mirror of
https://gitea.nishi.boats/pyrite-dev/milsko
synced 2026-01-10 03:13:28 +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:
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->prop_event = 1;
|
||||
h->draw_inject = NULL;
|
||||
h->tick_list = NULL;
|
||||
|
||||
if(parent == NULL) arrput(h->tick_list, h);
|
||||
|
||||
if(h->lowlevel != NULL) {
|
||||
h->lowlevel->user = h;
|
||||
@@ -190,14 +193,25 @@ static void MwFreeWidget(MwWidget handle) {
|
||||
shfree(handle->data);
|
||||
|
||||
arrfree(handle->destroy_queue);
|
||||
arrfree(handle->tick_list);
|
||||
|
||||
free(handle);
|
||||
}
|
||||
|
||||
void MwDestroyWidget(MwWidget handle) {
|
||||
int i;
|
||||
MwWidget root = handle;
|
||||
if(handle->parent != NULL) {
|
||||
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) {
|
||||
@@ -235,10 +249,13 @@ int MwPending(MwWidget handle) {
|
||||
|
||||
void MwLoop(MwWidget handle) {
|
||||
long tick = MwLLGetTick();
|
||||
int i;
|
||||
while(!handle->close) {
|
||||
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);
|
||||
if(tick > 0) MwLLSleep(tick);
|
||||
tick = MwLLGetTick();
|
||||
@@ -426,3 +443,10 @@ void MwForceRender2(MwWidget handle, void* ptr) {
|
||||
|
||||
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