Compare commits
3 commits
master
...
feat-set-m
Author | SHA1 | Date | |
---|---|---|---|
![]() |
77ba7d5163 | ||
![]() |
3e155c9f41 | ||
![]() |
7c2b2149e3 |
3 changed files with 37 additions and 11 deletions
|
@ -789,6 +789,12 @@ impl Frame {
|
|||
}
|
||||
}
|
||||
|
||||
/// Minimize or un-minimize window
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
pub fn set_minimized(&mut self, minimized: bool) {
|
||||
self.output.minimized = Some(minimized);
|
||||
}
|
||||
|
||||
/// for integrations only: call once per frame
|
||||
pub(crate) fn take_app_output(&mut self) -> backend::AppOutput {
|
||||
std::mem::take(&mut self.output)
|
||||
|
@ -1002,5 +1008,9 @@ pub(crate) mod backend {
|
|||
/// Set to some bool to tell the window always on top.
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
pub always_on_top: Option<bool>,
|
||||
|
||||
/// Set to some bool to change window minimization
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
pub minimized: Option<bool>,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -180,6 +180,7 @@ pub fn handle_app_output(
|
|||
window_pos,
|
||||
visible: _, // handled in post_present
|
||||
always_on_top,
|
||||
minimized,
|
||||
} = app_output;
|
||||
|
||||
if let Some(decorated) = decorated {
|
||||
|
@ -218,6 +219,10 @@ pub fn handle_app_output(
|
|||
if let Some(always_on_top) = always_on_top {
|
||||
window.set_always_on_top(always_on_top);
|
||||
}
|
||||
|
||||
if let Some(minimized) = minimized {
|
||||
window.set_minimized(minimized);
|
||||
}
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
|
|
@ -10,8 +10,8 @@ fn main() -> Result<(), eframe::Error> {
|
|||
decorated: false,
|
||||
// To have rounded corners we need transparency:
|
||||
transparent: true,
|
||||
min_window_size: Some(egui::vec2(320.0, 100.0)),
|
||||
initial_window_size: Some(egui::vec2(320.0, 240.0)),
|
||||
min_window_size: Some(egui::vec2(350.0, 100.0)),
|
||||
initial_window_size: Some(egui::vec2(350.0, 240.0)),
|
||||
..Default::default()
|
||||
};
|
||||
eframe::run_native(
|
||||
|
@ -84,15 +84,6 @@ fn custom_window_frame(
|
|||
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):
|
||||
let title_bar_rect = {
|
||||
let mut rect = rect;
|
||||
|
@ -105,6 +96,26 @@ fn custom_window_frame(
|
|||
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:
|
||||
let content_rect = {
|
||||
let mut rect = rect;
|
||||
|
|
Loading…
Reference in a new issue