Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make Vector4/i properties show in 2x2 layout #80893

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions editor/editor_properties.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3708,14 +3708,14 @@ EditorProperty *EditorInspectorDefaultPlugin::get_editor_for_property(Object *p_

} break;
case Variant::VECTOR4: {
EditorPropertyVector4 *editor = memnew(EditorPropertyVector4);
EditorPropertyVector4 *editor = memnew(EditorPropertyVector4(p_wide));
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unrelated change. I just noticed it's missing.

EditorPropertyRangeHint hint = _parse_range_hint(p_hint, p_hint_text, default_float_step);
editor->setup(hint.min, hint.max, hint.step, hint.hide_slider, p_hint == PROPERTY_HINT_LINK, hint.suffix);
return editor;

} break;
case Variant::VECTOR4I: {
EditorPropertyVector4i *editor = memnew(EditorPropertyVector4i);
EditorPropertyVector4i *editor = memnew(EditorPropertyVector4i(p_wide));
EditorPropertyRangeHint hint = _parse_range_hint(p_hint, p_hint_text, 1, true);
editor->setup(hint.min, hint.max, 1, true, p_hint == PROPERTY_HINT_LINK, hint.suffix);
return editor;
Expand Down
17 changes: 15 additions & 2 deletions editor/editor_properties_vector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ EditorPropertyVectorN::EditorPropertyVectorN(Variant::Type p_type, bool p_force_
break;
}
bool horizontal = p_force_wide || p_horizontal;
bool grid = false;

HBoxContainer *hb = memnew(HBoxContainer);
hb->set_h_size_flags(SIZE_EXPAND_FILL);
Expand All @@ -197,10 +198,18 @@ EditorPropertyVectorN::EditorPropertyVectorN(Variant::Type p_type, bool p_force_
if (p_force_wide) {
bc = memnew(HBoxContainer);
hb->add_child(bc);
} else if (horizontal) {
} else if (horizontal && component_count < 4) {
bc = memnew(HBoxContainer);
hb->add_child(bc);
set_bottom_editor(hb);
} else if (horizontal) {
bc = memnew(VBoxContainer);
hb->add_child(bc);
set_bottom_editor(hb);

bc->add_child(memnew(HBoxContainer));
bc->add_child(memnew(HBoxContainer));
grid = true;
} else {
bc = memnew(VBoxContainer);
hb->add_child(bc);
Expand All @@ -212,7 +221,11 @@ EditorPropertyVectorN::EditorPropertyVectorN(Variant::Type p_type, bool p_force_

for (int i = 0; i < component_count; i++) {
spin[i] = memnew(EditorSpinSlider);
bc->add_child(spin[i]);
if (grid) {
bc->get_child(i / 2)->add_child(spin[i]);
} else {
bc->add_child(spin[i]);
}
spin[i]->set_flat(true);
spin[i]->set_label(String(COMPONENT_LABELS[i]));
if (horizontal) {
Expand Down