Skip to content

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

Merged
emilk merged 16 commits into
masterfrom
emilk/border
Jan 4, 2025
Merged

emilk merged 16 commits into
masterfrom
emilk/border

Conversation

@emilk

@emilk emilk commented Jan 3, 2025

Copy link
Copy Markdown
Owner

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
@github-actions

github-actions Bot commented Jan 3, 2025

Copy link
Copy Markdown

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
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