diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2017-03-05 16:44:50 +0100 |
---|---|---|
committer | Rémi Verschelde <rverschelde@gmail.com> | 2017-03-05 16:44:50 +0100 |
commit | 5dbf1809c6e3e905b94b8764e99491e608122261 (patch) | |
tree | 5e5a5360db15d86d59ec8c6e4f7eb511388c5a9a /scene/gui/progress_bar.cpp | |
parent | 45438e9918d421b244bfd7776a30e67dc7f2d3e3 (diff) | |
download | redot-engine-5dbf1809c6e3e905b94b8764e99491e608122261.tar.gz |
A Whole New World (clang-format edition)
I can show you the code
Pretty, with proper whitespace
Tell me, coder, now when did
You last write readable code?
I can open your eyes
Make you see your bad indent
Force you to respect the style
The core devs agreed upon
A whole new world
A new fantastic code format
A de facto standard
With some sugar
Enforced with clang-format
A whole new world
A dazzling style we all dreamed of
And when we read it through
It's crystal clear
That now we're in a whole new world of code
Diffstat (limited to 'scene/gui/progress_bar.cpp')
-rw-r--r-- | scene/gui/progress_bar.cpp | 38 |
1 files changed, 17 insertions, 21 deletions
diff --git a/scene/gui/progress_bar.cpp b/scene/gui/progress_bar.cpp index 61776d3ae6..86dea6cd96 100644 --- a/scene/gui/progress_bar.cpp +++ b/scene/gui/progress_bar.cpp @@ -28,68 +28,64 @@ /*************************************************************************/ #include "progress_bar.h" - Size2 ProgressBar::get_minimum_size() const { Ref<StyleBox> bg = get_stylebox("bg"); Ref<Font> font = get_font("font"); - Size2 ms=bg->get_minimum_size()+bg->get_center_size(); + Size2 ms = bg->get_minimum_size() + bg->get_center_size(); if (percent_visible) { - ms.height=MAX(ms.height,bg->get_minimum_size().height+font->get_height()); + ms.height = MAX(ms.height, bg->get_minimum_size().height + font->get_height()); } return ms; } - void ProgressBar::_notification(int p_what) { - - if (p_what==NOTIFICATION_DRAW) { + if (p_what == NOTIFICATION_DRAW) { Ref<StyleBox> bg = get_stylebox("bg"); Ref<StyleBox> fg = get_stylebox("fg"); Ref<Font> font = get_font("font"); - Color font_color=get_color("font_color"); + Color font_color = get_color("font_color"); - draw_style_box(bg,Rect2(Point2(),get_size())); + draw_style_box(bg, Rect2(Point2(), get_size())); float r = get_as_ratio(); int mp = fg->get_minimum_size().width; - int p = r*get_size().width-mp; - if (p>0) { + int p = r * get_size().width - mp; + if (p > 0) { - draw_style_box(fg,Rect2(Point2(),Size2(p+fg->get_minimum_size().width,get_size().height))); + draw_style_box(fg, Rect2(Point2(), Size2(p + fg->get_minimum_size().width, get_size().height))); } if (percent_visible) { - 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); + 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); } } } - void ProgressBar::set_percent_visible(bool p_visible) { - percent_visible=p_visible; + percent_visible = p_visible; update(); } -bool ProgressBar::is_percent_visible() const{ +bool ProgressBar::is_percent_visible() const { return percent_visible; } void ProgressBar::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_percent_visible","visible"),&ProgressBar::set_percent_visible); - ClassDB::bind_method(D_METHOD("is_percent_visible"),&ProgressBar::is_percent_visible); - ADD_GROUP("Percent","percent_"); - ADD_PROPERTY(PropertyInfo(Variant::BOOL,"percent_visible"),"set_percent_visible","is_percent_visible"); + ClassDB::bind_method(D_METHOD("set_percent_visible", "visible"), &ProgressBar::set_percent_visible); + ClassDB::bind_method(D_METHOD("is_percent_visible"), &ProgressBar::is_percent_visible); + ADD_GROUP("Percent", "percent_"); + ADD_PROPERTY(PropertyInfo(Variant::BOOL, "percent_visible"), "set_percent_visible", "is_percent_visible"); } ProgressBar::ProgressBar() { set_v_size_flags(0); - percent_visible=true; + percent_visible = true; } |