add selection cut button and binding
This commit is contained in:
parent
11fd29c9c6
commit
997297ab68
4 changed files with 31 additions and 8 deletions
|
@ -1036,8 +1036,31 @@ impl Editor {
|
|||
draw_scaled_texture(d, globals.get_tex("save"), 148, y + 4, 2.);
|
||||
|
||||
self.tooltip.add(188, y, 40, 40, "Copy");
|
||||
let mut copy_selection = false;
|
||||
if simple_button((d, &self.mouse), 188, y, 40, 40) || globals.is_pressed(ActionId::Copy)
|
||||
{
|
||||
copy_selection = true;
|
||||
}
|
||||
draw_scaled_texture(d, globals.get_tex("copy"), 192, y + 4, 2.);
|
||||
|
||||
self.tooltip.add(232, y, 40, 40, "Cut");
|
||||
let mut erase_selection = false;
|
||||
if simple_button((d, &self.mouse), 232, y, 40, 40) || globals.is_pressed(ActionId::Cut)
|
||||
{
|
||||
copy_selection = true;
|
||||
erase_selection = true;
|
||||
}
|
||||
draw_scaled_texture(d, globals.get_tex("cut"), 236, y + 4, 2.);
|
||||
|
||||
self.tooltip.add(276, y, 40, 40, "Delete");
|
||||
if simple_button((d, &self.mouse), 276, y, 40, 40)
|
||||
|| globals.is_pressed(ActionId::Erase)
|
||||
{
|
||||
erase_selection = true;
|
||||
}
|
||||
draw_scaled_texture(d, globals.get_tex("eraser"), 280, y + 4, 2.);
|
||||
|
||||
if copy_selection {
|
||||
let board = self.get_selected_as_board(selection);
|
||||
if let Some(clipboard) = &mut globals.clipboard {
|
||||
clipboard
|
||||
|
@ -1047,10 +1070,7 @@ impl Editor {
|
|||
self.pasting_board = Some(board);
|
||||
}
|
||||
}
|
||||
draw_scaled_texture(d, globals.get_tex("copy"), 192, y + 4, 2.);
|
||||
|
||||
self.tooltip.add(232, y, 40, 40, "Delete");
|
||||
if simple_button((d, &self.mouse), 232, y, 40, 40) {
|
||||
if erase_selection {
|
||||
let min = selection.0.min(selection.1);
|
||||
let max = selection.0.max(selection.1);
|
||||
let board = Board::new(Grid::new_empty(
|
||||
|
@ -1059,7 +1079,6 @@ impl Editor {
|
|||
));
|
||||
self.set_area(min, board);
|
||||
}
|
||||
draw_scaled_texture(d, globals.get_tex("eraser"), 236, y + 4, 2.);
|
||||
}
|
||||
|
||||
let mut tool_button = |(row, col): (i32, i32),
|
||||
|
|
|
@ -21,7 +21,9 @@ pub enum ActionId {
|
|||
Undo,
|
||||
Redo,
|
||||
Copy,
|
||||
Cut,
|
||||
Paste,
|
||||
Erase,
|
||||
ToggleMenu,
|
||||
StartSim,
|
||||
StopSim,
|
||||
|
@ -59,7 +61,9 @@ impl Default for Input {
|
|||
bind_key(ActionId::Redo, vec![LCtrl], Y);
|
||||
bind_key(ActionId::Redo, vec![LCtrl, LShift], Z);
|
||||
bind_key(ActionId::Copy, vec![LCtrl], C);
|
||||
bind_key(ActionId::Cut, vec![LCtrl], X);
|
||||
bind_key(ActionId::Paste, vec![LCtrl], V);
|
||||
bind_key(ActionId::Erase, vec![], Backspace);
|
||||
bind_key(ActionId::ToggleMenu, vec![], Escape);
|
||||
bind_key(ActionId::StartSim, vec![], Enter);
|
||||
bind_key(ActionId::StopSim, vec![], Enter);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue