Skip to content

Commit

Permalink
More progress on flexible layout control
Browse files Browse the repository at this point in the history
  • Loading branch information
RodZill4 committed Nov 22, 2023
1 parent 6d258f4 commit c16527e
Show file tree
Hide file tree
Showing 8 changed files with 220 additions and 11 deletions.
46 changes: 46 additions & 0 deletions addons/flexible_layout/arrow.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
37 changes: 37 additions & 0 deletions addons/flexible_layout/arrow.svg.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
[remap]

importer="texture"
type="CompressedTexture2D"
uid="uid://c2ljin3axj2sd"
path="res://.godot/imported/arrow.svg-e1254f39413b91d100a308431d762230.ctex"
metadata={
"vram_texture": false
}

[deps]

source_file="res://addons/flexible_layout/arrow.svg"
dest_files=["res://.godot/imported/arrow.svg-e1254f39413b91d100a308431d762230.ctex"]

[params]

compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1
svg/scale=1.0
editor/scale_with_editor_scale=false
editor/convert_colors_with_editor_theme=false
9 changes: 6 additions & 3 deletions addons/flexible_layout/flexible_dragger.gd
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,16 @@ 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
if vertical:
mouse_default_cursor_shape = Control.CURSOR_VSPLIT
$TextureRect.texture = get_theme_icon("grabber", "VSplitContainer")
else:
mouse_default_cursor_shape = Control.CURSOR_HSPLIT
$TextureRect.texture = get_theme_icon("grabber", "HSplitContainer")

func _on_gui_input(event):
if event is InputEventMouseButton:
Expand Down
22 changes: 16 additions & 6 deletions addons/flexible_layout/flexible_dragger.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,24 @@

[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
[node name="Dragger" type="HBoxContainer"]
anchors_preset = 8
anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
grow_horizontal = 2
grow_vertical = 2
script = ExtResource("1_3i5mx")

[node name="TextureRect" type="TextureRect" parent="."]
visible = false
layout_mode = 2
size_flags_horizontal = 6
size_flags_vertical = 4
mouse_filter = 2
stretch_mode = 2

[connection signal="gui_input" from="." to="." method="_on_gui_input"]
[connection signal="mouse_entered" from="." to="TextureRect" method="show"]
[connection signal="mouse_exited" from="." to="TextureRect" method="hide"]
10 changes: 10 additions & 0 deletions addons/flexible_layout/flexible_overlay.gd
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
extends ColorRect


var arrow_icon = preload("res://addons/flexible_layout/arrow.svg")
var tab_icon = preload("res://addons/flexible_layout/tab.svg")


func find_position_from_target(at_position, target):
const POSITIONS = [ -1, 1, -1, 2, 0, 3, -1, 4, -1]
var pos_x = int(3*(at_position.x-target.rect.position.x) / target.rect.size.x)
Expand All @@ -23,22 +28,27 @@ func _can_drop_data(at_position, data):
$Arrow.visible = false
return false
$Arrow.visible = true
$Arrow.texture = tab_icon
$Arrow.position = rect.get_center()-Vector2(32, 32)
$Arrow.rotation_degrees = 0
1:
$Arrow.visible = true
$Arrow.texture = arrow_icon
$Arrow.position = Vector2(rect.get_center().x-32, rect.position.y)
$Arrow.rotation_degrees = 0
2:
$Arrow.visible = true
$Arrow.texture = arrow_icon
$Arrow.position = Vector2(rect.position.x, rect.get_center().y-32)
$Arrow.rotation_degrees = -90
3:
$Arrow.visible = true
$Arrow.texture = arrow_icon
$Arrow.position = Vector2(rect.end.x-64, rect.get_center().y-32)
$Arrow.rotation_degrees = 90
4:
$Arrow.visible = true
$Arrow.texture = arrow_icon
$Arrow.position = Vector2(rect.get_center().x-32, rect.end.y-64)
$Arrow.rotation_degrees = 180
_:
Expand Down
4 changes: 2 additions & 2 deletions addons/flexible_layout/flexible_overlay.tscn
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[gd_scene load_steps=3 format=3 uid="uid://gqucl1dthw6d"]

[ext_resource type="Script" path="res://addons/flexible_layout/flexible_overlay.gd" id="1_5tomg"]
[ext_resource type="Texture2D" uid="uid://0gespyud2ad" path="res://icon.png" id="2_5qmj0"]
[ext_resource type="Texture2D" uid="uid://c2ljin3axj2sd" path="res://addons/flexible_layout/arrow.svg" id="2_0tnc1"]

[node name="Control" type="ColorRect"]
anchors_preset = 15
Expand All @@ -18,4 +18,4 @@ layout_mode = 0
offset_right = 40.0
offset_bottom = 40.0
pivot_offset = Vector2(32, 32)
texture = ExtResource("2_5qmj0")
texture = ExtResource("2_0tnc1")
66 changes: 66 additions & 0 deletions addons/flexible_layout/tab.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
37 changes: 37 additions & 0 deletions addons/flexible_layout/tab.svg.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
[remap]

importer="texture"
type="CompressedTexture2D"
uid="uid://bja65j8x1jrvj"
path="res://.godot/imported/tab.svg-ccf47035ab2d2b2098f3b421c7a32000.ctex"
metadata={
"vram_texture": false
}

[deps]

source_file="res://addons/flexible_layout/tab.svg"
dest_files=["res://.godot/imported/tab.svg-ccf47035ab2d2b2098f3b421c7a32000.ctex"]

[params]

compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1
svg/scale=1.0
editor/scale_with_editor_scale=false
editor/convert_colors_with_editor_theme=false

0 comments on commit c16527e

Please sign in to comment.