diff options
author | RĂ©mi Verschelde <rverschelde@gmail.com> | 2017-09-13 20:09:28 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-09-13 20:09:28 +0200 |
commit | 57a55489650faa18d785b69d2ed59314ab6faf7b (patch) | |
tree | 1b97649b3c75d99dfad7aad04573351de05ff62f /scene | |
parent | cc7c892bca3ed70d1ce41cb64e53a6e50da6d0be (diff) | |
parent | c2c8aac9a302700d777acf539fda6113004d83e3 (diff) |
Merge pull request #11191 from toger5/slider_highlight_area
added highlight area to slider
Diffstat (limited to 'scene')
-rw-r--r-- | scene/gui/slider.cpp | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/scene/gui/slider.cpp b/scene/gui/slider.cpp index 4661f54526..8fda5df53c 100644 --- a/scene/gui/slider.cpp +++ b/scene/gui/slider.cpp @@ -162,18 +162,20 @@ void Slider::_notification(int p_what) { Size2i size = get_size(); Ref<StyleBox> style = get_stylebox("slider"); Ref<StyleBox> focus = get_stylebox("focus"); + Ref<StyleBox> grabber_area = get_stylebox("grabber_area"); Ref<Texture> grabber = get_icon(editable ? ((mouse_inside || has_focus()) ? "grabber_highlight" : "grabber") : "grabber_disabled"); Ref<Texture> tick = get_icon("tick"); if (orientation == VERTICAL) { int widget_width = style->get_minimum_size().width + style->get_center_size().width; + float areasize = size.height - grabber->get_size().height; style->draw(ci, Rect2i(Point2i(size.width / 2 - widget_width / 2, 0), Size2i(widget_width, size.height))); + grabber_area->draw(ci, Rect2i(Point2i((size.width - widget_width) / 2, size.height - areasize * get_as_ratio() - grabber->get_size().height / 2), Size2i(widget_width, areasize * get_as_ratio() + grabber->get_size().width / 2))); /* if (mouse_inside||has_focus()) focus->draw(ci,Rect2i(Point2i(),Size2i(style->get_minimum_size().width+style->get_center_size().width,size.height))); */ - float areasize = size.height - grabber->get_size().height; if (ticks > 1) { int tickarea = size.height - tick->get_height(); for (int i = 0; i < ticks; i++) { @@ -186,13 +188,15 @@ void Slider::_notification(int p_what) { } else { 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))); + float areasize = size.width - grabber->get_size().width; + + style->draw(ci, Rect2i(Point2i(0, (size.height - widget_height) / 2), Size2i(size.width, widget_height))); + grabber_area->draw(ci, Rect2i(Point2i(0, (size.height - widget_height) / 2), Size2i(areasize * get_as_ratio() + grabber->get_size().width / 2, 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))); */ - float areasize = size.width - grabber->get_size().width; if (ticks > 1) { int tickarea = size.width - tick->get_width(); for (int i = 0; i < ticks; i++) { |