Fix custom property editor layout
This commit is contained in:
parent
1aeb88205d
commit
f6ed465613
|
@ -326,6 +326,9 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant::
|
||||||
menu->set_size(Size2(1, 1) * EDSCALE);
|
menu->set_size(Size2(1, 1) * EDSCALE);
|
||||||
|
|
||||||
for (int i = 0; i < MAX_VALUE_EDITORS; i++) {
|
for (int i = 0; i < MAX_VALUE_EDITORS; i++) {
|
||||||
|
if (i < MAX_VALUE_EDITORS / 4) {
|
||||||
|
value_hboxes[i]->hide();
|
||||||
|
}
|
||||||
value_editor[i]->hide();
|
value_editor[i]->hide();
|
||||||
value_label[i]->hide();
|
value_label[i]->hide();
|
||||||
if (i < 4) {
|
if (i < 4) {
|
||||||
|
@ -1701,6 +1704,14 @@ void CustomPropertyEditor::config_value_editors(int p_amount, int p_columns, int
|
||||||
set_size(Size2(cell_margin + p_label_w + (cell_width + cell_margin + p_label_w) * p_columns, cell_margin + (cell_height + cell_margin) * rows) * EDSCALE);
|
set_size(Size2(cell_margin + p_label_w + (cell_width + cell_margin + p_label_w) * p_columns, cell_margin + (cell_height + cell_margin) * rows) * EDSCALE);
|
||||||
|
|
||||||
for (int i = 0; i < MAX_VALUE_EDITORS; i++) {
|
for (int i = 0; i < MAX_VALUE_EDITORS; i++) {
|
||||||
|
if (i < MAX_VALUE_EDITORS / 4) {
|
||||||
|
if (i <= p_amount / 4) {
|
||||||
|
value_hboxes[i]->show();
|
||||||
|
} else {
|
||||||
|
value_hboxes[i]->hide();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int c = i % p_columns;
|
int c = i % p_columns;
|
||||||
int r = i / p_columns;
|
int r = i / p_columns;
|
||||||
|
|
||||||
|
@ -1729,13 +1740,23 @@ CustomPropertyEditor::CustomPropertyEditor() {
|
||||||
read_only = false;
|
read_only = false;
|
||||||
updating = false;
|
updating = false;
|
||||||
|
|
||||||
|
value_vbox = memnew(VBoxContainer);
|
||||||
|
add_child(value_vbox);
|
||||||
|
|
||||||
for (int i = 0; i < MAX_VALUE_EDITORS; i++) {
|
for (int i = 0; i < MAX_VALUE_EDITORS; i++) {
|
||||||
value_editor[i] = memnew(LineEdit);
|
if (i < MAX_VALUE_EDITORS / 4) {
|
||||||
add_child(value_editor[i]);
|
value_hboxes[i] = memnew(HBoxContainer);
|
||||||
|
value_vbox->add_child(value_hboxes[i]);
|
||||||
|
value_hboxes[i]->hide();
|
||||||
|
}
|
||||||
|
int hbox_idx = i / 4;
|
||||||
value_label[i] = memnew(Label);
|
value_label[i] = memnew(Label);
|
||||||
add_child(value_label[i]);
|
value_hboxes[hbox_idx]->add_child(value_label[i]);
|
||||||
value_editor[i]->hide();
|
|
||||||
value_label[i]->hide();
|
value_label[i]->hide();
|
||||||
|
value_editor[i] = memnew(LineEdit);
|
||||||
|
value_hboxes[hbox_idx]->add_child(value_editor[i]);
|
||||||
|
value_editor[i]->set_h_size_flags(Control::SIZE_EXPAND_FILL);
|
||||||
|
value_editor[i]->hide();
|
||||||
value_editor[i]->connect("text_entered", callable_mp(this, &CustomPropertyEditor::_modified));
|
value_editor[i]->connect("text_entered", callable_mp(this, &CustomPropertyEditor::_modified));
|
||||||
value_editor[i]->connect("focus_entered", callable_mp(this, &CustomPropertyEditor::_focus_enter));
|
value_editor[i]->connect("focus_entered", callable_mp(this, &CustomPropertyEditor::_focus_enter));
|
||||||
value_editor[i]->connect("focus_exited", callable_mp(this, &CustomPropertyEditor::_focus_exit));
|
value_editor[i]->connect("focus_exited", callable_mp(this, &CustomPropertyEditor::_focus_exit));
|
||||||
|
|
|
@ -100,6 +100,8 @@ class CustomPropertyEditor : public PopupPanel {
|
||||||
List<String> field_names;
|
List<String> field_names;
|
||||||
int hint;
|
int hint;
|
||||||
String hint_text;
|
String hint_text;
|
||||||
|
HBoxContainer *value_hboxes[MAX_VALUE_EDITORS / 4];
|
||||||
|
VBoxContainer *value_vbox;
|
||||||
LineEdit *value_editor[MAX_VALUE_EDITORS];
|
LineEdit *value_editor[MAX_VALUE_EDITORS];
|
||||||
int focused_value_editor;
|
int focused_value_editor;
|
||||||
Label *value_label[MAX_VALUE_EDITORS];
|
Label *value_label[MAX_VALUE_EDITORS];
|
||||||
|
|
Loading…
Reference in New Issue