Enhance tree scrolling when dragging
(cherry picked from commit 14a901e88f
)
This commit is contained in:
parent
34c2679506
commit
4be1343f3c
|
@ -689,7 +689,7 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) {
|
||||||
theme->set_constant("button_margin", "Tree", default_margin_size * EDSCALE);
|
theme->set_constant("button_margin", "Tree", default_margin_size * EDSCALE);
|
||||||
theme->set_constant("draw_relationship_lines", "Tree", relationship_line_opacity >= 0.01);
|
theme->set_constant("draw_relationship_lines", "Tree", relationship_line_opacity >= 0.01);
|
||||||
theme->set_constant("draw_guides", "Tree", relationship_line_opacity < 0.01);
|
theme->set_constant("draw_guides", "Tree", relationship_line_opacity < 0.01);
|
||||||
theme->set_constant("scroll_border", "Tree", default_margin_size * EDSCALE);
|
theme->set_constant("scroll_border", "Tree", 40 * EDSCALE);
|
||||||
theme->set_constant("scroll_speed", "Tree", 12);
|
theme->set_constant("scroll_speed", "Tree", 12);
|
||||||
|
|
||||||
Ref<StyleBoxFlat> style_tree_btn = style_default->duplicate();
|
Ref<StyleBoxFlat> style_tree_btn = style_default->duplicate();
|
||||||
|
|
|
@ -2845,7 +2845,7 @@ void Tree::_notification(int p_what) {
|
||||||
if (p_what == NOTIFICATION_DRAG_BEGIN) {
|
if (p_what == NOTIFICATION_DRAG_BEGIN) {
|
||||||
|
|
||||||
single_select_defer = NULL;
|
single_select_defer = NULL;
|
||||||
if (cache.scroll_speed > 0 && get_rect().has_point(get_viewport()->get_mouse_position() - get_global_position())) {
|
if (cache.scroll_speed > 0) {
|
||||||
scrolling = true;
|
scrolling = true;
|
||||||
set_physics_process_internal(true);
|
set_physics_process_internal(true);
|
||||||
}
|
}
|
||||||
|
@ -2892,22 +2892,22 @@ void Tree::_notification(int p_what) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (scrolling) {
|
Point2 mouse_position = get_viewport()->get_mouse_position() - get_global_position();
|
||||||
Point2 point = get_viewport()->get_mouse_position() - get_global_position();
|
if (scrolling && get_rect().grow(cache.scroll_border).has_point(mouse_position)) {
|
||||||
if (point.x < cache.scroll_border) {
|
Point2 point;
|
||||||
point.x -= cache.scroll_border;
|
|
||||||
} else if (point.x > get_size().width - cache.scroll_border) {
|
if ((ABS(mouse_position.x) < ABS(mouse_position.x - get_size().width)) && (ABS(mouse_position.x) < cache.scroll_border)) {
|
||||||
point.x -= get_size().width - cache.scroll_border;
|
point.x = mouse_position.x - cache.scroll_border;
|
||||||
} else {
|
} else if (ABS(mouse_position.x - get_size().width) < cache.scroll_border) {
|
||||||
point.x = 0;
|
point.x = mouse_position.x - (get_size().width - cache.scroll_border);
|
||||||
}
|
}
|
||||||
if (point.y < cache.scroll_border) {
|
|
||||||
point.y -= cache.scroll_border;
|
if ((ABS(mouse_position.y) < ABS(mouse_position.y - get_size().height)) && (ABS(mouse_position.y) < cache.scroll_border)) {
|
||||||
} else if (point.y > get_size().height - cache.scroll_border) {
|
point.y = mouse_position.y - cache.scroll_border;
|
||||||
point.y -= get_size().height - cache.scroll_border;
|
} else if (ABS(mouse_position.y - get_size().height) < cache.scroll_border) {
|
||||||
} else {
|
point.y = mouse_position.y - (get_size().height - cache.scroll_border);
|
||||||
point.y = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
point *= cache.scroll_speed * get_physics_process_delta_time();
|
point *= cache.scroll_speed * get_physics_process_delta_time();
|
||||||
point += get_scroll();
|
point += get_scroll();
|
||||||
h_scroll->set_value(point.x);
|
h_scroll->set_value(point.x);
|
||||||
|
|
Loading…
Reference in New Issue