diff options
author | Jorge Arellano Cid <jcid@dillo.org> | 2016-04-29 14:14:56 -0300 |
---|---|---|
committer | Jorge Arellano Cid <jcid@dillo.org> | 2016-04-29 14:14:56 -0300 |
commit | 1b7bdb008c7e7f15b6b4ea393cd7e9264ff754c6 (patch) | |
tree | 6b854f7deb59fb76ad56bebf61156d75903bd5b3 /dw | |
parent | 0c2eaee51fbaa734a72e5c4d2cf62881e7c45991 (diff) |
FltkViewport::draw() part2: cleanups and three bug fixes.
Rewrote FltkViewport::draw() into a much cleaner style, fixing 3 problems.
Bug fixes:
1. The mouse button FL_RELEASE event over the scrollbars area
triggered an unnecessary redraw.
2. The mouse button FL_RELEASE event, after scrolling,
triggered an unnecessary redraw.
3. The FL_RELEASE event, after {horiz|vert}scrolling
was passed upwards although already handled.
Diffstat (limited to 'dw')
-rw-r--r-- | dw/fltkviewport.cc | 44 |
1 files changed, 26 insertions, 18 deletions
diff --git a/dw/fltkviewport.cc b/dw/fltkviewport.cc index e903e05f..ef1a3ecf 100644 --- a/dw/fltkviewport.cc +++ b/dw/fltkviewport.cc @@ -199,39 +199,47 @@ void FltkViewport::draw_area (void *data, int x, int y, int w, int h) * Draw the viewport. * * + Damage flags come in different ways, draw() should cope with them all. + * + Damage flags are alive for visible and hidden widgets. * + FL_DAMAGE_CHILD can flag scroll bars or embedded FLTK widgets. */ void FltkViewport::draw () { - int hdiff = vscrollbar->visible () ? SCROLLBAR_THICKNESS : 0; - int vdiff = hscrollbar->visible () ? SCROLLBAR_THICKNESS : 0; - int d = damage(); + const int d = damage(), + vis_vs = vscrollbar->visible () ? SCROLLBAR_THICKNESS : 0, + vis_hs = hscrollbar->visible () ? SCROLLBAR_THICKNESS : 0, + draw = d & (FL_DAMAGE_ALL | FL_DAMAGE_EXPOSE), + draw_vs = vis_vs && vscrollbar->damage (), + draw_hs = vis_hs && hscrollbar->damage (); MSG("FltkViewport::draw d=%d => ", d); - if (d == (FL_DAMAGE_SCROLL | FL_DAMAGE_CHILD)) { - fl_scroll(x(), y(), w() - hdiff, h() - vdiff, + // scrollbars + if (draw || draw_vs) + draw_child (*vscrollbar); + if (draw || draw_hs) + draw_child (*hscrollbar); + if (draw && vis_vs && vis_hs) { + fl_color(FL_BACKGROUND_COLOR); + fl_rectf(x()+w()-vis_vs, y()+h()-vis_hs, vis_vs, vis_hs); + } + // main area + if (d == FL_DAMAGE_CHILD && (draw_vs || draw_hs)) { + MSG("none\n"); + } else if (d == (FL_DAMAGE_SCROLL | FL_DAMAGE_CHILD)) { + fl_scroll(x(), y(), w() - vis_vs, h() - vis_hs, -scrollDX, -scrollDY, draw_area, this); MSG("fl_scroll()\n"); } else { - draw_area(this, x(), y(), w () - hdiff, h () - vdiff); + draw_area(this, x(), y(), w() - vis_vs, h() - vis_hs); MSG("draw_area()\n"); } - if ((d & (FL_DAMAGE_ALL | FL_DAMAGE_EXPOSE)) || vscrollbar->damage ()) - draw_child (*vscrollbar); - if ((d & (FL_DAMAGE_ALL | FL_DAMAGE_EXPOSE)) || hscrollbar->damage ()) - draw_child (*hscrollbar); - if ((d & (FL_DAMAGE_ALL | FL_DAMAGE_EXPOSE)) && (hdiff && vdiff)) { - fl_color(FL_BACKGROUND_COLOR); - fl_rectf(x()+w()-hdiff, y()+h()-vdiff, hdiff, vdiff); - } - scrollDX = 0; scrollDY = 0; } int FltkViewport::handle (int event) { + int ret = 0; _MSG("FltkViewport::handle %s\n", fl_eventnames[event]); switch(event) { @@ -312,9 +320,9 @@ int FltkViewport::handle (int event) if (Fl::event_button() == FL_MIDDLE_MOUSE) { setCursor (core::style::CURSOR_DEFAULT); } else if (verScrolling) { - vscrollbar->handle(event); + ret = vscrollbar->handle(event); } else if (horScrolling) { - hscrollbar->handle(event); + ret = hscrollbar->handle(event); } horScrolling = verScrolling = dragScrolling = 0; break; @@ -331,7 +339,7 @@ int FltkViewport::handle (int event) break; } - return FltkWidgetView::handle (event); + return ret ? ret : FltkWidgetView::handle (event); } // ---------------------------------------------------------------------- |