diff --git a/material_maker/icons/down.tres b/material_maker/icons/down.tres index 0a0d7264d..30b0d109d 100644 --- a/material_maker/icons/down.tres +++ b/material_maker/icons/down.tres @@ -1,8 +1,7 @@ -[gd_resource type="AtlasTexture" load_steps=2 format=3] +[gd_resource type="AtlasTexture" load_steps=2 format=3 uid="uid://br47pe0yf0gbl"] -[ext_resource type="Texture2D" path="res://material_maker/icons/icons.tres" id="1"] +[ext_resource type="Texture2D" uid="uid://c0j4px4n72di5" path="res://material_maker/icons/icons.tres" id="1"] [resource] -flags = 4 -atlas = ExtResource( 1 ) -region = Rect2( 32, 48, 16, 16 ) +atlas = ExtResource("1") +region = Rect2(32, 48, 16, 16) diff --git a/material_maker/main_window.gd b/material_maker/main_window.gd index 3cdae0a23..10caf259c 100644 --- a/material_maker/main_window.gd +++ b/material_maker/main_window.gd @@ -9,6 +9,7 @@ var current_tab = null var updating : bool = false var need_update : bool = false + # The resolution scale to use for 3D previews. # Values above 1.0 enable supersampling. This has a significant performance cost # but greatly improves texture rendering quality, especially when using @@ -111,10 +112,14 @@ const MENU : Array[Dictionary] = [ { menu="Help/About", command="about" } ] - func _enter_tree() -> void: mm_globals.main_window = self + if OS.get_name() == "macOS": + get_window().extend_to_title = true + $VBoxContainer/TitleBar.visible = true + $VBoxContainer/TitleBar.process_mode = Node.PROCESS_MODE_INHERIT + func _ready() -> void: get_window().borderless = false get_window().transparent = false diff --git a/material_maker/main_window.tscn b/material_maker/main_window.tscn index 975f9a438..22f4e7440 100644 --- a/material_maker/main_window.tscn +++ b/material_maker/main_window.tscn @@ -1,8 +1,9 @@ -[gd_scene load_steps=21 format=3 uid="uid://cgfeik04a5qqs"] +[gd_scene load_steps=22 format=3 uid="uid://cgfeik04a5qqs"] [ext_resource type="Script" uid="uid://cbfcjtm6e4t8h" path="res://material_maker/main_window.gd" id="1"] [ext_resource type="Theme" uid="uid://b628lwfk6ig2c" path="res://material_maker/theme/default.tres" id="1_2qcba"] [ext_resource type="Script" uid="uid://csdtiyrrw4pxg" path="res://material_maker/main_window_layout.gd" id="2"] +[ext_resource type="Script" uid="uid://vqcg44elblx8" path="res://material_maker/title_bar.gd" id="5_jxedr"] [ext_resource type="PackedScene" uid="uid://eiq3i53x72m2" path="res://addons/flexible_layout/flexible_layout.tscn" id="6_ygla4"] [ext_resource type="PackedScene" uid="uid://clw8sb0p8webl" path="res://material_maker/windows/add_node_popup/add_node_popup.tscn" id="7"] [ext_resource type="PackedScene" uid="uid://bnqq3vhwmudkw" path="res://material_maker/projects_panel.tscn" id="7_ih0ps"] @@ -145,6 +146,24 @@ layout_mode = 2 size_flags_horizontal = 3 size_flags_vertical = 3 +[node name="TitleBar" type="Control" parent="VBoxContainer"] +process_mode = 4 +custom_minimum_size = Vector2(0, 20) +layout_mode = 2 +mouse_filter = 1 +mouse_force_pass_scroll_events = false +script = ExtResource("5_jxedr") + +[node name="TitleBarLabel" type="Label" parent="VBoxContainer/TitleBar"] +layout_mode = 1 +anchors_preset = 5 +anchor_left = 0.5 +anchor_right = 0.5 +offset_left = -20.0 +offset_right = 20.0 +offset_bottom = 19.0 +grow_horizontal = 2 + [node name="TopBar" type="HBoxContainer" parent="VBoxContainer"] layout_mode = 2 @@ -283,6 +302,7 @@ script = ExtResource("9") [node name="AddNodePopup" parent="." instance=ExtResource("7")] visible = false +[connection signal="ready" from="VBoxContainer/TitleBar/TitleBarLabel" to="VBoxContainer/TitleBar" method="_on_title_bar_label_ready"] [connection signal="layout_changed" from="VBoxContainer/Layout/FlexibleLayout" to="." method="update_menus"] [connection signal="gui_input" from="VBoxContainer/ConsoleResizer" to="VBoxContainer/Console" method="_on_console_resizer_gui_input"] [connection signal="gui_input" from="VBoxContainer/ConsoleResizer/ResizerBar" to="VBoxContainer/Console" method="_on_console_resizer_gui_input"] diff --git a/material_maker/nodes/node_button.tscn b/material_maker/nodes/node_button.tscn index 2a0d45dd5..097a3c8ff 100644 --- a/material_maker/nodes/node_button.tscn +++ b/material_maker/nodes/node_button.tscn @@ -1,6 +1,6 @@ [gd_scene load_steps=2 format=3 uid="uid://nhbn35rfn2m5"] -[ext_resource type="Script" path="res://material_maker/nodes/node_button.gd" id="1_f00x4"] +[ext_resource type="Script" uid="uid://dgy0cxsasek5u" path="res://material_maker/nodes/node_button.gd" id="1_f00x4"] [node name="NodeButton" type="TextureButton"] anchors_preset = 15 diff --git a/material_maker/title_bar.gd b/material_maker/title_bar.gd new file mode 100644 index 000000000..9cdd76148 --- /dev/null +++ b/material_maker/title_bar.gd @@ -0,0 +1,54 @@ +extends Control + +var moving : bool +var click_pos : Vector2i + +var title_bar_font = preload("res://material_maker/theme/font_rubik/Rubik-416.ttf") + +func _gui_input(event: InputEvent) -> void: + if event is InputEventMouseMotion: + if moving: + if (event.button_mask & MOUSE_BUTTON_MASK_LEFT) != 0: + var window : Window = get_parent().get_window() + if window: + window.position = ( + DisplayServer.mouse_get_position() - click_pos) + else: + moving = false + + if event is InputEventMouseButton: + if get_rect().has_point(event.position): + var window : Window = get_parent().get_window() + if window: + if event.button_index == MOUSE_BUTTON_LEFT: + if event.is_pressed(): + click_pos = DisplayServer.mouse_get_position() - window.position + moving = true + else: + moving = false + if (event.button_index == MOUSE_BUTTON_LEFT + and event.double_click + and event.is_pressed()): + if DisplayServer.window_maximize_on_title_dbl_click(): + if window.mode == Window.MODE_WINDOWED: + window.mode = Window.MODE_MAXIMIZED + elif window.mode == Window.MODE_MAXIMIZED: + window.mode = Window.MODE_WINDOWED + elif DisplayServer.window_minimize_on_title_dbl_click(): + window.mode = Window.MODE_MINIMIZED + moving = false + + +func _on_title_bar_label_ready() -> void: + var tween = get_tree().create_tween() + modulate = Color.TRANSPARENT + tween.tween_property( + self,"modulate", Color.LIGHT_GRAY, 0.5).set_trans(Tween.TRANS_CUBIC).set_delay(0.15) + + var version = ProjectSettings.get_setting("application/config/actual_release") + var app_name = ProjectSettings.get_setting("application/config/name") + var title_bar_label_text = "%s v%s" % [ app_name, version ] + + $TitleBarLabel.add_theme_font_override("font", title_bar_font) + $TitleBarLabel.add_theme_font_size_override("font_size", 14) + $TitleBarLabel.text = title_bar_label_text diff --git a/material_maker/title_bar.gd.uid b/material_maker/title_bar.gd.uid new file mode 100644 index 000000000..40f45be64 --- /dev/null +++ b/material_maker/title_bar.gd.uid @@ -0,0 +1 @@ +uid://vqcg44elblx8