| 43 | #include "scene/theme/theme_db.h" |
| 44 | |
| 45 | void 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 | |
| 95 | Control::CursorShape SplitContainerDragger::get_cursor_shape(const Point2 &p_pos) const { |
| 96 | SplitContainer *sc = Object::cast_to<SplitContainer>(get_parent()); |
nothing calls this directly
no test coverage detected