Added a page to the test program tab for testing uiBox padding and hidden control interaction, which is currently incorrect.

This commit is contained in:
Pietro Gagliardi 2015-05-07 17:13:16 -04:00
parent d6aeb3c0a7
commit 3872b9777a
4 changed files with 77 additions and 1 deletions

View File

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

View File

@ -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");

69
test/page3.c Normal file
View File

@ -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;
}

View File

@ -28,3 +28,6 @@ extern void makePage1(uiWindow *);
// page2.c
extern uiBox *makePage2(void);
// page3.c
extern uiBox *makePage3(void);