Fix SimpleWindow control overflow with title

This commit is contained in:
2022-08-30 18:27:56 +00:00
parent f1e3cd7e13
commit 9fad6182a0

View File

@@ -35,7 +35,8 @@
(let [textHeight (let [textHeight
.height (new FlxText 0 0 0 "a" textSize)] .height (new FlxText 0 0 0 "a" textSize)]
(set controlsPerColumn (Math.floor (/ height textHeight)))) (set controlsPerColumn (Math.floor (/ height textHeight)))
(when title (-= controlsPerColumn 1)))
(when title (when title
(makeText title null)) (makeText title null))
@@ -58,12 +59,13 @@
(controls.add control) (controls.add control)
(+= nextControlY control.height) (+= nextControlY control.height)
// TODO controls that aren't the same height as text will be able to vertically overflow // TODO controls that aren't the same height as text will be able to vertically overflow
(when (= 0 (% controls.length controlsPerColumn)) (let [columnControls (controls.members.slice (if title 1 0))]
(set nextControlY y) (when (and columnControls (= 0 (% columnControls.length controlsPerColumn)))
(when title (+= nextControlY control.height)) (set nextControlY y)
(+= nextControlX (apply max (when title (+= nextControlY control.height))
(for control (last (groups controls.members controlsPerColumn)) (+= nextControlX (apply max
control.width)) textSize))) (for control (last (groups columnControls controlsPerColumn))
control.width)) textSize))))
(prop :Map<FlxSprite,Action> _actions (new Map)) (prop :Map<FlxSprite,Action> _actions (new Map))
(prop :Map<FlxSprite,FlxColor> _colors (new Map)) (prop :Map<FlxSprite,FlxColor> _colors (new Map))