From 0a701fb254e174a5c0391fe21a4864c301241c04 Mon Sep 17 00:00:00 2001 From: Stefan Schimanski Date: Tue, 22 Jan 2008 21:23:41 +0000 Subject: [PATCH 1/1] * Option to make macro editing less "noisy" by hiding the grey box with the macro name when the cursor is inside. The downside of the coin is that you have to look into the statusbar to see which macro is used. But some people prefer that than having the slight size change of macros when the cursor enters. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@22650 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/LyXFunc.cpp | 1 + src/LyXRC.cpp | 21 +++++++++++++++++++++ src/LyXRC.h | 3 +++ src/frontends/qt4/GuiPrefs.cpp | 4 ++++ src/frontends/qt4/ui/PrefUi.ui | 11 +++++++++++ src/mathed/MathMacro.cpp | 22 ++++++++++++---------- 6 files changed, 52 insertions(+), 10 deletions(-) diff --git a/src/LyXFunc.cpp b/src/LyXFunc.cpp index 7a499f1dd7..6505661e7d 100644 --- a/src/LyXFunc.cpp +++ b/src/LyXFunc.cpp @@ -2254,6 +2254,7 @@ void actOnUpdatedPrefs(LyXRC const & lyxrc_orig, LyXRC const & lyxrc_new) case LyXRC::RC_SERVERPIPE: case LyXRC::RC_SET_COLOR: case LyXRC::RC_SHOW_BANNER: + case LyXRC::RC_SHOW_MACRO_LABEL: case LyXRC::RC_SPELL_COMMAND: case LyXRC::RC_TEMPDIRPATH: case LyXRC::RC_TEMPLATEPATH: diff --git a/src/LyXRC.cpp b/src/LyXRC.cpp index a4520de545..96e0dac284 100644 --- a/src/LyXRC.cpp +++ b/src/LyXRC.cpp @@ -137,6 +137,7 @@ keyword_item lyxrcTags[] = { { "\\serverpipe", LyXRC::RC_SERVERPIPE }, { "\\set_color", LyXRC::RC_SET_COLOR }, { "\\show_banner", LyXRC::RC_SHOW_BANNER }, + { "\\show_macro_label", LyXRC::RC_SHOW_MACRO_LABEL }, { "\\sort_layouts", LyXRC::RC_SORT_LAYOUTS }, { "\\spell_command", LyXRC::RC_SPELL_COMMAND }, { "\\tempdir_path", LyXRC::RC_TEMPDIRPATH }, @@ -260,6 +261,7 @@ void LyXRC::setDefaults() { tex_allows_spaces = false; date_insert_format = "%x"; cursor_follows_scrollbar = false; + show_macro_label = true; dialogs_iconify_with_main = false; label_init_length = 3; preview = PREVIEW_OFF; @@ -837,6 +839,12 @@ int LyXRC::read(Lexer & lexrc) } break; + case RC_SHOW_MACRO_LABEL: + if (lexrc.next()) { + show_macro_label = lexrc.getBool(); + } + break; + case RC_DIALOGS_ICONIFY_WITH_MAIN: if (lexrc.next()) { dialogs_iconify_with_main = lexrc.getBool(); @@ -1574,6 +1582,15 @@ void LyXRC::write(ostream & os, bool ignore_system_lyxrc, string const & name) c } if (tag != RC_LAST) break; + case RC_SHOW_MACRO_LABEL: + if (ignore_system_lyxrc || + show_macro_label + != system_lyxrc.show_macro_label) { + os << "\\show_macro_label " + << convert(show_macro_label) << '\n'; + } + if (tag != RC_LAST) + break; case RC_DIALOGS_ICONIFY_WITH_MAIN: if (ignore_system_lyxrc || dialogs_iconify_with_main @@ -2385,6 +2402,10 @@ string const LyXRC::getDescription(LyXRCTags tag) str = _("LyX normally doesn't update the cursor position if you move the scrollbar. Set to true if you'd prefer to always have the cursor on screen."); break; + case RC_SHOW_MACRO_LABEL: + str = _("Show a small box around a Math Macro with the macro name when the cursor is inside."); + break; + case RC_CUSTOM_EXPORT_COMMAND: break; diff --git a/src/LyXRC.h b/src/LyXRC.h index 3bc2465eef..bc2a25ec93 100644 --- a/src/LyXRC.h +++ b/src/LyXRC.h @@ -124,6 +124,7 @@ public: RC_SERVERPIPE, RC_SET_COLOR, RC_SHOW_BANNER, + RC_SHOW_MACRO_LABEL, RC_SPELL_COMMAND, RC_TEMPDIRPATH, RC_TEMPLATEPATH, @@ -341,6 +342,8 @@ public: /// bool cursor_follows_scrollbar; /// + bool show_macro_label; + /// bool dialogs_iconify_with_main; /// int label_init_length; diff --git a/src/frontends/qt4/GuiPrefs.cpp b/src/frontends/qt4/GuiPrefs.cpp index 4162afbb84..e8315e2a31 100644 --- a/src/frontends/qt4/GuiPrefs.cpp +++ b/src/frontends/qt4/GuiPrefs.cpp @@ -1621,6 +1621,8 @@ PrefUserInterface::PrefUserInterface(GuiPreferences * form, QWidget * parent) this, SIGNAL(changed())); connect(sortEnvironmentsCB, SIGNAL(clicked()), this, SIGNAL(changed())); + connect(showMacroLabelCB, SIGNAL(clicked()), + this, SIGNAL(changed())); connect(autoSaveSB, SIGNAL(valueChanged(int)), this, SIGNAL(changed())); connect(autoSaveCB, SIGNAL(clicked()), @@ -1643,6 +1645,7 @@ void PrefUserInterface::apply(LyXRC & rc) const rc.allow_geometry_session = allowGeometrySessionCB->isChecked(); rc.cursor_follows_scrollbar = cursorFollowsCB->isChecked(); rc.sort_layouts = sortEnvironmentsCB->isChecked(); + rc.show_macro_label = showMacroLabelCB->isChecked(); rc.autosave = autoSaveSB->value() * 60; rc.make_backup = autoSaveCB->isChecked(); rc.num_lastfiles = lastfilesSB->value(); @@ -1659,6 +1662,7 @@ void PrefUserInterface::update(LyXRC const & rc) allowGeometrySessionCB->setChecked(rc.allow_geometry_session); cursorFollowsCB->setChecked(rc.cursor_follows_scrollbar); sortEnvironmentsCB->setChecked(rc.sort_layouts); + showMacroLabelCB->setChecked(rc.show_macro_label); // convert to minutes int mins(rc.autosave / 60); if (rc.autosave && !mins) diff --git a/src/frontends/qt4/ui/PrefUi.ui b/src/frontends/qt4/ui/PrefUi.ui index 48ab043738..7749f37db8 100644 --- a/src/frontends/qt4/ui/PrefUi.ui +++ b/src/frontends/qt4/ui/PrefUi.ui @@ -214,6 +214,13 @@ p, li { white-space: pre-wrap; } + + + + Show a box with the macro name around Math Macros + + + @@ -317,6 +324,7 @@ p, li { white-space: pre-wrap; } uiFileED uiFilePB + tooltipCB allowGeometrySessionCB restoreCursorCB loadSessionCB @@ -324,6 +332,9 @@ p, li { white-space: pre-wrap; } autoSaveSB lastfilesSB cursorFollowsCB + sortEnvironmentsCB + showMacroLabelCB + pixmapCacheCB qt_helpers.h diff --git a/src/mathed/MathMacro.cpp b/src/mathed/MathMacro.cpp index 1ce711a747..0d9c0e904a 100644 --- a/src/mathed/MathMacro.cpp +++ b/src/mathed/MathMacro.cpp @@ -23,6 +23,7 @@ #include "Cursor.h" #include "support/debug.h" #include "LaTeXFeatures.h" +#include "LyXRC.h" #include "FuncStatus.h" #include "FuncRequest.h" #include "Undo.h" @@ -198,7 +199,7 @@ void MathMacro::metrics(MetricsInfo & mi, Dimension & dim) const macro_->unlock(); // calculate dimension with label while editing - if (editing_[mi.base.bv]) { + if (lyxrc.show_macro_label && editing_[mi.base.bv]) { FontInfo font = mi.base.font; augmentFont(font, from_ascii("lyxtex")); Dimension namedim; @@ -301,7 +302,7 @@ void MathMacro::draw(PainterInfo & pi, int x, int y) const for (size_t i = 0; i < nargs(); ++i) cell(i).setXY(*pi.base.bv, x, y); - if (editing_[pi.base.bv]) { + if (lyxrc.show_macro_label && editing_[pi.base.bv]) { // draw header and rectangle around FontInfo font = pi.base.font; augmentFont(font, from_ascii("lyxtex")); @@ -309,24 +310,25 @@ void MathMacro::draw(PainterInfo & pi, int x, int y) const font.setColor(Color_mathmacrolabel); Dimension namedim; mathed_string_dim(font, name(), namedim); -#if 0 - pi.pain.fillRectangle(x, y - dim.asc, 2 + namedim.width() + 2, dim.height(), Color_mathmacrobg); - pi.pain.text(x + 2, y, name(), font); - expx += 2 + namew + 2; -#endif + pi.pain.fillRectangle(x, y - dim.asc, dim.wid, 1 + namedim.height() + 1, Color_mathmacrobg); pi.pain.text(x + 1, y - dim.asc + namedim.asc + 2, name(), font); expx += (dim.wid - expanded_.cell(0).dimension(*pi.base.bv).width()) / 2; + } + if (editing_[pi.base.bv]) { pi.pain.enterMonochromeMode(Color_mathbg, Color_mathmacroblend); expanded_.cell(0).draw(pi, expx, expy); pi.pain.leaveMonochromeMode(); + + if (lyxrc.show_macro_label) + pi.pain.rectangle(x, y - dim.asc, dim.wid, + dim.height(), Color_mathmacroframe); } else expanded_.cell(0).draw(pi, expx, expy); - // draw frame while editing - if (editing_[pi.base.bv]) - pi.pain.rectangle(x, y - dim.asc, dim.wid, dim.height(), Color_mathmacroframe); + if (!lyxrc.show_macro_label) + drawMarkers(pi, x, y); } // edit mode changed? -- 2.39.5