2016-06-15 12:21:07 -05:00
|
|
|
// 15 june 2016
|
|
|
|
#include "test.h"
|
|
|
|
|
2016-06-15 13:57:52 -05:00
|
|
|
static uiSpinbox *x, *y;
|
2016-06-15 21:28:44 -05:00
|
|
|
static uiSpinbox *width, *height;
|
2016-06-15 13:57:52 -05:00
|
|
|
|
|
|
|
static void moveX(uiSpinbox *s, void *data)
|
|
|
|
{
|
|
|
|
uiWindow *w = uiWindow(data);
|
|
|
|
int xp, yp;
|
|
|
|
|
|
|
|
uiWindowPosition(w, &xp, &yp);
|
|
|
|
xp = uiSpinboxValue(x);
|
|
|
|
uiWindowSetPosition(w, xp, yp);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void moveY(uiSpinbox *s, void *data)
|
2016-06-15 12:21:07 -05:00
|
|
|
{
|
|
|
|
uiWindow *w = uiWindow(data);
|
2016-06-15 13:57:52 -05:00
|
|
|
int xp, yp;
|
2016-06-15 12:21:07 -05:00
|
|
|
|
2016-06-15 13:57:52 -05:00
|
|
|
uiWindowPosition(w, &xp, &yp);
|
|
|
|
yp = uiSpinboxValue(y);
|
|
|
|
uiWindowSetPosition(w, xp, yp);
|
2016-06-15 12:21:07 -05:00
|
|
|
}
|
|
|
|
|
2016-06-15 21:28:44 -05:00
|
|
|
static void updatepos(uiWindow *w)
|
2016-06-15 13:57:52 -05:00
|
|
|
{
|
|
|
|
int xp, yp;
|
|
|
|
|
|
|
|
uiWindowPosition(w, &xp, &yp);
|
|
|
|
uiSpinboxSetValue(x, xp);
|
|
|
|
uiSpinboxSetValue(y, yp);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void center(uiButton *b, void *data)
|
2016-06-15 12:21:07 -05:00
|
|
|
{
|
|
|
|
uiWindow *w = uiWindow(data);
|
|
|
|
|
2016-06-15 13:57:52 -05:00
|
|
|
uiWindowCenter(w);
|
2016-06-15 21:28:44 -05:00
|
|
|
updatepos(w);
|
2016-06-15 12:21:07 -05:00
|
|
|
}
|
|
|
|
|
2016-06-15 13:57:52 -05:00
|
|
|
void onMove(uiWindow *w, void *data)
|
|
|
|
{
|
|
|
|
printf("move\n");
|
2016-06-15 21:28:44 -05:00
|
|
|
updatepos(w);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void sizeWidth(uiSpinbox *s, void *data)
|
|
|
|
{
|
|
|
|
uiWindow *w = uiWindow(data);
|
|
|
|
int xp, yp;
|
|
|
|
|
2016-06-15 21:52:35 -05:00
|
|
|
uiWindowContentSize(w, &xp, &yp);
|
2016-06-15 21:28:44 -05:00
|
|
|
xp = uiSpinboxValue(width);
|
|
|
|
uiWindowSetContentSize(w, xp, yp);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void sizeHeight(uiSpinbox *s, void *data)
|
|
|
|
{
|
|
|
|
uiWindow *w = uiWindow(data);
|
|
|
|
int xp, yp;
|
|
|
|
|
|
|
|
uiWindowContentSize(w, &xp, &yp);
|
|
|
|
yp = uiSpinboxValue(height);
|
|
|
|
uiWindowSetContentSize(w, xp, yp);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void updatesize(uiWindow *w)
|
|
|
|
{
|
|
|
|
int xp, yp;
|
|
|
|
|
|
|
|
uiWindowContentSize(w, &xp, &yp);
|
|
|
|
uiSpinboxSetValue(width, xp);
|
|
|
|
uiSpinboxSetValue(height, yp);
|
|
|
|
}
|
|
|
|
|
|
|
|
void onSize(uiWindow *w, void *data)
|
|
|
|
{
|
|
|
|
printf("size\n");
|
|
|
|
updatesize(w);
|
2016-06-15 13:57:52 -05:00
|
|
|
}
|
2016-06-15 12:21:07 -05:00
|
|
|
|
|
|
|
uiBox *makePage15(uiWindow *w)
|
|
|
|
{
|
|
|
|
uiBox *page15;
|
|
|
|
uiBox *hbox;
|
2016-06-15 13:57:52 -05:00
|
|
|
uiButton *button;
|
2016-06-15 12:21:07 -05:00
|
|
|
|
|
|
|
page15 = newVerticalBox();
|
|
|
|
|
|
|
|
hbox = newHorizontalBox();
|
2016-06-15 15:45:49 -05:00
|
|
|
// TODO if I make this 1 and not add anything else AND not call uiWindowOnPositionChanged(), on OS X the box won't be able to grow vertically
|
2016-06-15 13:57:52 -05:00
|
|
|
uiBoxAppend(page15, uiControl(hbox), 0);
|
2016-06-15 12:21:07 -05:00
|
|
|
|
|
|
|
uiBoxAppend(hbox, uiControl(uiNewLabel("Position")), 0);
|
|
|
|
x = uiNewSpinbox(INT_MIN, INT_MAX);
|
|
|
|
uiBoxAppend(hbox, uiControl(x), 1);
|
|
|
|
y = uiNewSpinbox(INT_MIN, INT_MAX);
|
|
|
|
uiBoxAppend(hbox, uiControl(y), 1);
|
2016-06-15 13:57:52 -05:00
|
|
|
button = uiNewButton("Center");
|
|
|
|
uiBoxAppend(hbox, uiControl(button), 0);
|
2016-06-15 12:21:07 -05:00
|
|
|
|
|
|
|
uiSpinboxOnChanged(x, moveX, w);
|
|
|
|
uiSpinboxOnChanged(y, moveY, w);
|
2016-06-15 13:57:52 -05:00
|
|
|
uiButtonOnClicked(button, center, w);
|
|
|
|
uiWindowOnPositionChanged(w, onMove, NULL);
|
2016-06-15 21:28:44 -05:00
|
|
|
updatepos(w);
|
|
|
|
|
|
|
|
hbox = newHorizontalBox();
|
|
|
|
uiBoxAppend(page15, uiControl(hbox), 0);
|
|
|
|
|
|
|
|
uiBoxAppend(hbox, uiControl(uiNewLabel("Size")), 0);
|
|
|
|
width = uiNewSpinbox(INT_MIN, INT_MAX);
|
|
|
|
uiBoxAppend(hbox, uiControl(width), 1);
|
|
|
|
height = uiNewSpinbox(INT_MIN, INT_MAX);
|
|
|
|
uiBoxAppend(hbox, uiControl(height), 1);
|
|
|
|
// button = uiNewButton("Center");
|
|
|
|
// uiBoxAppend(hbox, uiControl(button), 0);
|
|
|
|
|
|
|
|
uiSpinboxOnChanged(width, sizeWidth, w);
|
|
|
|
uiSpinboxOnChanged(height, sizeHeight, w);
|
|
|
|
// uiButtonOnClicked(button, center, w);
|
|
|
|
uiWindowOnContentSizeChanged(w, onSize, NULL);
|
|
|
|
updatesize(w);
|
2016-06-15 12:21:07 -05:00
|
|
|
|
|
|
|
return page15;
|
|
|
|
}
|