simplify alignment preset, fixing icon for full rect

This commit is contained in:
Nathan Franke 2022-07-20 05:15:23 -05:00
parent 351197bfe4
commit f3d43a384d
No known key found for this signature in database
GPG key ID: 082B90CF10A5B648
2 changed files with 9 additions and 15 deletions

View file

@ -173,7 +173,7 @@ void EditorPropertyAnchorsPreset::setup(const Vector<String> &p_options) {
Vector<String> split_after; Vector<String> split_after;
split_after.append("Custom"); split_after.append("Custom");
split_after.append("PresetWide"); split_after.append("PresetFullRect");
split_after.append("PresetBottomLeft"); split_after.append("PresetBottomLeft");
split_after.append("PresetCenter"); split_after.append("PresetCenter");
@ -181,24 +181,18 @@ void EditorPropertyAnchorsPreset::setup(const Vector<String> &p_options) {
Vector<String> text_split = p_options[i].split(":"); Vector<String> text_split = p_options[i].split(":");
int64_t current_val = text_split[1].to_int(); int64_t current_val = text_split[1].to_int();
String humanized_name = text_split[0]; String option_name = text_split[0];
if (humanized_name.begins_with("Preset")) { if (option_name.begins_with("Preset")) {
if (humanized_name == "PresetWide") { String preset_name = option_name.trim_prefix("Preset");
humanized_name = "Full Rect"; String humanized_name = preset_name.capitalize();
} else { String icon_name = "ControlAlign" + preset_name;
humanized_name = humanized_name.trim_prefix("Preset");
humanized_name = humanized_name.capitalize();
}
String icon_name = text_split[0].trim_prefix("Preset");
icon_name = "ControlAlign" + icon_name;
options->add_icon_item(EditorNode::get_singleton()->get_gui_base()->get_theme_icon(icon_name, "EditorIcons"), humanized_name); options->add_icon_item(EditorNode::get_singleton()->get_gui_base()->get_theme_icon(icon_name, "EditorIcons"), humanized_name);
} else { } else {
options->add_item(humanized_name); options->add_item(option_name);
} }
options->set_item_metadata(j, current_val); options->set_item_metadata(j, current_val);
if (split_after.has(text_split[0])) { if (split_after.has(option_name)) {
options->add_separator(); options->add_separator();
j++; j++;
} }

View file

@ -3300,7 +3300,7 @@ void Control::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::INT, "layout_mode", PROPERTY_HINT_ENUM, "Position,Anchors,Container,Uncontrolled", PROPERTY_USAGE_EDITOR | PROPERTY_USAGE_INTERNAL), "_set_layout_mode", "_get_layout_mode"); ADD_PROPERTY(PropertyInfo(Variant::INT, "layout_mode", PROPERTY_HINT_ENUM, "Position,Anchors,Container,Uncontrolled", PROPERTY_USAGE_EDITOR | PROPERTY_USAGE_INTERNAL), "_set_layout_mode", "_get_layout_mode");
ADD_PROPERTY_DEFAULT("layout_mode", LayoutMode::LAYOUT_MODE_POSITION); ADD_PROPERTY_DEFAULT("layout_mode", LayoutMode::LAYOUT_MODE_POSITION);
const String anchors_presets_options = "Custom:-1,PresetWide:15," const String anchors_presets_options = "Custom:-1,PresetFullRect:15,"
"PresetTopLeft:0,PresetTopRight:1,PresetBottomRight:3,PresetBottomLeft:2," "PresetTopLeft:0,PresetTopRight:1,PresetBottomRight:3,PresetBottomLeft:2,"
"PresetCenterLeft:4,PresetCenterTop:5,PresetCenterRight:6,PresetCenterBottom:7,PresetCenter:8," "PresetCenterLeft:4,PresetCenterTop:5,PresetCenterRight:6,PresetCenterBottom:7,PresetCenter:8,"
"PresetLeftWide:9,PresetTopWide:10,PresetRightWide:11,PresetBottomWide:12,PresetVCenterWide:13,PresetHCenterWide:14"; "PresetLeftWide:9,PresetTopWide:10,PresetRightWide:11,PresetBottomWide:12,PresetVCenterWide:13,PresetHCenterWide:14";