diff options
author | Rémi Verschelde <remi@verschelde.fr> | 2016-03-09 00:14:08 +0100 |
---|---|---|
committer | Rémi Verschelde <remi@verschelde.fr> | 2016-03-09 00:14:08 +0100 |
commit | e46e43d2aaa6339a1675eb989f41885e745bf5c3 (patch) | |
tree | cf91f2869ff8f058c6682569fb31e22e5ee736ad /scene/gui/control.cpp | |
parent | 1dad6eca812e5c2e313b54265114de8a1d73d999 (diff) | |
parent | 4a4f2479146aa33e235ed57cde311efda68d3c8f (diff) |
Merge pull request #3928 from Marqin/whitespace
remove trailing whitespace - sorry for the broken PRs, please rebase :)
Diffstat (limited to 'scene/gui/control.cpp')
-rw-r--r-- | scene/gui/control.cpp | 142 |
1 files changed, 71 insertions, 71 deletions
diff --git a/scene/gui/control.cpp b/scene/gui/control.cpp index af3b37bec2..295ec03702 100644 --- a/scene/gui/control.cpp +++ b/scene/gui/control.cpp @@ -226,9 +226,9 @@ bool Control::_get(const StringName& p_name,Variant &r_ret) const { return false; - + return true; - + } void Control::_get_property_list( List<PropertyInfo> *p_list) const { @@ -326,7 +326,7 @@ Control *Control::get_parent_control() const { void Control::_resize(const Size2& p_size) { - + _size_changed(); } @@ -626,7 +626,7 @@ void Control::set_drag_preview(Control *p_control) { } - + bool Control::is_window_modal_on_top() const { @@ -640,7 +640,7 @@ bool Control::is_window_modal_on_top() const { Size2 Control::get_minimum_size() const { - + ScriptInstance *si = const_cast<Control*>(this)->get_script_instance(); if (si) { @@ -654,7 +654,7 @@ Size2 Control::get_minimum_size() const { Ref<Texture> Control::get_icon(const StringName& p_name,const StringName& p_type) const { - + if (p_type==StringName()) { const Ref<Texture>* tex = data.icon_override.getptr(p_name); @@ -714,7 +714,7 @@ Ref<Shader> Control::get_shader(const StringName& p_name,const StringName& p_typ } Ref<StyleBox> Control::get_stylebox(const StringName& p_name,const StringName& p_type) const { - + if (p_type==StringName()) { const Ref<StyleBox>* style = data.style_override.getptr(p_name); if (style) @@ -828,12 +828,12 @@ int Control::get_constant(const StringName& p_name,const StringName& p_type) con return Theme::get_default()->get_constant( p_name, type ); - + } bool Control::has_icon(const StringName& p_name,const StringName& p_type) const { - + if (p_type==StringName()) { const Ref<Texture>* tex = data.icon_override.getptr(p_name); if (tex) @@ -859,7 +859,7 @@ bool Control::has_icon(const StringName& p_name,const StringName& p_type) const } return Theme::get_default()->has_icon( p_name, type ); - + } bool Control::has_shader(const StringName &p_name, const StringName &p_type) const @@ -889,10 +889,10 @@ bool Control::has_shader(const StringName &p_name, const StringName &p_type) con } return Theme::get_default()->has_shader( p_name, type ); - + } bool Control::has_stylebox(const StringName& p_name,const StringName& p_type) const { - + if (p_type==StringName()) { const Ref<StyleBox>* style = data.style_override.getptr(p_name); @@ -922,7 +922,7 @@ bool Control::has_stylebox(const StringName& p_name,const StringName& p_type) co } bool Control::has_font(const StringName& p_name,const StringName& p_type) const { - + if (p_type==StringName()) { const Ref<Font>* font = data.font_override.getptr(p_name); if (font) @@ -952,7 +952,7 @@ bool Control::has_font(const StringName& p_name,const StringName& p_type) const } bool Control::has_color(const StringName& p_name,const StringName& p_type) const { - + if (p_type==StringName()) { const Color* color = data.color_override.getptr(p_name); if (color) @@ -1024,7 +1024,7 @@ Size2 Control::get_parent_area_size() const { } else { parent_size=get_viewport()->get_visible_rect().size; - } + } return parent_size; } @@ -1083,11 +1083,11 @@ void Control::_size_changed() { } float Control::_get_parent_range(int p_idx) const { - + if (!is_inside_tree()) { - + return 1.0; - + } if (data.parent_canvas_item) { return data.parent_canvas_item->get_item_rect().size[p_idx&1]; @@ -1100,21 +1100,21 @@ float Control::_get_parent_range(int p_idx) const { float Control::_get_range(int p_idx) const { - + p_idx&=1; float parent_range = _get_parent_range( p_idx ); float from = _a2s( data.margin[p_idx], data.anchor[p_idx], parent_range ); float to = _a2s( data.margin[p_idx+2], data.anchor[p_idx+2], parent_range ); - + return to-from; } float Control::_s2a(float p_val, AnchorType p_anchor,float p_range) const { - + switch(p_anchor) { - - case ANCHOR_BEGIN: { + + case ANCHOR_BEGIN: { return p_val; } break; case ANCHOR_END: { @@ -1122,21 +1122,21 @@ float Control::_s2a(float p_val, AnchorType p_anchor,float p_range) const { } break; case ANCHOR_RATIO: { return p_val/p_range; - } break; + } break; case ANCHOR_CENTER: { return (p_range/2)-p_val; } break; - } - + } + return 0; } float Control::_a2s(float p_val, AnchorType p_anchor,float p_range) const { - + switch(p_anchor) { - - case ANCHOR_BEGIN: { + + case ANCHOR_BEGIN: { return Math::floor(p_val); } break; case ANCHOR_END: { @@ -1144,7 +1144,7 @@ float Control::_a2s(float p_val, AnchorType p_anchor,float p_range) const { } break; case ANCHOR_RATIO: { return Math::floor(p_range*p_val); - } break; + } break; case ANCHOR_CENTER: { return Math::floor((p_range/2)-p_val); } break; @@ -1154,9 +1154,9 @@ float Control::_a2s(float p_val, AnchorType p_anchor,float p_range) const { void Control::set_anchor(Margin p_margin,AnchorType p_anchor) { - + if (!is_inside_tree()) { - + data.anchor[p_margin]=p_anchor; } else { float pr = _get_parent_range(p_margin); @@ -1175,8 +1175,8 @@ void Control::set_anchor_and_margin(Margin p_margin,AnchorType p_anchor, float p Control::AnchorType Control::get_anchor(Margin p_margin) const { - - return data.anchor[p_margin]; + + return data.anchor[p_margin]; } @@ -1204,40 +1204,40 @@ void Control::set_margin(Margin p_margin,float p_value) { } void Control::set_begin(const Size2& p_point) { - + data.margin[0]=p_point.x; data.margin[1]=p_point.y; _size_changed(); } void Control::set_end(const Size2& p_point) { - + data.margin[2]=p_point.x; data.margin[3]=p_point.y; _size_changed(); } float Control::get_margin(Margin p_margin) const { - + return data.margin[p_margin]; } Size2 Control::get_begin() const { - + return Size2( data.margin[0], data.margin[1] ); } Size2 Control::get_end() const { - + return Size2( data.margin[2], data.margin[3] ); } Point2 Control::get_global_pos() const { - + return get_global_transform().get_origin(); } void Control::set_global_pos(const Point2& p_point) { - + Matrix32 inv; if (data.parent_canvas_item) { @@ -1264,10 +1264,10 @@ void Control::set_pos(const Size2& p_point) { Size2 size = Size2(MAX( min.width, ret.width),MAX( min.height, ret.height)); float w=size.x; float h=size.y; - + x=p_point.x; y=p_point.y; - + data.margin[0] = _s2a( x, data.anchor[0], pw ); data.margin[1] = _s2a( y, data.anchor[1], ph ); data.margin[2] = _s2a( x+w, data.anchor[2], pw ); @@ -1277,26 +1277,26 @@ void Control::set_pos(const Size2& p_point) { } void Control::set_size(const Size2& p_size) { - + Size2 new_size=p_size; Size2 min=get_combined_minimum_size(); if (new_size.x<min.x) new_size.x=min.x; if (new_size.y<min.y) new_size.y=min.y; - + float pw = _get_parent_range(0); float ph = _get_parent_range(1); - + float x = _a2s( data.margin[0], data.anchor[0], pw ); float y = _a2s( data.margin[1], data.anchor[1], ph ); - + float w=new_size.width; float h=new_size.height; - + data.margin[2] = _s2a( x+w, data.anchor[2], pw ); data.margin[3] = _s2a( y+h, data.anchor[3], ph ); - + _size_changed(); } @@ -1308,13 +1308,13 @@ Size2 Control::get_pos() const { } Size2 Control::get_size() const { - + return data.size_cache; } Rect2 Control::get_global_rect() const { - - return Rect2( get_global_pos(), get_size() ); + + return Rect2( get_global_pos(), get_size() ); } Rect2 Control::get_window_rect() const { @@ -1326,7 +1326,7 @@ Rect2 Control::get_window_rect() const { Rect2 Control::get_rect() const { - + return Rect2(get_pos(),get_size()); } @@ -1336,7 +1336,7 @@ Rect2 Control::get_item_rect() const { } void Control::set_area_as_parent_rect(int p_margin) { - + data.anchor[MARGIN_LEFT]=ANCHOR_BEGIN; data.anchor[MARGIN_TOP]=ANCHOR_BEGIN; data.anchor[MARGIN_RIGHT]=ANCHOR_END; @@ -1345,7 +1345,7 @@ void Control::set_area_as_parent_rect(int p_margin) { data.margin[i]=p_margin; _size_changed(); - + } void Control::add_icon_override(const StringName& p_name, const Ref<Texture>& p_icon) { @@ -1354,7 +1354,7 @@ void Control::add_icon_override(const StringName& p_name, const Ref<Texture>& p_ data.icon_override[p_name]=p_icon; notification(NOTIFICATION_THEME_CHANGED); update(); - + } void Control::add_shader_override(const StringName &p_name, const Ref<Shader> &p_shader) { @@ -1406,7 +1406,7 @@ static Control *_next_control(Control *p_from) { if (p_from->is_set_as_toplevel()) return NULL; // can't go above - Control *parent = p_from->get_parent()?p_from->get_parent()->cast_to<Control>():NULL; + Control *parent = p_from->get_parent()?p_from->get_parent()->cast_to<Control>():NULL; if (!parent) { @@ -1432,10 +1432,10 @@ static Control *_next_control(Control *p_from) { Control *Control::find_next_valid_focus() const { Control *from = const_cast<Control*>(this); - + while(true) { - - + + // find next child Control *next_child=NULL; @@ -1494,7 +1494,7 @@ Control *Control::find_next_valid_focus() const { from = next_child; } - + return NULL; @@ -1610,7 +1610,7 @@ void Control::grab_focus() { get_viewport()->_gui_control_grab_focus(this); -} +} void Control::release_focus() { @@ -1630,7 +1630,7 @@ bool Control::is_toplevel_control() const { } void Control::show_modal(bool p_exclusive) { - + ERR_FAIL_COND(!is_inside_tree()); ERR_FAIL_COND(!data.SI); @@ -1642,7 +1642,7 @@ void Control::show_modal(bool p_exclusive) { raise(); data.modal_exclusive=p_exclusive; data.MI=get_viewport()->_gui_show_modal(this); - + } void Control::_modal_set_prev_focus_owner(ObjectID p_prev) { @@ -2135,7 +2135,7 @@ void Control::_bind_methods() { ObjectTypeDB::bind_method(_MD("set_theme","theme:Theme"),&Control::set_theme); ObjectTypeDB::bind_method(_MD("get_theme:Theme"),&Control::get_theme); - + ObjectTypeDB::bind_method(_MD("add_icon_override","name","texture:Texture"),&Control::add_icon_override); ObjectTypeDB::bind_method(_MD("add_shader_override","name","shader:Shader"),&Control::add_shader_override); ObjectTypeDB::bind_method(_MD("add_style_override","name","stylebox:StyleBox"),&Control::add_style_override); @@ -2150,7 +2150,7 @@ void Control::_bind_methods() { ObjectTypeDB::bind_method(_MD("get_constant","name","type"),&Control::get_constant,DEFVAL("")); - ObjectTypeDB::bind_method(_MD("get_parent_control:Control"),&Control::get_parent_control); + ObjectTypeDB::bind_method(_MD("get_parent_control:Control"),&Control::get_parent_control); ObjectTypeDB::bind_method(_MD("set_tooltip","tooltip"),&Control::set_tooltip); ObjectTypeDB::bind_method(_MD("get_tooltip","atpos"),&Control::get_tooltip,DEFVAL(Point2())); @@ -2214,7 +2214,7 @@ void Control::_bind_methods() { BIND_CONSTANT( ANCHOR_BEGIN ); BIND_CONSTANT( ANCHOR_END ); - BIND_CONSTANT( ANCHOR_RATIO ); + BIND_CONSTANT( ANCHOR_RATIO ); BIND_CONSTANT( ANCHOR_CENTER ); BIND_CONSTANT( FOCUS_NONE ); BIND_CONSTANT( FOCUS_CLICK ); @@ -2261,11 +2261,11 @@ void Control::_bind_methods() { ADD_SIGNAL( MethodInfo("minimum_size_changed") ); ADD_SIGNAL( MethodInfo("modal_close") ); - + } Control::Control() { - - data.parent=NULL; + + data.parent=NULL; data.ignore_mouse=false; data.stop_mouse=true; @@ -2297,7 +2297,7 @@ Control::Control() { - + } |