mirror of
https://github.com/emilk/egui.git
synced 2026-09-01 06:10:06 -04:00
update custom_window_frame example
This commit is contained in:
@@ -84,15 +84,6 @@ fn custom_window_frame(
|
|||||||
Stroke::new(1.0, text_color),
|
Stroke::new(1.0, text_color),
|
||||||
);
|
);
|
||||||
|
|
||||||
// Add the close button:
|
|
||||||
let close_response = ui.put(
|
|
||||||
Rect::from_min_size(rect.left_top(), Vec2::splat(height)),
|
|
||||||
Button::new(RichText::new("❌").size(height - 4.0)).frame(false),
|
|
||||||
);
|
|
||||||
if close_response.clicked() {
|
|
||||||
frame.close();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Interact with the title bar (drag to move window):
|
// Interact with the title bar (drag to move window):
|
||||||
let title_bar_rect = {
|
let title_bar_rect = {
|
||||||
let mut rect = rect;
|
let mut rect = rect;
|
||||||
@@ -105,6 +96,26 @@ fn custom_window_frame(
|
|||||||
frame.drag_window();
|
frame.drag_window();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Add the close button:
|
||||||
|
let close_response = ui.put(
|
||||||
|
Rect::from_min_size(rect.left_top(), Vec2::splat(height)),
|
||||||
|
Button::new(RichText::new("❌").size(height - 4.0)).frame(false),
|
||||||
|
);
|
||||||
|
if close_response.clicked() {
|
||||||
|
frame.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
let minimized_response = ui.put(
|
||||||
|
Rect::from_min_size(
|
||||||
|
rect.left_top() + vec2((height - 4.0) * 1.0, 0.0),
|
||||||
|
Vec2::splat(height),
|
||||||
|
),
|
||||||
|
Button::new(RichText::new("🗕").size(height - 4.0)).frame(false),
|
||||||
|
);
|
||||||
|
if minimized_response.clicked() {
|
||||||
|
frame.set_minimized(true);
|
||||||
|
}
|
||||||
|
|
||||||
// Add the contents:
|
// Add the contents:
|
||||||
let content_rect = {
|
let content_rect = {
|
||||||
let mut rect = rect;
|
let mut rect = rect;
|
||||||
|
|||||||
Reference in New Issue
Block a user