mirror of
https://github.com/git-learning-game/oh-my-git.git
synced 2024-11-22 16:20:19 +01:00
Automatically switch on simplified view when there are >= 3 commits
This commit is contained in:
parent
aec32e115c
commit
e974342693
2 changed files with 18 additions and 13 deletions
|
@ -19,6 +19,9 @@ var shell = Shell.new()
|
||||||
var objects = {}
|
var objects = {}
|
||||||
var mouse_inside = false
|
var mouse_inside = false
|
||||||
|
|
||||||
|
# We use this for a heuristic of when to hide trees and blobs.
|
||||||
|
var _commit_count = 0
|
||||||
|
|
||||||
func _ready():
|
func _ready():
|
||||||
file_browser.shell = shell
|
file_browser.shell = shell
|
||||||
|
|
||||||
|
@ -118,6 +121,10 @@ func update_objects():
|
||||||
for p in commit_parents(o):
|
for p in commit_parents(o):
|
||||||
c[p] = ""
|
c[p] = ""
|
||||||
n.children = c
|
n.children = c
|
||||||
|
|
||||||
|
_commit_count += 1
|
||||||
|
if _commit_count >= 3 and not simplified_view:
|
||||||
|
simplified_view = true
|
||||||
"tag":
|
"tag":
|
||||||
n.children = tag_target(o)
|
n.children = tag_target(o)
|
||||||
|
|
||||||
|
@ -263,23 +270,19 @@ func ref_target(ref):
|
||||||
ret = git("show-ref "+ref).split(" ")[0]
|
ret = git("show-ref "+ref).split(" ")[0]
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
|
|
||||||
func simplify_view(pressed):
|
|
||||||
simplified_view = pressed
|
|
||||||
|
|
||||||
for o in objects:
|
|
||||||
var obj = objects[o]
|
|
||||||
if obj.type == "tree" or obj.type == "blob":
|
|
||||||
obj.visible = not pressed
|
|
||||||
|
|
||||||
if there_is_a_git():
|
|
||||||
update_objects()
|
|
||||||
|
|
||||||
func set_simplified_view(simplify):
|
func set_simplified_view(simplify):
|
||||||
simplified_view = simplify
|
simplified_view = simplify
|
||||||
if simplify_checkbox:
|
if simplify_checkbox:
|
||||||
simplify_checkbox.pressed = simplify
|
simplify_checkbox.pressed = simplify
|
||||||
|
|
||||||
|
for o in objects:
|
||||||
|
var obj = objects[o]
|
||||||
|
if obj.type == "tree" or obj.type == "blob":
|
||||||
|
obj.visible = not simplify
|
||||||
|
|
||||||
|
if there_is_a_git():
|
||||||
|
update_objects()
|
||||||
|
|
||||||
func set_editable_path(editable):
|
func set_editable_path(editable):
|
||||||
editable_path = editable
|
editable_path = editable
|
||||||
if label_node:
|
if label_node:
|
||||||
|
|
|
@ -93,6 +93,8 @@ __meta__ = {
|
||||||
[node name="Nodes" type="Control" parent="Rows/RepoVis"]
|
[node name="Nodes" type="Control" parent="Rows/RepoVis"]
|
||||||
anchor_right = 1.0
|
anchor_right = 1.0
|
||||||
anchor_bottom = 1.0
|
anchor_bottom = 1.0
|
||||||
|
margin_top = -1.43991
|
||||||
|
margin_bottom = -1.43994
|
||||||
mouse_filter = 2
|
mouse_filter = 2
|
||||||
__meta__ = {
|
__meta__ = {
|
||||||
"_edit_use_anchors_": false
|
"_edit_use_anchors_": false
|
||||||
|
@ -118,5 +120,5 @@ size_flags_stretch_ratio = 0.16
|
||||||
[connection signal="mouse_entered" from="." to="." method="_on_mouse_entered"]
|
[connection signal="mouse_entered" from="." to="." method="_on_mouse_entered"]
|
||||||
[connection signal="mouse_exited" from="." to="." method="_on_mouse_exited"]
|
[connection signal="mouse_exited" from="." to="." method="_on_mouse_exited"]
|
||||||
[connection signal="pressed" from="Rows/RepoVis/Button" to="." method="update_everything"]
|
[connection signal="pressed" from="Rows/RepoVis/Button" to="." method="update_everything"]
|
||||||
[connection signal="toggled" from="Rows/RepoVis/SimplifyCheckbox" to="." method="simplify_view"]
|
[connection signal="toggled" from="Rows/RepoVis/SimplifyCheckbox" to="." method="set_simplified_view"]
|
||||||
[connection signal="text_entered" from="Rows/RepoVis/Path" to="." method="set_path"]
|
[connection signal="text_entered" from="Rows/RepoVis/Path" to="." method="set_path"]
|
||||||
|
|
Loading…
Reference in a new issue