oh-my-git/scenes/file_browser_item.gd

50 lines
1.4 KiB
GDScript3
Raw Normal View History

2020-11-03 16:39:55 +01:00
class_name FileBrowserItem
extends Control
signal clicked(what)
2020-11-03 16:39:55 +01:00
enum IconStatus {NONE, NEW, REMOVED, CONFLICT, EDIT, UNTRACKED}
export(IconStatus) var status setget _set_status
export var label: String setget _set_label
var type = "file"
onready var label_node = $VBoxContainer/Label
2020-11-03 16:39:55 +01:00
onready var status_icon = $VBoxContainer/Control/TextureRect/StatusIcon
func _ready():
_set_label(label)
2020-11-03 16:39:55 +01:00
_set_status(status)
func _set_label(new_label):
label = new_label
if label_node:
label_node.text = helpers.abbreviate(new_label, 30)
func _gui_input(event):
if event is InputEventMouseButton and event.is_pressed() and event.button_index == BUTTON_LEFT:
emit_signal("clicked", self)
2020-11-03 16:39:55 +01:00
func _set_status(new_status):
if status_icon:
match new_status:
IconStatus.NEW:
status_icon.texture = preload("res://images/new.svg")
status_icon.modulate = Color("33BB33")
IconStatus.REMOVED:
status_icon.texture = preload("res://images/removed.svg")
status_icon.modulate = Color("D10F0F")
IconStatus.CONFLICT:
status_icon.texture = preload("res://images/conflict.svg")
status_icon.modulate = Color("DE5E09")
IconStatus.EDIT:
status_icon.texture = preload("res://images/modified.svg")
status_icon.modulate = Color("344DED")
IconStatus.UNTRACKED:
status_icon.texture = preload("res://images/untracked.svg")
status_icon.modulate = Color("9209B8")
IconStatus.NONE:
status_icon.texture = null
status = new_status