Control's geometry
Control does not directly adjust its size
Instead of adjust self size directly Control can announce 3 parameters per direction (horizontal/vertical):
- Minimum size — minimum required amount of space. Parent must follow this value and guarantee that Control gets enough space. This is the only guaranteed geometry parameter.
- Best size — size at which Control can draw itself in the best way. This parameter is just a recommendation.
- Maximum size — maximum size at which Control want draw itself. It is not always possible to follow this restriction. For example, if window has 2 visible Controls arranged vertically (Control A over Control B) and Control A minimum width larger than Control B maximum width, then both Controls must have the same width. In this case Control B receives larger width than it announce as maximum.
The following restriction applies to these parameters: minimum ≤ best ≤ maximum.
GUI geometry hypervisor (special algorithm implemented by window) takes these parameters and after computation sets appropriate width and height for Control. When Control draw itself it uses these width and height as an available region, but can decide (especially if region is larger than announced maximum size) to draw itself only on some part of available region, in center for example.
Width has priority over height
Width is a primary dimension and height is secondary dimension. This is because in most cases text is horizontal oriented and people prefer vertical scroll over horizontal. Priority of width means: height is a function of width. For example, we have some long text and want to draw it, then height will depend on available width (how much line breaks required).
Algorithm
Following algorithm used to achieve “Control does not directly adjust its size” and “Width has priority over height” (Control's point of view):
- Geometry hypervisor (GH) asks Control about minimal, best and maximum width. Control computes requested parameter based on what exactly and how it would draw.
- GH set Control's width (and horizontal position in window coordinates).
- GH asks Control about minimal, best and maximum height. Here Control can use width from previous step to compute requested parameters.
- GH set Control's height (and vertical position in window coordinates).
- GH request Control to draw. Control draw itself somewhere in region defined by step 2 & 4 of this algorithm.
Events
Events can be categorized by how Controls receive them:
Event | Receiving |
---|---|
Keyboard events (press/release non-modifier key) |
Control which is focused receives this event. Control must decide does it accept event or not. If event is not accepted by Control, then it will be sent to Control's parent (iterating up to window). |
Pointer button press events (press mouse button) |
Topmost (in term of Z index) Control under pointer receives this event. Control must decide whether to accept the event or not. If event is not accepted by Control then it will be sent to “less topmost” Control under pointer (iterating up to window). |
Scroll event (scroll mouse wheel) |
|
Pointer button other events (release/click mouse button) |
Control that received (and accepted) the corresponding pointer button press event receives this event. Event will not be sent to other Controls even if it was not accepted. |
Pointer drag events (drag using mouse button) |
|
Modifiers events (press/release keyboard modifier key) |
All Controls which have previously subscribed to this type of events. |
Window main state event (window becomes main/background) |
|
Window display state event (relates to minimized/maximized/full screen state) |