|
@@ -1760,24 +1760,40 @@ void CustomPropertyEditor::_focus_exit() {
|
|
|
|
|
|
void CustomPropertyEditor::config_action_buttons(const List<String> &p_strings) {
|
|
|
|
|
|
- int cell_width = 60;
|
|
|
- int cell_height = 25;
|
|
|
- int cell_margin = 5;
|
|
|
+ Ref<StyleBox> sb = get_stylebox("panel");
|
|
|
+ int margin_top = sb->get_margin(MARGIN_TOP);
|
|
|
+ int margin_left = sb->get_margin(MARGIN_LEFT);
|
|
|
+ int margin_bottom = sb->get_margin(MARGIN_BOTTOM);
|
|
|
+ int margin_right = sb->get_margin(MARGIN_RIGHT);
|
|
|
|
|
|
- set_size(Size2(cell_margin + (cell_width + cell_margin) * p_strings.size(), (cell_margin * 2) + cell_height) * EDSCALE);
|
|
|
+ int max_width = 0;
|
|
|
+ int height = 0;
|
|
|
|
|
|
for (int i = 0; i < MAX_ACTION_BUTTONS; i++) {
|
|
|
|
|
|
if (i < p_strings.size()) {
|
|
|
+
|
|
|
action_buttons[i]->show();
|
|
|
action_buttons[i]->set_text(p_strings[i]);
|
|
|
- action_buttons[i]->set_position(Point2(cell_margin + (cell_width + cell_margin) * i, cell_margin) * EDSCALE);
|
|
|
- action_buttons[i]->set_size(Size2(cell_width, cell_height - cell_margin * 2) * EDSCALE);
|
|
|
- action_buttons[i]->set_flat(true);
|
|
|
+
|
|
|
+ Size2 btn_m_size = action_buttons[i]->get_minimum_size();
|
|
|
+ if (btn_m_size.width > max_width)
|
|
|
+ max_width = btn_m_size.width;
|
|
|
+
|
|
|
} else {
|
|
|
action_buttons[i]->hide();
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ for (int i = 0; i < p_strings.size(); i++) {
|
|
|
+
|
|
|
+ Size2 btn_m_size = action_buttons[i]->get_size();
|
|
|
+ action_buttons[i]->set_position(Point2(0, height) + Point2(margin_left, margin_top));
|
|
|
+ action_buttons[i]->set_size(Size2(max_width, btn_m_size.height));
|
|
|
+
|
|
|
+ height += btn_m_size.height;
|
|
|
+ }
|
|
|
+ set_size(Size2(max_width, height) + Size2(margin_left + margin_right, margin_top + margin_bottom));
|
|
|
}
|
|
|
|
|
|
void CustomPropertyEditor::config_value_editors(int p_amount, int p_columns, int p_label_w, const List<String> &p_strings) {
|
|
@@ -1898,6 +1914,7 @@ CustomPropertyEditor::CustomPropertyEditor() {
|
|
|
Vector<Variant> binds;
|
|
|
binds.push_back(i);
|
|
|
action_buttons[i]->connect("pressed", this, "_action_pressed", binds);
|
|
|
+ action_buttons[i]->set_flat(true);
|
|
|
}
|
|
|
|
|
|
color_picker = NULL;
|
|
@@ -3952,11 +3969,13 @@ void PropertyEditor::_edit_button(Object *p_item, int p_column, int p_button) {
|
|
|
if (t == Variant::NODE_PATH) {
|
|
|
|
|
|
Variant v = obj->get(n);
|
|
|
- custom_editor->edit(obj, n, (Variant::Type)t, v, h, ht);
|
|
|
Rect2 where = tree->get_item_rect(ti, 1);
|
|
|
where.position -= tree->get_scroll();
|
|
|
- where.position += tree->get_global_position();
|
|
|
+ where.position += tree->get_global_position() + Point2(where.size.width, 0);
|
|
|
+ for (int i = ti->get_button_count(p_column) - 1; i >= p_button; i--)
|
|
|
+ where.position.x -= ti->get_button(p_column, i)->get_width();
|
|
|
custom_editor->set_position(where.position);
|
|
|
+ custom_editor->edit(obj, n, (Variant::Type)t, v, h, ht);
|
|
|
custom_editor->popup();
|
|
|
|
|
|
} else if (t == Variant::STRING) {
|
|
@@ -3967,7 +3986,9 @@ void PropertyEditor::_edit_button(Object *p_item, int p_column, int p_button) {
|
|
|
|
|
|
Rect2 where = tree->get_item_rect(ti, 1);
|
|
|
where.position -= tree->get_scroll();
|
|
|
- where.position += tree->get_global_position();
|
|
|
+ where.position += tree->get_global_position() + Point2(where.size.width, 0);
|
|
|
+ for (int i = ti->get_button_count(p_column) - 1; i >= p_button; i--)
|
|
|
+ where.position.x -= ti->get_button(p_column, i)->get_width();
|
|
|
custom_editor->set_position(where.position);
|
|
|
custom_editor->popup();
|
|
|
} else {
|