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 org.jetbrains.annotations.PropertyKey
|
||||||
import java.util.concurrent.atomic.AtomicInteger
|
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 {
|
init {
|
||||||
content.marginHorizontal = 24
|
content.marginHorizontal = 24
|
||||||
content.marginTop = 12
|
content.marginTop = 12
|
||||||
|
@ -7,7 +7,8 @@ import org.gnome.gtk.Window
|
|||||||
|
|
||||||
open class SettingsTab<T : Widget, W : Window>(
|
open class SettingsTab<T : Widget, W : Window>(
|
||||||
protected val window: W?,
|
protected val window: W?,
|
||||||
val content: T
|
val content: T,
|
||||||
|
val scrollable: Boolean
|
||||||
) {
|
) {
|
||||||
protected fun showError(message: String, t: Throwable) =
|
protected fun showError(message: String, t: Throwable) =
|
||||||
GtkEnvBackend.simpleDialog(
|
GtkEnvBackend.simpleDialog(
|
||||||
|
@ -15,7 +15,9 @@ open class SettingsWindow(app: Application?) : Window() {
|
|||||||
init {
|
init {
|
||||||
application = app
|
application = app
|
||||||
|
|
||||||
stack = ViewStack()
|
stack = ViewStack().apply {
|
||||||
|
vexpand = true
|
||||||
|
}
|
||||||
|
|
||||||
val header = HeaderBar()
|
val header = HeaderBar()
|
||||||
val viewSwitcher = ViewSwitcherTitle()
|
val viewSwitcher = ViewSwitcherTitle()
|
||||||
@ -23,16 +25,11 @@ open class SettingsWindow(app: Application?) : Window() {
|
|||||||
header.titleWidget = viewSwitcher
|
header.titleWidget = viewSwitcher
|
||||||
titlebar = header
|
titlebar = header
|
||||||
|
|
||||||
val scroll = ScrolledWindow()
|
|
||||||
scroll.setPolicy(PolicyType.NEVER, PolicyType.AUTOMATIC)
|
|
||||||
scroll.child = stack
|
|
||||||
scroll.vexpand = true
|
|
||||||
|
|
||||||
val bottomBar = ViewSwitcherBar()
|
val bottomBar = ViewSwitcherBar()
|
||||||
bottomBar.stack = stack
|
bottomBar.stack = stack
|
||||||
viewSwitcher.bindProperty("title-visible", bottomBar, "reveal", BindingFlags.DEFAULT)
|
viewSwitcher.bindProperty("title-visible", bottomBar, "reveal", BindingFlags.DEFAULT)
|
||||||
val view = Box(Orientation.VERTICAL, 0)
|
val view = Box(Orientation.VERTICAL, 0)
|
||||||
view.append(scroll)
|
view.append(stack)
|
||||||
view.append(bottomBar)
|
view.append(bottomBar)
|
||||||
|
|
||||||
child = view
|
child = view
|
||||||
@ -41,8 +38,14 @@ open class SettingsWindow(app: Application?) : Window() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun addTab(tab: SettingsTab<*, *>, title: @PropertyKey(resourceBundle = I18n.BUNDLE) String, iconName: String) {
|
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)
|
stack.addTitledWithIcon(tab.content, title, I18n[title], iconName)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
var activePage: String
|
var activePage: String
|
||||||
get() = stack.visibleChildName!!
|
get() = stack.visibleChildName!!
|
||||||
|
@ -31,7 +31,7 @@ import org.jetbrains.annotations.PropertyKey
|
|||||||
import java.util.concurrent.ForkJoinPool
|
import java.util.concurrent.ForkJoinPool
|
||||||
import kotlin.jvm.optionals.getOrNull
|
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 instance: Instance = window.instance
|
||||||
private val mds: ModsDirScanner = instance.mds
|
private val mds: ModsDirScanner = instance.mds
|
||||||
private val listModel: StringList
|
private val listModel: StringList
|
||||||
|
Loading…
Reference in New Issue
Block a user