aboutsummaryrefslogtreecommitdiff
path: root/src/libui_sdl/libui/test/page3.c
blob: 1f229e937dd7dda30295a358a0386a246c496074 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
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 = (*newhbox)();
	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 = (*newhbox)();
		vbox = (*newvbox)();
		// 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;
}