From 4e5124c7d97244623001733998f98c8255e81adf Mon Sep 17 00:00:00 2001 From: jkds Date: Sun, 11 Jan 2026 11:25:38 +0100 Subject: [PATCH] app/edit: correctly render on android with window_scale applied --- bin/app/src/app/schema/chat.rs | 10 ++++++++++ bin/app/src/gfx/mod.rs | 6 +++--- bin/app/src/ui/edit/mod.rs | 11 ++++++----- 3 files changed, 19 insertions(+), 8 deletions(-) diff --git a/bin/app/src/app/schema/chat.rs b/bin/app/src/app/schema/chat.rs index 23387fbdb..95cdf474c 100644 --- a/bin/app/src/app/schema/chat.rs +++ b/bin/app/src/app/schema/chat.rs @@ -91,6 +91,10 @@ mod android_ui_consts { pub const CMD_HELP_NICK_DESC_WIDTH: f32 = 1000.; pub const CMD_HELP_NICK_DESC_X: f32 = 320.; pub const CMD_HELP_LABEL_Y: f32 = 20.; + + // Action menu + pub const ACTION_PADDING: f32 = 32.; + pub const ACTION_SPACING: f32 = 8.; } #[cfg(target_os = "android")] @@ -152,6 +156,10 @@ mod ui_consts { pub const CMD_HELP_NICK_DESC_WIDTH: f32 = 500.; pub const CMD_HELP_NICK_DESC_X: f32 = 160.; pub const CMD_HELP_LABEL_Y: f32 = 10.; + + // Action menu + pub const ACTION_PADDING: f32 = 8.; + pub const ACTION_SPACING: f32 = 4.; } use super::EMOJI_PICKER_ICON_SIZE; @@ -763,6 +771,8 @@ pub async fn make( node.set_property_f32(atom, Role::App, "select_ascent", CHATEDIT_SELECT_ASCENT).unwrap(); node.set_property_f32(atom, Role::App, "select_descent", CHATEDIT_SELECT_DESCENT).unwrap(); node.set_property_f32(atom, Role::App, "handle_descent", CHATEDIT_HANDLE_DESCENT).unwrap(); + node.set_property_f32(atom, Role::App, "action_padding", ACTION_PADDING).unwrap(); + node.set_property_f32(atom, Role::App, "action_spacing", ACTION_SPACING).unwrap(); let prop = node.get_property("hi_bg_color").unwrap(); if COLOR_SCHEME == ColorScheme::PaperLight { prop.set_f32(atom, Role::App, 0, 0.5).unwrap(); diff --git a/bin/app/src/gfx/mod.rs b/bin/app/src/gfx/mod.rs index 56f520b44..cf9dafba3 100644 --- a/bin/app/src/gfx/mod.rs +++ b/bin/app/src/gfx/mod.rs @@ -788,8 +788,8 @@ impl<'a> RenderContext<'a> { d!("{ws}set_pipeline({pipeline:?})"); } } - GfxDrawInstruction::Overlay(instrs) => { - let pos = self.view.pos() + self.cursor; + GfxDrawInstruction::Overlay(instrs) => { + let pos = self.view.pos() + (self.cursor * self.scale); self.overlays.push(OverlayDefer { pos, instrs: instrs.clone() }); } } @@ -1821,7 +1821,7 @@ impl EventHandler for Stage { loaded_pipelines: &self.loaded_pipelines, scale: 1., view: Rectangle::from([0., 0., screen_w, screen_h]), - cursor: Point::from([0., 0.]), + cursor: Point::zero(), gfx_pipeline: GraphicPipeline::RGB, anims: &mut self.anims, overlays: vec![], diff --git a/bin/app/src/ui/edit/mod.rs b/bin/app/src/ui/edit/mod.rs index b901b4947..2f50babe9 100644 --- a/bin/app/src/ui/edit/mod.rs +++ b/bin/app/src/ui/edit/mod.rs @@ -661,8 +661,12 @@ impl BaseEdit { fn handle_touch_start(&self, touch_pos: Point) -> bool { t!("handle_touch_start({touch_pos:?})"); + let mut local_pos = touch_pos; + self.abs_to_local(&mut local_pos); + t!("localize touch_pos = {local_pos:?}"); + let atom = &mut self.render_api.make_guard(gfxtag!("BaseEdit::handle_touch_start_action")); - if let Some(action_id) = self.action_mode.interact(touch_pos) { + if let Some(action_id) = self.action_mode.interact(local_pos) { match action_id { ACTION_COPY => { if let Some(txt) = self.editor.lock().selected_text() { @@ -697,7 +701,7 @@ impl BaseEdit { return false } - if self.try_handle_drag(touch_pos) { + if self.try_handle_drag(local_pos) { return true } @@ -724,9 +728,6 @@ impl BaseEdit { let editor = self.editor.lock(); let Some((mut first, mut last)) = self.get_select_handles(&editor) else { return false }; - self.abs_to_local(&mut touch_pos); - t!("localize touch_pos = {touch_pos:?}"); - let baseline = self.baseline.get(); let handle_off_y = self.handle_descent.get();