From 0ac56ab7486b21f27dc11b4baa14fb27cdc5ce61 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Ventura?= Date: Fri, 20 May 2016 15:51:10 +0100 Subject: [PATCH 1/2] Create barebones example --- examples/helloworld/main.c | 57 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100755 examples/helloworld/main.c diff --git a/examples/helloworld/main.c b/examples/helloworld/main.c new file mode 100755 index 00000000..63a5f184 --- /dev/null +++ b/examples/helloworld/main.c @@ -0,0 +1,57 @@ +#include +#include +#include "../../ui.h" + +static uiWindow *mainwin; + +static int onClosing(uiWindow *w, void *data) +{ + uiControlDestroy(uiControl(mainwin)); + uiQuit(); + return 0; +} + +static int shouldQuit(void *data) +{ + uiControlDestroy(uiControl(mainwin)); + return 1; +} + +int main(void) +{ + uiInitOptions o; + const char *err; + uiMenu *menu; + uiMenuItem *item; + uiBox *box; + uiLabel *label; + + memset(&o, 0, sizeof (uiInitOptions)); + err = uiInit(&o); + if (err != NULL) { + fprintf(stderr, "error initializing ui: %s\n", err); + uiFreeInitError(err); + return 1; + } + + menu = uiNewMenu("File"); + item = uiMenuAppendItem(menu, "Item"); + item = uiMenuAppendQuitItem(menu); + uiOnShouldQuit(shouldQuit, NULL); + + mainwin = uiNewWindow("Window", 640, 480, 1); + uiWindowSetMargined(mainwin, 1); + uiWindowOnClosing(mainwin, onClosing, NULL); + + box = uiNewVerticalBox(); + uiBoxSetPadded(box, 1); + uiWindowSetChild(mainwin, uiControl(box)); + + label = uiNewLabel("Hello, World!"); + uiBoxAppend(box, uiControl(label), 0); + + uiControlShow(uiControl(mainwin)); + uiMain(); + uiUninit(); + return 0; +} From b44e720e84fa789f213f03b9bf0e84f6447eb1f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Ventura?= Date: Fri, 20 May 2016 15:56:26 +0100 Subject: [PATCH 2/2] Use tabs instead of spaces --- examples/helloworld/main.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/examples/helloworld/main.c b/examples/helloworld/main.c index 63a5f184..efdb38b6 100755 --- a/examples/helloworld/main.c +++ b/examples/helloworld/main.c @@ -24,7 +24,7 @@ int main(void) uiMenu *menu; uiMenuItem *item; uiBox *box; - uiLabel *label; + uiLabel *label; memset(&o, 0, sizeof (uiInitOptions)); err = uiInit(&o); @@ -35,7 +35,7 @@ int main(void) } menu = uiNewMenu("File"); - item = uiMenuAppendItem(menu, "Item"); + item = uiMenuAppendItem(menu, "Item"); item = uiMenuAppendQuitItem(menu); uiOnShouldQuit(shouldQuit, NULL); @@ -46,9 +46,9 @@ int main(void) box = uiNewVerticalBox(); uiBoxSetPadded(box, 1); uiWindowSetChild(mainwin, uiControl(box)); - - label = uiNewLabel("Hello, World!"); - uiBoxAppend(box, uiControl(label), 0); + + label = uiNewLabel("Hello, World!"); + uiBoxAppend(box, uiControl(label), 0); uiControlShow(uiControl(mainwin)); uiMain();