|
|
|
@ -238,16 +238,14 @@ impl Editor {
|
|
|
|
|
fn resize_window(&mut self, grid: u64, width: u64, height: u64) {
|
|
|
|
|
trace!("editor resize {}", grid);
|
|
|
|
|
if let Some(window) = self.windows.get_mut(&grid) {
|
|
|
|
|
window.resize(width, height);
|
|
|
|
|
window.resize((width, height));
|
|
|
|
|
} else {
|
|
|
|
|
let window = Window::new(
|
|
|
|
|
grid,
|
|
|
|
|
WindowType::Editor,
|
|
|
|
|
width,
|
|
|
|
|
height,
|
|
|
|
|
None,
|
|
|
|
|
0.0,
|
|
|
|
|
0.0,
|
|
|
|
|
(0.0, 0.0),
|
|
|
|
|
(width, height),
|
|
|
|
|
self.draw_command_batcher.clone(),
|
|
|
|
|
);
|
|
|
|
|
self.windows.insert(grid, window);
|
|
|
|
@ -263,17 +261,15 @@ impl Editor {
|
|
|
|
|
height: u64,
|
|
|
|
|
) {
|
|
|
|
|
if let Some(window) = self.windows.get_mut(&grid) {
|
|
|
|
|
window.position(width, height, None, start_left as f64, start_top as f64);
|
|
|
|
|
window.position(None, (width, height), (start_left as f64, start_top as f64));
|
|
|
|
|
window.show();
|
|
|
|
|
} else {
|
|
|
|
|
let new_window = Window::new(
|
|
|
|
|
grid,
|
|
|
|
|
WindowType::Editor,
|
|
|
|
|
width,
|
|
|
|
|
height,
|
|
|
|
|
None,
|
|
|
|
|
start_left as f64,
|
|
|
|
|
start_top as f64,
|
|
|
|
|
(start_left as f64, start_top as f64),
|
|
|
|
|
(width, height),
|
|
|
|
|
self.draw_command_batcher.clone(),
|
|
|
|
|
);
|
|
|
|
|
self.windows.insert(grid, new_window);
|
|
|
|
@ -302,8 +298,6 @@ impl Editor {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
window.position(
|
|
|
|
|
width,
|
|
|
|
|
height,
|
|
|
|
|
Some(AnchorInfo {
|
|
|
|
|
anchor_grid_id: anchor_grid,
|
|
|
|
|
anchor_type,
|
|
|
|
@ -311,8 +305,8 @@ impl Editor {
|
|
|
|
|
anchor_top,
|
|
|
|
|
sort_order: sort_order.unwrap_or(grid),
|
|
|
|
|
}),
|
|
|
|
|
modified_left,
|
|
|
|
|
modified_top,
|
|
|
|
|
(width, height),
|
|
|
|
|
(modified_left, modified_top),
|
|
|
|
|
);
|
|
|
|
|
window.show();
|
|
|
|
|
} else {
|
|
|
|
@ -338,22 +332,18 @@ impl Editor {
|
|
|
|
|
if let Some(window) = self.windows.get_mut(&grid) {
|
|
|
|
|
window.window_type = WindowType::Message;
|
|
|
|
|
window.position(
|
|
|
|
|
parent_width,
|
|
|
|
|
window.get_height(),
|
|
|
|
|
Some(anchor_info),
|
|
|
|
|
0.0,
|
|
|
|
|
grid_top as f64,
|
|
|
|
|
(parent_width, window.get_height()),
|
|
|
|
|
(0.0, grid_top as f64),
|
|
|
|
|
);
|
|
|
|
|
window.show();
|
|
|
|
|
} else {
|
|
|
|
|
let new_window = Window::new(
|
|
|
|
|
grid,
|
|
|
|
|
WindowType::Message,
|
|
|
|
|
parent_width,
|
|
|
|
|
1,
|
|
|
|
|
Some(anchor_info),
|
|
|
|
|
0.0,
|
|
|
|
|
grid_top as f64,
|
|
|
|
|
(0.0, grid_top as f64),
|
|
|
|
|
(parent_width, 1),
|
|
|
|
|
self.draw_command_batcher.clone(),
|
|
|
|
|
);
|
|
|
|
|
self.windows.insert(grid, new_window);
|
|
|
|
@ -387,26 +377,27 @@ impl Editor {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn set_cursor_position(&mut self, grid: u64, grid_left: u64, grid_top: u64) {
|
|
|
|
|
match self.windows.get(&grid) {
|
|
|
|
|
Some(Window { window_type: WindowType::Message, .. }) => {
|
|
|
|
|
// When the user presses ":" to type a command, the cursor is sent to the gutter
|
|
|
|
|
// in position 1 (right after the ":"). In all other cases, we want to skip
|
|
|
|
|
// positioning to avoid confusing movements.
|
|
|
|
|
let intentional = grid_left == 1;
|
|
|
|
|
// If the cursor was already in this message, we can still move within it.
|
|
|
|
|
let already_there = self.cursor.parent_window_id == grid;
|
|
|
|
|
if let Some(Window {
|
|
|
|
|
window_type: WindowType::Message,
|
|
|
|
|
..
|
|
|
|
|
}) = self.windows.get(&grid)
|
|
|
|
|
{
|
|
|
|
|
// When the user presses ":" to type a command, the cursor is sent to the gutter
|
|
|
|
|
// in position 1 (right after the ":"). In all other cases, we want to skip
|
|
|
|
|
// positioning to avoid confusing movements.
|
|
|
|
|
let intentional = grid_left == 1;
|
|
|
|
|
// If the cursor was already in this message, we can still move within it.
|
|
|
|
|
let already_there = self.cursor.parent_window_id == grid;
|
|
|
|
|
|
|
|
|
|
if !intentional && !already_there {
|
|
|
|
|
trace!(
|
|
|
|
|
"Cursor unexpectedly sent to message buffer {} ({}, {})",
|
|
|
|
|
grid,
|
|
|
|
|
grid_left,
|
|
|
|
|
grid_top
|
|
|
|
|
);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if !intentional && !already_there {
|
|
|
|
|
trace!(
|
|
|
|
|
"Cursor unexpectedly sent to message buffer {} ({}, {})",
|
|
|
|
|
grid,
|
|
|
|
|
grid_left,
|
|
|
|
|
grid_top
|
|
|
|
|
);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
_ => {}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
self.cursor.parent_window_id = grid;
|
|
|
|
|