|
@@ -857,7 +857,7 @@ impl BaseEdit {
|
|
|
}
|
|
}
|
|
|
true
|
|
true
|
|
|
}
|
|
}
|
|
|
- async fn handle_touch_end(&self, atom: &mut PropertyAtomicGuard, mut touch_pos: Point) -> bool {
|
|
|
|
|
|
|
+ async fn handle_touch_end(&self, mut touch_pos: Point) -> bool {
|
|
|
//t!("handle_touch_end({touch_pos:?})");
|
|
//t!("handle_touch_end({touch_pos:?})");
|
|
|
self.abs_to_local(&mut touch_pos);
|
|
self.abs_to_local(&mut touch_pos);
|
|
|
|
|
|
|
@@ -865,6 +865,7 @@ impl BaseEdit {
|
|
|
match state {
|
|
match state {
|
|
|
TouchStateAction::Inactive => return false,
|
|
TouchStateAction::Inactive => return false,
|
|
|
TouchStateAction::Started { pos: _, instant: _ } | TouchStateAction::SetCursorPos => {
|
|
TouchStateAction::Started { pos: _, instant: _ } | TouchStateAction::SetCursorPos => {
|
|
|
|
|
+ let atom = &mut self.render_api.make_guard(gfxtag!("BaseEdit::handle_touch_end"));
|
|
|
self.touch_set_cursor_pos(atom, touch_pos).await;
|
|
self.touch_set_cursor_pos(atom, touch_pos).await;
|
|
|
self.redraw(atom).await;
|
|
self.redraw(atom).await;
|
|
|
}
|
|
}
|
|
@@ -980,7 +981,7 @@ impl BaseEdit {
|
|
|
|
|
|
|
|
editor.selected_text()
|
|
editor.selected_text()
|
|
|
};
|
|
};
|
|
|
- //d!("Select {seltext:?} from {clip_mouse_pos:?} (unclipped: {mouse_pos:?}) to ({sel_start}, {sel_end})");
|
|
|
|
|
|
|
+ //d!("Select {seltext:?} from {clip_mouse_pos:?} (unclipped: {mouse_pos:?})");
|
|
|
|
|
|
|
|
// Android editor impl detail: selection disappears when anchor == index
|
|
// Android editor impl detail: selection disappears when anchor == index
|
|
|
// But we disallow this so it should never happen. Just making a note of it here.
|
|
// But we disallow this so it should never happen. Just making a note of it here.
|
|
@@ -1047,6 +1048,7 @@ impl BaseEdit {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
async fn redraw_select(&self, batch_id: BatchGuardId) {
|
|
async fn redraw_select(&self, batch_id: BatchGuardId) {
|
|
|
|
|
+ //t!("redraw_select");
|
|
|
let sel_instrs = self.regen_select_mesh().await;
|
|
let sel_instrs = self.regen_select_mesh().await;
|
|
|
let phone_sel_instrs = self.regen_phone_select_handle_mesh().await;
|
|
let phone_sel_instrs = self.regen_phone_select_handle_mesh().await;
|
|
|
let draw_calls = vec![
|
|
let draw_calls = vec![
|
|
@@ -1315,13 +1317,10 @@ impl BaseEdit {
|
|
|
|
|
|
|
|
// Nothing changed. Just return.
|
|
// Nothing changed. Just return.
|
|
|
if !is_text_changed && !is_select_changed && !is_compose_changed {
|
|
if !is_text_changed && !is_select_changed && !is_compose_changed {
|
|
|
- t!("Skipping update since nothing changed");
|
|
|
|
|
|
|
+ //t!("Skipping update since nothing changed");
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- self.eval_rect().await;
|
|
|
|
|
- self.behave.apply_cursor_scroll().await;
|
|
|
|
|
-
|
|
|
|
|
//t!("is_text_changed={is_text_changed}, is_select_changed={is_select_changed}, is_compose_changed={is_compose_changed}");
|
|
//t!("is_text_changed={is_text_changed}, is_select_changed={is_select_changed}, is_compose_changed={is_compose_changed}");
|
|
|
// Only redraw once we have the parent_rect
|
|
// Only redraw once we have the parent_rect
|
|
|
// Can happen when we receive an Android event before the canvas is ready
|
|
// Can happen when we receive an Android event before the canvas is ready
|
|
@@ -1331,6 +1330,9 @@ impl BaseEdit {
|
|
|
|
|
|
|
|
// Text changed - finish any active selection
|
|
// Text changed - finish any active selection
|
|
|
if is_text_changed || is_compose_changed {
|
|
if is_text_changed || is_compose_changed {
|
|
|
|
|
+ self.eval_rect().await;
|
|
|
|
|
+ self.behave.apply_cursor_scroll().await;
|
|
|
|
|
+
|
|
|
self.pause_blinking();
|
|
self.pause_blinking();
|
|
|
//assert!(state.text != self.text.get());
|
|
//assert!(state.text != self.text.get());
|
|
|
self.finish_select(atom);
|
|
self.finish_select(atom);
|
|
@@ -1338,6 +1340,7 @@ impl BaseEdit {
|
|
|
} else if is_select_changed {
|
|
} else if is_select_changed {
|
|
|
// Redrawing the entire text just for select changes is expensive
|
|
// Redrawing the entire text just for select changes is expensive
|
|
|
self.redraw_cursor(atom.batch_id).await;
|
|
self.redraw_cursor(atom.batch_id).await;
|
|
|
|
|
+ //t!("handle_android_event calling redraw_select");
|
|
|
self.redraw_select(atom.batch_id).await;
|
|
self.redraw_select(atom.batch_id).await;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -1360,13 +1363,17 @@ impl UIObject for BaseEdit {
|
|
|
fn init(&self) {
|
|
fn init(&self) {
|
|
|
let mut guard = self.editor.lock_blocking();
|
|
let mut guard = self.editor.lock_blocking();
|
|
|
assert!(guard.is_none());
|
|
assert!(guard.is_none());
|
|
|
- *guard = Some(Editor::new(
|
|
|
|
|
|
|
+ let mut editor = Editor::new(
|
|
|
self.text.clone(),
|
|
self.text.clone(),
|
|
|
self.font_size.clone(),
|
|
self.font_size.clone(),
|
|
|
self.text_color.clone(),
|
|
self.text_color.clone(),
|
|
|
self.window_scale.clone(),
|
|
self.window_scale.clone(),
|
|
|
self.lineheight.clone(),
|
|
self.lineheight.clone(),
|
|
|
- ));
|
|
|
|
|
|
|
+ );
|
|
|
|
|
+ let atom = &mut PropertyAtomicGuard::none();
|
|
|
|
|
+ self.text.set(atom, "the quick brown fox jumped over the");
|
|
|
|
|
+ smol::block_on(editor.on_text_prop_changed());
|
|
|
|
|
+ *guard = Some(editor);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
async fn start(self: Arc<Self>, ex: ExecutorPtr) {
|
|
async fn start(self: Arc<Self>, ex: ExecutorPtr) {
|
|
@@ -1758,12 +1765,10 @@ impl UIObject for BaseEdit {
|
|
|
return false
|
|
return false
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- let atom = &mut self.render_api.make_guard(gfxtag!("BaseEdit::handle_touch"));
|
|
|
|
|
-
|
|
|
|
|
match phase {
|
|
match phase {
|
|
|
TouchPhase::Started => self.handle_touch_start(touch_pos).await,
|
|
TouchPhase::Started => self.handle_touch_start(touch_pos).await,
|
|
|
TouchPhase::Moved => self.handle_touch_move(touch_pos).await,
|
|
TouchPhase::Moved => self.handle_touch_move(touch_pos).await,
|
|
|
- TouchPhase::Ended => self.handle_touch_end(atom, touch_pos).await,
|
|
|
|
|
|
|
+ TouchPhase::Ended => self.handle_touch_end(touch_pos).await,
|
|
|
TouchPhase::Cancelled => false,
|
|
TouchPhase::Cancelled => false,
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|