summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--scene/gui/base_button.cpp22
-rw-r--r--scene/gui/base_button.h16
-rw-r--r--scene/gui/menu_button.cpp2
-rw-r--r--scene/gui/progress_bar.cpp4
-rw-r--r--scene/gui/range.cpp38
-rw-r--r--scene/gui/range.h14
-rw-r--r--scene/gui/scroll_bar.cpp6
-rw-r--r--scene/gui/slider.cpp12
-rw-r--r--scene/gui/texture_progress.cpp12
-rw-r--r--scene/gui/tree.cpp2
10 files changed, 71 insertions, 57 deletions
diff --git a/scene/gui/base_button.cpp b/scene/gui/base_button.cpp
index e161906775..8949a080c1 100644
--- a/scene/gui/base_button.cpp
+++ b/scene/gui/base_button.cpp
@@ -64,7 +64,7 @@ void BaseButton::_gui_input(InputEvent p_event) {
if (status.pressing_button)
break;
- if (status.click_on_press) {
+ if (action_mode==ACTION_MODE_BUTTON_PRESS) {
if (b.pressed) {
@@ -415,14 +415,14 @@ bool BaseButton::is_toggle_mode() const {
return toggle_mode;
}
-void BaseButton::set_click_on_press(bool p_click_on_press) {
+void BaseButton::set_action_mode(ActionMode p_mode) {
- status.click_on_press=p_click_on_press;
+ action_mode=p_mode;
}
-bool BaseButton::get_click_on_press() const {
+BaseButton::ActionMode BaseButton::get_action_mode() const {
- return status.click_on_press;
+ return action_mode;
}
void BaseButton::set_enabled_focus_mode(FocusMode p_mode) {
@@ -514,8 +514,8 @@ void BaseButton::_bind_methods() {
ClassDB::bind_method(_MD("is_toggle_mode"),&BaseButton::is_toggle_mode);
ClassDB::bind_method(_MD("set_disabled","disabled"),&BaseButton::set_disabled);
ClassDB::bind_method(_MD("is_disabled"),&BaseButton::is_disabled);
- ClassDB::bind_method(_MD("set_click_on_press","enable"),&BaseButton::set_click_on_press);
- ClassDB::bind_method(_MD("get_click_on_press"),&BaseButton::get_click_on_press);
+ ClassDB::bind_method(_MD("set_action_mode","mode"),&BaseButton::set_action_mode);
+ ClassDB::bind_method(_MD("get_action_mode"),&BaseButton::get_action_mode);
ClassDB::bind_method(_MD("get_draw_mode"),&BaseButton::get_draw_mode);
ClassDB::bind_method(_MD("set_enabled_focus_mode","mode"),&BaseButton::set_enabled_focus_mode);
ClassDB::bind_method(_MD("get_enabled_focus_mode"),&BaseButton::get_enabled_focus_mode);
@@ -536,7 +536,7 @@ void BaseButton::_bind_methods() {
ADD_PROPERTYNZ( PropertyInfo( Variant::BOOL, "disabled"), _SCS("set_disabled"), _SCS("is_disabled"));
ADD_PROPERTY( PropertyInfo( Variant::BOOL, "toggle_mode"), _SCS("set_toggle_mode"), _SCS("is_toggle_mode"));
ADD_PROPERTYNZ( PropertyInfo( Variant::BOOL, "is_pressed"), _SCS("set_pressed"), _SCS("is_pressed"));
- ADD_PROPERTYNZ( PropertyInfo( Variant::BOOL, "click_on_press"), _SCS("set_click_on_press"), _SCS("get_click_on_press"));
+ ADD_PROPERTYNO( PropertyInfo( Variant::INT, "action_mode",PROPERTY_HINT_ENUM,"Button Press,Button Release"), _SCS("set_action_mode"), _SCS("get_action_mode"));
ADD_PROPERTY( PropertyInfo( Variant::INT,"enabled_focus_mode", PROPERTY_HINT_ENUM, "None,Click,All" ), _SCS("set_enabled_focus_mode"), _SCS("get_enabled_focus_mode") );
ADD_PROPERTY( PropertyInfo( Variant::OBJECT, "shortcut",PROPERTY_HINT_RESOURCE_TYPE,"ShortCut"), _SCS("set_shortcut"), _SCS("get_shortcut"));
ADD_PROPERTY( PropertyInfo( Variant::OBJECT, "group",PROPERTY_HINT_RESOURCE_TYPE,"ButtonGroup"), _SCS("set_button_group"), _SCS("get_button_group"));
@@ -547,6 +547,10 @@ void BaseButton::_bind_methods() {
BIND_CONSTANT( DRAW_HOVER );
BIND_CONSTANT( DRAW_DISABLED );
+ BIND_CONSTANT( ACTION_MODE_BUTTON_PRESS );
+ BIND_CONSTANT( ACTION_MODE_BUTTON_RELEASE );
+
+
}
BaseButton::BaseButton() {
@@ -557,10 +561,10 @@ BaseButton::BaseButton() {
status.hovering=false;
status.pressing_inside=false;
status.disabled = false;
- status.click_on_press=false;
status.pressing_button=0;
set_focus_mode( FOCUS_ALL );
enabled_focus_mode = FOCUS_ALL;
+ action_mode=ACTION_MODE_BUTTON_RELEASE;
if (button_group.is_valid()) {
diff --git a/scene/gui/base_button.h b/scene/gui/base_button.h
index 898c19e811..def4ff7536 100644
--- a/scene/gui/base_button.h
+++ b/scene/gui/base_button.h
@@ -40,11 +40,20 @@ class ButtonGroup;
class BaseButton : public Control {
GDCLASS( BaseButton, Control );
+public:
+
+ enum ActionMode {
+ ACTION_MODE_BUTTON_PRESS,
+ ACTION_MODE_BUTTON_RELEASE,
+ };
+
+private:
bool toggle_mode;
FocusMode enabled_focus_mode;
Ref<ShortCut> shortcut;
+ ActionMode action_mode;
struct Status {
bool pressed;
@@ -53,7 +62,6 @@ class BaseButton : public Control {
bool pressing_inside;
bool disabled;
- bool click_on_press;
int pressing_button;
} status;
@@ -100,8 +108,8 @@ public:
void set_disabled(bool p_disabled);
bool is_disabled() const;
- void set_click_on_press(bool p_click_on_press);
- bool get_click_on_press() const;
+ void set_action_mode(ActionMode p_mode);
+ ActionMode get_action_mode() const;
void set_enabled_focus_mode(FocusMode p_mode);
FocusMode get_enabled_focus_mode() const;
@@ -120,6 +128,8 @@ public:
};
VARIANT_ENUM_CAST( BaseButton::DrawMode )
+VARIANT_ENUM_CAST( BaseButton::ActionMode )
+
class ButtonGroup : public Resource {
diff --git a/scene/gui/menu_button.cpp b/scene/gui/menu_button.cpp
index 4fed40f4ac..4a366c55c6 100644
--- a/scene/gui/menu_button.cpp
+++ b/scene/gui/menu_button.cpp
@@ -117,7 +117,7 @@ MenuButton::MenuButton() {
add_child(popup);
popup->set_as_toplevel(true);
set_process_unhandled_key_input(true);
- set_click_on_press(true);
+ set_action_mode(ACTION_MODE_BUTTON_PRESS);
}
diff --git a/scene/gui/progress_bar.cpp b/scene/gui/progress_bar.cpp
index ee9369fb3a..0f99d4f19e 100644
--- a/scene/gui/progress_bar.cpp
+++ b/scene/gui/progress_bar.cpp
@@ -53,7 +53,7 @@ void ProgressBar::_notification(int p_what) {
Color font_color=get_color("font_color");
draw_style_box(bg,Rect2(Point2(),get_size()));
- float r = get_unit_value();
+ float r = get_as_ratio();
int mp = fg->get_minimum_size().width;
int p = r*get_size().width-mp;
if (p>0) {
@@ -62,7 +62,7 @@ void ProgressBar::_notification(int p_what) {
}
if (percent_visible) {
- String txt=itos(int(get_unit_value()*100))+"%";
+ String txt=itos(int(get_as_ratio()*100))+"%";
font->draw_halign(get_canvas_item(),Point2(0,font->get_ascent()+(get_size().height-font->get_height())/2),HALIGN_CENTER,get_size().width,txt,font_color);
}
}
diff --git a/scene/gui/range.cpp b/scene/gui/range.cpp
index 2f37ed0341..d5c1034c9c 100644
--- a/scene/gui/range.cpp
+++ b/scene/gui/range.cpp
@@ -135,11 +135,11 @@ double Range::get_page() const {
return shared->page;
}
-void Range::set_unit_value(double p_value) {
+void Range::set_as_ratio(double p_value) {
double v;
- if (shared->exp_unit_value && get_min()>0) {
+ if (shared->exp_ratio && get_min()>0) {
double exp_min = Math::log(get_min())/Math::log(2);
double exp_max = Math::log(get_max())/Math::log(2);
@@ -156,9 +156,9 @@ void Range::set_unit_value(double p_value) {
}
set_value( v );
}
-double Range::get_unit_value() const {
+double Range::get_as_ratio() const {
- if (shared->exp_unit_value && get_min()>0) {
+ if (shared->exp_ratio && get_min()>0) {
double exp_min = Math::log(get_min())/Math::log(2);
double exp_max = Math::log(get_max())/Math::log(2);
@@ -227,17 +227,17 @@ void Range::_bind_methods() {
ClassDB::bind_method(_MD("get_max"),&Range::get_max);
ClassDB::bind_method(_MD("get_step"),&Range::get_step);
ClassDB::bind_method(_MD("get_page"),&Range::get_page);
- ClassDB::bind_method(_MD("get_unit_value"),&Range::get_unit_value);
+ ClassDB::bind_method(_MD("get_as_ratio"),&Range::get_as_ratio);
ClassDB::bind_method(_MD("set_value","value"),&Range::set_value);
ClassDB::bind_method(_MD("set_min","minimum"),&Range::set_min);
ClassDB::bind_method(_MD("set_max","maximum"),&Range::set_max);
ClassDB::bind_method(_MD("set_step","step"),&Range::set_step);
ClassDB::bind_method(_MD("set_page","pagesize"),&Range::set_page);
- ClassDB::bind_method(_MD("set_unit_value","value"),&Range::set_unit_value);
- ClassDB::bind_method(_MD("set_rounded_values","enabled"),&Range::set_rounded_values);
- ClassDB::bind_method(_MD("is_rounded_values"),&Range::is_rounded_values);
- ClassDB::bind_method(_MD("set_exp_unit_value","enabled"),&Range::set_exp_unit_value);
- ClassDB::bind_method(_MD("is_unit_value_exp"),&Range::is_unit_value_exp);
+ ClassDB::bind_method(_MD("set_as_ratio","value"),&Range::set_as_ratio);
+ ClassDB::bind_method(_MD("set_use_rounded_values","enabled"),&Range::set_use_rounded_values);
+ ClassDB::bind_method(_MD("is_using_rounded_values"),&Range::is_using_rounded_values);
+ ClassDB::bind_method(_MD("set_exp_ratio","enabled"),&Range::set_exp_ratio);
+ ClassDB::bind_method(_MD("is_ratio_exp"),&Range::is_ratio_exp);
ClassDB::bind_method(_MD("share","with"),&Range::_share);
ClassDB::bind_method(_MD("unshare"),&Range::unshare);
@@ -250,29 +250,29 @@ void Range::_bind_methods() {
ADD_PROPERTY( PropertyInfo( Variant::REAL, "step" ), _SCS("set_step"), _SCS("get_step") );
ADD_PROPERTY( PropertyInfo( Variant::REAL, "page" ), _SCS("set_page"), _SCS("get_page") );
ADD_PROPERTY( PropertyInfo( Variant::REAL, "value" ), _SCS("set_value"), _SCS("get_value") );
- ADD_PROPERTY( PropertyInfo( Variant::BOOL, "exp_edit" ), _SCS("set_exp_unit_value"), _SCS("is_unit_value_exp") );
- ADD_PROPERTY( PropertyInfo( Variant::BOOL, "rounded" ), _SCS("set_rounded_values"), _SCS("is_rounded_values") );
+ ADD_PROPERTY( PropertyInfo( Variant::BOOL, "exp_edit" ), _SCS("set_exp_ratio"), _SCS("is_ratio_exp") );
+ ADD_PROPERTY( PropertyInfo( Variant::BOOL, "rounded" ), _SCS("set_use_rounded_values"), _SCS("is_using_rounded_values") );
}
-void Range::set_rounded_values(bool p_enable) {
+void Range::set_use_rounded_values(bool p_enable) {
_rounded_values = p_enable;
}
-bool Range::is_rounded_values() const {
+bool Range::is_using_rounded_values() const {
return _rounded_values;
}
-void Range::set_exp_unit_value(bool p_enable) {
+void Range::set_exp_ratio(bool p_enable) {
- shared->exp_unit_value=p_enable;
+ shared->exp_ratio=p_enable;
}
-bool Range::is_unit_value_exp() const {
+bool Range::is_ratio_exp() const {
- return shared->exp_unit_value;
+ return shared->exp_ratio;
}
@@ -285,7 +285,7 @@ Range::Range()
shared->step=1;
shared->page=0;
shared->owners.insert(this);
- shared->exp_unit_value=false;
+ shared->exp_ratio=false;
_rounded_values = false;
}
diff --git a/scene/gui/range.h b/scene/gui/range.h
index 0872254fff..5f274a6901 100644
--- a/scene/gui/range.h
+++ b/scene/gui/range.h
@@ -41,7 +41,7 @@ class Range : public Control {
struct Shared {
double val,min,max;
double step,page;
- bool exp_unit_value;
+ bool exp_ratio;
Set<Range*> owners;
void emit_value_changed();
void emit_changed(const char *p_what="");
@@ -71,20 +71,20 @@ public:
void set_max(double p_max);
void set_step(double p_step);
void set_page(double p_page);
- void set_unit_value(double p_value);
+ void set_as_ratio(double p_value);
double get_value() const;
double get_min() const;
double get_max() const;
double get_step() const;
double get_page() const;
- double get_unit_value() const;
+ double get_as_ratio() const;
- void set_rounded_values(bool p_enable);
- bool is_rounded_values() const;
+ void set_use_rounded_values(bool p_enable);
+ bool is_using_rounded_values() const;
- void set_exp_unit_value(bool p_enable);
- bool is_unit_value_exp() const;
+ void set_exp_ratio(bool p_enable);
+ bool is_ratio_exp() const;
void share(Range *p_range);
void unshare();
diff --git a/scene/gui/scroll_bar.cpp b/scene/gui/scroll_bar.cpp
index 2c44e51e5e..da267b9f27 100644
--- a/scene/gui/scroll_bar.cpp
+++ b/scene/gui/scroll_bar.cpp
@@ -112,7 +112,7 @@ void ScrollBar::_gui_input(InputEvent p_event) {
drag.active=true;
drag.pos_at_click=grabber_ofs+ofs;
- drag.value_at_click=get_unit_value();
+ drag.value_at_click=get_as_ratio();
update();
} else {
@@ -145,7 +145,7 @@ void ScrollBar::_gui_input(InputEvent p_event) {
double diff = (ofs-drag.pos_at_click) / get_area_size();
- set_unit_value( drag.value_at_click + diff );
+ set_as_ratio( drag.value_at_click + diff );
} else {
@@ -497,7 +497,7 @@ double ScrollBar::get_click_pos(const Point2& p_pos) const {
double ScrollBar::get_grabber_offset() const {
- return (get_area_size()) * get_unit_value();
+ return (get_area_size()) * get_as_ratio();
}
diff --git a/scene/gui/slider.cpp b/scene/gui/slider.cpp
index dacfc644ee..a7cc38846d 100644
--- a/scene/gui/slider.cpp
+++ b/scene/gui/slider.cpp
@@ -53,11 +53,11 @@ void Slider::_gui_input(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;
}
@@ -81,7 +81,7 @@ void Slider::_gui_input(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 {
@@ -176,7 +176,7 @@ 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())
@@ -192,7 +192,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;
diff --git a/scene/gui/texture_progress.cpp b/scene/gui/texture_progress.cpp
index df0512fc96..f6a33b5643 100644
--- a/scene/gui/texture_progress.cpp
+++ b/scene/gui/texture_progress.cpp
@@ -135,24 +135,24 @@ void TextureProgress::_notification(int p_what){
Size2 s = progress->get_size();
switch (mode) {
case FILL_LEFT_TO_RIGHT: {
- Rect2 region=Rect2(Point2(),Size2(s.x*get_unit_value(),s.y));
+ Rect2 region=Rect2(Point2(),Size2(s.x*get_as_ratio(),s.y));
draw_texture_rect_region(progress,region,region);
} break;
case FILL_RIGHT_TO_LEFT: {
- Rect2 region=Rect2(Point2(s.x-s.x*get_unit_value(),0),Size2(s.x*get_unit_value(),s.y));
+ Rect2 region=Rect2(Point2(s.x-s.x*get_as_ratio(),0),Size2(s.x*get_as_ratio(),s.y));
draw_texture_rect_region(progress,region,region);
} break;
case FILL_TOP_TO_BOTTOM: {
- Rect2 region=Rect2(Point2(),Size2(s.x,s.y*get_unit_value()));
+ Rect2 region=Rect2(Point2(),Size2(s.x,s.y*get_as_ratio()));
draw_texture_rect_region(progress,region,region);
} break;
case FILL_BOTTOM_TO_TOP: {
- Rect2 region=Rect2(Point2(0,s.y-s.y*get_unit_value()),Size2(s.x,s.y*get_unit_value()));
+ Rect2 region=Rect2(Point2(0,s.y-s.y*get_as_ratio()),Size2(s.x,s.y*get_as_ratio()));
draw_texture_rect_region(progress,region,region);
} break;
case FILL_CLOCKWISE:
case FILL_COUNTER_CLOCKWISE: {
- float val=get_unit_value()*rad_max_degrees/360;
+ float val=get_as_ratio()*rad_max_degrees/360;
if (val==1) {
Rect2 region=Rect2(Point2(),s);
draw_texture_rect_region(progress,region,region);
@@ -192,7 +192,7 @@ void TextureProgress::_notification(int p_what){
}
} break;
default:
- draw_texture_rect_region(progress,Rect2(Point2(),Size2(s.x*get_unit_value(),s.y)),Rect2(Point2(),Size2(s.x*get_unit_value(),s.y)));
+ draw_texture_rect_region(progress,Rect2(Point2(),Size2(s.x*get_as_ratio(),s.y)),Rect2(Point2(),Size2(s.x*get_as_ratio(),s.y)));
}
diff --git a/scene/gui/tree.cpp b/scene/gui/tree.cpp
index 19bb515bea..b50ecc58ef 100644
--- a/scene/gui/tree.cpp
+++ b/scene/gui/tree.cpp
@@ -2567,7 +2567,7 @@ bool Tree::edit_selected() {
value_editor->set_max( c.max );
value_editor->set_step( c.step );
value_editor->set_value( c.val );
- value_editor->set_exp_unit_value( c.expr );
+ value_editor->set_exp_ratio( c.expr );
updating_value_editor=false;
}