]> git.lyx.org Git - features.git/commitdiff
* math macro toolbar can be made automatic
authorStefan Schimanski <sts@lyx.org>
Sun, 23 Dec 2007 00:47:37 +0000 (00:47 +0000)
committerStefan Schimanski <sts@lyx.org>
Sun, 23 Dec 2007 00:47:37 +0000 (00:47 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@22265 a592a061-630c-0410-9148-cb99ea01b6c8

lib/ui/default.ui
lib/ui/stdtoolbars.inc
src/LyXAction.cpp
src/ToolbarBackend.cpp
src/ToolbarBackend.h
src/frontends/qt4/GuiToolbars.cpp
src/frontends/qt4/GuiToolbars.h
src/frontends/qt4/GuiView.cpp
src/lfuns.h
src/mathed/MathMacroTemplate.cpp

index a099932d7e0ca861e37844859f8ade8f83ae6fe4..21ec83c0a725470eb5b7848f4aff7e167e883ac4 100644 (file)
@@ -25,6 +25,7 @@ Include "stdtoolbars.inc"
 # on: the toolbar is visible
 # off: the toolbar is not visible
 # math: the toolbar is visible only when in math
+# mathmacrotemplate: the toolbar is visible only when in a macro definition
 # table: the toolbar is visible only when in a table
 # top: the toolbar should be at the top of the window
 # bottom: the toolbar should be at the bottom of the window
@@ -39,6 +40,6 @@ Toolbars
        "table" "table,bottom"
        "math_panels" "math,bottom"
        "math" "math,bottom"
-       "math_macros" "off,bottom"
+       "mathmacrotemplate" "auto,mathmacrotemplate,bottom"
        "minibuffer" "off,bottom"
 End
index 4d5f251395d91fb3907a2b24a98af8a1711e8b66..538ca06f2b3359e21d3987d7f27f87fdf136f8cc 100644 (file)
@@ -164,7 +164,7 @@ ToolbarSet
                Item "Toggle Math Panels" "toolbar-toggle math_panels"
        End
 
-       Toolbar "math_macros" "Math Macros"
+       Toolbar "mathmacrotemplate" "Math Macros"
                Item "Remove Last Parameter" "math-macro-remove-param"
                Item "Append Parameter" "math-macro-add-param"
                 Separator
index 03ccd69384d5fbff974f428019f79be4af69c344..c1222ff06d97e615005ad708f8627440597fed07 100644 (file)
@@ -243,6 +243,7 @@ void LyXAction::init()
                { LFUN_MATH_MACRO_ADD_OPTIONAL_PARAM, "math-macro-add-optional-param", Noop, Math },
                { LFUN_MATH_MACRO_REMOVE_OPTIONAL_PARAM, "math-macro-remove-optional-param", Noop, Math },
                { LFUN_MATH_MACRO_ADD_GREEDY_OPTIONAL_PARAM, "math-macro-add-greedy-optional-param", Noop, Math },
+               { LFUN_IN_MATHMACROTEMPLATE, "in-mathmacrotemplate", Noop, Math },
                { LFUN_MENU_OPEN, "menu-open", NoBuffer, Buffer },
                { LFUN_META_PREFIX, "meta-prefix", NoBuffer, System },
                { LFUN_NEW_LINE, "new-line", Noop, Edit },
index 91eab84e1b19889e509da222f41ca5e4ae27e057..b789f1a9d9abfee78ab44b7025327f2ae8c1a89a 100644 (file)
@@ -295,6 +295,8 @@ void ToolbarBackend::readToolbarSettings(Lexer & lex)
                                flag = ToolbarInfo::MATH;
                        else if (!compare_ascii_no_case(*cit, "table"))
                                flag = ToolbarInfo::TABLE;
+                       else if (!compare_ascii_no_case(*cit, "mathmacrotemplate"))
+                               flag = ToolbarInfo::MATHMACROTEMPLATE;
                        else if (!compare_ascii_no_case(*cit, "review"))
                                flag = ToolbarInfo::REVIEW;
                        else if (!compare_ascii_no_case(*cit, "top"))
@@ -305,6 +307,8 @@ void ToolbarBackend::readToolbarSettings(Lexer & lex)
                                flag = ToolbarInfo::LEFT;
                        else if (!compare_ascii_no_case(*cit, "right"))
                                flag = ToolbarInfo::RIGHT;
+                       else if (!compare_ascii_no_case(*cit, "auto"))
+                               flag = ToolbarInfo::AUTO;                       
                        else {
                                LYXERR(Debug::ANY,
                                        "ToolbarBackend::readToolbarSettings: unrecognised token:`"
index 95dc8900b726e9021a1ff9aabf19d1907c8ccb57..87162e8d589e3364f972bc7c8d4a992d22b152c2 100644 (file)
@@ -77,7 +77,8 @@ public:
                LEFT = 64, //< show at left
                RIGHT = 128, //< show at right
                REVIEW = 256, //< show when change tracking is enabled
-               AUTO = 512  //< only if AUTO is set, when MATH, TABLE and REVIEW is used
+               AUTO = 512,  //< only if AUTO is set, when MATH, TABLE and REVIEW is used
+               MATHMACROTEMPLATE = 1024 //< show in math macro
        };
        /// the toolbar items
        typedef std::vector<ToolbarItem> Items;
index adad497065508ed643f83611bba869497abcfb2a..ea8f764b759534e09cd38f8cebe7518b9d102d10 100644 (file)
@@ -208,7 +208,8 @@ void GuiToolbars::toggleToolbarState(string const & name, bool allowauto)
        } else if (allowauto 
                   && ((flags & ToolbarInfo::MATH) 
                       || (flags & ToolbarInfo::TABLE)
-                      || (flags & ToolbarInfo::REVIEW))) {
+                      || (flags & ToolbarInfo::REVIEW)
+                                        || (flags & ToolbarInfo::MATHMACROTEMPLATE))) {
                // for math etc, toggle from on -> auto
                TurnOffFlag(ON);
                TurnOnFlag(AUTO);
@@ -223,7 +224,8 @@ void GuiToolbars::toggleToolbarState(string const & name, bool allowauto)
 #undef TurnOffFlag
 
 
-void GuiToolbars::update(bool in_math, bool in_table, bool review)
+void GuiToolbars::update(bool in_math, bool in_table, bool review, 
+       bool in_mathmacrotemplate)
 {
        updateIcons();
 
@@ -241,7 +243,9 @@ void GuiToolbars::update(bool in_math, bool in_table, bool review)
                else if ((cit->flags & ToolbarInfo::AUTO) && (cit->flags & ToolbarInfo::TABLE))
                        displayToolbar(*cit, in_table);
                else if ((cit->flags & ToolbarInfo::AUTO) && (cit->flags & ToolbarInfo::REVIEW))
-                       displayToolbar(*cit, review);
+                       displayToolbar(*cit, review);   
+               else if ((cit->flags & ToolbarInfo::AUTO) && (cit->flags & ToolbarInfo::MATHMACROTEMPLATE))
+                       displayToolbar(*cit, in_mathmacrotemplate);
        }
 }
 
index c7ffc66eaa7fe3d7c735ac4446ea1281bf9951d0..28d36a3ffd205b3f945b5fe543f832f8297af65c 100644 (file)
@@ -50,7 +50,8 @@ public:
        void toggleToolbarState(std::string const & name, bool allowauto);
 
        /// Update the state of the toolbars.
-       void update(bool in_math, bool in_table, bool review);
+       void update(bool in_math, bool in_table, bool review, 
+                                                       bool in_mathmacrotemplate);
 
        /// Is the Toolbar currently visible?
        bool visible(std::string const & name) const;
index c24b93d21d2000e27116cd3abdb37cb40c1d1508..2cd0f881530816c915c87716cde315031972eb47 100644 (file)
@@ -787,10 +787,12 @@ void GuiView::updateToolbars()
                bool const review =
                        lyx::getStatus(FuncRequest(LFUN_CHANGES_TRACK)).enabled() &&
                        lyx::getStatus(FuncRequest(LFUN_CHANGES_TRACK)).onoff(true);
-
-               d.toolbars_->update(math, table, review);
+               bool const mathmacrotemplate =
+                       lyx::getStatus(FuncRequest(LFUN_IN_MATHMACROTEMPLATE)).enabled();
+               
+               d.toolbars_->update(math, table, review, mathmacrotemplate);
        } else
-               d.toolbars_->update(false, false, false);
+               d.toolbars_->update(false, false, false, false);
 
        // update read-only status of open dialogs.
        checkStatus();
index b62de88a7f3815b46f860ec94b50a648fb6da619..add94e5c28ca05a085e7ec94c773ce84049caa0f 100644 (file)
@@ -475,6 +475,7 @@ enum kb_action {
 
        // 315
        LFUN_MATH_MACRO_ADD_GREEDY_OPTIONAL_PARAM,
+       LFUN_IN_MATHMACROTEMPLATE,
        LFUN_LASTACTION                  // end of the table
 };
 
index 6b7493de7f97f33833316a4ea47a0cb397b56c2d..93ad7e328905a5909b5a6a55c141de23f90c655c 100644 (file)
@@ -645,6 +645,10 @@ bool MathMacroTemplate::getStatus(Cursor & /*cur*/, FuncRequest const & cmd,
                        flag.enabled(numargs_ == 0 
                                     && type_ != MacroTypeDef);
                        break;
+                       
+               case LFUN_IN_MATHMACROTEMPLATE:
+                       flag.enabled();
+                       break;
 
                default:
                        ret = false;