47 lines
1.6 KiB
GDScript3
47 lines
1.6 KiB
GDScript3
|
extends Control
|
||
|
|
||
|
|
||
|
const MAX_WIDTH = 1280
|
||
|
|
||
|
onready var margin_container = get_node("Panel/MarginContainer")
|
||
|
|
||
|
|
||
|
func _ready():
|
||
|
# warning-ignore:return_value_discarded
|
||
|
Users.connect("switched", self, "_on_user_switched")
|
||
|
Users.emit_signal("switched")
|
||
|
|
||
|
|
||
|
func _on_user_switched():
|
||
|
theme.get_stylebox("panel", "Panel").bg_color = Users.get_current().background_color
|
||
|
theme.get_stylebox("panel", "PanelContainer").bg_color = Users.get_current().panel_color
|
||
|
theme.get_stylebox("panel", "PopupMenu").bg_color = Users.get_current().popup_menu_color
|
||
|
theme.get_stylebox("grabber", "VScrollBar").bg_color = Users.get_current().scroll_bar_color
|
||
|
theme.get_stylebox("grabber_highlight", "VScrollBar").bg_color = Users.get_current().scroll_bar_highlight_color
|
||
|
theme.get_stylebox("grabber_pressed", "VScrollBar").bg_color = Users.get_current().scroll_bar_pressed_color
|
||
|
|
||
|
|
||
|
func _on_resized():
|
||
|
if !margin_container:
|
||
|
return
|
||
|
|
||
|
var left_margin = theme.get_constant("margin_left", "MarginContainer")
|
||
|
var right_margin = theme.get_constant("margin_right", "MarginContainer")
|
||
|
|
||
|
var content_width = rect_size.x - left_margin - right_margin
|
||
|
|
||
|
if content_width >= MAX_WIDTH:
|
||
|
var difference = content_width - MAX_WIDTH
|
||
|
var additional_margin = 0.5 * difference
|
||
|
|
||
|
margin_container.add_constant_override(
|
||
|
"margin_left", left_margin + additional_margin
|
||
|
)
|
||
|
margin_container.add_constant_override(
|
||
|
"margin_right", right_margin + additional_margin
|
||
|
)
|
||
|
else:
|
||
|
margin_container.add_constant_override("margin_left", left_margin)
|
||
|
margin_container.add_constant_override("margin_right", right_margin)
|
||
|
|