From: Jean-Marc Lasgouttes Date: Wed, 15 Feb 2012 09:42:13 +0000 (+0000) Subject: Sort out usage of INset::has Settings and Inset::clickable X-Git-Tag: 2.1.0beta1~2052 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=5d3461b10f68b81c06898d19e5d7a1b55c472f37;p=features.git Sort out usage of INset::has Settings and Inset::clickable * 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 --- diff --git a/src/insets/Inset.cpp b/src/insets/Inset.cpp index c4894569ab..e9c736c619 100644 --- a/src/insets/Inset.cpp +++ b/src/insets/Inset.cpp @@ -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); } diff --git a/src/insets/InsetCommand.cpp b/src/insets/InsetCommand.cpp index 1c9a170b11..004f2f3283 100644 --- a/src/insets/InsetCommand.cpp +++ b/src/insets/InsetCommand.cpp @@ -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); } diff --git a/src/insets/InsetFloatList.cpp b/src/insets/InsetFloatList.cpp index f0c649824e..5e72ee386f 100644 --- a/src/insets/InsetFloatList.cpp +++ b/src/insets/InsetFloatList.cpp @@ -14,10 +14,13 @@ #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"; diff --git a/src/insets/InsetFloatList.h b/src/insets/InsetFloatList.h index 6f7844eb26..0b570766fd 100644 --- a/src/insets/InsetFloatList.h +++ b/src/insets/InsetFloatList.h @@ -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; //@} diff --git a/src/insets/InsetSpace.h b/src/insets/InsetSpace.h index dc74faadca..718a97ba17 100644 --- a/src/insets/InsetSpace.h +++ b/src/insets/InsetSpace.h @@ -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); } diff --git a/src/insets/InsetTOC.cpp b/src/insets/InsetTOC.cpp index bac2f43699..0ab4b65816 100644 --- a/src/insets/InsetTOC.cpp +++ b/src/insets/InsetTOC.cpp @@ -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; diff --git a/src/insets/InsetTOC.h b/src/insets/InsetTOC.h index cb32c66ac3..9ba7cf06f3 100644 --- a/src/insets/InsetTOC.h +++ b/src/insets/InsetTOC.h @@ -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 diff --git a/src/insets/InsetVSpace.h b/src/insets/InsetVSpace.h index f8df1d3b3f..4724c7b567 100644 --- a/src/insets/InsetVSpace.h +++ b/src/insets/InsetVSpace.h @@ -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;