fix(gtk): handle scrolling of settings tabs independently
This commit is contained in:
parent
4dfcbb038d
commit
363a62542e
@ -7,7 +7,7 @@ import org.gnome.gtk.*
|
||||
import org.jetbrains.annotations.PropertyKey
|
||||
import java.util.concurrent.atomic.AtomicInteger
|
||||
|
||||
open class SectionedSettingsTab<W : Window>(window: W?): SettingsTab<Box, W>(window, Box(Orientation.VERTICAL, 8)) {
|
||||
open class SectionedSettingsTab<W : Window>(window: W?): SettingsTab<Box, W>(window, Box(Orientation.VERTICAL, 8), true) {
|
||||
init {
|
||||
content.marginHorizontal = 24
|
||||
content.marginTop = 12
|
||||
|
@ -7,7 +7,8 @@ import org.gnome.gtk.Window
|
||||
|
||||
open class SettingsTab<T : Widget, W : Window>(
|
||||
protected val window: W?,
|
||||
val content: T
|
||||
val content: T,
|
||||
val scrollable: Boolean
|
||||
) {
|
||||
protected fun showError(message: String, t: Throwable) =
|
||||
GtkEnvBackend.simpleDialog(
|
||||
|
@ -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,8 +38,14 @@ open class SettingsWindow(app: Application?) : Window() {
|
||||
}
|
||||
|
||||
fun addTab(tab: SettingsTab<*, *>, title: @PropertyKey(resourceBundle = I18n.BUNDLE) String, iconName: String) {
|
||||
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
|
||||
get() = stack.visibleChildName!!
|
||||
|
@ -31,7 +31,7 @@ import org.jetbrains.annotations.PropertyKey
|
||||
import java.util.concurrent.ForkJoinPool
|
||||
import kotlin.jvm.optionals.getOrNull
|
||||
|
||||
class ModsTab(window: InstanceSettingsWindow) : SettingsTab<Leaflet, InstanceSettingsWindow>(window, Leaflet()) {
|
||||
class ModsTab(window: InstanceSettingsWindow) : SettingsTab<Leaflet, InstanceSettingsWindow>(window, Leaflet(), false) {
|
||||
private val instance: Instance = window.instance
|
||||
private val mds: ModsDirScanner = instance.mds
|
||||
private val listModel: StringList
|
||||
|
Loading…
Reference in New Issue
Block a user