Put top menu & ruler styles inside the themes

Instead of using stylebox files.
This commit is contained in:
OverloadedOrama 2020-08-14 00:22:49 +03:00
parent fe2ed42819
commit 79bd015c19
17 changed files with 1453 additions and 1472 deletions

View file

@ -45,28 +45,14 @@ func _on_Theme_pressed(index : int) -> void:
func change_theme(ID : int) -> void:
var font = Global.control.theme.default_font
var main_theme : Theme = themes[ID]
var top_menu_style
var ruler_style
if ID == 0: # Dark Theme
if ID == 0 or ID == 1: # Dark or Gray Theme
Global.theme_type = Global.Theme_Types.DARK
top_menu_style = preload("res://assets/themes/dark/top_menu_style.tres")
ruler_style = preload("res://assets/themes/dark/ruler_style.tres")
elif ID == 1: # Gray Theme
Global.theme_type = Global.Theme_Types.DARK
top_menu_style = preload("res://assets/themes/gray/top_menu_style.tres")
ruler_style = preload("res://assets/themes/dark/ruler_style.tres")
elif ID == 2: # Godot's Theme
Global.theme_type = Global.Theme_Types.BLUE
top_menu_style = preload("res://assets/themes/blue/top_menu_style.tres")
ruler_style = preload("res://assets/themes/blue/ruler_style.tres")
elif ID == 3: # Caramel Theme
Global.theme_type = Global.Theme_Types.CARAMEL
top_menu_style = preload("res://assets/themes/caramel/top_menu_style.tres")
ruler_style = preload("res://assets/themes/caramel/ruler_style.tres")
elif ID == 4: # Light Theme
Global.theme_type = Global.Theme_Types.LIGHT
top_menu_style = preload("res://assets/themes/light/top_menu_style.tres")
ruler_style = preload("res://assets/themes/light/ruler_style.tres")
Global.control.theme = main_theme
Global.control.theme.default_font = font
@ -76,6 +62,8 @@ func change_theme(ID : int) -> void:
var layer_button_panel_container : PanelContainer = Global.find_node_by_name(Global.animation_timeline, "LayerButtonPanelContainer")
(layer_button_panel_container.get_stylebox("panel", "PanelContainer") as StyleBoxFlat).bg_color = default_clear_color
var top_menu_style = main_theme.get_stylebox("TopMenu", "Panel")
var ruler_style = main_theme.get_stylebox("Ruler", "Button")
Global.top_menu_container.add_stylebox_override("panel", top_menu_style)
Global.horizontal_ruler.add_stylebox_override("normal", ruler_style)
Global.horizontal_ruler.add_stylebox_override("pressed", ruler_style)

View file

@ -1,13 +1,11 @@
[gd_scene load_steps=3 format=2]
[gd_scene load_steps=2 format=2]
[ext_resource path="res://assets/themes/dark/top_menu_style.tres" type="StyleBox" id=1]
[ext_resource path="res://src/UI/TopMenuContainer.gd" type="Script" id=2]
[node name="TopMenuContainer" type="Panel"]
margin_right = 1280.0
margin_bottom = 28.0
rect_min_size = Vector2( 0, 28 )
custom_styles/panel = ExtResource( 1 )
script = ExtResource( 2 )
__meta__ = {
"_edit_use_anchors_": false

View file

@ -1,4 +1,4 @@
[gd_scene load_steps=24 format=2]
[gd_scene load_steps=23 format=2]
[ext_resource path="res://src/UI/ToolButtons.gd" type="Script" id=1]
[ext_resource path="res://src/UI/CanvasPreview.tscn" type="PackedScene" id=2]
@ -8,7 +8,6 @@
[ext_resource path="res://src/UI/Rulers/HorizontalRuler.gd" type="Script" id=6]
[ext_resource path="res://src/CameraMovement.gd" type="Script" id=7]
[ext_resource path="res://src/SelectionRectangle.gd" type="Script" id=8]
[ext_resource path="res://assets/themes/dark/ruler_style.tres" type="StyleBox" id=9]
[ext_resource path="res://assets/graphics/dark_themes/tools/bucket.png" type="Texture" id=10]
[ext_resource path="res://assets/graphics/dark_themes/tools/colorpicker.png" type="Texture" id=11]
[ext_resource path="res://assets/graphics/dark_themes/tools/rectselect.png" type="Texture" id=12]
@ -220,20 +219,16 @@ script = ExtResource( 3 )
[node name="HorizontalRuler" type="Button" parent="CanvasAndTimeline/ViewportAndRulers"]
margin_top = 38.0
margin_right = 902.0
margin_bottom = 54.0
margin_bottom = 58.0
rect_min_size = Vector2( 0, 16 )
focus_mode = 0
mouse_default_cursor_shape = 14
custom_styles/hover = ExtResource( 9 )
custom_styles/pressed = ExtResource( 9 )
custom_styles/focus = ExtResource( 9 )
custom_styles/normal = ExtResource( 9 )
action_mode = 0
enabled_focus_mode = 0
script = ExtResource( 6 )
[node name="HSplitContainer" type="HSplitContainer" parent="CanvasAndTimeline/ViewportAndRulers"]
margin_top = 54.0
margin_top = 58.0
margin_right = 902.0
margin_bottom = 480.0
size_flags_vertical = 3
@ -241,23 +236,19 @@ custom_constants/autohide = 0
[node name="ViewportandVerticalRuler" type="HBoxContainer" parent="CanvasAndTimeline/ViewportAndRulers/HSplitContainer"]
margin_right = 890.0
margin_bottom = 426.0
margin_bottom = 422.0
size_flags_horizontal = 3
size_flags_vertical = 3
custom_constants/separation = 0
[node name="VerticalRuler" type="Button" parent="CanvasAndTimeline/ViewportAndRulers/HSplitContainer/ViewportandVerticalRuler"]
margin_right = 16.0
margin_bottom = 426.0
margin_bottom = 422.0
rect_min_size = Vector2( 16, 0 )
focus_mode = 0
mouse_default_cursor_shape = 15
size_flags_horizontal = 0
size_flags_vertical = 3
custom_styles/hover = ExtResource( 9 )
custom_styles/pressed = ExtResource( 9 )
custom_styles/focus = ExtResource( 9 )
custom_styles/normal = ExtResource( 9 )
action_mode = 0
enabled_focus_mode = 0
script = ExtResource( 4 )
@ -265,7 +256,7 @@ script = ExtResource( 4 )
[node name="ViewportContainer" type="ViewportContainer" parent="CanvasAndTimeline/ViewportAndRulers/HSplitContainer/ViewportandVerticalRuler"]
margin_left = 16.0
margin_right = 890.0
margin_bottom = 426.0
margin_bottom = 422.0
focus_mode = 2
mouse_default_cursor_shape = 3
size_flags_horizontal = 3
@ -274,7 +265,7 @@ stretch = true
script = ExtResource( 23 )
[node name="Viewport" type="Viewport" parent="CanvasAndTimeline/ViewportAndRulers/HSplitContainer/ViewportandVerticalRuler/ViewportContainer"]
size = Vector2( 874, 426 )
size = Vector2( 874, 422 )
handle_input_locally = false
usage = 0
render_target_update_mode = 3
@ -300,13 +291,13 @@ script = ExtResource( 8 )
[node name="ViewportContainer2" type="ViewportContainer" parent="CanvasAndTimeline/ViewportAndRulers/HSplitContainer"]
margin_left = 902.0
margin_right = 902.0
margin_bottom = 426.0
margin_bottom = 422.0
size_flags_vertical = 3
stretch = true
script = ExtResource( 23 )
[node name="Viewport" type="Viewport" parent="CanvasAndTimeline/ViewportAndRulers/HSplitContainer/ViewportContainer2"]
size = Vector2( 0, 426 )
size = Vector2( 0, 422 )
handle_input_locally = false
render_target_update_mode = 3