-
-
Notifications
You must be signed in to change notification settings - Fork 227
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Started prototyping flexible UI layout
- Loading branch information
Showing
12 changed files
with
737 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"] |
Oops, something went wrong.