Kryslin
New member
Here we go...
gbox() makes things easier to move around and resize, though it doesn't make for very readable code. The function itself could use some tweaking; I could give it a "mode" setting, so it automatically adds offset and/or skew values for the main panel and separators, and maybe some variants, for centering things a little nicer.
This got the job done, though.
Code:
//Globals for UI Helper function
var GRIDSIZE = 22;
var SKEW = floor(GRIDSIZE / 2);
var OFFSET = floor(SKEW / 2);
//Global UI Helper Function
gbox : w_x, w_y, w_h, w_w
{
//All units are in grid coordinates
//w_x = x coordinate, w_y = y coordinate
//w_h = height, w_w = width
//This UDF converts from grid coordinates to screen coordinates
var retv[4]; //Return Values
retv[1] = (w_x * GRIDSIZE) + OFFSET;
retv[2] = (w_y * GRIDSIZE) + OFFSET;
retv[3] = (w_h * GRIDSIZE);
retv[4] = (w_w * GRIDSIZE);
return(retv);
}
//Code Snippets...
var a[4]; //array to hold the return values from gbox()
//Sizing your requester panel...
//You only need Height and Width...
reqbegin("My Panel"); a = gbox(0,0,24,18);reqsize(a[3]+OFFSET,a[4]);
//A text box example
a = gbox(5,0,14,1); c1 = ctlstring("Item Name",itemname); ctlposition(c1,a[1],a[2],a[3],a[4]);
//A separator example
//Skew is used to offset the line to the middle of the box
a = gbox(0,1,24,1); s1 = ctlsep(a[1],a[3]); ctlposition(s1,a[1],a[2] + SKEW,a[3],a[4]);
gbox() makes things easier to move around and resize, though it doesn't make for very readable code. The function itself could use some tweaking; I could give it a "mode" setting, so it automatically adds offset and/or skew values for the main panel and separators, and maybe some variants, for centering things a little nicer.
This got the job done, though.