]> git.lyx.org Git - features.git/commitdiff
Sort out usage of INset::has Settings and Inset::clickable
authorJean-Marc Lasgouttes <lasgouttes@lyx.org>
Wed, 15 Feb 2012 09:42:13 +0000 (09:42 +0000)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Wed, 15 Feb 2012 09:42:13 +0000 (09:42 +0000)
 * now hasSettings only means... that the inset has a settings dialog
 * and clickable means that something should happen with left-clicking on the inset

Some inset behaviours are changed:
 * (V)Space insets are not clickable anymore (the settings dialog is still accessible via context menu and Edit menu)
 * TOC inset is now shown as active
 * FloatList inset is shown as active and clicking on it opens the relevant part of the TOC dialog

This could be a candidate for branch (2.0.4)

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@40755 a592a061-630c-0410-9148-cb99ea01b6c8

src/insets/Inset.cpp
src/insets/InsetCommand.cpp
src/insets/InsetFloatList.cpp
src/insets/InsetFloatList.h
src/insets/InsetSpace.h
src/insets/InsetTOC.cpp
src/insets/InsetTOC.h
src/insets/InsetVSpace.h

index c4894569abed5680bb3243cbf95f21caa07696c3..e9c736c61937d39cbcc0986757aad0fc1ba7e2ba 100644 (file)
@@ -347,7 +347,7 @@ void Inset::doDispatch(Cursor & cur, FuncRequest &cmd)
                // if the derived inset did not explicitly handle mouse_release,
                // we assume we request the settings dialog
                if (!cur.selection() && cmd.button() == mouse_button::button1
-                         && hasSettings()) {
+                   && clickable(cmd.x(), cmd.y()) && hasSettings()) {
                        FuncRequest tmpcmd(LFUN_INSET_SETTINGS);
                        dispatch(cur, tmpcmd);
                }
index 1c9a170b11214caf6d2387b369ee0205ea1dfeb5..004f2f328300fa577a61f5f32af9ad7da0ebbe9a 100644 (file)
@@ -80,7 +80,7 @@ InsetCommand::~InsetCommand()
 
 void InsetCommand::metrics(MetricsInfo & mi, Dimension & dim) const
 {
-       button_.update(screenLabel(), editable() || hasSettings());
+       button_.update(screenLabel(), editable() || clickable(0, 0));
        button_.metrics(mi, dim);
 }
 
index f0c649824e6b077e74def8c2ebf68116d37e72e9..5e72ee386fcf30c3921f0f0ae6b352d9f54967fd 100644 (file)
 
 #include "Buffer.h"
 #include "BufferParams.h"
+#include "BufferView.h"
+#include "Cursor.h"
 #include "DispatchResult.h"
 #include "Floating.h"
 #include "FloatList.h"
 #include "Font.h"
+#include "FuncRequest.h"
 #include "Language.h"
 #include "LaTeXFeatures.h"
 #include "Lexer.h"
@@ -79,6 +82,21 @@ docstring InsetFloatList::screenLabel() const
 }
 
 
+void InsetFloatList::doDispatch(Cursor & cur, FuncRequest & cmd) {
+       switch (cmd.action()) {
+       case LFUN_MOUSE_RELEASE:
+               if (!cur.selection() && cmd.button() == mouse_button::button1) {
+                       cur.bv().showDialog("toc", params2string(params()));
+                       cur.dispatched();
+               }
+               break;
+       
+       default:
+               InsetCommand::doDispatch(cur, cmd);
+       }
+}
+
+
 void InsetFloatList::write(ostream & os) const
 {
        os << "FloatList " << to_ascii(getParam("type")) << "\n";
index 6f7844eb2658f65fdba1f499f2050877bce6ed2c..0b570766fd4a83c0e7cb79be76d5b72e8db61b04 100644 (file)
@@ -46,6 +46,10 @@ public:
        ///
        docstring xhtml(XHTMLStream &, OutputParams const &) const;
        ///
+       void doDispatch(Cursor & cur, FuncRequest & cmd);
+       ///
+       bool clickable(int, int) const { return true; }
+       ///
        void validate(LaTeXFeatures & features) const;
        //@}
 
index dc74faadcac26832922415216631d38e988e4dba..718a97ba1749fe6326473561a870bfbde8d819cb 100644 (file)
@@ -151,8 +151,6 @@ public:
        bool isSpace() const { return true; }
        ///
        std::string contextMenuName() const;
-       ///
-       bool clickable(int /* x */, int /* y */) const { return true; }
 protected:
        ///
        Inset * clone() const { return new InsetSpace(*this); }
index bac2f43699b27c9aa5dd92656ab4aabfa3bea2d6..0ab4b65816f7d19e5da333fa2a9fae925f75c150 100644 (file)
@@ -14,6 +14,7 @@
 
 #include "Buffer.h"
 #include "BufferParams.h"
+#include "BufferView.h"
 #include "Cursor.h"
 #include "DispatchResult.h"
 #include "Font.h"
@@ -64,7 +65,7 @@ void InsetTOC::doDispatch(Cursor & cur, FuncRequest & cmd) {
        switch (cmd.action()) {
        case LFUN_MOUSE_RELEASE:
                if (!cur.selection() && cmd.button() == mouse_button::button1) {
-                       showInsetDialog(&cur.bv());
+                       cur.bv().showDialog("toc", params2string(params()));
                        cur.dispatched();
                }
                break;
index cb32c66ac3f18c85b1df6313a151c12f3cba773f..9ba7cf06f3de98d527014932d087ed8c725ef435 100644 (file)
@@ -41,6 +41,8 @@ public:
        docstring xhtml(XHTMLStream & xs, OutputParams const &) const;
        ///
        void doDispatch(Cursor & cur, FuncRequest & cmd);
+       ///
+       bool clickable(int, int) const { return true; }
        //@}
 
        /// \name Static public methods obligated for InsetCommand derived classes
index f8df1d3b3f02429afa2b105002ce6ed4f9d4c480..4724c7b5670ff6abd7ce8906374c2d0dfb3caab7 100644 (file)
@@ -37,8 +37,6 @@ public:
        static void string2params(std::string const &, VSpace &);
        ///
        static std::string params2string(VSpace const &);
-       ///
-       bool clickable(int, int) const { return true; }
 private:
        ///
        void metrics(MetricsInfo & mi, Dimension & dim) const;