Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions src/autoload/HandlerGUI.gd
Original file line number Diff line number Diff line change
Expand Up @@ -382,17 +382,10 @@ func get_auto_ui_scale() -> float:
var scale := dpi / base_dpi
var blend: float = clamp((dpi - 240.0) / 400.0, 0.0, 1.0)
var adjusted_scale: float = max(lerp(scale, pow(scale, 0.75), blend), 1.0)

var screen_width := get_tree().root.size.x
print("contents_minimum_width: ", minimum_content_width)
print("screen_width: ", screen_width)
print("adjusted_scale: ", adjusted_scale)

# Ensure the scale doesn't cause UI overflow.
if (screen_width / adjusted_scale) < minimum_content_width:
adjusted_scale = screen_width / minimum_content_width
print("Adjusted scale due to min content width: ", adjusted_scale)

return snapped(adjusted_scale, 0.01)

func update_ui_scale() -> void:
Expand Down
11 changes: 11 additions & 0 deletions src/ui_parts/tabs_panel.gd
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,20 @@ func _ready() -> void:
get_parent().gui_input.connect(_on_parent_gui_input)
Configs.tab_removed.connect(refresh_tabs)
Configs.tab_selected.connect(highlight_active_tab)
Configs.theme_changed.connect(sync_theming)
sync_theming()
Configs.tabs_changed.connect(func(): should_refresh = true)
refresh_tabs()

func sync_theming():
var scroll_bar: VScrollBar= $VBoxContainer/ScrollContainer.get_v_scroll_bar()
scroll_bar.mouse_filter = Control.MOUSE_FILTER_IGNORE
var s: StyleBoxFlat = scroll_bar.get_theme_stylebox("scroll").duplicate()
s.draw_center = false
s.content_margin_left = 2
s.content_margin_right = 2
scroll_bar.add_theme_stylebox_override("scroll", s)

func animate_in() -> void:
if should_refresh:
refresh_tabs()
Expand Down
23 changes: 17 additions & 6 deletions src/ui_widgets/tab_item.gd
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ const PreviewRectScene = preload("res://src/ui_widgets/preview_rect.tscn")
@onready var title: Label = $VBoxContainer/HBoxContainer/title
@onready var close_button: Button = $VBoxContainer/HBoxContainer/close

var _click_start_time := 0
var _dragged := false
const CLICK_MAX_TIME := 300


func setup(tab_title: String, svg_text: String, is_active: bool = false) -> void:
title.text = tab_title
highlight(is_active)
Expand All @@ -30,12 +35,18 @@ func highlight(is_active: bool) -> void:
theme_type_variation = "TabItem"

func _gui_input(event: InputEvent) -> void:
if not event is InputEventMouseButton:
return
if event.is_pressed() and event.button_index == MOUSE_BUTTON_LEFT:
var index := get_index()
Configs.tab_selected.emit(index)

if event is InputEventMouseMotion:
_dragged = true

elif event is InputEventMouseButton and event.button_index == MOUSE_BUTTON_LEFT:
if event.is_pressed():
_click_start_time = Time.get_ticks_msec()
_dragged = false
else:
var time_diff := Time.get_ticks_msec() - _click_start_time
if time_diff <= CLICK_MAX_TIME and not _dragged:
var index := get_index()
Configs.tab_selected.emit(index)

func _on_close_pressed() -> void:
FileUtils.close_tabs(get_index())
Expand Down
1 change: 1 addition & 0 deletions src/ui_widgets/tab_item.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
[node name="TabItem" type="PanelContainer"]
custom_minimum_size = Vector2(120, 160)
size_flags_horizontal = 6
mouse_filter = 1
theme_type_variation = &"TabItem"
script = ExtResource("1_aprl0")

Expand Down