ui: update egui, fix android back button

This commit is contained in:
ardocrat
2025-11-05 18:11:07 +03:00
parent 215b5d3f27
commit 42bcda621a
7 changed files with 156 additions and 143 deletions
+2 -1
View File
@@ -64,7 +64,8 @@ impl<Platform: PlatformCallbacks> App<Platform> {
}
// Handle Esc keyboard key event.
if ctx.input_mut(|i| i.consume_key(Modifiers::NONE, egui::Key::Escape)) {
if ctx.input_mut(|i| i.consume_key(Modifiers::NONE, egui::Key::Escape) ||
i.consume_key(Modifiers::NONE, egui::Key::BrowserBack)) {
self.content.on_back(&self.platform);
// Request repaint to update previous content.
ctx.request_repaint();
+1 -1
View File
@@ -56,7 +56,7 @@ impl KeyboardContent {
/// Draw keyboard content as separate [`Window`].
pub fn window_ui(&mut self, numeric: bool, ctx: &egui::Context) {
let width = ctx.screen_rect().width();
let width = ctx.content_rect().width();
let layer_id = egui::Window::new(Self::WINDOW_ID)
.title_bar(false)
.resizable(false)
+3 -3
View File
@@ -201,7 +201,7 @@ impl Modal {
// Setup background rect.
let is_win = OperatingSystem::Windows == OperatingSystem::from_target_os();
let bg_rect = if View::is_desktop() && !is_win {
let mut r = ctx.screen_rect();
let mut r = ctx.content_rect();
let is_mac = OperatingSystem::Mac == OperatingSystem::from_target_os();
if !is_mac && !is_fullscreen {
r = r.shrink(Content::WINDOW_FRAME_MARGIN - 1.0);
@@ -209,7 +209,7 @@ impl Modal {
r.min.y += Content::WINDOW_TITLE_HEIGHT;
r
} else {
ctx.screen_rect()
ctx.content_rect()
};
// Draw modal background.
@@ -228,7 +228,7 @@ impl Modal {
// Setup width of modal content.
let side_insets = View::get_left_inset() + View::get_right_inset();
let available_width = ctx.screen_rect().width() - (side_insets + Self::DEFAULT_MARGIN);
let available_width = ctx.content_rect().width() - (side_insets + Self::DEFAULT_MARGIN);
let width = f32::min(available_width, Self::DEFAULT_WIDTH);
// Show main content window at given position.
+1 -1
View File
@@ -83,7 +83,7 @@ impl View {
/// Get width and height of app window.
pub fn window_size(ctx: &egui::Context) -> (f32, f32) {
let rect = ctx.screen_rect();
let rect = ctx.content_rect();
(rect.width(), rect.height())
}
+2 -4
View File
@@ -178,9 +178,8 @@ pub fn setup_fonts(ctx: &Context) {
"../fonts/phosphor.ttf"
)).tweak(egui::FontTweak {
scale: 1.0,
y_offset_factor: -0.20,
y_offset_factor: -0.04,
y_offset: 0.0,
baseline_offset_factor: 0.16,
}),
));
fonts
@@ -195,9 +194,8 @@ pub fn setup_fonts(ctx: &Context) {
"../fonts/noto_sc_reg.otf"
)).tweak(egui::FontTweak {
scale: 1.0,
y_offset_factor: -0.25,
y_offset_factor: -0.08,
y_offset: 0.0,
baseline_offset_factor: 0.17,
}),
));
fonts