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

Width of the window title bar with custom frame #4024

Closed
Tearth opened this issue Feb 11, 2024 · 3 comments · Fixed by #4032
Closed

Width of the window title bar with custom frame #4024

Tearth opened this issue Feb 11, 2024 · 3 comments · Fixed by #4032
Labels
bug Something is broken

Comments

@Tearth
Copy link

Tearth commented Feb 11, 2024

Describe the bug
While testing #4002 (thanks for the fast fix!) on 0.26.1, I found another issue, or at least I think it was not desired. When setting the inner margin and stroke, the title bar is wider than the window's content as can be seen below. I've put some ridiculous values to show it clearly, but it's visible even when the stroke is just a few pixels wide.

image

To Reproduce
Steps to reproduce the behavior:

  1. Go to egui_demo_lib -> window_options.rs
  2. Find creation of "demo_window_options" window
  3. Make it as below:
use super::View as _;
let frame = egui::containers::Frame::none() // <-- new
	.fill(egui::Color32::from_rgb(180, 220, 160)) // <-- new
	.stroke(egui::Stroke::new(20.0, egui::Color32::from_rgb(40, 100, 30))) // <-- new
	.inner_margin(egui::Margin::symmetric(20.0, 20.0)); // <-- new
let mut window = egui::Window::new(title)
	.id(egui::Id::new("demo_window_options"))
	.frame(frame) // <-- new
	.resizable(resizable)
	.constrain(constrain)
	.collapsible(collapsible)
	.title_bar(title_bar)
	.scroll2(scroll2)
	.enabled(enabled);

Expected behavior
The title bar should respect margin/stroke settings and have the same width as the rest of the window.

@Tearth Tearth added the bug Something is broken label Feb 11, 2024
@rustbasic
Copy link
Contributor

rustbasic commented Feb 11, 2024

Related Issue: #3806

The egui::Window active.
This causes TitleBar to be activated and paint the backgound to display the TitleBar as active.
This occurs because the width (thickness) of the Stroke used in the frame is not excluded when the TitleBar is activated and displayed.

Until the bug is fixed,
You may temporarily disable a title highlight.

             let mut visuals = ui.visuals_mut().clone();
             visuals.window_highlight_topmost = false;
             ui.ctx().set_visuals(visuals);

@rustbasic
Copy link
Contributor

I'm editing this issue for Pull Request, and I think I'll have it done soon.

@Tearth
Copy link
Author

Tearth commented Feb 11, 2024

Thank you!

@emilk emilk closed this as completed in a93c6cd Mar 8, 2024
hacknus pushed a commit to hacknus/egui that referenced this issue Oct 30, 2024
…order or large rounding (emilk#4032)

Currently, the Window frame is displayed incorrectly when using a wide
border or large rounding.

* Closes emilk#3806
* Closes emilk#4024 
* Closes emilk#4025 

* Screencast of egui demo app (emilk:master)


[window-frame-bug.webm](https://github.com/emilk/egui/assets/1274171/391f67fa-ae6f-445a-8c64-1bb575770127)

* Screencast of egui demo app (varphone:hotfix/window-custom-frame)


[window-frame-fixed.webm](https://github.com/emilk/egui/assets/1274171/1953124e-9f7a-4c2d-9024-5d2eece6b87c)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something is broken
Projects
None yet
2 participants