Mercurial > dillo_port1.3
changeset 2009:234097ef5e23
Bug fix: resize the viewport internally (when attached to a layout)
* It also has a fix for scrollbars resize, and an optimization to avoid
scrollbar adjustment overhead.
author | Jorge Arellano Cid <jcid@dillo.org> |
---|---|
date | Thu, 12 May 2011 07:56:37 -0400 |
parents | 0da9d72218ee |
children | c60462acb9cf |
files | dw/fltkviewbase.cc dw/fltkviewport.cc dw/layout.cc dw/view.hh |
diffstat | 4 files changed, 24 insertions(+), 18 deletions(-) [+] |
line wrap: on
line diff
--- a/dw/fltkviewbase.cc Wed May 11 15:41:15 2011 -0400 +++ b/dw/fltkviewbase.cc Thu May 12 07:56:37 2011 -0400 @@ -297,6 +297,8 @@ void FltkViewBase::setLayout (core::Layout *layout) { theLayout = layout; + if (usesViewport()) + theLayout->viewportSizeChanged(this, w(), h()); } void FltkViewBase::setCanvasSize (int width, int ascent, int descent)
--- a/dw/fltkviewport.cc Wed May 11 15:41:15 2011 -0400 +++ b/dw/fltkviewport.cc Thu May 12 07:56:37 2011 -0400 @@ -40,11 +40,13 @@ hscrollbar = new Fl_Scrollbar (x (), y (), 1, 1); hscrollbar->type(FL_HORIZONTAL); hscrollbar->callback (hscrollbarCallback, this); + hscrollbar->hide(); add (hscrollbar); vscrollbar = new Fl_Scrollbar (x (), y(), 1, 1); vscrollbar->type(FL_VERTICAL); vscrollbar->callback (vscrollbarCallback, this); + vscrollbar->hide(); add (vscrollbar); scrollX = scrollY = scrollDX = scrollDY = 0; @@ -70,6 +72,7 @@ int hdiff = 0, vdiff = 0; int visibility = 0; + _MSG(" >>FltkViewport::adjustScrollbarsAndGadgetsAllocation\n"); if (hscrollbar->visible ()) visibility |= 1; if (vscrollbar->visible ()) @@ -384,18 +387,26 @@ int hScrollbarThickness, int vScrollbarThickness) { - if (hScrollbarThickness > 0) - hscrollbar->show (); - else - hscrollbar->hide (); - if (vScrollbarThickness > 0) - vscrollbar->show (); - else - vscrollbar->hide (); + int adjustReq = + (hscrollbar->visible() ? !hScrollbarThickness : hScrollbarThickness) || + (vscrollbar->visible() ? !vScrollbarThickness : vScrollbarThickness); + + _MSG("FltkViewport::setViewportSize old_w,old_h=%dx%d -> w,h=%dx%d\n" + "\t hThick=%d hVis=%d, vThick=%d vVis=%d, adjustReq=%d\n", + w(),h(),width,height, + hScrollbarThickness,hscrollbar->visible(), + vScrollbarThickness,vscrollbar->visible(), adjustReq); + + (hScrollbarThickness > 0) ? hscrollbar->show () : hscrollbar->hide (); + (vScrollbarThickness > 0) ? vscrollbar->show () : vscrollbar->hide (); /* If no scrollbar, go to the beginning */ scroll(hScrollbarThickness ? 0 : -scrollX, vScrollbarThickness ? 0 : -scrollY); + + /* Adjust when scrollbar visibility changes */ + if (adjustReq) + adjustScrollbarsAndGadgetsAllocation (); } void FltkViewport::updateCanvasWidgets (int dx, int dy)
--- a/dw/layout.cc Wed May 11 15:41:15 2011 -0400 +++ b/dw/layout.cc Thu May 12 07:56:37 2011 -0400 @@ -679,10 +679,9 @@ } // Set viewport sizes. - if (view->usesViewport ()) - view->setViewportSize (viewportWidth, viewportHeight, - actualHScrollbarThickness, - actualVScrollbarThickness); + view->setViewportSize (viewportWidth, viewportHeight, + actualHScrollbarThickness, + actualVScrollbarThickness); } }
--- a/dw/view.hh Wed May 11 15:41:15 2011 -0400 +++ b/dw/view.hh Thu May 12 07:56:37 2011 -0400 @@ -92,12 +92,6 @@ * This will normally imply a resize of the UI widget. Width and height are * the dimensions of the new size, \em including the scrollbar thicknesses. * - * \bug The rest of this comment needs to be updated. - * - * markerWidthDiff and markerHeightDiff are the respective dimensions of - * the viewport markers (see dw::core::getMarkerWidthDiff and - * dw::core::getMarkerHeightDiff), if they are 0, the respective - * marker should not be shown at all. */ virtual void setViewportSize (int width, int height, int hScrollbarThickness,