47 lines
1.1 KiB
GDScript
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
|