Can I position window automatically, just like layout? #157
-
Hello! First, thanks for all who maintaining this awesome library. I discovered this library recently, and I'm bit surprised that how easy to use this library and how everything is well-documented. I even had some issue about relative path but it was fixed within a day. How awesome! To get the point, I have a question. My question is if there is any way to set windows position automatically. I have a code like this:
I want to position my window at center of the screen. I think I can get window size by Slab.GetWindowSize(), calculate it with my screen size and adjst X/Y coords of the window. But I wonder if it's possible to set window position automatically, just like setting AlignX element of layout. Thank you for reading this post, and have a nice day! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hello there! Thanks for the kind words about this awesome library!.
Yes, you can use the
You can do this with something like: local ww, wh = 640, 480 -- slab window's size
local w, h = love.windows.getDimensions()
local cx = w/2 - ww/2
local cy = h/2 - wh/2
Slab.BeginWindow('login', {Title = ":: Login", AllowMove = false, ShowMinimize = false, X = cx, Y = cy, W = ww, H = wh, AutoSizeWindow = false})
...
If you mean the slab window's position, unfortunately there is nothing implemented for that because it is trivial to calculate and provide your own coordinate and size |
Beta Was this translation helpful? Give feedback.
Hello there! Thanks for the kind words about this awesome library!.
Yes, you can use the
X
andY
parameter in theBeginWindow
.You can do this with something like:
I…