Dillo
|
As described in Handling Elements Out Of Flow (The sizeRequest/sizeAllocate problem), the principle that the size of a widget depends only on the sizes of its children causes some problems with floats; the current solution is a frequent correction by calling dw::core::Widget::queueResize. In this document, an alternative approach is presented.
A widget size may depend on the position relative to an ancestor widget. If a widget wants to get the size of a child widget, it should:
All positions passed to dw::core::Widget::sizeRequest must constitute the position at which this child will be allocated.
There are situations where the parent widget is unable to determine these positions before the size is known. An example: a textblock widget cannot determine the positions of an inline widget (like an image, or an inline block) before the line is finished; on the other hand, finishing the line depends on knowing the sizes of the inline widgets.
This may result in a conflict, when the size of an inline widget depends on positions. Generally, the only widget whose size depends on positions is dw::Textblock (the size will depend on the positions within its oof container, see Handling Elements Out Of Flow), so this conflict occurs with inline blocks.
This conflict is handled in different ways:
(This is not (yet) considered for borders: borders are only relevant for floats, but conflicts do not occur for floats.)
Extremes may depend on the position in an analogue way, see:
Currently, the size of a widget has to be recalculated when:
Since for this new approach, the size does not only depend on the size of the children, the second condition must be modified. See beginning of dw::core::Widget::sizeRequest.
An implementation may have to consider, this too, especially when implementing incremental resizing (see Sizes of Dillo Widgets); see dw::Textblock::sizeRequestImpl as an example.
Regarding changes of the position is not sufficient. Consider this example, where a float size changes as soon as the image is loaded:
The second paragraph ("A longer paragraph" ...) stays at the same position, both absolute and relative to the float container, but has to be rewrapped because of the float. Instead, this is handled by dw::oof::OutOfFlowMgr::markSizeChange (and likewise dw::oof::OutOfFlowMgr::markExtremesChange), which is called by the implementation of markSizeChange
(or markExtremesChange
, respectively) of the OOF container. (See also the end of the comment of dw::oof::OOFAwareWidget.)
Change interface of dw::oof::OutOfFlowMgr (this affects mostly only comments). Completed.
Affects methods dw::oof::OutOfFlowMgr::tellPosition1, dw::oof::OutOfFlowMgr::tellPosition2, dw::oof::OutOfFlowMgr::getLeftBorder, dw::oof::OutOfFlowMgr::getRightBorder, dw::oof::OutOfFlowMgr::hasFloatLeft, dw::oof::OutOfFlowMgr::hasFloatRight, dw::oof::OutOfFlowMgr::getLeftFloatHeight, and dw::oof::OutOfFlowMgr::getRightFloatHeight.
Apply step 3 to calls within dw::Textblock. Completed.
Attention: After this step, and before completing the next steps, the code is inconsistent and so incorrect.
display
has the value block
(or analogue), will work better.