]> git.lyx.org Git - lyx.git/commitdiff
* Option to make macro editing less "noisy" by hiding the grey box with the
authorStefan Schimanski <sts@lyx.org>
Tue, 22 Jan 2008 21:23:41 +0000 (21:23 +0000)
committerStefan Schimanski <sts@lyx.org>
Tue, 22 Jan 2008 21:23:41 +0000 (21:23 +0000)
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
src/LyXRC.cpp
src/LyXRC.h
src/frontends/qt4/GuiPrefs.cpp
src/frontends/qt4/ui/PrefUi.ui
src/mathed/MathMacro.cpp

index 7a499f1dd773d65bab9ccd80c4674087aa659794..6505661e7d3b93c9f6e120bad4c4b1b83e14f21f 100644 (file)
@@ -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:
index a4520de545474812293b38f58edfb0fc3b621b73..96e0dac284e635b774ffcecaaab1857b0c6546bc 100644 (file)
@@ -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<string>(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;
 
index 3bc2465eefa9f688c53ff71007046b37e2d6aa57..bc2a25ec93245f44b3af03c178910d3b31236594 100644 (file)
@@ -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;
index 4162afbb8499303db9e98a55aa009506731c29c1..e8315e2a31a592a204ac99104c3fec1089ff2372 100644 (file)
@@ -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)
index 48ab043738151248fc1475beb364a01dd906d316..7749f37db88005747e6b016269444dd3300534fc 100644 (file)
@@ -214,6 +214,13 @@ p, li { white-space: pre-wrap; }
         </property>
        </widget>
       </item>
+      <item row="2" column="0" >
+       <widget class="QCheckBox" name="showMacroLabelCB" >
+        <property name="text" >
+         <string>Show a box with the macro name around Math Macros</string>
+        </property>
+       </widget>
+      </item>
      </layout>
     </widget>
    </item>
@@ -317,6 +324,7 @@ p, li { white-space: pre-wrap; }
  <tabstops>
   <tabstop>uiFileED</tabstop>
   <tabstop>uiFilePB</tabstop>
+  <tabstop>tooltipCB</tabstop>
   <tabstop>allowGeometrySessionCB</tabstop>
   <tabstop>restoreCursorCB</tabstop>
   <tabstop>loadSessionCB</tabstop>
@@ -324,6 +332,9 @@ p, li { white-space: pre-wrap; }
   <tabstop>autoSaveSB</tabstop>
   <tabstop>lastfilesSB</tabstop>
   <tabstop>cursorFollowsCB</tabstop>
+  <tabstop>sortEnvironmentsCB</tabstop>
+  <tabstop>showMacroLabelCB</tabstop>
+  <tabstop>pixmapCacheCB</tabstop>
  </tabstops>
  <includes>
   <include location="local" >qt_helpers.h</include>
index 1ce711a7478026f1450b8a48b6ed4ecbbf800ed0..0d9c0e904a125b7c54628c8687449d119796153f 100644 (file)
@@ -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?