Skip to content

Commit 15fb1ed

Browse files
author
alferio
committed
fix(ui): toolbars collapsed width glitch
- The collapsed toolbar width logic was already shrinking the content area. - But the VisWindow title label still kept its full text, so the window pref width stayed title-driven on initial render and in auto-collapse mode. I fixed it in core/src/main/kotlin/com/github/alfu32/sketch/ui/SketchUiOverlay.kt. - CollapsibleWindow now stores its base title and can switch to a compact-title mode - when a toolbar is auto-collapsed: - the title text is set to "" - when expanded: - the full title is restored That makes the collapsed window width depend on the visible button, not on the title text.
1 parent 5e8555d commit 15fb1ed

2 files changed

Lines changed: 12 additions & 0 deletions

File tree

core/src/main/kotlin/com/github/alfu32/sketch/ui/SketchUiOverlay.kt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,9 @@ class SketchUiOverlay(
171171
private val fixedHeight: Float? = null,
172172
showCloseButton: Boolean = true
173173
) : com.kotcrab.vis.ui.widget.VisWindow(title, true) {
174+
private val baseTitle = title
174175
private var collapsed = false
176+
private var toolbarCompactTitle = false
175177

176178
init {
177179
isMovable = true
@@ -194,6 +196,15 @@ class SketchUiOverlay(
194196
isVisible = false
195197
}
196198

199+
fun setToolbarCompactTitle(compact: Boolean) {
200+
if (toolbarCompactTitle == compact) {
201+
return
202+
}
203+
toolbarCompactTitle = compact
204+
getTitleLabel().setText(if (compact) "" else baseTitle)
205+
invalidateHierarchy()
206+
}
207+
197208
fun setCollapsedState(value: Boolean) {
198209
if (collapsed == value) {
199210
return
@@ -1762,6 +1773,7 @@ class SketchUiOverlay(
17621773
val window = binding.window
17631774
val oldX = window.x
17641775
val oldTop = window.y + window.height
1776+
window.setToolbarCompactTitle(!expanded)
17651777
binding.expanded = expanded
17661778
binding.visibleButtonIndex = visibleButtonIndex
17671779
binding.slots.forEachIndexed { index, slot ->
0 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)