|
@@ -1095,7 +1095,7 @@ bool CanvasItemEditor::_gui_input_rulers_and_guides(const Ref<InputEvent> &p_eve
|
|
|
}
|
|
|
|
|
|
// Start dragging a guide
|
|
|
- if (b.is_valid() && b->get_button_index() == BUTTON_LEFT && b->is_pressed()) {
|
|
|
+ if (b.is_valid() && b->get_button_index() == MOUSE_BUTTON_LEFT && b->is_pressed()) {
|
|
|
// Press button
|
|
|
if (b->get_position().x < RULER_WIDTH && b->get_position().y < RULER_WIDTH) {
|
|
|
// Drag a new double guide
|
|
@@ -1154,7 +1154,7 @@ bool CanvasItemEditor::_gui_input_rulers_and_guides(const Ref<InputEvent> &p_eve
|
|
|
}
|
|
|
|
|
|
// Release confirms the guide move
|
|
|
- if (b.is_valid() && b->get_button_index() == BUTTON_LEFT && !b->is_pressed()) {
|
|
|
+ if (b.is_valid() && b->get_button_index() == MOUSE_BUTTON_LEFT && !b->is_pressed()) {
|
|
|
if (show_guides && EditorNode::get_singleton()->get_edited_scene()) {
|
|
|
Transform2D xform = viewport_scrollable->get_transform() * transform;
|
|
|
|
|
@@ -1268,7 +1268,7 @@ bool CanvasItemEditor::_gui_input_zoom_or_pan(const Ref<InputEvent> &p_event, bo
|
|
|
if (pan_on_scroll) {
|
|
|
// Perform horizontal scrolling first so we can check for Shift being held.
|
|
|
if (b->is_pressed() &&
|
|
|
- (b->get_button_index() == BUTTON_WHEEL_LEFT || (b->get_shift() && b->get_button_index() == BUTTON_WHEEL_UP))) {
|
|
|
+ (b->get_button_index() == MOUSE_BUTTON_WHEEL_LEFT || (b->get_shift() && b->get_button_index() == MOUSE_BUTTON_WHEEL_UP))) {
|
|
|
// Pan left
|
|
|
view_offset.x -= int(EditorSettings::get_singleton()->get("editors/2d/pan_speed")) / zoom * b->get_factor();
|
|
|
update_viewport();
|
|
@@ -1276,7 +1276,7 @@ bool CanvasItemEditor::_gui_input_zoom_or_pan(const Ref<InputEvent> &p_event, bo
|
|
|
}
|
|
|
|
|
|
if (b->is_pressed() &&
|
|
|
- (b->get_button_index() == BUTTON_WHEEL_RIGHT || (b->get_shift() && b->get_button_index() == BUTTON_WHEEL_DOWN))) {
|
|
|
+ (b->get_button_index() == MOUSE_BUTTON_WHEEL_RIGHT || (b->get_shift() && b->get_button_index() == MOUSE_BUTTON_WHEEL_DOWN))) {
|
|
|
// Pan right
|
|
|
view_offset.x += int(EditorSettings::get_singleton()->get("editors/2d/pan_speed")) / zoom * b->get_factor();
|
|
|
update_viewport();
|
|
@@ -1284,7 +1284,7 @@ bool CanvasItemEditor::_gui_input_zoom_or_pan(const Ref<InputEvent> &p_event, bo
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if (b->is_pressed() && b->get_button_index() == BUTTON_WHEEL_DOWN) {
|
|
|
+ if (b->is_pressed() && b->get_button_index() == MOUSE_BUTTON_WHEEL_DOWN) {
|
|
|
// Scroll or pan down
|
|
|
if (pan_on_scroll) {
|
|
|
view_offset.y += int(EditorSettings::get_singleton()->get("editors/2d/pan_speed")) / zoom * b->get_factor();
|
|
@@ -1299,7 +1299,7 @@ bool CanvasItemEditor::_gui_input_zoom_or_pan(const Ref<InputEvent> &p_event, bo
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
- if (b->is_pressed() && b->get_button_index() == BUTTON_WHEEL_UP) {
|
|
|
+ if (b->is_pressed() && b->get_button_index() == MOUSE_BUTTON_WHEEL_UP) {
|
|
|
// Scroll or pan up
|
|
|
if (pan_on_scroll) {
|
|
|
view_offset.y -= int(EditorSettings::get_singleton()->get("editors/2d/pan_speed")) / zoom * b->get_factor();
|
|
@@ -1316,17 +1316,17 @@ bool CanvasItemEditor::_gui_input_zoom_or_pan(const Ref<InputEvent> &p_event, bo
|
|
|
|
|
|
if (!panning) {
|
|
|
if (b->is_pressed() &&
|
|
|
- (b->get_button_index() == BUTTON_MIDDLE ||
|
|
|
- b->get_button_index() == BUTTON_RIGHT ||
|
|
|
- (b->get_button_index() == BUTTON_LEFT && tool == TOOL_PAN) ||
|
|
|
- (b->get_button_index() == BUTTON_LEFT && !EditorSettings::get_singleton()->get("editors/2d/simple_panning") && pan_pressed))) {
|
|
|
+ (b->get_button_index() == MOUSE_BUTTON_MIDDLE ||
|
|
|
+ b->get_button_index() == MOUSE_BUTTON_RIGHT ||
|
|
|
+ (b->get_button_index() == MOUSE_BUTTON_LEFT && tool == TOOL_PAN) ||
|
|
|
+ (b->get_button_index() == MOUSE_BUTTON_LEFT && !EditorSettings::get_singleton()->get("editors/2d/simple_panning") && pan_pressed))) {
|
|
|
// Pan the viewport
|
|
|
panning = true;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if (panning) {
|
|
|
- if (!b->is_pressed() && (pan_on_scroll || (b->get_button_index() != BUTTON_WHEEL_DOWN && b->get_button_index() != BUTTON_WHEEL_UP))) {
|
|
|
+ if (!b->is_pressed() && (pan_on_scroll || (b->get_button_index() != MOUSE_BUTTON_WHEEL_DOWN && b->get_button_index() != MOUSE_BUTTON_WHEEL_UP))) {
|
|
|
// Stop panning the viewport (for any mouse button press except zooming)
|
|
|
panning = false;
|
|
|
}
|
|
@@ -1412,7 +1412,7 @@ bool CanvasItemEditor::_gui_input_pivot(const Ref<InputEvent> &p_event) {
|
|
|
|
|
|
// Drag the pivot (in pivot mode / with V key)
|
|
|
if (drag_type == DRAG_NONE) {
|
|
|
- if ((b.is_valid() && b->is_pressed() && b->get_button_index() == BUTTON_LEFT && tool == TOOL_EDIT_PIVOT) ||
|
|
|
+ if ((b.is_valid() && b->is_pressed() && b->get_button_index() == MOUSE_BUTTON_LEFT && tool == TOOL_EDIT_PIVOT) ||
|
|
|
(k.is_valid() && k->is_pressed() && !k->is_echo() && k->get_keycode() == KEY_V)) {
|
|
|
List<CanvasItem *> selection = _get_edited_canvas_items();
|
|
|
|
|
@@ -1466,7 +1466,7 @@ bool CanvasItemEditor::_gui_input_pivot(const Ref<InputEvent> &p_event) {
|
|
|
|
|
|
// Confirm the pivot move
|
|
|
if (drag_selection.size() >= 1 &&
|
|
|
- ((b.is_valid() && !b->is_pressed() && b->get_button_index() == BUTTON_LEFT && tool == TOOL_EDIT_PIVOT) ||
|
|
|
+ ((b.is_valid() && !b->is_pressed() && b->get_button_index() == MOUSE_BUTTON_LEFT && tool == TOOL_EDIT_PIVOT) ||
|
|
|
(k.is_valid() && !k->is_pressed() && k->get_keycode() == KEY_V))) {
|
|
|
_commit_canvas_item_state(
|
|
|
drag_selection,
|
|
@@ -1480,7 +1480,7 @@ bool CanvasItemEditor::_gui_input_pivot(const Ref<InputEvent> &p_event) {
|
|
|
}
|
|
|
|
|
|
// Cancel a drag
|
|
|
- if (b.is_valid() && b->get_button_index() == BUTTON_RIGHT && b->is_pressed()) {
|
|
|
+ if (b.is_valid() && b->get_button_index() == MOUSE_BUTTON_RIGHT && b->is_pressed()) {
|
|
|
_restore_canvas_item_state(drag_selection);
|
|
|
drag_type = DRAG_NONE;
|
|
|
viewport->update();
|
|
@@ -1566,7 +1566,7 @@ bool CanvasItemEditor::_gui_input_rotate(const Ref<InputEvent> &p_event) {
|
|
|
|
|
|
// Start rotation
|
|
|
if (drag_type == DRAG_NONE) {
|
|
|
- if (b.is_valid() && b->get_button_index() == BUTTON_LEFT && b->is_pressed()) {
|
|
|
+ if (b.is_valid() && b->get_button_index() == MOUSE_BUTTON_LEFT && b->is_pressed()) {
|
|
|
if ((b->get_command() && !b->get_alt() && tool == TOOL_SELECT) || tool == TOOL_ROTATE) {
|
|
|
List<CanvasItem *> selection = _get_edited_canvas_items();
|
|
|
|
|
@@ -1610,7 +1610,7 @@ bool CanvasItemEditor::_gui_input_rotate(const Ref<InputEvent> &p_event) {
|
|
|
}
|
|
|
|
|
|
// Confirms the node rotation
|
|
|
- if (b.is_valid() && b->get_button_index() == BUTTON_LEFT && !b->is_pressed()) {
|
|
|
+ if (b.is_valid() && b->get_button_index() == MOUSE_BUTTON_LEFT && !b->is_pressed()) {
|
|
|
if (drag_selection.size() != 1) {
|
|
|
_commit_canvas_item_state(
|
|
|
drag_selection,
|
|
@@ -1634,7 +1634,7 @@ bool CanvasItemEditor::_gui_input_rotate(const Ref<InputEvent> &p_event) {
|
|
|
}
|
|
|
|
|
|
// Cancel a drag
|
|
|
- if (b.is_valid() && b->get_button_index() == BUTTON_RIGHT && b->is_pressed()) {
|
|
|
+ if (b.is_valid() && b->get_button_index() == MOUSE_BUTTON_RIGHT && b->is_pressed()) {
|
|
|
_restore_canvas_item_state(drag_selection);
|
|
|
drag_type = DRAG_NONE;
|
|
|
viewport->update();
|
|
@@ -1648,7 +1648,7 @@ bool CanvasItemEditor::_gui_input_open_scene_on_double_click(const Ref<InputEven
|
|
|
Ref<InputEventMouseButton> b = p_event;
|
|
|
|
|
|
// Open a sub-scene on double-click
|
|
|
- if (b.is_valid() && b->get_button_index() == BUTTON_LEFT && b->is_pressed() && b->is_doubleclick() && tool == TOOL_SELECT) {
|
|
|
+ if (b.is_valid() && b->get_button_index() == MOUSE_BUTTON_LEFT && b->is_pressed() && b->is_doubleclick() && tool == TOOL_SELECT) {
|
|
|
List<CanvasItem *> selection = _get_edited_canvas_items();
|
|
|
if (selection.size() == 1) {
|
|
|
CanvasItem *canvas_item = selection[0];
|
|
@@ -1667,7 +1667,7 @@ bool CanvasItemEditor::_gui_input_anchors(const Ref<InputEvent> &p_event) {
|
|
|
|
|
|
// Starts anchor dragging if needed
|
|
|
if (drag_type == DRAG_NONE) {
|
|
|
- if (b.is_valid() && b->get_button_index() == BUTTON_LEFT && b->is_pressed() && tool == TOOL_SELECT) {
|
|
|
+ if (b.is_valid() && b->get_button_index() == MOUSE_BUTTON_LEFT && b->is_pressed() && tool == TOOL_SELECT) {
|
|
|
List<CanvasItem *> selection = _get_edited_canvas_items();
|
|
|
if (selection.size() == 1) {
|
|
|
Control *control = Object::cast_to<Control>(selection[0]);
|
|
@@ -1787,7 +1787,7 @@ bool CanvasItemEditor::_gui_input_anchors(const Ref<InputEvent> &p_event) {
|
|
|
}
|
|
|
|
|
|
// Confirms new anchor position
|
|
|
- if (drag_selection.size() >= 1 && b.is_valid() && b->get_button_index() == BUTTON_LEFT && !b->is_pressed()) {
|
|
|
+ if (drag_selection.size() >= 1 && b.is_valid() && b->get_button_index() == MOUSE_BUTTON_LEFT && !b->is_pressed()) {
|
|
|
_commit_canvas_item_state(
|
|
|
drag_selection,
|
|
|
vformat(TTR("Move CanvasItem \"%s\" Anchor"), drag_selection[0]->get_name()));
|
|
@@ -1796,7 +1796,7 @@ bool CanvasItemEditor::_gui_input_anchors(const Ref<InputEvent> &p_event) {
|
|
|
}
|
|
|
|
|
|
// Cancel a drag
|
|
|
- if (b.is_valid() && b->get_button_index() == BUTTON_RIGHT && b->is_pressed()) {
|
|
|
+ if (b.is_valid() && b->get_button_index() == MOUSE_BUTTON_RIGHT && b->is_pressed()) {
|
|
|
_restore_canvas_item_state(drag_selection);
|
|
|
drag_type = DRAG_NONE;
|
|
|
viewport->update();
|
|
@@ -1812,7 +1812,7 @@ bool CanvasItemEditor::_gui_input_resize(const Ref<InputEvent> &p_event) {
|
|
|
|
|
|
// Drag resize handles
|
|
|
if (drag_type == DRAG_NONE) {
|
|
|
- if (b.is_valid() && b->get_button_index() == BUTTON_LEFT && b->is_pressed() && tool == TOOL_SELECT) {
|
|
|
+ if (b.is_valid() && b->get_button_index() == MOUSE_BUTTON_LEFT && b->is_pressed() && tool == TOOL_SELECT) {
|
|
|
List<CanvasItem *> selection = _get_edited_canvas_items();
|
|
|
if (selection.size() == 1) {
|
|
|
CanvasItem *canvas_item = selection[0];
|
|
@@ -1966,7 +1966,7 @@ bool CanvasItemEditor::_gui_input_resize(const Ref<InputEvent> &p_event) {
|
|
|
}
|
|
|
|
|
|
// Confirm resize
|
|
|
- if (drag_selection.size() >= 1 && b.is_valid() && b->get_button_index() == BUTTON_LEFT && !b->is_pressed()) {
|
|
|
+ if (drag_selection.size() >= 1 && b.is_valid() && b->get_button_index() == MOUSE_BUTTON_LEFT && !b->is_pressed()) {
|
|
|
const Node2D *node2d = Object::cast_to<Node2D>(drag_selection[0]);
|
|
|
if (node2d) {
|
|
|
// Extends from Node2D.
|
|
@@ -2003,7 +2003,7 @@ bool CanvasItemEditor::_gui_input_resize(const Ref<InputEvent> &p_event) {
|
|
|
}
|
|
|
|
|
|
// Cancel a drag
|
|
|
- if (b.is_valid() && b->get_button_index() == BUTTON_RIGHT && b->is_pressed()) {
|
|
|
+ if (b.is_valid() && b->get_button_index() == MOUSE_BUTTON_RIGHT && b->is_pressed()) {
|
|
|
_restore_canvas_item_state(drag_selection);
|
|
|
snap_target[0] = SNAP_TARGET_NONE;
|
|
|
snap_target[1] = SNAP_TARGET_NONE;
|
|
@@ -2021,7 +2021,7 @@ bool CanvasItemEditor::_gui_input_scale(const Ref<InputEvent> &p_event) {
|
|
|
|
|
|
// Drag resize handles
|
|
|
if (drag_type == DRAG_NONE) {
|
|
|
- if (b.is_valid() && b->get_button_index() == BUTTON_LEFT && b->is_pressed() && ((b->get_alt() && b->get_control()) || tool == TOOL_SCALE)) {
|
|
|
+ if (b.is_valid() && b->get_button_index() == MOUSE_BUTTON_LEFT && b->is_pressed() && ((b->get_alt() && b->get_control()) || tool == TOOL_SCALE)) {
|
|
|
List<CanvasItem *> selection = _get_edited_canvas_items();
|
|
|
if (selection.size() == 1) {
|
|
|
CanvasItem *canvas_item = selection[0];
|
|
@@ -2117,7 +2117,7 @@ bool CanvasItemEditor::_gui_input_scale(const Ref<InputEvent> &p_event) {
|
|
|
}
|
|
|
|
|
|
// Confirm resize
|
|
|
- if (b.is_valid() && b->get_button_index() == BUTTON_LEFT && !b->is_pressed()) {
|
|
|
+ if (b.is_valid() && b->get_button_index() == MOUSE_BUTTON_LEFT && !b->is_pressed()) {
|
|
|
if (drag_selection.size() != 1) {
|
|
|
_commit_canvas_item_state(
|
|
|
drag_selection,
|
|
@@ -2142,7 +2142,7 @@ bool CanvasItemEditor::_gui_input_scale(const Ref<InputEvent> &p_event) {
|
|
|
}
|
|
|
|
|
|
// Cancel a drag
|
|
|
- if (b.is_valid() && b->get_button_index() == BUTTON_RIGHT && b->is_pressed()) {
|
|
|
+ if (b.is_valid() && b->get_button_index() == MOUSE_BUTTON_RIGHT && b->is_pressed()) {
|
|
|
_restore_canvas_item_state(drag_selection);
|
|
|
drag_type = DRAG_NONE;
|
|
|
viewport->update();
|
|
@@ -2159,7 +2159,7 @@ bool CanvasItemEditor::_gui_input_move(const Ref<InputEvent> &p_event) {
|
|
|
|
|
|
if (drag_type == DRAG_NONE) {
|
|
|
//Start moving the nodes
|
|
|
- if (b.is_valid() && b->get_button_index() == BUTTON_LEFT && b->is_pressed()) {
|
|
|
+ if (b.is_valid() && b->get_button_index() == MOUSE_BUTTON_LEFT && b->is_pressed()) {
|
|
|
if ((b->get_alt() && !b->get_control()) || tool == TOOL_MOVE) {
|
|
|
List<CanvasItem *> selection = _get_edited_canvas_items();
|
|
|
|
|
@@ -2262,7 +2262,7 @@ bool CanvasItemEditor::_gui_input_move(const Ref<InputEvent> &p_event) {
|
|
|
}
|
|
|
|
|
|
// Confirm the move (only if it was moved)
|
|
|
- if (b.is_valid() && !b->is_pressed() && b->get_button_index() == BUTTON_LEFT) {
|
|
|
+ if (b.is_valid() && !b->is_pressed() && b->get_button_index() == MOUSE_BUTTON_LEFT) {
|
|
|
if (transform.affine_inverse().xform(b->get_position()) != drag_from) {
|
|
|
if (drag_selection.size() != 1) {
|
|
|
_commit_canvas_item_state(
|
|
@@ -2295,7 +2295,7 @@ bool CanvasItemEditor::_gui_input_move(const Ref<InputEvent> &p_event) {
|
|
|
}
|
|
|
|
|
|
// Cancel a drag
|
|
|
- if (b.is_valid() && b->get_button_index() == BUTTON_RIGHT && b->is_pressed()) {
|
|
|
+ if (b.is_valid() && b->get_button_index() == MOUSE_BUTTON_RIGHT && b->is_pressed()) {
|
|
|
_restore_canvas_item_state(drag_selection, true);
|
|
|
snap_target[0] = SNAP_TARGET_NONE;
|
|
|
snap_target[1] = SNAP_TARGET_NONE;
|
|
@@ -2435,8 +2435,8 @@ bool CanvasItemEditor::_gui_input_select(const Ref<InputEvent> &p_event) {
|
|
|
|
|
|
if (drag_type == DRAG_NONE) {
|
|
|
if (b.is_valid() &&
|
|
|
- ((b->get_button_index() == BUTTON_RIGHT && b->get_alt() && tool == TOOL_SELECT) ||
|
|
|
- (b->get_button_index() == BUTTON_LEFT && tool == TOOL_LIST_SELECT))) {
|
|
|
+ ((b->get_button_index() == MOUSE_BUTTON_RIGHT && b->get_alt() && tool == TOOL_SELECT) ||
|
|
|
+ (b->get_button_index() == MOUSE_BUTTON_LEFT && tool == TOOL_LIST_SELECT))) {
|
|
|
// Popup the selection menu list
|
|
|
Point2 click = transform.affine_inverse().xform(b->get_position());
|
|
|
|
|
@@ -2497,7 +2497,7 @@ bool CanvasItemEditor::_gui_input_select(const Ref<InputEvent> &p_event) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if (b.is_valid() && b->is_pressed() && b->get_button_index() == BUTTON_RIGHT && b->get_control()) {
|
|
|
+ if (b.is_valid() && b->is_pressed() && b->get_button_index() == MOUSE_BUTTON_RIGHT && b->get_control()) {
|
|
|
add_node_menu->set_position(get_global_transform().xform(get_local_mouse_position()));
|
|
|
add_node_menu->set_size(Vector2(1, 1));
|
|
|
add_node_menu->popup();
|
|
@@ -2505,7 +2505,7 @@ bool CanvasItemEditor::_gui_input_select(const Ref<InputEvent> &p_event) {
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
- if (b.is_valid() && b->get_button_index() == BUTTON_LEFT && b->is_pressed() && tool == TOOL_SELECT) {
|
|
|
+ if (b.is_valid() && b->get_button_index() == MOUSE_BUTTON_LEFT && b->is_pressed() && tool == TOOL_SELECT) {
|
|
|
// Single item selection
|
|
|
Point2 click = transform.affine_inverse().xform(b->get_position());
|
|
|
|
|
@@ -2571,7 +2571,7 @@ bool CanvasItemEditor::_gui_input_select(const Ref<InputEvent> &p_event) {
|
|
|
}
|
|
|
|
|
|
if (drag_type == DRAG_BOX_SELECTION) {
|
|
|
- if (b.is_valid() && !b->is_pressed() && b->get_button_index() == BUTTON_LEFT) {
|
|
|
+ if (b.is_valid() && !b->is_pressed() && b->get_button_index() == MOUSE_BUTTON_LEFT) {
|
|
|
// Confirms box selection
|
|
|
Node *scene = editor->get_edited_scene();
|
|
|
if (scene) {
|
|
@@ -2597,7 +2597,7 @@ bool CanvasItemEditor::_gui_input_select(const Ref<InputEvent> &p_event) {
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
- if (b.is_valid() && b->is_pressed() && b->get_button_index() == BUTTON_RIGHT) {
|
|
|
+ if (b.is_valid() && b->is_pressed() && b->get_button_index() == MOUSE_BUTTON_RIGHT) {
|
|
|
// Cancel box selection
|
|
|
drag_type = DRAG_NONE;
|
|
|
viewport->update();
|
|
@@ -2634,7 +2634,7 @@ bool CanvasItemEditor::_gui_input_ruler_tool(const Ref<InputEvent> &p_event) {
|
|
|
ruler_tool_origin = snap_point(viewport->get_local_mouse_position() / zoom + view_offset);
|
|
|
}
|
|
|
|
|
|
- if (b.is_valid() && b->get_button_index() == BUTTON_LEFT) {
|
|
|
+ if (b.is_valid() && b->get_button_index() == MOUSE_BUTTON_LEFT) {
|
|
|
if (b->is_pressed()) {
|
|
|
ruler_tool_active = true;
|
|
|
} else {
|