This repository has been archived on 2020-09-30. You can view files and clone it, but cannot push or open issues or pull requests.
odyssey-old/Scenes/UI/Widgets/ResizablePanel.gd
2020-07-20 11:15:39 +02:00

47 lines
1.1 KiB
GDScript

tool
extends Panel
export var title = "Unnamed panel" setget set_title
var dragging = false
var resizing = false
var last_origin = Vector2.ZERO
var last_mouse = Vector2.ZERO
func _handle_drag(event):
if event is InputEventMouseButton:
dragging = event.pressed
last_origin = rect_position
last_mouse = event.global_position
if dragging and event is InputEventMouseMotion:
rect_position = last_origin + (event.global_position - last_mouse)
func _handle_resize(event):
if event is InputEventMouseButton:
resizing = event.pressed
last_origin = rect_size
last_mouse = event.global_position
if resizing and event is InputEventMouseMotion:
rect_size = last_origin + (event.global_position - last_mouse)
func _input(event):
if event is InputEventMouseButton:
if dragging and not event.pressed:
dragging = false
if resizing and not event.pressed:
resizing = false
if not chat_bar_focus:
$LineEdit.release_focus()
func set_title(val):
title = val
$DragHandle/Label.text = title
var chat_bar_focus = false
func _chat_bar_status(editing):
$"/root/scene".writing = editing
func _chat_bar_focus(entered):
chat_bar_focus = entered