You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-12-31 18:41:20 +00:00
add gui_drag_threshold for viewports
This commit is contained in:
@@ -2016,7 +2016,7 @@ void Viewport::_gui_input_event(Ref<InputEvent> p_event) {
|
||||
if (!gui.drag_attempted && gui.mouse_focus && section_root && !section_root->gui.global_dragging && (mm->get_button_mask().has_flag(MouseButtonMask::LEFT))) {
|
||||
gui.drag_accum += mm->get_relative();
|
||||
float len = gui.drag_accum.length();
|
||||
if (len > 10) {
|
||||
if (len > gui.drag_threshold) {
|
||||
{ // Attempt grab, try parent controls too.
|
||||
CanvasItem *ci = gui.mouse_focus;
|
||||
while (ci) {
|
||||
@@ -4136,6 +4136,16 @@ TypedArray<Window> Viewport::get_embedded_subwindows() const {
|
||||
return windows;
|
||||
}
|
||||
|
||||
void Viewport::set_drag_threshold(int p_threshold) {
|
||||
ERR_MAIN_THREAD_GUARD
|
||||
gui.drag_threshold = p_threshold;
|
||||
}
|
||||
|
||||
int Viewport::get_drag_threshold() const {
|
||||
ERR_READ_THREAD_GUARD_V(10);
|
||||
return gui.drag_threshold;
|
||||
}
|
||||
|
||||
void Viewport::subwindow_set_popup_safe_rect(Window *p_window, const Rect2i &p_rect) {
|
||||
int index = _sub_window_find(p_window);
|
||||
ERR_FAIL_COND(index == -1);
|
||||
@@ -5033,6 +5043,9 @@ void Viewport::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("is_embedding_subwindows"), &Viewport::is_embedding_subwindows);
|
||||
ClassDB::bind_method(D_METHOD("get_embedded_subwindows"), &Viewport::get_embedded_subwindows);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_drag_threshold", "threshold"), &Viewport::set_drag_threshold);
|
||||
ClassDB::bind_method(D_METHOD("get_drag_threshold"), &Viewport::get_drag_threshold);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_canvas_cull_mask", "mask"), &Viewport::set_canvas_cull_mask);
|
||||
ClassDB::bind_method(D_METHOD("get_canvas_cull_mask"), &Viewport::get_canvas_cull_mask);
|
||||
|
||||
@@ -5158,6 +5171,7 @@ void Viewport::_bind_methods() {
|
||||
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "gui_disable_input"), "set_disable_input", "is_input_disabled");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "gui_snap_controls_to_pixels"), "set_snap_controls_to_pixels", "is_snap_controls_to_pixels_enabled");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "gui_embed_subwindows"), "set_embedding_subwindows", "is_embedding_subwindows");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "gui_drag_threshold"), "set_drag_threshold", "get_drag_threshold");
|
||||
ADD_GROUP("SDF", "sdf_");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "sdf_oversize", PROPERTY_HINT_ENUM, "100%,120%,150%,200%"), "set_sdf_oversize", "get_sdf_oversize");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "sdf_scale", PROPERTY_HINT_ENUM, "100%,50%,25%"), "set_sdf_scale", "get_sdf_scale");
|
||||
|
||||
@@ -401,6 +401,7 @@ private:
|
||||
bool drag_successful = false;
|
||||
Control *target_control = nullptr; // Control that the mouse is over in the innermost nested Viewport. Only used in root-Viewport and SubViewports, that are not children of a SubViewportContainer.
|
||||
bool embed_subwindows_hint = false;
|
||||
int drag_threshold = 10;
|
||||
|
||||
Window *subwindow_focused = nullptr;
|
||||
Window *currently_dragged_subwindow = nullptr;
|
||||
@@ -706,6 +707,9 @@ public:
|
||||
void subwindow_set_popup_safe_rect(Window *p_window, const Rect2i &p_rect);
|
||||
Rect2i subwindow_get_popup_safe_rect(Window *p_window) const;
|
||||
|
||||
void set_drag_threshold(int p_threshold);
|
||||
int get_drag_threshold() const;
|
||||
|
||||
Viewport *get_parent_viewport() const;
|
||||
Window *get_base_window();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user