Skip to content

Commit

Permalink
Use human-readable unique names for GraphEdit's internal nodes
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronfranke committed Aug 4, 2024
1 parent 3978628 commit 7e37380
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion scene/gui/graph_edit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2786,6 +2786,7 @@ GraphEdit::GraphEdit() {
panner->set_callbacks(callable_mp(this, &GraphEdit::_pan_callback), callable_mp(this, &GraphEdit::_zoom_callback));

top_layer = memnew(Control);
top_layer->set_name("_top_layer");
add_child(top_layer, false, INTERNAL_MODE_BACK);
top_layer->set_mouse_filter(MOUSE_FILTER_IGNORE);
top_layer->set_anchors_and_offsets_preset(Control::PRESET_FULL_RECT);
Expand Down Expand Up @@ -2838,11 +2839,13 @@ GraphEdit::GraphEdit() {
menu_panel->set_position(Vector2(10, 10));

menu_hbox = memnew(HBoxContainer);
menu_hbox->set_name("_menu_hbox");
menu_panel->add_child(menu_hbox);

// Zoom label and controls.

zoom_label = memnew(Label);
zoom_label->set_name("_zoom_label");
zoom_label->set_visible(show_zoom_label);
zoom_label->set_v_size_flags(Control::SIZE_SHRINK_CENTER);
zoom_label->set_horizontal_alignment(HORIZONTAL_ALIGNMENT_CENTER);
Expand All @@ -2851,6 +2854,7 @@ GraphEdit::GraphEdit() {
_update_zoom_label();

zoom_minus_button = memnew(Button);
zoom_minus_button->set_name("_zoom_minus_button");
zoom_minus_button->set_theme_type_variation("FlatButton");
zoom_minus_button->set_visible(show_zoom_buttons);
zoom_minus_button->set_tooltip_text(ETR("Zoom Out"));
Expand All @@ -2859,6 +2863,7 @@ GraphEdit::GraphEdit() {
zoom_minus_button->connect(SceneStringName(pressed), callable_mp(this, &GraphEdit::_zoom_minus));

zoom_reset_button = memnew(Button);
zoom_reset_button->set_name("_zoom_reset_button");
zoom_reset_button->set_theme_type_variation("FlatButton");
zoom_reset_button->set_visible(show_zoom_buttons);
zoom_reset_button->set_tooltip_text(ETR("Zoom Reset"));
Expand All @@ -2867,6 +2872,7 @@ GraphEdit::GraphEdit() {
zoom_reset_button->connect(SceneStringName(pressed), callable_mp(this, &GraphEdit::_zoom_reset));

zoom_plus_button = memnew(Button);
zoom_plus_button->set_name("_zoom_plus_button");
zoom_plus_button->set_theme_type_variation("FlatButton");
zoom_plus_button->set_visible(show_zoom_buttons);
zoom_plus_button->set_tooltip_text(ETR("Zoom In"));
Expand All @@ -2877,6 +2883,7 @@ GraphEdit::GraphEdit() {
// Grid controls.

toggle_grid_button = memnew(Button);
toggle_grid_button->set_name("_toggle_grid_button");
toggle_grid_button->set_theme_type_variation("FlatButton");
toggle_grid_button->set_visible(show_grid_buttons);
toggle_grid_button->set_toggle_mode(true);
Expand All @@ -2887,6 +2894,7 @@ GraphEdit::GraphEdit() {
toggle_grid_button->connect(SceneStringName(pressed), callable_mp(this, &GraphEdit::_show_grid_toggled));

toggle_snapping_button = memnew(Button);
toggle_snapping_button->set_name("_toggle_snapping_button");
toggle_snapping_button->set_theme_type_variation("FlatButton");
toggle_snapping_button->set_visible(show_grid_buttons);
toggle_snapping_button->set_toggle_mode(true);
Expand All @@ -2897,6 +2905,7 @@ GraphEdit::GraphEdit() {
toggle_snapping_button->connect(SceneStringName(pressed), callable_mp(this, &GraphEdit::_snapping_toggled));

snapping_distance_spinbox = memnew(SpinBox);
snapping_distance_spinbox->set_name("_snapping_distance_spinbox");
snapping_distance_spinbox->set_visible(show_grid_buttons);
snapping_distance_spinbox->set_min(GRID_MIN_SNAPPING_DISTANCE);
snapping_distance_spinbox->set_max(GRID_MAX_SNAPPING_DISTANCE);
Expand All @@ -2909,6 +2918,7 @@ GraphEdit::GraphEdit() {
// Extra controls.

minimap_button = memnew(Button);
minimap_button->set_name("_minimap_button");
minimap_button->set_theme_type_variation("FlatButton");
minimap_button->set_visible(show_minimap_button);
minimap_button->set_toggle_mode(true);
Expand All @@ -2919,6 +2929,7 @@ GraphEdit::GraphEdit() {
minimap_button->connect(SceneStringName(pressed), callable_mp(this, &GraphEdit::_minimap_toggled));

arrange_button = memnew(Button);
arrange_button->set_name("_arrange_button");
arrange_button->set_theme_type_variation("FlatButton");
arrange_button->set_visible(show_arrange_button);
arrange_button->connect(SceneStringName(pressed), callable_mp(this, &GraphEdit::arrange_nodes));
Expand All @@ -2932,8 +2943,8 @@ GraphEdit::GraphEdit() {
const float minimap_opacity = 0.65;

minimap = memnew(GraphEditMinimap(this));
top_layer->add_child(minimap);
minimap->set_name("_minimap");
top_layer->add_child(minimap);
minimap->set_modulate(Color(1, 1, 1, minimap_opacity));
minimap->set_mouse_filter(MOUSE_FILTER_PASS);
minimap->set_custom_minimum_size(Vector2(50, 50));
Expand Down

0 comments on commit 7e37380

Please sign in to comment.