1
0
mirror of https://github.com/emilk/egui.git synced 2026-09-01 06:10:06 -04:00

Add a lot more CursorIcon's

This commit is contained in:
Emil Ernerfeldt
2021-03-13 12:38:03 +01:00
parent ee1fcf1ead
commit 958aea922f
8 changed files with 216 additions and 48 deletions

View File

@@ -173,7 +173,7 @@ pub fn run(mut app: Box<dyn epi::App>) -> ! {
let mut previous_frame_time = None;
let mut painter = Painter::new(&display);
let mut clipboard = init_clipboard();
let mut previous_cursor_icon = None;
let mut current_cursor_icon = CursorIcon::Default;
#[cfg(feature = "persistence")]
let mut last_auto_save = Instant::now();
@@ -209,14 +209,10 @@ pub fn run(mut app: Box<dyn epi::App>) -> ! {
ctx.clear_animations();
let (egui_output, _shapes) = ctx.end_frame();
let new_cursor_icon = egui_output.cursor_icon;
handle_output(egui_output, clipboard.as_mut());
display
.gl_window()
.window()
.set_cursor_icon(translate_cursor(new_cursor_icon));
previous_cursor_icon = Some(new_cursor_icon);
set_cursor_icon(&display, egui_output.cursor_icon);
current_cursor_icon = egui_output.cursor_icon;
handle_output(egui_output, clipboard.as_mut());
// TODO: handle app_output
// eprintln!("Warmed up in {} ms", warm_up_start.elapsed().as_millis())
@@ -285,18 +281,13 @@ pub fn run(mut app: Box<dyn epi::App>) -> ! {
}
screen_reader.speak(&egui_output.events_description());
let new_cursor_icon = egui_output.cursor_icon;
handle_output(egui_output, clipboard.as_mut());
if Some(new_cursor_icon) != previous_cursor_icon {
if current_cursor_icon != egui_output.cursor_icon {
// call only when changed to prevent flickering near frame boundary
// when Windows OS tries to control cursor icon for window resizing
display
.gl_window()
.window()
.set_cursor_icon(translate_cursor(new_cursor_icon));
previous_cursor_icon = Some(new_cursor_icon);
set_cursor_icon(&display, egui_output.cursor_icon);
current_cursor_icon = egui_output.cursor_icon;
}
handle_output(egui_output, clipboard.as_mut());
#[cfg(feature = "persistence")]
if let Some(storage) = &mut storage {