Skip to content

Commit 4ce022b

Browse files
committed
Move colors to theme resource
1 parent 86ff2a7 commit 4ce022b

File tree

2 files changed

+38
-19
lines changed

2 files changed

+38
-19
lines changed

material_maker/panels/graph_edit/lazy_link/lazy_link.gd

Lines changed: 28 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,15 @@ 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>"
1921

20-
const INACTIVE_COLOR := Color.DIM_GRAY
21-
const INACTIVE_LINK_COLOR := Color.WHITE
22-
const ACTIVE_COLOR := Color(0.643, 0.514, 1.0, 1.0)
23-
const ACTIVE_LINK_COLOR := Color(0.753, 0.667, 1.0, 1.0)
24-
const CONTEXT_COLOR := Color.STEEL_BLUE
25-
const CONTEXT_LINK_COLOR := Color(0.374, 0.609, 0.805, 1.0)
26-
const SLOT_SVG = "<svg width=\"16\"height=\"16\"><circle cx=\"8\"cy=\"8\"r=\"5\"fill=\"#FFF\"/></svg>"
22+
var inactive_color : Color
23+
var inactive_link_color : Color
24+
var active_color : Color
25+
var active_link_color : Color
26+
var context_color : Color
27+
var context_link_color : Color
2728

2829
var source : GraphNode
2930
var target : GraphNode
@@ -43,32 +44,40 @@ func _ready() -> void:
4344
popup_menu_item_height = (get_theme_constant("v_separation", "PopupMenu")
4445
+ get_theme_font_size("font"))
4546

47+
_setup_colors()
4648
frame = StyleBoxFlat.new()
47-
frame.border_color = INACTIVE_COLOR
48-
frame.corner_detail = 4
4949
frame.draw_center = false
50-
frame.set_border_width_all(7)
51-
frame.set_corner_radius_all(4)
52-
frame.set_expand_margin_all(12.0)
50+
frame.border_color = inactive_color
51+
frame.corner_detail = get_theme_constant("corner_detail", "MM_LazyLink")
52+
frame.set_border_width_all(get_theme_constant("border_width", "MM_LazyLink"))
53+
frame.set_corner_radius_all(get_theme_constant("corner_radius", "MM_LazyLink"))
54+
frame.set_expand_margin_all(get_theme_constant("expand_margin", "MM_LazyLink"))
5355

5456
linked_frame = frame.duplicate()
55-
linked_frame.border_color = ACTIVE_COLOR
57+
linked_frame.border_color = active_color
5658

59+
func _setup_colors() -> void:
60+
inactive_color = get_theme_color("inactive_color", "MM_LazyLink")
61+
inactive_link_color = get_theme_color("inactive_link_color", "MM_LazyLink")
62+
active_color = get_theme_color("active_color", "MM_LazyLink")
63+
active_link_color = get_theme_color("active_link_color", "MM_LazyLink")
64+
context_color = get_theme_color("context_color", "MM_LazyLink")
65+
context_link_color = get_theme_color("context_link_color", "MM_LazyLink")
5766

5867
func _draw() -> void:
5968
if not is_context_linking and source:
6069
if target:
6170
if is_context_link:
62-
_set_colors(INACTIVE_COLOR, CONTEXT_COLOR,
63-
CONTEXT_LINK_COLOR, CONTEXT_COLOR)
71+
_set_colors(inactive_color, context_color,
72+
context_link_color, context_color)
6473
else:
65-
_set_colors(ACTIVE_COLOR, ACTIVE_COLOR,
66-
ACTIVE_LINK_COLOR, ACTIVE_COLOR)
74+
_set_colors(active_color, active_color,
75+
active_link_color, active_color)
6776
draw_style_box(linked_frame, source.get_rect())
6877
draw_style_box(linked_frame, target.get_rect())
6978
else:
70-
_set_colors(INACTIVE_COLOR, INACTIVE_COLOR,
71-
INACTIVE_LINK_COLOR, INACTIVE_COLOR)
79+
_set_colors(inactive_color, inactive_color,
80+
inactive_link_color, inactive_color)
7281
draw_style_box(frame, source.get_rect())
7382

7483

material_maker/theme/default.tres

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1128,6 +1128,16 @@ MM_Icons/icons/zoom = SubResource("AtlasTexture_iyaen")
11281128
MM_Icons/icons/zoom_in = SubResource("AtlasTexture_5k62t")
11291129
MM_Icons/icons/zoom_out = SubResource("AtlasTexture_vqfa7")
11301130
MM_Icons/icons/zoom_reset = SubResource("AtlasTexture_ngrf6")
1131+
MM_LazyLink/colors/active_color = Color(0.643, 0.514, 1, 1)
1132+
MM_LazyLink/colors/active_link_color = Color(0.753, 0.667, 1, 1)
1133+
MM_LazyLink/colors/context_color = Color(0.275, 0.51, 0.706, 1)
1134+
MM_LazyLink/colors/context_link_color = Color(0.46, 0.757, 1, 1)
1135+
MM_LazyLink/colors/inactive_color = Color(0.412, 0.412, 0.412, 1)
1136+
MM_LazyLink/colors/inactive_link_color = Color(1, 1, 1, 1)
1137+
MM_LazyLink/constants/border_width = 7
1138+
MM_LazyLink/constants/corner_detail = 4
1139+
MM_LazyLink/constants/corner_radius = 4
1140+
MM_LazyLink/constants/expand_margin = 12
11311141
MM_MainBackground/base_type = &"PanelContainer"
11321142
MM_MainBackground/styles/panel = SubResource("StyleBoxFlat_wqwm5")
11331143
MM_Node/constants/minimum_line_height = 20

0 commit comments

Comments
 (0)