diff --git a/src/frontends/xforms/FormGraphics.C b/src/frontends/xforms/FormGraphics.C index 7cd6ceb015..eeb3ad7769 100644 --- a/src/frontends/xforms/FormGraphics.C +++ b/src/frontends/xforms/FormGraphics.C @@ -131,6 +131,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_size()); @@ -251,6 +252,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)) @@ -360,6 +362,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; } @@ -369,6 +372,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; } @@ -378,11 +382,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, @@ -529,18 +536,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),'%')) @@ -568,6 +578,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); @@ -575,6 +586,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); @@ -582,9 +594,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 && @@ -673,6 +688,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/form_graphics.C b/src/frontends/xforms/form_graphics.C index 1ad1866030..d7542dd941 100644 --- a/src/frontends/xforms/form_graphics.C +++ b/src/frontends/xforms/form_graphics.C @@ -405,7 +405,7 @@ FD_form_lyxview * FormGraphics::build_lyxview() fl_set_object_lsize(obj, FL_NORMAL_SIZE); { char const * const dummy = N_("Value|#V"); - fdui->input_lyxscale = obj = fl_add_input(FL_NORMAL_INPUT, 350, 95, 70, 30, idex(_(dummy))); + fdui->input_lyxscale = obj = fl_add_input(FL_NORMAL_INPUT, 350, 75, 70, 30, idex(_(dummy))); fl_set_button_shortcut(obj, scex(_(dummy)), 1); } fl_set_object_lsize(obj, FL_NORMAL_SIZE); @@ -413,35 +413,35 @@ FD_form_lyxview * FormGraphics::build_lyxview() fl_bgn_group(); { char const * const dummy = N_("Original size|#O"); - fdui->radio_lyxasis = obj = fl_add_round3dbutton(FL_RADIO_BUTTON, 255, 25, 30, 30, idex(_(dummy))); + fdui->radio_lyxasis = obj = fl_add_round3dbutton(FL_RADIO_BUTTON, 170, 25, 30, 30, idex(_(dummy))); fl_set_button_shortcut(obj, scex(_(dummy)), 1); } fl_set_object_color(obj, FL_COL1, FL_YELLOW); fl_set_object_lsize(obj, FL_NORMAL_SIZE); - fl_set_object_lalign(obj, FL_ALIGN_LEFT); + fl_set_object_lalign(obj, FL_ALIGN_RIGHT); fl_set_object_callback(obj, C_FormBaseInputCB, 0); { char const * const dummy = N_("Scale|#S"); - fdui->radio_lyxscale = obj = fl_add_round3dbutton(FL_RADIO_BUTTON, 255, 90, 30, 30, idex(_(dummy))); + fdui->radio_lyxscale = obj = fl_add_round3dbutton(FL_RADIO_BUTTON, 170, 75, 30, 30, idex(_(dummy))); fl_set_button_shortcut(obj, scex(_(dummy)), 1); } fl_set_object_color(obj, FL_COL1, FL_YELLOW); fl_set_object_lsize(obj, FL_NORMAL_SIZE); - fl_set_object_lalign(obj, FL_ALIGN_LEFT); + fl_set_object_lalign(obj, FL_ALIGN_RIGHT); fl_set_object_callback(obj, C_FormBaseInputCB, 0); { char const * const dummy = N_("Custom|#u"); - fdui->radio_lyxwh = obj = fl_add_round3dbutton(FL_RADIO_BUTTON, 255, 155, 30, 30, idex(_(dummy))); + fdui->radio_lyxwh = obj = fl_add_round3dbutton(FL_RADIO_BUTTON, 170, 140, 30, 30, idex(_(dummy))); fl_set_button_shortcut(obj, scex(_(dummy)), 1); } fl_set_object_color(obj, FL_COL1, FL_YELLOW); fl_set_object_lsize(obj, FL_NORMAL_SIZE); - fl_set_object_lalign(obj, FL_ALIGN_LEFT); + fl_set_object_lalign(obj, FL_ALIGN_RIGHT); fl_set_object_callback(obj, C_FormBaseInputCB, 0); fl_end_group(); // xgettext:no-c-format - obj = fl_add_text(FL_NORMAL_TEXT, 420, 95, 25, 30, _("%")); + obj = fl_add_text(FL_NORMAL_TEXT, 420, 75, 25, 30, _("%")); fl_set_object_lsize(obj, FL_NORMAL_SIZE); fl_set_object_lalign(obj, FL_ALIGN_LEFT|FL_ALIGN_INSIDE); fl_bgn_group(); @@ -489,23 +489,23 @@ FD_form_lyxview * FormGraphics::build_lyxview() { char const * const dummy = N_("Width|#W"); - fdui->input_lyxwidth = obj = fl_add_input(FL_NORMAL_INPUT, 350, 155, 70, 30, idex(_(dummy))); + fdui->input_lyxwidth = obj = fl_add_input(FL_NORMAL_INPUT, 350, 135, 70, 30, idex(_(dummy))); fl_set_button_shortcut(obj, scex(_(dummy)), 1); } fl_set_object_lsize(obj, FL_NORMAL_SIZE); fl_set_object_callback(obj, C_FormBaseInputCB, 0); - fdui->choice_lyxwidth = obj = fl_add_choice(FL_NORMAL_CHOICE, 425, 155, 50, 30, ""); + fdui->choice_lyxwidth = obj = fl_add_choice(FL_NORMAL_CHOICE, 425, 135, 50, 30, ""); fl_set_object_boxtype(obj, FL_FRAME_BOX); fl_set_object_lsize(obj, FL_NORMAL_SIZE); fl_set_object_callback(obj, C_FormBaseInputCB, 0); { char const * const dummy = N_("Height|#H"); - fdui->input_lyxheight = obj = fl_add_input(FL_NORMAL_INPUT, 350, 190, 70, 30, idex(_(dummy))); + fdui->input_lyxheight = obj = fl_add_input(FL_NORMAL_INPUT, 350, 170, 70, 30, idex(_(dummy))); fl_set_button_shortcut(obj, scex(_(dummy)), 1); } fl_set_object_lsize(obj, FL_NORMAL_SIZE); fl_set_object_callback(obj, C_FormBaseInputCB, 0); - fdui->choice_lyxheight = obj = fl_add_choice(FL_NORMAL_CHOICE, 425, 190, 50, 30, ""); + fdui->choice_lyxheight = obj = fl_add_choice(FL_NORMAL_CHOICE, 425, 170, 50, 30, ""); fl_set_object_boxtype(obj, FL_FRAME_BOX); fl_set_object_lsize(obj, FL_NORMAL_SIZE); fl_set_object_callback(obj, C_FormBaseInputCB, 0); @@ -516,6 +516,14 @@ FD_form_lyxview * FormGraphics::build_lyxview() } fl_set_object_lsize(obj, FL_NORMAL_SIZE); fl_set_object_callback(obj, C_FormBaseInputCB, 0); + { + char const * const dummy = N_("keep Aspect ratio|#A"); + fdui->check_lyxaspectratio = obj = fl_add_checkbutton(FL_PUSH_BUTTON, 210, 200, 30, 30, idex(_(dummy))); + fl_set_button_shortcut(obj, scex(_(dummy)), 1); + } + fl_set_object_lsize(obj, FL_NORMAL_SIZE); + fl_set_object_lalign(obj, FL_ALIGN_RIGHT); + fl_set_object_callback(obj, C_FormBaseInputCB, 0); fl_end_form(); fdui->form->fdui = fdui; diff --git a/src/frontends/xforms/form_graphics.h b/src/frontends/xforms/form_graphics.h index ea3af23e98..092e3a90e7 100644 --- a/src/frontends/xforms/form_graphics.h +++ b/src/frontends/xforms/form_graphics.h @@ -99,6 +99,7 @@ struct FD_form_lyxview { FL_OBJECT *input_lyxheight; FL_OBJECT *choice_lyxheight; FL_OBJECT *button_latex_values; + FL_OBJECT *check_lyxaspectratio; }; #endif /* FD_form_graphics_h_ */ diff --git a/src/frontends/xforms/forms/form_graphics.fd b/src/frontends/xforms/forms/form_graphics.fd index 4b3942c47e..68dd7719fc 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_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 dd6f44acfa..b40c3b3984 100644 --- a/src/graphics/ChangeLog +++ b/src/graphics/ChangeLog @@ -1,3 +1,8 @@ +2002-05-01 Herbert Voss + + * GraphicsParams.C (GParams c-tor): use the new keepLyXAspectRatio + parameter. + 2002-07-01 Jean-Marc Lasgouttes * GraphicsConverter.C (convert): do not use ChangeExtension diff --git a/src/graphics/GraphicsParams.C b/src/graphics/GraphicsParams.C index e2782973d7..116b2f9687 100644 --- a/src/graphics/GraphicsParams.C +++ b/src/graphics/GraphicsParams.C @@ -13,6 +13,7 @@ #endif #include "GraphicsParams.h" +#include "GraphicsCache.h" #include "insets/insetgraphicsParams.h" #include "lyxrc.h" #include "debug.h" @@ -112,6 +113,27 @@ GParams::GParams(InsetGraphicsParams const & iparams, string const & filepath) double const scaling_factor = 100.0 / double(lyxrc.zoom); width = uint(scaling_factor * width); height = uint(scaling_factor * height); + + if (iparams.keepLyXAspectRatio) { + // get the imagesize from the cache + grfx::GCache & gc = grfx::GCache::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 (!iparams.lyxwidth.zero() && + !iparams.lyxheight.zero()) { + if (width < height) + height = int(ratio * width); + else + width = int(ratio * height); + } else if (iparams.lyxwidth.zero()) + width = int(ratio * height); + else if (iparams.lyxheight.zero()) + height = int(ratio * width); + } } } diff --git a/src/insets/ChangeLog b/src/insets/ChangeLog index 60c5f071fa..3b53abedaa 100644 --- a/src/insets/ChangeLog +++ b/src/insets/ChangeLog @@ -1,3 +1,7 @@ +2002-05-01 Herbert Voss + + * insetgraphicsParams.[Ch]: define a new keepLyXAspectRatio parameter. + 2002-07-01 Claus Hentschel * insetgraphics.C (latex): make sure file name is in os native diff --git a/src/insets/insetgraphicsParams.C b/src/insets/insetgraphicsParams.C index 1cb34265cb..22d579ca83 100644 --- a/src/insets/insetgraphicsParams.C +++ b/src/insets/insetgraphicsParams.C @@ -93,6 +93,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 @@ -118,6 +119,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; @@ -144,6 +146,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 && @@ -210,6 +213,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'; } @@ -291,6 +296,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(); diff --git a/src/insets/insetgraphicsParams.h b/src/insets/insetgraphicsParams.h index 4845e74594..5a227dca3a 100644 --- a/src/insets/insetgraphicsParams.h +++ b/src/insets/insetgraphicsParams.h @@ -79,6 +79,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/status.12x b/status.12x index e84c16a7de..89734204f4 100644 --- a/status.12x +++ b/status.12x @@ -20,6 +20,8 @@ What's new ** Updates +- new option 'keep aspect ratio' in graphics dialog + - update finnish, danish, french and russian localizations - update Tutorial to be more up to date