Merge lp://staging/~rafalcieslak256/millenniumduel/containers into lp://staging/millenniumduel
Status: | Merged |
---|---|
Merged at revision: | 10 |
Proposed branch: | lp://staging/~rafalcieslak256/millenniumduel/containers |
Merge into: | lp://staging/millenniumduel |
Diff against target: |
765 lines (+408/-108) 18 files modified
src/Box.cpp (+59/-0) src/Box.hpp (+47/-0) src/Fixed.cpp (+28/-30) src/Fixed.hpp (+17/-16) src/HBox.cpp (+61/-0) src/HBox.hpp (+11/-0) src/VBox.cpp (+60/-0) src/VBox.hpp (+11/-0) src/build (+1/-1) src/button.cpp (+10/-4) src/button.hpp (+5/-2) src/display.cpp (+9/-10) src/display.hpp (+6/-4) src/drawable.cpp (+17/-7) src/drawable.hpp (+33/-11) src/label.cpp (+11/-4) src/label.hpp (+4/-1) src/main.cpp (+18/-18) |
To merge this branch: | bzr merge lp://staging/~rafalcieslak256/millenniumduel/containers |
Related bugs: | |
Related blueprints: |
Container widgets
(Medium)
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Adam Malinowski | Approve | ||
Jakub Sękowski | Approve | ||
Review via email:
|
Description of the change
This branch implements Container widgets (namely a custom VBox and a HBox).
[https:/
These widgets are meant to spread evenly widgets aligned horizontally or vertically.
They are kind of similar to GTK's boxes, but one should not assume any similarities.
This branch also significantly changes the way draw() is used. It is now called with a set of 4 values, representing coordinates of a rectangular area where the widget should draw itself.
This way all widgets can be drawn in variety of sizes.
All Drawables can also provide the minimal size they need for drawing (for example, a button cannot be too thin or its text will not fit). These can be learned by calling GetMinimalHeight and GetMinimalWidth.
Both boxes are used by appending widgets with Add(drawable). By default all items are shrinked to minimum, except for those that are added with BOX_EXPAND as a second argument to Add, these will be spread evenly.
One can set the space between boxes with SetSpacing, as well as the margin around the Box with SetMargin (both default to 0).
Of course, Boxes are also a Drawable, and therefore can be nested freely.
Another change introduced by this branch is that a View widget (renamed to Fixed) is now a Drawable.
The Display class requires now a Drawable to be the topmost widget, it does not have to be a Fixed (View).
The example in main() sets a VBox as the main menu, shrinking and expanding some of the buttons. The additional menu is left as it was, as a Fixed.
NOTE: This code does not fix bug #1198640.
Why items in Box are stored in a set? I would use list or vector instead. Ordering of items would be clear and member order (of struct BoxEntry) wouldn't be needed.