]> Untitled Git - wolf-seeking-sheep.git/blob - addons/dialogic/Editor/Common/toolbar.gd
Squashed commit of the following:
[wolf-seeking-sheep.git] / addons / dialogic / Editor / Common / toolbar.gd
1 @tool
2 extends HBoxContainer
3
4 # Dialogic Editor toolbar. Works together with editors_mangager.
5
6 ################################################################################
7 ##                                      EDITOR BUTTONS/LABELS 
8 ################################################################################
9 func _ready() -> void:
10         if owner.get_parent() is SubViewport:
11                 return
12         %CustomButtons.custom_minimum_size.y = 33 * DialogicUtil.get_editor_scale()
13
14         for child in get_children():
15                 if child is Button:
16                         child.queue_free()
17
18
19 func add_icon_button(icon: Texture, tooltip: String) -> Button:
20         var button := Button.new()
21         button.icon = icon
22         button.tooltip_text = tooltip
23         button.flat = true
24         button.size_flags_vertical = Control.SIZE_SHRINK_BEGIN
25         button.add_theme_color_override('icon_hover_color', get_theme_color('warning_color', 'Editor'))
26         button.add_theme_stylebox_override('focus', StyleBoxEmpty.new())
27         add_child(button)
28         move_child(button, -2)
29         return button
30
31
32 func add_custom_button(label:String, icon:Texture) -> Button:
33         var button := Button.new()
34         button.text = label
35         button.icon = icon
36 #       button.flat = true
37
38         button.size_flags_vertical = Control.SIZE_SHRINK_BEGIN
39         %CustomButtons.add_child(button)
40 #       custom_minimum_size.y = button.size.y
41         return button
42
43
44 func hide_all_custom_buttons() -> void:
45         for button in %CustomButtons.get_children():
46                 button.hide()
47
48
49