-
-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Margin model #329
Comments
Consider a row of items: A has height 20 and margin 5, B has height 10 and margin 10 (both with a total height of 30). But what about the row?
It is a little surprising that alignment affects the size requirement, and this turns out to be a problem: size requirements are calculated by Proposal: add optional input alignment to |
What should happen regarding margins on the edge of a window?
For now I won't make any changes here, but I wonder if (sometimes) subtracting margins at the edge of the window would make sense. This would be possible by changing the frame model introduced by #348 to include a subtractive component as suggested above replacing the current |
KAS attempts to provide correct margins automatically. This appears to mostly work, but with some little issues.
Current approach
Exterior margins
Each element, as part of
SizeRules
, details the expected (minimum) margin on each side. When two items are placed next to each other, the margin between them must be at least as large as the margin expected from each item on the neighbouring side.Alignment of elements excludes margins. This results in better visual alignment of rows/columns/grids but potentially larger than expected margins.
The same margin applies between an element and the edge of the window. Correctness of this choice is debatable. (This is relatable to the frame margins discussed below.)
Interior margins
Frames are a special case: they encapsulate some other element, and how content margins should be handled is less clear.
The
FrameRules
type is used to declare the size of a frame, exterior margin size, and the (minimum required) internal margin size. (An internal margin may be used e.g. to draw a selection box.)How the margins of a
FrameRules
are combined with the margins from its content'sSizeRules
depends, currently on what type of frame is used, but correctness of this approach is highly questionable:InnerMargin
,EditBox
andMenuEntry
(horizontal orientation only) usesurround_with_margin
, meaning content margin must appear inside the frameNavFocus
(used for navigation focus visual element only) usessurround_as_margin
, meaning the frame itself is considered a margin around the contentFrame
,Popup
,MenuEntry
(vertical),Button
) usesurround_no_margin
, meaning that the content's margin is simply ignoredThere is logic to the above choices, though imperfect:
NavFocus
should be as inconspicuous as possible when not usedButton
s have a large enough frame that extra margin is not normally requiredEditBox
requires internal margin since the (typical) text content requires this margin for drawing an edit cursorProblems
Having three different modes of combining frame and content margins smells like bad desgin.
Further, it may be preferable to have the method used to combine margins be part of the
FrameRules
type instead of inferred from usage.It is not currently possible for content to request a larger (or any) margin inside some frames, such as in a
Button
. This is notably problematic forComboBox
, which places an arrow mark inside aButton
frame, and results in insufficient margin between this mark and the inside edge of the button frame.It is currently tricky for UI designers to have any direct control over margins, though since our objective is "perfect margins automatically", it would be important to review such cases individually to see why additional control was required. (At the moment, probably the only solution would be to use a special wrapper widget replacing or extending content margins.)
Possible changes
We could always use
surround_as_margin
instead ofsurround_no_margin
, reducing us to two types of margin combination. Practically there is not much difference since the frame is usually large enough to cover content's margin requirements already.We could instead use
surround_with_margin
for some/all of the above frames. The main issue here is that buttons end up too large since the "chrome" of the button frame is already large, and get even larger when a content margin is used in addition.(Further, pop-up menus have somewhat special layout which gets broken when using
surround_with_margin
, though arguably this special layout is just a poor hack).Text elements could push the required text margin inside the text layout object. This would allow
EditBox
not to require an internal margin, but would makeTextButton
s larger and would affect visual alignment of text with other elements.We could try special solutions to problematic cases, e.g. for
ComboBox
wrap content in a frame inside the button to force internal margins (horizontally).We could try giving all elements two different margin sizes: that within frames and that between elements. This seems over complex.
The text was updated successfully, but these errors were encountered: