diff options
| author | Rémi Verschelde | 2017-03-05 16:44:50 +0100 |
|---|---|---|
| committer | Rémi Verschelde | 2017-03-05 16:44:50 +0100 |
| commit | 5dbf1809c6e3e905b94b8764e99491e608122261 (patch) | |
| tree | 5e5a5360db15d86d59ec8c6e4f7eb511388c5a9a /scene/gui/viewport_container.cpp | |
| parent | 45438e9918d421b244bfd7776a30e67dc7f2d3e3 (diff) | |
| download | godot-5dbf180.tar.gz godot-5dbf180.tar.zst godot-5dbf180.zip | |
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/viewport_container.cpp')
| -rw-r--r-- | scene/gui/viewport_container.cpp | 41 |
1 files changed, 16 insertions, 25 deletions
diff --git a/scene/gui/viewport_container.cpp b/scene/gui/viewport_container.cpp index adc4a14a6..93789d945 100644 --- a/scene/gui/viewport_container.cpp +++ b/scene/gui/viewport_container.cpp @@ -35,28 +35,25 @@ Size2 ViewportContainer::get_minimum_size() const { if (stretch) return Size2(); Size2 ms; - for(int i=0;i<get_child_count();i++) { + for (int i = 0; i < get_child_count(); i++) { Viewport *c = get_child(i)->cast_to<Viewport>(); if (!c) continue; Size2 minsize = c->get_size(); - ms.width = MAX(ms.width , minsize.width); - ms.height = MAX(ms.height , minsize.height); + ms.width = MAX(ms.width, minsize.width); + ms.height = MAX(ms.height, minsize.height); } return ms; - } - void ViewportContainer::set_stretch(bool p_enable) { - stretch=p_enable; + stretch = p_enable; queue_sort(); update(); - } bool ViewportContainer::is_stretch_enabled() const { @@ -64,16 +61,14 @@ bool ViewportContainer::is_stretch_enabled() const { return stretch; } - void ViewportContainer::_notification(int p_what) { - - if (p_what==NOTIFICATION_RESIZED) { + if (p_what == NOTIFICATION_RESIZED) { if (!stretch) return; - for(int i=0;i<get_child_count();i++) { + for (int i = 0; i < get_child_count(); i++) { Viewport *c = get_child(i)->cast_to<Viewport>(); if (!c) @@ -83,50 +78,46 @@ void ViewportContainer::_notification(int p_what) { } } - if (p_what==NOTIFICATION_ENTER_TREE || p_what==NOTIFICATION_VISIBILITY_CHANGED) { + if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_VISIBILITY_CHANGED) { - for(int i=0;i<get_child_count();i++) { + for (int i = 0; i < get_child_count(); i++) { Viewport *c = get_child(i)->cast_to<Viewport>(); if (!c) continue; - if (is_visible_in_tree()) c->set_update_mode(Viewport::UPDATE_ALWAYS); else c->set_update_mode(Viewport::UPDATE_DISABLED); } - } - if (p_what==NOTIFICATION_DRAW) { - - for(int i=0;i<get_child_count();i++) { + if (p_what == NOTIFICATION_DRAW) { + for (int i = 0; i < get_child_count(); i++) { Viewport *c = get_child(i)->cast_to<Viewport>(); if (!c) continue; if (stretch) - draw_texture_rect(c->get_texture(),Rect2(Vector2(),get_size()*Size2(1,-1))); + draw_texture_rect(c->get_texture(), Rect2(Vector2(), get_size() * Size2(1, -1))); else - draw_texture_rect(c->get_texture(),Rect2(Vector2(),c->get_size()*Size2(1,-1))); + draw_texture_rect(c->get_texture(), Rect2(Vector2(), c->get_size() * Size2(1, -1))); } } - } void ViewportContainer::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_stretch","enable"),&ViewportContainer::set_stretch); - ClassDB::bind_method(D_METHOD("is_stretch_enabled"),&ViewportContainer::is_stretch_enabled); + ClassDB::bind_method(D_METHOD("set_stretch", "enable"), &ViewportContainer::set_stretch); + ClassDB::bind_method(D_METHOD("is_stretch_enabled"), &ViewportContainer::is_stretch_enabled); - ADD_PROPERTY( PropertyInfo(Variant::BOOL,"stretch"),"set_stretch","is_stretch_enabled"); + ADD_PROPERTY(PropertyInfo(Variant::BOOL, "stretch"), "set_stretch", "is_stretch_enabled"); } ViewportContainer::ViewportContainer() { - stretch=false; + stretch = false; } |
