This fixes a long-standing bug, for some reason (namely, switch from
closed to inlined did not correctly recalculate the width), but does not
fix an *existing* bug that is new to 1.4.0cvs (bug 965). Jug, if you're
listening: why doesn't the insettext->update() correctly deal with the
cursor positioning changing ?
But really this is a matter of a start of cleanup, only insetert uses
the insetcollapsable need_update handling, so it should go there.
It also doesn't yet fix bug 966, which is old.
OK ?
regards,
john
? a.diff
Index: insetcollapsable.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetcollapsable.C,v
retrieving revision 1.129
diff -u -p -r1.129 insetcollapsable.C
--- insetcollapsable.C 19 Mar 2003 14:45:18 -0000 1.129
+++ insetcollapsable.C 19 Mar 2003 18:56:03 -0000
@@ -46,7 +46,7 @@ class LyXText;
InsetCollapsable::InsetCollapsable(BufferParams const & bp, bool collapsed)
: UpdatableInset(), collapsed_(collapsed), inset(bp),
button_length(0), button_top_y(0), button_bottom_y(0),
- need_update(NONE), label("Label"),
+ label("Label"),
#if 0
autocollapse(false),
#endif
@@ -64,7 +64,7 @@ InsetCollapsable::InsetCollapsable(Inset
: UpdatableInset(in, same_id), collapsed_(in.collapsed_),
framecolor(in.framecolor), labelfont(in.labelfont), inset(in.inset),
button_length(0), button_top_y(0), button_bottom_y(0),
- need_update(NONE), label(in.label),
+ label(in.label),
#if 0
autocollapse(in.autocollapse),
#endif
@@ -189,12 +189,6 @@ void InsetCollapsable::draw(BufferView *
lyx::Assert(bv);
cache(bv);
- if (need_update != NONE) {
- const_cast<InsetText *>(&inset)->update(bv, f, true);
- bv->text->postChangedInDraw();
- need_update = NONE;
- return;
- }
if (nodraw())
return;
Index: insetcollapsable.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetcollapsable.h,v
retrieving revision 1.94
diff -u -p -r1.94 insetcollapsable.h
--- insetcollapsable.h 17 Mar 2003 01:34:34 -0000 1.94
+++ insetcollapsable.h 19 Mar 2003 18:56:04 -0000
@@ -33,11 +33,6 @@ class LyXCursor;
class InsetCollapsable : public UpdatableInset {
public:
///
- enum UpdateCodes {
- NONE = 0,
- FULL
- };
- ///
static int const TEXT_TO_TOP_OFFSET = 2;
///
static int const TEXT_TO_BOTTOM_OFFSET = 2;
@@ -226,7 +221,6 @@ protected:
///
mutable int topx;
mutable int topbaseline;
- mutable UpdateCodes need_update;
private:
///
Index: insetert.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetert.C,v
retrieving revision 1.110
diff -u -p -r1.110 insetert.C
--- insetert.C 19 Mar 2003 14:45:19 -0000 1.110
+++ insetert.C 19 Mar 2003 18:56:05 -0000
@@ -53,7 +53,7 @@ void InsetERT::init()
InsetERT::InsetERT(BufferParams const & bp, bool collapsed)
- : InsetCollapsable(bp, collapsed)
+ : InsetCollapsable(bp, collapsed), need_update(false)
{
if (collapsed)
status_ = Collapsed;
@@ -64,7 +64,8 @@ InsetERT::InsetERT(BufferParams const &
InsetERT::InsetERT(InsetERT const & in, bool same_id)
- : InsetCollapsable(in, same_id), status_(in.status_)
+ : InsetCollapsable(in, same_id), status_(in.status_),
+ need_update(false)
{
init();
}
@@ -572,6 +573,14 @@ void InsetERT::draw(BufferView * bv, LyX
lyx::Assert(bv);
cache(bv);
+ if (need_update) {
+ InsetText * it = const_cast<InsetText *>(&inset);
+ it->update(bv, f, true);
+ bv->text->postChangedInDraw();
+ need_update = false;
+ return;
+ }
+
Painter & pain = bv->painter();
button_length = width_collapsed();
@@ -601,7 +610,6 @@ void InsetERT::draw(BufferView * bv, LyX
draw_collapsed(pain, bl, old_x);
inset.draw(bv, f, bl + descent_collapsed() + inset.ascent(bv, f), x);
}
- need_update = NONE;
}
@@ -623,7 +631,7 @@ void InsetERT::status(BufferView * bv, E
{
if (st != status_) {
status_ = st;
- need_update = FULL;
+ need_update = true;
switch (st) {
case Inlined:
if (bv)
@@ -710,10 +718,10 @@ void InsetERT::update(BufferView * bv, L
bool reinit)
{
if (inset.need_update & InsetText::INIT ||
- inset.need_update & InsetText::FULL)
- {
+ inset.need_update & InsetText::FULL) {
setButtonLabel();
}
+
InsetCollapsable::update(bv, font, reinit);
}
Index: insetert.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetert.h,v
retrieving revision 1.64
diff -u -p -r1.64 insetert.h
--- insetert.h 17 Mar 2003 01:34:34 -0000 1.64
+++ insetert.h 19 Mar 2003 18:56:05 -0000
@@ -149,6 +149,9 @@ private:
///
mutable ERTStatus status_;
+
+ /// repaint needed ?
+ mutable bool need_update;
};