1
0
Fork 0
mirror of https://github.com/Orama-Interactive/Pixelorama.git synced 2025-01-18 17:19:50 +00:00
Pixelorama/addons/dockable_container/drag_n_drop_panel.gd
Manolis Papadeas e2bb0b8440
New UI system using Dockable Containers (#640)
* Add dockable container plugin

Experimenting with it, also added a tabs_visible property to the DockableContainer. Removed some code about Tallscreen from Main.gd, but not all of it.

* Add a panel behind the UI, temporarily restore the dark theme

* Remove tallscreen code

* Add edit mode, toggles DockableContainer's tab visibility on and off

* Split tool options into color pickers, left and right tool options

* Remove alternate_transparent_background

* Re-order tool buttons on resize

* Clip content in timeline

* Changes to the tool panel

* Removed some old unused node variables

* Restore Zen mode

* Set tabs_visible = false by default

* Better way to set tabs_visible = false by default

* Added the license of godot-dockable-container

* Remove unneeded lines

* Update README.md

* Restore window transparency with the canvas

It makes all of the TabContainers transparent however, which may not be what we actually want.

* Change tab names of the UI elements

* Remove unneeded nodes from ColorPickers.tscn

* Update default.tres

* Let the user hide elements individually

* Add some checks in HandleThemes

* Center tool icons

* Remove unneeded custom panel in SplashDialog

* Bump version to v0.10-dev and some other minor changes

* Fix crash on Zen Mode

* Added a hacky way to fix the issue with the palette panel size
2022-01-30 00:47:25 +02:00

66 lines
1.7 KiB
GDScript

tool
extends Control
const MARGIN_NONE = -1
var _hover_margin = MARGIN_NONE
func _notification(what: int) -> void:
if what == NOTIFICATION_MOUSE_EXIT:
_hover_margin = MARGIN_NONE
elif what == NOTIFICATION_DRAG_BEGIN:
_hover_margin = MARGIN_NONE
func _gui_input(event: InputEvent) -> void:
if event is InputEventMouseMotion:
_find_hover_margin(event.position)
update()
func _draw() -> void:
var rect
if _hover_margin == MARGIN_NONE:
return
elif _hover_margin == MARGIN_LEFT:
rect = Rect2(0, 0, rect_size.x * 0.5, rect_size.y)
elif _hover_margin == MARGIN_TOP:
rect = Rect2(0, 0, rect_size.x, rect_size.y * 0.5)
elif _hover_margin == MARGIN_RIGHT:
var half_width = rect_size.x * 0.5
rect = Rect2(half_width, 0, half_width, rect_size.y)
elif _hover_margin == MARGIN_BOTTOM:
var half_height = rect_size.y * 0.5
rect = Rect2(0, half_height, rect_size.x, half_height)
var stylebox = get_stylebox("panel", "TooltipPanel")
draw_style_box(stylebox, rect)
func get_hover_margin() -> int:
return _hover_margin
func _find_hover_margin(point: Vector2):
var half_size = rect_size * 0.5
var left = point.distance_squared_to(Vector2(0, half_size.y))
var lesser = left
var lesser_margin = MARGIN_LEFT
var top = point.distance_squared_to(Vector2(half_size.x, 0))
if lesser > top:
lesser = top
lesser_margin = MARGIN_TOP
var right = point.distance_squared_to(Vector2(rect_size.x, half_size.y))
if lesser > right:
lesser = right
lesser_margin = MARGIN_RIGHT
var bottom = point.distance_squared_to(Vector2(half_size.x, rect_size.y))
if lesser > bottom:
#lesser = bottom # unused result
lesser_margin = MARGIN_BOTTOM
_hover_margin = lesser_margin