mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-26 03:11:59 +00:00
the autoopen patch (fixes bug 1921)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@10495 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
aba9a83f22
commit
5a704fe310
@ -1,3 +1,8 @@
|
|||||||
|
2005-09-28 Jürgen Spitzmüller <j.spitzmueller@gmx.de>
|
||||||
|
|
||||||
|
* cursor.C (setSelection): do not open collapsable insets;
|
||||||
|
the insets do by themselves now (autoopen).
|
||||||
|
|
||||||
2005-09-28 Jürgen Spitzmüller <j.spitzmueller@gmx.de>
|
2005-09-28 Jürgen Spitzmüller <j.spitzmueller@gmx.de>
|
||||||
|
|
||||||
* buffer.C: format is up to 244.
|
* buffer.C: format is up to 244.
|
||||||
|
@ -468,9 +468,6 @@ void LCursor::setSelection(DocIterator const & where, size_t n)
|
|||||||
selection() = true;
|
selection() = true;
|
||||||
anchor_ = where;
|
anchor_ = where;
|
||||||
pos() += n;
|
pos() += n;
|
||||||
// Open all collapsed insets
|
|
||||||
for (int i = depth() - 1; i >= 0; --i)
|
|
||||||
operator[](i).inset().setStatus(*this, InsetBase::Open);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,3 +1,9 @@
|
|||||||
|
2005-09-28 Jürgen Spitzmüller <j.spitzmueller@gmx.de>
|
||||||
|
|
||||||
|
* insetcollapsable.[Ch]: implement Alfredo Braunstein's approach
|
||||||
|
of autoopen, which means that collapsables automatically open
|
||||||
|
whenever the cursor enters (and close again on leave) (fixes bug 1921).
|
||||||
|
|
||||||
2005-09-28 Jürgen Spitzmüller <j.spitzmueller@gmx.de>
|
2005-09-28 Jürgen Spitzmüller <j.spitzmueller@gmx.de>
|
||||||
|
|
||||||
* insetspace.C: rename '\,' to '\thinspace{}' (avoid parsing error)
|
* insetspace.C: rename '\,' to '\thinspace{}' (avoid parsing error)
|
||||||
|
@ -40,9 +40,16 @@ using std::min;
|
|||||||
using std::ostream;
|
using std::ostream;
|
||||||
|
|
||||||
|
|
||||||
|
InsetCollapsable::CollapseStatus InsetCollapsable::status() const
|
||||||
|
{
|
||||||
|
return (autoOpen_ && status_ != Inlined) ? Open : status_;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
InsetCollapsable::InsetCollapsable
|
InsetCollapsable::InsetCollapsable
|
||||||
(BufferParams const & bp, CollapseStatus status)
|
(BufferParams const & bp, CollapseStatus status)
|
||||||
: InsetText(bp), label("Label"), status_(status), openinlined_(false)
|
: InsetText(bp), label("Label"), status_(status),
|
||||||
|
openinlined_(false), autoOpen_(false)
|
||||||
{
|
{
|
||||||
setAutoBreakRows(true);
|
setAutoBreakRows(true);
|
||||||
setDrawFrame(true);
|
setDrawFrame(true);
|
||||||
@ -122,12 +129,14 @@ Dimension InsetCollapsable::dimensionCollapsed() const
|
|||||||
|
|
||||||
void InsetCollapsable::metrics(MetricsInfo & mi, Dimension & dim) const
|
void InsetCollapsable::metrics(MetricsInfo & mi, Dimension & dim) const
|
||||||
{
|
{
|
||||||
|
autoOpen_ = mi.base.bv->cursor().isInside(this);
|
||||||
mi.base.textwidth -= 2 * TEXT_TO_INSET_OFFSET;
|
mi.base.textwidth -= 2 * TEXT_TO_INSET_OFFSET;
|
||||||
if (status_ == Inlined) {
|
|
||||||
|
if (status() == Inlined) {
|
||||||
InsetText::metrics(mi, dim);
|
InsetText::metrics(mi, dim);
|
||||||
} else {
|
} else {
|
||||||
dim = dimensionCollapsed();
|
dim = dimensionCollapsed();
|
||||||
if (status_ == Open) {
|
if (status() == Open) {
|
||||||
InsetText::metrics(mi, textdim_);
|
InsetText::metrics(mi, textdim_);
|
||||||
openinlined_ = (textdim_.wid + dim.wid <= mi.base.textwidth);
|
openinlined_ = (textdim_.wid + dim.wid <= mi.base.textwidth);
|
||||||
if (openinlined_) {
|
if (openinlined_) {
|
||||||
@ -151,7 +160,7 @@ void InsetCollapsable::metrics(MetricsInfo & mi, Dimension & dim) const
|
|||||||
void InsetCollapsable::draw(PainterInfo & pi, int x, int y) const
|
void InsetCollapsable::draw(PainterInfo & pi, int x, int y) const
|
||||||
{
|
{
|
||||||
const int xx = x + TEXT_TO_INSET_OFFSET;
|
const int xx = x + TEXT_TO_INSET_OFFSET;
|
||||||
if (status_ == Inlined) {
|
if (status() == Inlined) {
|
||||||
InsetText::draw(pi, xx, y);
|
InsetText::draw(pi, xx, y);
|
||||||
} else {
|
} else {
|
||||||
Dimension dimc = dimensionCollapsed();
|
Dimension dimc = dimensionCollapsed();
|
||||||
@ -162,7 +171,7 @@ void InsetCollapsable::draw(PainterInfo & pi, int x, int y) const
|
|||||||
button_dim.y2 = top + dimc.height();
|
button_dim.y2 = top + dimc.height();
|
||||||
|
|
||||||
pi.pain.buttonText(xx, top + dimc.asc, label, labelfont_);
|
pi.pain.buttonText(xx, top + dimc.asc, label, labelfont_);
|
||||||
if (status_ == Open) {
|
if (status() == Open) {
|
||||||
int textx, texty;
|
int textx, texty;
|
||||||
if (openinlined_) {
|
if (openinlined_) {
|
||||||
textx = xx + dimc.width();
|
textx = xx + dimc.width();
|
||||||
@ -181,13 +190,13 @@ void InsetCollapsable::draw(PainterInfo & pi, int x, int y) const
|
|||||||
void InsetCollapsable::drawSelection(PainterInfo & pi, int x, int y) const
|
void InsetCollapsable::drawSelection(PainterInfo & pi, int x, int y) const
|
||||||
{
|
{
|
||||||
x += TEXT_TO_INSET_OFFSET;
|
x += TEXT_TO_INSET_OFFSET;
|
||||||
if (status_ == Open) {
|
if (status() == Open) {
|
||||||
if (openinlined_)
|
if (openinlined_)
|
||||||
x += dimensionCollapsed().wid;
|
x += dimensionCollapsed().wid;
|
||||||
else
|
else
|
||||||
y += dimensionCollapsed().des + textdim_.asc;
|
y += dimensionCollapsed().des + textdim_.asc;
|
||||||
}
|
}
|
||||||
if (status_ != Collapsed)
|
if (status() != Collapsed)
|
||||||
InsetText::drawSelection(pi, x, y);
|
InsetText::drawSelection(pi, x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -195,12 +204,11 @@ void InsetCollapsable::drawSelection(PainterInfo & pi, int x, int y) const
|
|||||||
void InsetCollapsable::cursorPos
|
void InsetCollapsable::cursorPos
|
||||||
(CursorSlice const & sl, bool boundary, int & x, int & y) const
|
(CursorSlice const & sl, bool boundary, int & x, int & y) const
|
||||||
{
|
{
|
||||||
if (status_ == Collapsed) {
|
BOOST_ASSERT(status() != Collapsed);
|
||||||
x = xo();
|
|
||||||
y = yo();
|
|
||||||
} else {
|
|
||||||
InsetText::cursorPos(sl, boundary, x, y);
|
InsetText::cursorPos(sl, boundary, x, y);
|
||||||
if (status_ == Open) {
|
|
||||||
|
if (status() == Open) {
|
||||||
if (openinlined_)
|
if (openinlined_)
|
||||||
x += dimensionCollapsed().wid;
|
x += dimensionCollapsed().wid;
|
||||||
else
|
else
|
||||||
@ -208,19 +216,18 @@ void InsetCollapsable::cursorPos
|
|||||||
+ TEXT_TO_INSET_OFFSET + textdim_.asc;
|
+ TEXT_TO_INSET_OFFSET + textdim_.asc;
|
||||||
}
|
}
|
||||||
x += TEXT_TO_INSET_OFFSET;
|
x += TEXT_TO_INSET_OFFSET;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
InsetBase::EDITABLE InsetCollapsable::editable() const
|
InsetBase::EDITABLE InsetCollapsable::editable() const
|
||||||
{
|
{
|
||||||
return status_ != Collapsed ? HIGHLY_EDITABLE : IS_EDITABLE;
|
return status() != Collapsed ? HIGHLY_EDITABLE : IS_EDITABLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool InsetCollapsable::descendable() const
|
bool InsetCollapsable::descendable() const
|
||||||
{
|
{
|
||||||
return status_ != Collapsed;
|
return status() != Collapsed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -262,7 +269,7 @@ void InsetCollapsable::edit(LCursor & cur, bool left)
|
|||||||
InsetBase * InsetCollapsable::editXY(LCursor & cur, int x, int y)
|
InsetBase * InsetCollapsable::editXY(LCursor & cur, int x, int y)
|
||||||
{
|
{
|
||||||
//lyxerr << "InsetCollapsable: edit xy" << endl;
|
//lyxerr << "InsetCollapsable: edit xy" << endl;
|
||||||
if (status_ == Collapsed)
|
if (status() == Collapsed)
|
||||||
return this;
|
return this;
|
||||||
cur.push(*this);
|
cur.push(*this);
|
||||||
return InsetText::editXY(cur, x, y);
|
return InsetText::editXY(cur, x, y);
|
||||||
@ -276,9 +283,9 @@ void InsetCollapsable::doDispatch(LCursor & cur, FuncRequest & cmd)
|
|||||||
|
|
||||||
switch (cmd.action) {
|
switch (cmd.action) {
|
||||||
case LFUN_MOUSE_PRESS:
|
case LFUN_MOUSE_PRESS:
|
||||||
if (status_ == Inlined)
|
if (status() == Inlined)
|
||||||
InsetText::doDispatch(cur, cmd);
|
InsetText::doDispatch(cur, cmd);
|
||||||
else if (status_ == Open && !hitButton(cmd))
|
else if (status() == Open && !hitButton(cmd))
|
||||||
InsetText::doDispatch(cur, cmd);
|
InsetText::doDispatch(cur, cmd);
|
||||||
else
|
else
|
||||||
cur.noUpdate();
|
cur.noUpdate();
|
||||||
@ -289,7 +296,7 @@ void InsetCollapsable::doDispatch(LCursor & cur, FuncRequest & cmd)
|
|||||||
case LFUN_MOUSE_TRIPLE:
|
case LFUN_MOUSE_TRIPLE:
|
||||||
if (status_ == Inlined)
|
if (status_ == Inlined)
|
||||||
InsetText::doDispatch(cur, cmd);
|
InsetText::doDispatch(cur, cmd);
|
||||||
else if (status_ == Open && !hitButton(cmd))
|
else if (status() && !hitButton(cmd))
|
||||||
InsetText::doDispatch(cur, cmd);
|
InsetText::doDispatch(cur, cmd);
|
||||||
else
|
else
|
||||||
cur.undispatched();
|
cur.undispatched();
|
||||||
@ -301,7 +308,7 @@ void InsetCollapsable::doDispatch(LCursor & cur, FuncRequest & cmd)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (status_) {
|
switch (status()) {
|
||||||
|
|
||||||
case Collapsed:
|
case Collapsed:
|
||||||
//lyxerr << "InsetCollapsable::lfunMouseRelease 1" << endl;
|
//lyxerr << "InsetCollapsable::lfunMouseRelease 1" << endl;
|
||||||
|
@ -69,7 +69,7 @@ public:
|
|||||||
///
|
///
|
||||||
bool inlined() const { return status_ == Inlined; }
|
bool inlined() const { return status_ == Inlined; }
|
||||||
///
|
///
|
||||||
CollapseStatus status() const { return status_; }
|
CollapseStatus status() const;
|
||||||
///
|
///
|
||||||
bool allowSpellCheck() const { return true; }
|
bool allowSpellCheck() const { return true; }
|
||||||
///
|
///
|
||||||
@ -107,6 +107,8 @@ private:
|
|||||||
mutable CollapseStatus status_;
|
mutable CollapseStatus status_;
|
||||||
/// a substatus of the Open status, determined automatically in metrics
|
/// a substatus of the Open status, determined automatically in metrics
|
||||||
mutable bool openinlined_;
|
mutable bool openinlined_;
|
||||||
|
/// the inset will automatically open when the cursor is inside
|
||||||
|
mutable bool autoOpen_;
|
||||||
///
|
///
|
||||||
mutable Dimension textdim_;
|
mutable Dimension textdim_;
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user