From d2c491dbd067e402ab9a0f92a2f6810cc2bd5d3b Mon Sep 17 00:00:00 2001 From: Pietro Gagliardi Date: Wed, 29 Apr 2015 20:15:29 -0400 Subject: [PATCH] Readded the moving label test, which starts Page 2. --- test/GNUmakeinc.mk | 1 + test/main.c | 5 ++++- test/page2.c | 51 ++++++++++++++++++++++++++++++++++++++++++++++ test/test.h | 3 +++ 4 files changed, 59 insertions(+), 1 deletion(-) create mode 100644 test/page2.c diff --git a/test/GNUmakeinc.mk b/test/GNUmakeinc.mk index 851684fa..64de326d 100644 --- a/test/GNUmakeinc.mk +++ b/test/GNUmakeinc.mk @@ -4,6 +4,7 @@ testCFILES = \ test/main.c \ test/menus.c \ test/page1.c \ + test/page2.c \ test/spaced.c testHFILES = \ diff --git a/test/main.c b/test/main.c index f1fdc267..08840af6 100644 --- a/test/main.c +++ b/test/main.c @@ -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"); diff --git a/test/page2.c b/test/page2.c new file mode 100644 index 00000000..67a0f6a7 --- /dev/null +++ b/test/page2.c @@ -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; +} diff --git a/test/test.h b/test/test.h index 076027ce..fec80556 100644 --- a/test/test.h +++ b/test/test.h @@ -23,3 +23,6 @@ extern void initMenus(void); // page1.c extern uiBox *makePage1(uiWindow *); + +// page2.c +extern uiBox *makePage2(void);