ID:132546
 
onWindowResize proc (client)


Format:
onWindowResize(windowName, maximized=false, minimized=false)

When:
This procedure is called when the client resizes his window. [Perhaps only report if a window flag is set that says "report resizing"]

Default action:
Nothing.

The client resizing the window is the src of this procedure. windowName is, of course, the name of the window being resized. If the user maximizes or minimizes the window, this is also called with the appropriate parameters. [Alternatively, onWindowMaximize(), onWindowMinimize()]

Example:
client/onWindowResize(windowName)
if(windowName == "mainWindow")
var/const/components = 6
var/const/spacer = 8
var/const/y_pos = 8
var/const/x_pos = 8
var/const/component_height = 40

var/cursor_pos = x_pos
var/window_size = winget(src, "mainWindow", "size")
var/window_width = text2num(copytext(window_size, 1, findtextEx(window_size, "x")))-(x_pos*2)

var/component_width = floor((window_width - spacer*(components-1))/components)
var/size = "[component_width]x[component_height]"

for(var/i=1 to components)
winset(src, "mainWindow.component[i]", "size=[size]&pos=[cursor_pos]x[y_pos]")
cursor_pos += component_width + spacer





As you can see, I am trying to allot components on the window according to my own standard. I currently cannot duplicate this effort with anchors, so I thought I would do it programatically. Alas, I cannot. The best I can hope for is a little javascript or an update_window() verb, and even that is not perfect--I cannot get the size of the window as it is maximized.

I have these little boxes lining the top of the window. I need them to be padded from the left and right of the window by 8 units, and I want the distance of each box 8 units away from his neighbors. I am adjusting the width of the box accordingly.

Imagine:
[][box1][][box2][][box3][][box4][][box5][][box6][]
Where every empty cell is exactly 8 units wide and every box is exactly the same width and height as the next.

I tried using the auto-anchors for the group (having all selected boxes aligned, locked in width and height) and they just end up being spaced differently every other box.

Anyway, I figure why not have these callbacks? They add a little extra polish to the BYOND Suite, and with all these skin updates I think these are just necessary functions missing from a toolkit.
The Feature Tracker is better for this stuff. Should be noted that there's already a request for this.