inlined open submode, in the hope someone will actually test it. Easy take it back if there are problems.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@8483 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Alfredo Braunstein 2004-03-10 08:50:46 +00:00
parent 83d91912b5
commit 60cbc89f03
3 changed files with 25 additions and 16 deletions

View File

@ -1,3 +1,8 @@
2004-03-09 Alfredo Braunstein <abraunst@lyx.org>
* insetcollapsable.[Ch] (metrics, draw): implemented an inlined-Open
submode.
2004-03-07 Jürgen Spitzmüller <j.spitzmueller@gmx.de> 2004-03-07 Jürgen Spitzmüller <j.spitzmueller@gmx.de>
* insetcite.[Ch]: support jurabib. * insetcite.[Ch]: support jurabib.

View File

@ -41,7 +41,7 @@ using std::ostream;
InsetCollapsable::InsetCollapsable(BufferParams const & bp, InsetCollapsable::InsetCollapsable(BufferParams const & bp,
CollapseStatus status) CollapseStatus status)
: inset(bp), label("Label"), status_(status) : inset(bp), label("Label"), status_(status), openinlined_(false)
{ {
inset.setOwner(this); inset.setOwner(this);
inset.setAutoBreakRows(true); inset.setAutoBreakRows(true);
@ -127,14 +127,6 @@ void InsetCollapsable::dimension_collapsed(Dimension & dim) const
} }
int InsetCollapsable::height_collapsed() const
{
Dimension dim;
font_metrics::buttonText(label, labelfont_, dim.wid, dim.asc, dim.des);
return dim.asc + dim.des;
}
void InsetCollapsable::metrics(MetricsInfo & mi, Dimension & dim) const void InsetCollapsable::metrics(MetricsInfo & mi, Dimension & dim) const
{ {
if (status_ == Inlined) { if (status_ == Inlined) {
@ -144,8 +136,16 @@ void InsetCollapsable::metrics(MetricsInfo & mi, Dimension & dim) const
if (status_ == Open) { if (status_ == Open) {
Dimension insetdim; Dimension insetdim;
inset.metrics(mi, insetdim); inset.metrics(mi, insetdim);
dim.des += insetdim.height() + TEXT_TO_BOTTOM_OFFSET; openinlined_ = (insetdim.wid + dim.wid <= mi.base.textwidth);
dim.wid = max(dim.wid, insetdim.wid); if (openinlined_) {
dim.wid += insetdim.wid;
dim.des = max(dim.des, insetdim.des);
dim.asc = max(dim.asc, insetdim.asc);
} else {
dim.des += insetdim.height()
+ TEXT_TO_BOTTOM_OFFSET;
dim.wid = max(dim.wid, insetdim.wid);
}
} }
} }
dim_ = dim; dim_ = dim;
@ -177,7 +177,11 @@ void InsetCollapsable::draw(PainterInfo & pi, int x, int y) const
if (status_ == Open) { if (status_ == Open) {
if (!owner()) if (!owner())
x += scroll(); x += scroll();
inset.draw(pi, x, y - aa + dimc.height() + inset.ascent());
if (openinlined_)
inset.draw(pi, x + dimc.width(), y - aa + inset.ascent());
else
inset.draw(pi, x, y - aa + dimc.height() + inset.ascent());
} }
} }
} }
@ -324,14 +328,14 @@ void InsetCollapsable::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
case LFUN_MOUSE_PRESS: case LFUN_MOUSE_PRESS:
if (status_ == Inlined) if (status_ == Inlined)
inset.dispatch(cur, cmd); inset.dispatch(cur, cmd);
else if (status_ == Open && cmd.y > button_dim.y2) else if (status_ == Open && !hitButton(cmd))
inset.dispatch(cur, cmd); inset.dispatch(cur, cmd);
break; break;
case LFUN_MOUSE_MOTION: case LFUN_MOUSE_MOTION:
if (status_ == Inlined) if (status_ == Inlined)
inset.dispatch(cur, cmd); inset.dispatch(cur, cmd);
else if (status_ == Open && cmd.y > button_dim.y2) else if (status_ == Open && !hitButton(cmd))
inset.dispatch(cur, cmd); inset.dispatch(cur, cmd);
break; break;

View File

@ -127,8 +127,6 @@ protected:
/// ///
void dimension_collapsed(Dimension &) const; void dimension_collapsed(Dimension &) const;
/// ///
int height_collapsed() const;
///
void draw_collapsed(PainterInfo & pi, int x, int y) const; void draw_collapsed(PainterInfo & pi, int x, int y) const;
/// ///
int getMaxTextWidth(Painter & pain, UpdatableInset const *) const; int getMaxTextWidth(Painter & pain, UpdatableInset const *) const;
@ -160,6 +158,8 @@ protected:
private: private:
/// ///
mutable CollapseStatus status_; mutable CollapseStatus status_;
/// a substatus of the Open status, determined automatically in metrics
mutable bool openinlined_;
}; };
#endif #endif