From 3872b9777adc19895db51855530391f07c59c5bc Mon Sep 17 00:00:00 2001 From: Pietro Gagliardi Date: Thu, 7 May 2015 17:13:16 -0400 Subject: [PATCH] Added a page to the test program tab for testing uiBox padding and hidden control interaction, which is currently incorrect. --- test/GNUmakeinc.mk | 1 + test/main.c | 5 +++- test/page3.c | 69 ++++++++++++++++++++++++++++++++++++++++++++++ test/test.h | 3 ++ 4 files changed, 77 insertions(+), 1 deletion(-) create mode 100644 test/page3.c diff --git a/test/GNUmakeinc.mk b/test/GNUmakeinc.mk index 64de326d..1e845e7d 100644 --- a/test/GNUmakeinc.mk +++ b/test/GNUmakeinc.mk @@ -5,6 +5,7 @@ testCFILES = \ test/menus.c \ test/page1.c \ test/page2.c \ + test/page3.c \ test/spaced.c testHFILES = \ diff --git a/test/main.c b/test/main.c index 61e86445..b24392f0 100644 --- a/test/main.c +++ b/test/main.c @@ -29,7 +29,7 @@ int main(int argc, char *argv[]) int i; const char *err; uiWindow *w; - uiBox *page2; + uiBox *page2, *page3; int nomenus = 0; memset(&o, 0, sizeof (uiInitOptions)); @@ -69,6 +69,9 @@ int main(int argc, char *argv[]) uiTabAppendPage(mainTab, "Empty Page", uiControl(uiNewHorizontalBox())); + page3 = makePage3(); + uiTabAppendPage(mainTab, "Page 3", uiControl(page3)); + uiControlShow(uiControl(w)); uiMain(); printf("after uiMain()\n"); diff --git a/test/page3.c b/test/page3.c new file mode 100644 index 00000000..b9b20605 --- /dev/null +++ b/test/page3.c @@ -0,0 +1,69 @@ +// 7 may 2015 +#include "test.h" + +static uiBox *makeSet(int omit, int hidden, int stretch) +{ + uiBox *hbox; + uiButton *buttons[4]; + + // don't use newHorizontalBox() + // the point of this test is to test hidden controls and padded + hbox = uiNewHorizontalBox(); + uiBoxSetPadded(hbox, 1); + if (omit != 0) { + buttons[0] = uiNewButton("First"); + uiBoxAppend(hbox, uiControl(buttons[0]), stretch); + } + if (omit != 1) { + buttons[1] = uiNewButton("Second"); + uiBoxAppend(hbox, uiControl(buttons[1]), stretch); + } + if (omit != 2) { + buttons[2] = uiNewButton("Third"); + uiBoxAppend(hbox, uiControl(buttons[2]), stretch); + } + if (omit != 3) { + buttons[3] = uiNewButton("Fourth"); + uiBoxAppend(hbox, uiControl(buttons[3]), stretch); + } + if (hidden != -1) + uiControlHide(uiControl(buttons[hidden])); + return hbox; +} + +uiBox *makePage3(void) +{ + uiBox *page3; + uiBox *hbox; + uiBox *hbox2; + uiBox *vbox; + int hidden; + + page3 = newVerticalBox(); + + // first the non-stretchy type + for (hidden = 0; hidden < 4; hidden++) { + // these two must stay unpadded as well, otherwise the test isn't meaningful + hbox2 = uiNewHorizontalBox(); + vbox = uiNewVerticalBox(); + // reference set + hbox = makeSet(hidden, -1, 0); + uiBoxAppend(vbox, uiControl(hbox), 0); + // real thing + hbox = makeSet(-1, hidden, 0); + uiBoxAppend(vbox, uiControl(hbox), 0); + // pack vbox in + uiBoxAppend(hbox2, uiControl(vbox), 0); + // and have a button in there for showing right margins + uiBoxAppend(hbox2, uiControl(uiNewButton("Right Margin Test")), 1); + uiBoxAppend(page3, uiControl(hbox2), 0); + } + + // then the stretchy type + for (hidden = 0; hidden < 4; hidden++) { + hbox = makeSet(-1, hidden, 1); + uiBoxAppend(page3, uiControl(hbox), 0); + } + + return page3; +} diff --git a/test/test.h b/test/test.h index 1f5c98f0..8bb01db6 100644 --- a/test/test.h +++ b/test/test.h @@ -28,3 +28,6 @@ extern void makePage1(uiWindow *); // page2.c extern uiBox *makePage2(void); + +// page3.c +extern uiBox *makePage3(void);