-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfile_popup_window.gd
More file actions
63 lines (46 loc) · 1.57 KB
/
Copy pathfile_popup_window.gd
File metadata and controls
63 lines (46 loc) · 1.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
class_name FilePopupMenu extends PanelContainer
signal exited(confirmed:bool)
signal selected_filepath(filepath:String)
const FADE_TIME:float = 1.0
@export var code_box:CodeEdit
@export var confirm_button:Button
@export var cancel_button:Button
@onready var open_image_file_dialog: FileDialog = %OpenImageFileDialog
var modulate_tween:Tween
func _ready() -> void:
hide()
func popup_code(code:String = "", editable:bool = false) -> bool:
code_box.show()
code_box.text = code
code_box.editable = editable
code_box.get_v_scroll_bar().self_modulate = Utils.TRANSPARENT ## WORKING
#code_box.get_v_scroll_bar().add_theme_stylebox_override("normal", StyleBoxEmpty.new()) # not working
show()
confirm_button.show()
if editable:
cancel_button.show()
confirm_button.text = "Confirm"
else:
cancel_button.hide()
confirm_button.text = "OK"
var result:bool = await exited
hide()
return result
func popup_image_file_picker() -> String: ## Filepath
open_image_file_dialog.popup()
var _filepath:String = await selected_filepath
return _filepath
func _on_visibility_changed() -> void:
if visible:
if modulate_tween:
modulate_tween.kill()
modulate_tween = create_tween()
modulate_tween.tween_property(self, ^"modulate", Color.WHITE, FADE_TIME).from(Utils.TRANSPARENT)
func _on_cancel_button_pressed() -> void:
exited.emit(false)
func _on_confirm_button_pressed() -> void:
exited.emit(true)
func _on_open_image_file_dialog_file_selected(path: String) -> void:
selected_filepath.emit(path)
func _on_open_image_file_dialog_canceled() -> void:
selected_filepath.emit("")