summaryrefslogtreecommitdiff
path: root/scene
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <rverschelde@gmail.com>2017-12-15 15:39:31 +0100
committerGitHub <noreply@github.com>2017-12-15 15:39:31 +0100
commitc255643e2d6f2c74886ca995e128443c6087e645 (patch)
tree2f7aef3793edad749ba880b7b020dcceec21bf5e /scene
parent433cb6f490893a2d38cc46bbc7c7005cdb1281f8 (diff)
parentbaf11613446110ee6c734c29d9fe5181655449d3 (diff)
Merge pull request #14666 from henriquelalves/slider_issue
Fix slider ticks offset
Diffstat (limited to 'scene')
-rw-r--r--scene/gui/slider.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/scene/gui/slider.cpp b/scene/gui/slider.cpp
index 665ae8b6dd..70b8616af1 100644
--- a/scene/gui/slider.cpp
+++ b/scene/gui/slider.cpp
@@ -184,10 +184,10 @@ void Slider::_notification(int p_what) {
focus->draw(ci,Rect2i(Point2i(),Size2i(style->get_minimum_size().width+style->get_center_size().width,size.height)));
*/
if (ticks > 1) {
- int tickarea = size.height - tick->get_height();
+ int grabber_offset = (grabber->get_size().height / 2 - tick->get_height() / 2);
for (int i = 0; i < ticks; i++) {
if (!ticks_on_borders && (i == 0 || i + 1 == ticks)) continue;
- int ofs = i * tickarea / (ticks - 1);
+ int ofs = (i * areasize / (ticks - 1)) + grabber_offset;
tick->draw(ci, Point2i((size.width - widget_width) / 2, ofs));
}
}
@@ -205,10 +205,10 @@ void Slider::_notification(int p_what) {
*/
if (ticks > 1) {
- int tickarea = size.width - tick->get_width();
+ int grabber_offset = (grabber->get_size().width / 2 - tick->get_width() / 2);
for (int i = 0; i < ticks; i++) {
if ((!ticks_on_borders) && ((i == 0) || ((i + 1) == ticks))) continue;
- int ofs = i * tickarea / (ticks - 1);
+ int ofs = (i * areasize / (ticks - 1)) + grabber_offset;
tick->draw(ci, Point2i(ofs, (size.height - widget_height) / 2));
}
}