mirror of
https://github.com/enso-org/enso.git
synced 2024-12-21 12:02:27 +03:00
Fixing IDE layout by taking into consideration the new scene origin (https://github.com/enso-org/ide/pull/573)
Original commit: 7038d2702f
This commit is contained in:
parent
f88a1c20fd
commit
790d668731
@ -140,8 +140,11 @@ pub struct MouseFrpCallbackHandles {
|
||||
/// Bind FRP graph to MouseManager.
|
||||
pub fn bind_frp_to_mouse(frp:&enso_frp::io::Mouse, mouse_manager:&MouseManager)
|
||||
-> MouseFrpCallbackHandles {
|
||||
let dom_shape = mouse_manager.dom.clone_ref().shape();
|
||||
let on_move = enclose!((frp.position => frp) move |e:&OnMove| {
|
||||
frp.emit(Vector2(e.client_x() as f32,e.client_y() as f32));
|
||||
let position = Vector2(e.client_x() as f32,e.client_y() as f32);
|
||||
let position = position - Vector2(dom_shape.width,dom_shape.height) / 2.0;
|
||||
frp.emit(position);
|
||||
});
|
||||
let on_down = enclose!((frp.down => frp) move |_:&OnDown | frp.emit(()));
|
||||
let on_up = enclose!((frp.up => frp) move |_:&OnUp | frp.emit(()));
|
||||
|
@ -62,11 +62,7 @@ impl Navigator {
|
||||
let distance_to_show_full_ui = dom.shape().height / 2.0 / fovy_slope;
|
||||
let movement_scale_for_distance = distance / distance_to_show_full_ui;
|
||||
|
||||
// FIXME: Adding - here as panning was accidentally inverted by some recent changes.
|
||||
// Issue tracked by wdanilo and notdanilo.
|
||||
let dx = - pan.movement.x * movement_scale_for_distance;
|
||||
let dy = - pan.movement.y * movement_scale_for_distance;
|
||||
let diff = Vector3::new(dx,dy,0.0);
|
||||
let diff = Vector3::new(pan.movement.x,pan.movement.y,0.0)*movement_scale_for_distance;
|
||||
simulator.update_target_value(|p| p - diff);
|
||||
});
|
||||
|
||||
|
@ -232,8 +232,8 @@ impl NavigatorEvents {
|
||||
let zoom_event = ZoomEvent::new(position,amount,zoom_speed);
|
||||
data.on_zoom(zoom_event);
|
||||
} else {
|
||||
let x = event.delta_x() as f32;
|
||||
let y = -event.delta_y() as f32;
|
||||
let x = -event.delta_x() as f32;
|
||||
let y = event.delta_y() as f32;
|
||||
let movement = Vector2::new(x,y);
|
||||
let pan_event = PanEvent::new(movement);
|
||||
data.on_pan(pan_event);
|
||||
|
@ -10,11 +10,11 @@ use crate::view::node_editor::NodeEditor;
|
||||
use crate::view::node_searcher::NodeSearcher;
|
||||
|
||||
use enso_callback as callback;
|
||||
use enso_frp::io::keyboard;
|
||||
use enso_frp as frp;
|
||||
use frp::io::keyboard;
|
||||
use ensogl::application::Application;
|
||||
use ensogl::display::shape::text::glyph::font;
|
||||
use ensogl::display::traits::*;
|
||||
use ensogl::display::Uniform;
|
||||
use ensogl::display::world::World;
|
||||
use nalgebra::Vector2;
|
||||
use nalgebra::zero;
|
||||
@ -32,14 +32,13 @@ shared! { ViewLayout
|
||||
/// Initial implementation of ViewLayout with a TextEditor and NodeEditor.
|
||||
#[derive(Debug)]
|
||||
pub struct ViewLayoutData {
|
||||
network : frp::Network,
|
||||
mouse_position_sampler : frp::Sampler<Vector2<f32>>,
|
||||
text_editor : TextEditor,
|
||||
node_editor : NodeEditor,
|
||||
node_searcher : NodeSearcher,
|
||||
size : Vector2<f32>,
|
||||
logger : Logger,
|
||||
/// FIXME[dg]: This is a provisional code. Getting the mouse position from Uniform is bad. Mouse
|
||||
/// position should be retrieved from the frp network instead.
|
||||
mouse_position : Uniform<Vector2<i32>>,
|
||||
node_searcher_show_action : Option<callback::Handle>
|
||||
}
|
||||
|
||||
@ -65,7 +64,7 @@ impl ViewLayoutData {
|
||||
|
||||
fn update_text_editor(&mut self) {
|
||||
let screen_size = self.size;
|
||||
let position = Vector2::new(0.0,screen_size.y / 2.0);
|
||||
let position = Vector2::new(-screen_size.x / 2.0,0.0);
|
||||
let size = Vector2::new(screen_size.x,screen_size.y / 2.0);
|
||||
let padding = TemporaryPadding {
|
||||
left : 10.0,
|
||||
@ -80,7 +79,7 @@ impl ViewLayoutData {
|
||||
|
||||
fn update_graph_editor(&mut self) {
|
||||
let screen_size = self.size;
|
||||
let position = Vector3::new(50.0, screen_size.y * 3.0 / 4.0, 0.0);
|
||||
let position = Vector3::new(50.0 - screen_size.x / 2.0, screen_size.y / 4.0, 0.0);
|
||||
self.node_editor.set_position(position);
|
||||
}
|
||||
|
||||
@ -112,11 +111,13 @@ impl ViewLayout {
|
||||
world.add_child(&text_editor.display_object());
|
||||
world.add_child(&node_editor);
|
||||
world.add_child(&node_searcher);
|
||||
let size = zero();
|
||||
let mouse_position = world.scene().mouse.position.clone_ref();
|
||||
let size = zero();
|
||||
let scene = world.scene();
|
||||
let mouse = &scene.mouse.frp;
|
||||
frp::new_network! { network def mouse_position_sampler = mouse.position.sampler(); }
|
||||
let node_searcher_show_action = None;
|
||||
let data = ViewLayoutData{text_editor,node_editor,node_searcher,size,logger,mouse_position,
|
||||
node_searcher_show_action};
|
||||
let data = ViewLayoutData{network,text_editor,node_editor,node_searcher,size,logger,
|
||||
node_searcher_show_action,mouse_position_sampler};
|
||||
let rc = Rc::new(RefCell::new(data));
|
||||
Ok(Self {rc}.init(world,kb_actions))
|
||||
}
|
||||
@ -127,9 +128,9 @@ impl ViewLayout {
|
||||
let keys = &[keyboard::Key::Tab];
|
||||
let node_searcher_show_action = keyboard_actions.add_action(keys, move || {
|
||||
let mut layout = layout.borrow_mut();
|
||||
let position = layout.mouse_position.get();
|
||||
let position = *layout.mouse_position_sampler.value();
|
||||
//TODO[dg]: Test it when graph scene panning is working.
|
||||
let node_searcher_position = Vector3::new(position.x as f32,position.y as f32,0.0);
|
||||
let node_searcher_position = Vector3::new(position.x,position.y,0.0);
|
||||
layout.node_searcher.set_position(node_searcher_position);
|
||||
layout.node_searcher.show();
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user