Dillo v3.1.1-99-gf3103cc4
|
This paper describes (will describe) some design changes to calculating widget sizes. Goals are:
dw::core::Widget::sizeRequest and dw::core::Widget::getExtremes will return final results.** The caller does not have to correct the size, e. g. when percentages are defined. As an example, dw::Textblock::calcWidgetSize has already become much simpler.
A new hierarchy, container:** Aside from dw::core::Widget::parent and dw::core::Widget::generator, there is a third hierarchy dw::core::Widget::container, which is (unlike generator) always a direct ancestor, and represents what in CSS is called containing block. Containers are important to define the "context size", which is (not solely) used for percentage sizes.
(There is another "containing block", dw::Textblock::containingBlock; these may be consolidated some day.)
The process of size calculation is split between the widget itself and its container:**
Size hints are removed.** Instead, the container methods in the previous paragraph are used. Changes of container sizes (especially viewport the size) are handled in a different way.
Extremes are extended by intrinsic values.** In some cases (see dw::Table::forceCalcCellSizes, case minWidth > totalWidth, for an example) it is useful to know about minimal and maximal width of a widget independent of CSS attributes. For this, dw::core::Extremes is extended by:
The rules for the calculation:
Another extension of extremes: adjustmentWidth. This is used as minimum for the width, when "adjust_min_width" (or, "adjust_table_min_width", respectively) is set.
The rules for the calculation:
A widget must calculate adjustmentWidth from adjustmentWidth of its children.
Note:* An implementation of dw::core::Widget::getExtremesImpl may set this value after calling dw::core::Widget::correctExtremesOfChild, so that it cannot be used for the correction of extremes. In this case useAdjustmentWidth = false* should be passed to dw::core::Widget::correctExtremesOfChild. On the other hand, if known before, useAdjustmentWidth should be set to true.
Here is a diagram showing all permitted dependencies:
Do CSS size dimensions override intrinsic sizes in all cases?** If a textblock needs at least, say, 100 pixels width so that the text can be read, but has a specification "width: 50px", should half of the text be invisible? Or should the width be corrected again to 100 pixels?
Currently, in the CSS size specification is honoured in all cases, with one exception: see dw::Textblock::sizeRequestImpl and see dw::Textblock::getExtremesImpl (the time when dw::core::Widget::correctRequisition and dw::core::Widget::correctExtremes, respectively, is called).
Not* honouring the CSS size specification in all cases could improve readability in some cases, so this could depend on a user preference.
Update:** There is now a dillorc option adjust_min_width
, which is implemented for widths, but not heights (since it is based on width extremes, but there are currently no height extremes).
Another problem is that in most cases, there is no clippping, so that contents may exceed the allocation of the widget, but redrawing is not necessarily triggered.
Percentage values for margins and paddings, as well as negative margins** are interesting applications, but have not been considered yet. For negative margins, a new attribute dw::core::Widget::extraSpace could solve the problem of widgets sticking out of the allocation of parent.
Clarify percentage heights.** Search in widget.cc, and compare section 10.5 ('height') of the CSS 2.1 specification to section 10.2 ('width').
Fast queue resize does not work fully.** Example: run test/dw-simple-container-test* (dw_simple_container_test.cc), resize (best maximize) the window and follow (e. g. by using RTFL) what happens in consequence of dw::core::Layout::viewportSizeChanged. The dw::SimpleContainer in the middle is not affected, so only the two dw::Textblock's (at the top and at the bottom) call queueResize with fast = true*, and so get NEEDS_RESIZE set; but since it is not set for the dw::SimpleContainer, sizeRequest is never called for the bottom dw::Textblock.
There does not seem to be a real case for this problem in dillo, since all widgets which may contain other widgets (except dw::SimpleContainer, which is not used outside tests) use the available width and height (dw::core::Widget::usesAvailWidth and dw::core::Widget::usesAvailHeight), and so are always affected by viewport size changes.