初版
This commit is contained in:
@@ -0,0 +1,81 @@
|
||||
#ifndef __FONT_ALL_H__
|
||||
#define __FONT_ALL_H__
|
||||
|
||||
#include "generic/typedef.h"
|
||||
#include "font/font_sdfs.h"
|
||||
|
||||
typedef struct {
|
||||
u8 width;
|
||||
u8 size;
|
||||
u16 addr;
|
||||
} ASCSTRUCT;
|
||||
|
||||
//标志位
|
||||
#define FONT_GET_WIDTH 0x01
|
||||
#define FONT_SHOW_PIXEL 0x02
|
||||
#define FONT_SHOW_MULTI_LINE 0x04 /* 显示多行文本(默认显示一行) */
|
||||
#define FONT_SHOW_SCROLL 0x08 /* 滚动显示*/
|
||||
#define FONT_DEFAULT (FONT_SHOW_PIXEL)
|
||||
|
||||
#define FONT_ENCODE_ANSI 0x00
|
||||
#define FONT_ENCODE_UNICODE 0x01
|
||||
#define FONT_ENCODE_UTF8 0x02
|
||||
|
||||
#define FONT_ENDIAN_BIG 0x00
|
||||
#define FONT_ENDIAN_SMALL 0x01
|
||||
|
||||
struct font_file {
|
||||
char *name;
|
||||
FILE *fd;
|
||||
};
|
||||
|
||||
struct font {
|
||||
struct font_file file;
|
||||
u16 nbytes;
|
||||
u8 size;
|
||||
u8 *pixelbuf;
|
||||
};
|
||||
struct dispbuf {
|
||||
int format;
|
||||
u32 color;
|
||||
void *rect;
|
||||
void *map;
|
||||
};
|
||||
|
||||
enum FONT_STATUS {
|
||||
FT_ERROR_NONE,
|
||||
FT_ERROR_NOPIXFILE = 0x01, //没有字模文件
|
||||
FT_ERROR_NOASCPIXFILE = 0x02, //没有ASCII字模文件
|
||||
FT_ERROR_NOTABFILE = 0x04, //没有TAB文件
|
||||
FT_ERROR_NOMEM = 0x08, //内存不足
|
||||
FT_ERROR_CODEPAGE = 0x10, //代码页错误
|
||||
};
|
||||
|
||||
struct font_info {
|
||||
struct font ascpixel; //ASCII像素
|
||||
struct font pixel; //像素
|
||||
struct font_file tabfile; //UNICODE转内码文件
|
||||
u8 sta; //状态
|
||||
u8 ratio; //放大倍数,默认为1
|
||||
u8 language_id; //语言ID
|
||||
u8 bigendian; //大端模式(unicode编码)
|
||||
u8 isgb2312; //是否GB2312,用以区分GBK以及GB2312字库
|
||||
u8 codepage; //代码页
|
||||
u16 x;
|
||||
u16 y;
|
||||
u16 text_width; //文本宽度
|
||||
u16 text_height; //文本高度
|
||||
u16 string_width; //字符串宽度
|
||||
u16 offset; //显示偏移
|
||||
u32 flags; //标志位
|
||||
struct dispbuf disp; //显示相关信息
|
||||
void (*putchar)(struct font_info *info, u8 *pixel, u16 width, u16 height, u16 x, u16 y);
|
||||
void *dc;
|
||||
};
|
||||
|
||||
#define font_ntohl(x) (unsigned long)((x>>24)|((x>>8)&0xff00)|(x<<24)|((x&0xff00)<<8))
|
||||
#define font_ntoh(x) (unsigned short int )((x>>8&0x00ff)|x<<8&0xff00)
|
||||
|
||||
extern struct font_info font_info_table[];
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,22 @@
|
||||
#ifndef __UI_SDFS_H__
|
||||
#define __UI_SDFS_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "generic/typedef.h"
|
||||
#include "fs/fs.h"
|
||||
|
||||
#define SD_SEEK_SET 0x00
|
||||
#define SD_SEEK_CUR 0x01
|
||||
|
||||
FILE *font_sd_fopen(const char *filename, void *arg);
|
||||
int font_sd_fread(FILE *fp, void *buf, u32 len);
|
||||
int font_sd_fseek(FILE *fp, u8 seek_mode, u32 offset);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,103 @@
|
||||
#ifndef __FONT_OUT_H__
|
||||
#define __FONT_OUT_H__
|
||||
|
||||
#include "generic/typedef.h"
|
||||
#include "font/font_all.h"
|
||||
|
||||
/**
|
||||
* @brief 打开字库
|
||||
*
|
||||
* @param info:字库信息
|
||||
* @param language:语言
|
||||
*
|
||||
* @returns TRUE:打开成功 FALSE:打开失败
|
||||
*/
|
||||
struct font_info *font_open(struct font_info *info, u8 language);
|
||||
/**
|
||||
* @brief 获取字符宽度
|
||||
*
|
||||
* @param info
|
||||
* @param str
|
||||
* @param strlen
|
||||
*
|
||||
* @returns
|
||||
*/
|
||||
u16 font_text_width(struct font_info *info, u8 *str, u16 strlen);
|
||||
u16 font_textw_width(struct font_info *info, u8 *str, u16 strlen);
|
||||
u16 font_textu_width(struct font_info *info, u8 *str, u16 strlen);
|
||||
|
||||
/**
|
||||
* @brief 字库内码显示接口
|
||||
*
|
||||
* @param info
|
||||
* @param str
|
||||
* @param strlen
|
||||
*
|
||||
* @returns
|
||||
*/
|
||||
u16 font_textout(struct font_info *info, u8 *str, u16 strlen, u16 x, u16 y);
|
||||
/**
|
||||
* @brief 字库unicode显示接口
|
||||
*
|
||||
* @param info
|
||||
* @param str
|
||||
* @param strlen
|
||||
* @param x
|
||||
* @param y
|
||||
*
|
||||
* @returns
|
||||
*/
|
||||
u16 font_textout_unicode(struct font_info *info, u8 *str, u16 strlen, u16 x, u16 y);
|
||||
/**
|
||||
* @brief 字库utf8显示接口
|
||||
*
|
||||
* @param info
|
||||
* @param str
|
||||
* @param strlen
|
||||
* @param x
|
||||
* @param y
|
||||
*
|
||||
* @returns
|
||||
*/
|
||||
u16 font_textout_utf8(struct font_info *info, u8 *str, u16 strlen, u16 x, u16 y);
|
||||
/**
|
||||
* @brief utf8转内码
|
||||
*
|
||||
* @param info
|
||||
* @param utf8
|
||||
* @param utf8len
|
||||
* @param ansi
|
||||
*
|
||||
* @returns
|
||||
*/
|
||||
u16 font_utf8toansi(struct font_info *info, u8 *utf8, u16 utf8len, u8 *ansi);
|
||||
/**
|
||||
* @brief utf16转内码
|
||||
*
|
||||
* @param info
|
||||
* @param utf
|
||||
* @param len
|
||||
* @param ansi
|
||||
*
|
||||
* @returns
|
||||
*/
|
||||
u16 font_utf16toansi(struct font_info *info, u8 *utf, u16 len, u8 *ansi);
|
||||
/**
|
||||
* @brief utf8转utf16
|
||||
*
|
||||
* @param info
|
||||
* @param utf8
|
||||
* @param utf8len
|
||||
* @param utf16
|
||||
*
|
||||
* @returns
|
||||
*/
|
||||
u16 font_utf8toutf16(struct font_info *info, u8 *utf8, u16 utf8len, u16 *utf16);
|
||||
/**
|
||||
* @brief 字库关闭
|
||||
*
|
||||
* @param info
|
||||
*/
|
||||
void font_close(struct font_info *info);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,28 @@
|
||||
#ifndef __LANGUAGE_LIST_H__
|
||||
#define __LANGUAGE_LIST_H__
|
||||
|
||||
#define Chinese_Simplified 1 //简体中文
|
||||
#define Chinese_Traditional 2 //繁体中文
|
||||
#define Japanese 3 //日语
|
||||
#define Korean 4 //韩语
|
||||
#define English 5 //英语
|
||||
#define French 6 //法语
|
||||
#define German 7 //德语
|
||||
#define Italian 8 //意大利语
|
||||
#define Dutch 9 //荷兰语
|
||||
#define Portuguese 10 //葡萄牙语
|
||||
#define Spanish 11 //西班牙语
|
||||
#define Swedish 12 //瑞典语
|
||||
#define Czech 13 //捷克语
|
||||
#define Danish 14 //丹麦语
|
||||
#define Polish 15 //波兰语
|
||||
#define Russian 16 //俄语
|
||||
#define Turkey 17 //土耳其语
|
||||
#define Hebrew 18 //希伯来语
|
||||
#define Thai 19 //泰语
|
||||
#define Hungarian 20 //匈牙利语
|
||||
#define Romanian 21 //罗马尼亚语
|
||||
#define Arabic 22 //阿拉伯语
|
||||
#define Vietnam 23 //越南语
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,26 @@
|
||||
#ifndef UI_INCLUDES_H
|
||||
#define UI_INCLUDES_H
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#include "ui/ui.h"
|
||||
|
||||
#include "res/resfile.h"
|
||||
#include "res/font_ascii.h"
|
||||
|
||||
|
||||
|
||||
#define UI_TOUCH_DEBUG 1
|
||||
|
||||
#if (UI_TOUCH_DEBUG == 1)
|
||||
#define UI_ONTOUCH_DEBUG log_d
|
||||
#else
|
||||
#define UI_ONTOUCH_DEBUG(...)
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,23 @@
|
||||
#ifndef FONT_ASCII_H
|
||||
#define FONT_ASCII_H
|
||||
|
||||
|
||||
#include "typedef.h"
|
||||
|
||||
|
||||
int font_ascii_get_pix(char code, u8 *pixbuf, int buflen, int *height, int *width);
|
||||
|
||||
int font_ascii_width_check(const char *str);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
#ifndef RESFILE_H
|
||||
#define RESFILE_H
|
||||
|
||||
#include "typedef.h"
|
||||
//#include "fs/fs.h"
|
||||
|
||||
#define FILE_TYPE_JPEG 5
|
||||
#define AT_UI_RAM //AT(.ui_ram)
|
||||
|
||||
struct image_file {
|
||||
u8 format;
|
||||
u8 compress;
|
||||
u16 data_crc;
|
||||
u16 width;
|
||||
u16 height;
|
||||
u32 offset;
|
||||
u32 len;
|
||||
};
|
||||
|
||||
int open_resfile(const char *name);
|
||||
void close_resfile();
|
||||
|
||||
int res_file_version_compare(int res_ver);
|
||||
|
||||
int open_str_file(const char *name);
|
||||
void close_str_file();
|
||||
int str_file_version_compare(int str_ver);
|
||||
|
||||
int open_style_file(const char *name);
|
||||
|
||||
int font_ascii_init(const char *name);
|
||||
int open_image_by_id(struct image_file *f, int id, int page);
|
||||
int read_image_data(struct image_file *f, u8 *data, int len);
|
||||
int br23_read_image_data(struct image_file *f, u8 *data, int len, int offset);
|
||||
u32 image_decode(const void *pSour, void *pDest, u32 SourLen, u32 DestLen, u8 compress);
|
||||
int open_string_pic(struct image_file *file, int id);
|
||||
int read_str_data(struct image_file *f, u8 *data, int len);
|
||||
int br23_read_str_data(struct image_file *f, u8 *data, int len, int offset);
|
||||
int load_pallet_table(int id, u32 *data);
|
||||
int ui_language_set(int language);
|
||||
int ui_language_get();
|
||||
|
||||
FILE *res_fopen(const char *path, const char *mode);
|
||||
int res_fread(FILE *_file, void *buf, u32 len);
|
||||
int res_fseek(FILE *_file, int offset, int fromwhere);
|
||||
int res_fclose(FILE *file);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,19 @@
|
||||
#ifndef __RLE_H__
|
||||
#define __RLE_H__
|
||||
|
||||
//#include "system/includes.h"
|
||||
|
||||
struct rle_header {
|
||||
u32 addr: 22; //max 4M
|
||||
u32 len: 10; //max 1024 bytes
|
||||
};
|
||||
|
||||
struct rle_line {
|
||||
u32 addr: 23;
|
||||
u32 num: 9;
|
||||
u16 len[0];
|
||||
};
|
||||
|
||||
int Rle_Decode(u8 *inbuf, int inSize, u8 *outbuf, int onuBufSize, int offset, int len);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,339 @@
|
||||
#ifndef UI_CONTROL_H
|
||||
#define UI_CONTROL_H
|
||||
|
||||
#include "ui/ui_core.h"
|
||||
|
||||
union ui_control_info;
|
||||
struct layout_info;
|
||||
|
||||
|
||||
#define CTRL_TYPE_WINDOW 2
|
||||
#define CTRL_TYPE_LAYOUT 3
|
||||
#define CTRL_TYPE_LAYER 4
|
||||
#define CTRL_TYPE_GRID 5
|
||||
#define CTRL_TYPE_LIST 6
|
||||
#define CTRL_TYPE_BUTTON 7
|
||||
#define CTRL_TYPE_PIC 8
|
||||
#define CTRL_TYPE_BATTERY 9
|
||||
#define CTRL_TYPE_TIME 10
|
||||
#define CTRL_TYPE_CAMERA_VIEW 11
|
||||
#define CTRL_TYPE_TEXT 12
|
||||
#define CTRL_TYPE_ANIMATION 13
|
||||
#define CTRL_TYPE_PLAYER 14
|
||||
#define CTRL_TYPE_NUMBER 15
|
||||
|
||||
#define CTRL_TYPE_PROGRESS 30
|
||||
#define CTRL_PROGRESS_CHILD_BEGIN (CTRL_TYPE_PROGRESS + 1)
|
||||
#define CTRL_PROGRESS_CHILD_HIGHLIGHT (CTRL_PROGRESS_CHILD_BEGIN)
|
||||
#define CTRL_PROGRESS_CHILD_END (CTRL_PROGRESS_CHILD_BEGIN + 1)
|
||||
|
||||
#define CTRL_TYPE_MULTIPROGRESS 32
|
||||
#define CTRL_MULTIPROGRESS_CHILD_BEGIN (CTRL_TYPE_MULTIPROGRESS + 1)
|
||||
#define CTRL_MULTIPROGRESS_CHILD_HIGHLIGHT (CTRL_MULTIPROGRESS_CHILD_BEGIN)
|
||||
#define CTRL_MULTIPROGRESS_CHILD_END (CTRL_MULTIPROGRESS_CHILD_BEGIN + 1)
|
||||
|
||||
#define CTRL_TYPE_WATCH 40
|
||||
#define CTRL_WATCH_CHILD_BEGIN (CTRL_TYPE_WATCH + 1)
|
||||
#define CTRL_WATCH_CHILD_HOUR (CTRL_WATCH_CHILD_BEGIN)
|
||||
#define CTRL_WATCH_CHILD_MIN (CTRL_WATCH_CHILD_BEGIN+1)
|
||||
#define CTRL_WATCH_CHILD_SEC (CTRL_WATCH_CHILD_BEGIN+2)
|
||||
#define CTRL_WATCH_CHILD_END (CTRL_WATCH_CHILD_BEGIN+3)
|
||||
|
||||
|
||||
#define CTRL_TYPE_SLIDER 50
|
||||
|
||||
#define SLIDER_CHILD_BEGIN (CTRL_TYPE_SLIDER+1)
|
||||
#define SLIDER_CHILD_UNSELECT_PIC (SLIDER_CHILD_BEGIN)
|
||||
#define SLIDER_CHILD_SELECTED_PIC (SLIDER_CHILD_BEGIN+1)
|
||||
#define SLIDER_CHILD_SLIDER_PIC (SLIDER_CHILD_BEGIN+2)
|
||||
#define SLIDER_CHILD_PERSENT_TEXT (SLIDER_CHILD_BEGIN+3)
|
||||
#define SLIDER_CHILD_END (SLIDER_CHILD_BEGIN+4)
|
||||
|
||||
|
||||
#define CTRL_TYPE_BROWSER 60
|
||||
#define CTRL_TYPE_BROWSER_ITEM 61
|
||||
|
||||
#define CTRL_TYPE_FILE_ATTRS 70
|
||||
#define CTRL_TYPE_FILE_PREVIEW 71
|
||||
#define CTRL_TYPE_FILE_TYPE_ICON 72
|
||||
#define CTRL_TYPE_FILE_RW_PIC 73
|
||||
#define CTRL_TYPE_FILE_FILM_LEN 74
|
||||
#define CTRL_TYPE_FILE_NAME 75
|
||||
#define CTRL_TYPE_FILE_SIZE 76
|
||||
#define CTRL_TYPE_FILE_CREATE_TIME 77
|
||||
|
||||
|
||||
struct ui_ctrl_info_head {
|
||||
u8 type;
|
||||
u8 ctrl_num;
|
||||
u8 css_num;
|
||||
u8 len;
|
||||
u8 page;
|
||||
u8 rev[3];
|
||||
int id;
|
||||
struct element_css1 *css;
|
||||
};
|
||||
|
||||
struct ui_image_list {
|
||||
u16 num;
|
||||
u16 image[0];
|
||||
};
|
||||
|
||||
struct ui_text_list {
|
||||
u16 num;
|
||||
char str[0];
|
||||
};
|
||||
|
||||
|
||||
struct ui_image_list_t {
|
||||
u16 num;
|
||||
u16 image[16];
|
||||
};
|
||||
|
||||
struct ui_text_list_t {
|
||||
u16 num;
|
||||
char str[4];
|
||||
};
|
||||
|
||||
struct ui_button_info {
|
||||
struct ui_ctrl_info_head head;
|
||||
struct element_event_action *action;
|
||||
};
|
||||
|
||||
|
||||
|
||||
struct ui_camera_info {
|
||||
struct ui_ctrl_info_head head;
|
||||
char device[8];
|
||||
struct element_event_action *action;
|
||||
};
|
||||
|
||||
struct ui_player_info {
|
||||
struct ui_ctrl_info_head head;
|
||||
char device[8];
|
||||
struct element_event_action *action;
|
||||
};
|
||||
|
||||
struct ui_time_info {
|
||||
struct ui_ctrl_info_head head;
|
||||
u8 auto_cnt;
|
||||
u8 rev[3];
|
||||
char format[16];
|
||||
int color;
|
||||
int hi_color;
|
||||
u16 number[10];
|
||||
u16 delimiter[10];
|
||||
struct element_event_action *action;
|
||||
};
|
||||
|
||||
struct ui_number_info {
|
||||
struct ui_ctrl_info_head head;
|
||||
char format[16];
|
||||
int color;
|
||||
int hi_color;
|
||||
u16 number[10];
|
||||
u16 delimiter[10];
|
||||
u16 space[2];
|
||||
struct element_event_action *action;
|
||||
};
|
||||
|
||||
|
||||
struct ui_pic_info {
|
||||
struct ui_ctrl_info_head head;
|
||||
u8 highlight;
|
||||
u16 cent_x;
|
||||
u16 cent_y;
|
||||
struct ui_image_list *normal_img;
|
||||
struct ui_image_list *highlight_img;
|
||||
struct element_event_action *action;
|
||||
};
|
||||
|
||||
|
||||
struct ui_battery_info {
|
||||
struct ui_ctrl_info_head head;
|
||||
struct ui_image_list *normal_image;
|
||||
struct ui_image_list *charge_image;
|
||||
struct element_event_action *action;
|
||||
};
|
||||
|
||||
|
||||
struct ui_text_info {
|
||||
struct ui_ctrl_info_head head;
|
||||
char code[8];
|
||||
int color;
|
||||
int highlight_color;
|
||||
struct ui_text_list *str;
|
||||
struct element_event_action *action;
|
||||
};
|
||||
|
||||
|
||||
struct ui_grid_info {
|
||||
struct ui_ctrl_info_head head;
|
||||
u8 page_mode;
|
||||
char highlight_index;
|
||||
struct element_event_action *action;
|
||||
struct layout_info *info;
|
||||
};
|
||||
|
||||
struct ui_animation_info {
|
||||
struct ui_ctrl_info_head head;
|
||||
u16 loop_num;
|
||||
u32 interval;
|
||||
struct ui_image_list *img;
|
||||
struct element_event_action *action;
|
||||
};
|
||||
|
||||
struct ui_slider_info {
|
||||
struct ui_ctrl_info_head head;
|
||||
u8 step;
|
||||
struct ui_ctrl_info_head *ctrl;
|
||||
struct element_event_action *action;
|
||||
};
|
||||
|
||||
struct ui_watch_info {
|
||||
struct ui_ctrl_info_head head;
|
||||
struct element_event_action *action;
|
||||
struct ui_ctrl_info_head *ctrl;
|
||||
};
|
||||
|
||||
struct ui_progress_info {
|
||||
struct ui_ctrl_info_head head;
|
||||
struct element_event_action *action;
|
||||
struct ui_ctrl_info_head *ctrl;
|
||||
};
|
||||
|
||||
struct ui_multiprogress_info {
|
||||
struct ui_ctrl_info_head head;
|
||||
struct element_event_action *action;
|
||||
struct ui_ctrl_info_head *ctrl;
|
||||
};
|
||||
|
||||
struct ui_browser_info {
|
||||
struct ui_ctrl_info_head head;
|
||||
u8 row;
|
||||
u8 column;
|
||||
u8 interval;
|
||||
u8 scroll;
|
||||
u8 auto_highlight;
|
||||
struct element_event_action *action;
|
||||
struct ui_ctrl_info_head *ctrl;
|
||||
};
|
||||
|
||||
struct ui_fattrs_info {
|
||||
struct ui_ctrl_info_head head;
|
||||
struct element_event_action *action;
|
||||
struct ui_ctrl_info_head *ctrl;
|
||||
};
|
||||
|
||||
union ui_control_info {
|
||||
struct ui_ctrl_info_head head;
|
||||
struct ui_button_info button;
|
||||
struct ui_camera_info camera;
|
||||
struct ui_time_info time;
|
||||
struct ui_number_info number;
|
||||
struct ui_pic_info pic;
|
||||
struct ui_battery_info battery;
|
||||
struct ui_text_info text;
|
||||
struct ui_grid_info grid;
|
||||
};
|
||||
|
||||
struct layout_info {
|
||||
struct ui_ctrl_info_head head;
|
||||
struct element_event_action *action;
|
||||
union ui_control_info *ctrl;
|
||||
};
|
||||
|
||||
|
||||
struct layer_info {
|
||||
struct ui_ctrl_info_head head;
|
||||
u8 format;
|
||||
struct element_event_action *action;
|
||||
struct layout_info *layout;
|
||||
};
|
||||
|
||||
struct window_info {
|
||||
u8 type;
|
||||
u8 ctrl_num;
|
||||
u8 css_num;
|
||||
u8 len;
|
||||
u8 rev[4];
|
||||
struct rect rect;
|
||||
struct layer_info *layer;
|
||||
// struct element_event_action *action;
|
||||
};
|
||||
|
||||
struct control_ops {
|
||||
int type;
|
||||
void *(*new)(const void *, struct element *);
|
||||
/*int (*delete)(void *);*/
|
||||
};
|
||||
|
||||
extern const struct control_ops control_ops_begin[];
|
||||
extern const struct control_ops control_ops_end[];
|
||||
|
||||
|
||||
#define REGISTER_CONTROL_OPS(_type) \
|
||||
static const struct control_ops control_ops_##_type sec(.control_ops) __attribute__((used)) = { \
|
||||
.type = _type,
|
||||
|
||||
|
||||
|
||||
#define get_control_ops_by_type(_type) \
|
||||
({ \
|
||||
const struct control_ops *ops, *ret=NULL; \
|
||||
for (ops = control_ops_begin; ops < control_ops_end; ops++) { \
|
||||
if (ops->type == _type) { \
|
||||
ret = ops; \
|
||||
break; \
|
||||
} \
|
||||
}\
|
||||
ret; \
|
||||
})
|
||||
|
||||
|
||||
#if 0
|
||||
struct control_event_header {
|
||||
int id;
|
||||
int len;
|
||||
};
|
||||
|
||||
extern struct control_event_header control_event_handler_begin[];
|
||||
extern struct control_event_header control_event_handler_end[];
|
||||
|
||||
|
||||
#define REGISTER_CONTROL_EVENT_HANDLER(control, _id) \
|
||||
static const struct control##_event_handler __##control##_event_handler_##_id \
|
||||
sec(.control_event_handler) = { \
|
||||
.header = { \
|
||||
.id = _id, \
|
||||
.len = sizeof(struct control##_event_handler), \
|
||||
}, \
|
||||
|
||||
|
||||
|
||||
|
||||
static inline void *control_event_handler_for_id(int id)
|
||||
{
|
||||
struct control_event_header *p;
|
||||
|
||||
for (p = control_event_handler_begin; p < control_event_handler_end;) {
|
||||
if (p->id == id) {
|
||||
return p;
|
||||
}
|
||||
p = (u8 *)p + p->len;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
#ifndef LAYER_H
|
||||
#define LAYER_H
|
||||
|
||||
|
||||
#include "ui/layout.h"
|
||||
#include "ui/control.h"
|
||||
|
||||
|
||||
struct layer {
|
||||
struct element elm; //must be first
|
||||
u8 hide;
|
||||
u8 inited;
|
||||
u8 highlight;
|
||||
u8 ctrl_num;
|
||||
u8 css_num;
|
||||
u16 css[2];
|
||||
struct draw_context dc;
|
||||
struct layout *layout;
|
||||
const struct layer_info *info;
|
||||
const struct element_event_handler *handler;
|
||||
};
|
||||
|
||||
|
||||
#define layer_for_id(id) \
|
||||
(struct layer *)ui_core_get_element_by_id(id);
|
||||
|
||||
|
||||
struct layer *layer_new(struct layer_info *info, int num, struct element *parent);
|
||||
|
||||
|
||||
void layer_delete_probe(struct layer *layer, int num);
|
||||
|
||||
void layer_delete(struct layer *layer, int num);
|
||||
|
||||
int layer_show(int id);
|
||||
|
||||
int layer_hide(int id);
|
||||
|
||||
int layer_toggle(int id);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
#ifndef LAYOUT_H
|
||||
#define LAYOUT_H
|
||||
|
||||
|
||||
#include "ui/ui_core.h"
|
||||
#include "ui/control.h"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
struct layout {
|
||||
struct element elm; //must be first
|
||||
u8 hide: 1;
|
||||
u8 inited: 1;
|
||||
u8 release: 1;
|
||||
u8 css_num: 5;
|
||||
u16 css[2];
|
||||
struct layout *layout;
|
||||
const struct layout_info *info;
|
||||
const struct element_event_handler *handler;
|
||||
};
|
||||
|
||||
|
||||
|
||||
#define layout_for_id(id) \
|
||||
(struct layout *)ui_core_get_element_by_id(id);
|
||||
|
||||
|
||||
struct layout *layout_new(struct layout_info *, int, struct element *);
|
||||
|
||||
void layout_delete_probe(struct layout *layout, int num);
|
||||
|
||||
void layout_delete(struct layout *layout, int num);
|
||||
|
||||
int layout_show(int id);
|
||||
|
||||
int layout_hide(int id);
|
||||
|
||||
int layout_toggle(int id);
|
||||
|
||||
void layout_on_focus(struct layout *layout);
|
||||
void layout_lose_focus(struct layout *layout);
|
||||
|
||||
|
||||
/*int layout_current_highlight(int id);*/
|
||||
|
||||
/*int layout_onkey(struct layout *layout, struct element_key_event *e);*/
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -0,0 +1,110 @@
|
||||
#ifndef _LYRICS_H_
|
||||
#define _LYRICS_H_
|
||||
|
||||
#include "typedef.h"
|
||||
#include "system/fs/fs.h"
|
||||
|
||||
#define LRC_SIZEOF_ALIN(var, al) ((((var)+(al)-1)/(al))*(al))
|
||||
|
||||
//类型声明区
|
||||
typedef struct _TIME_LABEL { /*时间标签信息[mm:ss.ms]*/
|
||||
u16 dbtime_s; //time of label,unit:s
|
||||
u8 btime_100ms; //time of label,unit:ms
|
||||
u8 btext_len; //the length of lrc content, 占用的实际字节数
|
||||
u32 wline_pos; //for record next (byte addr) after the (real label of time)
|
||||
} TIME_LABEL;
|
||||
|
||||
typedef struct __LRC_FILE_IO {
|
||||
u32(*seek)(FILE *file, int offset, int orig);
|
||||
u32(*read)(FILE *file, void *buf, u32 len);
|
||||
} LRC_FILE_IO;
|
||||
|
||||
typedef struct _LABEL_INFO { /*标签处理后信息*/
|
||||
u16 dbtime_base; //first of time
|
||||
u16 dbtime_limit; //end of time
|
||||
u8 base_100ms; //first of time
|
||||
u8 limit_100ms; //first of time
|
||||
u16 dblabel_cnt; //(real label of time) count
|
||||
TIME_LABEL *g_plabel_buf; //解析过程中时间标签存储buf
|
||||
u8 *plabel_buf_tmp;
|
||||
u16 plabel_buf_len; //解析过程中时间标签存储buf长度
|
||||
} LABEL_INFO;
|
||||
|
||||
|
||||
|
||||
typedef struct _SORTING_INFO { /*文件解析信息*/
|
||||
u16 dbnow_fp_addr;//current addr of file pointer
|
||||
u8 bdata_len; //the length of lrc content
|
||||
u8 bis_next_file;//jump to next file
|
||||
} SORTING_INFO;
|
||||
|
||||
|
||||
typedef struct __LRC_FILE {
|
||||
void *hdl;
|
||||
LRC_FILE_IO *_io;
|
||||
} LRC_FILE;
|
||||
|
||||
|
||||
|
||||
typedef struct _LRC_INFO { ///</*lrc显示信息*/
|
||||
u8 coding_type; ///<歌词unicode编码格式
|
||||
///<显示相关的
|
||||
u8 bis_lrc_update; ///<lrc显示歌词更新标志
|
||||
u8 broll_speed_control; ///<lrc显示滚动速度控制标志
|
||||
u8 blcd_roll_speed; ///<lcd显示歌词内容滚动速度
|
||||
u8 content_len; ///<当前歌词内容长度
|
||||
u8 lrc_data_len; ///<实际歌词显示内容长度
|
||||
|
||||
//CFG
|
||||
u16 blrc_buf_len; ///<lrc显示内容buf长度,配置
|
||||
u8 *blrc_buf; ///<lrc显示内容buf地址
|
||||
|
||||
///<file相关的,CFG
|
||||
u8 *lrc_read_buf; ///<lrc读取数据buffer
|
||||
LRC_FILE file; ///lrc文件操作控制
|
||||
/* void *lrc_file_hdl; ///<lrc文件句柄 */
|
||||
u32 cur_faddr; ///当前文件文件位置
|
||||
u16 once_read_len; ///<一次读取的长度,需要配置
|
||||
u16 real_len; ///<真实一次读取到的数据长度
|
||||
u16 data_len_count; ///<缓存中已分析的数据offset
|
||||
u16 label_id; ///<时间标签读取id(0~)
|
||||
u16 lrc_label_len; ///<解析后标签数据长度
|
||||
|
||||
|
||||
bool bfirst_lable; ///<第一个时间标签标记
|
||||
bool blast_lable; ///<最后一个时间标签标记
|
||||
u8 lrc_text_id; ///text id
|
||||
u8 read_next_lrc_flag; ///是否预读下一条歌词lrc
|
||||
u8 save_flash;
|
||||
SORTING_INFO *sorting; ///<歌词文件解析信息
|
||||
LABEL_INFO *lab_info; ///<标签处理后信息
|
||||
|
||||
void (*roll_speed_ctrl_cb)(u8 lrc_len, u32 time_gap, u8 *roll_speed);///翻页速度控制
|
||||
void (*clr_lrc_disp_cb)(void);
|
||||
|
||||
} LRC_INFO;
|
||||
|
||||
|
||||
|
||||
typedef struct __LRC_CFG {
|
||||
u16 once_read_len;///一次读取长度配置
|
||||
u16 once_disp_len;///一次显示缓存长度配置
|
||||
u16 label_temp_buf_len;///时间标签缓存总长度配置
|
||||
u8 lrc_text_id; ///text id
|
||||
u8 read_next_lrc_flag; ///是否预读下一条歌词lrc
|
||||
u8 enable_save_lable_to_flash;//使能保存时间标签到flash,主要是解决长歌词文件不支持问题
|
||||
void (*roll_speed_ctrl_cb)(u8 lrc_len, u32 time_gap, u8 *roll_speed);///速度控制配置
|
||||
void (*clr_lrc_disp_cb)(void);///清屏回调
|
||||
} LRC_CFG;
|
||||
|
||||
|
||||
extern void lrc_destroy(void);
|
||||
extern int lrc_param_init(LRC_CFG *cfg, u8 *lrc_info_buf);
|
||||
extern bool lrc_analysis(void *lrc_handle, const LRC_FILE_IO *file_io);
|
||||
extern bool lrc_get(u16 dbtime_s, u8 btime_100ms);
|
||||
|
||||
extern bool lrc_show(int text_id, u16 dbtime_s, u8 btime_100ms);
|
||||
extern void lrc_label_save_to_flash_init(u32 addr, u32 len, u32 base_addr);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
#ifndef UI_P_H
|
||||
#define UI_P_H
|
||||
|
||||
#include "ui/ui_core.h"
|
||||
|
||||
struct ui_str {
|
||||
const char *format;
|
||||
char *str;
|
||||
};
|
||||
|
||||
struct element_text {
|
||||
struct element elm; //must be first
|
||||
char *str;
|
||||
const char *format;
|
||||
void *priv;
|
||||
int color;
|
||||
const struct element_event_handler *handler;
|
||||
};
|
||||
|
||||
|
||||
|
||||
void text_element_set_text(struct element_text *text, char *str,
|
||||
const char *format, int color);
|
||||
|
||||
|
||||
void text_element_init(struct element_text *text, int id,
|
||||
const struct element_css1 *css,
|
||||
const struct element_event_action *action);
|
||||
|
||||
|
||||
void text_element_set_event_handler(struct element_text *text, void *priv,
|
||||
const struct element_event_handler *handler);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,72 @@
|
||||
#ifndef UI_CORE_H
|
||||
#define UI_CORE_H
|
||||
|
||||
#include "window.h"
|
||||
#include "ui_button.h"
|
||||
#include "ui_grid.h"
|
||||
#include "ui_time.h"
|
||||
#include "ui_camera.h"
|
||||
#include "ui_pic.h"
|
||||
#include "ui_text.h"
|
||||
#include "ui_battery.h"
|
||||
#include "ui_browser.h"
|
||||
#include "ui_slider.h"
|
||||
#include "ui_number.h"
|
||||
#include "ui_watch.h"
|
||||
#include "ui_progress.h"
|
||||
#include "ui_progress_multi.h"
|
||||
#include <stdarg.h>
|
||||
|
||||
struct uimsg_handl {
|
||||
const char *msg;
|
||||
int (*handler)(const char *type, u32 args);
|
||||
};
|
||||
|
||||
int ui_framework_init(void *);
|
||||
|
||||
int ui_set_style_file(struct ui_style *style);
|
||||
|
||||
int ui_style_file_version_compare(int version);
|
||||
|
||||
int ui_show(int id);
|
||||
|
||||
int ui_hide(int id);
|
||||
|
||||
int ui_set_call(int (*func)(int), int param);
|
||||
|
||||
int ui_event_onkey(struct element_key_event *e);
|
||||
|
||||
int ui_event_ontouch(struct element_touch_event *e);
|
||||
|
||||
struct element *ui_get_highlight_child_by_id(int id);
|
||||
int ui_invert_element_by_id(int id);
|
||||
|
||||
int ui_no_highlight_element(struct element *elm);
|
||||
int ui_no_highlight_element_by_id(int id);
|
||||
int ui_highlight_element(struct element *elm);
|
||||
int ui_highlight_element_by_id(int id);
|
||||
|
||||
int ui_get_current_window_id();
|
||||
|
||||
int ui_register_msg_handler(int id, const struct uimsg_handl *handl);
|
||||
|
||||
int ui_message_handler(int id, const char *msg, va_list);
|
||||
|
||||
const char *str_substr_iter(const char *str, char delim, int *iter);
|
||||
|
||||
/*
|
||||
* 锁定元素elm之外的区域,所有的触摸消息都发给elm
|
||||
*/
|
||||
void ui_ontouch_lock(void *elm);
|
||||
void ui_ontouch_unlock(void *elm);
|
||||
|
||||
/*
|
||||
* 锁定控件的夫图层,先不推向imb显示
|
||||
*/
|
||||
int ui_lock_layer(int id);
|
||||
int ui_unlock_layer(int id);
|
||||
|
||||
int ui_get_disp_status_by_id(int id);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
lcd_interface_begin = .;
|
||||
KEEP(*(.lcd_if_info))
|
||||
lcd_interface_end = .;
|
||||
|
||||
ui_style_begin = .;
|
||||
KEEP(*(.ui_style))
|
||||
ui_style_end = .;
|
||||
|
||||
elm_event_handler_begin_UPGRADE = .;
|
||||
KEEP(*(.elm_event_handler_UPGRADE))
|
||||
elm_event_handler_end_UPGRADE = .;
|
||||
|
||||
elm_event_handler_begin_JL = .;
|
||||
KEEP(*(.elm_event_handler_JL))
|
||||
elm_event_handler_end_JL = .;
|
||||
|
||||
elm_event_handler_begin_JL_01 = .;
|
||||
KEEP(*(.elm_event_handler_JL_01))
|
||||
elm_event_handler_end_JL_01 = .;
|
||||
|
||||
elm_event_handler_begin_JL_02 = .;
|
||||
KEEP(*(.elm_event_handler_JL_02))
|
||||
elm_event_handler_end_JL_02 = .;
|
||||
|
||||
elm_event_handler_begin_JL_03 = .;
|
||||
KEEP(*(.elm_event_handler_JL_03))
|
||||
elm_event_handler_end_JL_03 = .;
|
||||
|
||||
control_event_handler_begin = .;
|
||||
KEEP(*(.control_event_handler))
|
||||
control_event_handler_end = .;
|
||||
|
||||
control_ops_begin = .;
|
||||
KEEP(*(.control_ops))
|
||||
control_ops_end = .;
|
||||
|
||||
vg_event_handler_begin = .;
|
||||
*(.vg_event_handler)
|
||||
vg_event_handler_end = .;
|
||||
|
||||
on_show_map_begin = .;
|
||||
*(.on_show_map)
|
||||
on_show_map_end = .;
|
||||
|
||||
on_click_map_begin = .;
|
||||
*(.on_click_map)
|
||||
on_click_map_end = .;
|
||||
|
||||
on_touch_map_begin = .;
|
||||
*(.on_touch_map)
|
||||
on_touch_map_end = .;
|
||||
|
||||
on_change_map_begin = .;
|
||||
*(.on_change_map)
|
||||
on_change_map_end = .;
|
||||
|
||||
on_key_map_begin = .;
|
||||
*(.on_key_map)
|
||||
on_key_map_end = .;
|
||||
|
||||
img_loader_begin = .;
|
||||
*(.img_loader)
|
||||
img_loader_end = .;
|
||||
|
||||
battery_notify_begin = .;
|
||||
*(.battery_notify)
|
||||
battery_notify_end = .;
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
#ifndef UI_BATTERY_H
|
||||
#define UI_BATTERY_H
|
||||
|
||||
|
||||
#include "ui/control.h"
|
||||
#include "list.h"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
struct ui_battery {
|
||||
struct element elm;
|
||||
int src;
|
||||
u8 index;
|
||||
u16 charge_image;
|
||||
u16 normal_image;
|
||||
struct list_head entry;
|
||||
const struct ui_battery_info *info;
|
||||
const struct element_event_handler *handler;
|
||||
};
|
||||
|
||||
void ui_battery_enable();
|
||||
void ui_battery_level_change(int persent, int incharge);//改变所有电池控件
|
||||
int ui_battery_set_level_by_id(int id, int persent, int incharge);//修改指定id
|
||||
int ui_battery_set_level(struct ui_battery *battery, int persent, int incharge);//初始化使用
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,92 @@
|
||||
#ifndef UI_BROWSER_H
|
||||
#define UI_BROWSER_H
|
||||
|
||||
|
||||
|
||||
#include "ui/ui_core.h"
|
||||
#include "ui/control.h"
|
||||
|
||||
|
||||
|
||||
|
||||
struct ui_browser {
|
||||
struct element elm;
|
||||
struct ui_file_browser *hdl;
|
||||
char order; // 1 ±íʾ ÕýÐò£¬ ·Ç1 ±íʾ·´Ðò
|
||||
u8 inited;
|
||||
u8 hide_byself;
|
||||
u8 item_num;
|
||||
u8 highlight;
|
||||
u8 show_mode;
|
||||
u16 cur_number;
|
||||
u16 file_number;
|
||||
struct ui_grid *grid;
|
||||
const char *path;
|
||||
const char *ftype;
|
||||
const struct ui_browser_info *info;
|
||||
const struct element_event_handler *handler;
|
||||
};
|
||||
|
||||
|
||||
#define ui_file_browser_cur_item(bro) ui_grid_cur_item(((struct ui_browser *)bro)->grid)
|
||||
|
||||
|
||||
int ui_file_browser_page_num(struct ui_browser *bro);
|
||||
|
||||
int ui_file_browser_cur_page(struct ui_browser *bro, int *file_num);
|
||||
|
||||
int ui_file_browser_set_page(struct ui_browser *bro, int page);
|
||||
|
||||
int ui_file_browser_set_page_by_id(int id, int page);
|
||||
|
||||
int ui_file_browser_next_page(struct ui_browser *bro);
|
||||
|
||||
int ui_file_browser_next_page_by_id(int id);
|
||||
|
||||
int ui_file_browser_prev_page(struct ui_browser *bro);
|
||||
|
||||
int ui_file_browser_prev_page_by_id(int id);
|
||||
|
||||
int ui_file_browser_set_dir(struct ui_browser *bro, const char *path, const char *ftype);
|
||||
|
||||
int ui_file_browser_set_dir_by_id(int id, const char *path, const char *ftype);
|
||||
|
||||
int ui_file_browser_get_file_attrs(struct ui_browser *bro, int item,
|
||||
struct ui_file_attrs *attrs);
|
||||
|
||||
int ui_file_browser_set_file_attrs(struct ui_browser *bro, int item,
|
||||
struct ui_file_attrs *attrs);
|
||||
|
||||
void *ui_file_browser_open_file(struct ui_browser *bro, int item);
|
||||
|
||||
|
||||
int ui_file_browser_del_file(struct ui_browser *bro, int item);
|
||||
|
||||
int ui_file_browser_highlight_item(struct ui_browser *bro, int item, bool yes);
|
||||
|
||||
void *ui_file_browser_get_child_by_id(struct ui_browser *bro, int item, int id);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,20 @@
|
||||
#ifndef UI_BUTTON_H
|
||||
#define UI_BUTTON_H
|
||||
|
||||
|
||||
#include "ui/control.h"
|
||||
#include "ui/ui_core.h"
|
||||
|
||||
struct button {
|
||||
struct element elm;
|
||||
u8 image_index;
|
||||
u8 css_num;
|
||||
u16 css[2];
|
||||
const struct ui_button_info *info;
|
||||
const struct element_event_handler *handler;
|
||||
};
|
||||
|
||||
void ui_button_enable();
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
#ifndef UI_CAMERA_H
|
||||
#define UI_CAMERA_H
|
||||
|
||||
#include "ui/control.h"
|
||||
#include "ui/ui_core.h"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
struct ui_camera {
|
||||
struct element elm; //must be first
|
||||
int fd;
|
||||
const struct ui_camera_info *info;
|
||||
const struct element_event_handler *handler;
|
||||
};
|
||||
|
||||
|
||||
|
||||
#define ui_camera_for_id(id) \
|
||||
(struct ui_camera*)ui_core_get_element_by_id(id)
|
||||
|
||||
|
||||
|
||||
void register_ui_camera_handler(const struct element_event_handler *handler);
|
||||
|
||||
int ui_camera_set_rect(int id, struct rect *r);
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,537 @@
|
||||
#ifndef UI_ELEMENT_CORE_H
|
||||
#define UI_ELEMENT_CORE_H
|
||||
|
||||
#include "typedef.h"
|
||||
#include "rect.h"
|
||||
#include "system/event.h"
|
||||
//#include "fs/fs.h"
|
||||
|
||||
|
||||
#define UI_CTRL_BUTTON 0
|
||||
|
||||
struct element;
|
||||
|
||||
|
||||
#ifdef offsetof
|
||||
#undef offsetof
|
||||
#endif
|
||||
#ifdef container_of
|
||||
#undef container_of
|
||||
#endif
|
||||
|
||||
#define offsetof(type, memb) \
|
||||
((unsigned long)(&((type *)0)->memb))
|
||||
|
||||
#define container_of(ptr, type, memb) \
|
||||
((type *)((char *)ptr - offsetof(type, memb)))
|
||||
|
||||
enum ui_direction {
|
||||
UI_DIR_UP,
|
||||
UI_DIR_DOWN,
|
||||
UI_DIR_LEFT,
|
||||
UI_DIR_RIGHT,
|
||||
};
|
||||
|
||||
enum ui_align {
|
||||
UI_ALIGN_LEFT = 0,
|
||||
UI_ALIGN_CENTER,
|
||||
UI_ALIGN_RIGHT,
|
||||
};
|
||||
|
||||
|
||||
enum {
|
||||
POSITION_ABSOLUTE = 0,
|
||||
POSITION_RELATIVE = 1,
|
||||
};
|
||||
|
||||
enum {
|
||||
ELM_EVENT_TOUCH_DOWN,
|
||||
ELM_EVENT_TOUCH_MOVE,
|
||||
ELM_EVENT_TOUCH_R_MOVE,
|
||||
ELM_EVENT_TOUCH_L_MOVE,
|
||||
ELM_EVENT_TOUCH_D_MOVE,
|
||||
ELM_EVENT_TOUCH_U_MOVE,
|
||||
ELM_EVENT_TOUCH_HOLD,
|
||||
ELM_EVENT_TOUCH_UP,
|
||||
};
|
||||
|
||||
|
||||
enum {
|
||||
ELM_EVENT_KEY_CLICK,
|
||||
ELM_EVENT_KEY_LONG,
|
||||
ELM_EVENT_KEY_HOLD,
|
||||
};
|
||||
|
||||
enum {
|
||||
ELM_STA_INITED,
|
||||
//ELM_STA_SHOW_PROBE,
|
||||
//ELM_STA_SHOW_POST,
|
||||
ELM_STA_HIDE,
|
||||
ELM_STA_SHOW,
|
||||
ELM_STA_PAUSE,
|
||||
};
|
||||
|
||||
enum {
|
||||
ELM_FLAG_NORMAL,
|
||||
ELM_FLAG_HEAD,
|
||||
};
|
||||
|
||||
enum {
|
||||
DC_DATA_FORMAT_OSD8 = 0,
|
||||
DC_DATA_FORMAT_YUV420 = 1,
|
||||
DC_DATA_FORMAT_OSD16 = 2,
|
||||
DC_DATA_FORMAT_OSD8A = 3,
|
||||
DC_DATA_FORMAT_MONO = 4,
|
||||
};
|
||||
|
||||
|
||||
struct element_touch_event {
|
||||
int event;
|
||||
int xoffset;
|
||||
int yoffset;
|
||||
u8 hold_up;
|
||||
u8 onfocus;
|
||||
u8 move_dir;
|
||||
struct position pos;
|
||||
struct position mov;
|
||||
void *private_data;
|
||||
};
|
||||
|
||||
struct element_key_event {
|
||||
u8 event;
|
||||
u8 value;
|
||||
void *private_data;
|
||||
};
|
||||
|
||||
#define ELM_KEY_EVENT(e) (0x0000 | (e->event) | (e->value << 8))
|
||||
#define ELM_TOUCH_EVENT(e) (0x1000 | (e->event))
|
||||
#define ELM_CHANGE_EVENT(e) (0x2000 | (e->event))
|
||||
|
||||
enum element_change_event {
|
||||
ON_CHANGE_INIT_PROBE,
|
||||
ON_CHANGE_INIT,
|
||||
ON_CHANGE_TRY_OPEN_DC,
|
||||
ON_CHANGE_FIRST_SHOW,
|
||||
ON_CHANGE_SHOW_PROBE,
|
||||
ON_CHANGE_SHOW,
|
||||
ON_CHANGE_SHOW_POST,
|
||||
ON_CHANGE_HIDE,
|
||||
ON_CHANGE_HIGHLIGHT,
|
||||
ON_CHANGE_RELEASE_PROBE,
|
||||
ON_CHANGE_RELEASE,
|
||||
ON_CHANGE_ANIMATION_END,
|
||||
ON_CHANGE_SHOW_COMPLETED,
|
||||
};
|
||||
|
||||
|
||||
struct element_event_handler {
|
||||
int id;
|
||||
int (*ontouch)(void *, struct element_touch_event *);
|
||||
int (*onkey)(void *, struct element_key_event *);
|
||||
int (*onchange)(void *, enum element_change_event, void *);
|
||||
};
|
||||
|
||||
struct jaction {
|
||||
u32 show;
|
||||
u32 hide;
|
||||
};
|
||||
|
||||
enum {
|
||||
ELM_ACTION_HIDE = 0,
|
||||
ELM_ACTION_SHOW,
|
||||
ELM_ACTION_TOGGLE,
|
||||
ELM_ACTION_HIGHLIGHT,
|
||||
};
|
||||
|
||||
struct event_action {
|
||||
u16 event;
|
||||
u16 action;
|
||||
int id;
|
||||
u8 argc;
|
||||
char argv[];
|
||||
};
|
||||
|
||||
struct element_event_action {
|
||||
u16 num;
|
||||
struct event_action action[0];
|
||||
};
|
||||
|
||||
|
||||
struct draw_context {
|
||||
u8 ref;
|
||||
u8 alpha;
|
||||
u8 align;
|
||||
u8 data_format;
|
||||
u8 page;
|
||||
u8 buf_num;
|
||||
u32 background_color;
|
||||
void *handl;
|
||||
struct element *elm;
|
||||
struct rect rect;
|
||||
struct rect draw;
|
||||
void *dc;
|
||||
|
||||
struct rect need_draw;
|
||||
struct rect disp;
|
||||
u16 width;
|
||||
u16 height;
|
||||
u8 *fbuf;
|
||||
u32 fbuf_len;
|
||||
u8 *buf;
|
||||
u8 *buf0;
|
||||
u8 *buf1;
|
||||
u32 len;
|
||||
u16 lines;
|
||||
u8 col_align;
|
||||
u8 row_align;
|
||||
|
||||
u8 *mask;
|
||||
};
|
||||
|
||||
struct css_border {
|
||||
u16 left: 4;
|
||||
u16 top: 4;
|
||||
u16 right: 4;
|
||||
u16 bottom: 4;
|
||||
u16 color: 16;
|
||||
};
|
||||
|
||||
struct css_border1 {
|
||||
u8 left;
|
||||
u8 top;
|
||||
u8 right;
|
||||
u8 bottom;
|
||||
int color: 24;
|
||||
};
|
||||
|
||||
struct element_css {
|
||||
u8 align: 2;
|
||||
u8 invisible: 1;
|
||||
u8 z_order: 5;
|
||||
int left/* : 16 */;
|
||||
int top/* : 16 */;
|
||||
int width/* : 16 */;
|
||||
int height/* : 16 */;
|
||||
u32 background_color: 24;
|
||||
u32 alpha: 8;
|
||||
int background_image: 24;
|
||||
int image_quadrant: 8;
|
||||
struct css_border border;
|
||||
};
|
||||
|
||||
struct element_css1 {
|
||||
u8 align;
|
||||
u8 invisible;
|
||||
u8 z_order;
|
||||
int left;
|
||||
int top;
|
||||
int width;
|
||||
int height;
|
||||
u32 background_color: 24;
|
||||
u32 alpha: 8;
|
||||
int background_image: 24;
|
||||
int image_quadrant: 8;
|
||||
struct css_border1 border;
|
||||
};
|
||||
|
||||
struct element_ops {
|
||||
int (*show)(struct element *);
|
||||
int (*redraw)(struct element *, struct rect *);
|
||||
};
|
||||
|
||||
struct element {
|
||||
u8 highlight: 1;
|
||||
u8 state: 2;
|
||||
u8 ref: 6;
|
||||
// u32 alive;
|
||||
int id;
|
||||
struct element *parent;
|
||||
struct list_head sibling;
|
||||
struct list_head child;
|
||||
struct element *focus;
|
||||
struct element_css css;
|
||||
struct draw_context *dc;
|
||||
// const struct element_ops *ops;
|
||||
const struct element_event_handler *handler;
|
||||
// const struct element_event_action *action;
|
||||
};
|
||||
|
||||
struct ui_style {
|
||||
const char *file;
|
||||
u32 version;
|
||||
};
|
||||
|
||||
enum {
|
||||
UI_FTYPE_VIDEO = 0,
|
||||
UI_FTYPE_IMAGE,
|
||||
UI_FTYPE_AUDIO,
|
||||
UI_FTYPE_DIR,
|
||||
UI_FTYPE_UNKNOW = 0xff,
|
||||
};
|
||||
|
||||
struct ui_file_attrs {
|
||||
char *format;
|
||||
char fname[128];
|
||||
// struct vfs_attr attr;
|
||||
u8 ftype;
|
||||
u16 file_num;
|
||||
u32 film_len;
|
||||
};
|
||||
|
||||
struct ui_image_attrs {
|
||||
u16 width;
|
||||
u16 height;
|
||||
};
|
||||
|
||||
struct ui_text_attrs {
|
||||
const char *str;
|
||||
const char *format;
|
||||
int color;
|
||||
u16 strlen;
|
||||
u16 offset;
|
||||
u8 encode: 2;
|
||||
u8 endian: 1;
|
||||
u8 flags: 5;
|
||||
// u16 offset;
|
||||
u8 displen;
|
||||
};
|
||||
|
||||
struct ui_file_browser {
|
||||
int file_number;
|
||||
u8 dev_num;
|
||||
void *private_data;
|
||||
};
|
||||
|
||||
#define ELEMENT_ALIVE 0x53547a7b
|
||||
|
||||
#define element_born(elm) \
|
||||
elm->alive = ELEMENT_ALIVE
|
||||
|
||||
#define element_alive(elm) \
|
||||
(elm->alive == ELEMENT_ALIVE)
|
||||
|
||||
|
||||
#define list_for_each_child_element(p, elm) \
|
||||
list_for_each_entry(p, &(elm)->child, sibling)
|
||||
|
||||
#define list_for_each_child_element_reverse(p, n, elm) \
|
||||
list_for_each_entry_reverse_safe(p, n, &(elm)->child, sibling)
|
||||
|
||||
#define list_for_each_child_element_safe(p, n, elm) \
|
||||
list_for_each_entry_safe(p, n, &(elm)->child, sibling)
|
||||
|
||||
struct ui_platform_api {
|
||||
void *(*malloc)(int);
|
||||
void (*free)(void *);
|
||||
|
||||
int (*load_style)(struct ui_style *);
|
||||
|
||||
void *(*load_window)(int id);
|
||||
void (*unload_window)(void *);
|
||||
|
||||
int (*open_draw_context)(struct draw_context *);
|
||||
int (*get_draw_context)(struct draw_context *);
|
||||
int (*put_draw_context)(struct draw_context *);
|
||||
int (*set_draw_context)(struct draw_context *);
|
||||
int (*close_draw_context)(struct draw_context *);
|
||||
|
||||
int (*fill_rect)(struct draw_context *, u32 color);
|
||||
int (*draw_rect)(struct draw_context *, struct css_border *border);
|
||||
int (*draw_image)(struct draw_context *, u32 src, u8 quadrant, u8 *mask);
|
||||
int (*draw_point)(struct draw_context *, u16 x, u16 y, u32 color);
|
||||
u32(*read_point)(struct draw_context *dc, u16 x, u16 y);
|
||||
int (*invert_rect)(struct draw_context *, u32 color);
|
||||
|
||||
void *(*load_widget_info)(void *_head, u8 page);
|
||||
void *(*load_css)(void *_css);
|
||||
void *(*load_image_list)(void *_list);
|
||||
void *(*load_text_list)(void *__list);
|
||||
|
||||
//int (*highlight)(struct draw_context *);
|
||||
int (*show_text)(struct draw_context *, struct ui_text_attrs *);
|
||||
int (*read_image_info)(struct draw_context *, u32, u8, struct ui_image_attrs *);
|
||||
|
||||
int (*open_device)(struct draw_context *, const char *device);
|
||||
int (*close_device)(int);
|
||||
|
||||
void *(*set_timer)(void *, void (*callback)(void *), u32 msec);
|
||||
int (*del_timer)(void *);
|
||||
|
||||
struct ui_file_browser *(*file_browser_open)(struct rect *r,
|
||||
const char *path, const char *ftype, int show_mode);
|
||||
|
||||
int (*get_file_attrs)(struct ui_file_browser *, struct ui_file_attrs *attrs);
|
||||
|
||||
int (*set_file_attrs)(struct ui_file_browser *, struct ui_file_attrs *attrs);
|
||||
|
||||
int (*clear_file_preview)(struct ui_file_browser *, struct rect *r);
|
||||
|
||||
int (*show_file_preview)(struct ui_file_browser *, struct rect *r, struct ui_file_attrs *attrs);
|
||||
|
||||
int (*flush_file_preview)(struct ui_file_browser *);
|
||||
|
||||
void *(*open_file)(struct ui_file_browser *, struct ui_file_attrs *attrs);
|
||||
int (*delete_file)(struct ui_file_browser *, struct ui_file_attrs *attrs);
|
||||
|
||||
int (*move_file_preview)(struct ui_file_browser *_bro, struct rect *dst, struct rect *src);
|
||||
|
||||
void (*file_browser_close)(struct ui_file_browser *);
|
||||
|
||||
};
|
||||
|
||||
extern /* const */ struct ui_platform_api *platform_api;
|
||||
|
||||
extern const struct element_event_handler dumy_handler;
|
||||
|
||||
struct janimation {
|
||||
u8 persent[5];
|
||||
u8 direction;
|
||||
u8 play_state;
|
||||
u8 iteration_count;
|
||||
u16 delay;
|
||||
u16 duration;
|
||||
struct element_css css[0];
|
||||
};
|
||||
|
||||
|
||||
extern struct element_event_handler *elm_event_handler_begin;
|
||||
extern struct element_event_handler *elm_event_handler_end;
|
||||
|
||||
|
||||
#define ___REGISTER_UI_EVENT_HANDLER(style, _id) \
|
||||
static const struct element_event_handler element_event_handler_##_id \
|
||||
sec(.elm_event_handler_##style) __attribute__((used)) = { \
|
||||
.id = _id,
|
||||
|
||||
#define __REGISTER_UI_EVENT_HANDLER(style, _id) \
|
||||
___REGISTER_UI_EVENT_HANDLER(style, _id)
|
||||
|
||||
#define REGISTER_UI_EVENT_HANDLER(id) \
|
||||
__REGISTER_UI_EVENT_HANDLER(STYLE_NAME, id)
|
||||
|
||||
|
||||
|
||||
struct ui_style_info {
|
||||
const char *name;
|
||||
struct element_event_handler *begin;
|
||||
struct element_event_handler *end;
|
||||
};
|
||||
|
||||
extern struct ui_style_info ui_style_begin[];
|
||||
extern struct ui_style_info ui_style_end[];
|
||||
|
||||
#define __REGISTER_UI_STYLE(style_name) \
|
||||
extern struct element_event_handler elm_event_handler_begin_##style_name[]; \
|
||||
extern struct element_event_handler elm_event_handler_end_##style_name[]; \
|
||||
static const struct ui_style_info ui_style_##style_name sec(.ui_style) __attribute__((used)) = { \
|
||||
.name = #style_name, \
|
||||
.begin = elm_event_handler_begin_##style_name, \
|
||||
.end = elm_event_handler_end_##style_name, \
|
||||
};
|
||||
|
||||
#define REGISTER_UI_STYLE(style_name) \
|
||||
__REGISTER_UI_STYLE(style_name)
|
||||
|
||||
|
||||
static inline struct element_event_handler *element_event_handler_for_id(u32 id)
|
||||
{
|
||||
struct element_event_handler *p;
|
||||
|
||||
for (p = elm_event_handler_begin; p < elm_event_handler_end; p++) {
|
||||
if (p->id == id) {
|
||||
return p;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
#define ui_core_get_element_css(elm) \
|
||||
&((struct element *)(elm))->css
|
||||
|
||||
#define ui_core_element_invisable(elm, i) \
|
||||
((struct element *)(elm))->css.invisible = i
|
||||
|
||||
|
||||
int ui_core_init(const struct ui_platform_api *api, struct rect *rect);
|
||||
|
||||
int ui_core_set_style(const char *style);
|
||||
|
||||
void ui_core_set_rotate(int _rotate);
|
||||
|
||||
int ui_core_get_rotate();
|
||||
|
||||
|
||||
void *ui_core_malloc(int size);
|
||||
|
||||
void ui_core_free(void *buf);
|
||||
|
||||
void ui_core_element_init(struct element *, u32 id,
|
||||
struct element_css1 *,
|
||||
const struct element_event_handler *,
|
||||
const struct element_event_action *);
|
||||
|
||||
void ui_core_get_element_abs_rect(struct element *elm, struct rect *rect);
|
||||
|
||||
void ui_core_append_child(void *_child);
|
||||
|
||||
struct element *ui_core_get_first_child();
|
||||
|
||||
void ui_core_remove_element(void *_child);
|
||||
|
||||
|
||||
int ui_core_open_draw_context(struct draw_context *dc, struct element *elm);
|
||||
|
||||
int ui_core_close_draw_context(struct draw_context *dc);
|
||||
|
||||
int ui_core_show(void *_elm, int init);
|
||||
|
||||
int ui_core_hide(void *_elm);
|
||||
|
||||
struct element *get_element_by_id(struct element *elm, u32 id);
|
||||
|
||||
struct element *ui_core_get_element_by_id(u32 id);
|
||||
int ui_core_get_disp_status_by_id(u32 id);
|
||||
|
||||
struct element *ui_core_get_up_element(struct element *elm);
|
||||
struct element *ui_core_get_down_element(struct element *elm);
|
||||
struct element *ui_core_get_left_element(struct element *elm);
|
||||
struct element *ui_core_get_right_element(struct element *elm);
|
||||
|
||||
int ui_core_element_ontouch(struct element *, struct element_touch_event *e);
|
||||
|
||||
int ui_core_ontouch(struct element_touch_event *e);
|
||||
|
||||
int ui_core_element_onkey(struct element *elm, struct element_key_event *e);
|
||||
|
||||
int ui_core_onkey(struct element_key_event *e);
|
||||
|
||||
void ui_core_element_append_child(struct element *parent, struct element *child);
|
||||
|
||||
struct element_css *ui_core_set_element_css(void *_elm, const struct element_css1 *css);
|
||||
|
||||
int ui_core_invert_rect(struct draw_context *dc);
|
||||
|
||||
void ui_core_release_child_probe(struct element *elm);
|
||||
|
||||
void ui_core_release_child(struct element *elm);
|
||||
|
||||
|
||||
int ui_core_redraw(void *_elm);
|
||||
|
||||
int ui_core_highlight_element(struct element *elm, int yes);
|
||||
|
||||
void ui_core_element_on_focus(struct element *elm, int yes);
|
||||
|
||||
|
||||
void ui_core_ontouch_lock(struct element *elm);
|
||||
|
||||
void ui_core_ontouch_unlock(struct element *elm);
|
||||
|
||||
int ui_core_get_draw_context(struct draw_context *dc, struct element *elm, struct rect *draw);
|
||||
#endif
|
||||
|
||||
|
||||
@@ -0,0 +1,81 @@
|
||||
#ifndef UI_GRID_H
|
||||
#define UI_GRID_H
|
||||
|
||||
|
||||
#include "ui/ui_core.h"
|
||||
#include "ui/control.h"
|
||||
|
||||
enum {
|
||||
GRID_SCROLL_MODE,
|
||||
GRID_PAGE_MODE,
|
||||
};
|
||||
|
||||
struct ui_grid_item_info {
|
||||
u8 row;
|
||||
u8 col;
|
||||
u8 page_mode;
|
||||
u8 highlight_index;
|
||||
u16 interval;
|
||||
struct layout_info *info;
|
||||
};
|
||||
|
||||
struct ui_grid {
|
||||
struct element elm;
|
||||
char hi_num;
|
||||
char hi_index;
|
||||
char touch_index;
|
||||
char onfocus;
|
||||
u8 page_mode;
|
||||
u8 col_num;
|
||||
u8 row_num;
|
||||
u8 show_row;
|
||||
u8 show_col;
|
||||
u8 avail_item_num;
|
||||
u8 pix_scroll;
|
||||
u8 rotate;
|
||||
int x_interval;
|
||||
int y_interval;
|
||||
int max_show_left;
|
||||
int max_show_top;
|
||||
int min_show_left;
|
||||
int min_show_top;
|
||||
int max_left;
|
||||
int max_top;
|
||||
int min_left;
|
||||
int min_top;
|
||||
int scroll_step;
|
||||
u8 ctrl_num;
|
||||
struct layout *item;
|
||||
struct layout_info *item_info;
|
||||
struct element elm2;
|
||||
struct position pos;
|
||||
struct draw_context dc;
|
||||
const struct ui_grid_info *info;
|
||||
const struct element_event_handler *handler;
|
||||
};
|
||||
|
||||
extern const struct element_event_handler grid_elm_handler;
|
||||
|
||||
static inline int ui_grid_cur_item(struct ui_grid *grid)
|
||||
{
|
||||
if (grid->touch_index >= 0) {
|
||||
return grid->touch_index;
|
||||
}
|
||||
return grid->hi_index;
|
||||
}
|
||||
|
||||
#define ui_grid_set_item(grid, index) (grid)->hi_index = index
|
||||
|
||||
|
||||
void ui_grid_enable();
|
||||
void ui_grid_on_focus(struct ui_grid *grid);
|
||||
void ui_grid_lose_focus(struct ui_grid *grid);
|
||||
void ui_grid_state_reset(struct ui_grid *grid, int highlight_item);
|
||||
int ui_grid_highlight_item(struct ui_grid *grid, int item, bool yes);
|
||||
int ui_grid_highlight_item_by_id(int id, int item, bool yes);
|
||||
struct ui_grid *__ui_grid_new(struct element_css1 *css, int id,
|
||||
struct ui_grid_item_info *info, struct element *parent);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
#ifndef UI_NUMBER_H
|
||||
#define UI_NUMBER_H
|
||||
|
||||
|
||||
#include "ui/control.h"
|
||||
#include "ui/ui_core.h"
|
||||
#include "ui/p.h"
|
||||
|
||||
enum {
|
||||
TYPE_NUM,
|
||||
TYPE_STRING,
|
||||
};
|
||||
|
||||
struct unumber {
|
||||
u8 numbs;
|
||||
u8 type;
|
||||
u32 number[2];
|
||||
u8 *num_str;
|
||||
};
|
||||
|
||||
struct ui_number {
|
||||
struct element_text text;
|
||||
u16 number[2];
|
||||
u16 buf[20];
|
||||
|
||||
int color;
|
||||
int hi_color;
|
||||
u8 css_num;
|
||||
u8 nums: 6;
|
||||
u8 type: 2;
|
||||
u16 css[2];
|
||||
u8 *num_str;
|
||||
const struct ui_number_info *info;
|
||||
const struct element_event_handler *handler;
|
||||
};
|
||||
|
||||
void ui_number_enable();
|
||||
void *new_ui_number(const void *_info, struct element *parent);
|
||||
int ui_number_update_by_id(int id, struct unumber *n);
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
#ifndef UI_PIC_H
|
||||
#define UI_PIC_H
|
||||
|
||||
#include "ui/ui_core.h"
|
||||
|
||||
|
||||
|
||||
|
||||
struct ui_pic {
|
||||
struct element elm;
|
||||
char index;
|
||||
u8 css_num;
|
||||
u16 css[2];
|
||||
u16 highlight_img;
|
||||
u16 normal_img;
|
||||
const struct ui_pic_info *info;
|
||||
const struct element_event_handler *handler;
|
||||
};
|
||||
|
||||
void ui_pic_enable();
|
||||
void *new_ui_pic(const void *_info, struct element *parent);
|
||||
int ui_pic_show_image_by_id(int id, int index);
|
||||
int ui_pic_set_image_index(struct ui_pic *pic, int index);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,47 @@
|
||||
#ifndef UI_PROGRESS_H
|
||||
#define UI_PROGRESS_H
|
||||
|
||||
|
||||
#include "ui/control.h"
|
||||
#include "ui/ui_core.h"
|
||||
|
||||
|
||||
#define PROGRESS_CHILD_NUM (CTRL_PROGRESS_CHILD_END - CTRL_PROGRESS_CHILD_BEGIN)
|
||||
|
||||
|
||||
struct progress_highlight_info {
|
||||
struct ui_ctrl_info_head head;
|
||||
u16 center_x;
|
||||
u16 center_y;
|
||||
u16 radius_big;
|
||||
u16 radius_small;
|
||||
u16 angle_begin;
|
||||
u16 angle_end;
|
||||
struct ui_image_list *img;
|
||||
};
|
||||
|
||||
struct ui_progress {
|
||||
struct element elm;
|
||||
struct element child_elm[PROGRESS_CHILD_NUM];
|
||||
u16 center_x;
|
||||
u16 center_y;
|
||||
u16 radius;
|
||||
u16 angle_begin;
|
||||
u16 angle_end;
|
||||
u8 ctrl_num;
|
||||
char percent;
|
||||
u8 *mask;
|
||||
u16 mask_len;
|
||||
void *timer;
|
||||
const struct layout_info *info;
|
||||
const struct progress_highlight_info *pic_info[PROGRESS_CHILD_NUM];
|
||||
const struct element_event_handler *handler;
|
||||
};
|
||||
|
||||
void ui_progress_enable();
|
||||
void ui_progress_enable();
|
||||
int ui_progress_set_persent_by_id(int id, int persent);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
#ifndef UI_PROGRESS_MULTI_H
|
||||
#define UI_PROGRESS_MULTI_H
|
||||
|
||||
|
||||
#include "ui/control.h"
|
||||
#include "ui/ui_core.h"
|
||||
|
||||
|
||||
#define MULTIPROGRESS_CHILD_NUM (CTRL_MULTIPROGRESS_CHILD_END - CTRL_MULTIPROGRESS_CHILD_BEGIN)
|
||||
|
||||
struct multiprogress_highlight_info {
|
||||
struct ui_ctrl_info_head head;
|
||||
u16 number;
|
||||
u16 center_x;
|
||||
u16 center_y;
|
||||
u16 radius0_big;
|
||||
u16 radius0_small;
|
||||
u16 radius1_big;
|
||||
u16 radius1_small;
|
||||
u16 radius2_big;
|
||||
u16 radius2_small;
|
||||
u16 angle_begin;
|
||||
u16 angle_end;
|
||||
struct ui_image_list *img;
|
||||
};
|
||||
|
||||
struct ui_multiprogress {
|
||||
struct element elm;
|
||||
struct element child_elm[MULTIPROGRESS_CHILD_NUM];
|
||||
u16 center_x;
|
||||
u16 center_y;
|
||||
u16 radius;
|
||||
u16 angle_begin;
|
||||
u16 angle_end;
|
||||
u8 ctrl_num;
|
||||
char percent[3];
|
||||
u8 circle_num;
|
||||
u8 index;
|
||||
u8 *mask;
|
||||
u16 mask_len;
|
||||
void *timer;
|
||||
const struct layout_info *info;
|
||||
const struct multiprogress_highlight_info *pic_info[MULTIPROGRESS_CHILD_NUM];
|
||||
const struct element_event_handler *handler;
|
||||
};
|
||||
|
||||
void ui_multiprogress_enable();
|
||||
int ui_multiprogress_set_persent_by_id(int id, int persent);
|
||||
int ui_multiprogress_set_second_persent_by_id(int id, int percent);
|
||||
int ui_multiprogress_set_third_persent_by_id(int id, int percent);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
#ifndef UI_SLIDER_H
|
||||
#define UI_SLIDER_H
|
||||
|
||||
#include "ui/ui_core.h"
|
||||
#include "ui/control.h"
|
||||
|
||||
|
||||
#define SLIDER_CHILD_NUM (SLIDER_CHILD_END - SLIDER_CHILD_BEGIN)
|
||||
|
||||
|
||||
struct slider_text_info {
|
||||
u8 move;
|
||||
int min_value;
|
||||
int max_value;
|
||||
int text_color;
|
||||
};
|
||||
|
||||
|
||||
struct ui_slider {
|
||||
struct element elm;
|
||||
struct element child_elm[SLIDER_CHILD_NUM];
|
||||
u8 step;
|
||||
char persent;
|
||||
s16 left;
|
||||
s16 width;
|
||||
s16 min_value;
|
||||
s16 max_value;
|
||||
u16 text_color;
|
||||
const struct ui_slider_info *info;
|
||||
const struct slider_text_info *text_info;
|
||||
const struct element_event_handler *handler;
|
||||
};
|
||||
|
||||
void ui_slider_enable();
|
||||
int ui_slider_set_persent_by_id(int id, int persent);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
#ifndef UI_TEXT_H
|
||||
#define UI_TEXT_H
|
||||
|
||||
#include "ui/ui_core.h"
|
||||
#include "ui/control.h"
|
||||
#include "font/font_all.h"
|
||||
|
||||
|
||||
struct ui_text {
|
||||
struct element elm;
|
||||
struct ui_text_attrs attrs;
|
||||
void *timer;
|
||||
char _str[4];
|
||||
char _format[7];
|
||||
u8 str_num: 4;
|
||||
u8 css_num: 4;
|
||||
u16 css[2];
|
||||
int attr_color;
|
||||
int attr_highlight_color;
|
||||
// const struct ui_text_info *info;
|
||||
const struct element_event_handler *handler;
|
||||
};
|
||||
|
||||
|
||||
|
||||
void ui_text_enable();
|
||||
void *new_ui_text(const void *_info, struct element *parent);
|
||||
int ui_text_show_index_by_id(int id, int index);
|
||||
int ui_text_set_index(struct ui_text *text, int index);
|
||||
int ui_text_set_str(struct ui_text *text, const char *format, const char *str, int strlen, u32 flags);
|
||||
int ui_text_set_str_by_id(int id, const char *format, const char *str);
|
||||
int ui_text_set_text_by_id(int id, const char *str, int strlen, u32 flags);
|
||||
int ui_text_set_textw_by_id(int id, const char *str, int strlen, int endian, u32 flags);
|
||||
int ui_text_set_textu_by_id(int id, const char *str, int strlen, u32 flags);
|
||||
void ui_text_set_text_attrs(struct ui_text *text, const char *str, int strlen, u8 encode, u8 endian, u32 flags);
|
||||
void text_release(struct ui_text *text);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,41 @@
|
||||
#ifndef UI_TIME_H
|
||||
#define UI_TIME_H
|
||||
|
||||
|
||||
#include "ui/control.h"
|
||||
#include "ui/ui_core.h"
|
||||
#include "ui/p.h"
|
||||
|
||||
struct utime {
|
||||
u16 year;
|
||||
u8 month;
|
||||
u8 day;
|
||||
u8 hour;
|
||||
u8 min;
|
||||
u8 sec;
|
||||
};
|
||||
|
||||
struct ui_time {
|
||||
struct element_text text;
|
||||
u16 year: 12;
|
||||
u16 month: 4;
|
||||
u8 day;
|
||||
u8 hour;
|
||||
u8 min;
|
||||
u8 sec;
|
||||
u8 css_num;
|
||||
u8 auto_cnt;
|
||||
u16 css[2];
|
||||
int color;
|
||||
int hi_color;
|
||||
u16 buf[20];
|
||||
void *timer;
|
||||
const struct ui_time_info *info;
|
||||
const struct element_event_handler *handler;
|
||||
};
|
||||
|
||||
void ui_time_enable();
|
||||
void *new_ui_time(const void *_info, struct element *parent);
|
||||
int ui_time_update_by_id(int id, struct utime *time);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,45 @@
|
||||
#ifndef UI_WATCH_H
|
||||
#define UI_WATCH_H
|
||||
|
||||
|
||||
#include "ui/control.h"
|
||||
#include "ui/ui_core.h"
|
||||
|
||||
|
||||
#define WATCH_CHILD_NUM (CTRL_WATCH_CHILD_END - CTRL_WATCH_CHILD_BEGIN)
|
||||
|
||||
|
||||
struct watch_pic_info {
|
||||
struct ui_ctrl_info_head head;
|
||||
u16 cent_x;
|
||||
u16 cent_y;
|
||||
struct ui_image_list *img;
|
||||
};
|
||||
|
||||
struct watch_css_info {
|
||||
int left: 16;
|
||||
int top: 16;
|
||||
};
|
||||
|
||||
struct ui_watch {
|
||||
struct element elm;
|
||||
struct element child_elm[WATCH_CHILD_NUM];
|
||||
struct watch_css_info child_css[WATCH_CHILD_NUM];
|
||||
u8 hour;
|
||||
u8 min;
|
||||
u8 sec;
|
||||
u8 updata;
|
||||
u8 ctrl_num;
|
||||
void *timer;
|
||||
const struct layout_info *info;
|
||||
const struct watch_pic_info *pic_info[WATCH_CHILD_NUM];
|
||||
const struct element_event_handler *handler;
|
||||
};
|
||||
|
||||
|
||||
void ui_watch_enable();
|
||||
int ui_watch_set_time_by_id(int id, int hour, int min, int sec);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
#ifndef UI_WINDOW_H
|
||||
#define UI_WINDOW_H
|
||||
|
||||
|
||||
#include "ui/layer.h"
|
||||
#include "ui/ui_core.h"
|
||||
#include "ui/control.h"
|
||||
#include "list.h"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
struct window {
|
||||
struct element elm; //must be first
|
||||
u8 busy;
|
||||
u8 hide;
|
||||
u8 ctrl_num;
|
||||
struct list_head entry;
|
||||
struct layer *layer;
|
||||
const struct window_info *info;
|
||||
const struct element_event_handler *handler;
|
||||
void *private_data;
|
||||
};
|
||||
|
||||
|
||||
extern const struct window_info *window_table;
|
||||
|
||||
|
||||
|
||||
#define REGISTER_WINDOW_EVENT_HANDLER(id) \
|
||||
REGISTER_UI_EVENT_HANDLER(id)
|
||||
|
||||
|
||||
int window_show(int);
|
||||
|
||||
int window_hide(int id);
|
||||
|
||||
int window_toggle(int id);
|
||||
|
||||
int window_ontouch(struct element_touch_event *e);
|
||||
|
||||
int window_onkey(struct element_key_event *e);
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
Reference in New Issue
Block a user