summaryrefslogtreecommitdiff
path: root/scene/gui/slider.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'scene/gui/slider.cpp')
-rw-r--r--scene/gui/slider.cpp54
1 files changed, 29 insertions, 25 deletions
diff --git a/scene/gui/slider.cpp b/scene/gui/slider.cpp
index 3b9ca40bd8..ad6e8786d7 100644
--- a/scene/gui/slider.cpp
+++ b/scene/gui/slider.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -37,7 +37,7 @@ Size2 Slider::get_minimum_size() const {
return ms;
}
-void Slider::_input_event(InputEvent p_event) {
+void Slider::_gui_input(InputEvent p_event) {
@@ -53,19 +53,19 @@ void Slider::_input_event(InputEvent p_event) {
double grab_height = (double)grabber->get_size().height;
double max = orientation==VERTICAL ? get_size().height - grab_height : get_size().width - grab_width;
if (orientation==VERTICAL)
- set_unit_value( 1 - (((double)grab.pos - (grab_height / 2.0)) / max) );
+ set_as_ratio( 1 - (((double)grab.pos - (grab_height / 2.0)) / max) );
else
- set_unit_value(((double)grab.pos - (grab_width/2.0)) / max);
+ set_as_ratio(((double)grab.pos - (grab_width/2.0)) / max);
grab.active=true;
- grab.uvalue=get_unit_value();
+ grab.uvalue=get_as_ratio();
} else {
grab.active=false;
}
} else if (mb.pressed && mb.button_index==BUTTON_WHEEL_UP) {
- set_val( get_val() + get_step());
+ set_value( get_value() + get_step());
} else if (mb.pressed && mb.button_index==BUTTON_WHEEL_DOWN) {
- set_val( get_val() - get_step());
+ set_value( get_value() - get_step());
}
} else if (p_event.type==InputEvent::MOUSE_MOTION) {
@@ -81,7 +81,7 @@ void Slider::_input_event(InputEvent p_event) {
if (areasize<=0)
return;
float umotion = motion / float(areasize);
- set_unit_value( grab.uvalue + umotion );
+ set_as_ratio( grab.uvalue + umotion );
}
} else {
@@ -89,26 +89,26 @@ void Slider::_input_event(InputEvent p_event) {
if (orientation!=HORIZONTAL)
return;
- set_val( get_val() - (custom_step>=0?custom_step:get_step()) );
+ set_value( get_value() - (custom_step>=0?custom_step:get_step()) );
accept_event();
} else if (p_event.is_action("ui_right") && p_event.is_pressed()) {
if (orientation!=HORIZONTAL)
return;
- set_val( get_val() + (custom_step>=0?custom_step:get_step()) );
+ set_value( get_value() + (custom_step>=0?custom_step:get_step()) );
accept_event();
} else if (p_event.is_action("ui_up") && p_event.is_pressed()) {
if (orientation!=VERTICAL)
return;
- set_val( get_val() + (custom_step>=0?custom_step:get_step()) );
+ set_value( get_value() + (custom_step>=0?custom_step:get_step()) );
accept_event();
} else if (p_event.is_action("ui_down") && p_event.is_pressed()) {
if (orientation!=VERTICAL)
return;
- set_val( get_val() - (custom_step>=0?custom_step:get_step()) );
+ set_value( get_value() - (custom_step>=0?custom_step:get_step()) );
accept_event();
} else if (p_event.type==InputEvent::KEY) {
@@ -122,12 +122,12 @@ void Slider::_input_event(InputEvent p_event) {
case KEY_HOME: {
- set_val( get_min() );
+ set_value( get_min() );
accept_event();
} break;
case KEY_END: {
- set_val( get_max() );
+ set_value( get_max() );
accept_event();
} break;
@@ -164,8 +164,10 @@ 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)));
- //if (mouse_inside||has_focus())
- // focus->draw(ci,Rect2i(Point2i(),Size2i(style->get_minimum_size().width+style->get_center_size().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)));
+ */
float areasize = size.height - grabber->get_size().height;
if (ticks>1) {
int tickarea = size.height - tick->get_height();
@@ -176,11 +178,13 @@ void Slider::_notification(int p_what) {
}
}
- grabber->draw(ci,Point2i(size.width/2-grabber->get_size().width/2,size.height - get_unit_value()*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 {
style->draw(ci,Rect2i(Point2i(),Size2i(size.width,style->get_minimum_size().height+style->get_center_size().height)));
- //if (mouse_inside||has_focus())
- // focus->draw(ci,Rect2i(Point2i(),Size2i(size.width,style->get_minimum_size().height+style->get_center_size().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) {
@@ -192,7 +196,7 @@ void Slider::_notification(int p_what) {
}
}
- grabber->draw(ci,Point2i(get_unit_value()*areasize,size.height/2-grabber->get_size().height/2));
+ grabber->draw(ci,Point2i(get_as_ratio()*areasize,size.height/2-grabber->get_size().height/2));
}
} break;
@@ -231,12 +235,12 @@ void Slider::set_ticks_on_borders(bool _tob){
void Slider::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("_input_event"),&Slider::_input_event);
- ObjectTypeDB::bind_method(_MD("set_ticks","count"),&Slider::set_ticks);
- ObjectTypeDB::bind_method(_MD("get_ticks"),&Slider::get_ticks);
+ ClassDB::bind_method(_MD("_gui_input"),&Slider::_gui_input);
+ ClassDB::bind_method(_MD("set_ticks","count"),&Slider::set_ticks);
+ ClassDB::bind_method(_MD("get_ticks"),&Slider::get_ticks);
- ObjectTypeDB::bind_method(_MD("get_ticks_on_borders"),&Slider::get_ticks_on_borders);
- ObjectTypeDB::bind_method(_MD("set_ticks_on_borders","ticks_on_border"),&Slider::set_ticks_on_borders);
+ ClassDB::bind_method(_MD("get_ticks_on_borders"),&Slider::get_ticks_on_borders);
+ ClassDB::bind_method(_MD("set_ticks_on_borders","ticks_on_border"),&Slider::set_ticks_on_borders);
ADD_PROPERTY( PropertyInfo( Variant::INT, "tick_count", PROPERTY_HINT_RANGE,"0,4096,1"), _SCS("set_ticks"), _SCS("get_ticks") );
ADD_PROPERTY( PropertyInfo( Variant::BOOL, "ticks_on_borders" ), _SCS("set_ticks_on_borders"), _SCS("get_ticks_on_borders") );