Skip to content

Commit

Permalink
remove InputEventPanGesture and InputEventMagnifyGesture
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremyz committed Mar 15, 2022
1 parent 17a47f7 commit e4479a2
Show file tree
Hide file tree
Showing 22 changed files with 36 additions and 180 deletions.
80 changes: 0 additions & 80 deletions core/input/input_event.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1361,86 +1361,6 @@ Vector2 InputEventGesture::get_position() const {

///////////////////////////////////

void InputEventMagnifyGesture::set_factor(real_t p_factor) {
factor = p_factor;
}

real_t InputEventMagnifyGesture::get_factor() const {
return factor;
}

Ref<InputEvent> InputEventMagnifyGesture::xformed_by(const Transform2D &p_xform, const Vector2 &p_local_ofs) const {
Ref<InputEventMagnifyGesture> ev;
ev.instantiate();

ev->set_device(get_device());
ev->set_window_id(get_window_id());

ev->set_modifiers_from_event(this);

ev->set_position(p_xform.xform(get_position() + p_local_ofs));
ev->set_factor(get_factor());

return ev;
}

String InputEventMagnifyGesture::as_text() const {
return vformat(RTR("Magnify Gesture at (%s) with factor %s"), String(get_position()), rtos(get_factor()));
}

String InputEventMagnifyGesture::to_string() {
return vformat("InputEventMagnifyGesture: factor=%.2f, position=(%s)", factor, String(get_position()));
}

void InputEventMagnifyGesture::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_factor", "factor"), &InputEventMagnifyGesture::set_factor);
ClassDB::bind_method(D_METHOD("get_factor"), &InputEventMagnifyGesture::get_factor);

ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "factor"), "set_factor", "get_factor");
}

///////////////////////////////////

void InputEventPanGesture::set_delta(const Vector2 &p_delta) {
delta = p_delta;
}

Vector2 InputEventPanGesture::get_delta() const {
return delta;
}

Ref<InputEvent> InputEventPanGesture::xformed_by(const Transform2D &p_xform, const Vector2 &p_local_ofs) const {
Ref<InputEventPanGesture> ev;
ev.instantiate();

ev->set_device(get_device());
ev->set_window_id(get_window_id());

ev->set_modifiers_from_event(this);

ev->set_position(p_xform.xform(get_position() + p_local_ofs));
ev->set_delta(get_delta());

return ev;
}

String InputEventPanGesture::as_text() const {
return vformat(RTR("Pan Gesture at (%s) with delta (%s)"), String(get_position()), String(get_delta()));
}

String InputEventPanGesture::to_string() {
return vformat("InputEventPanGesture: delta=(%s), position=(%s)", String(get_delta()), String(get_position()));
}

void InputEventPanGesture::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_delta", "delta"), &InputEventPanGesture::set_delta);
ClassDB::bind_method(D_METHOD("get_delta"), &InputEventPanGesture::get_delta);

ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "delta"), "set_delta", "get_delta");
}

///////////////////////////////////

void InputEventGesturePan::set_delta(const Vector2 &p_delta) {
delta = p_delta;
}
Expand Down
36 changes: 0 additions & 36 deletions core/input/input_event.h
Original file line number Diff line number Diff line change
Expand Up @@ -461,42 +461,6 @@ class InputEventGesture : public InputEventWithModifiers {
Vector2 get_position() const;
};

class InputEventMagnifyGesture : public InputEventGesture {
GDCLASS(InputEventMagnifyGesture, InputEventGesture);
real_t factor = 1.0;

protected:
static void _bind_methods();

public:
void set_factor(real_t p_factor);
real_t get_factor() const;

virtual Ref<InputEvent> xformed_by(const Transform2D &p_xform, const Vector2 &p_local_ofs = Vector2()) const override;
virtual String as_text() const override;
virtual String to_string() override;

InputEventMagnifyGesture() {}
};

class InputEventPanGesture : public InputEventGesture {
GDCLASS(InputEventPanGesture, InputEventGesture);
Vector2 delta;

protected:
static void _bind_methods();

public:
void set_delta(const Vector2 &p_delta);
Vector2 get_delta() const;

virtual Ref<InputEvent> xformed_by(const Transform2D &p_xform, const Vector2 &p_local_ofs = Vector2()) const override;
virtual String as_text() const override;
virtual String to_string() override;

InputEventPanGesture() {}
};

class InputEventGesturePan : public InputEventGesture {
GDCLASS(InputEventGesturePan, InputEventGesture);
Vector2 delta;
Expand Down
2 changes: 0 additions & 2 deletions core/register_core_types.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,6 @@ void register_core_types() {
GDREGISTER_CLASS(InputEventScreenTouch);
GDREGISTER_CLASS(InputEventAction);
GDREGISTER_ABSTRACT_CLASS(InputEventGesture);
GDREGISTER_CLASS(InputEventMagnifyGesture);
GDREGISTER_CLASS(InputEventPanGesture);
GDREGISTER_CLASS(InputEventGesturePan);
GDREGISTER_CLASS(InputEventGesturePinch);
GDREGISTER_CLASS(InputEventGestureTwist);
Expand Down
2 changes: 1 addition & 1 deletion doc/classes/InputEvent.xml
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@
<argument index="0" name="xform" type="Transform2D" />
<argument index="1" name="local_ofs" type="Vector2" default="Vector2(0, 0)" />
<description>
Returns a copy of the given input event which has been offset by [code]local_ofs[/code] and transformed by [code]xform[/code]. Relevant for events of type [InputEventMouseButton], [InputEventMouseMotion], [InputEventScreenTouch], [InputEventScreenDrag], [InputEventMagnifyGesture], [InputEventPanGesture], [InputEventGesturePan], [InputEventGesturePinch] and [InputEventGestureTwist].
Returns a copy of the given input event which has been offset by [code]local_ofs[/code] and transformed by [code]xform[/code]. Relevant for events of type [InputEventMouseButton], [InputEventMouseMotion], [InputEventScreenTouch], [InputEventScreenDrag], [InputEventGesturePan], [InputEventGesturePinch] and [InputEventGestureTwist].
</description>
</method>
</methods>
Expand Down
13 changes: 0 additions & 13 deletions doc/classes/InputEventMagnifyGesture.xml

This file was deleted.

13 changes: 0 additions & 13 deletions doc/classes/InputEventPanGesture.xml

This file was deleted.

6 changes: 3 additions & 3 deletions editor/code_editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -771,10 +771,10 @@ void CodeTextEditor::_text_editor_gui_input(const Ref<InputEvent> &p_event) {
}
}

Ref<InputEventMagnifyGesture> magnify_gesture = p_event;
if (magnify_gesture.is_valid()) {
Ref<InputEventGesturePinch> pinch_gesture = p_event;
if (pinch_gesture.is_valid()) {
font_size = text_editor->get_theme_font_size(SNAME("font_size"));
font_size *= powf(magnify_gesture->get_factor(), 0.25);
font_size *= powf(pinch_gesture->get_factor(), 0.25);

_add_font_size((int)font_size - text_editor->get_theme_font_size(SNAME("font_size")));
return;
Expand Down
2 changes: 1 addition & 1 deletion editor/plugins/animation_state_machine_editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ void AnimationNodeStateMachineEditor::_state_machine_gui_input(const Ref<InputEv
}
}

Ref<InputEventPanGesture> pan_gesture = p_event;
Ref<InputEventGesturePan> pan_gesture = p_event;
if (pan_gesture.is_valid()) {
h_scroll->set_value(h_scroll->get_value() + h_scroll->get_page() * pan_gesture->get_delta().x / 8);
v_scroll->set_value(v_scroll->get_value() + v_scroll->get_page() * pan_gesture->get_delta().y / 8);
Expand Down
8 changes: 4 additions & 4 deletions editor/plugins/canvas_item_editor_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1188,14 +1188,14 @@ bool CanvasItemEditor::_gui_input_zoom_or_pan(const Ref<InputEvent> &p_event, bo
}
}

Ref<InputEventMagnifyGesture> magnify_gesture = p_event;
if (magnify_gesture.is_valid() && !p_already_accepted) {
Ref<InputEventGesturePinch> pinch_gesture = p_event;
if (pinch_gesture.is_valid() && !p_already_accepted) {
// Zoom gesture
_zoom_on_position(zoom * magnify_gesture->get_factor(), magnify_gesture->get_position());
_zoom_on_position(zoom * pinch_gesture->get_factor(), pinch_gesture->get_position());
return true;
}

Ref<InputEventPanGesture> pan_gesture = p_event;
Ref<InputEventGesturePan> pan_gesture = p_event;
if (pan_gesture.is_valid() && !p_already_accepted) {
// If ctrl key pressed, then zoom instead of pan.
if (pan_gesture->is_ctrl_pressed()) {
Expand Down
10 changes: 5 additions & 5 deletions editor/plugins/node_3d_editor_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1822,16 +1822,16 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) {
}
}

Ref<InputEventMagnifyGesture> magnify_gesture = p_event;
if (magnify_gesture.is_valid()) {
Ref<InputEventGesturePinch> pinch_gesture = p_event;
if (pinch_gesture.is_valid()) {
if (is_freelook_active()) {
scale_freelook_speed(magnify_gesture->get_factor());
scale_freelook_speed(pinch_gesture->get_factor());
} else {
scale_cursor_distance(1.0 / magnify_gesture->get_factor());
scale_cursor_distance(1.0 / pinch_gesture->get_factor());
}
}

Ref<InputEventPanGesture> pan_gesture = p_event;
Ref<InputEventGesturePan> pan_gesture = p_event;
if (pan_gesture.is_valid()) {
NavigationScheme nav_scheme = (NavigationScheme)EditorSettings::get_singleton()->get("editors/3d/navigation/navigation_scheme").operator int();
NavigationMode nav_mode = NAVIGATION_NONE;
Expand Down
8 changes: 4 additions & 4 deletions editor/plugins/polygon_2d_editor_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -917,12 +917,12 @@ void Polygon2DEditor::_uv_input(const Ref<InputEvent> &p_input) {
}
}

Ref<InputEventMagnifyGesture> magnify_gesture = p_input;
if (magnify_gesture.is_valid()) {
uv_zoom->set_value(uv_zoom->get_value() * magnify_gesture->get_factor());
Ref<InputEventGesturePinch> pinch_gesture = p_input;
if (pinch_gesture.is_valid()) {
uv_zoom->set_value(uv_zoom->get_value() * pinch_gesture->get_factor());
}

Ref<InputEventPanGesture> pan_gesture = p_input;
Ref<InputEventGesturePan> pan_gesture = p_input;
if (pan_gesture.is_valid()) {
uv_hscroll->set_value(uv_hscroll->get_value() + uv_hscroll->get_page() * pan_gesture->get_delta().x / 8);
uv_vscroll->set_value(uv_vscroll->get_value() + uv_vscroll->get_page() * pan_gesture->get_delta().y / 8);
Expand Down
8 changes: 4 additions & 4 deletions editor/plugins/texture_region_editor_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -592,12 +592,12 @@ void TextureRegionEditor::_region_input(const Ref<InputEvent> &p_input) {
}
}

Ref<InputEventMagnifyGesture> magnify_gesture = p_input;
if (magnify_gesture.is_valid()) {
_zoom_on_position(draw_zoom * magnify_gesture->get_factor(), magnify_gesture->get_position());
Ref<InputEventGesturePinch> pinch_gesture = p_input;
if (pinch_gesture.is_valid()) {
_zoom_on_position(draw_zoom * pinch_gesture->get_factor(), pinch_gesture->get_position());
}

Ref<InputEventPanGesture> pan_gesture = p_input;
Ref<InputEventGesturePan> pan_gesture = p_input;
if (pan_gesture.is_valid()) {
hscroll->set_value(hscroll->get_value() + hscroll->get_page() * pan_gesture->get_delta().x / 8);
vscroll->set_value(vscroll->get_value() + vscroll->get_page() * pan_gesture->get_delta().y / 8);
Expand Down
2 changes: 1 addition & 1 deletion modules/gridmap/grid_map_editor_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -741,7 +741,7 @@ EditorPlugin::AfterGUIInput GridMapEditor::forward_spatial_input_event(Camera3D
}
}

Ref<InputEventPanGesture> pan_gesture = p_event;
Ref<InputEventGesturePan> pan_gesture = p_event;
if (pan_gesture.is_valid()) {
if (pan_gesture->is_alt_pressed() && (pan_gesture->is_command_pressed() || pan_gesture->is_shift_pressed())) {
const real_t delta = pan_gesture->get_delta().y * 0.5;
Expand Down
2 changes: 1 addition & 1 deletion platform/android/android_input_handler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ MouseButton AndroidInputHandler::_android_button_mask_to_godot_button_mask(int a
}

void AndroidInputHandler::process_scroll(Point2 p_pos) {
Ref<InputEventPanGesture> ev;
Ref<InputEventGesturePan> ev;
ev.instantiate();
_set_key_modifier_state(ev);
ev->set_position(p_pos);
Expand Down
4 changes: 2 additions & 2 deletions platform/osx/godot_content_view.mm
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,7 @@ - (void)magnifyWithEvent:(NSEvent *)event {

DisplayServerOSX::WindowData &wd = ds->get_window(window_id);

Ref<InputEventMagnifyGesture> ev;
Ref<InputEventGesturePinch> ev;
ev.instantiate();
ev->set_window_id(window_id);
ds->get_key_modifier_state([event modifierFlags], ev);
Expand Down Expand Up @@ -713,7 +713,7 @@ - (void)processPanEvent:(NSEvent *)event dx:(double)dx dy:(double)dy {

DisplayServerOSX::WindowData &wd = ds->get_window(window_id);

Ref<InputEventPanGesture> pg;
Ref<InputEventGesturePan> pg;
pg.instantiate();

pg->set_window_id(window_id);
Expand Down
8 changes: 4 additions & 4 deletions scene/gui/graph_edit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1348,12 +1348,12 @@ void GraphEdit::gui_input(const Ref<InputEvent> &p_ev) {
}
}

Ref<InputEventMagnifyGesture> magnify_gesture = p_ev;
if (magnify_gesture.is_valid()) {
set_zoom_custom(zoom * magnify_gesture->get_factor(), magnify_gesture->get_position());
Ref<InputEventGesturePinch> pinch_gesture = p_ev;
if (pinch_gesture.is_valid()) {
set_zoom_custom(zoom * pinch_gesture->get_factor(), pinch_gesture->get_position());
}

Ref<InputEventPanGesture> pan_gesture = p_ev;
Ref<InputEventGesturePan> pan_gesture = p_ev;
if (pan_gesture.is_valid()) {
h_scroll->set_value(h_scroll->get_value() + h_scroll->get_page() * pan_gesture->get_delta().x / 8);
v_scroll->set_value(v_scroll->get_value() + v_scroll->get_page() * pan_gesture->get_delta().y / 8);
Expand Down
2 changes: 1 addition & 1 deletion scene/gui/item_list.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -871,7 +871,7 @@ void ItemList::gui_input(const Ref<InputEvent> &p_event) {
}
}

Ref<InputEventPanGesture> pan_gesture = p_event;
Ref<InputEventGesturePan> pan_gesture = p_event;
if (pan_gesture.is_valid()) {
scroll_bar->set_value(scroll_bar->get_value() + scroll_bar->get_page() * pan_gesture->get_delta().y / 8);
}
Expand Down
2 changes: 1 addition & 1 deletion scene/gui/rich_text_label.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1783,7 +1783,7 @@ void RichTextLabel::gui_input(const Ref<InputEvent> &p_event) {
}
}

Ref<InputEventPanGesture> pan_gesture = p_event;
Ref<InputEventGesturePan> pan_gesture = p_event;
if (pan_gesture.is_valid()) {
if (scroll_active) {
vscroll->set_value(vscroll->get_value() + vscroll->get_page() * pan_gesture->get_delta().y * 0.5 / 8);
Expand Down
2 changes: 1 addition & 1 deletion scene/gui/scroll_container.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ void ScrollContainer::gui_input(const Ref<InputEvent> &p_gui_input) {
}
}

Ref<InputEventPanGesture> pan_gesture = p_gui_input;
Ref<InputEventGesturePan> pan_gesture = p_gui_input;
if (pan_gesture.is_valid()) {
if (h_scroll->is_visible_in_tree()) {
h_scroll->set_value(h_scroll->get_value() + h_scroll->get_page() * pan_gesture->get_delta().x / 8);
Expand Down
2 changes: 1 addition & 1 deletion scene/gui/text_edit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1749,7 +1749,7 @@ void TextEdit::gui_input(const Ref<InputEvent> &p_gui_input) {
}
}

const Ref<InputEventPanGesture> pan_gesture = p_gui_input;
const Ref<InputEventGesturePan> pan_gesture = p_gui_input;
if (pan_gesture.is_valid()) {
const real_t delta = pan_gesture->get_delta().y;
if (delta < 0) {
Expand Down
2 changes: 1 addition & 1 deletion scene/gui/tree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3459,7 +3459,7 @@ void Tree::gui_input(const Ref<InputEvent> &p_event) {
}
}

Ref<InputEventPanGesture> pan_gesture = p_event;
Ref<InputEventGesturePan> pan_gesture = p_event;
if (pan_gesture.is_valid()) {
double prev_v = v_scroll->get_value();
v_scroll->set_value(v_scroll->get_value() + v_scroll->get_page() * pan_gesture->get_delta().y / 8);
Expand Down
2 changes: 1 addition & 1 deletion scene/main/viewport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1287,7 +1287,7 @@ void Viewport::_gui_call_input(Control *p_control, const Ref<InputEvent> &p_inpu
mb->get_button_index() == MouseButton::WHEEL_UP ||
mb->get_button_index() == MouseButton::WHEEL_LEFT ||
mb->get_button_index() == MouseButton::WHEEL_RIGHT));
Ref<InputEventPanGesture> pn = p_input;
Ref<InputEventGesturePan> pn = p_input;
cant_stop_me_now = pn.is_valid() || cant_stop_me_now;

bool ismouse = ev.is_valid() || Object::cast_to<InputEventMouseMotion>(*p_input) != nullptr;
Expand Down

0 comments on commit e4479a2

Please sign in to comment.