Skip to content

Commit c50e373

Browse files
tksuoranclaude
andcommitted
editor: per-node pin label column width; wider rendergraph nodes by default
Graph_editor_node gains a pin-label-width property (canvas units, default 70, clamped 20..400): the space reserved on each pin edge for the pin labels, previously hardcoded in node_editor(). Exposed as the Node Properties "Pin labels" row, persisted in the graph asset JSON and the node clipboard next to the node size (written only when non-default), and settable through the *_graph_set_node_layout MCP tools (pin_label_width). The rendergraph viewer's pin names are long ("rendertarget texture", "depth visualization"), so its proxy nodes default to a 150 pin label column and a 520 requested node width - labels no longer clip and the nodes read comfortably. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
1 parent c8464e7 commit c50e373

9 files changed

Lines changed: 54 additions & 3 deletions

src/editor/developer/rendergraph_window.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,11 @@ class Rendergraph_editor_node : public Graph_editor_node
5555
for (const erhe::graph::Pin& pin : rendergraph_node.get_output_pins()) {
5656
base_make_output_pin(pin.get_key(), pin.get_name());
5757
}
58+
// Rendergraph pin names are long ("rendertarget texture", "depth
59+
// visualization"), so reserve wider pin label columns and a wider
60+
// node than the graph editors' defaults.
61+
set_pin_label_width(150.0f);
62+
set_ui_size(520.0f, 0.0f);
5863
}
5964

6065
[[nodiscard]] auto get_rendergraph_node() const -> erhe::rendergraph::Rendergraph_node* { return m_rendergraph_node; }

src/editor/graph/node_properties.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,14 @@ void Node_properties_window::graph_editor_node_properties(Graph_editor_window_ba
277277
}
278278
ImGui::EndDisabled();
279279
});
280+
m_property_editor.add_entry("Pin labels", [node]() {
281+
// Width of the pin label columns on the node edges (canvas units);
282+
// labels wider than this clip.
283+
float width = node->get_pin_label_width();
284+
if (ImGui::DragFloat("##pin_label_width", &width, 1.0f, 20.0f, 400.0f, "%.0f")) {
285+
node->set_pin_label_width(width);
286+
}
287+
});
280288
// Pin layout: only left / right are implemented by the node renderer, so
281289
// the combos offer just those two edges (unlike the shader graph's).
282290
m_property_editor.add_entry("Inputs", [node]() {

src/editor/graph_editor/graph_clipboard.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ auto paste_graph_nodes(
7272
node->read_parameters(node_json["parameters"]);
7373
}
7474
node->set_ui_size(node_json.value("width", 0.0f), node_json.value("height", 0.0f));
75+
node->set_pin_label_width(node_json.value("pin_label_width", Graph_editor_node::default_pin_label_width));
7576
node->set_input_pin_edge (node_json.value("input_edge", Node_edge::left));
7677
node->set_output_pin_edge(node_json.value("output_edge", Node_edge::right));
7778
const ImVec2 node_position{node_json.value("x", 0.0f), node_json.value("y", 0.0f)};

src/editor/graph_editor/graph_editor_node.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,16 @@ void Graph_editor_node::set_ui_size(const float width, const float height)
8383
m_ui_height = std::clamp(height, 0.0f, 4096.0f);
8484
}
8585

86+
auto Graph_editor_node::get_pin_label_width() const -> float
87+
{
88+
return m_pin_label_width;
89+
}
90+
91+
void Graph_editor_node::set_pin_label_width(const float width)
92+
{
93+
m_pin_label_width = std::clamp(width, 20.0f, 400.0f);
94+
}
95+
8696
auto Graph_editor_node::get_input_pin_edge() const -> int
8797
{
8898
return m_input_pin_edge;
@@ -185,7 +195,7 @@ void Graph_editor_node::node_editor(App_context& app_context, ax::NodeEditor::Ed
185195
// (or less, down to a minimum) room. NodePadding is part of the node's
186196
// outer extent, so subtract it to hit the requested canvas-unit width.
187197
const ImVec4 node_padding = node_editor.GetStyle().NodePadding; // canvas units: left, top, right, bottom
188-
const float pin_label_width = 70.0f * m_content_scale;
198+
const float pin_label_width = m_pin_label_width * m_content_scale;
189199
float center_width = 150.0f * m_content_scale;
190200
if (m_ui_width > 0.0f) {
191201
const float padding_width = (node_padding.x + node_padding.z) * m_content_scale;

src/editor/graph_editor/graph_editor_node.hpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,15 @@ class Graph_editor_node : public erhe::graph::Node
6565
[[nodiscard]] auto get_ui_height() const -> float;
6666
void set_ui_size(float width, float height);
6767

68+
// Pin label column width in canvas units: the space reserved on each pin
69+
// edge for the pin labels (labels wider than this clip). Editors whose
70+
// pins carry longer names raise it (the rendergraph viewer). Adjusted
71+
// from the Node Properties window "Pin labels" row; persisted in the
72+
// graph JSON next to the node size.
73+
static constexpr float default_pin_label_width = 70.0f;
74+
[[nodiscard]] auto get_pin_label_width() const -> float;
75+
void set_pin_label_width(float width);
76+
6877
// Pin layout: which node edge the input / output pins are laid out on
6978
// (Node_edge::left / right; the renderer implements only those two, so
7079
// the setters clamp anything else back to the default edge). Adjusted
@@ -128,6 +137,7 @@ class Graph_editor_node : public erhe::graph::Node
128137
float m_content_scale{1.0f};
129138
float m_ui_width {0.0f}; // canvas units; <= 0 = automatic
130139
float m_ui_height{0.0f}; // canvas units; <= 0 = automatic
140+
float m_pin_label_width{default_pin_label_width}; // canvas units
131141
// Bottom of the requested node content extent in screen space (0 = no
132142
// requested height); set per frame by node_editor(), consumed by the
133143
// height pad and by get_preview_fit_size().

src/editor/graph_editor/graph_editor_window_base.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -657,6 +657,9 @@ auto Graph_editor_window_base::serialize_nodes_json(const std::vector<std::share
657657
if (node->get_ui_height() > 0.0f) {
658658
node_json["height"] = node->get_ui_height();
659659
}
660+
if (node->get_pin_label_width() != Graph_editor_node::default_pin_label_width) {
661+
node_json["pin_label_width"] = node->get_pin_label_width();
662+
}
660663
if (node->get_input_pin_edge() != Node_edge::left) {
661664
node_json["input_edge"] = node->get_input_pin_edge();
662665
}

src/editor/graph_editor/graph_serialization.hpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#pragma once
22

33
#include "editor_log.hpp"
4+
#include "graph_editor/graph_editor_node.hpp"
45
#include "graph_editor/node_edge.hpp"
56

67
#include "erhe_graph/graph.hpp"
@@ -51,6 +52,9 @@ template <typename NodeT>
5152
if (node->get_ui_height() > 0.0f) {
5253
node_json["height"] = node->get_ui_height();
5354
}
55+
if (node->get_pin_label_width() != Graph_editor_node::default_pin_label_width) {
56+
node_json["pin_label_width"] = node->get_pin_label_width();
57+
}
5458
if (node->get_input_pin_edge() != Node_edge::left) {
5559
node_json["input_edge"] = node->get_input_pin_edge();
5660
}
@@ -134,6 +138,7 @@ auto read_graph_asset_json(
134138
node->read_parameters(node_json["parameters"]);
135139
}
136140
node->set_ui_size(node_json.value("width", 0.0f), node_json.value("height", 0.0f));
141+
node->set_pin_label_width(node_json.value("pin_label_width", Graph_editor_node::default_pin_label_width));
137142
node->set_input_pin_edge (node_json.value("input_edge", Node_edge::left));
138143
node->set_output_pin_edge(node_json.value("output_edge", Node_edge::right));
139144
new_nodes.push_back(node);

src/editor/mcp/mcp_server_graphs.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,12 @@ namespace {
141141
const float height = args.contains("height") ? args["height"].get<float>() : node.get_ui_height();
142142
node.set_ui_size(width, height);
143143
}
144+
if (args.contains("pin_label_width")) {
145+
if (!args["pin_label_width"].is_number()) {
146+
return make_error_content("'pin_label_width' must be a number (canvas units)");
147+
}
148+
node.set_pin_label_width(args["pin_label_width"].get<float>());
149+
}
144150
int edge = 0;
145151
if (args.contains("input_edge")) {
146152
if (!parse_node_edge(args["input_edge"], edge)) {
@@ -158,8 +164,9 @@ namespace {
158164
json result;
159165
result["node_id"] = node.get_id();
160166
result["position"] = json::array({position.x, position.y});
161-
result["width"] = node.get_ui_width(); // 0 = automatic
162-
result["height"] = node.get_ui_height(); // 0 = automatic
167+
result["width"] = node.get_ui_width(); // 0 = automatic
168+
result["height"] = node.get_ui_height(); // 0 = automatic
169+
result["pin_label_width"] = node.get_pin_label_width();
163170
result["input_edge"] = (node.get_input_pin_edge() == Node_edge::right) ? "right" : "left";
164171
result["output_edge"] = (node.get_output_pin_edge() == Node_edge::right) ? "right" : "left";
165172
return make_json_content(result).dump();

src/editor/mcp/mcp_server_tool_list.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -977,6 +977,7 @@ void Mcp_server::refresh_tool_list()
977977
{"position", {{"type", "array"}, {"items", {{"type", "number"}}}, {"description", "Canvas position [x, y]"}}},
978978
{"width", {{"type", "number"}, {"description", "Requested node width in canvas units; 0 = automatic (content-derived)"}}},
979979
{"height", {{"type", "number"}, {"description", "Requested node height in canvas units; 0 = automatic (content-derived)"}}},
980+
{"pin_label_width", {{"type", "number"}, {"description", "Pin label column width in canvas units (default 70; clamped to 20..400)"}}},
980981
{"input_edge", {{"type", "string"}, {"description", "Edge for input pins: left (default) or right"}}},
981982
{"output_edge", {{"type", "string"}, {"description", "Edge for output pins: left or right (default)"}}}
982983
}},
@@ -989,6 +990,7 @@ void Mcp_server::refresh_tool_list()
989990
{"position", {{"type", "array"}, {"items", {{"type", "number"}}}, {"description", "Canvas position [x, y]"}}},
990991
{"width", {{"type", "number"}, {"description", "Requested node width in canvas units; 0 = automatic (content-derived)"}}},
991992
{"height", {{"type", "number"}, {"description", "Requested node height in canvas units; 0 = automatic (content-derived)"}}},
993+
{"pin_label_width", {{"type", "number"}, {"description", "Pin label column width in canvas units (default 70; clamped to 20..400)"}}},
992994
{"input_edge", {{"type", "string"}, {"description", "Edge for input pins: left (default) or right"}}},
993995
{"output_edge", {{"type", "string"}, {"description", "Edge for output pins: left or right (default)"}}}
994996
}},

0 commit comments

Comments
 (0)