Abdelrazak Younes wrote:
Georg Baum wrote:
Abdelrazak Younes wrote:
As I said, there is way to solved that issue differently by painting the
corners independently from the text.
I am not going to rip the draw machinery apart right now, because I don't
know enough about it and I also think that now is not the right moment to
do so.
Well, your patch is much riskier believe me. I was about to propose to
do that myself and it is basically the opposite of what your patch is
doing. I create a Decoration flag used only in math (but that can be
used later by other inset).
Here is the patch. I also changed the ViewMetricInfo in prevision for
future use and change rowpainter.C accordingly.
As with your patch, math navigation is much better with with patch but
not everything is solved. Selection in particular will always recentre
the formula. I'll put it in during the week-end if I don't get objection.
Abdel.
Index: BufferView.C
===================================================================
--- BufferView.C (revision 16767)
+++ BufferView.C (working copy)
@@ -351,15 +351,30 @@
// Case when no explicit update is requested.
if (!flags) {
// no need to redraw anything.
+ metrics_info_.update_strategy = NoScreenUpdate;
return false;
}
- if (flags == Update::FitCursor) {
+ if (flags == Update::Decoration) {
+ metrics_info_.update_strategy = DecorationUpdate;
+ return true;
+ }
+
+ if (flags == Update::FitCursor
+ || flags == (Update::Decoration | Update::FitCursor)) {
bool const fit_cursor = fitCursor();
- if (fit_cursor)
+ // tell the frontend to update the screen if needed.
+ if (fit_cursor) {
updateMetrics(false);
- // tell the frontend to update the screen if needed.
- return fit_cursor;
+ return true;
+ }
+ if (flags & Update::Decoration) {
+ metrics_info_.update_strategy = DecorationUpdate;
+ return true;
+ }
+ // no screen update is needed.
+ metrics_info_.update_strategy = NoScreenUpdate;
+ return false;
}
bool full_metrics = flags & Update::Force;
@@ -1084,7 +1099,8 @@
// not expose the button for redraw. We adjust here the metrics
dimension
// to enable a full redraw.
// FIXME: It is possible to redraw only the area around the
button!
- if (need_redraw && metrics_info_.singlepar) {
+ if (need_redraw
+ && metrics_info_.update_strategy == SingleParUpdate) {
// FIXME: It should be possible to redraw only the area
around
// the button by doing this:
//
@@ -1454,7 +1470,8 @@
<< "size: " << size
<< endl;
- metrics_info_ = ViewMetricsInfo(pit1, pit2, y1, y2, singlepar, size);
+ metrics_info_ = ViewMetricsInfo(pit1, pit2, y1, y2,
+ singlepar? SingleParUpdate: FullScreenUpdate, size);
if (lyxerr.debugging(Debug::WORKAREA)) {
lyxerr[Debug::WORKAREA] << "BufferView::updateMetrics" << endl;
Index: mathed/InsetMathNest.C
===================================================================
--- mathed/InsetMathNest.C (revision 16767)
+++ mathed/InsetMathNest.C (working copy)
@@ -499,11 +499,7 @@
break;
case LFUN_CHAR_FORWARD:
- // FIXME: we have to enable full redraw here because of the
- // visual box corners that define the inset. If we know for
- // sure that we stay within the same cell we can optimize for
- // that using:
- //cur.updateFlags(Update::FitCursor);
+ cur.updateFlags(Update::Decoration | Update::FitCursor);
case LFUN_CHAR_FORWARD_SELECT:
cur.selHandle(cmd.action == LFUN_CHAR_FORWARD_SELECT);
cur.autocorrect() = false;
@@ -522,11 +518,7 @@
break;
case LFUN_CHAR_BACKWARD:
- // FIXME: we have to enable full redraw here because of the
- // visual box corners that define the inset. If we know for
- // sure that we stay within the same cell we can optimize for
- // that using:
- //cur.updateFlags(Update::FitCursor);
+ cur.updateFlags(Update::Decoration | Update::FitCursor);
case LFUN_CHAR_BACKWARD_SELECT:
cur.selHandle(cmd.action == LFUN_CHAR_BACKWARD_SELECT);
cur.autocorrect() = false;
@@ -546,11 +538,7 @@
break;
case LFUN_UP:
- // FIXME: we have to enable full redraw here because of the
- // visual box corners that define the inset. If we know for
- // sure that we stay within the same cell we can optimize for
- // that using:
- //cur.updateFlags(Update::FitCursor);
+ cur.updateFlags(Update::Decoration | Update::FitCursor);
case LFUN_UP_SELECT:
// FIXME Tried to use clearTargetX and macroModeClose, crashed
on cur.up()
if (cur.inMacroMode()) {
@@ -568,11 +556,7 @@
break;
case LFUN_DOWN:
- // FIXME: we have to enable full redraw here because of the
- // visual box corners that define the inset. If we know for
- // sure that we stay within the same cell we can optimize for
- // that using:
- //cur.updateFlags(Update::FitCursor);
+ cur.updateFlags(Update::Decoration | Update::FitCursor);
case LFUN_DOWN_SELECT:
if (cur.inMacroMode()) {
cur.macroModeClose();
@@ -601,22 +585,14 @@
case LFUN_PARAGRAPH_UP:
case LFUN_PARAGRAPH_DOWN:
- // FIXME: we have to enable full redraw here because of the
- // visual box corners that define the inset. If we know for
- // sure that we stay within the same cell we can optimize for
- // that using:
- //cur.updateFlags(Update::FitCursor);
+ cur.updateFlags(Update::Decoration | Update::FitCursor);
case LFUN_PARAGRAPH_UP_SELECT:
case LFUN_PARAGRAPH_DOWN_SELECT:
break;
case LFUN_LINE_BEGIN:
case LFUN_WORD_BACKWARD:
- // FIXME: we have to enable full redraw here because of the
- // visual box corners that define the inset. If we know for
- // sure that we stay within the same cell we can optimize for
- // that using:
- //cur.updateFlags(Update::FitCursor);
+ cur.updateFlags(Update::Decoration | Update::FitCursor);
case LFUN_LINE_BEGIN_SELECT:
case LFUN_WORD_BACKWARD_SELECT:
cur.selHandle(cmd.action == LFUN_WORD_BACKWARD_SELECT ||
@@ -638,11 +614,7 @@
case LFUN_WORD_FORWARD:
case LFUN_LINE_END:
- // FIXME: we have to enable full redraw here because of the
- // visual box corners that define the inset. If we know for
- // sure that we stay within the same cell we can optimize for
- // that using:
- //cur.updateFlags(Update::FitCursor);
+ cur.updateFlags(Update::Decoration | Update::FitCursor);
case LFUN_WORD_FORWARD_SELECT:
case LFUN_LINE_END_SELECT:
cur.selHandle(cmd.action == LFUN_WORD_FORWARD_SELECT ||
@@ -676,20 +648,12 @@
break;
case LFUN_CELL_FORWARD:
- // FIXME: we have to enable full redraw here because of the
- // visual box corners that define the inset. If we know for
- // sure that we stay within the same cell we can optimize for
- // that using:
- //cur.updateFlags(Update::FitCursor);
+ cur.updateFlags(Update::Decoration | Update::FitCursor);
cur.inset().idxNext(cur);
break;
case LFUN_CELL_BACKWARD:
- // FIXME: we have to enable full redraw here because of the
- // visual box corners that define the inset. If we know for
- // sure that we stay within the same cell we can optimize for
- // that using:
- //cur.updateFlags(Update::FitCursor);
+ cur.updateFlags(Update::Decoration | Update::FitCursor);
cur.inset().idxPrev(cur);
break;
@@ -1184,7 +1148,7 @@
bv.mouseSetCursor(cur);
// FIXME: we have to enable full redraw here because of the
// visual box corners that define the inset.
- //cur.noUpdate();
+ cur.updateFlags(Update::Decoration | Update::FitCursor);
} else if (cmd.button() == mouse_button::button2) {
MathArray ar;
if (cur.selection()) {
Index: metricsinfo.h
===================================================================
--- metricsinfo.h (revision 16767)
+++ metricsinfo.h (working copy)
@@ -100,22 +100,31 @@
class TextMetricsInfo {};
+enum ScreenUpdateStrategy {
+ NoScreenUpdate,
+ SingleParUpdate,
+ FullScreenUpdate,
+ DecorationUpdate
+};
+
class ViewMetricsInfo
{
public:
ViewMetricsInfo()
- : p1(0), p2(0), y1(0), y2(0), singlepar(false), size(0)
+ : p1(0), p2(0), y1(0), y2(0),
+ update_strategy(NoScreenUpdate), size(0)
{}
ViewMetricsInfo(pit_type p1, pit_type p2, int y1, int y2,
- bool singlepar, pit_type size)
- : p1(p1), p2(p2), y1(y1), y2(y2), singlepar(singlepar),
size(size)
+ ScreenUpdateStrategy updatestrategy, pit_type size)
+ : p1(p1), p2(p2), y1(y1), y2(y2),
+ update_strategy(update_strategy), size(size)
{}
pit_type p1;
pit_type p2;
int y1;
int y2;
- bool singlepar;
+ ScreenUpdateStrategy update_strategy;
pit_type size;
};
Index: rowpainter.C
===================================================================
--- rowpainter.C (revision 16767)
+++ rowpainter.C (working copy)
@@ -977,7 +977,10 @@
PainterInfo pi(const_cast<BufferView *>(&bv), pain);
// Should the whole screen, including insets, be refreshed?
- bool repaintAll = select || !vi.singlepar;
+ // FIXME: We should also distinguish DecorationUpdate to avoid text
+ // drawing if possible. This is not possible to do easily right now
+ // because of the single backing pixmap.
+ bool repaintAll = select || vi.update_strategy != SingleParUpdate;
if (repaintAll) {
// Clear background (if not delegated to rows)
@@ -1000,12 +1003,12 @@
// and grey out above (should not happen later)
// lyxerr << "par ascent: " << text.getPar(vi.p1).ascent() << endl;
- if (vi.y1 > 0 && !vi.singlepar)
+ if (vi.y1 > 0 && vi.update_strategy != SingleParUpdate)
pain.fillRectangle(0, 0, bv.workWidth(), vi.y1,
LColor::bottomarea);
// and possibly grey out below
// lyxerr << "par descent: " << text.getPar(vi.p1).ascent() << endl;
- if (vi.y2 < bv.workHeight() && !vi.singlepar)
+ if (vi.y2 < bv.workHeight() && vi.update_strategy != SingleParUpdate)
pain.fillRectangle(0, vi.y2, bv.workWidth(), bv.workHeight() -
vi.y2, LColor::bottomarea);
}
Index: UpdateFlags.h
===================================================================
--- UpdateFlags.h (revision 16767)
+++ UpdateFlags.h (working copy)
@@ -20,7 +20,8 @@
FitCursor = 1,
Force = 2,
SinglePar = 4,
- MultiParSel = 8
+ MultiParSel = 8,
+ Decoration = 16
};
inline flags operator|(flags const f, flags const g)