Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New theme icons #712

Merged
merged 11 commits into from
Dec 17, 2024
  •  
  •  
  •  
5 changes: 4 additions & 1 deletion addons/flexible_layout/flexible_tab.gd
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ var updating : bool = false


func _ready():
$Container/Close.texture_normal = get_theme_icon("close", "TabBar")
update()

func _notification(what):
Expand All @@ -23,6 +22,10 @@ func get_flex_layout():
return flex_tab.flexible_layout

func update():
$Container/Close.texture_normal = get_theme_icon("close", "MM_FlexibleTab")
$Container/Close.modulate = get_theme_color("font_selected_color", "MM_FlexibleTab")
$Container/Undock.texture_normal = get_theme_icon("undock", "MM_FlexibleTab")
$Container/Undock.modulate = get_theme_color("font_selected_color", "MM_FlexibleTab")
if not updating:
updating = true
var is_current: bool = (get_index() == get_parent().get_parent().current)
Expand Down
6 changes: 2 additions & 4 deletions addons/flexible_layout/flexible_tab.tscn
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
[gd_scene load_steps=4 format=3 uid="uid://e06xegp2tp3f"]
[gd_scene load_steps=3 format=3 uid="uid://e06xegp2tp3f"]

[ext_resource type="Script" uid="uid://ywxnr7grll4s" path="res://addons/flexible_layout/flexible_tab.gd" id="1"]
[ext_resource type="Texture2D" uid="uid://xuy6dfh1rsne" path="res://addons/flexible_layout/undock.png" id="2_nx0qp"]
[ext_resource type="Script" path="res://addons/flexible_layout/flexible_tab.gd" id="1"]

[sub_resource type="PlaceholderTexture2D" id="PlaceholderTexture2D_bok24"]
size = Vector2(16, 16)
Expand Down Expand Up @@ -31,7 +30,6 @@ visible = false
layout_mode = 2
size_flags_horizontal = 4
size_flags_vertical = 4
texture_normal = ExtResource("2_nx0qp")

[node name="Close" type="TextureButton" parent="Container"]
visible = false
Expand Down
1 change: 1 addition & 0 deletions material_maker/main_window.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
[ext_resource type="Script" uid="uid://ds4jcblbferbu" path="res://material_maker/tools/library_manager/library_manager.gd" id="14"]
[ext_resource type="Texture2D" path="res://material_maker/icons/paste_none.tres" id="15"]


[sub_resource type="GDScript" id="6"]
script/source = "extends Label

Expand Down
8 changes: 8 additions & 0 deletions material_maker/main_window_projects_panel.gd
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,14 @@ extends Control
@onready var preview_3d_background_panel = $PreviewUI/Panel


func _notification(what: int) -> void:
if what == NOTIFICATION_THEME_CHANGED:
if not is_node_ready():
await ready
preview_2d_background_button.icon = get_theme_icon("2D_preview", "MM_Icons")
preview_3d_background_button.icon = get_theme_icon("3D_preview", "MM_Icons")
%ControlView.texture = get_theme_icon("3D_preview_control", "MM_Icons")

func get_projects():
return projects

Expand Down
22 changes: 13 additions & 9 deletions material_maker/nodes/reroute/reroute.gd
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ const PREVIEW_SIZES : Array[int] = [ 0, 64, 128, 192]
func _ready() -> void:
super._ready()
close_button.visible = false
set_theme_type("Reroute")
theme_type_variation = "MM_Reroute"
#set_theme_type("Reroute")
on_connections_changed.call_deferred()

func set_generator(g : MMGenBase) -> void:
Expand All @@ -16,12 +17,13 @@ func set_generator(g : MMGenBase) -> void:
await set_preview(g.get_parameter("preview"))
update_node()

func set_theme_type(type : StringName):
var current_theme : Theme = mm_globals.main_window.theme
for constant in current_theme.get_constant_list(type):
add_theme_constant_override(constant, current_theme.get_constant(constant, type))
for stylebox in current_theme.get_stylebox_list(type):
add_theme_stylebox_override(stylebox, current_theme.get_stylebox(stylebox, type))

#func set_theme_type(type : StringName):
#var current_theme : Theme = mm_globals.main_window.theme
#for constant in current_theme.get_constant_list(type):
#add_theme_constant_override(constant, current_theme.get_constant(constant, type))
#for stylebox in current_theme.get_stylebox_list(type):
#add_theme_stylebox_override(stylebox, current_theme.get_stylebox(stylebox, type))

func on_connections_changed():
var graph_edit = get_parent()
Expand Down Expand Up @@ -95,7 +97,8 @@ func set_preview(v : int):
if v == 0:
if preview:
preview.queue_free()
set_theme_type("Reroute")
theme_type_variation = "MM_Reroute"
#set_theme_type("Reroute")
else:
if ! preview:
preview = preload("res://material_maker/panels/preview_2d/preview_2d_node.tscn").instantiate()
Expand All @@ -104,6 +107,7 @@ func set_preview(v : int):
update_preview(preview)
var preview_size : int = PREVIEW_SIZES[v]
preview.custom_minimum_size = Vector2(preview_size, preview_size)
set_theme_type("ReroutePreview")
#set_theme_type("ReroutePreview")
theme_type_variation = "MM_ReroutePreview"
await get_tree().process_frame
size = Vector2(0, 0)
11 changes: 11 additions & 0 deletions material_maker/panels/library/library.gd
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,17 @@ func _ready() -> void:
libraries_button.get_popup().id_pressed.connect(self._on_Libraries_id_pressed)
init_expanded_items()
update_tree()
update_theme()

func _notification(what: int) -> void:
if not is_node_ready():
return

if what == NOTIFICATION_THEME_CHANGED:
update_theme()

func update_theme() -> void:
libraries_button.icon = get_theme_icon("settings", "MM_Icons")

func init_expanded_items() -> void:
var f = FileAccess.open("user://expanded_items.bin", FileAccess.READ)
Expand Down
3 changes: 3 additions & 0 deletions material_maker/panels/preview_3d/preview_3d_ui.gd
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,6 @@ var target_node

func _ready() -> void:
target_node = get_node(target)

$Model.icon = get_theme_icon("model", "MM_Icons")
$Environment.icon = get_theme_icon("environment", "MM_Icons")
4 changes: 3 additions & 1 deletion material_maker/panels/preview_3d/preview_3d_ui.tscn
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
[gd_scene load_steps=4 format=3 uid="uid://brlp703awvxbn"]
[gd_scene load_steps=5 format=3 uid="uid://brlp703awvxbn"]

[ext_resource type="Script" path="res://material_maker/panels/preview_3d/preview_3d_ui.gd" id="1_oc43p"]
[ext_resource type="Texture2D" uid="uid://c0j4px4n72di5" path="res://material_maker/icons/icons.tres" id="2"]

[sub_resource type="AtlasTexture" id="1"]
Expand All @@ -15,6 +16,7 @@ anchors_preset = 10
anchor_right = 1.0
offset_bottom = 20.0
size_flags_horizontal = 3
script = ExtResource("1_oc43p")

[node name="Model" type="MenuButton" parent="."]
layout_mode = 2
Expand Down
29 changes: 7 additions & 22 deletions material_maker/projects_panel.tscn
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
[gd_scene load_steps=12 format=3 uid="uid://bnqq3vhwmudkw"]
[gd_scene load_steps=8 format=3 uid="uid://bnqq3vhwmudkw"]

[ext_resource type="Script" uid="uid://cryayuomvuwbo" path="res://material_maker/main_window_projects_panel.gd" id="1_m3usq"]
[ext_resource type="PackedScene" uid="uid://bb6iar0tbj2qt" path="res://material_maker/panels/preview_2d/preview_2d.tscn" id="2_oiaqi"]
[ext_resource type="PackedScene" uid="uid://dpaxvlnn2u1f6" path="res://material_maker/panels/preview_3d/preview_3d.tscn" id="3_qvj7k"]
[ext_resource type="Script" uid="uid://bl15iwn2k8qm" path="res://material_maker/widgets/tabs/tabs.gd" id="4_mpinq"]
[ext_resource type="Texture2D" uid="uid://c0j4px4n72di5" path="res://material_maker/icons/icons.tres" id="5_1qnqj"]
[ext_resource type="Script" path="res://material_maker/widgets/tabs/tabs.gd" id="4_mpinq"]
[ext_resource type="PackedScene" uid="uid://brlp703awvxbn" path="res://material_maker/panels/preview_3d/preview_3d_ui.tscn" id="6_mpc0m"]

[sub_resource type="Shader" id="1"]
Expand All @@ -15,18 +14,6 @@ resource_local_to_scene = true
render_priority = 0
shader = SubResource("1")

[sub_resource type="AtlasTexture" id="3"]
atlas = ExtResource("5_1qnqj")
region = Rect2(96, 96, 32, 32)

[sub_resource type="AtlasTexture" id="4"]
atlas = ExtResource("5_1qnqj")
region = Rect2(96, 32, 32, 32)

[sub_resource type="AtlasTexture" id="5"]
atlas = ExtResource("5_1qnqj")
region = Rect2(96, 64, 32, 31)

[node name="ProjectsPanel" type="Control"]
clip_contents = true
custom_minimum_size = Vector2(100, 100)
Expand Down Expand Up @@ -118,24 +105,22 @@ layout_mode = 1
anchors_preset = 2
anchor_top = 1.0
anchor_bottom = 1.0
offset_left = 5.5
offset_top = -53.5
offset_right = 335.5
offset_bottom = -13.5
offset_left = 11.5
offset_top = -24.5
offset_right = 95.5
offset_bottom = -16.5
grow_vertical = 0
mouse_filter = 2

[node name="Preview2DButton" type="Button" parent="PreviewUI"]
layout_mode = 2
tooltip_text = "Show 2D preview"
toggle_mode = true
icon = SubResource("3")

[node name="Preview3DButton" type="Button" parent="PreviewUI"]
layout_mode = 2
tooltip_text = "Show 3D preview"
toggle_mode = true
icon = SubResource("4")

[node name="Panel" type="PanelContainer" parent="PreviewUI"]
visible = false
Expand All @@ -148,9 +133,9 @@ layout_mode = 2
layout_mode = 2

[node name="ControlView" type="TextureRect" parent="PreviewUI/Panel/HBoxContainer"]
unique_name_in_owner = true
layout_mode = 2
size_flags_vertical = 4
texture = SubResource("5")

[node name="Preview3DUI" parent="PreviewUI/Panel/HBoxContainer" instance=ExtResource("6_mpc0m")]
layout_mode = 2
Expand Down
Loading
Loading