Skip to content

Commit e09acd1

Browse files
committed
context port style and format
1 parent d90a0fd commit e09acd1

1 file changed

Lines changed: 14 additions & 11 deletions

File tree

material_maker/panels/graph_edit/lazy_link/lazy_link.gd

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,11 @@ var csf : float
1616
var popup_menu_item_height : int
1717

1818
const MAX_POPUP_HEIGHT = 375
19-
const SLOT_SVG = "<svg width=\"16\"height=\"16\">
20-
<circle cx=\"8\"cy=\"8\"r=\"5\"fill=\"#FFF\"/></svg>"
19+
const SLOT_SVG = """
20+
<svg width="16" height="16">
21+
<circle cx="8" cy="8" r="6" fill="#FFF" stroke="#000" stroke-width="1"/>
22+
</svg>
23+
"""
2124

2225
var inactive_color : Color
2326
var inactive_link_color : Color
@@ -26,13 +29,13 @@ var active_link_color : Color
2629
var context_color : Color
2730
var context_link_color : Color
2831

29-
var source : GraphNode
30-
var target : GraphNode
32+
var source : MMGraphNodeMinimal
33+
var target : MMGraphNodeMinimal
3134

3235
var frame: StyleBoxFlat
3336
var linked_frame: StyleBoxFlat
3437

35-
var from_point: Vector2
38+
var from_point : Vector2
3639
var has_context : bool = false
3740
var is_lazy_linking: bool = false
3841
var is_context_link: bool = false
@@ -144,13 +147,13 @@ func invalidate_link() -> void:
144147
has_context = false
145148

146149
func show_node(node : LazyNode) -> void:
147-
var color_rect := $NodeA if node else $NodeB
150+
var color_rect : ColorRect = $NodeA if node else $NodeB
148151
color_rect.show()
149-
color_rect.position = get_local_mouse_position() - Vector2(16, 16)
152+
color_rect.position = get_local_mouse_position() - color_rect.size * 0.5
150153
move_to_front()
151154
queue_redraw()
152155

153-
func port_attr(node : GraphNode, port_idx : int,
156+
func port_attr(node : MMGraphNodeMinimal, port_idx : int,
154157
is_output : bool, key : String) -> String:
155158
if node:
156159
var defs : Array = (node.generator.get_output_defs()
@@ -159,7 +162,7 @@ func port_attr(node : GraphNode, port_idx : int,
159162
return defs[port_idx][key]
160163
return ""
161164

162-
func has_input_link(node : GraphNode, port_idx : int) -> bool:
165+
func has_input_link(node : MMGraphNodeMinimal, port_idx : int) -> bool:
163166
var graph : GraphEdit = get_parent()
164167
if graph:
165168
for c : Dictionary in graph.connections:
@@ -183,7 +186,7 @@ func connect_port_type(types : Array, allow_any : bool = false) -> bool:
183186
return false
184187

185188
func create_context_menu(is_output : bool, source_output : int = -1) -> void:
186-
var context_node : GraphNode = source if is_output else target
189+
var context_node : MMGraphNodeMinimal = source if is_output else target
187190

188191
# skip context menu if target node only has one input
189192
if not is_output and context_node.get_input_port_count() == 1:
@@ -217,7 +220,7 @@ func create_context_menu(is_output : bool, source_output : int = -1) -> void:
217220
var context_port_color : Color = (context_node.get_output_port_color(i)
218221
if is_output else context_node.get_input_port_color(i))
219222

220-
var slot_icon : Image = Image.new()
223+
var slot_icon := Image.new()
221224
slot_icon.load_svg_from_buffer(SLOT_SVG.replace("#FFF",
222225
"#" + context_port_color.to_html(false)).to_utf8_buffer())
223226
popup.add_icon_item(ImageTexture.create_from_image(slot_icon), port_name)

0 commit comments

Comments
 (0)