Fixed slider centering when using SIZE_EXPAND_FILL.

This commit is contained in:
Daniel J. Ramirez 2017-07-18 01:32:25 -05:00
parent 69a4ea34c4
commit 79d85b7ff6
2 changed files with 6 additions and 2 deletions

View File

@ -3774,6 +3774,7 @@ AnimationKeyEditor::AnimationKeyEditor() {
zoom->set_max(2.0); zoom->set_max(2.0);
zoom->set_value(1.0); zoom->set_value(1.0);
zoom->set_h_size_flags(SIZE_EXPAND_FILL); zoom->set_h_size_flags(SIZE_EXPAND_FILL);
zoom->set_v_size_flags(SIZE_EXPAND_FILL);
zoom->set_stretch_ratio(2); zoom->set_stretch_ratio(2);
hb->add_child(zoom); hb->add_child(zoom);
zoom->connect("value_changed", this, "_scroll_changed"); zoom->connect("value_changed", this, "_scroll_changed");

View File

@ -167,7 +167,8 @@ void Slider::_notification(int p_what) {
if (orientation == VERTICAL) { 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()) if (mouse_inside||has_focus())
focus->draw(ci,Rect2i(Point2i(),Size2i(style->get_minimum_size().width+style->get_center_size().width,size.height))); 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)); grabber->draw(ci, Point2i(size.width / 2 - grabber->get_size().width / 2, size.height - get_as_ratio() * areasize - grabber->get_size().height));
} else { } 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()) if (mouse_inside||has_focus())
focus->draw(ci,Rect2i(Point2i(),Size2i(size.width,style->get_minimum_size().height+style->get_center_size().height))); focus->draw(ci,Rect2i(Point2i(),Size2i(size.width,style->get_minimum_size().height+style->get_center_size().height)));