Skip to content

Vertical-tabs preferences #969

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

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions material_maker/theme/classic.tres
Original file line number Diff line number Diff line change
Expand Up @@ -899,6 +899,11 @@ MM_PanelMenuSubPanelLabel/base_type = &"Label"
MM_PanelMenuSubPanelLabel/colors/font_color = Color(0.881937, 0.881937, 0.881937, 1)
MM_PanelMenuSubPanelLabel/font_sizes/font_size = 15
MM_PanelMenuSubPanelLabel/styles/normal = SubResource("StyleBoxEmpty_5e0gw")
MM_PreferenceMargin/base_type = &"MarginContainer"
MM_PreferenceMargin/constants/margin_bottom = 8
MM_PreferenceMargin/constants/margin_left = 8
MM_PreferenceMargin/constants/margin_right = 8
MM_PreferenceMargin/constants/margin_top = 8
MM_ProjectsBackground/base_type = &"Panel"
MM_ProjectsBackground/styles/panel = SubResource("StyleBoxEmpty_u368o")
MM_Reroute/styles/panel = SubResource("StyleBoxFlat_wc6mb")
Expand Down
5 changes: 5 additions & 0 deletions material_maker/theme/default.tres
Original file line number Diff line number Diff line change
Expand Up @@ -1178,6 +1178,11 @@ MM_PanelMenuSubPanelLabel/base_type = &"Label"
MM_PanelMenuSubPanelLabel/colors/font_color = Color(0.556, 0.556, 0.556, 1)
MM_PanelMenuSubPanelLabel/font_sizes/font_size = 15
MM_PanelMenuSubPanelLabel/styles/normal = SubResource("StyleBoxEmpty_5e0gw")
MM_PreferenceMargin/base_type = &"MarginContainer"
MM_PreferenceMargin/constants/margin_bottom = 8
MM_PreferenceMargin/constants/margin_left = 8
MM_PreferenceMargin/constants/margin_right = 8
MM_PreferenceMargin/constants/margin_top = 8
MM_ProjectsBackground/base_type = &"Panel"
MM_ProjectsBackground/styles/panel = SubResource("StyleBoxFlat_1k0sx")
MM_Reroute/base_type = &"GraphNode"
Expand Down
2 changes: 2 additions & 0 deletions material_maker/windows/preferences/bool_option.gd
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
extends CheckBox

class_name BoolOption

@export var config_variable : String

func _ready() -> void:
Expand Down
2 changes: 1 addition & 1 deletion material_maker/windows/preferences/bool_option.tscn
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[gd_scene load_steps=2 format=3 uid="uid://drg0s4lftblx3"]

[ext_resource type="Script" path="res://material_maker/windows/preferences/bool_option.gd" id="1"]
[ext_resource type="Script" uid="uid://r578e00kfyhy" path="res://material_maker/windows/preferences/bool_option.gd" id="1"]

[node name="BooleanOption" type="CheckBox"]
offset_right = 308.0
Expand Down
2 changes: 2 additions & 0 deletions material_maker/windows/preferences/float_option.gd
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
extends "res://material_maker/widgets/float_edit/float_edit.gd"

class_name FloatOption

@export var config_variable : String

func _ready() -> void:
Expand Down
2 changes: 1 addition & 1 deletion material_maker/windows/preferences/float_option.tscn
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[gd_scene load_steps=3 format=3 uid="uid://3lo2jh781ten"]

[ext_resource type="PackedScene" uid="uid://rflulhsuy3ax" path="res://material_maker/widgets/float_edit/float_edit.tscn" id="1"]
[ext_resource type="Script" path="res://material_maker/windows/preferences/float_option.gd" id="2"]
[ext_resource type="Script" uid="uid://dlpvopqjvlj0i" path="res://material_maker/windows/preferences/float_option.gd" id="2"]

[node name="FloatOption" instance=ExtResource("1")]
script = ExtResource("2")
Expand Down
34 changes: 21 additions & 13 deletions material_maker/windows/preferences/preferences.gd
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ func edit_preferences(c : ConfigFile) -> void:
main_window.add_dialog(self)
config_changed.connect(main_window.on_config_changed)
update_controls(self)
size = $VBoxContainer.get_combined_minimum_size() * content_scale_factor
size *= content_scale_factor
hide()
popup_centered(size)

Expand Down Expand Up @@ -42,16 +42,6 @@ func _on_OK_pressed():
func _on_Cancel_pressed():
queue_free()


func _on_Preferences_about_to_show():
await get_tree().process_frame
_on_VBoxContainer_minimum_size_changed()

func _on_VBoxContainer_minimum_size_changed():
min_size = $VBoxContainer.get_combined_minimum_size() * content_scale_factor
size = min_size


func _on_InstallLanguage_pressed():
var dialog = load("res://material_maker/windows/file_dialog/file_dialog.tscn").instantiate()
dialog.min_size = Vector2(500, 500)
Expand All @@ -65,8 +55,8 @@ func _on_InstallLanguage_pressed():
update_language_list()

func update_language_list():
$VBoxContainer/TabContainer/General/HBoxContainer/Language.init_from_locales()
$VBoxContainer/TabContainer/General/HBoxContainer/Language.init_from_config(config)
%Language.init_from_locales()
%Language.init_from_config(config)

func _on_DownloadLanguage_pressed():
var download_popup = load("res://material_maker/windows/preferences/language_download.tscn").instantiate()
Expand All @@ -77,3 +67,21 @@ func _on_DownloadLanguage_closed():
var locale = load("res://material_maker/locale/locale.gd").new()
locale.read_translations()
update_language_list()


func _on_ready() -> void:
%Tree.clear()
%Tree.hide_root = true
var root : TreeItem = %Tree.create_item()
var sections = []

for child in %TabContainer.get_children():
var item : TreeItem = %Tree.create_item()
item.set_text(0, " " + child.name + " ")
sections.append(item)

%Tree.set_selected(sections[0], 0)


func _on_tree_item_selected() -> void:
%TabContainer.current_tab = %Tree.get_selected().get_index()
Loading