summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2017-07-18 14:05:54 +0200
committerGitHub <noreply@github.com>2017-07-18 14:05:54 +0200
commite21ea393ea9d69a53f82ec4aa6d8c7f05c16979a (patch)
tree0b4706c3cad281fc477980bad565e20ffe83a168
parent5a42bbaace7d8a72e2842f760c6ac905ac238d2c (diff)
parent79d85b7ff67e6edc700336ac112dad35e07fe102 (diff)
Merge pull request #9688 from djrm/slider_fix
Fixed slider centering when using SIZE_EXPAND_FILL.
-rw-r--r--editor/animation_editor.cpp1
-rw-r--r--scene/gui/slider.cpp7
2 files changed, 6 insertions, 2 deletions
diff --git a/editor/animation_editor.cpp b/editor/animation_editor.cpp
index 1798e66e8a..45da365695 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 c84608ef2e..9ba17ce34f 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)));