Started the work in removing the move and center functions from uiWindow; those simply cannot be done thanks to Wayland.
This commit is contained in:
parent
d344e1ae29
commit
570b794650
|
@ -0,0 +1,65 @@
|
|||
static uiSpinbox *x, *y;
|
||||
|
||||
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)
|
||||
{
|
||||
uiWindow *w = uiWindow(data);
|
||||
int xp, yp;
|
||||
|
||||
uiWindowPosition(w, &xp, &yp);
|
||||
yp = uiSpinboxValue(y);
|
||||
uiWindowSetPosition(w, xp, yp);
|
||||
}
|
||||
|
||||
static void updatepos(uiWindow *w)
|
||||
{
|
||||
int xp, yp;
|
||||
|
||||
uiWindowPosition(w, &xp, &yp);
|
||||
uiSpinboxSetValue(x, xp);
|
||||
uiSpinboxSetValue(y, yp);
|
||||
}
|
||||
|
||||
static void center(uiButton *b, void *data)
|
||||
{
|
||||
uiWindow *w = uiWindow(data);
|
||||
|
||||
uiWindowCenter(w);
|
||||
updatepos(w);
|
||||
}
|
||||
|
||||
void onMove(uiWindow *w, void *data)
|
||||
{
|
||||
printf("move\n");
|
||||
updatepos(w);
|
||||
}
|
||||
|
||||
uiBox *makePage15(uiWindow *w)
|
||||
{
|
||||
hbox = newHorizontalBox();
|
||||
// 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
|
||||
uiBoxAppend(page15, uiControl(hbox), 0);
|
||||
|
||||
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);
|
||||
button = uiNewButton("Center");
|
||||
uiBoxAppend(hbox, uiControl(button), 0);
|
||||
|
||||
uiSpinboxOnChanged(x, moveX, w);
|
||||
uiSpinboxOnChanged(y, moveY, w);
|
||||
uiButtonOnClicked(button, center, w);
|
||||
uiWindowOnPositionChanged(w, onMove, NULL);
|
||||
updatepos(w);
|
||||
}
|
|
@ -1,53 +1,9 @@
|
|||
// 15 june 2016
|
||||
#include "test.h"
|
||||
|
||||
static uiSpinbox *x, *y;
|
||||
static uiSpinbox *width, *height;
|
||||
static uiCheckbox *fullscreen;
|
||||
|
||||
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)
|
||||
{
|
||||
uiWindow *w = uiWindow(data);
|
||||
int xp, yp;
|
||||
|
||||
uiWindowPosition(w, &xp, &yp);
|
||||
yp = uiSpinboxValue(y);
|
||||
uiWindowSetPosition(w, xp, yp);
|
||||
}
|
||||
|
||||
static void updatepos(uiWindow *w)
|
||||
{
|
||||
int xp, yp;
|
||||
|
||||
uiWindowPosition(w, &xp, &yp);
|
||||
uiSpinboxSetValue(x, xp);
|
||||
uiSpinboxSetValue(y, yp);
|
||||
}
|
||||
|
||||
static void center(uiButton *b, void *data)
|
||||
{
|
||||
uiWindow *w = uiWindow(data);
|
||||
|
||||
uiWindowCenter(w);
|
||||
updatepos(w);
|
||||
}
|
||||
|
||||
void onMove(uiWindow *w, void *data)
|
||||
{
|
||||
printf("move\n");
|
||||
updatepos(w);
|
||||
}
|
||||
|
||||
static void sizeWidth(uiSpinbox *s, void *data)
|
||||
{
|
||||
uiWindow *w = uiWindow(data);
|
||||
|
@ -109,24 +65,6 @@ uiBox *makePage15(uiWindow *w)
|
|||
|
||||
page15 = newVerticalBox();
|
||||
|
||||
hbox = newHorizontalBox();
|
||||
// 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
|
||||
uiBoxAppend(page15, uiControl(hbox), 0);
|
||||
|
||||
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);
|
||||
button = uiNewButton("Center");
|
||||
uiBoxAppend(hbox, uiControl(button), 0);
|
||||
|
||||
uiSpinboxOnChanged(x, moveX, w);
|
||||
uiSpinboxOnChanged(y, moveY, w);
|
||||
uiButtonOnClicked(button, center, w);
|
||||
uiWindowOnPositionChanged(w, onMove, NULL);
|
||||
updatepos(w);
|
||||
|
||||
hbox = newHorizontalBox();
|
||||
uiBoxAppend(page15, uiControl(hbox), 0);
|
||||
|
||||
|
|
Loading…
Reference in New Issue