mirror of
https://gitea.nishi.boats/pyrite-dev/milsko
synced 2026-01-06 17:39:45 +00:00
add tick_list
git-svn-id: http://svn2.nishi.boats/svn/milsko/trunk@391 b9cfdab3-6d41-4d17-bbe4-086880011989
This commit is contained in:
@@ -231,6 +231,12 @@ MWDECL void MwForceRender(MwWidget handle);
|
|||||||
*/
|
*/
|
||||||
MWDECL void MwForceRender2(MwWidget handle, void* ptr);
|
MWDECL void MwForceRender2(MwWidget handle, void* ptr);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* %brief Adds an widget to tick handler list
|
||||||
|
* %param handle Widget
|
||||||
|
*/
|
||||||
|
MWDECL void MwAddTickList(MwWidget handle);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -105,6 +105,7 @@ struct _MwWidget {
|
|||||||
MwVoidKeyValue* data;
|
MwVoidKeyValue* data;
|
||||||
|
|
||||||
MwWidget* destroy_queue;
|
MwWidget* destroy_queue;
|
||||||
|
MwWidget* tick_list;
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
26
src/core.c
26
src/core.c
@@ -112,6 +112,9 @@ MwWidget MwCreateWidget(MwClass widget_class, const char* name, MwWidget parent,
|
|||||||
h->destroy_queue = NULL;
|
h->destroy_queue = NULL;
|
||||||
h->prop_event = 1;
|
h->prop_event = 1;
|
||||||
h->draw_inject = NULL;
|
h->draw_inject = NULL;
|
||||||
|
h->tick_list = NULL;
|
||||||
|
|
||||||
|
if(parent == NULL) arrput(h->tick_list, h);
|
||||||
|
|
||||||
if(h->lowlevel != NULL) {
|
if(h->lowlevel != NULL) {
|
||||||
h->lowlevel->user = h;
|
h->lowlevel->user = h;
|
||||||
@@ -190,14 +193,25 @@ static void MwFreeWidget(MwWidget handle) {
|
|||||||
shfree(handle->data);
|
shfree(handle->data);
|
||||||
|
|
||||||
arrfree(handle->destroy_queue);
|
arrfree(handle->destroy_queue);
|
||||||
|
arrfree(handle->tick_list);
|
||||||
|
|
||||||
free(handle);
|
free(handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MwDestroyWidget(MwWidget handle) {
|
void MwDestroyWidget(MwWidget handle) {
|
||||||
|
int i;
|
||||||
|
MwWidget root = handle;
|
||||||
if(handle->parent != NULL) {
|
if(handle->parent != NULL) {
|
||||||
arrput(handle->parent->destroy_queue, handle);
|
arrput(handle->parent->destroy_queue, handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
while(root->parent != NULL) root = root->parent;
|
||||||
|
for(i = 0; i < arrlen(root->tick_list); i++) {
|
||||||
|
if(handle == root->tick_list[i]) {
|
||||||
|
arrdel(root->tick_list, i);
|
||||||
|
i--;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MwStep(MwWidget handle) {
|
void MwStep(MwWidget handle) {
|
||||||
@@ -235,10 +249,13 @@ int MwPending(MwWidget handle) {
|
|||||||
|
|
||||||
void MwLoop(MwWidget handle) {
|
void MwLoop(MwWidget handle) {
|
||||||
long tick = MwLLGetTick();
|
long tick = MwLLGetTick();
|
||||||
|
int i;
|
||||||
while(!handle->close) {
|
while(!handle->close) {
|
||||||
while(MwPending(handle)) MwStep(handle);
|
while(MwPending(handle)) MwStep(handle);
|
||||||
|
|
||||||
MwDispatchUserHandler(handle, MwNtickHandler, NULL);
|
for(i = 0; i < arrlen(handle->tick_list); i++) {
|
||||||
|
MwDispatchUserHandler(handle->tick_list[i], MwNtickHandler, NULL);
|
||||||
|
}
|
||||||
tick = MwWaitMS - (MwLLGetTick() - tick);
|
tick = MwWaitMS - (MwLLGetTick() - tick);
|
||||||
if(tick > 0) MwLLSleep(tick);
|
if(tick > 0) MwLLSleep(tick);
|
||||||
tick = MwLLGetTick();
|
tick = MwLLGetTick();
|
||||||
@@ -426,3 +443,10 @@ void MwForceRender2(MwWidget handle, void* ptr) {
|
|||||||
|
|
||||||
MwForceRender(handle);
|
MwForceRender(handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MwAddTickList(MwWidget handle) {
|
||||||
|
MwWidget root = handle;
|
||||||
|
while(root->parent != NULL) root = root->parent;
|
||||||
|
|
||||||
|
arrput(root->tick_list, handle);
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user