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

⚠️ Frame now includes stroke width as part of padding #5575

Merged
merged 16 commits into from
Jan 4, 2025
Merged

Conversation

emilk
Copy link
Owner

@emilk emilk commented Jan 3, 2025

Frame now includes the width of the stroke as part of its size. From the new docs:

Frame docs

The total (outer) size of a frame is content_size + inner_margin + 2*stroke.width + outer_margin.

Everything within the stroke is filled with the fill color (if any).

+-----------------^-------------------------------------- -+
|                 | outer_margin                           |
|    +------------v----^------------------------------+    |
|    |                 | stroke width                 |    |
|    |    +------------v---^---------------------+    |    |
|    |    |                | inner_margin        |    |    |
|    |    |    +-----------v----------------+    |    |    |
|    |    |    |             ^              |    |    |    |
|    |    |    |             |              |    |    |    |
|    |    |    |<------ content_size ------>|    |    |    |
|    |    |    |             |              |    |    |    |
|    |    |    |             v              |    |    |    |
|    |    |    +------- content_rect -------+    |    |    |
|    |    |                                      |    |    |
|    |    +-------------fill_rect ---------------+    |    |
|    |                                                |    |
|    +----------------- widget_rect ------------------+    |
|                                                          |
+---------------------- outer_rect ------------------------+

The four rectangles, from inside to outside, are:

  • content_rect: the rectangle that is made available to the inner [Ui] or widget.
  • fill_rect: the rectangle that is filled with the fill color (inside the stroke, if any).
  • widget_rect: is the interactive part of the widget (what sense clicks etc).
  • outer_rect: what is allocated in the outer [Ui], and is what is returned by [Response::rect].

Notes

This required rewriting a lot of the layout code for egui::Window, which was a massive pain. But now the window margin and stroke width is properly accounted for everywhere.

@emilk emilk added egui style visuals and theming labels Jan 3, 2025
Copy link

github-actions bot commented Jan 3, 2025

Preview available at https://egui-pr-preview.github.io/pr/5575-emilkborder
Note that it might take a couple seconds for the update to show up after the preview_build workflow has completed.

@emilk emilk marked this pull request as ready for review January 3, 2025 13:42
@emilk emilk requested a review from lucasmerlin as a code owner January 3, 2025 13:42
@emilk emilk changed the title ⚠️ Frame now included stroke width as part of padding ⚠️ Frame now includes stroke width as part of padding Jan 3, 2025
@emilk emilk merged commit 6607cd9 into master Jan 4, 2025
46 checks passed
@emilk emilk deleted the emilk/border branch January 4, 2025 09:29
@emilk emilk mentioned this pull request Jan 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
egui style visuals and theming
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant