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
This commit is contained in:
Rémi Verschelde 2017-03-05 16:44:50 +01:00
parent 45438e9918
commit 5dbf1809c6
1318 changed files with 140051 additions and 166004 deletions

View file

@ -28,10 +28,9 @@
/*************************************************************************/
#include "link_button.h"
void LinkButton::set_text(const String &p_text) {
void LinkButton::set_text(const String& p_text) {
text=p_text;
text = p_text;
update();
minimum_size_changed();
}
@ -42,7 +41,7 @@ String LinkButton::get_text() const {
void LinkButton::set_underline_mode(UnderlineMode p_underline_mode) {
underline_mode=p_underline_mode;
underline_mode = p_underline_mode;
update();
}
@ -51,55 +50,51 @@ LinkButton::UnderlineMode LinkButton::get_underline_mode() const {
return underline_mode;
}
Size2 LinkButton::get_minimum_size() const {
return get_font("font")->get_string_size( text );
return get_font("font")->get_string_size(text);
}
void LinkButton::_notification(int p_what) {
switch( p_what ) {
switch (p_what) {
case NOTIFICATION_DRAW: {
RID ci = get_canvas_item();
Size2 size=get_size();
Size2 size = get_size();
Color color;
bool do_underline=false;
bool do_underline = false;
//print_line(get_text()+": "+itos(is_flat())+" hover "+itos(get_draw_mode()));
switch( get_draw_mode() ) {
switch (get_draw_mode()) {
case DRAW_NORMAL: {
color=get_color("font_color");
do_underline=underline_mode==UNDERLINE_MODE_ALWAYS;
color = get_color("font_color");
do_underline = underline_mode == UNDERLINE_MODE_ALWAYS;
} break;
case DRAW_PRESSED: {
if (has_color("font_color_pressed"))
color=get_color("font_color_pressed");
color = get_color("font_color_pressed");
else
color=get_color("font_color");
color = get_color("font_color");
do_underline=underline_mode!=UNDERLINE_MODE_NEVER;
do_underline = underline_mode != UNDERLINE_MODE_NEVER;
} break;
case DRAW_HOVER: {
color=get_color("font_color_hover");
do_underline=underline_mode!=UNDERLINE_MODE_NEVER;
color = get_color("font_color_hover");
do_underline = underline_mode != UNDERLINE_MODE_NEVER;
} break;
case DRAW_DISABLED: {
color=get_color("font_color_disabled");
do_underline=underline_mode==UNDERLINE_MODE_ALWAYS;
color = get_color("font_color_disabled");
do_underline = underline_mode == UNDERLINE_MODE_ALWAYS;
} break;
}
@ -107,21 +102,19 @@ void LinkButton::_notification(int p_what) {
if (has_focus()) {
Ref<StyleBox> style = get_stylebox("focus");
style->draw(ci,Rect2(Point2(),size));
style->draw(ci, Rect2(Point2(), size));
}
Ref<Font> font=get_font("font");
draw_string(font,Vector2(0,font->get_ascent()),text,color);
Ref<Font> font = get_font("font");
draw_string(font, Vector2(0, font->get_ascent()), text, color);
if (do_underline) {
int underline_spacing = get_constant("underline_spacing");
int width = font->get_string_size(text).width;
int y = font->get_ascent()+underline_spacing;
int y = font->get_ascent() + underline_spacing;
draw_line(Vector2(0,y),Vector2(width,y),color);
draw_line(Vector2(0, y), Vector2(width, y), color);
}
} break;
@ -130,24 +123,22 @@ void LinkButton::_notification(int p_what) {
void LinkButton::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_text","text"),&LinkButton::set_text);
ClassDB::bind_method(D_METHOD("get_text"),&LinkButton::get_text);
ClassDB::bind_method(D_METHOD("set_text", "text"), &LinkButton::set_text);
ClassDB::bind_method(D_METHOD("get_text"), &LinkButton::get_text);
ClassDB::bind_method(D_METHOD("set_underline_mode","underline_mode"),&LinkButton::set_underline_mode);
ClassDB::bind_method(D_METHOD("get_underline_mode"),&LinkButton::get_underline_mode);
ClassDB::bind_method(D_METHOD("set_underline_mode", "underline_mode"), &LinkButton::set_underline_mode);
ClassDB::bind_method(D_METHOD("get_underline_mode"), &LinkButton::get_underline_mode);
BIND_CONSTANT(UNDERLINE_MODE_ALWAYS);
BIND_CONSTANT(UNDERLINE_MODE_ON_HOVER);
BIND_CONSTANT(UNDERLINE_MODE_NEVER);
BIND_CONSTANT( UNDERLINE_MODE_ALWAYS );
BIND_CONSTANT( UNDERLINE_MODE_ON_HOVER );
BIND_CONSTANT( UNDERLINE_MODE_NEVER );
ADD_PROPERTYNZ(PropertyInfo(Variant::STRING,"text"), "set_text", "get_text");
ADD_PROPERTYNZ(PropertyInfo(Variant::INT,"underline",PROPERTY_HINT_ENUM,"Always,On Hover,Never"), "set_underline_mode", "get_underline_mode");
ADD_PROPERTYNZ(PropertyInfo(Variant::STRING, "text"), "set_text", "get_text");
ADD_PROPERTYNZ(PropertyInfo(Variant::INT, "underline", PROPERTY_HINT_ENUM, "Always,On Hover,Never"), "set_underline_mode", "get_underline_mode");
}
LinkButton::LinkButton() {
underline_mode=UNDERLINE_MODE_ALWAYS;
underline_mode = UNDERLINE_MODE_ALWAYS;
set_enabled_focus_mode(FOCUS_NONE);
set_default_cursor_shape(CURSOR_POINTING_HAND);
}