Added tests for the uiWindow methods being called after init/on the right thread. To actually implement those, wrote OS-independent wrappers for the uiWindow functions. This will likely become a pattern throughout libui...
This commit is contained in:
parent
0dd4bec2af
commit
de3598df80
|
@ -6,6 +6,7 @@ libui_sources += [
|
||||||
'common/errors.c',
|
'common/errors.c',
|
||||||
'common/main.c',
|
'common/main.c',
|
||||||
'common/utf8.c',
|
'common/utf8.c',
|
||||||
|
'common/window.c',
|
||||||
|
|
||||||
'common/third_party/utf.c',
|
'common/third_party/utf.c',
|
||||||
]
|
]
|
||||||
|
|
|
@ -81,6 +81,12 @@ extern uiControlOSVtable *uiprivControlOSVtable(uiControl *c);
|
||||||
extern char *uiprivSanitizeUTF8(const char *str);
|
extern char *uiprivSanitizeUTF8(const char *str);
|
||||||
extern void uiprivFreeUTF8(char *sanitized);
|
extern void uiprivFreeUTF8(char *sanitized);
|
||||||
|
|
||||||
|
// window.c
|
||||||
|
extern uint32_t uiprivSysWindowType(void);
|
||||||
|
extern uiWindow *uiprivSysNewWindow(void);
|
||||||
|
extern const char *uiprivSysWindowTitle(uiWindow *w);
|
||||||
|
extern void uiprivSysWindowSetTitle(uiWindow *w, const char *title);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -0,0 +1,33 @@
|
||||||
|
// 25 may 2020
|
||||||
|
#include "uipriv.h"
|
||||||
|
|
||||||
|
uint32_t uiWindowType(void)
|
||||||
|
{
|
||||||
|
if (!uiprivCheckInitializedAndThread())
|
||||||
|
return 0;
|
||||||
|
return uiprivSysWindowType();
|
||||||
|
}
|
||||||
|
|
||||||
|
uiWindow *uiNewWindow(void)
|
||||||
|
{
|
||||||
|
if (!uiprivCheckInitializedAndThread())
|
||||||
|
return NULL;
|
||||||
|
return uiprivSysNewWindow();
|
||||||
|
}
|
||||||
|
|
||||||
|
const char *uiWindowTitle(uiWindow *w)
|
||||||
|
{
|
||||||
|
if (!uiprivCheckInitializedAndThread())
|
||||||
|
return NULL;
|
||||||
|
// TODO check for w == NULL?
|
||||||
|
return uiprivSysWindowTitle(w);
|
||||||
|
}
|
||||||
|
|
||||||
|
void uiWindowSetTitle(uiWindow *w, const char *title)
|
||||||
|
{
|
||||||
|
if (!uiprivCheckInitializedAndThread())
|
||||||
|
return;
|
||||||
|
// TODO check for w == NULL?
|
||||||
|
// TODO other errors
|
||||||
|
uiprivSysWindowSetTitle(w, title);
|
||||||
|
}
|
|
@ -21,6 +21,7 @@ struct windowImplData {
|
||||||
};
|
};
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
|
// skip {
|
||||||
|
|
||||||
@implementation uiprivNSWindow
|
@implementation uiprivNSWindow
|
||||||
|
|
||||||
|
@ -152,8 +153,6 @@ static void uiWindowDestroy(uiControl *c)
|
||||||
uiFreeControl(uiControl(w));
|
uiFreeControl(uiControl(w));
|
||||||
}
|
}
|
||||||
|
|
||||||
uiDarwinControlDefaultHandle(uiWindow, window)
|
|
||||||
|
|
||||||
uiControl *uiWindowParent(uiControl *c)
|
uiControl *uiWindowParent(uiControl *c)
|
||||||
{
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -361,6 +360,7 @@ static void defaultOnPositionContentSizeChanged(uiWindow *w, void *data)
|
||||||
// do nothing
|
// do nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// } skip
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static bool windowInit(uiControl *c, void *implData, void *initData)
|
static bool windowInit(uiControl *c, void *implData, void *initData)
|
||||||
|
@ -437,19 +437,19 @@ static const uiControlOSVtable windowOSVtable = {
|
||||||
|
|
||||||
static uint32_t windowType = 0;
|
static uint32_t windowType = 0;
|
||||||
|
|
||||||
uint32_t uiWindowType(void)
|
uint32_t uiprivSysWindowType(void)
|
||||||
{
|
{
|
||||||
if (windowType == 0)
|
if (windowType == 0)
|
||||||
windowType = uiRegisterControlType("uiWindow", &windowVtable, &windowOSVtable, sizeof (struct windowImplData));
|
windowType = uiRegisterControlType("uiWindow", &windowVtable, &windowOSVtable, sizeof (struct windowImplData));
|
||||||
return windowType;
|
return windowType;
|
||||||
}
|
}
|
||||||
|
|
||||||
uiWindow *uiNewWindow(void)
|
uiWindow *uiprivSysNewWindow(void)
|
||||||
{
|
{
|
||||||
return (uiWindow *) uiNewControl(uiWindowType(), NULL);
|
return (uiWindow *) uiNewControl(uiWindowType(), NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *uiWindowTitle(uiWindow *w)
|
const char *uiprivSysWindowTitle(uiWindow *w)
|
||||||
{
|
{
|
||||||
struct windowImplData *wi = (struct windowImplData *) uiControlImplData(uiControl(w));
|
struct windowImplData *wi = (struct windowImplData *) uiControlImplData(uiControl(w));
|
||||||
|
|
||||||
|
@ -459,7 +459,7 @@ const char *uiWindowTitle(uiWindow *w)
|
||||||
return wi->title;
|
return wi->title;
|
||||||
}
|
}
|
||||||
|
|
||||||
void uiWindowSetTitle(uiWindow *w, const char *title)
|
void uiprivSysWindowSetTitle(uiWindow *w, const char *title)
|
||||||
{
|
{
|
||||||
struct windowImplData *wi = (struct windowImplData *) uiControlImplData(uiControl(w));
|
struct windowImplData *wi = (struct windowImplData *) uiControlImplData(uiControl(w));
|
||||||
|
|
||||||
|
|
|
@ -15,3 +15,9 @@ allcallsCase(uiNewControl, 0, NULL)
|
||||||
allcallsCase(uiControlFree, NULL)
|
allcallsCase(uiControlFree, NULL)
|
||||||
allcallsCase(uiControlSetParent, NULL, NULL)
|
allcallsCase(uiControlSetParent, NULL, NULL)
|
||||||
allcallsCase(uiControlImplData, NULL)
|
allcallsCase(uiControlImplData, NULL)
|
||||||
|
|
||||||
|
allcallsCase(uiWindowType, /* no arguments */)
|
||||||
|
|
||||||
|
allcallsCase(uiNewWindow, /* no arguments */)
|
||||||
|
allcallsCase(uiWindowTitle, NULL)
|
||||||
|
allcallsCase(uiWindowSetTitle, NULL, NULL)
|
||||||
|
|
Loading…
Reference in New Issue