From 00538ee581810819352e00dd226f5e471665f849 Mon Sep 17 00:00:00 2001 From: Sebastian Morr Date: Tue, 27 Oct 2020 16:10:02 +0100 Subject: [PATCH 1/2] Layout graphs in a horizontal direction --- scenes/node.gd | 6 ++++-- scenes/repository.gd | 7 ++----- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/scenes/node.gd b/scenes/node.gd index 2ec378e..1d41964 100644 --- a/scenes/node.gd +++ b/scenes/node.gd @@ -35,15 +35,17 @@ func _process(_delta): apply_forces() func apply_forces(): - var offset = Vector2(0, 80) + var offset = Vector2(-80, 0) for c in children.keys(): + if type == "ref" or type == "head": + offset = Vector2(0, 80) if repository.objects.has(c): var other = repository.objects[c] if other.visible: var d = other.position.distance_to(position+offset) var dir = (other.position - (position+offset)).normalized() - var f = (d*0.03) + var f = (d*0.12) position += dir*f other.position -= dir*f diff --git a/scenes/repository.gd b/scenes/repository.gd index 4972f17..8221bb4 100644 --- a/scenes/repository.gd +++ b/scenes/repository.gd @@ -148,7 +148,7 @@ func update_node_positions(): var hash_regex = RegEx.new() hash_regex.compile("[a-f0-9]+") var regex_match = hash_regex.search(line) - objects[regex_match.get_string()].position = Vector2(star_idx * 100 + 500, line_count * 100 + 500) + objects[regex_match.get_string()].position = Vector2((graph_lines.size()-line_count) * 100 + 500, star_idx * 100 + 500) for ref in all_refs(): var target_reference = objects[ref].children.keys()[0] @@ -159,9 +159,6 @@ func update_node_positions(): if objects.has(target_reference): var target = objects[target_reference] objects["HEAD"].position = Vector2(target.position.x ,target.position.y - 100) - - - func update_refs(): for r in all_refs(): @@ -193,7 +190,7 @@ func apply_forces(): var center_of_gravity = nodes.rect_size/2 var d = o.position.distance_to(center_of_gravity) var dir = (o.position - center_of_gravity).normalized() - var f = (d+0.00001)*(Vector2(nodes.rect_size.y, nodes.rect_size.x/3).normalized()/30) + var f = (d+0.00001)*(Vector2(nodes.rect_size.y/10, nodes.rect_size.x/3).normalized()/30) o.position -= dir*f func find_position(n): From ac2062bd5a69b9f78687eb33dc9a65d5add57e4c Mon Sep 17 00:00:00 2001 From: Sebastian Morr Date: Tue, 27 Oct 2020 16:53:19 +0100 Subject: [PATCH 2/2] First attempt of rearranging the elements better in horizontal layout --- scenes/file_browser.tscn | 2 -- scenes/main.gd | 3 +++ scenes/main.tscn | 5 +---- scenes/node.gd | 12 +++++++----- scenes/node.tscn | 16 ++++++++-------- scenes/repository.gd | 4 ++-- scenes/repository.tscn | 41 ++++++++++++++++++++++++---------------- 7 files changed, 46 insertions(+), 37 deletions(-) diff --git a/scenes/file_browser.tscn b/scenes/file_browser.tscn index 34f63ae..4b32925 100644 --- a/scenes/file_browser.tscn +++ b/scenes/file_browser.tscn @@ -4,7 +4,6 @@ [ext_resource path="res://fonts/default.tres" type="DynamicFont" id=2] [ext_resource path="res://styles/theme.tres" type="Theme" id=3] - [node name="FileBrowser" type="Control"] anchor_right = 1.0 anchor_bottom = 1.0 @@ -81,7 +80,6 @@ size_flags_horizontal = 3 size_flags_vertical = 3 custom_constants/vseparation = 16 custom_constants/hseparation = 16 -columns = 4 __meta__ = { "_edit_use_anchors_": false } diff --git a/scenes/main.gd b/scenes/main.gd index 16da975..6992038 100644 --- a/scenes/main.gd +++ b/scenes/main.gd @@ -78,6 +78,9 @@ func load_level(level_id): new_repo.path = repo.path new_repo.label = repo.slug new_repo.size_flags_horizontal = SIZE_EXPAND_FILL + new_repo.size_flags_vertical = SIZE_EXPAND_FILL + if new_repo.label != "yours": + new_repo.file_browser_active = false repositories_node.add_child(new_repo) repositories[r] = new_repo diff --git a/scenes/main.tscn b/scenes/main.tscn index bf011a7..143a65c 100644 --- a/scenes/main.tscn +++ b/scenes/main.tscn @@ -60,16 +60,13 @@ margin_bottom = 784.0 mouse_filter = 2 size_flags_vertical = 3 -[node name="Repositories" type="HBoxContainer" parent="Rows/Columns"] +[node name="Repositories" type="VBoxContainer" parent="Rows/Columns"] margin_right = 1266.0 margin_bottom = 784.0 mouse_filter = 2 size_flags_horizontal = 3 size_flags_stretch_ratio = 2.0 custom_constants/separation = 8 -__meta__ = { -"_edit_use_anchors_": false -} [node name="LevelInfo" type="VBoxContainer" parent="Rows/Columns"] margin_left = 1271.0 diff --git a/scenes/node.gd b/scenes/node.gd index 1d41964..662e58f 100644 --- a/scenes/node.gd +++ b/scenes/node.gd @@ -100,15 +100,16 @@ func children_set(new_children): func _on_hover(): hovered = true - if not id_always_visible: - content_label.visible = true + if not id_always_visible and type != "head": + if not file_browser.visible: + content_label.visible = true #$ID.visible = true func _on_unhover(): hovered = false - if not id_always_visible: + if not id_always_visible and type != "head": content_label.visible = false - $ID.visible = false + #$ID.visible = false func _input(event): if hovered: @@ -125,9 +126,10 @@ func _input(event): if start_pos: var dist = get_viewport().get_mouse_position() - start_pos print(dist.length()) - if dist.length() < 3: + if dist.length() < 3: # <3 var state = file_browser.visible repository.close_all_file_browsers() file_browser.visible = not state + content_label.visible = state start_pos = null diff --git a/scenes/node.tscn b/scenes/node.tscn index 8008176..6ec6644 100644 --- a/scenes/node.tscn +++ b/scenes/node.tscn @@ -70,10 +70,10 @@ z_index = 1 [node name="ContentLabel" type="Label" parent="Content"] visible = false -margin_left = 31.3944 -margin_top = -22.8078 -margin_right = 41.3944 -margin_bottom = 12.1922 +margin_left = -22.057 +margin_top = 31.1738 +margin_right = -12.057 +margin_bottom = 66.1738 custom_styles/normal = SubResource( 2 ) custom_fonts/font = ExtResource( 1 ) custom_colors/font_color = Color( 1, 1, 1, 1 ) @@ -88,10 +88,10 @@ z_index = 2 visible = false anchor_right = 0.0 anchor_bottom = 0.0 -margin_left = -460.672 -margin_top = -23.6409 -margin_right = -32.6716 -margin_bottom = 118.359 +margin_left = -23.2915 +margin_top = 30.6967 +margin_right = 404.709 +margin_bottom = 172.697 mouse_filter = 1 mode = 1 [connection signal="mouse_entered" from="Rect" to="." method="_on_hover"] diff --git a/scenes/repository.gd b/scenes/repository.gd index 8221bb4..12294a7 100644 --- a/scenes/repository.gd +++ b/scenes/repository.gd @@ -1,8 +1,8 @@ extends Control -onready var index = $Rows/Browsers/Index +onready var index = $Browsers/Index onready var nodes = $Rows/RepoVis/Nodes -onready var file_browser = $Rows/Browsers/FileBrowser +onready var file_browser = $Browsers/FileBrowser onready var label_node = $Rows/RepoVis/Label onready var path_node = $Rows/RepoVis/Path onready var simplify_checkbox = $Rows/RepoVis/SimplifyCheckbox diff --git a/scenes/repository.tscn b/scenes/repository.tscn index 2df5d72..d4b62a0 100644 --- a/scenes/repository.tscn +++ b/scenes/repository.tscn @@ -15,18 +15,16 @@ __meta__ = { "_edit_use_anchors_": false } -[node name="Rows" type="VSplitContainer" parent="."] +[node name="Rows" type="HSplitContainer" parent="."] anchor_right = 1.0 anchor_bottom = 1.0 mouse_filter = 2 -__meta__ = { -"_edit_use_anchors_": false -} [node name="RepoVis" type="Control" parent="Rows"] margin_right = 1920.0 -margin_bottom = 926.0 +margin_bottom = 1080.0 mouse_filter = 2 +size_flags_horizontal = 3 size_flags_vertical = 3 __meta__ = { "_edit_use_anchors_": false @@ -99,26 +97,37 @@ __meta__ = { "_edit_use_anchors_": false } -[node name="Browsers" type="VBoxContainer" parent="Rows"] -margin_top = 938.0 -margin_right = 1920.0 -margin_bottom = 1080.0 +[node name="Browsers" type="VBoxContainer" parent="."] +anchor_left = 1.0 +anchor_top = 1.0 +anchor_right = 1.0 +anchor_bottom = 1.0 +margin_left = 6.0 +margin_top = -356.0 +margin_right = 635.0 +margin_bottom = -5.0 +size_flags_horizontal = 3 +size_flags_vertical = 3 +size_flags_stretch_ratio = 0.2 +__meta__ = { +"_edit_use_anchors_": false +} -[node name="Index" parent="Rows/Browsers" instance=ExtResource( 4 )] -visible = false +[node name="Index" parent="Browsers" instance=ExtResource( 4 )] anchor_right = 0.0 anchor_bottom = 0.0 -margin_right = 1920.0 -margin_bottom = 142.0 +margin_right = 629.0 +margin_bottom = 173.0 size_flags_vertical = 3 title = "Index" mode = 2 -[node name="FileBrowser" parent="Rows/Browsers" instance=ExtResource( 4 )] +[node name="FileBrowser" parent="Browsers" instance=ExtResource( 4 )] anchor_right = 0.0 anchor_bottom = 0.0 -margin_right = 1920.0 -margin_bottom = 142.0 +margin_top = 178.0 +margin_right = 629.0 +margin_bottom = 351.0 size_flags_vertical = 3 title = "Working directory" [connection signal="mouse_entered" from="." to="." method="_on_mouse_entered"]