You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-07 12:30:27 +00:00
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:
@@ -28,76 +28,68 @@
|
||||
/*************************************************************************/
|
||||
#include "texture_editor_plugin.h"
|
||||
|
||||
#include "io/resource_loader.h"
|
||||
#include "global_config.h"
|
||||
#include "editor/editor_settings.h"
|
||||
#include "global_config.h"
|
||||
#include "io/resource_loader.h"
|
||||
|
||||
void TextureEditor::_gui_input(InputEvent p_event) {
|
||||
|
||||
|
||||
}
|
||||
|
||||
void TextureEditor::_notification(int p_what) {
|
||||
|
||||
if (p_what==NOTIFICATION_FIXED_PROCESS) {
|
||||
|
||||
if (p_what == NOTIFICATION_FIXED_PROCESS) {
|
||||
}
|
||||
|
||||
|
||||
if (p_what==NOTIFICATION_READY) {
|
||||
if (p_what == NOTIFICATION_READY) {
|
||||
|
||||
//get_scene()->connect("node_removed",this,"_node_removed");
|
||||
|
||||
}
|
||||
|
||||
if (p_what==NOTIFICATION_DRAW) {
|
||||
if (p_what == NOTIFICATION_DRAW) {
|
||||
|
||||
|
||||
Ref<Texture> checkerboard = get_icon("Checkerboard","EditorIcons");
|
||||
Ref<Texture> checkerboard = get_icon("Checkerboard", "EditorIcons");
|
||||
Size2 size = get_size();
|
||||
|
||||
draw_texture_rect(checkerboard,Rect2(Point2(),size),true);
|
||||
draw_texture_rect(checkerboard, Rect2(Point2(), size), true);
|
||||
|
||||
int tex_width = texture->get_width() * size.height / texture ->get_height();
|
||||
int tex_width = texture->get_width() * size.height / texture->get_height();
|
||||
int tex_height = size.height;
|
||||
|
||||
if (tex_width>size.width) {
|
||||
tex_width=size.width;
|
||||
tex_height=texture->get_height() * tex_width / texture->get_width();
|
||||
if (tex_width > size.width) {
|
||||
tex_width = size.width;
|
||||
tex_height = texture->get_height() * tex_width / texture->get_width();
|
||||
}
|
||||
|
||||
int ofs_x = (size.width - tex_width)/2;
|
||||
int ofs_y = (size.height - tex_height)/2;
|
||||
int ofs_x = (size.width - tex_width) / 2;
|
||||
int ofs_y = (size.height - tex_height) / 2;
|
||||
|
||||
draw_texture_rect(texture,Rect2(ofs_x,ofs_y,tex_width,tex_height));
|
||||
draw_texture_rect(texture, Rect2(ofs_x, ofs_y, tex_width, tex_height));
|
||||
|
||||
Ref<Font> font = get_font("font","Label");
|
||||
Ref<Font> font = get_font("font", "Label");
|
||||
|
||||
String format;
|
||||
if (texture->cast_to<ImageTexture>()) {
|
||||
format = Image::get_format_name(texture->cast_to<ImageTexture>()->get_format());
|
||||
} else {
|
||||
format=texture->get_class();
|
||||
format = texture->get_class();
|
||||
}
|
||||
String text = itos(texture->get_width())+"x"+itos(texture->get_height())+" "+format;
|
||||
String text = itos(texture->get_width()) + "x" + itos(texture->get_height()) + " " + format;
|
||||
|
||||
Size2 rect = font->get_string_size(text);
|
||||
|
||||
Vector2 draw_from = size-rect+Size2(-2,font->get_ascent()-2);
|
||||
if (draw_from.x<0)
|
||||
draw_from.x=0;
|
||||
Vector2 draw_from = size - rect + Size2(-2, font->get_ascent() - 2);
|
||||
if (draw_from.x < 0)
|
||||
draw_from.x = 0;
|
||||
|
||||
draw_string(font,draw_from+Vector2(2,2),text,Color(0,0,0,0.5),size.width);
|
||||
draw_string(font,draw_from-Vector2(2,2),text,Color(0,0,0,0.5),size.width);
|
||||
draw_string(font,draw_from,text,Color(1,1,1,1),size.width);
|
||||
draw_string(font, draw_from + Vector2(2, 2), text, Color(0, 0, 0, 0.5), size.width);
|
||||
draw_string(font, draw_from - Vector2(2, 2), text, Color(0, 0, 0, 0.5), size.width);
|
||||
draw_string(font, draw_from, text, Color(1, 1, 1, 1), size.width);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void TextureEditor::edit(Ref<Texture> p_texture) {
|
||||
|
||||
texture=p_texture;
|
||||
texture = p_texture;
|
||||
|
||||
if (!texture.is_null())
|
||||
update();
|
||||
@@ -105,27 +97,21 @@ void TextureEditor::edit(Ref<Texture> p_texture) {
|
||||
|
||||
hide();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
void TextureEditor::_bind_methods() {
|
||||
|
||||
ClassDB::bind_method(D_METHOD("_gui_input"),&TextureEditor::_gui_input);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("_gui_input"), &TextureEditor::_gui_input);
|
||||
}
|
||||
|
||||
TextureEditor::TextureEditor() {
|
||||
|
||||
set_custom_minimum_size(Size2(1,150));
|
||||
|
||||
set_custom_minimum_size(Size2(1, 150));
|
||||
}
|
||||
|
||||
|
||||
void TextureEditorPlugin::edit(Object *p_object) {
|
||||
|
||||
Texture * s = p_object->cast_to<Texture>();
|
||||
Texture *s = p_object->cast_to<Texture>();
|
||||
if (!s)
|
||||
return;
|
||||
|
||||
@@ -147,23 +133,15 @@ void TextureEditorPlugin::make_visible(bool p_visible) {
|
||||
texture_editor->hide();
|
||||
//texture_editor->set_process(false);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
TextureEditorPlugin::TextureEditorPlugin(EditorNode *p_node) {
|
||||
|
||||
editor=p_node;
|
||||
texture_editor = memnew( TextureEditor );
|
||||
add_control_to_container(CONTAINER_PROPERTY_EDITOR_BOTTOM,texture_editor);
|
||||
editor = p_node;
|
||||
texture_editor = memnew(TextureEditor);
|
||||
add_control_to_container(CONTAINER_PROPERTY_EDITOR_BOTTOM, texture_editor);
|
||||
texture_editor->hide();
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
TextureEditorPlugin::~TextureEditorPlugin()
|
||||
{
|
||||
TextureEditorPlugin::~TextureEditorPlugin() {
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user