diary/user_interface/topic_panel/topic_editable.gd

61 lines
1.3 KiB
GDScript3
Raw Normal View History

extends EditableTextBlock
class_name TopicEditable
const TYPE_CASUAL = 0
const TYPE_DAILY = 1
const TYPE_URGENT = 2
onready var parent = get_parent()
onready var type_label = get_node("VBoxContainer/HBoxContainer/TypeLabel")
var associated_topic
var type: int = TYPE_CASUAL
var color: Color
func _get_content_string() -> String: # Override.
return associated_topic.content
func _setup(): # Override.
_setup_content()
_setup_appearance()
func _adjust_appearance_to_user(): # Override.
match type:
TYPE_CASUAL:
if type_label:
type_label.text = "CASUAL"
color = Users.get_current().casual_topic_color
TYPE_DAILY:
if type_label:
type_label.text = "DAILY"
color = Users.get_current().daily_topic_color
TYPE_URGENT:
if type_label:
type_label.text = "URGENT"
color = Users.get_current().urgent_topic_color
_update_color()
func _update_color():
var addition = Color(0.1, 0.12, 0.15) if _is_selected() else Color.black
nine_patch.self_modulate = color + addition
func _is_selected() -> bool:
if get_parent().topic_feed:
return parent.topic_feed.selected_topics.has(parent)
else:
return false
func _delete():
associated_topic.delete()
func _on_text_edit_confirmed(confirmed_content): # Override
associated_topic.content = confirmed_content
_disable_edit_mode()