mirror of
https://github.com/lihop/godot-xterm.git
synced 2025-05-10 14:05:32 +02:00
Add popup label to show terminal and panel size on resize
Shows the terminal cols/rows (if a terminal is open) and the size of the the tab_container in pixels. Shows centered for 1 second, then closes.
This commit is contained in:
parent
de7980c077
commit
ec0d4ddf43
2 changed files with 65 additions and 0 deletions
|
@ -32,6 +32,12 @@ onready var tabbar_container: HBoxContainer = $VBoxContainer/TabbarContainer
|
|||
onready var add_button: ToolButton = $VBoxContainer/TabbarContainer/Tabs/AddButton
|
||||
onready var tab_container: TabContainer = $VBoxContainer/TabContainer
|
||||
onready var terminal_popup_menu: PopupMenu = $VBoxContainer/TerminalPopupMenu
|
||||
|
||||
# Size label.
|
||||
# Used to show the size of the terminal (rows/cols) and panel (pixels) when resized.
|
||||
onready var size_label: Label = $SizeLabel
|
||||
onready var size_label_timer: Timer = $SizeLabel/SizeLabelTimer
|
||||
|
||||
onready var ready := true
|
||||
|
||||
var _theme := Theme.new()
|
||||
|
@ -62,6 +68,7 @@ func _update_settings() -> void:
|
|||
|
||||
var editor_scale: float = editor_interface.get_editor_scale()
|
||||
rect_min_size = Vector2(0, tabbar_container.rect_size.y + 182) * editor_scale
|
||||
rect_size.y = 415
|
||||
|
||||
tabs.tab_close_display_policy = Tabs.CLOSE_BUTTON_SHOW_ALWAYS
|
||||
|
||||
|
@ -239,3 +246,26 @@ func _on_TerminalPopupMenu_id_pressed(id):
|
|||
func _on_Tabs_reposition_active_tab_request(idx_to):
|
||||
var active = tab_container.get_child(tab_container.current_tab)
|
||||
tab_container.move_child(active, idx_to)
|
||||
|
||||
|
||||
func _on_Panel_resized():
|
||||
if not size_label:
|
||||
return
|
||||
|
||||
var size = tab_container.rect_size
|
||||
if tabs.get_tab_count() > 0:
|
||||
var terminal = tab_container.get_child(tabs.current_tab)
|
||||
var cols = terminal.cols
|
||||
var rows = terminal.rows
|
||||
size_label.text = "Size: %d cols; %d rows\n(%d x %d px)" % [cols, rows, size.x, size.y]
|
||||
else:
|
||||
size_label.text = "Size:\n(%d x %d px)" % [size.x, size.y]
|
||||
|
||||
size_label.visible = true
|
||||
size_label_timer.wait_time = 1
|
||||
size_label_timer.start()
|
||||
|
||||
|
||||
func _on_SizeLabelTimer_timeout():
|
||||
if size_label:
|
||||
size_label.visible = false
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue