introduce early props
All checks were successful
pyrite-dev/milsko/pipeline/head This commit looks good
All checks were successful
pyrite-dev/milsko/pipeline/head This commit looks good
This commit is contained in:
parent
93325bb49c
commit
5d0c84d748
6 changed files with 62 additions and 45 deletions
46
src/core.c
46
src/core.c
|
|
@ -18,6 +18,9 @@
|
|||
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) {
|
||||
MwWidget h = (MwWidget)handle->common.user;
|
||||
#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));
|
||||
|
||||
h->name = MwStringDuplicate(name);
|
||||
|
|
@ -194,17 +197,17 @@ MwWidget MwCreateWidget(MwClass widget_class, const char* name, MwWidget parent,
|
|||
} else {
|
||||
h->lowlevel = NULL;
|
||||
}
|
||||
h->widget_class = widget_class;
|
||||
h->pressed = 0;
|
||||
h->close = 0;
|
||||
h->destroy_queue = NULL;
|
||||
h->prop_event = 1;
|
||||
h->draw_inject = NULL;
|
||||
h->widget_class = widget_class;
|
||||
h->pressed = 0;
|
||||
h->close = 0;
|
||||
h->destroy_queue = NULL;
|
||||
h->prop_event = 1;
|
||||
h->draw_inject = NULL;
|
||||
h->destroy_inject = NULL;
|
||||
h->tick_list = NULL;
|
||||
h->destroyed = 0;
|
||||
h->bgcolor = NULL;
|
||||
h->berserk = 0;
|
||||
h->tick_list = NULL;
|
||||
h->destroyed = 0;
|
||||
h->bgcolor = NULL;
|
||||
h->berserk = 0;
|
||||
|
||||
h->top_step = 0;
|
||||
h->draw_queue = NULL;
|
||||
|
|
@ -243,6 +246,8 @@ MwWidget MwCreateWidget(MwClass widget_class, const char* name, MwWidget parent,
|
|||
shdefault(h->handler, NULL);
|
||||
shdefault(h->data, NULL);
|
||||
|
||||
if(do_prop) MwVaListApply_Internal(h, prop, 1);
|
||||
|
||||
h->prop_event = 0;
|
||||
if(MwDispatch2(h, create) != 0) {
|
||||
h->widget_class = NULL;
|
||||
|
|
@ -276,6 +281,12 @@ MwWidget MwCreateWidget(MwClass widget_class, const char* name, MwWidget parent,
|
|||
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 h;
|
||||
va_list va;
|
||||
|
|
@ -704,13 +715,15 @@ void MwVaApply(MwWidget handle, ...) {
|
|||
va_end(va);
|
||||
}
|
||||
|
||||
void MwVaListApply(MwWidget handle, va_list va) {
|
||||
static void MwVaListApply_Internal(MwWidget handle, va_list va, int only_early) {
|
||||
char* key;
|
||||
int x = MwDEFAULT, y = MwDEFAULT, w = MwDEFAULT, h = MwDEFAULT;
|
||||
|
||||
while((key = va_arg(va, char*)) != NULL) {
|
||||
if(key[0] == 'I') {
|
||||
int n = va_arg(va, int);
|
||||
if(only_early && key[1] != 'E') continue;
|
||||
|
||||
if(strcmp(key, MwNx) == 0) {
|
||||
x = n;
|
||||
} else if(strcmp(key, MwNy) == 0) {
|
||||
|
|
@ -724,12 +737,17 @@ void MwVaListApply(MwWidget handle, va_list va) {
|
|||
}
|
||||
} else if(key[0] == 'S') {
|
||||
char* t = va_arg(va, char*);
|
||||
if(only_early && key[1] != 'E') continue;
|
||||
|
||||
MwSetText(handle, key, t);
|
||||
} else if(key[0] == 'C') {
|
||||
MwUserHandler h = va_arg(va, MwUserHandler);
|
||||
if(only_early && key[1] != 'E') continue;
|
||||
|
||||
MwAddUserHandler(handle, key, h, NULL);
|
||||
} else if(key[0] == 'V') {
|
||||
void* v = va_arg(va, void*);
|
||||
if(only_early && key[1] != 'E') continue;
|
||||
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) {
|
||||
if(handle->lowlevel != NULL) MwLLSetCursor(handle->lowlevel, &MwCursorDefault, &MwCursorDefaultMask);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -493,14 +493,6 @@ void MwVulkanConfigure(MwVulkanConfig* cfg) {
|
|||
vulkan_config = *cfg;
|
||||
}
|
||||
|
||||
void MwVulkanEnableExtension(const char* name) {
|
||||
arrput(enabledExtensions, name);
|
||||
}
|
||||
|
||||
void MwVulkanEnableLayer(const char* name) {
|
||||
arrput(enabledLayers, name);
|
||||
}
|
||||
|
||||
int MwVulkanSupported(void) {
|
||||
if(vulkan_supported == VULKAN_SUPPORTED_UNKNOWN) {
|
||||
void* lib = vulkan_lib_load();
|
||||
|
|
@ -552,7 +544,20 @@ static void* mwVulkanGetFieldImpl(MwWidget handle, int field, int* err) {
|
|||
if(err != NULL) {
|
||||
*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) {
|
||||
if(strcmp(name, "mwVulkanGetField") == 0) {
|
||||
|
|
@ -568,7 +573,7 @@ MwClassRec MwVulkanClassRec = {
|
|||
NULL, /* draw */
|
||||
NULL, /* click */
|
||||
NULL, /* parent_resize */
|
||||
NULL, /* prop_change */
|
||||
prop_change, /* prop_change */
|
||||
NULL, /* mouse_move */
|
||||
NULL, /* mouse_up */
|
||||
NULL, /* mouse_down */
|
||||
|
|
@ -587,14 +592,6 @@ MwClass MwVulkanClass = &MwVulkanClassRec;
|
|||
#else
|
||||
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)cfg;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue