Skip to content
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

Provide align hints to size_rules #350

Merged
merged 20 commits into from
Aug 17, 2022
Merged

Provide align hints to size_rules #350

merged 20 commits into from
Aug 17, 2022

Conversation

dhardy
Copy link
Collaborator

@dhardy dhardy commented Aug 17, 2022

Re-work how alignment is handled: pass through size_rules, and do not prevent stretching by default. A new layout specifier, pack, is used to limit size and set alignment.

Motivation: #329 — alignment is now available when calculating size_rules, albeit only the input (or parent item's) alignment. The result here is clean enough code.

It is also possible to add alignment information to the returned SizeRules, thus exposing per-item alignment, however this leads to messier code (e.g. content alignment and widget alignment are not always equal, especially for Text content). Moreover, many widgets will prefer to stretch to all available space, thus making more refined combination of margins ineffective.

  • Add field AxisInfo::align: Option<Align> for passing an align-hint into Layout::size_rules
  • Remove AlignHints parameter from Layout::set_rect
  • Add pack layout specifier to size-limit and align content
  • Buttons are no longer automatically size-limited and aligned when not using Align::Stretch
  • Stretch::None does not prevent stretching (see also Stretch model (usage of excess space) #349)
  • Add AlignPair, replacing CompleteAlignment
  • Text: SizeMgr::text_rules now sets alignment; ConfigMgr::text_set_size can optionally set alignment
  • Slider widget: use ConfigMgr::align_feature
  • Gallery: adjust scroll bars; pack theme-colour buttons
  • Sub and SubAssign impls for Size now use saturating subtraction; remove Size::clamped_sub

@dhardy dhardy merged commit 963a36b into master Aug 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant