Merge pull request #57155 from KoBeWi/drag_by_force
This commit is contained in:
commit
30701e3966
3 changed files with 14 additions and 1 deletions
|
@ -1117,6 +1117,7 @@ bool CanvasItemEditor::_gui_input_rulers_and_guides(const Ref<InputEvent> &p_eve
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CanvasItemEditor::_gui_input_zoom_or_pan(const Ref<InputEvent> &p_event, bool p_already_accepted) {
|
bool CanvasItemEditor::_gui_input_zoom_or_pan(const Ref<InputEvent> &p_event, bool p_already_accepted) {
|
||||||
|
panner->set_force_drag(tool == TOOL_PAN);
|
||||||
bool panner_active = panner->gui_input(p_event, warped_panning ? viewport->get_global_rect() : Rect2());
|
bool panner_active = panner->gui_input(p_event, warped_panning ? viewport->get_global_rect() : Rect2());
|
||||||
if (panner->is_panning() != pan_pressed) {
|
if (panner->is_panning() != pan_pressed) {
|
||||||
pan_pressed = panner->is_panning();
|
pan_pressed = panner->is_panning();
|
||||||
|
|
|
@ -81,7 +81,12 @@ bool ViewPanner::gui_input(const Ref<InputEvent> &p_event, Rect2 p_canvas_rect)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mb->get_button_index() == MouseButton::MIDDLE || (enable_rmb && mb->get_button_index() == MouseButton::RIGHT) || (!simple_panning_enabled && mb->get_button_index() == MouseButton::LEFT && is_panning())) {
|
bool is_drag_event = mb->get_button_index() == MouseButton::MIDDLE ||
|
||||||
|
(enable_rmb && mb->get_button_index() == MouseButton::RIGHT) ||
|
||||||
|
(!simple_panning_enabled && mb->get_button_index() == MouseButton::LEFT && is_panning()) ||
|
||||||
|
(force_drag && mb->get_button_index() == MouseButton::LEFT);
|
||||||
|
|
||||||
|
if (is_drag_event) {
|
||||||
if (mb->is_pressed()) {
|
if (mb->is_pressed()) {
|
||||||
is_dragging = true;
|
is_dragging = true;
|
||||||
} else {
|
} else {
|
||||||
|
@ -166,6 +171,10 @@ bool ViewPanner::is_panning() const {
|
||||||
return is_dragging || pan_key_pressed;
|
return is_dragging || pan_key_pressed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ViewPanner::set_force_drag(bool p_force) {
|
||||||
|
force_drag = p_force;
|
||||||
|
}
|
||||||
|
|
||||||
ViewPanner::ViewPanner() {
|
ViewPanner::ViewPanner() {
|
||||||
Array inputs;
|
Array inputs;
|
||||||
inputs.append(InputEventKey::create_reference(Key::SPACE));
|
inputs.append(InputEventKey::create_reference(Key::SPACE));
|
||||||
|
|
|
@ -48,6 +48,8 @@ public:
|
||||||
private:
|
private:
|
||||||
bool is_dragging = false;
|
bool is_dragging = false;
|
||||||
bool pan_key_pressed = false;
|
bool pan_key_pressed = false;
|
||||||
|
bool force_drag = false;
|
||||||
|
|
||||||
bool enable_rmb = false;
|
bool enable_rmb = false;
|
||||||
bool simple_panning_enabled = false;
|
bool simple_panning_enabled = false;
|
||||||
|
|
||||||
|
@ -70,6 +72,7 @@ public:
|
||||||
void setup(ControlScheme p_scheme, Ref<Shortcut> p_shortcut, bool p_simple_panning);
|
void setup(ControlScheme p_scheme, Ref<Shortcut> p_shortcut, bool p_simple_panning);
|
||||||
|
|
||||||
bool is_panning() const;
|
bool is_panning() const;
|
||||||
|
void set_force_drag(bool p_force);
|
||||||
|
|
||||||
bool gui_input(const Ref<InputEvent> &p_ev, Rect2 p_canvas_rect = Rect2());
|
bool gui_input(const Ref<InputEvent> &p_ev, Rect2 p_canvas_rect = Rect2());
|
||||||
void release_pan_key();
|
void release_pan_key();
|
||||||
|
|
Loading…
Reference in a new issue