Skip to content

Commit

Permalink
Started prototyping flexible UI layout
Browse files Browse the repository at this point in the history
  • Loading branch information
RodZill4 committed Nov 20, 2023
1 parent 7bf06c9 commit a935f06
Show file tree
Hide file tree
Showing 12 changed files with 737 additions and 0 deletions.
31 changes: 31 additions & 0 deletions addons/flexible_layout/flexible_dragger.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
extends Control


var dragging : bool = false
var flex_split
var dragger_index : int
var vertical : bool

func _init():
set_meta("flexlayout", true)

func _draw():
draw_rect(Rect2(Vector2(0, 0), size), Color(1, 1, 0))

func set_split(s, i : int, v : bool):
flex_split = s
dragger_index = i
vertical = v

func _on_gui_input(event):
if event is InputEventMouseButton:
if event.button_index == MOUSE_BUTTON_LEFT:
dragging = event.pressed
elif event is InputEventMouseMotion:
if dragging:
if vertical:
position.y += event.position.y-5
flex_split.drag(dragger_index, position.y)
else:
position.x += event.position.x-5
flex_split.drag(dragger_index, position.x)
15 changes: 15 additions & 0 deletions addons/flexible_layout/flexible_dragger.tscn
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[gd_scene load_steps=2 format=3 uid="uid://cucx3oayvvxhu"]

[ext_resource type="Script" path="res://addons/flexible_layout/flexible_dragger.gd" id="1_3i5mx"]

[node name="Dragger" type="Control"]
custom_minimum_size = Vector2(10, 10)
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
script = ExtResource("1_3i5mx")

[connection signal="gui_input" from="." to="." method="_on_gui_input"]
Loading

0 comments on commit a935f06

Please sign in to comment.