forked from KolibriOS/kolibrios
Fplay: missing files and functions
git-svn-id: svn://kolibrios.org@4446 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
ac3deada16
commit
65ae2ea810
@ -101,3 +101,4 @@ _res_progress_bar: file 'pbar.raw'
|
||||
_res_prg_level: file 'prg_level.raw'
|
||||
|
||||
_res_def_font: file 'IstokWeb.ttf'
|
||||
|
||||
|
60
contrib/media/fplay/winlib/link.h
Normal file
60
contrib/media/fplay/winlib/link.h
Normal 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;
|
||||
}
|
46
contrib/media/fplay/winlib/timer.h
Normal file
46
contrib/media/fplay/winlib/timer.h
Normal 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;
|
||||
}
|
@ -18,12 +18,13 @@ uint32_t cursor_nesw;
|
||||
|
||||
int win_font;
|
||||
|
||||
static window_t Window;
|
||||
|
||||
static pos_t old_pos;
|
||||
|
||||
ctrl_t *mouse_capture = NULL;
|
||||
|
||||
static link_t timers;
|
||||
static link_t timers;
|
||||
static uint32_t realtime;
|
||||
static uint32_t wait_time;
|
||||
static uint32_t exp_time;
|
||||
@ -35,16 +36,31 @@ static int need_update;
|
||||
|
||||
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"
|
||||
//#include "io.inc"
|
||||
#include "timer.inc"
|
||||
|
||||
//#include "button.inc"
|
||||
//#include "scroller.inc"
|
||||
|
||||
static window_t Window;
|
||||
if( win )
|
||||
{
|
||||
if(pt_in_rect(&win->client, x, y))
|
||||
{
|
||||
ctrl_t *tmp = (ctrl_t*)win->child.next;
|
||||
|
||||
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);
|
||||
|
Loading…
Reference in New Issue
Block a user