add overlap icon when maximized

This commit is contained in:
SunDoge 2022-11-14 21:02:59 +08:00
parent 817236f640
commit d644b6bc8c

View file

@ -21,9 +21,7 @@ fn main() {
} }
#[derive(Default)] #[derive(Default)]
struct MyApp { struct MyApp {}
maximized: bool,
}
impl eframe::App for MyApp { impl eframe::App for MyApp {
fn clear_color(&self, _visuals: &egui::Visuals) -> egui::Rgba { fn clear_color(&self, _visuals: &egui::Visuals) -> egui::Rgba {
@ -118,16 +116,17 @@ fn custom_window_frame(
frame.set_minimized(true); frame.set_minimized(true);
} }
let is_maximized = frame.info().window_info.maximized;
let maximized_response = ui.put( let maximized_response = ui.put(
Rect::from_min_size( Rect::from_min_size(
rect.left_top() + vec2((height - 4.0) * 2.0, 0.0), rect.left_top() + vec2((height - 4.0) * 2.0, 0.0),
Vec2::splat(height), Vec2::splat(height),
), ),
Button::new(RichText::new("🗖").size(height - 4.0)).frame(false), Button::new(RichText::new(if is_maximized { "🗗" } else { "🗖" }).size(height - 4.0))
.frame(false),
); );
if maximized_response.clicked() { if maximized_response.clicked() {
app.maximized = !app.maximized; frame.set_maximized(!is_maximized);
frame.set_maximized(app.maximized);
} }
// Add the contents: // Add the contents: