From 79d85b7ff67e6edc700336ac112dad35e07fe102 Mon Sep 17 00:00:00 2001 From: "Daniel J. Ramirez" Date: Tue, 18 Jul 2017 01:32:25 -0500 Subject: [PATCH] Fixed slider centering when using SIZE_EXPAND_FILL. --- editor/animation_editor.cpp | 1 + scene/gui/slider.cpp | 7 +++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/editor/animation_editor.cpp b/editor/animation_editor.cpp index 1798e66e8a9..45da3656952 100644 --- a/editor/animation_editor.cpp +++ b/editor/animation_editor.cpp @@ -3774,6 +3774,7 @@ AnimationKeyEditor::AnimationKeyEditor() { zoom->set_max(2.0); zoom->set_value(1.0); zoom->set_h_size_flags(SIZE_EXPAND_FILL); + zoom->set_v_size_flags(SIZE_EXPAND_FILL); zoom->set_stretch_ratio(2); hb->add_child(zoom); zoom->connect("value_changed", this, "_scroll_changed"); diff --git a/scene/gui/slider.cpp b/scene/gui/slider.cpp index c84608ef2e6..9ba17ce34f6 100644 --- a/scene/gui/slider.cpp +++ b/scene/gui/slider.cpp @@ -167,7 +167,8 @@ void Slider::_notification(int p_what) { if (orientation == VERTICAL) { - style->draw(ci, Rect2i(Point2i(), Size2i(style->get_minimum_size().width + style->get_center_size().width, size.height))); + int widget_width = style->get_minimum_size().width + style->get_center_size().width; + style->draw(ci, Rect2i(Point2i(size.width / 2 - widget_width / 2, 0), Size2i(widget_width, size.height))); /* if (mouse_inside||has_focus()) focus->draw(ci,Rect2i(Point2i(),Size2i(style->get_minimum_size().width+style->get_center_size().width,size.height))); @@ -183,7 +184,9 @@ void Slider::_notification(int p_what) { } grabber->draw(ci, Point2i(size.width / 2 - grabber->get_size().width / 2, size.height - get_as_ratio() * areasize - grabber->get_size().height)); } else { - style->draw(ci, Rect2i(Point2i(), Size2i(size.width, style->get_minimum_size().height + style->get_center_size().height))); + + int widget_height = style->get_minimum_size().height + style->get_center_size().height; + style->draw(ci, Rect2i(Point2i(0, size.height / 2 - widget_height / 2), Size2i(size.width, widget_height))); /* if (mouse_inside||has_focus()) focus->draw(ci,Rect2i(Point2i(),Size2i(size.width,style->get_minimum_size().height+style->get_center_size().height)));