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:
@ -29,19 +29,19 @@
|
||||
#ifndef PROPERTY_EDITOR_H
|
||||
#define PROPERTY_EDITOR_H
|
||||
|
||||
#include "scene/gui/tree.h"
|
||||
#include "editor/editor_file_dialog.h"
|
||||
#include "scene/gui/button.h"
|
||||
#include "scene/gui/check_box.h"
|
||||
#include "scene/gui/label.h"
|
||||
#include "editor/editor_file_dialog.h"
|
||||
#include "scene/gui/dialogs.h"
|
||||
#include "scene/gui/color_picker.h"
|
||||
#include "scene/gui/menu_button.h"
|
||||
#include "scene/gui/texture_rect.h"
|
||||
#include "scene/gui/text_edit.h"
|
||||
#include "scene/gui/check_button.h"
|
||||
#include "scene/gui/split_container.h"
|
||||
#include "scene/gui/color_picker.h"
|
||||
#include "scene/gui/dialogs.h"
|
||||
#include "scene/gui/grid_container.h"
|
||||
#include "scene/gui/label.h"
|
||||
#include "scene/gui/menu_button.h"
|
||||
#include "scene/gui/split_container.h"
|
||||
#include "scene/gui/text_edit.h"
|
||||
#include "scene/gui/texture_rect.h"
|
||||
#include "scene/gui/tree.h"
|
||||
#include "scene_tree_editor.h"
|
||||
|
||||
/**
|
||||
@ -54,21 +54,21 @@ class PropertySelector;
|
||||
|
||||
class CustomPropertyEditor : public Popup {
|
||||
|
||||
GDCLASS( CustomPropertyEditor, Popup );
|
||||
GDCLASS(CustomPropertyEditor, Popup);
|
||||
|
||||
enum {
|
||||
MAX_VALUE_EDITORS=12,
|
||||
MAX_ACTION_BUTTONS=5,
|
||||
OBJ_MENU_LOAD=0,
|
||||
OBJ_MENU_EDIT=1,
|
||||
OBJ_MENU_CLEAR=2,
|
||||
OBJ_MENU_MAKE_UNIQUE=3,
|
||||
OBJ_MENU_COPY=4,
|
||||
OBJ_MENU_PASTE=5,
|
||||
OBJ_MENU_REIMPORT=6,
|
||||
OBJ_MENU_NEW_SCRIPT=7,
|
||||
OBJ_MENU_SHOW_IN_FILE_SYSTEM=8,
|
||||
TYPE_BASE_ID=100
|
||||
MAX_VALUE_EDITORS = 12,
|
||||
MAX_ACTION_BUTTONS = 5,
|
||||
OBJ_MENU_LOAD = 0,
|
||||
OBJ_MENU_EDIT = 1,
|
||||
OBJ_MENU_CLEAR = 2,
|
||||
OBJ_MENU_MAKE_UNIQUE = 3,
|
||||
OBJ_MENU_COPY = 4,
|
||||
OBJ_MENU_PASTE = 5,
|
||||
OBJ_MENU_REIMPORT = 6,
|
||||
OBJ_MENU_NEW_SCRIPT = 7,
|
||||
OBJ_MENU_SHOW_IN_FILE_SYSTEM = 8,
|
||||
TYPE_BASE_ID = 100
|
||||
};
|
||||
|
||||
enum {
|
||||
@ -80,7 +80,6 @@ class CustomPropertyEditor : public Popup {
|
||||
EASING_OUT_IN
|
||||
};
|
||||
|
||||
|
||||
PopupMenu *menu;
|
||||
SceneTreeDialog *scene_tree;
|
||||
EditorFileDialog *file;
|
||||
@ -108,12 +107,11 @@ class CustomPropertyEditor : public Popup {
|
||||
SpinBox *spinbox;
|
||||
HSlider *slider;
|
||||
|
||||
|
||||
Control *easing_draw;
|
||||
CreateDialog *create_dialog;
|
||||
PropertySelector *property_select;
|
||||
|
||||
Object* owner;
|
||||
Object *owner;
|
||||
|
||||
bool updating;
|
||||
|
||||
@ -131,46 +129,41 @@ class CustomPropertyEditor : public Popup {
|
||||
void _create_dialog_callback();
|
||||
void _create_selected_property(const String &p_prop);
|
||||
|
||||
|
||||
void _color_changed(const Color& p_color);
|
||||
void _color_changed(const Color &p_color);
|
||||
void _draw_easing();
|
||||
void _menu_option(int p_which);
|
||||
|
||||
void _drag_easing(const InputEvent& p_ev);
|
||||
void _drag_easing(const InputEvent &p_ev);
|
||||
|
||||
void _node_path_selected(NodePath p_path);
|
||||
void show_value_editors(int p_amount);
|
||||
void config_value_editors(int p_amount, int p_columns,int p_label_w,const List<String>& p_strings);
|
||||
void config_action_buttons(const List<String>& p_strings);
|
||||
void config_value_editors(int p_amount, int p_columns, int p_label_w, const List<String> &p_strings);
|
||||
void config_action_buttons(const List<String> &p_strings);
|
||||
|
||||
void _emit_changed_whole_or_field();
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
void _notification(int p_what);
|
||||
static void _bind_methods();
|
||||
|
||||
public:
|
||||
|
||||
|
||||
void hide_menu();
|
||||
|
||||
Variant get_variant() const;
|
||||
String get_name() const;
|
||||
|
||||
void set_read_only(bool p_read_only) { read_only=p_read_only; }
|
||||
void set_read_only(bool p_read_only) { read_only = p_read_only; }
|
||||
|
||||
void set_value_evaluator( PropertyValueEvaluator *p_evaluator) { evaluator=p_evaluator; }
|
||||
void set_value_evaluator(PropertyValueEvaluator *p_evaluator) { evaluator = p_evaluator; }
|
||||
|
||||
bool edit(Object* p_owner,const String& p_name,Variant::Type p_type, const Variant& p_variant,int p_hint,String p_hint_text);
|
||||
bool edit(Object *p_owner, const String &p_name, Variant::Type p_type, const Variant &p_variant, int p_hint, String p_hint_text);
|
||||
|
||||
CustomPropertyEditor();
|
||||
};
|
||||
|
||||
class PropertyEditor : public Control {
|
||||
|
||||
GDCLASS( PropertyEditor, Control );
|
||||
GDCLASS(PropertyEditor, Control);
|
||||
|
||||
Tree *tree;
|
||||
Label *top_label;
|
||||
@ -179,8 +172,7 @@ class PropertyEditor : public Control {
|
||||
|
||||
PropertyValueEvaluator *evaluator;
|
||||
|
||||
Object* obj;
|
||||
|
||||
Object *obj;
|
||||
|
||||
StringName _prop_edited;
|
||||
|
||||
@ -198,91 +190,93 @@ class PropertyEditor : public Control {
|
||||
bool subsection_selectable;
|
||||
bool hide_script;
|
||||
|
||||
HashMap<String,String> pending;
|
||||
HashMap<String, String> pending;
|
||||
String selected_property;
|
||||
|
||||
Map<StringName,Map<StringName,String> > descr_cache;
|
||||
Map<StringName,String > class_descr_cache;
|
||||
Map<StringName, Map<StringName, String> > descr_cache;
|
||||
Map<StringName, String> class_descr_cache;
|
||||
|
||||
CustomPropertyEditor *custom_editor;
|
||||
|
||||
void _resource_edit_request();
|
||||
void _custom_editor_edited();
|
||||
void _custom_editor_edited_field(const String& p_field_name);
|
||||
void _custom_editor_edited_field(const String &p_field_name);
|
||||
void _custom_editor_request(bool p_arrow);
|
||||
|
||||
void _item_selected();
|
||||
void _item_edited();
|
||||
TreeItem *get_parent_node(String p_path,HashMap<String,TreeItem*>& item_paths,TreeItem *root);
|
||||
TreeItem *get_parent_node(String p_path, HashMap<String, TreeItem *> &item_paths, TreeItem *root);
|
||||
|
||||
void set_item_text(TreeItem *p_item, int p_type, const String& p_name, int p_hint=PROPERTY_HINT_NONE, const String& p_hint_text="");
|
||||
void set_item_text(TreeItem *p_item, int p_type, const String &p_name, int p_hint = PROPERTY_HINT_NONE, const String &p_hint_text = "");
|
||||
|
||||
TreeItem *find_item(TreeItem *p_item,const String& p_name);
|
||||
TreeItem *find_item(TreeItem *p_item, const String &p_name);
|
||||
|
||||
virtual void _changed_callback(Object *p_changed, const char *p_what);
|
||||
virtual void _changed_callbacks(Object *p_changed, const String &p_callback);
|
||||
|
||||
virtual void _changed_callback(Object *p_changed,const char * p_what);
|
||||
virtual void _changed_callbacks(Object *p_changed,const String& p_callback);
|
||||
|
||||
void _check_reload_status(const String&p_name,TreeItem* item);
|
||||
void _check_reload_status(const String &p_name, TreeItem *item);
|
||||
|
||||
void _edit_button(Object *p_item, int p_column, int p_button);
|
||||
|
||||
void _node_removed(Node *p_node);
|
||||
|
||||
friend class ProjectExportDialog;
|
||||
void _edit_set(const String& p_name, const Variant& p_value,bool p_refresh_all=false, const String& p_changed_field="");
|
||||
void _draw_flags(Object *ti,const Rect2& p_rect);
|
||||
friend class ProjectExportDialog;
|
||||
void _edit_set(const String &p_name, const Variant &p_value, bool p_refresh_all = false, const String &p_changed_field = "");
|
||||
void _draw_flags(Object *ti, const Rect2 &p_rect);
|
||||
|
||||
bool _might_be_in_instance();
|
||||
bool _get_instanced_node_original_property(const StringName& p_prop,Variant& value);
|
||||
bool _is_property_different(const Variant& p_current, const Variant& p_orig,int p_usage=0);
|
||||
bool _get_instanced_node_original_property(const StringName &p_prop, Variant &value);
|
||||
bool _is_property_different(const Variant &p_current, const Variant &p_orig, int p_usage = 0);
|
||||
|
||||
void _refresh_item(TreeItem *p_item);
|
||||
void _set_range_def(Object *p_item, String prop, float p_frame);
|
||||
|
||||
void _filter_changed(const String& p_text);
|
||||
void _filter_changed(const String &p_text);
|
||||
|
||||
void _mark_drop_fields(TreeItem* p_at);
|
||||
void _clear_drop_fields(TreeItem* p_at);
|
||||
void _mark_drop_fields(TreeItem *p_at);
|
||||
void _clear_drop_fields(TreeItem *p_at);
|
||||
|
||||
bool _is_drop_valid(const Dictionary& p_drag_data, const Dictionary& p_item_data) const;
|
||||
Variant get_drag_data_fw(const Point2& p_point,Control* p_from);
|
||||
bool can_drop_data_fw(const Point2& p_point,const Variant& p_data,Control* p_from) const;
|
||||
void drop_data_fw(const Point2& p_point,const Variant& p_data,Control* p_from);
|
||||
bool _is_drop_valid(const Dictionary &p_drag_data, const Dictionary &p_item_data) const;
|
||||
Variant get_drag_data_fw(const Point2 &p_point, Control *p_from);
|
||||
bool can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const;
|
||||
void drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from);
|
||||
|
||||
void _resource_preview_done(const String& p_path,const Ref<Texture>& p_preview,Variant p_ud);
|
||||
void _draw_transparency(Object *t, const Rect2& p_rect);
|
||||
void _resource_preview_done(const String &p_path, const Ref<Texture> &p_preview, Variant p_ud);
|
||||
void _draw_transparency(Object *t, const Rect2 &p_rect);
|
||||
|
||||
UndoRedo *undo_redo;
|
||||
protected:
|
||||
|
||||
protected:
|
||||
void _notification(int p_what);
|
||||
static void _bind_methods();
|
||||
public:
|
||||
|
||||
void set_undo_redo(UndoRedo *p_undo_redo) { undo_redo=p_undo_redo; }
|
||||
public:
|
||||
void set_undo_redo(UndoRedo *p_undo_redo) { undo_redo = p_undo_redo; }
|
||||
|
||||
String get_selected_path() const;
|
||||
|
||||
Tree *get_scene_tree();
|
||||
Label* get_top_label();
|
||||
Label *get_top_label();
|
||||
void hide_top_label();
|
||||
void update_tree();
|
||||
void update_property(const String& p_prop);
|
||||
void update_property(const String &p_prop);
|
||||
|
||||
void refresh();
|
||||
|
||||
void edit(Object* p_object);
|
||||
void edit(Object *p_object);
|
||||
|
||||
void set_keying(bool p_active);
|
||||
void set_read_only(bool p_read_only) { read_only=p_read_only; custom_editor->set_read_only(p_read_only);}
|
||||
void set_read_only(bool p_read_only) {
|
||||
read_only = p_read_only;
|
||||
custom_editor->set_read_only(p_read_only);
|
||||
}
|
||||
|
||||
void set_capitalize_paths(bool p_capitalize);
|
||||
void set_autoclear(bool p_enable);
|
||||
|
||||
void set_show_categories(bool p_show);
|
||||
void set_use_doc_hints(bool p_enable) { use_doc_hints=p_enable; }
|
||||
void set_hide_script(bool p_hide) { hide_script=p_hide; }
|
||||
void set_use_doc_hints(bool p_enable) { use_doc_hints = p_enable; }
|
||||
void set_hide_script(bool p_hide) { hide_script = p_hide; }
|
||||
|
||||
void set_use_filter(bool p_use);
|
||||
void register_text_enter(Node *p_line_edit);
|
||||
@ -291,36 +285,31 @@ public:
|
||||
|
||||
PropertyEditor();
|
||||
~PropertyEditor();
|
||||
|
||||
};
|
||||
|
||||
|
||||
class SectionedPropertyEditorFilter;
|
||||
|
||||
class SectionedPropertyEditor : public HBoxContainer {
|
||||
|
||||
|
||||
GDCLASS(SectionedPropertyEditor,HBoxContainer);
|
||||
GDCLASS(SectionedPropertyEditor, HBoxContainer);
|
||||
|
||||
ObjectID obj;
|
||||
|
||||
Tree *sections;
|
||||
SectionedPropertyEditorFilter *filter;
|
||||
|
||||
Map<String,TreeItem*> section_map;
|
||||
Map<String, TreeItem *> section_map;
|
||||
PropertyEditor *editor;
|
||||
|
||||
|
||||
static void _bind_methods();
|
||||
void _section_selected();
|
||||
|
||||
public:
|
||||
|
||||
PropertyEditor *get_property_editor();
|
||||
void edit(Object* p_object);
|
||||
String get_full_item_path(const String& p_item);
|
||||
void edit(Object *p_object);
|
||||
String get_full_item_path(const String &p_item);
|
||||
|
||||
void set_current_section(const String& p_section);
|
||||
void set_current_section(const String &p_section);
|
||||
String get_current_section() const;
|
||||
|
||||
void update_category_list();
|
||||
@ -330,20 +319,19 @@ public:
|
||||
};
|
||||
|
||||
class PropertyValueEvaluator : public ValueEvaluator {
|
||||
GDCLASS( PropertyValueEvaluator, ValueEvaluator );
|
||||
GDCLASS(PropertyValueEvaluator, ValueEvaluator);
|
||||
|
||||
Object *obj;
|
||||
ScriptLanguage *script_language;
|
||||
String _build_script(const String& p_text);
|
||||
String _build_script(const String &p_text);
|
||||
|
||||
_FORCE_INLINE_ double _default_eval(const String& p_text) {
|
||||
_FORCE_INLINE_ double _default_eval(const String &p_text) {
|
||||
return p_text.to_double();
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
void edit(Object *p_obj);
|
||||
double eval(const String& p_text);
|
||||
double eval(const String &p_text);
|
||||
|
||||
PropertyValueEvaluator();
|
||||
~PropertyValueEvaluator();
|
||||
|
||||
Reference in New Issue
Block a user