Fix scrollbar regression on large scales

This commit is contained in:
Michael Alexsander
2020-01-16 00:36:31 -03:00
parent e889100f2f
commit 76e03f9b4d
3 changed files with 36 additions and 6 deletions

View File

@ -289,6 +289,20 @@ void GraphEdit::_notification(int p_what) {
zoom_plus->set_icon(get_icon("more"));
snap_button->set_icon(get_icon("snap"));
}
if (p_what == NOTIFICATION_READY) {
Size2 hmin = h_scroll->get_combined_minimum_size();
Size2 vmin = v_scroll->get_combined_minimum_size();
h_scroll->set_anchor_and_margin(MARGIN_LEFT, ANCHOR_BEGIN, 0);
h_scroll->set_anchor_and_margin(MARGIN_RIGHT, ANCHOR_END, 0);
h_scroll->set_anchor_and_margin(MARGIN_TOP, ANCHOR_END, -hmin.height);
h_scroll->set_anchor_and_margin(MARGIN_BOTTOM, ANCHOR_END, 0);
v_scroll->set_anchor_and_margin(MARGIN_LEFT, ANCHOR_END, -vmin.width);
v_scroll->set_anchor_and_margin(MARGIN_RIGHT, ANCHOR_END, 0);
v_scroll->set_anchor_and_margin(MARGIN_TOP, ANCHOR_BEGIN, 0);
v_scroll->set_anchor_and_margin(MARGIN_BOTTOM, ANCHOR_END, 0);
}
if (p_what == NOTIFICATION_DRAW) {
draw_style_box(get_stylebox("bg"), Rect2(Point2(), get_size()));
@ -1341,12 +1355,10 @@ GraphEdit::GraphEdit() {
h_scroll = memnew(HScrollBar);
h_scroll->set_name("_h_scroll");
top_layer->add_child(h_scroll);
h_scroll->set_anchors_and_margins_preset(PRESET_BOTTOM_WIDE);
v_scroll = memnew(VScrollBar);
v_scroll->set_name("_v_scroll");
top_layer->add_child(v_scroll);
v_scroll->set_anchors_and_margins_preset(PRESET_RIGHT_WIDE);
updating = false;
connecting = false;