Improve dropdown window layout code
This commit is contained in:
parent
f29e690208
commit
91c512c4e9
|
@ -92,7 +92,7 @@ class DropdownButton<Value, ContentView: View>(
|
|||
val dropdownBackground = dropdownWindow.addView(NinePatchView(NinePatchTexture.BUTTON_BG).apply {
|
||||
zIndex = -1.0
|
||||
})
|
||||
val stack = dropdownWindow.addView(StackView(Axis.VERTICAL, StackView.Distribution.LEADING))
|
||||
val stack = dropdownWindow.addView(StackView(Axis.VERTICAL, StackView.Distribution.FILL))
|
||||
lateinit var selectedButton: View
|
||||
val buttons = mutableListOf<Button>()
|
||||
val last = allValues.count() - 1
|
||||
|
@ -113,7 +113,9 @@ class DropdownButton<Value, ContentView: View>(
|
|||
}
|
||||
buttons.add(button)
|
||||
dropdownWindow.solver.dsl {
|
||||
stack.widthAnchor greaterThanOrEqualTo button.widthAnchor
|
||||
if (button.content.intrinsicContentSize != null) {
|
||||
button.widthAnchor greaterThanOrEqualTo button.content.intrinsicContentSize!!.width + 2 * button.padding
|
||||
}
|
||||
}
|
||||
}
|
||||
dropdownWindow.solver.dsl {
|
||||
|
@ -128,12 +130,6 @@ class DropdownButton<Value, ContentView: View>(
|
|||
dropdownBackground.bottomAnchor equalTo stack.bottomAnchor
|
||||
}
|
||||
dropdownWindow.layout()
|
||||
dropdownWindow.solver.dsl {
|
||||
buttons.forEach {
|
||||
it.widthAnchor equalTo stack.frame.width
|
||||
}
|
||||
}
|
||||
dropdownWindow.layout()
|
||||
}
|
||||
|
||||
private fun valueSelected(value: Value) {
|
||||
|
|
Loading…
Reference in New Issue