diff options
Diffstat (limited to 'dw/layout.cc')
-rw-r--r-- | dw/layout.cc | 91 |
1 files changed, 59 insertions, 32 deletions
diff --git a/dw/layout.cc b/dw/layout.cc index 1609dae0..82a21f57 100644 --- a/dw/layout.cc +++ b/dw/layout.cc @@ -277,6 +277,11 @@ Layout::Layout (Platform *platform) viewportWidth = viewportHeight = 0; hScrollbarThickness = vScrollbarThickness = 0; + DBG_OBJ_SET_NUM ("viewportWidth", viewportWidth); + DBG_OBJ_SET_NUM ("viewportHeight", viewportHeight); + DBG_OBJ_SET_NUM ("hScrollbarThickness", hScrollbarThickness); + DBG_OBJ_SET_NUM ("vScrollbarThickness", vScrollbarThickness); + requestedAnchor = NULL; scrollIdleId = -1; scrollIdleNotInterrupted = false; @@ -371,13 +376,17 @@ void Layout::addWidget (Widget *widget) topLevel = widget; widget->layout = this; + widget->container = NULL; + DBG_OBJ_SET_PTR_O (widget, "container", widget->container); + queueResizeList->clear (); - widget->notifySetAsTopLevel(); + widget->notifySetAsTopLevel (); findtextState.setWidget (widget); canvasHeightGreater = false; - setSizeHints (); + DBG_OBJ_SET_SYM ("canvasHeightGreater", + canvasHeightGreater ? "true" : "false"); // Do not directly call Layout::queueResize(), but // Widget::queueResize(), so that all flags are set properly, @@ -471,6 +480,11 @@ void Layout::attachView (View *view) hScrollbarThickness = view->getHScrollbarThickness (); vScrollbarThickness = view->getVScrollbarThickness (); } + + DBG_OBJ_SET_NUM ("viewportWidth", viewportWidth); + DBG_OBJ_SET_NUM ("viewportHeight", viewportHeight); + DBG_OBJ_SET_NUM ("hScrollbarThickness", hScrollbarThickness); + DBG_OBJ_SET_NUM ("vScrollbarThickness", vScrollbarThickness); } /* @@ -834,8 +848,7 @@ void Layout::setBgImage (style::StyleImage *bgImage, void Layout::resizeIdle () { - DBG_OBJ_MSG ("resize", 0, "<b>resizeIdle</b>"); - DBG_OBJ_MSG_START (); + DBG_OBJ_ENTER0 ("resize", 0, "resizeIdle"); enterResizeIdle (); @@ -873,7 +886,10 @@ void Layout::resizeIdle () // called again. resizeIdleId = -1; - if (topLevel) { + // If this method is triggered by a viewport change, we can save + // time when the toplevel widget is not affected (as for a toplevel + // image resource). + if (topLevel && (topLevel->needsResize () || topLevel->needsAllocate ())) { Requisition requisition; Allocation allocation; @@ -882,9 +898,11 @@ void Layout::resizeIdle () requisition.width, requisition.ascent, requisition.descent); // This method is triggered by Widget::queueResize, which will, - // in any case, set NEEDS_ALLOCATE (indirectly, as - // ALLOCATE_QUEUED). This assertion helps to find - // inconsistences. + // in any case, set NEEDS_ALLOCATE (indirectly, as ALLOCATE_QUEUED). + // This assertion helps to find inconsistences. (Cases where + // this method is triggered by a viewport change, but the + // toplevel widget is not affected, are filtered out some lines + // above: "if (topLevel && topLevel->needsResize ())".) assert (topLevel->needsAllocate ()); allocation.x = allocation.y = 0; @@ -908,12 +926,12 @@ void Layout::resizeIdle () int currVThickness = currVScrollbarThickness(); if (!canvasHeightGreater && - canvasAscent + canvasDescent - > viewportHeight - currHThickness) { + canvasAscent + canvasDescent > viewportHeight - currHThickness) { canvasHeightGreater = true; - setSizeHints (); - /* May queue a new resize. */ - } + DBG_OBJ_SET_SYM ("canvasHeightGreater", + canvasHeightGreater ? "true" : "false"); + containerSizeChanged (); + } // Set viewport sizes. view->setViewportSize (viewportWidth, viewportHeight, @@ -927,21 +945,11 @@ void Layout::resizeIdle () DBG_OBJ_MSGF ("resize", 1, "after resizeIdle: resizeIdleId = %d", resizeIdleId); - DBG_OBJ_MSG_END (); + DBG_OBJ_LEAVE (); leaveResizeIdle (); } -void Layout::setSizeHints () -{ - if (topLevel) { - topLevel->setWidth (viewportWidth - - (canvasHeightGreater ? vScrollbarThickness : 0)); - topLevel->setAscent (viewportHeight - hScrollbarThickness); - topLevel->setDescent (0); - } -} - void Layout::queueDraw (int x, int y, int width, int height) { Rectangle area; @@ -980,9 +988,8 @@ void Layout::queueDrawExcept (int x, int y, int width, int height, void Layout::queueResize (bool extremesChanged) { - DBG_OBJ_MSGF ("resize", 0, "<b>queueResize</b> (%s)", - extremesChanged ? "true" : "false"); - DBG_OBJ_MSG_START (); + DBG_OBJ_ENTER ("resize", 0, "queueResize", "%s", + extremesChanged ? "true" : "false"); if (resizeIdleId == -1) { view->cancelQueueDraw (); @@ -993,7 +1000,7 @@ void Layout::queueResize (bool extremesChanged) emitter.emitResizeQueued (extremesChanged); - DBG_OBJ_MSG_END (); + DBG_OBJ_LEAVE (); } @@ -1264,13 +1271,16 @@ void Layout::scrollPosChanged (View *view, int x, int y) */ void Layout::viewportSizeChanged (View *view, int width, int height) { - _MSG("Layout::viewportSizeChanged w=%d h=%d new_w=%d new_h=%d\n", - viewportWidth, viewportHeight, width, height); + DBG_OBJ_ENTER ("resize", 0, "viewportSizeChanged", "%p, %d, %d", + view, width, height); /* If the width has become higher, we test again, whether the vertical * scrollbar (so to speak) can be hidden again. */ - if (usesViewport && width > viewportWidth) + if (usesViewport && width > viewportWidth) { canvasHeightGreater = false; + DBG_OBJ_SET_SYM ("canvasHeightGreater", + canvasHeightGreater ? "true" : "false"); + } /* if size changes, redraw this view. * TODO: this is a resize call (redraw/resize code needs a review). */ @@ -1285,7 +1295,24 @@ void Layout::viewportSizeChanged (View *view, int width, int height) viewportWidth = width; viewportHeight = height; - setSizeHints (); + DBG_OBJ_SET_NUM ("viewportWidth", viewportWidth); + DBG_OBJ_SET_NUM ("viewportHeight", viewportHeight); + + containerSizeChanged (); + + DBG_OBJ_LEAVE (); +} + +void Layout::containerSizeChanged () +{ + DBG_OBJ_ENTER0 ("resize", 0, "containerSizeChanged"); + + if (topLevel) { + topLevel->containerSizeChanged (); + queueResize (true); + } + + DBG_OBJ_LEAVE (); } } // namespace core |