Skip to content

Commit

Permalink
GH-491 Improve graph node left/right column rendering
Browse files Browse the repository at this point in the history
  • Loading branch information
Naros committed Jul 13, 2024
1 parent 17c5248 commit 3212e0f
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 4 deletions.
23 changes: 23 additions & 0 deletions src/editor/graph/nodes/graph_node_default.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,29 @@ void OrchestratorGraphNodeDefault::_update_pins()
_create_row_widget(row);
}

real_t max_left_width{ 0 };
real_t max_right_width{ 0 };
for (int row_index = 0; row_index < max_rows; row_index++)
{
if (_pin_rows[row_index].left)
max_left_width = Math::max(_pin_rows[row_index].left->get_size().x, max_left_width);
if (_pin_rows[row_index].right)
max_right_width = Math::max(_pin_rows[row_index].right->get_size().x, max_right_width);
}
for (int row_index = 0; row_index < max_rows; row_index++)
{
if (_pin_rows[row_index].left)
{
_pin_rows[row_index].left->set_custom_minimum_size(Vector2(max_left_width, 0));
_pin_rows[row_index].left->set_alignment(BoxContainer::ALIGNMENT_BEGIN);
}
if (_pin_rows[row_index].right)
{
_pin_rows[row_index].right->set_custom_minimum_size(Vector2(max_right_width, 0));
_pin_rows[row_index].right->set_alignment(BoxContainer::ALIGNMENT_END);
}
}

OrchestratorGraphNode::_update_pins();
}

Expand Down
2 changes: 1 addition & 1 deletion src/editor/graph/pins/graph_node_pin_color.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ Control* OrchestratorGraphNodePinColor::_get_default_value_widget()
{
ColorPickerButton* button = memnew(ColorPickerButton);
button->set_focus_mode(Control::FOCUS_NONE);
button->set_h_size_flags(Control::SIZE_EXPAND_FILL);
button->set_h_size_flags(Control::SIZE_EXPAND);
button->set_custom_minimum_size(Vector2(24, 24));
button->set_pick_color(_pin->get_default_value());
button->connect("color_changed", callable_mp(this, &OrchestratorGraphNodePinColor::_on_default_value_changed));
Expand Down
2 changes: 1 addition & 1 deletion src/editor/graph/pins/graph_node_pin_numeric.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ Control* OrchestratorGraphNodePinNumeric::_get_default_value_widget()
{
LineEdit* line_edit = memnew(LineEdit);
line_edit->set_expand_to_text_length_enabled(true);
line_edit->set_h_size_flags(Control::SIZE_EXPAND_FILL);
line_edit->set_h_size_flags(Control::SIZE_EXPAND);
line_edit->set_text(_pin->get_effective_default_value());
line_edit->add_theme_constant_override("minimum_character_width", 0);
line_edit->set_select_all_on_focus(true);
Expand Down
4 changes: 2 additions & 2 deletions src/editor/graph/pins/graph_node_pin_string.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ Control* OrchestratorGraphNodePinString::_get_default_value_widget()
{
TextEdit* text_edit = memnew(TextEdit);
text_edit->set_placeholder("No value...");
text_edit->set_h_size_flags(Control::SIZE_EXPAND_FILL);
text_edit->set_h_size_flags(Control::SIZE_EXPAND);
text_edit->set_v_size_flags(Control::SIZE_EXPAND);
text_edit->set_h_grow_direction(Control::GROW_DIRECTION_END);
text_edit->set_custom_minimum_size(Vector2(350, 0));
Expand All @@ -76,7 +76,7 @@ Control* OrchestratorGraphNodePinString::_get_default_value_widget()
LineEdit* line_edit = memnew(LineEdit);
line_edit->set_custom_minimum_size(Vector2(30, 0));
line_edit->set_expand_to_text_length_enabled(true);
line_edit->set_h_size_flags(Control::SIZE_EXPAND_FILL);
line_edit->set_h_size_flags(Control::SIZE_EXPAND);
line_edit->set_text(_pin->get_effective_default_value());
line_edit->set_select_all_on_focus(true);
line_edit->connect("text_submitted",
Expand Down

0 comments on commit 3212e0f

Please sign in to comment.