Freezing when resizing to a too small window
Resizing to a to small window freezes the Figuro application, like so:
Thanks! Definitely a corner case. I'll look into it, probably the renderer freaking out.
I tried replicating it on my Mac, but it seems just fine on a couple of the programs I tried. It might be windows specific.
Would you mind sharing your test code so I could test it to be sure?
Sure, here you go:
## This minimal example shows 5 blue squares.
import ../figuro/figuro/widgets/buttonWrap
import ../figuro/figuro/widget
import ../figuro/figuro
type
Main* = ref object of Figuro
value: float
hasHovered: bool
hoveredAlpha: float
mainRect: Figuro
let
typeface = loadTypeFace("IBMPlexSans-Regular.ttf")
font = UiFont(typefaceId: typeface, size: 22)
proc draw*(self: Main) {.slot.} =
withDraw(self):
rectangle "body":
fill "#D0D0D0"
box 10'pp, 10'pp, 80'pp, 80'pp
cornerRadius 10.0
button "btn":
box 10'pp, 10'pp, 80'pp, 10'pp
fill "#2B9FEA"
for i in 0 .. 1:
button("btn", state(int), captures(i)):
let btn = current
box 10'pp, 10'pp, 50'pp, 50'pp
contents "child":
text "text":
box csPerc(5 + 12), 5'pp, 40'pp, 40'pp
fill blackColor
setText({font: "test-" & $i})
var main = Main.new()
connect(main, doDraw, main, Main.draw)
echo "main: ", main.listeners
app.width = 400
app.height = 400
startFiguro(main)
Thanks, I tried it out and it seems to be working fine on MacOS. I do recall having similar issues before with Fidget/Fidgetty. Likely that means it's an issue on Windows then. I have a Windows machine but it's not setup, so I'll have to set it up.
There used to be a "set minimum window size" option in Fidget. If we had that setup we could just set minimum window sizes for now.
Also, looks like you were playing around with the layout. I just added basic vertical layouts so you can try them out. There's also horizontal this PR https://github.com/elcritch/figuro/pull/51. Also, I recommend checking out the grid layout examples, like texample.nim, tgrid.nim, and tgridautoflow.nim. It's really nice once you get the hang of it!
Here's some toying with your example using vertical, and a "spacer rect" like you'd do in HTML:
## This minimal example shows 5 blue squares.
import figuro/widgets/[buttonWrap, vertical]
import figuro/widget
import figuro
type
Main* = ref object of Figuro
value: float
hasHovered: bool
hoveredAlpha: float
mainRect: Figuro
let
typeface = loadTypeFace("IBMPlexSans-Regular.ttf")
font = UiFont(typefaceId: typeface, size: 22)
proc draw*(self: Main) {.slot.} =
withDraw(self):
rectangle "body":
fill "#D0D0D0"
box 10'pp, 10'pp, 80'pp, 80'pp
cornerRadius 10.0
vertical "body":
button "btn":
offset 30'pp, 20'ux
size 80'ux, 40'ux
fill "#2B9FEA"
rectangle "skip":
size 80'ux, 40'ux
for i in 0 .. 1:
button("btn", state(int), captures(i)):
let btn = current
# box 10'pp, 10'pp, 50'pp, 50'pp
size 140'ux, 40'ux
contents "child":
text "text":
box csPerc(5 + 12), 5'pp, 100'pp, 40'pp
fill blackColor
setText({font: "test-" & $i})
var main = Main.new()
app.width = 400
app.height = 400
startFiguro(main)