mirror of
https://github.com/cds-astro/aladin-lite.git
synced 2026-01-14 14:08:07 -08:00
First step to fix touchmove
This commit is contained in:
@@ -954,8 +954,8 @@ pub fn install_canvas_events(runner_ref: GuiRef) -> Result<(), JsValue> {
|
||||
|
||||
push_touches(&mut *runner_lock, egui::TouchPhase::Start, &event);
|
||||
runner_lock.needs_repaint.set_true();
|
||||
event.stop_propagation();
|
||||
event.prevent_default();
|
||||
//event.stop_propagation();
|
||||
//event.prevent_default();
|
||||
}) as Box<dyn FnMut(_)>);
|
||||
canvas.add_event_listener_with_callback(event_name, closure.as_ref().unchecked_ref())?;
|
||||
closure.forget();
|
||||
@@ -978,8 +978,10 @@ pub fn install_canvas_events(runner_ref: GuiRef) -> Result<(), JsValue> {
|
||||
|
||||
push_touches(&mut *runner_lock, egui::TouchPhase::Move, &event);
|
||||
runner_lock.needs_repaint.set_true();
|
||||
event.stop_propagation();
|
||||
event.prevent_default();
|
||||
runner_lock.cur_mouse_pos = pos;
|
||||
|
||||
//event.stop_propagation();
|
||||
//event.prevent_default();
|
||||
}) as Box<dyn FnMut(_)>);
|
||||
canvas.add_event_listener_with_callback(event_name, closure.as_ref().unchecked_ref())?;
|
||||
closure.forget();
|
||||
@@ -1008,8 +1010,8 @@ pub fn install_canvas_events(runner_ref: GuiRef) -> Result<(), JsValue> {
|
||||
|
||||
push_touches(&mut *runner_lock, egui::TouchPhase::End, &event);
|
||||
runner_lock.needs_repaint.set_true();
|
||||
event.stop_propagation();
|
||||
event.prevent_default();
|
||||
//event.stop_propagation();
|
||||
//event.prevent_default();
|
||||
|
||||
// Finally, focus or blur on agent to toggle keyboard
|
||||
manipulate_agent(&runner_lock, runner_lock.input.latest_touch_pos);
|
||||
|
||||
@@ -13,6 +13,7 @@ pub struct LayerLayout {
|
||||
use crate::widgets::SurveyGrid;
|
||||
use crate::Event;
|
||||
|
||||
use egui::InnerResponse;
|
||||
use wasm_bindgen::prelude::JsValue;
|
||||
use std::sync::{Arc, Mutex};
|
||||
impl LayerLayout {
|
||||
@@ -25,8 +26,8 @@ impl LayerLayout {
|
||||
})
|
||||
}
|
||||
|
||||
pub fn show(&mut self, ui: &mut egui::Ui, events: Arc<Mutex<Vec<Event>>>) {
|
||||
egui::Window::new("Aladin Lite v3")
|
||||
pub fn show(&mut self, ui: &mut egui::Ui, events: Arc<Mutex<Vec<Event>>>) -> egui::Rect {
|
||||
let response = egui::Window::new("Aladin Lite v3")
|
||||
.collapsible(true)
|
||||
.show(ui.ctx(), |ui| {
|
||||
ui.set_max_width(270.0);
|
||||
@@ -70,6 +71,9 @@ impl LayerLayout {
|
||||
wasm_bindgen_futures::spawn_local(fut);
|
||||
}
|
||||
});
|
||||
response.unwrap()
|
||||
.response
|
||||
.rect
|
||||
}
|
||||
|
||||
fn ui(&mut self, ui: &mut egui::Ui, events: Arc<Mutex<Vec<Event>>>) {
|
||||
|
||||
@@ -77,6 +77,8 @@ pub struct Gui {
|
||||
}
|
||||
use al_core::WebGlContext;
|
||||
use std::sync::{Arc, Mutex};
|
||||
use egui::Pos2;
|
||||
use cgmath::Vector2;
|
||||
impl Gui {
|
||||
pub fn new(aladin_lite_div: &str, gl: &WebGlContext) -> Result<GuiRef, JsValue> {
|
||||
let ctx = egui::CtxRef::default();
|
||||
@@ -91,7 +93,7 @@ impl Gui {
|
||||
let gui = Self {
|
||||
ctx,
|
||||
painter,
|
||||
|
||||
|
||||
input,
|
||||
layout,
|
||||
clipped_meshes: None,
|
||||
@@ -167,10 +169,11 @@ impl Gui {
|
||||
});
|
||||
});*/
|
||||
|
||||
layout.show(ui, events);
|
||||
layout.show(ui, events)
|
||||
});
|
||||
|
||||
self.mouse_on_ui = !response.response.hovered();
|
||||
self.mouse_on_ui = response.inner.contains(self.cur_mouse_pos);
|
||||
al_core::log(&format!("mouse: {:?}", self.mouse_on_ui));
|
||||
}
|
||||
self.painter.upload_egui_texture(&self.ctx.texture());
|
||||
|
||||
|
||||
@@ -491,6 +491,7 @@ export let View = (function() {
|
||||
if(view.aladin.webglAPI.posOnUi()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// zoom pinching
|
||||
if (e.type==='touchstart' && e.originalEvent && e.originalEvent.targetTouches && e.originalEvent.targetTouches.length==2) {
|
||||
view.dragging = false;
|
||||
@@ -522,7 +523,7 @@ export let View = (function() {
|
||||
view.dragy = xymouse.y;
|
||||
}
|
||||
|
||||
|
||||
console.log("AAAA")
|
||||
view.dragging = true;
|
||||
if (view.mode==View.PAN) {
|
||||
view.setCursor('move');
|
||||
@@ -689,8 +690,8 @@ export let View = (function() {
|
||||
e.preventDefault();
|
||||
var xymouse = view.imageCanvas.relMouseCoords(e);
|
||||
p = xymouse;
|
||||
if(view.aladin.webglAPI.posOnUi()) {
|
||||
|
||||
if(view.aladin.webglAPI.posOnUi()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -766,7 +767,6 @@ export let View = (function() {
|
||||
if (! view.dragging) {
|
||||
return;
|
||||
}
|
||||
|
||||
//var xoffset, yoffset;
|
||||
var s1, s2;
|
||||
if (e.originalEvent && e.originalEvent.targetTouches) {
|
||||
|
||||
Reference in New Issue
Block a user