forked from pyrite-dev/milsko
introduce early props
This commit is contained in:
parent
93325bb49c
commit
5d0c84d748
6 changed files with 62 additions and 45 deletions
|
|
@ -624,9 +624,9 @@ int main() {
|
||||||
MwNtitle, "hello world",
|
MwNtitle, "hello world",
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
MwVulkanEnableExtension(VK_KHR_SWAPCHAIN_EXTENSION_NAME);
|
vulkan = MwVaCreateWidget(MwVulkanClass, "vulkan", window, 50, 50, ow, oh,
|
||||||
|
MwNvulkanExtension, VK_KHR_SWAPCHAIN_EXTENSION_NAME,
|
||||||
vulkan = MwCreateWidget(MwVulkanClass, "vulkan", window, 50, 50, ow, oh);
|
NULL);
|
||||||
|
|
||||||
MwAddUserHandler(window, MwNtickHandler, tick, NULL);
|
MwAddUserHandler(window, MwNtickHandler, tick, NULL);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -51,6 +51,9 @@
|
||||||
#define MwNforeground "Sforeground"
|
#define MwNforeground "Sforeground"
|
||||||
#define MwNsubForeground "SsubForeground"
|
#define MwNsubForeground "SsubForeground"
|
||||||
|
|
||||||
|
#define MwNvulkanExtension "SEvulkanExtension"
|
||||||
|
#define MwNvulkanLayer "SEvulkanLayer"
|
||||||
|
|
||||||
#define MwNpixmap "Vpixmap"
|
#define MwNpixmap "Vpixmap"
|
||||||
#define MwNiconPixmap "ViconPixmap"
|
#define MwNiconPixmap "ViconPixmap"
|
||||||
#define MwNsizeHints "VsizeHints"
|
#define MwNsizeHints "VsizeHints"
|
||||||
|
|
|
||||||
|
|
@ -33,18 +33,6 @@ extern "C" {
|
||||||
*/
|
*/
|
||||||
MWDECL MwClass MwVulkanClass;
|
MWDECL MwClass MwVulkanClass;
|
||||||
|
|
||||||
/*!
|
|
||||||
* @brief Add an extension to the list of extensions to enable prior to initialization.
|
|
||||||
* @warning This must be called before MwCreateWidget.
|
|
||||||
*/
|
|
||||||
MWDECL void MwVulkanEnableExtension(const char* ext_name);
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* @brief Add an layer to the list of layers to enable prior to initialization.
|
|
||||||
* @warning This must be called before MwCreateWidget.
|
|
||||||
*/
|
|
||||||
MWDECL void MwVulkanEnableLayer(const char* ext_name);
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief Configuration options that can be passed to setup Vulkan before a widget is created.
|
* @brief Configuration options that can be passed to setup Vulkan before a widget is created.
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -55,6 +55,9 @@
|
||||||
String properties must be prefixed with S.
|
String properties must be prefixed with S.
|
||||||
Handler properties must be prefixed with C.
|
Handler properties must be prefixed with C.
|
||||||
Other properties must be prefixed with V.
|
Other properties must be prefixed with V.
|
||||||
|
|
||||||
|
"Early" properties must have letter "E" as 2nd letter.
|
||||||
|
e.g. vulkanExtension would be SEvulkanExtension
|
||||||
-->
|
-->
|
||||||
<properties>
|
<properties>
|
||||||
<integer name="x" common="yes" />
|
<integer name="x" common="yes" />
|
||||||
|
|
@ -104,6 +107,10 @@
|
||||||
<string name="foreground" common="yes" />
|
<string name="foreground" common="yes" />
|
||||||
<string name="subForeground" common="yes" />
|
<string name="subForeground" common="yes" />
|
||||||
|
|
||||||
|
<!-- Early string properties -->
|
||||||
|
<string name="vulkanExtension" early="yes" />
|
||||||
|
<string name="vulkanLayer" early="yes" />
|
||||||
|
|
||||||
<pixmap name="pixmap" />
|
<pixmap name="pixmap" />
|
||||||
<pixmap name="iconPixmap" />
|
<pixmap name="iconPixmap" />
|
||||||
<struct defname="MwSizeHints" pointer="yes" name="sizeHints" />
|
<struct defname="MwSizeHints" pointer="yes" name="sizeHints" />
|
||||||
|
|
|
||||||
26
src/core.c
26
src/core.c
|
|
@ -18,6 +18,9 @@
|
||||||
MwLLEndDraw(handle->lowlevel); \
|
MwLLEndDraw(handle->lowlevel); \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void MwVaListApply_Internal(MwWidget handle, va_list va, int only_early);
|
||||||
|
static MwWidget MwCreateWidget_Internal(MwClass widget_class, const char* name, MwWidget parent, int x, int y, unsigned int width, unsigned int height, int do_prop, va_list prop);
|
||||||
|
|
||||||
static void lldrawhandler(MwLL handle, void* data) {
|
static void lldrawhandler(MwLL handle, void* data) {
|
||||||
MwWidget h = (MwWidget)handle->common.user;
|
MwWidget h = (MwWidget)handle->common.user;
|
||||||
#ifdef PERIODIC
|
#ifdef PERIODIC
|
||||||
|
|
@ -177,7 +180,7 @@ static void lldarkthemehandler(MwLL handle, void* data) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MwWidget MwCreateWidget(MwClass widget_class, const char* name, MwWidget parent, int x, int y, unsigned int width, unsigned int height) {
|
static MwWidget MwCreateWidget_Internal(MwClass widget_class, const char* name, MwWidget parent, int x, int y, unsigned int width, unsigned int height, int do_prop, va_list prop) {
|
||||||
MwWidget h = malloc(sizeof(*h));
|
MwWidget h = malloc(sizeof(*h));
|
||||||
|
|
||||||
h->name = MwStringDuplicate(name);
|
h->name = MwStringDuplicate(name);
|
||||||
|
|
@ -243,6 +246,8 @@ MwWidget MwCreateWidget(MwClass widget_class, const char* name, MwWidget parent,
|
||||||
shdefault(h->handler, NULL);
|
shdefault(h->handler, NULL);
|
||||||
shdefault(h->data, NULL);
|
shdefault(h->data, NULL);
|
||||||
|
|
||||||
|
if(do_prop) MwVaListApply_Internal(h, prop, 1);
|
||||||
|
|
||||||
h->prop_event = 0;
|
h->prop_event = 0;
|
||||||
if(MwDispatch2(h, create) != 0) {
|
if(MwDispatch2(h, create) != 0) {
|
||||||
h->widget_class = NULL;
|
h->widget_class = NULL;
|
||||||
|
|
@ -276,6 +281,12 @@ MwWidget MwCreateWidget(MwClass widget_class, const char* name, MwWidget parent,
|
||||||
return h;
|
return h;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MwWidget MwCreateWidget(MwClass widget_class, const char* name, MwWidget parent, int x, int y, unsigned int width, unsigned int height) {
|
||||||
|
va_list dummy;
|
||||||
|
|
||||||
|
return MwCreateWidget_Internal(widget_class, name, parent, x, y, width, height, 0, dummy);
|
||||||
|
}
|
||||||
|
|
||||||
MwWidget MwVaCreateWidget(MwClass widget_class, const char* name, MwWidget parent, int x, int y, unsigned int width, unsigned int height, ...) {
|
MwWidget MwVaCreateWidget(MwClass widget_class, const char* name, MwWidget parent, int x, int y, unsigned int width, unsigned int height, ...) {
|
||||||
MwWidget h;
|
MwWidget h;
|
||||||
va_list va;
|
va_list va;
|
||||||
|
|
@ -704,13 +715,15 @@ void MwVaApply(MwWidget handle, ...) {
|
||||||
va_end(va);
|
va_end(va);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MwVaListApply(MwWidget handle, va_list va) {
|
static void MwVaListApply_Internal(MwWidget handle, va_list va, int only_early) {
|
||||||
char* key;
|
char* key;
|
||||||
int x = MwDEFAULT, y = MwDEFAULT, w = MwDEFAULT, h = MwDEFAULT;
|
int x = MwDEFAULT, y = MwDEFAULT, w = MwDEFAULT, h = MwDEFAULT;
|
||||||
|
|
||||||
while((key = va_arg(va, char*)) != NULL) {
|
while((key = va_arg(va, char*)) != NULL) {
|
||||||
if(key[0] == 'I') {
|
if(key[0] == 'I') {
|
||||||
int n = va_arg(va, int);
|
int n = va_arg(va, int);
|
||||||
|
if(only_early && key[1] != 'E') continue;
|
||||||
|
|
||||||
if(strcmp(key, MwNx) == 0) {
|
if(strcmp(key, MwNx) == 0) {
|
||||||
x = n;
|
x = n;
|
||||||
} else if(strcmp(key, MwNy) == 0) {
|
} else if(strcmp(key, MwNy) == 0) {
|
||||||
|
|
@ -724,12 +737,17 @@ void MwVaListApply(MwWidget handle, va_list va) {
|
||||||
}
|
}
|
||||||
} else if(key[0] == 'S') {
|
} else if(key[0] == 'S') {
|
||||||
char* t = va_arg(va, char*);
|
char* t = va_arg(va, char*);
|
||||||
|
if(only_early && key[1] != 'E') continue;
|
||||||
|
|
||||||
MwSetText(handle, key, t);
|
MwSetText(handle, key, t);
|
||||||
} else if(key[0] == 'C') {
|
} else if(key[0] == 'C') {
|
||||||
MwUserHandler h = va_arg(va, MwUserHandler);
|
MwUserHandler h = va_arg(va, MwUserHandler);
|
||||||
|
if(only_early && key[1] != 'E') continue;
|
||||||
|
|
||||||
MwAddUserHandler(handle, key, h, NULL);
|
MwAddUserHandler(handle, key, h, NULL);
|
||||||
} else if(key[0] == 'V') {
|
} else if(key[0] == 'V') {
|
||||||
void* v = va_arg(va, void*);
|
void* v = va_arg(va, void*);
|
||||||
|
if(only_early && key[1] != 'E') continue;
|
||||||
MwSetVoid(handle, key, v);
|
MwSetVoid(handle, key, v);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -761,6 +779,10 @@ void MwVaListApply(MwWidget handle, va_list va) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MwVaListApply(MwWidget handle, va_list va) {
|
||||||
|
MwVaListApply_Internal(handle, va, 0);
|
||||||
|
}
|
||||||
|
|
||||||
void MwSetDefault(MwWidget handle) {
|
void MwSetDefault(MwWidget handle) {
|
||||||
if(handle->lowlevel != NULL) MwLLSetCursor(handle->lowlevel, &MwCursorDefault, &MwCursorDefaultMask);
|
if(handle->lowlevel != NULL) MwLLSetCursor(handle->lowlevel, &MwCursorDefault, &MwCursorDefaultMask);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -493,14 +493,6 @@ void MwVulkanConfigure(MwVulkanConfig* cfg) {
|
||||||
vulkan_config = *cfg;
|
vulkan_config = *cfg;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MwVulkanEnableExtension(const char* name) {
|
|
||||||
arrput(enabledExtensions, name);
|
|
||||||
}
|
|
||||||
|
|
||||||
void MwVulkanEnableLayer(const char* name) {
|
|
||||||
arrput(enabledLayers, name);
|
|
||||||
}
|
|
||||||
|
|
||||||
int MwVulkanSupported(void) {
|
int MwVulkanSupported(void) {
|
||||||
if(vulkan_supported == VULKAN_SUPPORTED_UNKNOWN) {
|
if(vulkan_supported == VULKAN_SUPPORTED_UNKNOWN) {
|
||||||
void* lib = vulkan_lib_load();
|
void* lib = vulkan_lib_load();
|
||||||
|
|
@ -552,7 +544,20 @@ static void* mwVulkanGetFieldImpl(MwWidget handle, int field, int* err) {
|
||||||
if(err != NULL) {
|
if(err != NULL) {
|
||||||
*err = 0;
|
*err = 0;
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
|
static void prop_change(MwWidget handle, const char* prop) {
|
||||||
|
/* TODO: make this local to widgets, not global */
|
||||||
|
if(strcmp(prop, MwNvulkanExtension) == 0) {
|
||||||
|
char* str = MwStringDuplicate(MwGetText(handle, MwNvulkanExtension));
|
||||||
|
|
||||||
|
arrput(enabledExtensions, str);
|
||||||
|
} else if(strcmp(prop, MwNvulkanLayer) == 0) {
|
||||||
|
char* str = MwStringDuplicate(MwGetText(handle, MwNvulkanExtension));
|
||||||
|
|
||||||
|
arrput(enabledLayers, str);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void func_handler(MwWidget handle, const char* name, void* output, va_list va) {
|
static void func_handler(MwWidget handle, const char* name, void* output, va_list va) {
|
||||||
if(strcmp(name, "mwVulkanGetField") == 0) {
|
if(strcmp(name, "mwVulkanGetField") == 0) {
|
||||||
|
|
@ -568,7 +573,7 @@ MwClassRec MwVulkanClassRec = {
|
||||||
NULL, /* draw */
|
NULL, /* draw */
|
||||||
NULL, /* click */
|
NULL, /* click */
|
||||||
NULL, /* parent_resize */
|
NULL, /* parent_resize */
|
||||||
NULL, /* prop_change */
|
prop_change, /* prop_change */
|
||||||
NULL, /* mouse_move */
|
NULL, /* mouse_move */
|
||||||
NULL, /* mouse_up */
|
NULL, /* mouse_up */
|
||||||
NULL, /* mouse_down */
|
NULL, /* mouse_down */
|
||||||
|
|
@ -587,14 +592,6 @@ MwClass MwVulkanClass = &MwVulkanClassRec;
|
||||||
#else
|
#else
|
||||||
MwClass MwVulkanClass = NULL;
|
MwClass MwVulkanClass = NULL;
|
||||||
|
|
||||||
void MwVulkanEnableExtension(const char* ext_name) {
|
|
||||||
(void)ext_name;
|
|
||||||
}
|
|
||||||
|
|
||||||
void MwVulkanEnableLayer(const char* ext_name) {
|
|
||||||
(void)ext_name;
|
|
||||||
}
|
|
||||||
|
|
||||||
void MwVulkanConfigure(MwVulkanConfig* cfg) {
|
void MwVulkanConfigure(MwVulkanConfig* cfg) {
|
||||||
(void)cfg;
|
(void)cfg;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue