From 363a62542e94ba5b1f8610ea5831d347bb927a10 Mon Sep 17 00:00:00 2001 From: JFronny Date: Fri, 4 Oct 2024 18:06:59 +0200 Subject: [PATCH] fix(gtk): handle scrolling of settings tabs independently --- .../control/settings/SectionedSettingsTab.kt | 2 +- .../gtk/control/settings/SettingsTab.kt | 3 ++- .../gtk/control/settings/SettingsWindow.kt | 19 +++++++++++-------- .../gtk/window/settings/instance/ModsTab.kt | 2 +- 4 files changed, 15 insertions(+), 11 deletions(-) diff --git a/launcher-gtk/src/main/kotlin/io/gitlab/jfronny/inceptum/gtk/control/settings/SectionedSettingsTab.kt b/launcher-gtk/src/main/kotlin/io/gitlab/jfronny/inceptum/gtk/control/settings/SectionedSettingsTab.kt index f627258..ffd017c 100644 --- a/launcher-gtk/src/main/kotlin/io/gitlab/jfronny/inceptum/gtk/control/settings/SectionedSettingsTab.kt +++ b/launcher-gtk/src/main/kotlin/io/gitlab/jfronny/inceptum/gtk/control/settings/SectionedSettingsTab.kt @@ -7,7 +7,7 @@ import org.gnome.gtk.* import org.jetbrains.annotations.PropertyKey import java.util.concurrent.atomic.AtomicInteger -open class SectionedSettingsTab(window: W?): SettingsTab(window, Box(Orientation.VERTICAL, 8)) { +open class SectionedSettingsTab(window: W?): SettingsTab(window, Box(Orientation.VERTICAL, 8), true) { init { content.marginHorizontal = 24 content.marginTop = 12 diff --git a/launcher-gtk/src/main/kotlin/io/gitlab/jfronny/inceptum/gtk/control/settings/SettingsTab.kt b/launcher-gtk/src/main/kotlin/io/gitlab/jfronny/inceptum/gtk/control/settings/SettingsTab.kt index 581364d..eb29f44 100644 --- a/launcher-gtk/src/main/kotlin/io/gitlab/jfronny/inceptum/gtk/control/settings/SettingsTab.kt +++ b/launcher-gtk/src/main/kotlin/io/gitlab/jfronny/inceptum/gtk/control/settings/SettingsTab.kt @@ -7,7 +7,8 @@ import org.gnome.gtk.Window open class SettingsTab( protected val window: W?, - val content: T + val content: T, + val scrollable: Boolean ) { protected fun showError(message: String, t: Throwable) = GtkEnvBackend.simpleDialog( diff --git a/launcher-gtk/src/main/kotlin/io/gitlab/jfronny/inceptum/gtk/control/settings/SettingsWindow.kt b/launcher-gtk/src/main/kotlin/io/gitlab/jfronny/inceptum/gtk/control/settings/SettingsWindow.kt index 3d048f3..469e470 100644 --- a/launcher-gtk/src/main/kotlin/io/gitlab/jfronny/inceptum/gtk/control/settings/SettingsWindow.kt +++ b/launcher-gtk/src/main/kotlin/io/gitlab/jfronny/inceptum/gtk/control/settings/SettingsWindow.kt @@ -15,7 +15,9 @@ open class SettingsWindow(app: Application?) : Window() { init { application = app - stack = ViewStack() + stack = ViewStack().apply { + vexpand = true + } val header = HeaderBar() val viewSwitcher = ViewSwitcherTitle() @@ -23,16 +25,11 @@ open class SettingsWindow(app: Application?) : Window() { header.titleWidget = viewSwitcher titlebar = header - val scroll = ScrolledWindow() - scroll.setPolicy(PolicyType.NEVER, PolicyType.AUTOMATIC) - scroll.child = stack - scroll.vexpand = true - val bottomBar = ViewSwitcherBar() bottomBar.stack = stack viewSwitcher.bindProperty("title-visible", bottomBar, "reveal", BindingFlags.DEFAULT) val view = Box(Orientation.VERTICAL, 0) - view.append(scroll) + view.append(stack) view.append(bottomBar) child = view @@ -41,7 +38,13 @@ open class SettingsWindow(app: Application?) : Window() { } fun addTab(tab: SettingsTab<*, *>, title: @PropertyKey(resourceBundle = I18n.BUNDLE) String, iconName: String) { - stack.addTitledWithIcon(tab.content, title, I18n[title], iconName) + if (tab.scrollable) { + stack.addTitledWithIcon(ScrolledWindow().apply { + child = tab.content + }, title, I18n[title], iconName) + } else { + stack.addTitledWithIcon(tab.content, title, I18n[title], iconName) + } } var activePage: String diff --git a/launcher-gtk/src/main/kotlin/io/gitlab/jfronny/inceptum/gtk/window/settings/instance/ModsTab.kt b/launcher-gtk/src/main/kotlin/io/gitlab/jfronny/inceptum/gtk/window/settings/instance/ModsTab.kt index a1bd297..0dd440b 100644 --- a/launcher-gtk/src/main/kotlin/io/gitlab/jfronny/inceptum/gtk/window/settings/instance/ModsTab.kt +++ b/launcher-gtk/src/main/kotlin/io/gitlab/jfronny/inceptum/gtk/window/settings/instance/ModsTab.kt @@ -31,7 +31,7 @@ import org.jetbrains.annotations.PropertyKey import java.util.concurrent.ForkJoinPool import kotlin.jvm.optionals.getOrNull -class ModsTab(window: InstanceSettingsWindow) : SettingsTab(window, Leaflet()) { +class ModsTab(window: InstanceSettingsWindow) : SettingsTab(window, Leaflet(), false) { private val instance: Instance = window.instance private val mds: ModsDirScanner = instance.mds private val listModel: StringList