Skip to content

Commit

Permalink
maybe so?
Browse files Browse the repository at this point in the history
  • Loading branch information
Mnemotechnician committed Jan 2, 2022
1 parent 1a3d082 commit d824aae
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
6 changes: 3 additions & 3 deletions lib/src/main/kotlin/com/github/mnemotechnician/mkui/Layout.kt
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ inline fun Table.addTable(background: Drawable = Styles.none, constructor: Table
}

/** Adds a collapser constructed by a lambda to the existing table and returns the created cell */
inline fun Table.addCollapser(background: Drawable = Styles.none, shown: Boolean = true, constructor: Table.() -> Unit = {}): Cell<Collapser> {
inline fun Table.addCollapser(shown: Boolean = true, background: Drawable = Styles.none, constructor: Table.() -> Unit = {}): Cell<Collapser> {
val table = Table(background)
table.constructor()

Expand All @@ -43,8 +43,8 @@ inline fun Table.addCollapser(background: Drawable = Styles.none, shown: Boolean
}

/** Adds a collapser constructed by a lambda to the existing table and returns the created cell. Whether it's shown is determined by the lambda. */
inline fun Table.addCollapser(background: Drawable = Styles.none, crossinline shown: () -> Boolean = { true }, animate: Boolean = false, constructor: Table.() -> Unit = {}): Cell<Collapser> {
val cell = addCollapser(background, shown(), constructor)
inline fun Table.addCollapser(crossinline shown: () -> Boolean = { true }, background: Drawable = Styles.none, animate: Boolean = false, constructor: Table.() -> Unit = {}): Cell<Collapser> {
val cell = addCollapser(shown(), background, constructor)
cell.get().setCollapsed(animate) { !shown() }
return cell;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import com.github.mnemotechnician.mkui.*
object WindowManager {

internal val windowGroup = WidgetGroup()
val windows = Seq<Window>()
internal val windows = Seq<Window>()

init {
Events.run(EventType.ClientLoadEvent::class.java) {
Expand Down Expand Up @@ -56,13 +56,13 @@ object WindowManager {

//top bar — name, buttons and also a way to drag the table
addTable(Styles.black3) {
addLabel({ window.name }, ellipsis = "...").fillX()
addLabel({ window.name }, ellipsis = "...").growX()

//collapse/show
textToggle("-", Styles.togglet) {
childAs<Label>(0).setText(if (it) "[accent]=" else "[accent]-")

collapser.toggle()
collapser.setCollapsed(true, it)
window.isCollapsed = it
window.onToggle(it)
}
Expand All @@ -79,8 +79,8 @@ object WindowManager {
}

override fun touchDragged(event: InputEvent, x: Float, y: Float, pointer: Int) {
val oldPos = window.rootTable.localToParentCoordinates(Tmp.v1.set(x, y))
window.rootTable.setPosition(oldPos.x, oldPos.y)
val pos = window.rootTable.localToParentCoordinates(Tmp.v1.set(x, y))
window.rootTable.setPosition(pos.x, pos.y)

window.onDrag()
}
Expand All @@ -94,12 +94,12 @@ object WindowManager {
row()

//main container
collapser = addCollapser(animate = true) {
collapser = addCollapser(true) {
setClip(true)

window.table = this
window.onCreate()
}.pad(5f).get()
}.grow().pad(5f).get()
}

windowGroup.addChild(windowTable)
Expand Down

0 comments on commit d824aae

Please sign in to comment.