Connected events in the opentype example.

This commit is contained in:
Pietro Gagliardi 2017-06-11 00:37:26 -04:00
parent 8728dcb5c0
commit 85c39c6cb3
1 changed files with 20 additions and 0 deletions

View File

@ -5,6 +5,8 @@
#include <time.h> #include <time.h>
#include "../../ui.h" #include "../../ui.h"
// TODO the grid simply flat out does not work on OS X
uiWindow *mainwin; uiWindow *mainwin;
uiFontButton *fontButton; uiFontButton *fontButton;
uiEntry *textEntry; uiEntry *textEntry;
@ -81,6 +83,21 @@ static int handlerKeyEvent(uiAreaHandler *ah, uiArea *a, uiAreaKeyEvent *e)
return 0; return 0;
} }
static void onFontChanged(uiFontButton *b, void *data)
{
remakeAttrStr();
}
static void onTextChanged(uiEntry *e, void *data)
{
remakeAttrStr();
}
static void onNULLToggled(uiCheckbox *c, void *data)
{
remakeAttrStr();
}
static int onClosing(uiWindow *w, void *data) static int onClosing(uiWindow *w, void *data)
{ {
// TODO change the others to be like this? (the others destroy here rather than later) // TODO change the others to be like this? (the others destroy here rather than later)
@ -129,6 +146,7 @@ int main(void)
uiWindowSetChild(mainwin, uiControl(grid)); uiWindowSetChild(mainwin, uiControl(grid));
fontButton = uiNewFontButton(); fontButton = uiNewFontButton();
uiFontButtonOnChanged(fontButton, onFontChanged, NULL);
uiGridAppend(grid, uiControl(fontButton), uiGridAppend(grid, uiControl(fontButton),
0, 0, 1, 1, 0, 0, 1, 1,
// TODO are these Y values correct? // TODO are these Y values correct?
@ -136,6 +154,7 @@ int main(void)
textEntry = uiNewEntry(); textEntry = uiNewEntry();
uiEntrySetText(textEntry, "afford afire aflight"); uiEntrySetText(textEntry, "afford afire aflight");
uiEntryOnChanged(textEntry, onTextChanged, NULL);
uiGridAppend(grid, uiControl(textEntry), uiGridAppend(grid, uiControl(textEntry),
1, 0, 1, 1, 1, 0, 1, 1,
// TODO are these Y values correct too? // TODO are these Y values correct too?
@ -149,6 +168,7 @@ int main(void)
0, uiAlignFill, 1, uiAlignFill); 0, uiAlignFill, 1, uiAlignFill);
nullFeatures = uiNewCheckbox("NULL uiOpenTypeFeatures"); nullFeatures = uiNewCheckbox("NULL uiOpenTypeFeatures");
uiCheckboxOnToggled(nullFeatures, onNULLToggled, NULL);
uiBoxAppend(vbox, uiControl(nullFeatures), 0); uiBoxAppend(vbox, uiControl(nullFeatures), 0);
// TODO separator (if other stuff isn't a tab) // TODO separator (if other stuff isn't a tab)