]> git.lyx.org Git - features.git/commitdiff
toolbar3.diff
authorJohn Levon <levon@movementarian.org>
Thu, 10 Apr 2003 14:08:06 +0000 (14:08 +0000)
committerJohn Levon <levon@movementarian.org>
Thu, 10 Apr 2003 14:08:06 +0000 (14:08 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@6768 a592a061-630c-0410-9148-cb99ea01b6c8

16 files changed:
lib/ChangeLog
lib/ui/default.ui
src/BufferView_pimpl.C
src/ToolbarBackend.C
src/ToolbarBackend.h
src/frontends/ChangeLog
src/frontends/LyXView.C
src/frontends/Toolbar.C
src/frontends/Toolbar.h
src/frontends/qt2/ChangeLog
src/frontends/qt2/QtView.C
src/frontends/qt2/Toolbar_pimpl.C
src/frontends/qt2/Toolbar_pimpl.h
src/frontends/xforms/ChangeLog
src/frontends/xforms/Toolbar_pimpl.h
src/frontends/xforms/XFormsView.C

index 9bda5ad60bb16b7e4d2f166e6902802b0addd425..0ffaa8f35fa1417c843a11c70ac81eae5e21d9e3 100644 (file)
@@ -1,3 +1,13 @@
+2003-04-10  John Levon  <levon@movementarian.org>
+
+       * ui/default.ui: Add visibility tag to toolbars
+
+       * BufferView_pimpl.C: updateToolbar on mouse click
+
+       * ToolbarBackend.h:
+       * ToolbarBackend.C: handle toolbar on/off settings
+
+
 2003-04-10  John Levon  <levon@movementarian.org>
 
        * images/: new icons, mostly taken from kdeart
index 1fe6bf61342f598413e712f07ba51fe51da90164..6a7cc5231ec374d3f496ab7f77131aa56b9c8814 100644 (file)
@@ -391,7 +391,13 @@ Menuset
 
 End
 
-# Setup your favorite Toolbar here:
+# A Toolbar starts like :
+#
+# Toolbar "Name" "on" 
+#
+# The second parameter is the status, and can be "on", "off", "math"
+# or "table". The last two make the toolbars appear and disappear automatically.
+#
 # Only three commands are allowed inside the begin_toolbar and end_toolbar
 # directives: 
 #   Item "<action> [<parameter>]" adds an icon to the toolbar performing
@@ -411,7 +417,7 @@ End
 #
 # This is the default toolbar:
 
-Toolbar "Standard"
+Toolbar "Standard" "on"
     Layouts
     Item "Open document" "file-open"
     Item "Save document" "buffer-write"
index a2acdf364d2a8f5a9a4af477556f92a5111b30a4..d31a6af5e0881475e73c0955d26a79b2928f71b5 100644 (file)
@@ -937,7 +937,9 @@ bool BufferView::Pimpl::workAreaDispatch(FuncRequest const & ev_in)
 
        bool const res = dispatch(ev_in);
 
+       // FIXME: we should skip these when selecting
        bv_->owner()->updateLayoutChoice();
+       bv_->owner()->updateToolbar();
        bv_->fitCursor();
 
        // slight hack: this is only called currently when
index 61bfdc9260a430bf6a9a71c7702ccff08cabcf97..b16f85120b3273c418cef9656f3389c5bcf89d01 100644 (file)
@@ -65,6 +65,21 @@ void ToolbarBackend::read(LyXLex & lex)
        Toolbar tb;
        tb.name = lex.getString();
 
+       lex.next(true);
+       string type = lex.getString();
+       if (!compare_ascii_no_case(type, "off"))
+               tb.display_type = OFF;
+       else if (!compare_ascii_no_case(type, "on"))
+               tb.display_type = ON;
+       else if (!compare_ascii_no_case(type, "math"))
+               tb.display_type = MATH;
+       else if (!compare_ascii_no_case(type, "table"))
+               tb.display_type = TABLE;
+       else {
+               lyxerr << "ToolbarBackend::read: unrecognised token:`"
+                      << type << '\'' << endl;
+       }
+
        bool quit = false;
 
        lex.pushTable(toolTags, TO_LAST - 1);
index ba2bfa4c9a7c48107abeb328a85f2c49e84e289a..952d2649cf5942410bab910910620451734a623f 100644 (file)
@@ -23,7 +23,7 @@ class LyXLex;
 class ToolbarBackend {
 public:
        /// The special toolbar actions
-       enum  ItemType {
+       enum ItemType {
                /// adds space between buttons in the toolbar
                SEPARATOR = -3,
                /// a special combox insead of a button
@@ -38,12 +38,22 @@ public:
        /// the toolbar items
        typedef std::vector<std::pair<int, string> > Items;
 
+       /// possibly display types
+       enum DisplayType {
+               OFF, //< never shown
+               ON, //< always shown
+               MATH, //< shown when in math
+               TABLE //< shown when in table
+       };
+
        /// a toolbar
        struct Toolbar {
                /// toolbar UI name
                string name;
                /// toolbar contents
                Items items;
+               /// display type
+               DisplayType display_type;
        };
 
        typedef std::vector<Toolbar> Toolbars;
index dd9f5b356d955ae0035dbda9e1daf86c97af1426..e9f60c11649226a56ae5c4530e96e98701e6bc36 100644 (file)
@@ -1,3 +1,10 @@
+2003-04-10  John Levon  <levon@movementarian.org>
+
+       * Toolbar.h:
+       * Toolbar.C: handle on/off etc. for toolbars
+
+       * LyXView.C: update toolbar on/off etc.
+
 2003-04-09  John Levon  <levon@movementarian.org>
 
        * Toolbar.C: handle multiple toolbars
index 1baa0ce1db392e1271fd8067450504663be84d21..fd25d66e65ed59836ea0580f27df36063d807dcf 100644 (file)
@@ -31,6 +31,7 @@
 #include "Timeout.h"
 #include "Menubar.h"
 #include "controllers/ControlCommandBuffer.h"
+#include "mathed/math_cursor.h"
 
 #include "support/filetools.h" // OnlyFilename()
 
@@ -96,7 +97,10 @@ void LyXView::setLayout(string const & layout)
 
 void LyXView::updateToolbar()
 {
-       toolbar_->update();
+       bool const math = mathcursor;
+       bool const table =
+               !getLyXFunc().getStatus(LFUN_LAYOUT_TABULAR).disabled();
+       toolbar_->update(math, table);
 }
 
 
index 836e40ce83fde0ff15a67d0087f5393405d25c60..123b15d06f64ba6030e93c79f018391143ee6f2e 100644 (file)
 
 using std::endl;
 
-Toolbar::Toolbar(LyXView * o, int x, int y, ToolbarBackend const & backend)
+Toolbar::Toolbar(LyXView * o, int x, int y)
        : last_textclass_(-1)
 {
        pimpl_ = new Pimpl(o, x, y);
 
        // extracts the toolbars from the backend
-       ToolbarBackend::Toolbars::const_iterator cit = backend.begin();
-       ToolbarBackend::Toolbars::const_iterator end = backend.end();
+       ToolbarBackend::Toolbars::const_iterator cit = toolbarbackend.begin();
+       ToolbarBackend::Toolbars::const_iterator end = toolbarbackend.end();
 
        for (; cit != end; ++cit)
                pimpl_->add(*cit);
@@ -39,9 +39,27 @@ Toolbar::~Toolbar()
 }
 
 
-void Toolbar::update()
+void Toolbar::update(bool in_math, bool in_table)
 {
        pimpl_->update();
+
+       // extracts the toolbars from the backend
+       ToolbarBackend::Toolbars::const_iterator cit = toolbarbackend.begin();
+       ToolbarBackend::Toolbars::const_iterator end = toolbarbackend.end();
+
+       for (; cit != end; ++cit) {
+               switch (cit->display_type) {
+                       case ToolbarBackend::OFF:
+                       case ToolbarBackend::ON:
+                               break;
+                       case ToolbarBackend::MATH:
+                               pimpl_->displayToolbar(*cit, in_math);
+                               break;
+                       case ToolbarBackend::TABLE:
+                               pimpl_->displayToolbar(*cit, in_table);
+                               break;
+               }
+       }
 }
 
 
index e59af253f214a157c3391af029c1555f71aa8f34..c12a21b2f925b34a952c36c9ec8a616ace769661 100644 (file)
 #include "LString.h"
 
 class LyXView;
-class ToolbarBackend;
 
 
-/** The LyX GUI independent toolbar class
-  The GUI interface is implemented in the corresponding Toolbar_pimpl class.
-  */
+/**
+ * The LyX GUI independent toolbar class
+ *
+ * The GUI interface is implemented in the corresponding Toolbar_pimpl class.
+ */
 class Toolbar {
 public:
        ///
-       Toolbar(LyXView * o, int x, int y, ToolbarBackend const &);
+       Toolbar(LyXView * o, int x, int y);
 
        ///
        ~Toolbar();
 
-       /// update the state of the icons
-       void update();
+       /// update the state of the toolbars
+       void update(bool in_math, bool in_table);
 
        /// update the layout combox
        void setLayout(string const & layout);
index 130257b7849eefb0fc10c07a0c9504e506958a83..eeea3f4ae1ce0aff1a926344cea034c29236447c 100644 (file)
@@ -1,3 +1,11 @@
+2003-04-10  John Levon  <levon@movementarian.org>
+
+       * QtView.C: Toolbar ctor changed
+
+       * Toolbar_pimpl.h:
+       * Toolbar_pimpl.C: store toolbars in a map
+       for show/hide as needed
+
 2003-04-09  John Levon  <levon@movementarian.org>
 
        * Toolbar_pimpl.h:
index 6c432b673635245c432da274f1382767471316b0..5d68030f83df4b36be3879117c486ceb383ff12e 100644 (file)
@@ -64,7 +64,7 @@ QtView::QtView(unsigned int width, unsigned int height)
        ::current_view = bufferview_.get();
 
        menubar_.reset(new Menubar(this, menubackend));
-       toolbar_.reset(new Toolbar(this, 0, 0, toolbarbackend));
+       toolbar_.reset(new Toolbar(this, 0, 0));
 
        statusBar()->setSizeGripEnabled(false);
 
index f00d776f3ac1fb7d2ceef87ffa225315f8986cab..63205804452fefa68d138f18a6db5e52dd08c9c6 100644 (file)
@@ -58,6 +58,17 @@ Toolbar::Pimpl::~Pimpl()
 }
 
 
+void Toolbar::Pimpl::displayToolbar(ToolbarBackend::Toolbar const & tb, bool show)
+{
+       QToolBar * qtb = toolbars_[tb.name];
+       if (show) {
+               qtb->show();
+       } else {
+               qtb->hide();
+       }
+}
+
+
 void Toolbar::Pimpl::update()
 {
        ButtonMap::const_iterator p = map_.begin();
@@ -201,7 +212,9 @@ void Toolbar::Pimpl::add(ToolbarBackend::Toolbar const & tb)
        for (; it != end; ++it)
                add(qtb, it->first, it->second);
 
-       toolbars_.push_back(qtb);
+       toolbars_[tb.name] = qtb;
+       displayToolbar(tb, tb.display_type == ToolbarBackend::ON);
+
 }
 
 
index 0f4d87934ef7e8c79d763b90bc40280dd78f9f39..9ae211ec1c569b1044c9188fa213283f64f45799 100644 (file)
@@ -44,6 +44,9 @@ public:
        /// add an item to a toolbar
        void add(QToolBar * tb, int action, string const & tooltip);
 
+       /// show or hide a toolbar
+       void displayToolbar(ToolbarBackend::Toolbar const & tb, bool show);
+
        /// update the state of the icons
        void update();
 
@@ -64,7 +67,7 @@ private:
 
        boost::scoped_ptr<ToolbarProxy> proxy_;
 
-       std::vector<QToolBar *> toolbars_;
+       std::map<string, QToolBar *> toolbars_;
 
        QLComboBox * combo_;
 
index bd8c681613cdd21e4a4300f53a713b4bfe01100d..6fb94f5e8813232c75b77da3a2b78309d29ededd 100644 (file)
@@ -1,3 +1,9 @@
+2003-04-10  John Levon  <levon@movementarian.org>
+
+       * XFormsView.C:
+       * Toolbar_pimpl.h:
+       * Toolbar_pimpl.C: API change for show/hide
+
 2003-04-09  Angus Leeming  <leeming@lyx.org>
 
        * FormAboutlyx.C:
index 5c97ccceff2f69ba9e9c217c3aa5091329a2b07c..7fd210ad80bd9bffad099a39eb109f0fb7b822f1 100644 (file)
@@ -38,6 +38,9 @@ public:
        /// add an item to a toolbar
        void add(int action, string const & tooltip);
 
+       /// display toolbar, not implemented
+       void displayToolbar(ToolbarBackend::Toolbar const & tb, bool show) {}
+
        /// update the state of the icons
        void update();
 
index 4d37ffd1753d4976e08b7f8e8f1005de618e4b3f..d4c7d4420b403d323cc48b0fa7d328473368aa53 100644 (file)
@@ -142,7 +142,7 @@ void XFormsView::create_form_form_main(int width, int height)
 
        menubar_.reset(new Menubar(this, menubackend));
 
-       toolbar_.reset(new Toolbar(this, air, 30 + air + bw, toolbarbackend));
+       toolbar_.reset(new Toolbar(this, air, 30 + air + bw));
 
        int const ywork = 60 + 2 * air + bw;
        int const workheight = height - ywork - (25 + 2 * air);