From: Edwin Leuven Date: Wed, 23 May 2007 22:08:07 +0000 (+0000) Subject: - introduces toolbar_toggle lfun X-Git-Tag: 1.6.10~9654 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=630fe09637d2ec718df16442b5468748cae0d455;p=features.git - introduces toolbar_toggle lfun - adds a "toggle math toolbar" and "toggle table toolbar" buttons to the main toolbar (i also moved "toggle toc" there) - adds a "toggle math panels" button to the math toolbar - reshuffles the Big Operators panel to avoid confusion with the sum icon on the math toolbar - adds some icons git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@18478 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/lib/images/attic/dialog-show_mathpanel.xpm b/lib/images/attic/dialog-show_mathpanel.xpm deleted file mode 100644 index ef091c8741..0000000000 --- a/lib/images/attic/dialog-show_mathpanel.xpm +++ /dev/null @@ -1,30 +0,0 @@ -/* XPM */ -static char * math_panel_xpm[] = { -"20 20 7 1", -" c None", -". c #777777", -"+ c #C9C9C9", -"@ c #919191", -"# c #606060", -"$ c #24238E", -"% c #000000", -".................+@ ", -"..+++++++++++++++@@#", -".+ $$ @@#", -".+ $$$ $ $$ @@#", -".+$$ $ $ $$$@@#", -".+$ $$ $ $$ $@@#", -".+$ $ $ $ $@@#", -".+$$$$ $$$ @@#", -".+ @@#", -".+%%%%%%%%%%%%%%%@@#", -".+ @@#", -".+ $$$ @@#", -".+ $$ $$ @@#", -".+ $ @@#", -".+ $$ @@#", -".+ $$$ @@#", -"+@@@@@@ @@@@@@@@#", -"@@@@@@@@@@@@@@@@@@##", -" ###################", -" "}; diff --git a/lib/images/tabular-insert.xpm b/lib/images/tabular-insert.xpm index 5dc636fd4e..036b79b90b 100644 --- a/lib/images/tabular-insert.xpm +++ b/lib/images/tabular-insert.xpm @@ -1,31 +1,30 @@ /* XPM */ static char *show-dialog-new-inset_tabular[] = { /* columns rows colors chars-per-pixel */ -"22 22 3 1", +"20 20 4 1", " c #000000", ". c #ffffff", +"D c Red", "X c None", /* pixels */ -"XXXXXXXXXXXXXXXXXXXXXX", -"XXXXXXXXXXXXXXXXXXXXXX", -"XXXXXXXXXXXXXXXXXXXXXX", -"XXX XXX", -"XXX .... .... .... XXX", -"XXX .... .... .... XXX", -"XXX XXX", -"XXX .... .... .... XXX", -"XXX .... .... .... XXX", -"XXX XXX", -"XXX .... .... .... XXX", -"XXX .... .... .... XXX", -"XXX XXX", -"XXX .... .... .... XXX", -"XXX .... .... .... XXX", -"XXX XXX", -"XXX .... .... .... XXX", -"XXX .... .... .... XXX", -"XXX XXX", -"XXXXXXXXXXXXXXXXXXXXXX", -"XXXXXXXXXXXXXXXXXXXXXX", -"XXXXXXXXXXXXXXXXXXXXXX" +"XXXXXXXXXXXXXXXXXXXX", +"XXXXXXXXXXXXXXXXXXXX", +"XXXXXXXXXXXXXXXXXXXX", +"XX XXX", +"XX .... .... ....XXX", +"XX .... .... ....XXX", +"XX XXX", +"XX .... .... ....XXX", +"XX .... .... ....XXX", +"XX XXX", +"XX .... .... ....XXX", +"XX .... .... ....XXX", +"XX XXX", +"XX .... .... ....XXX", +"XX .... .... ....XXX", +"XXXXXXXXXXXXXXXXXXXX", +"XXXXXXXXXXXXXXXXXXXX", +"XXXXXXXXXXXXXX X", +"XXXXXXXXXXXXXXX XX", +"XXXXXXXXXXXXXXXX XXX" }; diff --git a/lib/images/toolbar-toggle_math.xpm b/lib/images/toolbar-toggle_math.xpm new file mode 100644 index 0000000000..76b9160d92 --- /dev/null +++ b/lib/images/toolbar-toggle_math.xpm @@ -0,0 +1,30 @@ +/* XPM */ +static char * toolbar-toggle_math_xpm[] = { +"20 20 7 1", +" c None", +". c #777777", +"+ c #C9C9C9", +"@ c #919191", +"# c #606060", +"$ c #24238E", +"% c #000000", +".................+@ ", +"..+++++++++++++++@@#", +".+ $$ @@#", +".+ $$$ $ $$ @@#", +".+$$ $ $ $$$@@#", +".+$ $$ $ $$ $@@#", +".+$ $ $ $ $@@#", +".+$$$$ $$$ @@#", +".+ @@#", +".+%%%%%%%%%%%%%%%@@#", +".+ @@#", +".+ $$$ @@#", +".+ $$ $$ @@#", +".+ $ @@#", +".+ $$ @@#", +".+ $$$ @@#", +"+@@@@@@ @@@@@@@@#", +"@@@@@@@@@@@@@@@@@@##", +" ###################", +" "}; diff --git a/lib/images/toolbar-toggle_math_panels.xpm b/lib/images/toolbar-toggle_math_panels.xpm new file mode 100644 index 0000000000..811bafeb1c --- /dev/null +++ b/lib/images/toolbar-toggle_math_panels.xpm @@ -0,0 +1,29 @@ +/* XPM */ +static char * toolbar-toggle_math_panels_xpm[] = { +"20 20 6 1", +"X c None", +". c #777777", +"+ c #C9C9C9", +"@ c #919191", +"# c #606060", +" c #24238E", +".................+@X", +"..+++++++++++++++@@#", +".+XXXXXXXXXXXXXXX@@#", +".+XXXXXXXXXXXXXXX@@#", +".+XXXXXXXXXXXXXXX@@#", +".+XXXXXXXXXXXXXXX@@#", +".+XXXX XXXX@@#", +".+XXX XX X XXXXXX@@#", +".+XXXXXX X XXXXXX@@#", +".+XXXXXX X XXXXXX@@#", +".+XXXXX XX XXXXXX@@#", +".+XXXXX XXX XXXXX@@#", +".+XXXXX XXX XXXXX@@#", +".+XXXXXXXXXXXXXXX@@#", +".+XXXXXXXXXXXXXXX@@#", +".+XXXXXXXXXXXXXXX@@#", +"+@@@@@@@@@@@@@@@@@@#", +"@@@@@@@@@@@@@@@@@@##", +"X###################", +"XXXXXXXXXXXXXXXXXXXX"}; diff --git a/lib/images/toolbar-toggle_table.xpm b/lib/images/toolbar-toggle_table.xpm new file mode 100644 index 0000000000..9b1733dff1 --- /dev/null +++ b/lib/images/toolbar-toggle_table.xpm @@ -0,0 +1,30 @@ +/* XPM */ +static char * toolbar-toggle_table_xpm[] = { +"20 20 7 1", +"X c None", +". c #777777", +"+ c #C9C9C9", +"@ c #919191", +"0 c #ffffff", +"# c #606060", +" c #000000", +".................+@X", +"..+++++++++++++++@@#", +".+XXXXXXXXXXXXXXX@@#", +".+XXXXXXXXXXXXXXX@@#", +".+X X@@#", +".+X 000 000 000 X@@#", +".+X 000 000 000 X@@#", +".+X X@@#", +".+X 000 000 000 X@@#", +".+X 000 000 000 X@@#", +".+X X@@#", +".+X 000 000 000 X@@#", +".+X 000 000 000 X@@#", +".+X X@@#", +".+XXXXXXXXXXXXXXX@@#", +".+XXXXXXXXXXXXXXX@@#", +"+@@@@@@@@@@@@@@@@@@#", +"@@@@@@@@@@@@@@@@@@##", +"X###################", +"XXXXXXXXXXXXXXXXXXXX"}; diff --git a/lib/ui/stdmenus.inc b/lib/ui/stdmenus.inc index 8bfbf3a11c..6d8e96ce51 100644 --- a/lib/ui/stdmenus.inc +++ b/lib/ui/stdmenus.inc @@ -364,6 +364,8 @@ Menuset Separator Item "Delimiters|r" "dialog-show mathdelimiter" Item "Matrix|x" "dialog-show mathmatrix" + Separator + Item "Toggle Math Panels" "toolbar-toggle math_panels" End Menu "insert_float" diff --git a/lib/ui/stdtoolbars.inc b/lib/ui/stdtoolbars.inc index e110df0797..be8fa706b5 100644 --- a/lib/ui/stdtoolbars.inc +++ b/lib/ui/stdtoolbars.inc @@ -75,6 +75,10 @@ ToolbarSet Item "Insert math" "math-mode" Item "Insert graphics" "dialog-show-new-inset graphics" TableInsert "Insert table" + Separator + Item "Toggle Table of Contents" "dialog-toggle toc" + Item "Toggle Math Toolbar" "toolbar-toggle math" + Item "Toggle Table Toolbar" "toolbar-toggle table" End Toolbar "extra" "Extra" @@ -103,7 +107,6 @@ ToolbarSet Separator Item "Text style" "dialog-show character" Item "Paragraph settings" "layout-paragraph" - Item "Table of contents" "dialog-toggle toc" Item "Thesaurus" "thesaurus-entry" End @@ -156,6 +159,8 @@ ToolbarSet Item "Add column" "tabular-feature append-column" Item "Delete row" "tabular-feature delete-row" Item "Delete column" "tabular-feature delete-column" + Separator + Item "Toggle Math Panels" "toolbar-toggle math_panels" End Toolbar "minibuffer" "Command Buffer" @@ -521,29 +526,29 @@ ToolbarSet End Toolbar "latex_varsz" "Big Operators" - Item "sum" "math-insert \sum" - Item "int" "math-insert \int" Item "intop" "math-insert \intop" - Item "iint" "math-insert \iint" + Item "int" "math-insert \int" Item "iintop" "math-insert \iintop" - Item "iiint" "math-insert \iiint" + Item "iint" "math-insert \iint" Item "iiintop" "math-insert \iiintop" - Item "iiiint" "math-insert \iiiint" + Item "iiint" "math-insert \iiint" Item "iiiintop" "math-insert \iiiintop" - Item "dotsint" "math-insert \dotsint" + Item "iiiint" "math-insert \iiiint" Item "dotsintop" "math-insert \dotsintop" - Item "oint" "math-insert \oint" + Item "dotsint" "math-insert \dotsint" Item "ointop" "math-insert \ointop" - Item "oiint" "math-insert \oiint" + Item "oint" "math-insert \oint" Item "oiintop" "math-insert \oiintop" - Item "ointctrclockwise" "math-insert \ointctrclockwise" + Item "oiint" "math-insert \oiint" Item "ointctrclockwiseop" "math-insert \ointctrclockwiseop" - Item "ointclockwise" "math-insert \ointclockwise" + Item "ointctrclockwise" "math-insert \ointctrclockwise" Item "ointclockwiseop" "math-insert \ointclockwiseop" - Item "sqint" "math-insert \sqint" + Item "ointclockwise" "math-insert \ointclockwise" Item "sqintop" "math-insert \sqintop" - Item "sqiint" "math-insert \sqiint" + Item "sqint" "math-insert \sqint" Item "sqiintop" "math-insert \sqiintop" + Item "sqiint" "math-insert \sqiint" + Item "sum" "math-insert \sum" Item "prod" "math-insert \prod" Item "coprod" "math-insert \coprod" Item "bigsqcup" "math-insert \bigsqcup" diff --git a/src/LyXAction.cpp b/src/LyXAction.cpp index 4f42742c90..f1a5a52d51 100644 --- a/src/LyXAction.cpp +++ b/src/LyXAction.cpp @@ -367,6 +367,7 @@ void LyXAction::init() { LFUN_WINDOW_CLOSE, "window-close", NoBuffer }, { LFUN_UNICODE_INSERT, "unicode-insert", Noop }, { LFUN_TOOLBAR_TOGGLE_STATE, "", NoBuffer }, + { LFUN_TOOLBAR_TOGGLE, "toolbar-toggle", NoBuffer }, { LFUN_NOMENCL_INSERT, "nomencl-insert", Noop }, { LFUN_NOMENCL_PRINT, "nomencl-print", Noop }, { LFUN_CLEARPAGE_INSERT, "clearpage-insert", Noop }, diff --git a/src/LyXFunc.cpp b/src/LyXFunc.cpp index fc1eb74a04..aa3f5a769c 100644 --- a/src/LyXFunc.cpp +++ b/src/LyXFunc.cpp @@ -623,6 +623,11 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & cmd) const break; } + case LFUN_TOOLBAR_TOGGLE: { + bool const current = lyx_view_->getToolbars().visible(cmd.getArg(0)); + flag.setOnOff(current); + break; + } // this one is difficult to get right. As a half-baked // solution, we consider only the first action of the sequence case LFUN_COMMAND_SEQUENCE: { @@ -1752,6 +1757,14 @@ void LyXFunc::dispatch(FuncRequest const & cmd) lyx_view_->toggleToolbarState(argument); break; + case LFUN_TOOLBAR_TOGGLE: { + BOOST_ASSERT(lyx_view_); + string const name = to_utf8(cmd.argument()); + bool const current = lyx_view_->getToolbars().visible(name); + lyx_view_->getToolbars().display(name, !current); + break; + } + default: { BOOST_ASSERT(lyx_view_); view()->cursor().dispatch(cmd); diff --git a/src/frontends/Toolbars.cpp b/src/frontends/Toolbars.cpp index fb8b42b023..20082cdd63 100644 --- a/src/frontends/Toolbars.cpp +++ b/src/frontends/Toolbars.cpp @@ -151,14 +151,13 @@ void Toolbars::display(string const & name, bool show) for (; cit != end; ++cit) { if (cit->name == name) { unsigned int flags = cit->flags; + TurnOffFlag(ON); + TurnOffFlag(OFF); TurnOffFlag(AUTO); - if (show) { + if (show) TurnOnFlag(ON); + else TurnOnFlag(OFF); - } else { - TurnOnFlag(OFF); - TurnOnFlag(ON); - } cit->flags = static_cast(flags); displayToolbar(*cit, show); return; @@ -248,6 +247,16 @@ void Toolbars::update(bool in_math, bool in_table, bool review) } +bool Toolbars::visible(string const & name) const +{ + std::map::const_iterator it = + toolbars_.find(name); + if (it == toolbars_.end()) + return false; + return it->second.get()->isVisible(); +} + + void Toolbars::saveToolbarInfo() { ToolbarSection & tb = LyX::ref().session().toolbars(); diff --git a/src/frontends/Toolbars.h b/src/frontends/Toolbars.h index 3602224a86..eb10a4cdfd 100644 --- a/src/frontends/Toolbars.h +++ b/src/frontends/Toolbars.h @@ -70,6 +70,8 @@ public: */ virtual void saveInfo(ToolbarSection::ToolbarInfo & tbinfo) = 0; + /// whether toolbar is visible + virtual bool isVisible() const = 0; /// Refresh the contents of the bar. virtual void update() = 0; /// Accessor to the layout combox, if any. @@ -90,13 +92,16 @@ public: /// get toolbar state (on/off/auto) ToolbarInfo::Flags getToolbarState(std::string const & name); - + /// toggle the state of toolbars (on/off/auto) void toggleToolbarState(std::string const & name); /// Update the state of the toolbars. void update(bool in_math, bool in_table, bool review); + /// Is the Toolbar currently visible? + bool visible(std::string const & name) const; + /// save toolbar information void saveToolbarInfo(); diff --git a/src/frontends/qt4/QLToolbar.cpp b/src/frontends/qt4/QLToolbar.cpp index db2f6570ee..31f89bd5b4 100644 --- a/src/frontends/qt4/QLToolbar.cpp +++ b/src/frontends/qt4/QLToolbar.cpp @@ -298,6 +298,12 @@ void QLToolbar::show(bool) } +bool QLToolbar::isVisible() const +{ + return QToolBar::isVisible(); +} + + void QLToolbar::saveInfo(ToolbarSection::ToolbarInfo & tbinfo) { // if tbinfo.state == auto *do not* set on/off diff --git a/src/frontends/qt4/QLToolbar.h b/src/frontends/qt4/QLToolbar.h index eb7db6b520..73a822974b 100644 --- a/src/frontends/qt4/QLToolbar.h +++ b/src/frontends/qt4/QLToolbar.h @@ -69,6 +69,7 @@ public: void add(ToolbarItem const & item); void hide(bool); void show(bool); + bool isVisible() const; void saveInfo(ToolbarSection::ToolbarInfo & info); void update(); LayoutBox * layout() const { return layout_.get(); } diff --git a/src/lfuns.h b/src/lfuns.h index 3415ae441b..b5260611b4 100644 --- a/src/lfuns.h +++ b/src/lfuns.h @@ -381,6 +381,7 @@ enum kb_action { LFUN_CLEARDOUBLEPAGE_INSERT, // Ugras 20061125 //290 LFUN_LISTING_INSERT, // Herbert 20011110, bpeng 20070502 + LFUN_TOOLBAR_TOGGLE, // Edwin 20070521 LFUN_LASTACTION // end of the table };