Started a new controlgallery. Fixed some glitches in OS X uiForm.
This commit is contained in:
parent
9f4092dab5
commit
41ec54cb47
|
@ -260,11 +260,8 @@ struct uiForm {
|
||||||
prev = [fc view];
|
prev = [fc view];
|
||||||
prevlabel = fc;
|
prevlabel = fc;
|
||||||
}
|
}
|
||||||
relation = NSLayoutRelationEqual;
|
|
||||||
if (self->nStretchy != 0)
|
|
||||||
relation = NSLayoutRelationLessThanOrEqual;
|
|
||||||
self->last = mkConstraint(prev, NSLayoutAttributeBottom,
|
self->last = mkConstraint(prev, NSLayoutAttributeBottom,
|
||||||
relation,
|
NSLayoutRelationEqual,
|
||||||
self, NSLayoutAttributeBottom,
|
self, NSLayoutAttributeBottom,
|
||||||
1, 0,
|
1, 0,
|
||||||
@"uiForm last vertical constraint");
|
@"uiForm last vertical constraint");
|
||||||
|
@ -314,6 +311,25 @@ struct uiForm {
|
||||||
[self->trailings addObject:c];
|
[self->trailings addObject:c];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// and make all stretchy controls have the same height
|
||||||
|
prev = nil;
|
||||||
|
for (fc in self->children) {
|
||||||
|
if (!fc.stretchy)
|
||||||
|
continue;
|
||||||
|
if (prev == nil) {
|
||||||
|
prev = [fc view];
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
c = mkConstraint([fc view], NSLayoutAttributeHeight,
|
||||||
|
NSLayoutRelationEqual,
|
||||||
|
prev, NSLayoutAttributeHeight,
|
||||||
|
1, 0,
|
||||||
|
@"uiForm stretchy constraint");
|
||||||
|
[self addConstraint:c];
|
||||||
|
// TODO make a dedicated array for this
|
||||||
|
[self->leadings addObject:c];
|
||||||
|
}
|
||||||
|
|
||||||
// we don't arrange the labels vertically; that's done when we add the control since those constraints don't need to change (they just need to be at their baseline)
|
// we don't arrange the labels vertically; that's done when we add the control since those constraints don't need to change (they just need to be at their baseline)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -333,7 +349,6 @@ struct uiForm {
|
||||||
[self addSubview:fc];
|
[self addSubview:fc];
|
||||||
|
|
||||||
uiControlSetParent(fc.c, uiControl(self->f));
|
uiControlSetParent(fc.c, uiControl(self->f));
|
||||||
// TODO fix this it's wrong
|
|
||||||
uiDarwinControlSetSuperview(uiDarwinControl(fc.c), self);
|
uiDarwinControlSetSuperview(uiDarwinControl(fc.c), self);
|
||||||
uiDarwinControlSyncEnableState(uiDarwinControl(fc.c), uiControlEnabledToUser(uiControl(self->f)));
|
uiDarwinControlSyncEnableState(uiDarwinControl(fc.c), uiControlEnabledToUser(uiControl(self->f)));
|
||||||
|
|
||||||
|
|
|
@ -3,25 +3,114 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "../../ui.h"
|
#include "../../ui.h"
|
||||||
|
|
||||||
// TODOs
|
|
||||||
// - rename variables in main()
|
|
||||||
// - make both columns the same size?
|
|
||||||
|
|
||||||
static uiWindow *mainwin;
|
|
||||||
|
|
||||||
static int onClosing(uiWindow *w, void *data)
|
static int onClosing(uiWindow *w, void *data)
|
||||||
{
|
{
|
||||||
uiControlDestroy(uiControl(mainwin));
|
|
||||||
uiQuit();
|
uiQuit();
|
||||||
return 0;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int shouldQuit(void *data)
|
static int onShouldQuit(void *data)
|
||||||
{
|
{
|
||||||
|
uiWindow *mainwin = uiWindow(data);
|
||||||
|
|
||||||
uiControlDestroy(uiControl(mainwin));
|
uiControlDestroy(uiControl(mainwin));
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static uiControl *makeBasicControlsPage(void)
|
||||||
|
{
|
||||||
|
uiBox *vbox;
|
||||||
|
uiBox *hbox;
|
||||||
|
uiGroup *group;
|
||||||
|
uiForm *entryForm;
|
||||||
|
|
||||||
|
vbox = uiNewVerticalBox();
|
||||||
|
uiBoxSetPadded(vbox, 1);
|
||||||
|
|
||||||
|
hbox = uiNewHorizontalBox();
|
||||||
|
uiBoxSetPadded(hbox, 1);
|
||||||
|
uiBoxAppend(vbox, uiControl(hbox), 0);
|
||||||
|
|
||||||
|
uiBoxAppend(hbox,
|
||||||
|
uiControl(uiNewButton("Button")),
|
||||||
|
0);
|
||||||
|
uiBoxAppend(hbox,
|
||||||
|
uiControl(uiNewCheckbox("Checkbox")),
|
||||||
|
0);
|
||||||
|
|
||||||
|
uiBoxAppend(vbox,
|
||||||
|
uiControl(uiNewLabel("This is a label. Right now, labels can only span one line.")),
|
||||||
|
0);
|
||||||
|
|
||||||
|
uiBoxAppend(vbox,
|
||||||
|
uiControl(uiNewHorizontalSeparator()),
|
||||||
|
0);
|
||||||
|
|
||||||
|
group = uiNewGroup("Entries");
|
||||||
|
uiGroupSetMargined(group, 1);
|
||||||
|
uiBoxAppend(vbox, uiControl(group), 1);
|
||||||
|
|
||||||
|
entryForm = uiNewForm();
|
||||||
|
uiFormSetPadded(entryForm, 1);
|
||||||
|
uiGroupSetChild(group, uiControl(entryForm));
|
||||||
|
|
||||||
|
uiFormAppend(entryForm,
|
||||||
|
"Entry",
|
||||||
|
uiControl(uiNewEntry()),
|
||||||
|
0);
|
||||||
|
uiFormAppend(entryForm,
|
||||||
|
"Password Entry",
|
||||||
|
uiControl(uiNewPasswordEntry()),
|
||||||
|
0);
|
||||||
|
uiFormAppend(entryForm,
|
||||||
|
"Search Entry",
|
||||||
|
uiControl(uiNewSearchEntry()),
|
||||||
|
0);
|
||||||
|
uiFormAppend(entryForm,
|
||||||
|
"Multiline Entry",
|
||||||
|
uiControl(uiNewMultilineEntry()),
|
||||||
|
1);
|
||||||
|
uiFormAppend(entryForm,
|
||||||
|
"Multiline Entry No Wrap",
|
||||||
|
uiControl(uiNewNonWrappingMultilineEntry()),
|
||||||
|
1);
|
||||||
|
|
||||||
|
return uiControl(vbox);
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
uiInitOptions options;
|
||||||
|
const char *err;
|
||||||
|
uiWindow *mainwin;
|
||||||
|
uiTab *tab;
|
||||||
|
|
||||||
|
memset(&options, 0, sizeof (uiInitOptions));
|
||||||
|
err = uiInit(&options);
|
||||||
|
if (err != NULL) {
|
||||||
|
fprintf(stderr, "error initializing libui: %s", err);
|
||||||
|
uiFreeInitError(err);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
mainwin = uiNewWindow("libui Control Gallery", 640, 480, 1);
|
||||||
|
uiWindowOnClosing(mainwin, onClosing, NULL);
|
||||||
|
uiOnShouldQuit(onShouldQuit, mainwin);
|
||||||
|
|
||||||
|
tab = uiNewTab();
|
||||||
|
uiWindowSetChild(mainwin, uiControl(tab));
|
||||||
|
uiWindowSetMargined(mainwin, 1);
|
||||||
|
|
||||||
|
uiTabAppend(tab, "Basic Controls", makeBasicControlsPage());
|
||||||
|
uiTabSetMargined(tab, 0, 1);
|
||||||
|
|
||||||
|
uiControlShow(uiControl(mainwin));
|
||||||
|
uiMain();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
|
||||||
static void openClicked(uiMenuItem *item, uiWindow *w, void *data)
|
static void openClicked(uiMenuItem *item, uiWindow *w, void *data)
|
||||||
{
|
{
|
||||||
char *filename;
|
char *filename;
|
||||||
|
@ -230,3 +319,5 @@ int main(void)
|
||||||
uiUninit();
|
uiUninit();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
|
@ -17,7 +17,6 @@ struct uiForm {
|
||||||
GtkGrid *grid;
|
GtkGrid *grid;
|
||||||
GArray *children;
|
GArray *children;
|
||||||
int padded;
|
int padded;
|
||||||
// TODO OS X is missing this
|
|
||||||
GtkSizeGroup *stretchygroup; // ensures all stretchy controls have the same size
|
GtkSizeGroup *stretchygroup; // ensures all stretchy controls have the same size
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue