2018-08-01 13:40:37 +00:00
|
|
|
extends MarginContainer
|
|
|
|
|
|
|
|
export(bool) var is_movable = true
|
|
|
|
export(bool) var is_resizable = true
|
|
|
|
export(bool) var is_borderless = false
|
|
|
|
export(String) var title = "Window"
|
|
|
|
export(Color) var background_color = Color( 1.0, 1.0, 1.0, 1.0 )
|
2018-08-16 12:53:10 +00:00
|
|
|
|
|
|
|
export(String) var background_texture = "res://assets/GUI/images/background_test.png"
|
|
|
|
|
|
|
|
signal window_clicked( window )
|
|
|
|
|
2018-08-17 09:00:27 +00:00
|
|
|
onready var header_box = $parts/header_box
|
|
|
|
onready var content_box = $parts/content_box
|
|
|
|
onready var footer_box = $parts/footer_box
|
|
|
|
|
2018-08-01 13:40:37 +00:00
|
|
|
var current_rect_size = Vector2( 0, 0 )
|
|
|
|
var current_rect_position = Vector2( -1, -1 )
|
|
|
|
var is_resizing = false
|
|
|
|
var is_moving = false
|
|
|
|
|
2018-08-17 09:00:27 +00:00
|
|
|
func add_child( node):
|
|
|
|
if self.get_content():
|
|
|
|
self.get_content().add_child(node)
|
|
|
|
# else:
|
|
|
|
# .add_child( node )
|
|
|
|
# prints(self.get_name()+" just fathered", node.get_name())
|
|
|
|
|
|
|
|
func add_window_part( node ):
|
|
|
|
.add_child( node )
|
|
|
|
|
2018-08-16 12:53:10 +00:00
|
|
|
func set_mouse_pass_to_children( node ):
|
|
|
|
for child in node.get_children():
|
|
|
|
set_mouse_pass_to_children( child )
|
|
|
|
if node is Control:
|
|
|
|
node.mouse_filter = MOUSE_FILTER_PASS
|
|
|
|
|
2018-08-05 12:47:18 +00:00
|
|
|
#func _ready():
|
|
|
|
func _enter_tree():
|
2018-08-17 09:00:27 +00:00
|
|
|
########
|
|
|
|
#### Window's part création.
|
|
|
|
# The interal elements structure is:
|
|
|
|
# self - MarginContainer
|
|
|
|
# background - NinePatchRect
|
|
|
|
# parts - VBoxContainer
|
|
|
|
# header_box - MarginContainer
|
|
|
|
# header - HBoxContainer
|
|
|
|
# quit - TextureButton
|
|
|
|
# close - TextureButton
|
|
|
|
# open - TextureButton
|
|
|
|
# label - Label
|
|
|
|
# content_box - MarginContainer
|
|
|
|
# scroll_container - Scrollcontainer
|
|
|
|
# content - VBoxContainer
|
|
|
|
# footer_box - MarginContainer
|
|
|
|
# footer - HBoxContainer
|
|
|
|
# contextual_help - Label
|
|
|
|
# resize - TextureButton
|
|
|
|
|
2018-08-01 13:40:37 +00:00
|
|
|
###
|
|
|
|
# self
|
|
|
|
self.size_flags_horizontal = SIZE_EXPAND
|
|
|
|
self.size_flags_vertical = SIZE_EXPAND
|
|
|
|
|
|
|
|
self.set( "custom_constants/margin_right", 0)
|
|
|
|
self.set( "custom_constants/margin_top", 0)
|
|
|
|
self.set( "custom_constants/margin_left", 0)
|
|
|
|
self.set( "custom_constants/margin_bottom", 0)
|
2018-08-16 12:53:10 +00:00
|
|
|
|
|
|
|
|
|
|
|
self.connect ( "gui_input", self, "_on_window_gui_input" )
|
2018-08-01 13:40:37 +00:00
|
|
|
###
|
|
|
|
###
|
2018-08-17 09:00:27 +00:00
|
|
|
# background
|
2018-08-05 12:47:18 +00:00
|
|
|
var background
|
2018-08-17 09:00:27 +00:00
|
|
|
if not self.has_node( "background" ):
|
2018-08-05 12:47:18 +00:00
|
|
|
background = NinePatchRect.new()
|
2018-08-17 09:00:27 +00:00
|
|
|
background.name = "background"
|
2018-08-05 12:47:18 +00:00
|
|
|
var background_image = Image.new()
|
2018-08-16 12:53:10 +00:00
|
|
|
if not background_image.load( background_texture ):
|
|
|
|
print("Erreur lors du chargement de l'image: "+background_texture )
|
2018-08-05 12:47:18 +00:00
|
|
|
background.texture = ImageTexture.new()
|
|
|
|
background.texture.create_from_image( background_image )
|
2018-08-16 12:53:10 +00:00
|
|
|
background.texture.flags = Texture.FLAG_FILTER | Texture.FLAG_REPEAT
|
2018-08-05 12:47:18 +00:00
|
|
|
background.axis_stretch_horizontal = NinePatchRect.AXIS_STRETCH_MODE_TILE
|
|
|
|
background.axis_stretch_vertical = NinePatchRect.AXIS_STRETCH_MODE_TILE
|
|
|
|
|
|
|
|
background.size_flags_horizontal = SIZE_EXPAND_FILL
|
|
|
|
background.size_flags_vertical = SIZE_EXPAND_FILL
|
|
|
|
|
2018-08-16 12:55:15 +00:00
|
|
|
background.region_rect = Rect2( 0, 0, 0, 0 )
|
2018-08-05 12:47:18 +00:00
|
|
|
background.patch_margin_left = 4
|
|
|
|
background.patch_margin_top = 32
|
|
|
|
background.patch_margin_right = 4
|
2018-08-16 12:53:10 +00:00
|
|
|
background.patch_margin_bottom = 4
|
2018-08-05 12:47:18 +00:00
|
|
|
|
|
|
|
background.self_modulate = background_color
|
|
|
|
|
2018-08-17 09:00:27 +00:00
|
|
|
self.add_window_part( background )
|
2018-08-05 12:47:18 +00:00
|
|
|
background.set_owner( self )
|
|
|
|
###
|
2018-08-01 13:40:37 +00:00
|
|
|
###
|
2018-08-17 09:00:27 +00:00
|
|
|
# parts
|
|
|
|
var parts
|
|
|
|
if not self.has_node( "parts" ):
|
|
|
|
parts = VBoxContainer.new()
|
|
|
|
parts.name = "parts"
|
|
|
|
parts.size_flags_horizontal = SIZE_EXPAND_FILL
|
|
|
|
parts.size_flags_vertical = SIZE_EXPAND_FILL
|
|
|
|
self.add_window_part( parts )
|
|
|
|
parts.set_owner( self )
|
|
|
|
###
|
|
|
|
###
|
|
|
|
# header_box
|
|
|
|
var header_box
|
|
|
|
if not parts.has_node( "header_box" ):
|
|
|
|
header_box = MarginContainer.new()
|
|
|
|
header_box.name = "header_box"
|
|
|
|
header_box.size_flags_horizontal = SIZE_EXPAND_FILL
|
|
|
|
header_box.size_flags_vertical = SIZE_SHRINK_CENTER
|
2018-08-05 12:47:18 +00:00
|
|
|
|
2018-08-17 09:00:27 +00:00
|
|
|
header_box.set( "custom_constants/margin_right", 0)
|
|
|
|
header_box.set( "custom_constants/margin_top", 4)
|
|
|
|
header_box.set( "custom_constants/margin_left", 4)
|
|
|
|
header_box.set( "custom_constants/margin_bottom", 4)
|
2018-08-05 12:47:18 +00:00
|
|
|
|
|
|
|
if is_movable:
|
2018-08-17 09:00:27 +00:00
|
|
|
header_box.mouse_default_cursor_shape = CURSOR_MOVE
|
|
|
|
parts.add_child( header_box )
|
|
|
|
header_box.set_owner( parts )
|
|
|
|
header_box.connect ( "gui_input", self, "_on_Header_gui_input" )
|
|
|
|
###
|
2018-08-05 12:47:18 +00:00
|
|
|
###
|
2018-08-17 09:00:27 +00:00
|
|
|
# header
|
|
|
|
var header
|
|
|
|
if not header_box.has_node( "header" ):
|
|
|
|
header = HBoxContainer.new()
|
|
|
|
header.name = "header"
|
|
|
|
header.size_flags_horizontal = SIZE_EXPAND_FILL
|
|
|
|
header.size_flags_vertical = SIZE_EXPAND | SIZE_SHRINK_CENTER
|
2018-08-05 12:47:18 +00:00
|
|
|
if is_movable:
|
|
|
|
header.mouse_default_cursor_shape = CURSOR_MOVE
|
2018-08-17 09:00:27 +00:00
|
|
|
header_box.add_child( header )
|
|
|
|
header.set_owner( header )
|
|
|
|
###
|
2018-08-01 13:40:37 +00:00
|
|
|
###
|
2018-08-17 09:00:27 +00:00
|
|
|
# quit
|
2018-08-05 12:47:18 +00:00
|
|
|
var quit_button
|
2018-08-17 09:00:27 +00:00
|
|
|
if not header.has_node( "quit" ):
|
2018-08-05 12:47:18 +00:00
|
|
|
quit_button = TextureButton.new()
|
2018-08-17 09:00:27 +00:00
|
|
|
quit_button.name = "quit"
|
2018-08-05 12:47:18 +00:00
|
|
|
quit_button.size_flags_horizontal = SIZE_SHRINK_END
|
|
|
|
quit_button.size_flags_vertical = SIZE_SHRINK_CENTER
|
|
|
|
|
|
|
|
var tex_quit = ImageTexture.new()
|
|
|
|
var img_quit = Image.new()
|
|
|
|
img_quit.load( "res://assets/GUI/images/button_quit.png" )
|
|
|
|
tex_quit.create_from_image( img_quit )
|
|
|
|
quit_button.texture_normal = tex_quit
|
|
|
|
|
2018-08-17 09:00:27 +00:00
|
|
|
header.add_child( quit_button )
|
|
|
|
quit_button.set_owner( header )
|
2018-08-05 12:47:18 +00:00
|
|
|
quit_button.connect ( "pressed", self, "_on_Quit_pressed" )
|
2018-08-17 09:00:27 +00:00
|
|
|
###
|
|
|
|
# close
|
2018-08-01 13:40:37 +00:00
|
|
|
var close_button = TextureButton.new()
|
2018-08-17 09:00:27 +00:00
|
|
|
if not header.has_node( "close" ):
|
2018-08-05 12:47:18 +00:00
|
|
|
close_button = TextureButton.new()
|
2018-08-17 09:00:27 +00:00
|
|
|
close_button.name = "close"
|
2018-08-05 12:47:18 +00:00
|
|
|
close_button.size_flags_horizontal = SIZE_SHRINK_END
|
|
|
|
close_button.size_flags_vertical = SIZE_SHRINK_CENTER
|
|
|
|
|
|
|
|
var tex_close = ImageTexture.new()
|
|
|
|
var img_close = Image.new()
|
|
|
|
img_close.load( "res://assets/GUI/images/button_close.png" )
|
|
|
|
tex_close.create_from_image( img_close )
|
|
|
|
close_button.texture_normal = tex_close
|
|
|
|
|
2018-08-17 09:00:27 +00:00
|
|
|
header.add_child( close_button )
|
|
|
|
close_button.set_owner( header )
|
2018-08-05 12:47:18 +00:00
|
|
|
close_button.connect ( "pressed", self, "_on_Close_pressed" )
|
2018-08-17 09:00:27 +00:00
|
|
|
###
|
|
|
|
# open
|
2018-08-05 12:47:18 +00:00
|
|
|
var open_button
|
2018-08-17 09:00:27 +00:00
|
|
|
if not header.has_node( "open" ):
|
2018-08-05 12:47:18 +00:00
|
|
|
open_button = TextureButton.new()
|
2018-08-17 09:00:27 +00:00
|
|
|
open_button.name = "open"
|
2018-08-05 12:47:18 +00:00
|
|
|
open_button.size_flags_horizontal = SIZE_SHRINK_END
|
|
|
|
open_button.size_flags_vertical = SIZE_SHRINK_CENTER
|
|
|
|
|
|
|
|
var tex_open = ImageTexture.new()
|
|
|
|
var img_open = Image.new()
|
|
|
|
img_open.load( "res://assets/GUI/images/button_open.png" )
|
|
|
|
tex_open.create_from_image( img_open )
|
|
|
|
open_button.texture_normal = tex_open
|
|
|
|
open_button.visible = false
|
2018-08-17 09:00:27 +00:00
|
|
|
header.add_child( open_button )
|
|
|
|
open_button.set_owner( header )
|
2018-08-05 12:47:18 +00:00
|
|
|
open_button.connect ( "pressed", self, "_on_Open_pressed" )
|
2018-08-17 09:00:27 +00:00
|
|
|
###
|
2018-08-01 13:40:37 +00:00
|
|
|
###
|
|
|
|
# Title Label
|
2018-08-05 12:47:18 +00:00
|
|
|
var title_label
|
2018-08-17 09:00:27 +00:00
|
|
|
if not header.has_node( "label" ):
|
2018-08-05 12:47:18 +00:00
|
|
|
title_label = Label.new()
|
2018-08-17 09:00:27 +00:00
|
|
|
title_label.name = "label"
|
2018-08-05 12:47:18 +00:00
|
|
|
title_label.text = title
|
|
|
|
title_label.size_flags_horizontal = SIZE_EXPAND_FILL
|
|
|
|
title_label.size_flags_vertical = SIZE_SHRINK_CENTER
|
|
|
|
if is_movable:
|
|
|
|
title_label.mouse_default_cursor_shape = CURSOR_MOVE
|
2018-08-17 09:00:27 +00:00
|
|
|
header.add_child( title_label )
|
|
|
|
title_label.set_owner( header )
|
|
|
|
###
|
2018-08-01 13:40:37 +00:00
|
|
|
###
|
|
|
|
# Content
|
2018-08-17 09:00:27 +00:00
|
|
|
var content_box
|
|
|
|
if not parts.has_node( "content_box" ):
|
|
|
|
content_box = MarginContainer.new()
|
|
|
|
content_box.name = "content_box"
|
|
|
|
content_box.size_flags_horizontal = SIZE_EXPAND_FILL
|
|
|
|
content_box.size_flags_vertical = SIZE_EXPAND_FILL
|
|
|
|
content_box.set( "custom_constants/margin_right", 8)
|
|
|
|
content_box.set( "custom_constants/margin_top", 8)
|
|
|
|
content_box.set( "custom_constants/margin_left", 8)
|
|
|
|
content_box.set( "custom_constants/margin_bottom", 8)
|
|
|
|
parts.add_child( content_box )
|
|
|
|
content_box.set_owner( parts )
|
|
|
|
###
|
|
|
|
###
|
|
|
|
# content_box/scroll_container
|
|
|
|
var content_scroll_container
|
|
|
|
if not content_box.has_node( "scroll_container" ):
|
|
|
|
content_scroll_container = ScrollContainer.new()
|
|
|
|
content_scroll_container.name = "scroll_container"
|
|
|
|
content_scroll_container.size_flags_horizontal = SIZE_FILL
|
|
|
|
content_scroll_container.size_flags_vertical = SIZE_FILL
|
2018-08-18 08:22:19 +00:00
|
|
|
content_scroll_container.scroll_deadzone = 0
|
2018-08-17 09:00:27 +00:00
|
|
|
content_box.add_child( content_scroll_container )
|
|
|
|
content_scroll_container.set_owner( content_box )
|
|
|
|
###
|
|
|
|
###
|
|
|
|
# content
|
2018-08-05 12:47:18 +00:00
|
|
|
var content
|
2018-08-17 09:00:27 +00:00
|
|
|
if not content_scroll_container.has_node( "content" ):
|
|
|
|
content = VBoxContainer.new()
|
|
|
|
content.name = "content"
|
2018-08-05 12:47:18 +00:00
|
|
|
content.size_flags_horizontal = SIZE_EXPAND_FILL
|
|
|
|
content.size_flags_vertical = SIZE_EXPAND_FILL
|
2018-08-17 09:00:27 +00:00
|
|
|
content_scroll_container.add_child( content )
|
|
|
|
content.set_owner( content_scroll_container )
|
|
|
|
###
|
|
|
|
|
|
|
|
|
2018-08-01 13:40:37 +00:00
|
|
|
###
|
|
|
|
# Footer
|
2018-08-05 12:47:18 +00:00
|
|
|
var footer_box
|
2018-08-17 09:00:27 +00:00
|
|
|
if not parts.has_node( "footer_box" ):
|
|
|
|
footer_box = MarginContainer.new()
|
|
|
|
footer_box.name = "footer_box"
|
2018-08-05 12:47:18 +00:00
|
|
|
footer_box.size_flags_horizontal = SIZE_FILL
|
|
|
|
footer_box.size_flags_vertical = SIZE_FILL
|
2018-08-17 09:00:27 +00:00
|
|
|
footer_box.set( "custom_constants/margin_right", 6)
|
|
|
|
footer_box.set( "custom_constants/margin_top", 2)
|
|
|
|
footer_box.set( "custom_constants/margin_left", 6)
|
|
|
|
footer_box.set( "custom_constants/margin_bottom", 6)
|
|
|
|
parts.add_child( footer_box )
|
|
|
|
footer_box.set_owner( parts )
|
|
|
|
###
|
|
|
|
###
|
2018-08-17 18:41:03 +00:00
|
|
|
# footer_box/footer
|
2018-08-17 09:00:27 +00:00
|
|
|
var footer
|
|
|
|
if not footer_box.has_node( "footer" ):
|
|
|
|
footer = HBoxContainer.new()
|
|
|
|
footer.name = "footer"
|
2018-08-17 18:41:03 +00:00
|
|
|
footer.size_flags_horizontal = SIZE_EXPAND_FILL
|
|
|
|
footer.size_flags_vertical = SIZE_EXPAND_FILL
|
2018-08-17 09:00:27 +00:00
|
|
|
footer_box.add_child( footer )
|
|
|
|
footer.set_owner( footer_box )
|
2018-08-01 13:40:37 +00:00
|
|
|
###
|
2018-08-17 18:41:03 +00:00
|
|
|
###
|
|
|
|
# footer_label
|
|
|
|
var footer_label
|
|
|
|
if not footer.has_node( "footer_label" ):
|
|
|
|
footer_label = Label.new()
|
|
|
|
footer_label.name = "footer_label"
|
|
|
|
footer_label.size_flags_horizontal = SIZE_EXPAND
|
|
|
|
footer_label.size_flags_vertical = SIZE_EXPAND
|
|
|
|
|
|
|
|
footer.add_child( footer_label )
|
|
|
|
|
|
|
|
###
|
|
|
|
# resize
|
2018-08-05 12:47:18 +00:00
|
|
|
var resize_button
|
2018-08-17 18:41:03 +00:00
|
|
|
if not footer.has_node( "resize" ):
|
2018-08-05 12:47:18 +00:00
|
|
|
resize_button = TextureButton.new()
|
2018-08-17 18:41:03 +00:00
|
|
|
resize_button.name = "resize"
|
|
|
|
resize_button.size_flags_horizontal = SIZE_FILL | SIZE_SHRINK_END
|
|
|
|
resize_button.size_flags_vertical = SIZE_SHRINK_END
|
2018-08-05 12:47:18 +00:00
|
|
|
|
|
|
|
var tex_resize = ImageTexture.new()
|
|
|
|
var img_resize = Image.new()
|
|
|
|
img_resize.load( "res://assets/GUI/images/button_resize.png" )
|
|
|
|
tex_resize.create_from_image( img_resize )
|
|
|
|
resize_button.texture_normal = tex_resize
|
|
|
|
resize_button.mouse_default_cursor_shape = CURSOR_FDIAGSIZE
|
|
|
|
resize_button.action_mode = Button.ACTION_MODE_BUTTON_PRESS
|
2018-08-17 18:41:03 +00:00
|
|
|
footer.add_child( resize_button )
|
|
|
|
resize_button.set_owner( footer )
|
2018-08-05 12:47:18 +00:00
|
|
|
resize_button.connect ( "pressed", self, "_on_Resize_pressed" )
|
2018-08-17 18:41:03 +00:00
|
|
|
###er_label.set_owner( footer )
|
|
|
|
###
|
2018-08-05 12:47:18 +00:00
|
|
|
|
2018-08-01 13:40:37 +00:00
|
|
|
current_rect_size = self.rect_min_size
|
|
|
|
|
|
|
|
if is_borderless:
|
2018-08-17 18:41:03 +00:00
|
|
|
$background.region_rect = Rect2( $background.patch_margin_left-1
|
|
|
|
, $background.patch_margin_top-1
|
|
|
|
, 256-($background.patch_margin_left+$background.patch_margin_right)+2
|
|
|
|
, 256-($background.patch_margin_top+$background.patch_margin_bottom)+2 )
|
|
|
|
$background.patch_margin_left = 1
|
|
|
|
$background.patch_margin_top = 1
|
|
|
|
$background.patch_margin_right = 1
|
|
|
|
$background.patch_margin_bottom = 1
|
|
|
|
close_button.visible = false
|
|
|
|
open_button.visible = false
|
|
|
|
quit_button.visible = false
|
|
|
|
title_label.visible = false
|
|
|
|
|
|
|
|
|
|
|
|
|
2018-08-17 09:00:27 +00:00
|
|
|
|
2018-08-01 13:40:37 +00:00
|
|
|
if not is_resizable:
|
2018-08-17 09:00:27 +00:00
|
|
|
$v_box_container/Footer/HBoxContainer/Resize.visible = false
|
2018-08-01 13:40:37 +00:00
|
|
|
|
2018-08-16 12:53:10 +00:00
|
|
|
func _ready():
|
2018-08-17 09:00:27 +00:00
|
|
|
# On déplace les enfants ajouter via l'editeur sous content.
|
|
|
|
for child in self.get_children():
|
|
|
|
if not child.name =="parts" and not child.name =="background":
|
2018-08-17 18:41:03 +00:00
|
|
|
if child.name.begins_with( "footer_" ):
|
|
|
|
if footer_box.get_node("footer").has_node("footer_label"):
|
|
|
|
footer_box.get_node("footer").remove_child( footer_box.get_node("footer").get_node("footer_label") )
|
|
|
|
|
|
|
|
self.remove_child( child )
|
|
|
|
get_footer().add_child( child )
|
|
|
|
get_footer().move_child( child, 0 )
|
|
|
|
else:
|
|
|
|
self.remove_child( child )
|
|
|
|
get_content().add_child( child )
|
2018-08-17 09:00:27 +00:00
|
|
|
|
2018-08-17 18:41:03 +00:00
|
|
|
set_mouse_pass_to_children( self )
|
2018-08-17 09:00:27 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
2018-08-01 13:40:37 +00:00
|
|
|
func _on_Window_mouse_entered():
|
|
|
|
print("mouse_entered")
|
|
|
|
|
|
|
|
|
|
|
|
func _on_Window_focus_entered():
|
|
|
|
print("focus_entered")
|
|
|
|
|
|
|
|
|
|
|
|
func _on_Quit_pressed():
|
|
|
|
self.visible = false
|
|
|
|
|
|
|
|
func get_content():
|
2018-08-17 09:00:27 +00:00
|
|
|
return content_box.get_node( "scroll_container/content" )
|
2018-08-01 13:40:37 +00:00
|
|
|
|
2018-08-17 18:41:03 +00:00
|
|
|
func get_footer():
|
|
|
|
return footer_box.get_node( "footer" )
|
2018-08-01 13:40:37 +00:00
|
|
|
|
|
|
|
|
|
|
|
func close():
|
|
|
|
if not is_borderless:
|
2018-08-17 09:00:27 +00:00
|
|
|
header_box.get_node( "header/close" ).visible = false
|
|
|
|
header_box.get_node( "header/open" ).visible = true
|
|
|
|
content_box.visible = false
|
|
|
|
footer_box.visible = false
|
2018-08-01 13:40:37 +00:00
|
|
|
current_rect_size = self.rect_size
|
|
|
|
self.rect_size = Vector2( 0, 0 )
|
|
|
|
else:
|
2018-08-17 09:00:27 +00:00
|
|
|
header_box.get_node( "header/close" ).visible = false
|
|
|
|
header_box.get_node( "header/open" ).visible = false
|
|
|
|
content_box.visible = false
|
|
|
|
footer_box.visible = false
|
2018-08-01 13:40:37 +00:00
|
|
|
current_rect_size = self.rect_size
|
|
|
|
self.rect_size = Vector2( 0, 0 )
|
|
|
|
|
|
|
|
|
|
|
|
func _on_Close_pressed():
|
|
|
|
close()
|
|
|
|
|
|
|
|
func open():
|
|
|
|
if not is_borderless:
|
2018-08-17 09:00:27 +00:00
|
|
|
header_box.get_node( "header/close" ).visible = true
|
|
|
|
header_box.get_node( "header/open" ).visible = false
|
|
|
|
content_box.visible = true
|
|
|
|
footer_box.visible = true
|
2018-08-01 13:40:37 +00:00
|
|
|
self.rect_size = current_rect_size
|
|
|
|
else:
|
2018-08-17 09:00:27 +00:00
|
|
|
header_box.get_node( "header/close" ).visible = false
|
|
|
|
header_box.get_node( "header/open" ).visible = false
|
|
|
|
content_box.visible = true
|
|
|
|
footer_box.visible = true
|
2018-08-01 13:40:37 +00:00
|
|
|
self.rect_size = current_rect_size
|
|
|
|
|
|
|
|
func _on_Open_pressed():
|
|
|
|
open()
|
|
|
|
|
|
|
|
func _on_Resize_pressed():
|
|
|
|
is_resizing = true
|
|
|
|
|
|
|
|
func _input( event ):
|
|
|
|
if is_resizable:
|
|
|
|
if is_resizing and event is InputEventMouseButton and not event.pressed:
|
|
|
|
is_resizing = false
|
|
|
|
if event is InputEventMouseMotion and is_resizing:
|
|
|
|
var delta = event.relative
|
|
|
|
self.rect_size += delta
|
2018-08-16 12:53:10 +00:00
|
|
|
|
|
|
|
func check_if_clicked( event ):
|
|
|
|
if not is_moving and event is InputEventMouseButton and event.is_pressed() and not event.is_echo() and event.button_index == 1 :
|
|
|
|
emit_signal( "window_clicked", self )
|
|
|
|
|
|
|
|
func _on_Header_gui_input( event ):
|
|
|
|
|
|
|
|
check_if_clicked( event )
|
|
|
|
|
2018-08-01 13:40:37 +00:00
|
|
|
if is_movable:
|
2018-08-16 12:53:10 +00:00
|
|
|
if is_moving and event is InputEventMouseButton and not event.pressed:
|
2018-08-01 13:40:37 +00:00
|
|
|
is_moving = false
|
2018-08-16 12:53:10 +00:00
|
|
|
elif not is_moving and event is InputEventMouseButton and event.pressed:
|
2018-08-01 13:40:37 +00:00
|
|
|
is_moving = true
|
2018-08-16 12:53:10 +00:00
|
|
|
if event is InputEventMouseMotion and is_moving:
|
|
|
|
var delta = event.relative
|
2018-08-01 13:40:37 +00:00
|
|
|
self.rect_position += delta
|
|
|
|
|
2018-08-16 12:53:10 +00:00
|
|
|
func _on_window_gui_input( event ):
|
|
|
|
check_if_clicked( event )
|
|
|
|
|
2018-08-01 13:40:37 +00:00
|
|
|
func load_from_file( config_file ):
|
|
|
|
if config_file.has_section( self.name ):
|
|
|
|
self.rect_position = config_file.get_value( self.name, "position" )
|
|
|
|
self.rect_size = config_file.get_value( self.name, "size" )
|
|
|
|
self.is_borderless = config_file.get_value( self.name, "borderless" )
|
|
|
|
current_rect_position = self.rect_position
|
|
|
|
current_rect_size = self.rect_size
|
|
|
|
if config_file.get_value( self.name, "opened" ):
|
|
|
|
open()
|
|
|
|
else:
|
|
|
|
close()
|
|
|
|
|
|
|
|
|
|
|
|
func save_to_file( config_file ):
|
|
|
|
|
2018-08-17 09:11:24 +00:00
|
|
|
var is_open = content_box.visible
|
2018-08-01 13:40:37 +00:00
|
|
|
|
|
|
|
config_file.set_value(self.name, "position", self.rect_position)
|
|
|
|
|
|
|
|
if not is_open:
|
|
|
|
config_file.set_value(self.name, "size", current_rect_size)
|
|
|
|
else:
|
|
|
|
config_file.set_value(self.name, "size", self.rect_size)
|
|
|
|
|
|
|
|
if is_open:
|
|
|
|
config_file.set_value(self.name, "opened", true)
|
|
|
|
else:
|
|
|
|
config_file.set_value(self.name, "opened", false)
|
|
|
|
|
|
|
|
config_file.set_value(self.name, "borderless", is_borderless)
|
|
|
|
|