MCPcopy Create free account
hub / github.com/Redot-Engine/redot-engine / gui_input

Method gui_input

scene/gui/split_container.cpp:45–93  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

43#include "scene/theme/theme_db.h"
44
45void SplitContainerDragger::gui_input(const Ref<InputEvent> &p_event) {
46 ERR_FAIL_COND(p_event.is_null());
47
48 SplitContainer *sc = Object::cast_to<SplitContainer>(get_parent());
49
50 if (sc->collapsed || !sc->_get_sortable_child(0) || !sc->_get_sortable_child(1) || !sc->dragging_enabled) {
51 return;
52 }
53
54 Ref<InputEventMouseButton> mb = p_event;
55
56 if (mb.is_valid()) {
57 if (mb->get_button_index() == MouseButton::LEFT) {
58 if (mb->is_pressed()) {
59 sc->_compute_split_offset(true);
60 dragging = true;
61 sc->emit_signal(SNAME("drag_started"));
62 drag_ofs = sc->split_offset;
63 if (sc->vertical) {
64 drag_from = get_transform().xform(mb->get_position()).y;
65 } else {
66 drag_from = get_transform().xform(mb->get_position()).x;
67 }
68 } else {
69 dragging = false;
70 queue_redraw();
71 sc->emit_signal(SNAME("drag_ended"));
72 }
73 }
74 }
75
76 Ref<InputEventMouseMotion> mm = p_event;
77
78 if (mm.is_valid()) {
79 if (!dragging) {
80 return;
81 }
82
83 Vector2i in_parent_pos = get_transform().xform(mm->get_position());
84 if (!sc->vertical && is_layout_rtl()) {
85 sc->split_offset = drag_ofs - (in_parent_pos.x - drag_from);
86 } else {
87 sc->split_offset = drag_ofs + ((sc->vertical ? in_parent_pos.y : in_parent_pos.x) - drag_from);
88 }
89 sc->_compute_split_offset(true);
90 sc->queue_sort();
91 sc->emit_signal(SNAME("dragged"), sc->get_split_offset());
92 }
93}
94
95Control::CursorShape SplitContainerDragger::get_cursor_shape(const Point2 &p_pos) const {
96 SplitContainer *sc = Object::cast_to<SplitContainer>(get_parent());

Callers

nothing calls this directly

Calls 11

_get_sortable_childMethod · 0.80
get_button_indexMethod · 0.80
_compute_split_offsetMethod · 0.80
emit_signalMethod · 0.80
queue_sortMethod · 0.80
get_split_offsetMethod · 0.80
is_nullMethod · 0.45
is_validMethod · 0.45
is_pressedMethod · 0.45
xformMethod · 0.45
get_positionMethod · 0.45

Tested by

no test coverage detected