merge guilte-xxx.cpp into guilite.cpp
This commit is contained in:
parent
e8057f2e3e
commit
ff66d3fa4d
3727
GuiLite-linux.cpp
3727
GuiLite-linux.cpp
File diff suppressed because it is too large
Load Diff
3460
GuiLite-unknow.cpp
3460
GuiLite-unknow.cpp
File diff suppressed because it is too large
Load Diff
|
@ -834,73 +834,73 @@ void c_surface_no_fb::draw_pixel_on_fb(int x, int y, unsigned int rgb)
|
|||
((unsigned short*)m_fb)[y * m_width + x] = GL_RGB_32_to_16(rgb);
|
||||
}
|
||||
}
|
||||
|
||||
static const FONT_INFO* s_font_map[FONT_MAX];
|
||||
static const BITMAP_INFO* s_bmp_map[BITMAP_MAX];
|
||||
static unsigned int s_color_map[COLOR_MAX];
|
||||
|
||||
int c_theme::add_font(FONT_TYPE index, const FONT_INFO* font)
|
||||
{
|
||||
if (index >= FONT_MAX)
|
||||
{
|
||||
ASSERT(false);
|
||||
return -1;
|
||||
}
|
||||
s_font_map[index] = font;
|
||||
return 0;
|
||||
}
|
||||
|
||||
const FONT_INFO* c_theme::get_font(FONT_TYPE index)
|
||||
{
|
||||
if (index >= FONT_MAX)
|
||||
{
|
||||
ASSERT(false);
|
||||
return 0;
|
||||
}
|
||||
return s_font_map[index];
|
||||
}
|
||||
|
||||
int c_theme::add_bitmap(BITMAP_TYPE index, const BITMAP_INFO* bmp)
|
||||
{
|
||||
if (index >= BITMAP_MAX)
|
||||
{
|
||||
ASSERT(false);
|
||||
return -1;
|
||||
}
|
||||
s_bmp_map[index] = bmp;
|
||||
return 0;
|
||||
}
|
||||
|
||||
const BITMAP_INFO* c_theme::get_bmp(BITMAP_TYPE index)
|
||||
{
|
||||
if (index >= BITMAP_MAX)
|
||||
{
|
||||
ASSERT(false);
|
||||
return 0;
|
||||
}
|
||||
return s_bmp_map[index];
|
||||
}
|
||||
|
||||
int c_theme::add_color(COLOR_TYPE index, const unsigned int color)
|
||||
{
|
||||
if (index >= COLOR_MAX)
|
||||
{
|
||||
ASSERT(false);
|
||||
return -1;
|
||||
}
|
||||
s_color_map[index] = color;
|
||||
return 0;
|
||||
}
|
||||
|
||||
const unsigned int c_theme::get_color(COLOR_TYPE index)
|
||||
{
|
||||
if (index >= COLOR_MAX)
|
||||
{
|
||||
ASSERT(false);
|
||||
return 0;
|
||||
}
|
||||
return s_color_map[index];
|
||||
}
|
||||
|
||||
static const FONT_INFO* s_font_map[FONT_MAX];
|
||||
static const BITMAP_INFO* s_bmp_map[BITMAP_MAX];
|
||||
static unsigned int s_color_map[COLOR_MAX];
|
||||
|
||||
int c_theme::add_font(FONT_TYPE index, const FONT_INFO* font)
|
||||
{
|
||||
if (index >= FONT_MAX)
|
||||
{
|
||||
ASSERT(false);
|
||||
return -1;
|
||||
}
|
||||
s_font_map[index] = font;
|
||||
return 0;
|
||||
}
|
||||
|
||||
const FONT_INFO* c_theme::get_font(FONT_TYPE index)
|
||||
{
|
||||
if (index >= FONT_MAX)
|
||||
{
|
||||
ASSERT(false);
|
||||
return 0;
|
||||
}
|
||||
return s_font_map[index];
|
||||
}
|
||||
|
||||
int c_theme::add_bitmap(BITMAP_TYPE index, const BITMAP_INFO* bmp)
|
||||
{
|
||||
if (index >= BITMAP_MAX)
|
||||
{
|
||||
ASSERT(false);
|
||||
return -1;
|
||||
}
|
||||
s_bmp_map[index] = bmp;
|
||||
return 0;
|
||||
}
|
||||
|
||||
const BITMAP_INFO* c_theme::get_bmp(BITMAP_TYPE index)
|
||||
{
|
||||
if (index >= BITMAP_MAX)
|
||||
{
|
||||
ASSERT(false);
|
||||
return 0;
|
||||
}
|
||||
return s_bmp_map[index];
|
||||
}
|
||||
|
||||
int c_theme::add_color(COLOR_TYPE index, const unsigned int color)
|
||||
{
|
||||
if (index >= COLOR_MAX)
|
||||
{
|
||||
ASSERT(false);
|
||||
return -1;
|
||||
}
|
||||
s_color_map[index] = color;
|
||||
return 0;
|
||||
}
|
||||
|
||||
const unsigned int c_theme::get_color(COLOR_TYPE index)
|
||||
{
|
||||
if (index >= COLOR_MAX)
|
||||
{
|
||||
ASSERT(false);
|
||||
return 0;
|
||||
}
|
||||
return s_color_map[index];
|
||||
}
|
||||
c_wnd::c_wnd(): m_status(STATUS_NORMAL), m_attr(ATTR_VISIBLE), m_parent(0), m_top_child(0), m_prev_sibling(0), m_next_sibling(0),
|
||||
m_str(0), m_font_color(0), m_bg_color(0), m_resource_id(0), m_z_order(Z_ORDER_LEVEL_0), m_focus_child(0), m_surface(0)
|
||||
{
|
||||
|
@ -1662,6 +1662,486 @@ void c_word::get_string_pos(const char *s, const FONT_INFO* font, c_rect rect, u
|
|||
break;
|
||||
}
|
||||
}
|
||||
#if (defined __linux__) || (defined __APPLE__)
|
||||
#include <unistd.h>
|
||||
#include <pthread.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
#include <sys/time.h>
|
||||
#include <signal.h>
|
||||
#include <sys/times.h>
|
||||
#include <fcntl.h>
|
||||
#include <termios.h>
|
||||
#include <sys/stat.h>
|
||||
#include <semaphore.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#define MAX_TIMER_CNT 10
|
||||
#define TIMER_UNIT 50//ms
|
||||
static void(*do_assert)(const char* file, int line);
|
||||
static void(*do_log_out)(const char* log);
|
||||
void register_debug_function(void(*my_assert)(const char* file, int line), void(*my_log_out)(const char* log))
|
||||
{
|
||||
do_assert = my_assert;
|
||||
do_log_out = my_log_out;
|
||||
}
|
||||
void _assert(const char* file, int line)
|
||||
{
|
||||
if(do_assert)
|
||||
{
|
||||
do_assert(file, line);
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("assert@ file:%s, line:%d, error no: %d\n", file, line, errno);
|
||||
}
|
||||
}
|
||||
void log_out(const char* log)
|
||||
{
|
||||
if (do_log_out)
|
||||
{
|
||||
do_log_out(log);
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("%s", log);
|
||||
fflush(stdout);
|
||||
}
|
||||
}
|
||||
typedef struct _timer_manage
|
||||
{
|
||||
struct _timer_info
|
||||
{
|
||||
int state; /* on or off */
|
||||
int interval;
|
||||
int elapse; /* 0~interval */
|
||||
void (* timer_proc) (void* ptmr, void* parg);
|
||||
}timer_info[MAX_TIMER_CNT];
|
||||
void (* old_sigfunc)(int);
|
||||
void (* new_sigfunc)(int);
|
||||
}_timer_manage_t;
|
||||
static struct _timer_manage timer_manage;
|
||||
static void* timer_routine(void*)
|
||||
{
|
||||
int i;
|
||||
while(true)
|
||||
{
|
||||
for(i = 0; i < MAX_TIMER_CNT; i++)
|
||||
{
|
||||
if(timer_manage.timer_info[i].state == 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
timer_manage.timer_info[i].elapse++;
|
||||
if(timer_manage.timer_info[i].elapse == timer_manage.timer_info[i].interval)
|
||||
{
|
||||
timer_manage.timer_info[i].elapse = 0;
|
||||
timer_manage.timer_info[i].timer_proc(0, 0);
|
||||
}
|
||||
}
|
||||
usleep(1000 * TIMER_UNIT);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
static int init_mul_timer()
|
||||
{
|
||||
static bool s_is_init = false;
|
||||
if(s_is_init == true)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
memset(&timer_manage, 0, sizeof(struct _timer_manage));
|
||||
pthread_t pid;
|
||||
pthread_create(&pid, NULL, timer_routine, NULL);
|
||||
s_is_init = true;
|
||||
return 1;
|
||||
}
|
||||
static int set_a_timer(int interval, void (* timer_proc) (void* ptmr, void* parg))
|
||||
{
|
||||
init_mul_timer();
|
||||
int i;
|
||||
if(timer_proc == NULL || interval <= 0)
|
||||
{
|
||||
return (-1);
|
||||
}
|
||||
for(i = 0; i < MAX_TIMER_CNT; i++)
|
||||
{
|
||||
if(timer_manage.timer_info[i].state == 1)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
memset(&timer_manage.timer_info[i], 0, sizeof(timer_manage.timer_info[i]));
|
||||
timer_manage.timer_info[i].timer_proc = timer_proc;
|
||||
timer_manage.timer_info[i].interval = interval;
|
||||
timer_manage.timer_info[i].elapse = 0;
|
||||
timer_manage.timer_info[i].state = 1;
|
||||
break;
|
||||
}
|
||||
if(i >= MAX_TIMER_CNT)
|
||||
{
|
||||
ASSERT(false);
|
||||
return (-1);
|
||||
}
|
||||
return (i);
|
||||
}
|
||||
typedef void (*EXPIRE_ROUTINE)(void* arg);
|
||||
EXPIRE_ROUTINE s_expire_function;
|
||||
static c_fifo s_real_timer_fifo;
|
||||
static void* real_timer_routine(void*)
|
||||
{
|
||||
char dummy;
|
||||
while(1)
|
||||
{
|
||||
if(s_real_timer_fifo.read(&dummy, 1) > 0)
|
||||
{
|
||||
if(s_expire_function)s_expire_function(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
ASSERT(false);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
static void expire_real_timer(int sigo)
|
||||
{
|
||||
char dummy = 0x33;
|
||||
if(s_real_timer_fifo.write(&dummy, 1) <= 0)
|
||||
{
|
||||
ASSERT(false);
|
||||
}
|
||||
}
|
||||
void start_real_timer(void (*func)(void* arg))
|
||||
{
|
||||
if(NULL == func)
|
||||
{
|
||||
return;
|
||||
}
|
||||
s_expire_function = func;
|
||||
signal(SIGALRM, expire_real_timer);
|
||||
struct itimerval value, ovalue;
|
||||
value.it_value.tv_sec = 0;
|
||||
value.it_value.tv_usec = REAL_TIME_TASK_CYCLE_MS * 1000;
|
||||
value.it_interval.tv_sec = 0;
|
||||
value.it_interval.tv_usec = REAL_TIME_TASK_CYCLE_MS * 1000;
|
||||
setitimer(ITIMER_REAL, &value, &ovalue);
|
||||
static pthread_t s_pid;
|
||||
if(s_pid == 0)
|
||||
{
|
||||
pthread_create(&s_pid, NULL, real_timer_routine, NULL);
|
||||
}
|
||||
}
|
||||
unsigned int get_cur_thread_id()
|
||||
{
|
||||
return (unsigned long)pthread_self();
|
||||
}
|
||||
void register_timer(int milli_second,void func(void* ptmr, void* parg))
|
||||
{
|
||||
set_a_timer(milli_second/TIMER_UNIT,func);
|
||||
}
|
||||
long get_time_in_second()
|
||||
{
|
||||
return time(NULL); /* + 8*60*60*/
|
||||
}
|
||||
T_TIME get_time()
|
||||
{
|
||||
T_TIME ret = {0};
|
||||
struct tm *fmt;
|
||||
time_t timer;
|
||||
timer = get_time_in_second();
|
||||
fmt = localtime(&timer);
|
||||
ret.year = fmt->tm_year + 1900;
|
||||
ret.month = fmt->tm_mon + 1;
|
||||
ret.day = fmt->tm_mday;
|
||||
ret.hour = fmt->tm_hour;
|
||||
ret.minute = fmt->tm_min;
|
||||
ret.second = fmt->tm_sec;
|
||||
return ret;
|
||||
}
|
||||
T_TIME second_to_day(long second)
|
||||
{
|
||||
T_TIME ret = {0};
|
||||
struct tm *fmt;
|
||||
fmt = localtime(&second);
|
||||
ret.year = fmt->tm_year + 1900;
|
||||
ret.month = fmt->tm_mon + 1;
|
||||
ret.day = fmt->tm_mday;
|
||||
ret.hour = fmt->tm_hour;
|
||||
ret.minute = fmt->tm_min;
|
||||
ret.second = fmt->tm_sec;
|
||||
return ret;
|
||||
}
|
||||
void create_thread(unsigned long* thread_id, void* attr, void *(*start_routine) (void *), void* arg)
|
||||
{
|
||||
pthread_create((pthread_t*)thread_id, (pthread_attr_t const*)attr, start_routine, arg);
|
||||
}
|
||||
void thread_sleep(unsigned int milli_seconds)
|
||||
{
|
||||
usleep(milli_seconds * 1000);
|
||||
}
|
||||
typedef struct {
|
||||
unsigned short bfType;
|
||||
unsigned int bfSize;
|
||||
unsigned short bfReserved1;
|
||||
unsigned short bfReserved2;
|
||||
unsigned int bfOffBits;
|
||||
}__attribute__((packed))FileHead;
|
||||
typedef struct{
|
||||
unsigned int biSize;
|
||||
int biWidth;
|
||||
int biHeight;
|
||||
unsigned short biPlanes;
|
||||
unsigned short biBitCount;
|
||||
unsigned int biCompress;
|
||||
unsigned int biSizeImage;
|
||||
int biXPelsPerMeter;
|
||||
int biYPelsPerMeter;
|
||||
unsigned int biClrUsed;
|
||||
unsigned int biClrImportant;
|
||||
unsigned int biRedMask;
|
||||
unsigned int biGreenMask;
|
||||
unsigned int biBlueMask;
|
||||
}__attribute__((packed))Infohead;
|
||||
int build_bmp(const char *filename, unsigned int width, unsigned int height, unsigned char *data)
|
||||
{
|
||||
FileHead bmp_head;
|
||||
Infohead bmp_info;
|
||||
int size = width * height * 2;
|
||||
//initialize bmp head.
|
||||
bmp_head.bfType = 0x4d42;
|
||||
bmp_head.bfSize = size + sizeof(FileHead) + sizeof(Infohead);
|
||||
bmp_head.bfReserved1 = bmp_head.bfReserved2 = 0;
|
||||
bmp_head.bfOffBits = bmp_head.bfSize - size;
|
||||
//initialize bmp info.
|
||||
bmp_info.biSize = 40;
|
||||
bmp_info.biWidth = width;
|
||||
bmp_info.biHeight = height;
|
||||
bmp_info.biPlanes = 1;
|
||||
bmp_info.biBitCount = 16;
|
||||
bmp_info.biCompress = 3;
|
||||
bmp_info.biSizeImage = size;
|
||||
bmp_info.biXPelsPerMeter = 0;
|
||||
bmp_info.biYPelsPerMeter = 0;
|
||||
bmp_info.biClrUsed = 0;
|
||||
bmp_info.biClrImportant = 0;
|
||||
//RGB565
|
||||
bmp_info.biRedMask = 0xF800;
|
||||
bmp_info.biGreenMask = 0x07E0;
|
||||
bmp_info.biBlueMask = 0x001F;
|
||||
//copy the data
|
||||
FILE *fp;
|
||||
if(!(fp=fopen(filename,"wb")))
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
fwrite(&bmp_head, 1, sizeof(FileHead),fp);
|
||||
fwrite(&bmp_info, 1, sizeof(Infohead),fp);
|
||||
//fwrite(data, 1, size, fp);//top <-> bottom
|
||||
for (int i = (height - 1); i >= 0; --i)
|
||||
{
|
||||
fwrite(&data[i * width * 2], 1, width * 2, fp);
|
||||
}
|
||||
|
||||
fclose(fp);
|
||||
return 0;
|
||||
}
|
||||
c_fifo::c_fifo()
|
||||
{
|
||||
m_head = m_tail = 0;
|
||||
m_read_sem = malloc(sizeof(sem_t));
|
||||
m_write_mutex = malloc(sizeof(pthread_mutex_t));
|
||||
|
||||
sem_init((sem_t*)m_read_sem, 0, 0);
|
||||
pthread_mutex_init((pthread_mutex_t*)m_write_mutex, 0);
|
||||
}
|
||||
int c_fifo::read(void* buf, int len)
|
||||
{
|
||||
unsigned char* pbuf = (unsigned char*)buf;
|
||||
int i = 0;
|
||||
while(i < len)
|
||||
{
|
||||
if (m_tail == m_head)
|
||||
{//empty
|
||||
sem_wait((sem_t*)m_read_sem);
|
||||
continue;
|
||||
}
|
||||
*pbuf++ = m_buf[m_head];
|
||||
m_head = (m_head + 1) % FIFO_BUFFER_LEN;
|
||||
i++;
|
||||
}
|
||||
if(i != len)
|
||||
{
|
||||
ASSERT(false);
|
||||
}
|
||||
return i;
|
||||
}
|
||||
int c_fifo::write(void* buf, int len)
|
||||
{
|
||||
unsigned char* pbuf = (unsigned char*)buf;
|
||||
int i = 0;
|
||||
int tail = m_tail;
|
||||
pthread_mutex_lock((pthread_mutex_t*)m_write_mutex);
|
||||
while(i < len)
|
||||
{
|
||||
if ((m_tail + 1) % FIFO_BUFFER_LEN == m_head)
|
||||
{//full, clear data has been written;
|
||||
m_tail = tail;
|
||||
log_out("Warning: fifo full\n");
|
||||
pthread_mutex_unlock((pthread_mutex_t*)m_write_mutex);
|
||||
return 0;
|
||||
}
|
||||
m_buf[m_tail] = *pbuf++;
|
||||
m_tail = (m_tail + 1) % FIFO_BUFFER_LEN;
|
||||
i++;
|
||||
}
|
||||
pthread_mutex_unlock((pthread_mutex_t*)m_write_mutex);
|
||||
if(i != len)
|
||||
{
|
||||
ASSERT(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
sem_post((sem_t*)m_read_sem);
|
||||
}
|
||||
return i;
|
||||
}
|
||||
#endif
|
||||
#if (!defined _WIN32) && (!defined WIN32) && (!defined _WIN64) && (!defined WIN64) && (!defined __linux__) && (!defined __APPLE__)
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
static void(*do_assert)(const char* file, int line);
|
||||
static void(*do_log_out)(const char* log);
|
||||
void register_debug_function(void(*my_assert)(const char* file, int line), void(*my_log_out)(const char* log))
|
||||
{
|
||||
do_assert = my_assert;
|
||||
do_log_out = my_log_out;
|
||||
}
|
||||
|
||||
void _assert(const char* file, int line)
|
||||
{
|
||||
if(do_assert)
|
||||
{
|
||||
do_assert(file, line);
|
||||
}
|
||||
while(1);
|
||||
}
|
||||
|
||||
void log_out(const char* log)
|
||||
{
|
||||
if (do_log_out)
|
||||
{
|
||||
do_log_out(log);
|
||||
}
|
||||
}
|
||||
|
||||
long get_time_in_second()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
T_TIME second_to_day(long second)
|
||||
{
|
||||
T_TIME ret = {0};
|
||||
return ret;
|
||||
}
|
||||
|
||||
T_TIME get_time()
|
||||
{
|
||||
T_TIME ret = {0};
|
||||
return ret;
|
||||
}
|
||||
|
||||
void start_real_timer(void (*func)(void* arg))
|
||||
{
|
||||
log_out("Not support now");
|
||||
}
|
||||
|
||||
void register_timer(int milli_second, void func(void* ptmr, void* parg))
|
||||
{
|
||||
log_out("Not support now");
|
||||
}
|
||||
|
||||
unsigned int get_cur_thread_id()
|
||||
{
|
||||
log_out("Not support now");
|
||||
return 0;
|
||||
}
|
||||
|
||||
void create_thread(unsigned long* thread_id, void* attr, void *(*start_routine) (void *), void* arg)
|
||||
{
|
||||
log_out("Not support now");
|
||||
}
|
||||
|
||||
extern "C" void delay_ms(unsigned short nms);
|
||||
void thread_sleep(unsigned int milli_seconds)
|
||||
{//MCU alway implemnet driver code in APP.
|
||||
delay_ms(milli_seconds);
|
||||
}
|
||||
|
||||
int build_bmp(const char *filename, unsigned int width, unsigned int height, unsigned char *data)
|
||||
{
|
||||
log_out("Not support now");
|
||||
return 0;
|
||||
}
|
||||
|
||||
c_fifo::c_fifo()
|
||||
{
|
||||
m_head = m_tail = 0;
|
||||
m_read_sem = m_write_mutex = 0;
|
||||
}
|
||||
|
||||
int c_fifo::read(void* buf, int len)
|
||||
{
|
||||
unsigned char* pbuf = (unsigned char*)buf;
|
||||
int i = 0;
|
||||
while(i < len)
|
||||
{
|
||||
if (m_tail == m_head)
|
||||
{//empty
|
||||
continue;
|
||||
}
|
||||
*pbuf++ = m_buf[m_head];
|
||||
m_head = (m_head + 1) % FIFO_BUFFER_LEN;
|
||||
i++;
|
||||
}
|
||||
if(i != len)
|
||||
{
|
||||
ASSERT(false);
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
||||
int c_fifo::write(void* buf, int len)
|
||||
{
|
||||
unsigned char* pbuf = (unsigned char*)buf;
|
||||
int i = 0;
|
||||
int tail = m_tail;
|
||||
|
||||
while(i < len)
|
||||
{
|
||||
if ((m_tail + 1) % FIFO_BUFFER_LEN == m_head)
|
||||
{//full, clear data has been written;
|
||||
m_tail = tail;
|
||||
log_out("Warning: fifo full\n");
|
||||
return 0;
|
||||
}
|
||||
m_buf[m_tail] = *pbuf++;
|
||||
m_tail = (m_tail + 1) % FIFO_BUFFER_LEN;
|
||||
i++;
|
||||
}
|
||||
|
||||
if(i != len)
|
||||
{
|
||||
ASSERT(false);
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
||||
#endif
|
||||
#if (defined _WIN32) || (defined WIN32) || (defined _WIN64) || (defined WIN64)
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <time.h>
|
||||
|
@ -2010,6 +2490,62 @@ int c_fifo::write(void* buf, int len)
|
|||
}
|
||||
return i;
|
||||
}
|
||||
#endif
|
||||
#if (defined __linux__) || (defined __APPLE__)
|
||||
#include <unistd.h>
|
||||
#include <sys/types.h>
|
||||
#include <stdlib.h>
|
||||
#include <pthread.h>
|
||||
#include <stdio.h>
|
||||
typedef void(*ANDROID_PLAY_WAV)(const char* fileName);
|
||||
ANDROID_PLAY_WAV gAndroidPlayWav;
|
||||
typedef struct
|
||||
{
|
||||
AUDIO_TYPE type;
|
||||
}AUDIO_REQUEST;
|
||||
static c_fifo s_request_fifo;
|
||||
static void* render_thread(void* param)
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
AUDIO_REQUEST request;
|
||||
s_request_fifo.read(&request, sizeof(request));
|
||||
|
||||
if (AUDIO_MAX <= request.type)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if(gAndroidPlayWav)
|
||||
{
|
||||
gAndroidPlayWav("heart_beat.wav");
|
||||
}
|
||||
}
|
||||
}
|
||||
void c_audio::init()
|
||||
{
|
||||
static bool s_flag = false;
|
||||
if (s_flag)
|
||||
{
|
||||
return;
|
||||
}
|
||||
unsigned long pid;
|
||||
create_thread(&pid, 0, render_thread, 0);
|
||||
s_flag = true;
|
||||
}
|
||||
int c_audio::play(AUDIO_TYPE type)
|
||||
{
|
||||
if (AUDIO_MAX <= type)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
init();
|
||||
AUDIO_REQUEST request;
|
||||
request.type = type;
|
||||
s_request_fifo.write(&request, sizeof(request));
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
#if (defined _WIN32) || (defined WIN32) || (defined _WIN64) || (defined WIN64)
|
||||
#include <windows.h>
|
||||
#include <Audioclient.h>
|
||||
#include <mmdeviceapi.h>
|
||||
|
@ -2218,6 +2754,7 @@ int c_audio::play(AUDIO_TYPE type)
|
|||
s_request_fifo.write(&request, sizeof(request));
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
void c_button::pre_create_wnd()
|
||||
{
|
||||
m_attr = (WND_ATTRIBUTION)(ATTR_VISIBLE | ATTR_FOCUS);
|
|
@ -327,7 +327,7 @@ public:
|
|||
unsigned int surface_width, unsigned int surface_height,
|
||||
unsigned int color_bytes, unsigned int surface_cnt, EXTERNAL_GFX_OP* gfx_op = 0);
|
||||
c_surface* alloc_surface(Z_ORDER_LEVEL max_zorder);
|
||||
int swipe_surface(c_surface* s1, c_surface* s2, int x0, int x1, int y0, int y2, int offset);
|
||||
int swipe_surface(c_surface* s0, c_surface* s1, int x0, int x1, int y0, int y2, int offset);
|
||||
unsigned int get_width() { return m_width; }
|
||||
unsigned int get_height() { return m_height; }
|
||||
void* get_updated_fb(int* width, int* height, bool force_update = false);
|
||||
|
@ -796,7 +796,7 @@ public:
|
|||
unsigned int get_col_num(){ return m_col_num;}
|
||||
c_rect get_item_rect(int row, int col);
|
||||
protected:
|
||||
void draw_item(int col, int row, const char* str, unsigned int color);
|
||||
void draw_item(int row, int col, const char* str, unsigned int color);
|
||||
unsigned int m_align_type;
|
||||
unsigned int m_row_num;
|
||||
unsigned int m_col_num;
|
||||
|
|
|
@ -1,15 +1,8 @@
|
|||
./.sync.sh 1h1cpp
|
||||
|
||||
echo "Merge GuiLite source code into: 1 hearder & 1 source file"
|
||||
echo ""
|
||||
echo "Choose 1: Build for Linux"
|
||||
echo "Choose 2: Build for Windows"
|
||||
echo "Choose 3: Build for None OS or any OS"
|
||||
echo "Choose 4: exit"
|
||||
echo "Flatten source code into: GuiLite.h/GuiLite.cpp"
|
||||
|
||||
read -p "Please input:[1-3]:" input
|
||||
|
||||
# build GuiLite.h
|
||||
# build GuiLiteRaw.h
|
||||
cd core_include
|
||||
cat api.h cmd_target.h rect.h resource.h theme.h surface.h display.h word.h bitmap.h wnd.h audio.h > core.h
|
||||
mv core.h ../
|
||||
|
@ -22,40 +15,13 @@ cd ..
|
|||
cat core.h widgets.h > GuiLiteRaw.h
|
||||
rm core.h widgets.h
|
||||
|
||||
# build GuiLite-xxx.cpp
|
||||
cppFileName="GuiLite-win.cpp"
|
||||
# build GuiLiteRaw.cpp
|
||||
cd core
|
||||
cat *.cpp > core.cpp
|
||||
mv core.cpp ../
|
||||
|
||||
cd adapter
|
||||
|
||||
while :
|
||||
do
|
||||
case $input in
|
||||
1)
|
||||
echo "Choose 1"
|
||||
cat *linux*.cpp > adapter.cpp
|
||||
cppFileName="GuiLite-linux.cpp"
|
||||
break
|
||||
;;
|
||||
2)
|
||||
echo "Choose 2"
|
||||
cat *win*.cpp > adapter.cpp
|
||||
break
|
||||
;;
|
||||
3)
|
||||
echo "Choose 3"
|
||||
cat *unknow*.cpp > adapter.cpp
|
||||
cppFileName="GuiLite-unknow.cpp"
|
||||
break
|
||||
;;
|
||||
*)
|
||||
rm ../../GuiLiteRaw.h ../../core.cpp
|
||||
exit 0
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
cat *.cpp > adapter.cpp
|
||||
mv adapter.cpp ../../
|
||||
|
||||
cd ../../widgets
|
||||
|
@ -74,13 +40,13 @@ sed -i '1s/^/#include "GuiLite.h" /' GuiLiteNoInclude.cpp
|
|||
|
||||
# Delete empty lines or blank lines
|
||||
sed '/^$/d' GuiLiteRaw.h > GuiLite.h
|
||||
sed '/^$/d' GuiLiteNoInclude.cpp > $cppFileName
|
||||
sed '/^$/d' GuiLiteNoInclude.cpp > GuiLite.cpp
|
||||
|
||||
# Verify
|
||||
gcc -c $cppFileName
|
||||
gcc -c GuiLite.cpp
|
||||
|
||||
# clean
|
||||
rm GuiLiteRaw.h GuiLiteRaw.cpp GuiLiteNoInclude.cpp
|
||||
|
||||
echo "Done!"
|
||||
echo "You could find GuiLite.h/$cppFileName in this folder"
|
||||
echo "You could find GuiLite.h/GuiLite.cpp in this folder"
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#if (!defined _WIN32) && (!defined WIN32) && (!defined _WIN64) && (!defined WIN64) && (!defined __linux__) && && (!defined __APPLE__)
|
||||
#if (!defined _WIN32) && (!defined WIN32) && (!defined _WIN64) && (!defined WIN64) && (!defined __linux__) && (!defined __APPLE__)
|
||||
|
||||
#include "../../core_include/api.h"
|
||||
#include <stdio.h>
|
||||
|
|
Loading…
Reference in New Issue