diff options
| author | Rémi Verschelde <rverschelde@gmail.com> | 2020-05-14 16:41:43 +0200 |
|---|---|---|
| committer | Rémi Verschelde <rverschelde@gmail.com> | 2020-05-14 21:57:34 +0200 |
| commit | 0ee0fa42e6639b6fa474b7cf6afc6b1a78142185 (patch) | |
| tree | 198d4ff7665d89307f6ca2469fa38620a9eb1672 /editor/editor_properties.cpp | |
| parent | 07bc4e2f96f8f47991339654ff4ab16acc19d44f (diff) | |
| download | redot-engine-0ee0fa42e6639b6fa474b7cf6afc6b1a78142185.tar.gz | |
Style: Enforce braces around if blocks and loops
Using clang-tidy's `readability-braces-around-statements`.
https://clang.llvm.org/extra/clang-tidy/checks/readability-braces-around-statements.html
Diffstat (limited to 'editor/editor_properties.cpp')
| -rw-r--r-- | editor/editor_properties.cpp | 130 |
1 files changed, 86 insertions, 44 deletions
diff --git a/editor/editor_properties.cpp b/editor/editor_properties.cpp index e5ca5d95e8..81c4e48974 100644 --- a/editor/editor_properties.cpp +++ b/editor/editor_properties.cpp @@ -51,8 +51,9 @@ EditorPropertyNil::EditorPropertyNil() { ///////////////////// TEXT ///////////////////////// void EditorPropertyText::_text_entered(const String &p_string) { - if (updating) + if (updating) { return; + } if (text->has_focus()) { text->release_focus(); @@ -61,8 +62,9 @@ void EditorPropertyText::_text_entered(const String &p_string) { } void EditorPropertyText::_text_changed(const String &p_string) { - if (updating) + if (updating) { return; + } if (string_name) { emit_changed(get_edited_property(), StringName(p_string), "", true); @@ -366,16 +368,18 @@ void EditorPropertyMember::_property_select() { type = Variant::Type(i); } } - if (type != Variant::NIL) + if (type != Variant::NIL) { selector->select_method_from_basic_type(type, current); + } } else if (hint == MEMBER_METHOD_OF_BASE_TYPE) { selector->select_method_from_base_type(hint_text, current); } else if (hint == MEMBER_METHOD_OF_INSTANCE) { Object *instance = ObjectDB::get_instance(ObjectID(hint_text.to_int64())); - if (instance) + if (instance) { selector->select_method_from_instance(instance, current); + } } else if (hint == MEMBER_METHOD_OF_SCRIPT) { Object *obj = ObjectDB::get_instance(ObjectID(hint_text.to_int64())); @@ -386,24 +390,27 @@ void EditorPropertyMember::_property_select() { } else if (hint == MEMBER_PROPERTY_OF_VARIANT_TYPE) { Variant::Type type = Variant::NIL; String tname = hint_text; - if (tname.find(".") != -1) + if (tname.find(".") != -1) { tname = tname.get_slice(".", 0); + } for (int i = 0; i < Variant::VARIANT_MAX; i++) { if (tname == Variant::get_type_name(Variant::Type(i))) { type = Variant::Type(Variant::Type(i)); } } - if (type != Variant::NIL) + if (type != Variant::NIL) { selector->select_property_from_basic_type(type, current); + } } else if (hint == MEMBER_PROPERTY_OF_BASE_TYPE) { selector->select_property_from_base_type(hint_text, current); } else if (hint == MEMBER_PROPERTY_OF_INSTANCE) { Object *instance = ObjectDB::get_instance(ObjectID(hint_text.to_int64())); - if (instance) + if (instance) { selector->select_property_from_instance(instance, current); + } } else if (hint == MEMBER_PROPERTY_OF_SCRIPT) { Object *obj = ObjectDB::get_instance(ObjectID(hint_text.to_int64())); @@ -479,8 +486,9 @@ void EditorPropertyEnum::setup(const Vector<String> &p_options) { int64_t current_val = 0; for (int i = 0; i < p_options.size(); i++) { Vector<String> text_split = p_options[i].split(":"); - if (text_split.size() != 1) + if (text_split.size() != 1) { current_val = text_split[1].to_int64(); + } options->add_item(text_split[0]); options->set_item_metadata(i, current_val); current_val += 1; @@ -619,14 +627,16 @@ public: Color color = get_theme_color("highlight_color", "Editor"); for (int i = 0; i < 2; i++) { Point2 ofs(4, vofs); - if (i == 1) + if (i == 1) { ofs.y += bsize + 1; + } ofs += rect.position; for (int j = 0; j < 10; j++) { Point2 o = ofs + Point2(j * (bsize + 1), 0); - if (j >= 5) + if (j >= 5) { o.x += 1; + } uint32_t idx = i * 10 + j; bool on = value & (1 << idx); @@ -756,8 +766,9 @@ EditorPropertyLayers::EditorPropertyLayers() { ///////////////////// INT ///////////////////////// void EditorPropertyInteger::_value_changed(int64_t val) { - if (setting) + if (setting) { return; + } emit_changed(get_edited_property(), val); } @@ -802,8 +813,9 @@ void EditorPropertyObjectID::_edit_pressed() { void EditorPropertyObjectID::update_property() { String type = base_type; - if (type == "") + if (type == "") { type = "Object"; + } ObjectID id = get_edited_object()->get(get_edited_property()); if (id.is_valid()) { @@ -834,8 +846,9 @@ EditorPropertyObjectID::EditorPropertyObjectID() { ///////////////////// FLOAT ///////////////////////// void EditorPropertyFloat::_value_changed(double val) { - if (setting) + if (setting) { return; + } emit_changed(get_edited_property(), val); } @@ -898,15 +911,18 @@ void EditorPropertyEasing::_drag_easing(const Ref<InputEvent> &p_ev) { if (mm.is_valid() && mm->get_button_mask() & BUTTON_MASK_LEFT) { float rel = mm->get_relative().x; - if (rel == 0) + if (rel == 0) { return; + } - if (flip) + if (flip) { rel = -rel; + } float val = get_edited_object()->get(get_edited_property()); - if (val == 0) + if (val == 0) { return; + } bool sg = val < 0; val = Math::absf(val); @@ -915,8 +931,9 @@ void EditorPropertyEasing::_drag_easing(const Ref<InputEvent> &p_ev) { val += rel * 0.05; val = Math::pow(2.0f, val); - if (sg) + if (sg) { val = -val; + } emit_changed(get_edited_property(), val); easing_draw->update(); @@ -983,8 +1000,9 @@ void EditorPropertyEasing::_setup_spin() { } void EditorPropertyEasing::_spin_value_changed(double p_value) { - if (setting) + if (setting) { return; + } // 0 is a singularity, but both positive and negative values // are otherwise allowed. Enforce 0+ as workaround. @@ -1060,8 +1078,9 @@ EditorPropertyEasing::EditorPropertyEasing() { ///////////////////// VECTOR2 ///////////////////////// void EditorPropertyVector2::_value_changed(double val, const String &p_name) { - if (setting) + if (setting) { return; + } Vector2 v2; v2.x = spin[0]->get_value(); @@ -1141,8 +1160,9 @@ EditorPropertyVector2::EditorPropertyVector2(bool p_force_wide) { ///////////////////// RECT2 ///////////////////////// void EditorPropertyRect2::_value_changed(double val, const String &p_name) { - if (setting) + if (setting) { return; + } Rect2 r2; r2.position.x = spin[0]->get_value(); @@ -1226,8 +1246,9 @@ EditorPropertyRect2::EditorPropertyRect2(bool p_force_wide) { ///////////////////// VECTOR3 ///////////////////////// void EditorPropertyVector3::_value_changed(double val, const String &p_name) { - if (setting) + if (setting) { return; + } Vector3 v3; v3.x = spin[0]->get_value(); @@ -1309,8 +1330,9 @@ EditorPropertyVector3::EditorPropertyVector3(bool p_force_wide) { ///////////////////// VECTOR2i ///////////////////////// void EditorPropertyVector2i::_value_changed(double val, const String &p_name) { - if (setting) + if (setting) { return; + } Vector2i v2; v2.x = spin[0]->get_value(); @@ -1390,8 +1412,9 @@ EditorPropertyVector2i::EditorPropertyVector2i(bool p_force_wide) { ///////////////////// RECT2 ///////////////////////// void EditorPropertyRect2i::_value_changed(double val, const String &p_name) { - if (setting) + if (setting) { return; + } Rect2i r2; r2.position.x = spin[0]->get_value(); @@ -1475,8 +1498,9 @@ EditorPropertyRect2i::EditorPropertyRect2i(bool p_force_wide) { ///////////////////// VECTOR3 ///////////////////////// void EditorPropertyVector3i::_value_changed(double val, const String &p_name) { - if (setting) + if (setting) { return; + } Vector3i v3; v3.x = spin[0]->get_value(); @@ -1557,8 +1581,9 @@ EditorPropertyVector3i::EditorPropertyVector3i(bool p_force_wide) { ///////////////////// PLANE ///////////////////////// void EditorPropertyPlane::_value_changed(double val, const String &p_name) { - if (setting) + if (setting) { return; + } Plane p; p.normal.x = spin[0]->get_value(); @@ -1642,8 +1667,9 @@ EditorPropertyPlane::EditorPropertyPlane(bool p_force_wide) { ///////////////////// QUAT ///////////////////////// void EditorPropertyQuat::_value_changed(double val, const String &p_name) { - if (setting) + if (setting) { return; + } Quat p; p.x = spin[0]->get_value(); @@ -1724,8 +1750,9 @@ EditorPropertyQuat::EditorPropertyQuat() { ///////////////////// AABB ///////////////////////// void EditorPropertyAABB::_value_changed(double val, const String &p_name) { - if (setting) + if (setting) { return; + } AABB p; p.position.x = spin[0]->get_value(); @@ -1799,8 +1826,9 @@ EditorPropertyAABB::EditorPropertyAABB() { ///////////////////// TRANSFORM2D ///////////////////////// void EditorPropertyTransform2D::_value_changed(double val, const String &p_name) { - if (setting) + if (setting) { return; + } Transform2D p; p[0][0] = spin[0]->get_value(); @@ -1873,8 +1901,9 @@ EditorPropertyTransform2D::EditorPropertyTransform2D() { ///////////////////// BASIS ///////////////////////// void EditorPropertyBasis::_value_changed(double val, const String &p_name) { - if (setting) + if (setting) { return; + } Basis p; p[0][0] = spin[0]->get_value(); @@ -1953,8 +1982,9 @@ EditorPropertyBasis::EditorPropertyBasis() { ///////////////////// TRANSFORM ///////////////////////// void EditorPropertyTransform::_value_changed(double val, const String &p_name) { - if (setting) + if (setting) { return; + } Transform p; p.basis[0][0] = spin[0]->get_value(); @@ -2049,10 +2079,11 @@ void EditorPropertyColor::_popup_closed() { void EditorPropertyColor::_picker_created() { // get default color picker mode from editor settings int default_color_mode = EDITOR_GET("interface/inspector/default_color_picker_mode"); - if (default_color_mode == 1) + if (default_color_mode == 1) { picker->get_picker()->set_hsv_mode(true); - else if (default_color_mode == 2) + } else if (default_color_mode == 2) { picker->get_picker()->set_raw_mode(true); + } } void EditorPropertyColor::_bind_methods() { @@ -2263,8 +2294,9 @@ void EditorPropertyResource::_file_selected(const String &p_path) { } } - if (!any_type_matches) + if (!any_type_matches) { EditorNode::get_singleton()->show_warning(vformat(TTR("The selected resource (%s) does not match any type expected for this property (%s)."), res->get_class(), property_types)); + } } emit_changed(get_edited_property(), res); @@ -2316,8 +2348,9 @@ void EditorPropertyResource::_menu_option(int p_which) { case OBJ_MENU_MAKE_UNIQUE: { RES res_orig = get_edited_object()->get(get_edited_property()); - if (res_orig.is_null()) + if (res_orig.is_null()) { return; + } List<PropertyInfo> property_list; res_orig->get_property_list(&property_list); @@ -2354,8 +2387,9 @@ void EditorPropertyResource::_menu_option(int p_which) { case OBJ_MENU_SAVE: { RES res = get_edited_object()->get(get_edited_property()); - if (res.is_null()) + if (res.is_null()) { return; + } EditorNode::get_singleton()->save_resource(res); } break; @@ -2556,20 +2590,23 @@ void EditorPropertyResource::_update_menu_items() { for (int j = 0; j < custom_resources.size(); j++) { if (custom_resources[j].name == t) { is_custom_resource = true; - if (custom_resources[j].icon.is_valid()) + if (custom_resources[j].icon.is_valid()) { icon = custom_resources[j].icon; + } break; } } } - if (!is_custom_resource && !(ScriptServer::is_global_class(t) || ClassDB::can_instance(t))) + if (!is_custom_resource && !(ScriptServer::is_global_class(t) || ClassDB::can_instance(t))) { continue; + } inheritors_array.push_back(t); - if (!icon.is_valid()) + if (!icon.is_valid()) { icon = get_theme_icon(has_theme_icon(t, "EditorIcons") ? t : "Object", "EditorIcons"); + } int id = TYPE_BASE_ID + idx; menu->add_icon_item(icon, vformat(TTR("New %s"), t), id); @@ -2578,8 +2615,9 @@ void EditorPropertyResource::_update_menu_items() { } } - if (menu->get_item_count()) + if (menu->get_item_count()) { menu->add_separator(); + } } menu->add_icon_item(get_theme_icon("Load", "EditorIcons"), TTR("Load"), OBJ_MENU_LOAD); @@ -2599,14 +2637,16 @@ void EditorPropertyResource::_update_menu_items() { RES cb = EditorSettings::get_singleton()->get_resource_clipboard(); bool paste_valid = false; if (cb.is_valid()) { - if (base_type == "") + if (base_type == "") { paste_valid = true; - else - for (int i = 0; i < base_type.get_slice_count(","); i++) + } else { + for (int i = 0; i < base_type.get_slice_count(","); i++) { if (ClassDB::is_parent_class(cb->get_class(), base_type.get_slice(",", i))) { paste_valid = true; break; } + } + } } if (!res.is_null() || paste_valid) { @@ -2691,8 +2731,9 @@ void EditorPropertyResource::_fold_other_editors(Object *p_self) { RES res = get_edited_object()->get(get_edited_property()); - if (!res.is_valid()) + if (!res.is_valid()) { return; + } bool use_editor = false; for (int i = 0; i < EditorNode::get_editor_data().get_editor_plugin_count(); i++) { EditorPlugin *ep = EditorNode::get_editor_data().get_editor_plugin(i); @@ -2701,8 +2742,9 @@ void EditorPropertyResource::_fold_other_editors(Object *p_self) { } } - if (!use_editor) + if (!use_editor) { return; + } bool unfolded = get_edited_object()->editor_is_section_unfolded(get_edited_property()); opened_editor = false; |
