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
This commit is contained in:
Jean-Marc Lasgouttes 2012-02-15 09:42:13 +00:00
parent fcca6c2d11
commit 5d3461b10f
8 changed files with 28 additions and 7 deletions

View 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);
}

View 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);
}

View File

@ -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";

View 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;
//@}

View 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); }

View 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;

View 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

View 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;