From: Jean-Marc Lasgouttes Date: Fri, 19 Jul 2002 21:44:14 +0000 (+0000) Subject: toggleInset improvement; make lyxpreview work out of the box (?); apply aspect ratio... X-Git-Tag: 1.6.10~18811 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=f6fa51549106d7bab3e0d26dad29dc9151e575f6;p=features.git toggleInset improvement; make lyxpreview work out of the box (?); apply aspect ratio patch, with a part disabled (angus, help!) git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@4714 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/lib/ChangeLog b/lib/ChangeLog index f55c6a4ff3..e0f006b377 100644 --- a/lib/ChangeLog +++ b/lib/ChangeLog @@ -1,6 +1,13 @@ +2002-07-19 Jean-Marc Lasgouttes + + * configure.m4: fix definition of the lyxpreview2ppm converter; + add ppm format. All should work out of the box now, even though + all may not be pretty + 2002-07-18 Angus Leeming - * lyxpreview2ppm.sh: clean-up. Get it to work with scary_eqns.lyx. + * scripts/lyxpreview2ppm.sh: clean-up. Get it to work with + scary_eqns.lyx. 2002-07-17 André Pönitz diff --git a/lib/configure.m4 b/lib/configure.m4 index 974808a33e..b0c7a2b1fb 100644 --- a/lib/configure.m4 +++ b/lib/configure.m4 @@ -270,9 +270,8 @@ test $dvi_to_ps_command = "dvips" && dvi_to_ps_command="dvips -o \$\$o \$\$i" SEARCH_PROG([for a DVI to PDF converter],dvi_to_pdf_command,dvipdfm) test $dvi_to_pdf_command = "dvipdfm" && dvi_to_pdf_command="dvipdfm \$\$i" -# Search for a program to convert previewlyx to eps -SEARCH_PROG([for a LyX preview converter],lyxpreview_to_xpm_command,lyxpreview2xpm.sh) -test $lyxpreview_to_xpm_command = "lyxpreview2xpm.sh" && lyxpreview_to_xpm_command="lyxpreview2xpm.sh \$\$i \$\$o" +# We have a script to convert previewlyx to ppm +lyxpreview_to_ppm_command="lyxpreview2ppm.sh" # Search a *roff program (used to translate tables in ASCII export) LYXRC_PROG([for a *roff formatter], \ascii_roff_command, dnl @@ -449,13 +448,14 @@ cat >$outfile <$outfile < + + * text2.C (toggleInset): if cursor is inside an inset, close the + inset and leave cursor _after_ it + 2002-07-19 John Levon * lyxfunc.C: move minibuffer completion handling out of here diff --git a/src/frontends/xforms/ChangeLog b/src/frontends/xforms/ChangeLog index 3ec1c34e3b..15c1720270 100644 --- a/src/frontends/xforms/ChangeLog +++ b/src/frontends/xforms/ChangeLog @@ -1,3 +1,8 @@ +2002-04-28 Herbert Voss + + * FormGraphics.C: + * forms/form_graphics.fd: add a new check button for LyXAspectRatio. + 2002-07-19 John Levon * DropDown.h: diff --git a/src/frontends/xforms/FormGraphics.C b/src/frontends/xforms/FormGraphics.C index af7451faea..22d9e46ab5 100644 --- a/src/frontends/xforms/FormGraphics.C +++ b/src/frontends/xforms/FormGraphics.C @@ -132,6 +132,7 @@ void FormGraphics::build() bc().addReadOnly(lyxview_->radio_gray); bc().addReadOnly(lyxview_->radio_color); bc().addReadOnly(lyxview_->radio_nodisplay); + bc().addReadOnly(lyxview_->check_lyxaspectratio); // the size section size_.reset(build_graphics_size(this)); @@ -252,6 +253,7 @@ void FormGraphics::apply() lyxview_->choice_lyxheight); igp.lyxscale = strToInt(getStringFromInput(lyxview_->input_lyxscale)); + igp.keepLyXAspectRatio = fl_get_button(lyxview_->check_lyxaspectratio); // the size section if (fl_get_button(size_->radio_asis)) @@ -361,6 +363,7 @@ void FormGraphics::update() { setEnabled(lyxview_->choice_lyxwidth, 0); setEnabled(lyxview_->input_lyxheight, 0); setEnabled(lyxview_->choice_lyxheight, 0); + setEnabled(lyxview_->check_lyxaspectratio, 0); setEnabled(lyxview_->input_lyxscale, 0); break; } @@ -370,6 +373,7 @@ void FormGraphics::update() { setEnabled(lyxview_->choice_lyxwidth, 1); setEnabled(lyxview_->input_lyxheight, 1); setEnabled(lyxview_->choice_lyxheight, 1); + setEnabled(lyxview_->check_lyxaspectratio, 1); setEnabled(lyxview_->input_lyxscale, 0); break; } @@ -379,11 +383,14 @@ void FormGraphics::update() { setEnabled(lyxview_->choice_lyxwidth, 0); setEnabled(lyxview_->input_lyxheight, 0); setEnabled(lyxview_->choice_lyxheight, 0); + setEnabled(lyxview_->check_lyxaspectratio, 0); setEnabled(lyxview_->input_lyxscale, 1); break; } } + fl_set_button(lyxview_->check_lyxaspectratio, igp.keepLyXAspectRatio); + // the size section // Update the draft and clip mode updateWidgetsFromLength(size_->input_width, @@ -530,18 +537,21 @@ ButtonPolicy::SMInput FormGraphics::input(FL_OBJECT * ob, long) setEnabled(lyxview_->choice_lyxwidth, 0); setEnabled(lyxview_->input_lyxheight, 0); setEnabled(lyxview_->choice_lyxheight, 0); + setEnabled(lyxview_->check_lyxaspectratio, 0); setEnabled(lyxview_->input_lyxscale, 0); } else if (ob == lyxview_->radio_lyxwh) { setEnabled(lyxview_->input_lyxwidth, 1); setEnabled(lyxview_->choice_lyxwidth, 1); setEnabled(lyxview_->input_lyxheight, 1); setEnabled(lyxview_->choice_lyxheight, 1); + setEnabled(lyxview_->check_lyxaspectratio, 1); setEnabled(lyxview_->input_lyxscale, 0); } else if (ob == lyxview_->radio_lyxscale) { setEnabled(lyxview_->input_lyxwidth, 0); setEnabled(lyxview_->choice_lyxwidth, 0); setEnabled(lyxview_->input_lyxheight, 0); setEnabled(lyxview_->choice_lyxheight, 0); + setEnabled(lyxview_->check_lyxaspectratio, 0); setEnabled(lyxview_->input_lyxscale, 1); } else if (ob == lyxview_->button_latex_values) { if (contains(fl_get_choice_text(size_->choice_width),'%') || @@ -570,6 +580,7 @@ ButtonPolicy::SMInput FormGraphics::input(FL_OBJECT * ob, long) setEnabled(lyxview_->choice_lyxwidth, 0); setEnabled(lyxview_->input_lyxheight, 0); setEnabled(lyxview_->choice_lyxheight, 0); + setEnabled(lyxview_->check_lyxaspectratio, 0); setEnabled(lyxview_->input_lyxscale, 0); } else if (fl_get_button (size_->radio_wh) == 1) { fl_set_button (lyxview_->radio_lyxwh, 1); @@ -577,6 +588,7 @@ ButtonPolicy::SMInput FormGraphics::input(FL_OBJECT * ob, long) setEnabled(lyxview_->choice_lyxwidth, 1); setEnabled(lyxview_->input_lyxheight, 1); setEnabled(lyxview_->choice_lyxheight, 1); + setEnabled(lyxview_->check_lyxaspectratio, 1); setEnabled(lyxview_->input_lyxscale, 0); } else if (fl_get_button (size_->radio_scale) ==1) { fl_set_button (lyxview_->radio_lyxscale, 1); @@ -584,9 +596,12 @@ ButtonPolicy::SMInput FormGraphics::input(FL_OBJECT * ob, long) setEnabled(lyxview_->choice_lyxwidth, 0); setEnabled(lyxview_->input_lyxheight, 0); setEnabled(lyxview_->choice_lyxheight, 0); + setEnabled(lyxview_->check_lyxaspectratio, 0); setEnabled(lyxview_->input_lyxscale, 1); } } + fl_set_button(lyxview_->check_lyxaspectratio, + fl_get_button(size_->check_aspectratio)); // the bb section } else if (!controller().bbChanged && @@ -675,6 +690,8 @@ ButtonPolicy::SMInput FormGraphics::input(FL_OBJECT * ob, long) setEnabled(size_->check_aspectratio, 0); setEnabled(size_->input_scale, 1); } + fl_set_button(size_->check_aspectratio, + fl_get_button(lyxview_->check_lyxaspectratio)); } // check if the input is valid diff --git a/src/frontends/xforms/forms/form_graphics.fd b/src/frontends/xforms/forms/form_graphics.fd index 09e39a39a7..73e58f0282 100644 --- a/src/frontends/xforms/forms/form_graphics.fd +++ b/src/frontends/xforms/forms/form_graphics.fd @@ -442,7 +442,7 @@ argument: -------------------- class: FL_BEGIN_GROUP type: 0 -box: 0 0 0 0 +box: 0 10 10 0 boxtype: FL_NO_BOX colors: FL_COL1 FL_MCOL alignment: FL_ALIGN_CENTER @@ -453,7 +453,7 @@ label: shortcut: resize: FL_RESIZE_ALL gravity: FL_NoGravity FL_NoGravity -name: +name: callback: argument: @@ -923,7 +923,7 @@ argument: 0 Name: form_graphics_lyxview Width: 500 Height: 245 -Number of Objects: 23 +Number of Objects: 24 -------------------- class: FL_BOX @@ -1000,7 +1000,7 @@ argument: -------------------- class: FL_INPUT type: NORMAL_INPUT -box: 350 95 70 30 +box: 350 75 70 30 boxtype: FL_DOWN_BOX colors: FL_COL1 FL_MCOL alignment: FL_ALIGN_LEFT @@ -1018,7 +1018,7 @@ argument: 0 -------------------- class: FL_BEGIN_GROUP type: 0 -box: 0 0 0 0 +box: 0 10 10 0 boxtype: FL_NO_BOX colors: FL_COL1 FL_MCOL alignment: FL_ALIGN_CENTER @@ -1036,10 +1036,10 @@ argument: -------------------- class: FL_ROUND3DBUTTON type: RADIO_BUTTON -box: 255 25 30 30 +box: 170 25 30 30 boxtype: FL_NO_BOX colors: FL_COL1 FL_YELLOW -alignment: FL_ALIGN_LEFT +alignment: FL_ALIGN_RIGHT style: FL_NORMAL_STYLE size: FL_NORMAL_SIZE lcol: FL_BLACK @@ -1054,10 +1054,10 @@ argument: 0 -------------------- class: FL_ROUND3DBUTTON type: RADIO_BUTTON -box: 255 90 30 30 +box: 170 75 30 30 boxtype: FL_NO_BOX colors: FL_COL1 FL_YELLOW -alignment: FL_ALIGN_LEFT +alignment: FL_ALIGN_RIGHT style: FL_NORMAL_STYLE size: FL_NORMAL_SIZE lcol: FL_BLACK @@ -1072,10 +1072,10 @@ argument: 0 -------------------- class: FL_ROUND3DBUTTON type: RADIO_BUTTON -box: 255 155 30 30 +box: 170 140 30 30 boxtype: FL_NO_BOX colors: FL_COL1 FL_YELLOW -alignment: FL_ALIGN_LEFT +alignment: FL_ALIGN_RIGHT style: FL_NORMAL_STYLE size: FL_NORMAL_SIZE lcol: FL_BLACK @@ -1108,7 +1108,7 @@ argument: -------------------- class: FL_TEXT type: NORMAL_TEXT -box: 420 95 25 30 +box: 420 75 25 30 boxtype: FL_FLAT_BOX colors: FL_COL1 FL_MCOL alignment: FL_ALIGN_LEFT|FL_ALIGN_INSIDE @@ -1126,7 +1126,7 @@ argument: -------------------- class: FL_BEGIN_GROUP type: 0 -box: 0 0 0 0 +box: 0 10 10 0 boxtype: FL_NO_BOX colors: FL_COL1 FL_MCOL alignment: FL_ALIGN_CENTER @@ -1137,7 +1137,7 @@ label: shortcut: resize: FL_RESIZE_ALL gravity: FL_NoGravity FL_NoGravity -name: +name: callback: argument: @@ -1252,7 +1252,7 @@ argument: -------------------- class: FL_INPUT type: NORMAL_INPUT -box: 350 155 70 30 +box: 350 135 70 30 boxtype: FL_DOWN_BOX colors: FL_COL1 FL_MCOL alignment: FL_ALIGN_LEFT @@ -1270,7 +1270,7 @@ argument: 0 -------------------- class: FL_CHOICE type: NORMAL_CHOICE -box: 425 155 50 30 +box: 425 135 50 30 boxtype: FL_FRAME_BOX colors: FL_COL1 FL_BLACK alignment: FL_ALIGN_LEFT @@ -1288,7 +1288,7 @@ argument: 0 -------------------- class: FL_INPUT type: NORMAL_INPUT -box: 350 190 70 30 +box: 350 170 70 30 boxtype: FL_DOWN_BOX colors: FL_COL1 FL_MCOL alignment: FL_ALIGN_LEFT @@ -1306,7 +1306,7 @@ argument: 0 -------------------- class: FL_CHOICE type: NORMAL_CHOICE -box: 425 190 50 30 +box: 425 170 50 30 boxtype: FL_FRAME_BOX colors: FL_COL1 FL_BLACK alignment: FL_ALIGN_LEFT @@ -1339,5 +1339,23 @@ name: button_latex_values callback: C_FormBaseInputCB argument: 0 +-------------------- +class: FL_CHECKBUTTON +type: PUSH_BUTTON +box: 210 200 30 30 +boxtype: FL_NO_BOX +colors: FL_COL1 FL_YELLOW +alignment: FL_ALIGN_RIGHT +style: FL_NORMAL_STYLE +size: FL_NORMAL_SIZE +lcol: FL_BLACK +label: keep Aspect ratio|#A +shortcut: +resize: FL_RESIZE_ALL +gravity: FL_NoGravity FL_NoGravity +name: check_lyxaspectratio +callback: C_FormBaseInputCB +argument: 0 + ============================== -------------------- diff --git a/src/graphics/ChangeLog b/src/graphics/ChangeLog index bb99b48118..ddf0b89cea 100644 --- a/src/graphics/ChangeLog +++ b/src/graphics/ChangeLog @@ -1,3 +1,8 @@ +2002-07-19 Jean-Marc Lasgouttes + + * PreviewLoader.C (startLoading): use LibScriptSearch to find the + preview converter script + 2002-07-18 Jean-Marc Lasgouttes * GraphicsCacheItem.C (reset): use erase() instead of clear() for diff --git a/src/graphics/PreviewLoader.C b/src/graphics/PreviewLoader.C index a78005fe0a..ccdbaaca82 100644 --- a/src/graphics/PreviewLoader.C +++ b/src/graphics/PreviewLoader.C @@ -467,7 +467,7 @@ void PreviewLoader::Impl::startLoading() cs << pconverter_->command << " " << latexfile << " " << font_scaling_factor_; - string const command = cs.str().c_str(); + string const command = LibScriptSearch(cs.str().c_str()); // Initiate the conversion from LaTeX to bitmap images files. Forkedcall::SignalTypePtr convert_ptr; diff --git a/src/insets/ChangeLog b/src/insets/ChangeLog index f0f953a2de..2cbf2e0fac 100644 --- a/src/insets/ChangeLog +++ b/src/insets/ChangeLog @@ -1,3 +1,14 @@ +2002-07-19 Jean-Marc Lasgouttes + + * insetgraphicsParams.C (as_grfxParams): use the new + keepLyXAspectRatio parameter. Note that this is an adaptation of a + 1.2.0 patch, and I do not really know how to adapt it to the new + grfx::Cache world. Angus, please could you have a look? + +2002-05-01 Herbert Voss + + * insetgraphicsParams.[Ch]: define a new keepLyXAspectRatio parameter. + 2002-07-18 Angus Leeming * insetgraphics.C: clean-up comments (from Herbert). diff --git a/src/insets/insetgraphicsParams.C b/src/insets/insetgraphicsParams.C index 13952b2bd7..c9d31047f9 100644 --- a/src/insets/insetgraphicsParams.C +++ b/src/insets/insetgraphicsParams.C @@ -19,6 +19,7 @@ #include "insetgraphicsParams.h" #include "graphics/GraphicsParams.h" +#include "graphics/GraphicsCache.h" #include "support/translator.h" #include "support/filetools.h" @@ -98,6 +99,7 @@ void InsetGraphicsParams::init() lyxscale = 0; // same for lyxview size_type = DEFAULT_SIZE; // do nothing lyxsize_type = DEFAULT_SIZE; // do nothing + keepLyXAspectRatio = false; // only for LyXview keepAspectRatio = false; // only for latex rotate = false; // Rotating rotateOrigin = "center"; // Origin @@ -123,6 +125,7 @@ void InsetGraphicsParams::copy(InsetGraphicsParams const & igp) lyxsize_type = igp.lyxsize_type; lyxwidth = igp.lyxwidth; lyxheight = igp.lyxheight; + keepLyXAspectRatio = igp.keepLyXAspectRatio; lyxscale = igp.lyxscale; rotate = igp.rotate; rotateOrigin = igp.rotateOrigin; @@ -149,6 +152,7 @@ bool operator==(InsetGraphicsParams const & left, left.lyxsize_type == right.lyxsize_type && left.lyxwidth == right.lyxwidth && left.lyxheight == right.lyxheight && + left.keepLyXAspectRatio == right.keepLyXAspectRatio && left.lyxscale == right.lyxscale && left.rotate == right.rotate && left.rotateOrigin == right.rotateOrigin && @@ -215,6 +219,8 @@ void InsetGraphicsParams::Write(ostream & os) const os << "\tlyxwidth " << lyxwidth.asString() << '\n'; if (!lyxheight.zero()) os << "\tlyxheight " << lyxheight.asString(); + if (keepLyXAspectRatio) + os << "\tkeepLyXAspectRatio\n"; if (lyxscale != 0) os << "\tlyxscale " << lyxscale << '\n'; } @@ -296,6 +302,8 @@ bool InsetGraphicsParams::Read(LyXLex & lex, string const & token) } else if (token == "lyxheight") { lex.next(); lyxheight = LyXLength(lex.getString()); + } else if (token == "keepLyXAspectRatio") { + keepLyXAspectRatio = true; } else if (token == "lyxscale") { lex.next(); lyxscale = lex.getInteger(); @@ -401,6 +409,30 @@ grfx::Params InsetGraphicsParams::as_grfxParams(string const & filepath) const double const scaling_factor = 100.0 / double(lyxrc.zoom); pars.width = uint(scaling_factor * pars.width); pars.height = uint(scaling_factor * pars.height); + +#if 0 +#warning Angus, could you please adapt this code? (JMarc) + if (keepLyXAspectRatio) { + // get the imagesize from the cache + grfx::Cache & gc = grfx::Cache::get(); + float const rw = gc.raw_width(filename); + float const rh = gc.raw_height(filename); + float const ratio = (rw > 0.001) ? rh/rw : 1.0; + lyxerr[Debug::GRAPHICS] + << "Value of LyXAspectRatio: " + << ratio << std::endl; + if (!lyxwidth.zero() && !lyxheight.zero()) { + if (width < height) + height = int(ratio * width); + else + width = int(ratio * height); + } else if (lyxwidth.zero()) + width = int(ratio * height); + else if (lyxheight.zero()) + height = int(ratio * width); + } +#endif } + return pars; } diff --git a/src/insets/insetgraphicsParams.h b/src/insets/insetgraphicsParams.h index 1591b5980b..3fae9694e2 100644 --- a/src/insets/insetgraphicsParams.h +++ b/src/insets/insetgraphicsParams.h @@ -83,6 +83,8 @@ struct InsetGraphicsParams LyXLength lyxwidth; /// LyXLength lyxheight; + /// Keep the ratio between lyxheight and lyxwidth when resizing. + bool keepLyXAspectRatio; /// Typ of rescaling the Screen inside lyx int lyxscale; /// diff --git a/src/text2.C b/src/text2.C index 80c9a487cb..896e2a97dd 100644 --- a/src/text2.C +++ b/src/text2.C @@ -431,6 +431,7 @@ void LyXText::toggleInset(BufferView * bview) && inset_owner->owner()->isOpen()) { bview->unlockInset(static_cast(inset_owner->owner())); inset_owner->owner()->close(bview); + bview->getLyXText()->cursorRight(bview); } return; }