Readded the moving label test, which starts Page 2.

This commit is contained in:
Pietro Gagliardi 2015-04-29 20:15:29 -04:00
parent 0370f10031
commit d2c491dbd0
4 changed files with 59 additions and 1 deletions

View File

@ -4,6 +4,7 @@ testCFILES = \
test/main.c \
test/menus.c \
test/page1.c \
test/page2.c \
test/spaced.c
testHFILES = \

View File

@ -23,7 +23,7 @@ int main(int argc, char *argv[])
const char *err;
uiWindow *w;
uiTab *tab;
uiBox *page1;
uiBox *page1, *page2;
memset(&o, 0, sizeof (uiInitOptions));
for (i = 1; i < argc; i++)
@ -55,6 +55,9 @@ int main(int argc, char *argv[])
page1 = makePage1(w);
uiTabAppendPage(tab, "Page 1", uiControl(page1));
page2 = makePage2();
uiTabAppendPage(tab, "Page 2", uiControl(page2));
uiControlShow(uiControl(w));
uiMain();
printf("after uiMain()\n");

51
test/page2.c Normal file
View File

@ -0,0 +1,51 @@
// 29 april 2015
#include "test.h"
static uiLabel *movingLabel;
static uiBox *movingBoxes[2];
static int movingCurrent;
static void moveLabel(uiButton *b, void *data)
{
int from, to;
from = movingCurrent;
to = 0;
if (from == 0)
to = 1;
uiBoxDelete(movingBoxes[from], 0);
uiBoxAppend(movingBoxes[to], uiControl(movingLabel), 0);
movingCurrent = to;
}
// TODO tab manipulation
uiBox *makePage2(void)
{
uiBox *page2;
uiBox *hbox;
uiButton *button;
page2 = newVerticalBox();
hbox = newHorizontalBox();
button = uiNewButton("Move the Label!");
uiButtonOnClicked(button, moveLabel, NULL);
uiBoxAppend(hbox, uiControl(button), 1);
// have a blank label for space
uiBoxAppend(hbox, uiControl(uiNewLabel("")), 1);
uiBoxAppend(page2, uiControl(hbox), 0);
hbox = newHorizontalBox();
movingBoxes[0] = newVerticalBox();
uiBoxAppend(hbox, uiControl(movingBoxes[0]), 1);
movingBoxes[1] = newVerticalBox();
uiBoxAppend(hbox, uiControl(movingBoxes[1]), 1);
uiBoxAppend(page2, uiControl(hbox), 0);
movingCurrent = 0;
movingLabel = uiNewLabel("This label moves!");
uiBoxAppend(movingBoxes[movingCurrent], uiControl(movingLabel), 0);
return page2;
}

View File

@ -23,3 +23,6 @@ extern void initMenus(void);
// page1.c
extern uiBox *makePage1(uiWindow *);
// page2.c
extern uiBox *makePage2(void);