Fplay: missing files and functions

git-svn-id: svn://kolibrios.org@4446 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Sergey Semyonov (Serge) 2014-01-13 14:57:59 +00:00
parent ac3deada16
commit 65ae2ea810
4 changed files with 132 additions and 9 deletions

View File

@ -101,3 +101,4 @@ _res_progress_bar: file 'pbar.raw'
_res_prg_level: file 'prg_level.raw' _res_prg_level: file 'prg_level.raw'
_res_def_font: file 'IstokWeb.ttf' _res_def_font: file 'IstokWeb.ttf'

View File

@ -0,0 +1,60 @@
typedef struct link
{
struct link *prev;
struct link *next;
}link_t;
#define LIST_INITIALIZE(name) \
link_t name = { .prev = &name, .next = &name }
#define list_get_instance(link, type, member) \
((type *)(((u8_t *)(link)) - ((u8_t *)&(((type *)NULL)->member))))
static inline void link_initialize(link_t *link)
{
link->prev = NULL;
link->next = NULL;
}
static inline void list_initialize(link_t *head)
{
head->prev = head;
head->next = head;
}
static inline void list_append(link_t *link, link_t *head)
{
link->prev = head->prev;
link->next = head;
head->prev->next = link;
head->prev = link;
}
static inline void list_remove(link_t *link)
{
link->next->prev = link->prev;
link->prev->next = link->next;
link_initialize(link);
}
static inline int list_empty(link_t *head)
{
return head->next == head ? 1 : 0;
}
static inline void list_prepend(link_t *link, link_t *head)
{
link->next = head->next;
link->prev = head;
head->next->prev = link;
head->next = link;
}
static inline void list_insert(link_t *new, link_t *old)
{
new->prev = old->prev;
new->next = old;
new->prev->next = new;
old->prev = new;
}

View File

@ -0,0 +1,46 @@
static uint32_t update_timers(uint32_t realtime)
{
ostimer_t *timer;
uint32_t exp_time = -1;
timer = (ostimer_t*)timers.next;
while( &timer->link != &timers)
{
ostimer_t *tmp;
tmp = timer;
timer = (ostimer_t*)timer->link.next;
if( tmp->exp_time < realtime)
{
list_remove(&tmp->link);
send_message(tmp->ctrl, MSG_TIMER, tmp->tmr_arg, tmp);
}
};
timer = (ostimer_t*)timers.next;
while( &timer->link != &timers)
{
if( exp_time > timer->exp_time)
exp_time = timer->exp_time;
timer = (ostimer_t*)timer->link.next;
}
return exp_time;
};
int set_timer(ctrl_t *ctrl, ostimer_t *timer, uint32_t delay)
{
if( ctrl && timer &&delay)
{
timer->ctrl = ctrl;
timer->exp_time = realtime + delay;
if( exp_time > timer->exp_time)
exp_time = timer->exp_time;
list_append(&timer->link, &timers);
};
return 0;
}

View File

@ -18,6 +18,7 @@ uint32_t cursor_nesw;
int win_font; int win_font;
static window_t Window;
static pos_t old_pos; static pos_t old_pos;
@ -35,16 +36,31 @@ static int need_update;
void adjust_frame(window_t *win); void adjust_frame(window_t *win);
//#include "timer.h"
ctrl_t *win_get_child(window_t *win, int x, int y)
{
ctrl_t *child = NULL;
#include "control.inc" if( win )
//#include "io.inc" {
#include "timer.inc" if(pt_in_rect(&win->client, x, y))
{
//#include "button.inc" ctrl_t *tmp = (ctrl_t*)win->child.next;
//#include "scroller.inc"
static window_t Window;
while( &tmp->link != &win->child )
{
if(pt_in_rect(&tmp->rc, x, y))
{
child = get_child(tmp, x, y);
return child == NULL ? tmp : child;
};
tmp = (ctrl_t*)tmp->link.next;
};
}
else child = (ctrl_t*)(&win->frame);
};
return child;
};
void init_frame(window_t *win); void init_frame(window_t *win);