mirror of
https://github.com/emilk/egui.git
synced 2026-08-30 05:10:03 -04:00
Add helpers for zooming an app using Ctrl+Plus and Ctrl+Minus (#2239)
* Using tracing-subscriber in hello_world example * Add Key::Plus/Minus/Equals * Warn if failing to guess OS from User-Agent * Remove jitter when using Context::set_pixels_per_point * Demo app: zoom in/out using ⌘+ and ⌘- * Demo app: make backend panel GUI scale slider better * Optimize debug builds a bit * typo * Update changelog * Add helper module `egui::gui_zoom` for zooming an app * Better names, and update changelog * Combine Plus and Equals keys * Last fix * Fix docs
This commit is contained in:
@@ -113,83 +113,88 @@ pub fn should_ignore_key(key: &str) -> bool {
|
||||
/// Web sends all all keys as strings, so it is up to us to figure out if it is
|
||||
/// a real text input or the name of a key.
|
||||
pub fn translate_key(key: &str) -> Option<egui::Key> {
|
||||
use egui::Key;
|
||||
|
||||
match key {
|
||||
"ArrowDown" => Some(egui::Key::ArrowDown),
|
||||
"ArrowLeft" => Some(egui::Key::ArrowLeft),
|
||||
"ArrowRight" => Some(egui::Key::ArrowRight),
|
||||
"ArrowUp" => Some(egui::Key::ArrowUp),
|
||||
"ArrowDown" => Some(Key::ArrowDown),
|
||||
"ArrowLeft" => Some(Key::ArrowLeft),
|
||||
"ArrowRight" => Some(Key::ArrowRight),
|
||||
"ArrowUp" => Some(Key::ArrowUp),
|
||||
|
||||
"Esc" | "Escape" => Some(egui::Key::Escape),
|
||||
"Tab" => Some(egui::Key::Tab),
|
||||
"Backspace" => Some(egui::Key::Backspace),
|
||||
"Enter" => Some(egui::Key::Enter),
|
||||
"Space" | " " => Some(egui::Key::Space),
|
||||
"Esc" | "Escape" => Some(Key::Escape),
|
||||
"Tab" => Some(Key::Tab),
|
||||
"Backspace" => Some(Key::Backspace),
|
||||
"Enter" => Some(Key::Enter),
|
||||
"Space" | " " => Some(Key::Space),
|
||||
|
||||
"Help" | "Insert" => Some(egui::Key::Insert),
|
||||
"Delete" => Some(egui::Key::Delete),
|
||||
"Home" => Some(egui::Key::Home),
|
||||
"End" => Some(egui::Key::End),
|
||||
"PageUp" => Some(egui::Key::PageUp),
|
||||
"PageDown" => Some(egui::Key::PageDown),
|
||||
"Help" | "Insert" => Some(Key::Insert),
|
||||
"Delete" => Some(Key::Delete),
|
||||
"Home" => Some(Key::Home),
|
||||
"End" => Some(Key::End),
|
||||
"PageUp" => Some(Key::PageUp),
|
||||
"PageDown" => Some(Key::PageDown),
|
||||
|
||||
"0" => Some(egui::Key::Num0),
|
||||
"1" => Some(egui::Key::Num1),
|
||||
"2" => Some(egui::Key::Num2),
|
||||
"3" => Some(egui::Key::Num3),
|
||||
"4" => Some(egui::Key::Num4),
|
||||
"5" => Some(egui::Key::Num5),
|
||||
"6" => Some(egui::Key::Num6),
|
||||
"7" => Some(egui::Key::Num7),
|
||||
"8" => Some(egui::Key::Num8),
|
||||
"9" => Some(egui::Key::Num9),
|
||||
"-" => Some(Key::Minus),
|
||||
"+" | "=" => Some(Key::PlusEquals),
|
||||
|
||||
"a" | "A" => Some(egui::Key::A),
|
||||
"b" | "B" => Some(egui::Key::B),
|
||||
"c" | "C" => Some(egui::Key::C),
|
||||
"d" | "D" => Some(egui::Key::D),
|
||||
"e" | "E" => Some(egui::Key::E),
|
||||
"f" | "F" => Some(egui::Key::F),
|
||||
"g" | "G" => Some(egui::Key::G),
|
||||
"h" | "H" => Some(egui::Key::H),
|
||||
"i" | "I" => Some(egui::Key::I),
|
||||
"j" | "J" => Some(egui::Key::J),
|
||||
"k" | "K" => Some(egui::Key::K),
|
||||
"l" | "L" => Some(egui::Key::L),
|
||||
"m" | "M" => Some(egui::Key::M),
|
||||
"n" | "N" => Some(egui::Key::N),
|
||||
"o" | "O" => Some(egui::Key::O),
|
||||
"p" | "P" => Some(egui::Key::P),
|
||||
"q" | "Q" => Some(egui::Key::Q),
|
||||
"r" | "R" => Some(egui::Key::R),
|
||||
"s" | "S" => Some(egui::Key::S),
|
||||
"t" | "T" => Some(egui::Key::T),
|
||||
"u" | "U" => Some(egui::Key::U),
|
||||
"v" | "V" => Some(egui::Key::V),
|
||||
"w" | "W" => Some(egui::Key::W),
|
||||
"x" | "X" => Some(egui::Key::X),
|
||||
"y" | "Y" => Some(egui::Key::Y),
|
||||
"z" | "Z" => Some(egui::Key::Z),
|
||||
"0" => Some(Key::Num0),
|
||||
"1" => Some(Key::Num1),
|
||||
"2" => Some(Key::Num2),
|
||||
"3" => Some(Key::Num3),
|
||||
"4" => Some(Key::Num4),
|
||||
"5" => Some(Key::Num5),
|
||||
"6" => Some(Key::Num6),
|
||||
"7" => Some(Key::Num7),
|
||||
"8" => Some(Key::Num8),
|
||||
"9" => Some(Key::Num9),
|
||||
|
||||
"F1" => Some(egui::Key::F1),
|
||||
"F2" => Some(egui::Key::F2),
|
||||
"F3" => Some(egui::Key::F3),
|
||||
"F4" => Some(egui::Key::F4),
|
||||
"F5" => Some(egui::Key::F5),
|
||||
"F6" => Some(egui::Key::F6),
|
||||
"F7" => Some(egui::Key::F7),
|
||||
"F8" => Some(egui::Key::F8),
|
||||
"F9" => Some(egui::Key::F9),
|
||||
"F10" => Some(egui::Key::F10),
|
||||
"F11" => Some(egui::Key::F11),
|
||||
"F12" => Some(egui::Key::F12),
|
||||
"F13" => Some(egui::Key::F13),
|
||||
"F14" => Some(egui::Key::F14),
|
||||
"F15" => Some(egui::Key::F15),
|
||||
"F16" => Some(egui::Key::F16),
|
||||
"F17" => Some(egui::Key::F17),
|
||||
"F18" => Some(egui::Key::F18),
|
||||
"F19" => Some(egui::Key::F19),
|
||||
"F20" => Some(egui::Key::F20),
|
||||
"a" | "A" => Some(Key::A),
|
||||
"b" | "B" => Some(Key::B),
|
||||
"c" | "C" => Some(Key::C),
|
||||
"d" | "D" => Some(Key::D),
|
||||
"e" | "E" => Some(Key::E),
|
||||
"f" | "F" => Some(Key::F),
|
||||
"g" | "G" => Some(Key::G),
|
||||
"h" | "H" => Some(Key::H),
|
||||
"i" | "I" => Some(Key::I),
|
||||
"j" | "J" => Some(Key::J),
|
||||
"k" | "K" => Some(Key::K),
|
||||
"l" | "L" => Some(Key::L),
|
||||
"m" | "M" => Some(Key::M),
|
||||
"n" | "N" => Some(Key::N),
|
||||
"o" | "O" => Some(Key::O),
|
||||
"p" | "P" => Some(Key::P),
|
||||
"q" | "Q" => Some(Key::Q),
|
||||
"r" | "R" => Some(Key::R),
|
||||
"s" | "S" => Some(Key::S),
|
||||
"t" | "T" => Some(Key::T),
|
||||
"u" | "U" => Some(Key::U),
|
||||
"v" | "V" => Some(Key::V),
|
||||
"w" | "W" => Some(Key::W),
|
||||
"x" | "X" => Some(Key::X),
|
||||
"y" | "Y" => Some(Key::Y),
|
||||
"z" | "Z" => Some(Key::Z),
|
||||
|
||||
"F1" => Some(Key::F1),
|
||||
"F2" => Some(Key::F2),
|
||||
"F3" => Some(Key::F3),
|
||||
"F4" => Some(Key::F4),
|
||||
"F5" => Some(Key::F5),
|
||||
"F6" => Some(Key::F6),
|
||||
"F7" => Some(Key::F7),
|
||||
"F8" => Some(Key::F8),
|
||||
"F9" => Some(Key::F9),
|
||||
"F10" => Some(Key::F10),
|
||||
"F11" => Some(Key::F11),
|
||||
"F12" => Some(Key::F12),
|
||||
"F13" => Some(Key::F13),
|
||||
"F14" => Some(Key::F14),
|
||||
"F15" => Some(Key::F15),
|
||||
"F16" => Some(Key::F16),
|
||||
"F17" => Some(Key::F17),
|
||||
"F18" => Some(Key::F18),
|
||||
"F19" => Some(Key::F19),
|
||||
"F20" => Some(Key::F20),
|
||||
|
||||
_ => None,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user