refactor folder
|
@ -0,0 +1,900 @@
|
|||
#ifndef GUILITE_CORE_INCLUDE_API_H
|
||||
#define GUILITE_CORE_INCLUDE_API_H
|
||||
|
||||
#define REAL_TIME_TASK_CYCLE_MS 50
|
||||
|
||||
#define GL_ARGB(a, r, g, b) ((((unsigned int)(a)) << 24) | (((unsigned int)(r)) << 16) | (((unsigned int)(g)) << 8) | ((unsigned int)(b)))
|
||||
#define GL_ARGB_A(rgb) ((((unsigned int)(rgb)) >> 24) & 0xFF)
|
||||
|
||||
#define GL_RGB(r, g, b) ((0xFF << 24) | (((unsigned int)(r)) << 16) | (((unsigned int)(g)) << 8) | ((unsigned int)(b)))
|
||||
#define GL_RGB_R(rgb) ((((unsigned int)(rgb)) >> 16) & 0xFF)
|
||||
#define GL_RGB_G(rgb) ((((unsigned int)(rgb)) >> 8) & 0xFF)
|
||||
#define GL_RGB_B(rgb) (((unsigned int)(rgb)) & 0xFF)
|
||||
#define GL_RGB_32_to_16(rgb) (((((unsigned int)(rgb)) & 0xFF) >> 3) | ((((unsigned int)(rgb)) & 0xFC00) >> 5) | ((((unsigned int)(rgb)) & 0xF80000) >> 8))
|
||||
#define GL_RGB_16_to_32(rgb) ((0xFF << 24) | ((((unsigned int)(rgb)) & 0x1F) << 3) | ((((unsigned int)(rgb)) & 0x7E0) << 5) | ((((unsigned int)(rgb)) & 0xF800) << 8))
|
||||
|
||||
#define ALIGN_HCENTER 0x00000000L
|
||||
#define ALIGN_LEFT 0x01000000L
|
||||
#define ALIGN_RIGHT 0x02000000L
|
||||
#define ALIGN_HMASK 0x03000000L
|
||||
|
||||
#define ALIGN_VCENTER 0x00000000L
|
||||
#define ALIGN_TOP 0x00100000L
|
||||
#define ALIGN_BOTTOM 0x00200000L
|
||||
#define ALIGN_VMASK 0x00300000L
|
||||
|
||||
typedef struct
|
||||
{
|
||||
unsigned short year;
|
||||
unsigned short month;
|
||||
unsigned short date;
|
||||
unsigned short day;
|
||||
unsigned short hour;
|
||||
unsigned short minute;
|
||||
unsigned short second;
|
||||
}T_TIME;
|
||||
|
||||
void register_debug_function(void(*my_assert)(const char* file, int line), void(*my_log_out)(const char* log));
|
||||
void _assert(const char* file, int line);
|
||||
#define ASSERT(condition) \
|
||||
do{ \
|
||||
if(!(condition))_assert(__FILE__, __LINE__);\
|
||||
}while(0)
|
||||
void log_out(const char* log);
|
||||
|
||||
long get_time_in_second();
|
||||
T_TIME second_to_day(long second);
|
||||
T_TIME get_time();
|
||||
|
||||
void start_real_timer(void (*func)(void* arg));
|
||||
void register_timer(int milli_second, void func(void* ptmr, void* parg));
|
||||
|
||||
unsigned int get_cur_thread_id();
|
||||
void create_thread(unsigned long* thread_id, void* attr, void *(*start_routine) (void *), void* arg);
|
||||
void thread_sleep(unsigned int milli_seconds);
|
||||
int build_bmp(const char *filename, unsigned int width, unsigned int height, unsigned char *data);
|
||||
|
||||
#define FIFO_BUFFER_LEN 1024
|
||||
class c_fifo
|
||||
{
|
||||
public:
|
||||
c_fifo();
|
||||
int read(void* buf, int len);
|
||||
int write(void* buf, int len);
|
||||
private:
|
||||
unsigned char m_buf[FIFO_BUFFER_LEN];
|
||||
int m_head;
|
||||
int m_tail;
|
||||
void* m_read_sem;
|
||||
void* m_write_mutex;
|
||||
};
|
||||
#endif
|
||||
#ifndef GUILITE_CORE_INCLUDE_CMD_TARGET_H
|
||||
#define GUILITE_CORE_INCLUDE_CMD_TARGET_H
|
||||
class c_cmd_target;
|
||||
#define MSG_TYPE_INVALID 0xFFFF
|
||||
#define MSG_TYPE_WND 0x0001
|
||||
#define MSG_TYPE_USR 0x0002
|
||||
#define USR_MSG_MAX 32
|
||||
typedef void (c_cmd_target::*MsgFuncVV)();
|
||||
enum MSG_CALLBACK_TYPE
|
||||
{
|
||||
MSG_CALLBACK_NULL = 0,
|
||||
MSG_CALLBACK_VV,
|
||||
MSG_CALLBACK_IWL,
|
||||
MSG_CALLBACK_IWV,
|
||||
MSG_CALLBACK_VWV,
|
||||
MSG_CALLBACK_VVL,
|
||||
MSG_CALLBACK_VWL,
|
||||
MSG_CALLBACK_IVV
|
||||
};
|
||||
typedef union
|
||||
{
|
||||
void (c_cmd_target::*func)();
|
||||
void (c_cmd_target::*func_vwv)(unsigned int w_param);
|
||||
int (c_cmd_target::*func_iwl)(unsigned int w_param, long l_param);
|
||||
int (c_cmd_target::*func_iwv)(unsigned int w_param);
|
||||
void (c_cmd_target::*func_vvl)(long l_param);
|
||||
void (c_cmd_target::*func_vwl)(unsigned int w_param, long l_param);
|
||||
int (c_cmd_target::*func_ivv)();
|
||||
}MSGFUNCS;
|
||||
struct GL_MSG_ENTRY
|
||||
{
|
||||
unsigned int msgType;
|
||||
unsigned int msgId;
|
||||
c_cmd_target* pObject;
|
||||
MSG_CALLBACK_TYPE callbackType;
|
||||
MsgFuncVV func;
|
||||
};
|
||||
#define ON_GL_USER_MSG(msgId, func) \
|
||||
{MSG_TYPE_USR, msgId, 0, MSG_CALLBACK_VWL, (MsgFuncVV)(static_cast<void (c_cmd_target::*)(unsigned int, unsigned int)>(&func))},
|
||||
#define GL_DECLARE_MESSAGE_MAP() \
|
||||
protected: \
|
||||
virtual const GL_MSG_ENTRY* GetMSgEntries() const; \
|
||||
private: \
|
||||
static const GL_MSG_ENTRY mMsgEntries[];
|
||||
#define GL_BEGIN_MESSAGE_MAP(theClass) \
|
||||
const GL_MSG_ENTRY* theClass::GetMSgEntries() const \
|
||||
{ \
|
||||
return theClass::mMsgEntries; \
|
||||
} \
|
||||
const GL_MSG_ENTRY theClass::mMsgEntries[] = \
|
||||
{
|
||||
#define GL_END_MESSAGE_MAP() \
|
||||
{MSG_TYPE_INVALID, 0, (c_cmd_target*)0, MSG_CALLBACK_NULL, (MsgFuncVV)0}};
|
||||
class c_cmd_target
|
||||
{
|
||||
public:
|
||||
c_cmd_target();
|
||||
virtual ~c_cmd_target();
|
||||
static int handle_usr_msg(unsigned int msgId, unsigned int wParam, unsigned int lParam);
|
||||
protected:
|
||||
void load_cmd_msg();
|
||||
const GL_MSG_ENTRY* FindMsgEntry(const GL_MSG_ENTRY *pEntry,
|
||||
unsigned int msgType, unsigned short msgId, unsigned short ctrlId);
|
||||
private:
|
||||
static GL_MSG_ENTRY ms_usr_map_entries[USR_MSG_MAX];
|
||||
static unsigned short ms_user_map_size;
|
||||
GL_DECLARE_MESSAGE_MAP()
|
||||
};
|
||||
#endif
|
||||
#ifndef GUILITE_CORE_INCLUDE_RECT_H
|
||||
#define GUILITE_CORE_INCLUDE_RECT_H
|
||||
class c_rect
|
||||
{
|
||||
public:
|
||||
c_rect(){Empty();}
|
||||
c_rect(int left, int top, int right, int bottom){m_left = left;m_top = top;m_right = right;m_bottom = bottom;};
|
||||
void SetRect( int left, int top, int right, int bottom);
|
||||
c_rect(const c_rect&);
|
||||
c_rect& operator=(const c_rect&);
|
||||
void Empty();
|
||||
void Offset(int x, int y);
|
||||
int IsEmpty() const ;
|
||||
int PtInRect(int x, int y) const ;
|
||||
int operator==(const c_rect& ) const;
|
||||
c_rect operator&(const c_rect& aRect) const;
|
||||
int Width() const {return m_right - m_left + 1;}
|
||||
int Height() const {return m_bottom - m_top + 1;}
|
||||
int m_left;
|
||||
int m_top;
|
||||
int m_right;
|
||||
int m_bottom;
|
||||
};
|
||||
#endif
|
||||
#ifndef GUILITE_CORE_INCLUDE_RESOURCE_H
|
||||
#define GUILITE_CORE_INCLUDE_RESOURCE_H
|
||||
//BITMAP
|
||||
typedef struct struct_bitmap_info
|
||||
{
|
||||
unsigned short width;
|
||||
unsigned short height;
|
||||
unsigned short color_bits;//support 16 bits only
|
||||
const unsigned short* pixel_color_array;
|
||||
} BITMAP_INFO;
|
||||
//FONT
|
||||
typedef struct struct_lattice
|
||||
{
|
||||
unsigned int utf8_code;
|
||||
unsigned char width;
|
||||
const unsigned char* pixel_gray_array;
|
||||
} LATTICE;
|
||||
typedef struct struct_font_info
|
||||
{
|
||||
unsigned char height;
|
||||
unsigned int count;
|
||||
LATTICE* lattice_array;
|
||||
} FONT_INFO;
|
||||
#endif
|
||||
#ifndef GUILITE_CORE_INCLUDE_THEME_H
|
||||
#define GUILITE_CORE_INCLUDE_THEME_H
|
||||
typedef struct struct_font_info FONT_INFO;
|
||||
typedef struct struct_color_rect COLOR_RECT;
|
||||
typedef struct struct_bitmap_info BITMAP_INFO;
|
||||
//Rebuild gui library once you change this file
|
||||
enum FONT_TYPE
|
||||
{
|
||||
FONT_NULL,
|
||||
FONT_DEFAULT,
|
||||
FONT_CUSTOM1,
|
||||
FONT_CUSTOM2,
|
||||
FONT_CUSTOM3,
|
||||
FONT_CUSTOM4,
|
||||
FONT_CUSTOM5,
|
||||
FONT_CUSTOM6,
|
||||
FONT_MAX
|
||||
};
|
||||
enum BITMAP_TYPE
|
||||
{
|
||||
BITMAP_CUSTOM1,
|
||||
BITMAP_CUSTOM2,
|
||||
BITMAP_CUSTOM3,
|
||||
BITMAP_CUSTOM4,
|
||||
BITMAP_CUSTOM5,
|
||||
BITMAP_CUSTOM6,
|
||||
BITMAP_MAX
|
||||
};
|
||||
enum COLOR_TYPE
|
||||
{
|
||||
COLOR_WND_FONT,
|
||||
COLOR_WND_NORMAL,
|
||||
COLOR_WND_PUSHED,
|
||||
COLOR_WND_FOCUS,
|
||||
COLOR_WND_BORDER,
|
||||
COLOR_CUSTOME1,
|
||||
COLOR_CUSTOME2,
|
||||
COLOR_CUSTOME3,
|
||||
COLOR_CUSTOME4,
|
||||
COLOR_CUSTOME5,
|
||||
COLOR_CUSTOME6,
|
||||
COLOR_MAX
|
||||
};
|
||||
class c_theme
|
||||
{
|
||||
public:
|
||||
static int add_font(FONT_TYPE index, const FONT_INFO* font);
|
||||
static const FONT_INFO* get_font(FONT_TYPE index);
|
||||
static int add_bitmap(BITMAP_TYPE index, const BITMAP_INFO* bmp);
|
||||
static const BITMAP_INFO* get_bmp(BITMAP_TYPE index);
|
||||
static int add_color(COLOR_TYPE index, const unsigned int color);
|
||||
static const unsigned int get_color(COLOR_TYPE index);
|
||||
};
|
||||
#endif
|
||||
#ifndef GUILITE_CORE_INCLUDE_SURFACE_H
|
||||
#define GUILITE_CORE_INCLUDE_SURFACE_H
|
||||
class c_frame_layer
|
||||
{
|
||||
public:
|
||||
c_frame_layer() { fb = 0;}
|
||||
unsigned short* fb;
|
||||
c_rect visible_rect;
|
||||
};
|
||||
typedef enum
|
||||
{
|
||||
Z_ORDER_LEVEL_0,//view/wave/page
|
||||
Z_ORDER_LEVEL_1,//dialog
|
||||
Z_ORDER_LEVEL_2,//editbox/spinbox/listbox/keyboard
|
||||
Z_ORDER_LEVEL_MAX
|
||||
}Z_ORDER_LEVEL;
|
||||
struct EXTERNAL_GFX_OP
|
||||
{
|
||||
void(*draw_pixel)(int x, int y, unsigned int rgb);
|
||||
void(*fill_rect)(int x0, int y0, int x1, int y1, unsigned int rgb);
|
||||
};
|
||||
class c_display;
|
||||
class c_surface {
|
||||
friend class c_display; friend class c_bitmap;
|
||||
public:
|
||||
int get_width() { return m_width; }
|
||||
int get_height() { return m_height; }
|
||||
unsigned int get_pixel(int x, int y, unsigned int z_order);
|
||||
void draw_pixel(int x, int y, unsigned int rgb, unsigned int z_order);
|
||||
void fill_rect(int x0, int y0, int x1, int y1, unsigned int rgb, unsigned int z_order);
|
||||
void draw_hline(int x0, int x1, int y, unsigned int rgb, unsigned int z_order);
|
||||
void draw_vline(int x, int y0, int y1, unsigned int rgb, unsigned int z_order);
|
||||
void draw_line(int x0, int y0, int x1, int y1, unsigned int rgb, unsigned int z_order);
|
||||
void draw_rect(int x0, int y0, int x1, int y1, unsigned int rgb, unsigned int z_order, unsigned int size = 1);
|
||||
inline void draw_rect(c_rect rect, unsigned int rgb, unsigned int size, unsigned int z_order)
|
||||
{
|
||||
draw_rect(rect.m_left, rect.m_top, rect.m_right, rect.m_bottom, rgb, z_order, size);
|
||||
}
|
||||
inline void fill_rect(c_rect rect, unsigned int rgb, unsigned int z_order)
|
||||
{
|
||||
fill_rect(rect.m_left, rect.m_top, rect.m_right, rect.m_bottom, rgb, z_order);
|
||||
}
|
||||
int flush_screen(int left, int top, int right, int bottom);
|
||||
bool is_valid(c_rect rect);
|
||||
bool is_active() { return m_is_active; }
|
||||
c_display* get_display() { return m_display; }
|
||||
int set_frame_layer_visible_rect(c_rect& rect, unsigned int z_order);
|
||||
void set_active(bool flag){m_is_active = flag;}
|
||||
protected:
|
||||
virtual void fill_rect_on_fb(int x0, int y0, int x1, int y1, unsigned int rgb);
|
||||
virtual void draw_pixel_on_fb(int x, int y, unsigned int rgb);
|
||||
void set_surface(Z_ORDER_LEVEL max_z_order);
|
||||
c_surface(c_display* display, unsigned int width, unsigned int height, unsigned int color_bytes);
|
||||
int m_width; //in pixels
|
||||
int m_height; //in pixels
|
||||
int m_color_bytes; //16 bits, 32 bits only
|
||||
void* m_fb; //Top frame buffer you could see
|
||||
c_frame_layer m_frame_layers[Z_ORDER_LEVEL_MAX];//Top layber fb always be 0
|
||||
bool m_is_active;
|
||||
Z_ORDER_LEVEL m_max_zorder;
|
||||
Z_ORDER_LEVEL m_top_zorder;
|
||||
void* m_phy_fb;
|
||||
int* m_phy_write_index;
|
||||
c_display* m_display;
|
||||
};
|
||||
class c_surface_no_fb : public c_surface {//No physical framebuffer, memory fb is 32 bits
|
||||
friend class c_display;
|
||||
c_surface_no_fb(c_display* display, unsigned int width, unsigned int height, unsigned int color_bytes, struct EXTERNAL_GFX_OP* gfx_op) :
|
||||
c_surface(display, width, height, color_bytes) {m_gfx_op = gfx_op;}
|
||||
protected:
|
||||
virtual void fill_rect_on_fb(int x0, int y0, int x1, int y1, unsigned int rgb);
|
||||
virtual void draw_pixel_on_fb(int x, int y, unsigned int rgb);
|
||||
struct EXTERNAL_GFX_OP* m_gfx_op;//Rendering by external method
|
||||
};
|
||||
#endif
|
||||
#ifndef GUILITE_CORE_INCLUDE_DISPLAY_H
|
||||
#define GUILITE_CORE_INCLUDE_DISPLAY_H
|
||||
#define SURFACE_CNT_MAX 6//root + pages
|
||||
class c_hid_pipe;
|
||||
class c_surface;
|
||||
class c_display {
|
||||
friend class c_surface;
|
||||
public:
|
||||
c_display(void* phy_fb, unsigned int display_width, unsigned int display_height,
|
||||
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);
|
||||
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);
|
||||
int snap_shot(const char* file_name);
|
||||
private:
|
||||
unsigned int m_width; //in pixels
|
||||
unsigned int m_height; //in pixels
|
||||
unsigned int m_color_bytes; //16 bits, 32 bits only
|
||||
void* m_phy_fb;
|
||||
int m_phy_read_index;
|
||||
int m_phy_write_index;
|
||||
c_surface* m_surface_group[SURFACE_CNT_MAX];
|
||||
unsigned int m_surface_cnt;
|
||||
unsigned int m_surface_index;
|
||||
};
|
||||
#endif
|
||||
#ifndef GUILITE_CORE_INCLUDE_WORD_H
|
||||
#define GUILITE_CORE_INCLUDE_WORD_H
|
||||
class c_surface;
|
||||
class c_word
|
||||
{
|
||||
public:
|
||||
static void draw_string(c_surface* surface, int z_order, const char *s, int x, int y, const FONT_INFO* font, unsigned int font_color, unsigned int bg_color, unsigned int align_type = ALIGN_LEFT);
|
||||
static void draw_string_in_rect(c_surface* surface, int z_order, const char *s, c_rect rect, const FONT_INFO* font, unsigned int font_color, unsigned int bg_color, unsigned int align_type = ALIGN_LEFT);
|
||||
static void draw_value(c_surface* surface, int z_order, int value, int dot_position, int x, int y, const FONT_INFO* font, unsigned int font_color, unsigned int bg_color, unsigned int align_type = ALIGN_LEFT);
|
||||
static void draw_value_in_rect(c_surface* surface, int z_order, int value, int dot_position, c_rect rect, const FONT_INFO* font, unsigned int font_color, unsigned int bg_color, unsigned int align_type = ALIGN_LEFT);
|
||||
static void value_2_string(int value, int dot_position, char* buf, int len);
|
||||
static int get_str_size(const char *s, const FONT_INFO* font, int& width, int& height);
|
||||
private:
|
||||
static int draw_single_char(c_surface* surface, int z_order, unsigned int utf8_code, int x, int y, const FONT_INFO* font, unsigned int font_color, unsigned int bg_color);
|
||||
static void draw_lattice(c_surface* surface, int z_order, int x, int y, int width, int height, const unsigned char* p_data, unsigned int font_color, unsigned int bg_color);
|
||||
|
||||
static const LATTICE* get_lattice(const FONT_INFO* font, unsigned int utf8_code);
|
||||
static void get_string_pos(const char *s, const FONT_INFO* font, c_rect rect, unsigned int align_type, int &x, int &y);
|
||||
};
|
||||
#endif
|
||||
#ifndef GUILITE_CORE_INCLUDE_BITMAP_H
|
||||
#define GUILITE_CORE_INCLUDE_BITMAP_H
|
||||
#define DEFAULT_MASK_COLOR 0xFF080408
|
||||
class c_surface;
|
||||
class c_bitmap
|
||||
{
|
||||
public:
|
||||
static void draw_bitmap(c_surface* surface, int z_order, const BITMAP_INFO *pBitmap, int x, int y, unsigned int mask_rgb = DEFAULT_MASK_COLOR);
|
||||
static void draw_bitmap(c_surface* surface, int z_order, const BITMAP_INFO* pBitmap, int x, int y, int src_x, int src_y, int width, int height, unsigned int mask_rgb = DEFAULT_MASK_COLOR);
|
||||
};
|
||||
#endif
|
||||
#ifndef GUILITE_CORE_INCLUDE_WND_H
|
||||
#define GUILITE_CORE_INCLUDE_WND_H
|
||||
typedef struct struct_font_info FONT_INFO;
|
||||
typedef struct struct_color_rect COLOR_RECT;
|
||||
class c_wnd;
|
||||
class c_surface;
|
||||
typedef enum
|
||||
{
|
||||
ATTR_VISIBLE = 0x80000000L,
|
||||
ATTR_DISABLED = 0x40000000L,
|
||||
ATTR_FOCUS = 0x20000000L,
|
||||
ATTR_MODAL = 0x10000000L// Handle touch action at high priority
|
||||
}WND_ATTRIBUTION;
|
||||
typedef enum
|
||||
{
|
||||
STATUS_NORMAL,
|
||||
STATUS_PUSHED,
|
||||
STATUS_FOCUSED,
|
||||
STATUS_DISABLED
|
||||
}WND_STATUS;
|
||||
typedef enum
|
||||
{
|
||||
KEY_FORWARD,
|
||||
KEY_BACKWARD,
|
||||
KEY_ENTER
|
||||
}KEY_TYPE;
|
||||
typedef enum
|
||||
{
|
||||
TOUCH_DOWN,
|
||||
TOUCH_UP
|
||||
}TOUCH_ACTION;
|
||||
typedef struct struct_wnd_tree
|
||||
{
|
||||
c_wnd* p_wnd;
|
||||
unsigned int resource_id;
|
||||
const char* str;
|
||||
short x;
|
||||
short y;
|
||||
short width;
|
||||
short height;
|
||||
struct struct_wnd_tree* p_child_tree;
|
||||
}WND_TREE;
|
||||
class c_wnd : public c_cmd_target
|
||||
{
|
||||
friend class c_dialog;
|
||||
public:
|
||||
c_wnd();
|
||||
virtual ~c_wnd() {};
|
||||
virtual int connect(c_wnd *parent, unsigned short resource_id, const char* str,
|
||||
short x, short y, short width, short height, WND_TREE* p_child_tree = 0);
|
||||
virtual c_wnd* connect_clone(c_wnd *parent, unsigned short resource_id, const char* str,
|
||||
short x, short y, short width, short height, WND_TREE* p_child_tree = 0);
|
||||
void disconnect();
|
||||
virtual c_wnd* clone() = 0;
|
||||
virtual void on_init_children() {}
|
||||
virtual void on_paint() {}
|
||||
virtual void show_window();
|
||||
unsigned short get_id() const { return m_resource_id; }
|
||||
int get_z_order() { return m_z_order; }
|
||||
c_wnd* get_wnd_ptr(unsigned short id) const;
|
||||
unsigned int get_attr() const { return m_attr; }
|
||||
void set_attr(WND_ATTRIBUTION attr);
|
||||
void set_str(const char* str) { m_str = str; }
|
||||
int is_focus_wnd() const;
|
||||
void set_font_color(unsigned int color) { m_font_color = color; }
|
||||
unsigned int get_font_color() { return m_font_color; }
|
||||
void set_bg_color(unsigned int color) { m_bg_color = color; }
|
||||
unsigned int get_bg_color() { return m_bg_color; }
|
||||
void set_font_type(const FONT_INFO *font_type) { m_font_type = font_type; }
|
||||
const FONT_INFO* get_font_type() { return m_font_type; }
|
||||
void set_wnd_pos(short x, short y, short width, short height);
|
||||
void get_wnd_rect(c_rect &rect) const;
|
||||
void get_screen_rect(c_rect &rect) const;
|
||||
c_wnd* set_child_focus(c_wnd *focus_child);
|
||||
c_wnd* get_parent() const { return m_parent; }
|
||||
c_wnd* get_last_child() const;
|
||||
int unlink_child(c_wnd *child);
|
||||
c_wnd* get_prev_sibling() const { return m_prev_sibling; }
|
||||
c_wnd* get_next_sibling() const { return m_next_sibling; }
|
||||
void notify_parent(unsigned int msg_id, int param);
|
||||
virtual bool on_touch(int x, int y, TOUCH_ACTION action);// return true: handled; false: not be handled.
|
||||
virtual bool on_key(KEY_TYPE key);// return false: skip handling by parent;
|
||||
c_surface* get_surface() { return m_surface; }
|
||||
void set_surface(c_surface* surface) { m_surface = surface; }
|
||||
protected:
|
||||
virtual void pre_create_wnd() {};
|
||||
void add_child_2_tail(c_wnd *child);
|
||||
void wnd2screen(int &x, int &y) const;
|
||||
void wnd2screen(c_rect &rect) const;
|
||||
int load_child_wnd(WND_TREE *p_child_tree);
|
||||
int load_clone_child_wnd(WND_TREE *p_child_tree);
|
||||
void set_active_child(c_wnd* child) { m_focus_child = child; }
|
||||
virtual void on_focus() {};
|
||||
virtual void on_kill_focus() {};
|
||||
protected:
|
||||
WND_STATUS m_status;
|
||||
WND_ATTRIBUTION m_attr;
|
||||
c_rect m_wnd_rect;// position relative to parent wnd.
|
||||
c_wnd* m_parent;
|
||||
c_wnd* m_top_child;
|
||||
c_wnd* m_prev_sibling;
|
||||
c_wnd* m_next_sibling;
|
||||
const char* m_str;
|
||||
const FONT_INFO* m_font_type;
|
||||
unsigned int m_font_color;
|
||||
unsigned int m_bg_color;
|
||||
unsigned short m_resource_id;
|
||||
int m_z_order;
|
||||
c_wnd* m_focus_child;//current focused wnd
|
||||
c_surface* m_surface;
|
||||
private:
|
||||
c_wnd(const c_wnd &win);
|
||||
c_wnd& operator=(const c_wnd &win);
|
||||
};
|
||||
#endif
|
||||
#ifndef GUILITE_CORE_INCLUDE_AUDIO_H
|
||||
#define GUILITE_CORE_INCLUDE_AUDIO_H
|
||||
enum AUDIO_TYPE
|
||||
{
|
||||
AUDIO_HEART_BEAT,
|
||||
AUDIO_ALARM,
|
||||
AUDIO_MAX
|
||||
};
|
||||
class c_audio
|
||||
{
|
||||
public:
|
||||
static int play(AUDIO_TYPE type);
|
||||
private:
|
||||
static void init();
|
||||
};
|
||||
#endif
|
||||
#ifndef GUILITE_WIDGETS_INCLUDE_BUTTON_H
|
||||
#define GUILITE_WIDGETS_INCLUDE_BUTTON_H
|
||||
#define GL_BN_CLICKED 0x1111
|
||||
#define ON_GL_BN_CLICKED(ctrlId, func) \
|
||||
{MSG_TYPE_WND, GL_BN_CLICKED, (c_cmd_target*)ctrlId, MSG_CALLBACK_VWV, (MsgFuncVV)(static_cast<void (c_cmd_target::*)(unsigned int)>(&func))},
|
||||
typedef struct struct_bitmap_info BITMAP_INFO;
|
||||
class c_button : public c_wnd
|
||||
{
|
||||
public:
|
||||
virtual c_wnd* clone(){return new c_button();}
|
||||
protected:
|
||||
virtual void on_paint();
|
||||
virtual void on_focus();
|
||||
virtual void on_kill_focus();
|
||||
virtual void pre_create_wnd();
|
||||
virtual bool on_touch(int x, int y, TOUCH_ACTION action);
|
||||
virtual bool on_key(KEY_TYPE key);
|
||||
};
|
||||
#endif
|
||||
#ifndef GUILITE_WIDGETS_INCLUDE_DIALOG_H
|
||||
#define GUILITE_WIDGETS_INCLUDE_DIALOG_H
|
||||
class c_surface;
|
||||
class c_dialog;
|
||||
typedef struct
|
||||
{
|
||||
c_dialog* dialog;
|
||||
c_surface* surface;
|
||||
} DIALOG_ARRAY;
|
||||
class c_dialog : public c_wnd
|
||||
{
|
||||
public:
|
||||
static int open_dialog(c_dialog* p_dlg, bool modal_mode = true);
|
||||
static int close_dialog(c_surface* surface);
|
||||
static c_dialog* get_the_dialog(c_surface* surface);
|
||||
protected:
|
||||
virtual const char* get_class_name(void) const {return "c_dialog";}
|
||||
virtual void pre_create_wnd();
|
||||
virtual void on_paint();
|
||||
static DIALOG_ARRAY ms_the_dialogs[SURFACE_CNT_MAX];
|
||||
private:
|
||||
int set_me_the_dialog();
|
||||
};
|
||||
#endif
|
||||
#ifndef GUILITE_WIDGETS_INCLUDE_KEYBOARD_H
|
||||
#define GUILITE_WIDGETS_INCLUDE_KEYBOARD_H
|
||||
#define KEYBORAD_CLICK 0x5014
|
||||
#define ON_KEYBORAD_UPDATE(ctrlId, func) \
|
||||
{MSG_TYPE_WND, KEYBORAD_CLICK, (c_cmd_target*)ctrlId, MSG_CALLBACK_VWL, (MsgFuncVV)(static_cast<void (c_cmd_target::*)(unsigned int, long)>(&func))},
|
||||
typedef enum
|
||||
{
|
||||
STATUS_UPPERCASE,
|
||||
STATUS_LOWERCASE
|
||||
}KEYBOARD_STATUS;
|
||||
typedef enum
|
||||
{
|
||||
STYLE_ALL_BOARD,
|
||||
STYLE_NUM_BOARD
|
||||
}KEYBOARD_STYLE;
|
||||
typedef enum
|
||||
{
|
||||
CLICK_CHAR,
|
||||
CLICK_ENTER,
|
||||
CLICK_ESC
|
||||
}CLICK_STATUS;
|
||||
class c_keyboard: public c_wnd
|
||||
{
|
||||
public:
|
||||
virtual int connect(c_wnd *user, unsigned short resource_id, KEYBOARD_STYLE style);
|
||||
KEYBOARD_STATUS get_cap_status(){return m_cap_status;}
|
||||
char* get_str() { return m_str; }
|
||||
protected:
|
||||
virtual void pre_create_wnd();
|
||||
virtual c_wnd* clone(){return new c_keyboard();}
|
||||
virtual void on_paint();
|
||||
void on_char_clicked(unsigned int ctrl_id);
|
||||
void on_del_clicked(unsigned int ctrl_id);
|
||||
void on_caps_clicked(unsigned int ctrl_id);
|
||||
void on_enter_clicked(unsigned int ctrl_id);
|
||||
void on_esc_clicked(unsigned int ctrl_id);
|
||||
GL_DECLARE_MESSAGE_MAP()
|
||||
private:
|
||||
char m_str[32];
|
||||
int m_str_len;
|
||||
KEYBOARD_STATUS m_cap_status;
|
||||
};
|
||||
class c_keyboard_button : public c_button
|
||||
{
|
||||
protected:
|
||||
virtual c_wnd* clone(){return new c_keyboard_button();}
|
||||
virtual void on_paint();
|
||||
};
|
||||
#endif /* KEYBOARD_H_ */
|
||||
#ifndef GUILITE_WIDGETS_INCLUDE_EDIT_H
|
||||
#define GUILITE_WIDGETS_INCLUDE_EDIT_H
|
||||
#define MAX_EDIT_STRLEN 32
|
||||
class c_edit : public c_wnd
|
||||
{
|
||||
friend class c_keyboard;
|
||||
public:
|
||||
virtual c_wnd* clone(){return new c_edit();}
|
||||
const char* get_text(){return m_str;}
|
||||
void set_text(const char* str);
|
||||
void set_keyboard_style(KEYBOARD_STYLE kb_sytle) { m_kb_style = kb_sytle; }
|
||||
|
||||
protected:
|
||||
virtual void pre_create_wnd();
|
||||
virtual void on_paint();
|
||||
virtual void on_focus();
|
||||
virtual void on_kill_focus();
|
||||
virtual bool on_touch(int x, int y, TOUCH_ACTION action);
|
||||
|
||||
void on_key_board_click(unsigned int ctrl_id, long param);
|
||||
GL_DECLARE_MESSAGE_MAP()
|
||||
private:
|
||||
void show_keyboard();
|
||||
void on_touch_down(int x, int y);
|
||||
void on_touch_up(int x, int y);
|
||||
KEYBOARD_STYLE m_kb_style;
|
||||
char m_str_input[MAX_EDIT_STRLEN];
|
||||
char m_str[MAX_EDIT_STRLEN];
|
||||
};
|
||||
#endif
|
||||
#ifndef GUILITE_WIDGETS_INCLUDE_GESTURE_H
|
||||
#define GUILITE_WIDGETS_INCLUDE_GESTURE_H
|
||||
typedef enum{
|
||||
TOUCH_MOVE,
|
||||
TOUCH_IDLE
|
||||
}TOUCH_STATE;
|
||||
class c_slide_group;
|
||||
class c_gesture{
|
||||
public:
|
||||
c_gesture(c_slide_group* group);
|
||||
bool handle_swipe(int x, int y, TOUCH_ACTION action);
|
||||
private:
|
||||
bool on_move(int x);
|
||||
bool on_swipe(int x);
|
||||
int swipe_left();
|
||||
int swipe_right();
|
||||
void move_left();
|
||||
void move_right();
|
||||
int m_down_x;
|
||||
int m_down_y;
|
||||
int m_move_x;
|
||||
int m_move_y;
|
||||
TOUCH_STATE m_state;
|
||||
c_slide_group* m_slide_group;
|
||||
};
|
||||
#endif
|
||||
#ifndef GUILITE_WIDGETS_INCLUDE_LABEL_H
|
||||
#define GUILITE_WIDGETS_INCLUDE_LABEL_H
|
||||
class c_label : public c_wnd
|
||||
{
|
||||
public:
|
||||
virtual c_wnd* clone(){return new c_label();}
|
||||
virtual void on_paint();
|
||||
protected:
|
||||
virtual void pre_create_wnd();
|
||||
private:
|
||||
};
|
||||
#endif
|
||||
#ifndef GUILITE_WIDGETS_INCLUDE_LIST_BOX_H
|
||||
#define GUILITE_WIDGETS_INCLUDE_LIST_BOX_H
|
||||
#define MAX_ITEM_NUM 4
|
||||
#define GL_LIST_CONFIRM 0x1
|
||||
#define ON_LIST_CONFIRM(ctrlId, func) \
|
||||
{MSG_TYPE_WND, GL_LIST_CONFIRM, (c_cmd_target*)ctrlId, MSG_CALLBACK_VWL, (MsgFuncVV)(static_cast<void (c_cmd_target::*)(unsigned int, int)>(&func))},
|
||||
class c_list_box : public c_wnd
|
||||
{
|
||||
public:
|
||||
int add_item(char* str);
|
||||
void clear_item();
|
||||
short get_item_count() { return m_item_total; }
|
||||
void select_item(short index);
|
||||
|
||||
protected:
|
||||
virtual c_wnd* clone(){return new c_list_box();}
|
||||
virtual void pre_create_wnd();
|
||||
virtual void on_paint();
|
||||
virtual void on_focus();
|
||||
virtual void on_kill_focus();
|
||||
virtual bool on_touch(int x, int y, TOUCH_ACTION action);
|
||||
|
||||
private:
|
||||
void update_list_size();
|
||||
void show_list();
|
||||
void on_touch_down(int x, int y);
|
||||
void on_touch_up(int x, int y);
|
||||
short m_selected_item;
|
||||
short m_item_total;
|
||||
char* m_item_array[MAX_ITEM_NUM];
|
||||
c_rect m_list_wnd_rect; //rect relative to parent wnd.
|
||||
c_rect m_list_screen_rect; //rect relative to physical screen(frame buffer)
|
||||
};
|
||||
#endif
|
||||
#ifndef GUILITE_WIDGETS_INCLUDE_SLIDE_GROUP_H
|
||||
#define GUILITE_WIDGETS_INCLUDE_SLIDE_GROUP_H
|
||||
#define MAX_PAGES 5
|
||||
class c_gesture;
|
||||
class c_slide_group : public c_wnd {
|
||||
public:
|
||||
c_slide_group();
|
||||
int set_active_slide(int index, bool is_redraw = true);
|
||||
c_wnd* get_slide(int index){return m_slides[index];}
|
||||
c_wnd* get_active_slide(){return m_slides[m_active_slide_index];}
|
||||
int get_active_slide_index(){return m_active_slide_index;}
|
||||
int add_slide(c_wnd* slide, unsigned short resource_id, short x, short y,
|
||||
short width, short height, WND_TREE* p_child_tree = 0,
|
||||
Z_ORDER_LEVEL max_zorder = Z_ORDER_LEVEL_0);
|
||||
int add_clone_silde(c_wnd* slide, unsigned short resource_id, short x, short y,
|
||||
short width, short height, WND_TREE* p_child_tree = 0,
|
||||
Z_ORDER_LEVEL max_zorder = Z_ORDER_LEVEL_0);
|
||||
void disabel_all_slide();
|
||||
virtual bool on_touch(int x, int y, TOUCH_ACTION action);
|
||||
virtual bool on_key(KEY_TYPE key);
|
||||
protected:
|
||||
virtual c_wnd* clone(){return new c_slide_group();}
|
||||
c_wnd* m_slides[MAX_PAGES];
|
||||
int m_active_slide_index;
|
||||
c_gesture* m_gesture;
|
||||
};
|
||||
#endif
|
||||
#ifndef GUILITE_WIDGETS_INCLUDE_SPINBOX_H
|
||||
#define GUILITE_WIDGETS_INCLUDE_SPINBOX_H
|
||||
#define GL_SPIN_CONFIRM 0x2222
|
||||
#define GL_SPIN_CHANGE 0x3333
|
||||
#define ON_SPIN_CONFIRM(ctrlId, func) \
|
||||
{MSG_TYPE_WND, GL_SPIN_CONFIRM, (c_cmd_target*)ctrlId, MSG_CALLBACK_VWL, (MsgFuncVV)(static_cast<void (c_cmd_target::*)(unsigned int, int)>(&func))},
|
||||
#define ON_SPIN_CHANGE(ctrlId, func) \
|
||||
{MSG_TYPE_WND, GL_SPIN_CHANGE, (c_cmd_target*)ctrlId, MSG_CALLBACK_VWL, (MsgFuncVV)(static_cast<void (c_cmd_target::*)(unsigned int, int)>(&func))},
|
||||
class c_spin_box : public c_wnd
|
||||
{
|
||||
public:
|
||||
short get_value(){return m_value;}
|
||||
void set_value(unsigned short value){m_value = m_cur_value = value;}
|
||||
void set_max_min(short max, short min){m_max = max; m_min = min;}
|
||||
void set_step(short step){m_step = step;}
|
||||
short get_min(){return m_min;}
|
||||
short get_max(){return m_max;}
|
||||
short get_step(){return m_step;}
|
||||
void set_value_digit(short digit){m_digit = digit;}
|
||||
short get_value_digit(){return m_digit;}
|
||||
|
||||
protected:
|
||||
virtual c_wnd* clone(){return new c_spin_box();}
|
||||
virtual void on_paint();
|
||||
virtual void on_focus();
|
||||
virtual void on_kill_focus();
|
||||
virtual void pre_create_wnd();
|
||||
virtual bool on_touch(int x, int y, TOUCH_ACTION action);
|
||||
void on_arrow_up_bt_click(unsigned int ctr_id);
|
||||
void on_arrow_down_bt_click(unsigned int ctr_id);
|
||||
GL_DECLARE_MESSAGE_MAP()
|
||||
private:
|
||||
void show_arrow_button();
|
||||
void hide_arrow_button();
|
||||
void on_touch_down(int x, int y);
|
||||
void on_touch_up(int x, int y);
|
||||
protected:
|
||||
short m_cur_value;
|
||||
short m_value;
|
||||
short m_step;
|
||||
short m_max;
|
||||
short m_min;
|
||||
short m_digit;
|
||||
c_button m_bt_up;
|
||||
c_button m_bt_down;
|
||||
c_rect m_bt_up_rect;
|
||||
c_rect m_bt_down_rect;
|
||||
};
|
||||
#endif
|
||||
#ifndef GUILITE_WIDGETS_INCLUDE_TABLE_H
|
||||
#define GUILITE_WIDGETS_INCLUDE_TABLE_H
|
||||
#define MAX_COL_NUM 30
|
||||
#define MAX_ROW_NUM 30
|
||||
class c_table: public c_wnd
|
||||
{
|
||||
public:
|
||||
virtual c_wnd* clone(){return new c_table();}
|
||||
void set_sheet_align(unsigned int align_type){ m_align_type = align_type;}
|
||||
void set_row_num(unsigned int row_num){ m_row_num = row_num;}
|
||||
void set_col_num(unsigned int col_num){ m_col_num = col_num;}
|
||||
void set_row_height(unsigned int height);
|
||||
void set_col_width(unsigned int width);
|
||||
int set_row_height(unsigned int index, unsigned int height);
|
||||
int set_col_width(unsigned int index, unsigned int width);
|
||||
void set_item(int row, int col, char* str, unsigned int color);
|
||||
unsigned int get_row_num(){ return m_row_num;}
|
||||
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);
|
||||
unsigned int m_align_type;
|
||||
unsigned int m_row_num;
|
||||
unsigned int m_col_num;
|
||||
unsigned int m_row_height[MAX_ROW_NUM];
|
||||
unsigned int m_col_width[MAX_COL_NUM];
|
||||
};
|
||||
#endif
|
||||
#ifndef GUILITE_WIDGETS_INCLUDE_WAVE_BUFFER_H
|
||||
#define GUILITE_WIDGETS_INCLUDE_WAVE_BUFFER_H
|
||||
#define WAVE_BUFFER_LEN 1024
|
||||
#define WAVE_READ_CACHE_LEN 8
|
||||
#define BUFFER_EMPTY -1111
|
||||
#define BUFFER_FULL -2222;
|
||||
class c_wave_buffer
|
||||
{
|
||||
public:
|
||||
c_wave_buffer();
|
||||
int write_wave_data(short data);
|
||||
int read_wave_data_by_frame(short &max, short &min, short frame_len, unsigned int sequence, short offset);
|
||||
void reset();
|
||||
void clear_data();
|
||||
short get_cnt();
|
||||
private:
|
||||
int read_data();
|
||||
short m_wave_buf[WAVE_BUFFER_LEN];
|
||||
short m_head;
|
||||
short m_tail;
|
||||
int m_min_old;
|
||||
int m_max_old;
|
||||
int m_min_older;
|
||||
int m_max_older;
|
||||
int m_last_data;
|
||||
short m_read_cache_min[WAVE_READ_CACHE_LEN];
|
||||
short m_read_cache_mid[WAVE_READ_CACHE_LEN];
|
||||
short m_read_cache_max[WAVE_READ_CACHE_LEN];
|
||||
short m_read_cache_sum;
|
||||
unsigned int m_refresh_sequence;
|
||||
};
|
||||
#endif
|
||||
#ifndef GUILITE_WIDGETS_INCLUDE_WAVE_CTRL_H
|
||||
#define GUILITE_WIDGETS_INCLUDE_WAVE_CTRL_H
|
||||
typedef enum
|
||||
{
|
||||
FILL_MODE,
|
||||
SCAN_MODE
|
||||
}E_WAVE_DRAW_MODE;
|
||||
class c_wave_buffer;
|
||||
class c_wave_ctrl : public c_wnd
|
||||
{
|
||||
public:
|
||||
c_wave_ctrl();
|
||||
virtual c_wnd* clone(){return new c_wave_ctrl();}
|
||||
virtual void on_init_children();
|
||||
virtual void on_paint();
|
||||
void set_wave_name(char* wave_name){ m_wave_name = wave_name;}
|
||||
void set_wave_unit(char* wave_unit){ m_wave_unit = wave_unit;}
|
||||
void set_wave_name_font(const FONT_INFO* wave_name_font_type){ m_wave_name_font = wave_name_font_type;}
|
||||
void set_wave_unit_font(const FONT_INFO* wave_unit_font_type){ m_wave_unit_font = wave_unit_font_type;}
|
||||
void set_wave_name_color(unsigned int wave_name_color){ m_wave_name_color = wave_name_color;}
|
||||
void set_wave_unit_color(unsigned int wave_unit_color){ m_wave_unit_color = wave_unit_color;}
|
||||
void set_wave_color(unsigned int color){ m_wave_color = color;}
|
||||
void set_wave_in_out_rate(unsigned int data_rate, unsigned int refresh_rate);
|
||||
void set_wave_speed(unsigned int speed);
|
||||
void set_max_min(short max_data, short min_data);
|
||||
void set_wave(c_wave_buffer* wave){m_wave = wave;}
|
||||
c_wave_buffer* get_wave(){return m_wave;}
|
||||
void clear_data();
|
||||
bool is_data_enough();
|
||||
void refresh_wave(unsigned char frame);
|
||||
void clear_wave();
|
||||
|
||||
protected:
|
||||
void draw_smooth_vline(int y_min, int y_max, int mid, unsigned int rgb);
|
||||
void restore_background();
|
||||
void save_background();
|
||||
char* m_wave_name;
|
||||
char* m_wave_unit;
|
||||
const FONT_INFO* m_wave_name_font;
|
||||
const FONT_INFO* m_wave_unit_font;
|
||||
unsigned int m_wave_name_color;
|
||||
unsigned int m_wave_unit_color;
|
||||
unsigned int m_wave_color;
|
||||
unsigned int m_back_color;
|
||||
int m_wave_left;
|
||||
int m_wave_right;
|
||||
int m_wave_top;
|
||||
int m_wave_bottom;
|
||||
short m_max_data;
|
||||
short m_min_data;
|
||||
|
||||
private:
|
||||
c_wave_buffer* m_wave;
|
||||
unsigned int* m_bg_fb; //background frame buffer, could be used to draw scale line.
|
||||
int m_wave_cursor;
|
||||
int m_wave_speed; //pixels per refresh
|
||||
unsigned int m_wave_data_rate; //data sample rate
|
||||
unsigned int m_wave_refresh_rate;//refresh cycle in millisecond
|
||||
unsigned char m_frame_len_map[64];
|
||||
unsigned char m_frame_len_map_index;
|
||||
};
|
||||
#endif
|
40
README.md
|
@ -1,5 +1,5 @@
|
|||
<p align="center">
|
||||
<img src="doc/GuiLiteCube.gif" alt="Image" width="320" height="304"/>
|
||||
<img src="documents/GuiLiteCube.gif" alt="Image" width="320" height="304"/>
|
||||
</p>
|
||||
|
||||
# GuiLite - The smallest GUI library
|
||||
|
@ -14,7 +14,7 @@
|
|||
***
|
||||
## Introduction
|
||||
GuiLite is the smallest GUI library with 5000 lines of code, could run on **all platforms**(e.g, iOS/macOS/WathOS, Android, Linux, Windows, Docker and MCU without OS), and work with **many languages**(e.g. Swift, Java, Javascript, C#, Golang).
|
||||
- ✂️Small: 5,000 lines of C++ code, could be merged into 1 header & 1 source file(GuiLite.h/GuiLite.cpp) - Easy to [build & port](doc/HowToBuild.md)
|
||||
- ✂️Small: 5,000 lines of C++ code, could be merged into 1 header & 1 source file(GuiLite.h/GuiLite.cpp) - Easy to [build & port](documents/HowToBuild.md)
|
||||
- ⚡Fast: Render GUI within one invoking, independent of any OS and any third party library - Make GUI run quickly and smoothly
|
||||
- 💉Inject: Run inside Qt/MFC/Winform/Cocoa/Web - Keep Qt/MFC code reusable, and speed it up by local GuiLite-optimization
|
||||
- ⚙️️Hardware Minimum Requirment:
|
||||
|
@ -27,36 +27,36 @@ GuiLite is the smallest GUI library with 5000 lines of code, could run on **all
|
|||
Run GuiLite both on MCU and Apple Watch:
|
||||
| MCU | Apple Watch |
|
||||
| --- | --- |
|
||||
| ![Hello3D](doc/Hello3D.gif) | ![iWatch.hello3D](doc/iWatch.hello3D.gif) |
|
||||
| ![MCU](doc/HelloWave.gif) | ![iWatch.helloWave](doc/iWatch.helloWave.gif) |
|
||||
| ![Hello3D](documents/Hello3D.gif) | ![iWatch.hello3D](documents/iWatch.hello3D.gif) |
|
||||
| ![MCU](documents/HelloWave.gif) | ![iWatch.helloWave](documents/iWatch.helloWave.gif) |
|
||||
|
||||
## ✨Features
|
||||
### ⚔️Cross platform
|
||||
| ARM Linux | STM32 Without OS |
|
||||
| --- | --- |
|
||||
| ![ARM Linux](doc/Linux.gif) | ![MCU](doc/HelloParticle.gif) ![MCU](doc/HelloWave.gif) |
|
||||
| ![ARM Linux](documents/Linux.gif) | ![MCU](documents/HelloParticle.gif) ![MCU](documents/HelloWave.gif) |
|
||||
|
||||
| Windows Mixed Reality | Android |
|
||||
| --- | --- |
|
||||
| ![Win MR](doc/WinMR.gif) | ![Android](doc/Android.gif) |
|
||||
| ![Win MR](documents/WinMR.gif) | ![Android](documents/Android.gif) |
|
||||
|
||||
| macOS | iOS & Aplle Watch |
|
||||
| --- | --- |
|
||||
| ![macOS](doc/Mac.gif) | ![iOS.hostMonitor](doc/iOS.gif) ![iOS.particle](doc/iOS.particle.gif) ![iWatch.helloWave](doc/iWatch.helloWave.gif) |
|
||||
| ![macOS](documents/Mac.gif) | ![iOS.hostMonitor](documents/iOS.gif) ![iOS.particle](documents/iOS.particle.gif) ![iWatch.helloWave](documents/iWatch.helloWave.gif) |
|
||||
***
|
||||
### 🔍GuiLite previewer(WYSIWYG extension for GuiLite)
|
||||
[GuiLite Previewer](https://github.com/idea4good/GuiLitePreviewer) is a Visual Studio Code extension, could extract GUI information from C++ code and preview GUI at preview page(What you see is what you get)
|
||||
![GuiLitePreviewer](doc/Previewer.gif)
|
||||
![GuiLitePreviewer](documents/Previewer.gif)
|
||||
***
|
||||
### 😎Gorgeous UI
|
||||
![HostMonitor](doc/HostMonitor.gif)![HelloNets-pc](doc/HelloNets-pc.gif)
|
||||
![HostMonitor](documents/HostMonitor.gif)![HelloNets-pc](documents/HelloNets-pc.gif)
|
||||
***
|
||||
### 🔣Multi-language:
|
||||
![unicode](doc/unicode.jpg)
|
||||
![unicode](documents/unicode.jpg)
|
||||
***
|
||||
### 🌐IoT Solution & 📊Code Telemetry
|
||||
- Report build activities to cloud:<br>![BuildInfo](doc/BuildInfo.png)
|
||||
- Sync running data to cloud:<br>![DataOnCloud](doc/data_on_cloud.png)
|
||||
- Report build activities to cloud:<br>![BuildInfo](documents/BuildInfo.png)
|
||||
- Sync running data to cloud:<br>![DataOnCloud](documents/data_on_cloud.png)
|
||||
- ⚠️To stop telemetry, remove script files(e,g: sync_build.bat .sync.sh .sync_build.sh)
|
||||
***
|
||||
### 🐋Support Docker
|
||||
|
@ -64,7 +64,7 @@ We build GuiLite demo as docker image, you can update/deploy/run the latest GuiL
|
|||
- `sudo docker run -it --privileged -v /dev:/dev-share idea4good/gui-lite:latest bash /run.sh`
|
||||
***
|
||||
## 📦3D
|
||||
- ![GuiLiteGraphic](doc/GuiLite3D.gif) ![Hello3D](doc/Hello3D.gif)
|
||||
- ![GuiLiteGraphic](documents/GuiLite3D.gif) ![Hello3D](documents/Hello3D.gif)
|
||||
- Run GuiLite Samples[(HelloParticle, HelloWave)](https://gitee.com/idea4good/GuiLiteSamples) on Web and 3D scenario, [source code here](https://github.com/idea4good/GuiLiteWeb/blob/master/CubeEx/main.js)
|
||||
- Run GuiLite-Sample-Hello3D on MCU and Windows/Linux/Qt platform
|
||||
***
|
||||
|
@ -95,15 +95,15 @@ GuiLite is the smallest and simplest GUI library.
|
|||
2. Only use basic C++ feature(class, virtual function), no complex syntax
|
||||
3. All rendering base on draw_pixel, no algorithm
|
||||
4. Full documents and small live demos for reference
|
||||
- [Design specification](doc/HowToWork.md)
|
||||
- [How to build & port?](doc/HowToBuild.md)
|
||||
- [How to Layout widgets?](doc/HowLayoutWork.md)
|
||||
- [Design specification](documents/HowToWork.md)
|
||||
- [How to build & port?](documents/HowToBuild.md)
|
||||
- [How to Layout widgets?](documents/HowLayoutWork.md)
|
||||
- [How to build unicode font/bitmap resource?](https://github.com/idea4good/GuiLiteToolkit)
|
||||
- [How to switch theme?](https://github.com/idea4good/GuiLiteSamples/blob/master/HostMonitor/UIcode/source/resource/resource.cpp)
|
||||
- [How to dispatch messages?](doc/HowMessageWork.md)
|
||||
- [UML chart of GuiLite core](doc/UML.md)
|
||||
- [How to dispatch messages?](documents/HowMessageWork.md)
|
||||
- [UML chart of GuiLite core](documents/UML.md)
|
||||
- How GuiLite multi-layers work?
|
||||
- ![GuiLiteGraphic](doc/GuiLiteGraphic.gif)
|
||||
- ![GuiLiteGraphic](documents/GuiLiteGraphic.gif)
|
||||
- [Full video](https://www.youtube.com/watch?v=QzZJnU5KmDQ)
|
||||
- [Tutorial Source code](https://github.com/idea4good/GuiLiteWeb/blob/master/Graphic/main.js)
|
||||
|
||||
|
@ -126,4 +126,4 @@ GuiLite is the smallest and simplest GUI library.
|
|||
## 📞Community Channel
|
||||
Thanks for the help from community, you guys make GuiLite better! And welcome new friend to join us.
|
||||
- [**@Twitter**](https://twitter.com/idea4good)
|
||||
- QQ code: [<img src="doc/qq.group.jpg">](https://jq.qq.com/?_wv=1027&k=5EO8D9i)
|
||||
- QQ code: [<img src="documents/qq.group.jpg">](https://jq.qq.com/?_wv=1027&k=5EO8D9i)
|
||||
|
|
40
README_zh.md
|
@ -1,5 +1,5 @@
|
|||
<p align="center">
|
||||
<img src="doc/GuiLiteCube.gif" alt="Image" width="320" height="304"/>
|
||||
<img src="documents/GuiLiteCube.gif" alt="Image" width="320" height="304"/>
|
||||
</p>
|
||||
|
||||
# GuiLite(超轻量UI框架)- 最小的GUI库
|
||||
|
@ -13,7 +13,7 @@
|
|||
***
|
||||
## GuiLite是什么鬼?
|
||||
GuiLite是5千行的图形界面库,可以运行在**所有平台**(例如:iOS/macOS/WathOS,Android,Linux(ARM/x86-64),Windows(包含VR),Docker和MCU)上;也可以与**多种语言**(例如: Swift, Java, Javascript, C#, Golang)协同工作。
|
||||
- ✂️轻量: 5千行C++代码,可合并在:1个头文件(GuiLite.h),1个实现文件(GuiLite.cpp)中 - 轻松[编译/移植](doc/HowToBuild.md)
|
||||
- ✂️轻量: 5千行C++代码,可合并在:1个头文件(GuiLite.h),1个实现文件(GuiLite.cpp)中 - 轻松[编译/移植](documents/HowToBuild.md)
|
||||
- ⚡超快: 一次调用就可以完成图形渲染,与操作系统及第三方库无关 - 程序更快速,UI更流畅
|
||||
- 💉可注入: 可注入在Qt/MFC/Winform/Cocoa/Web程序中运行 - 充分利用现有Qt/MFC代码,局部GuiLite优化,亦可显著提升效率
|
||||
- ⚙️️最低硬件要求:
|
||||
|
@ -26,43 +26,43 @@ GuiLite是5千行的图形界面库,可以运行在**所有平台**(例如
|
|||
GuiLite程序,可以同时运行在单片机和苹果“手表”上:
|
||||
| MCU | Apple Watch |
|
||||
| --- | --- |
|
||||
| ![Hello3D](doc/Hello3D.gif) | ![iWatch.hello3D](doc/iWatch.hello3D.gif) |
|
||||
| ![MCU](doc/HelloWave.gif) | ![iWatch.helloWave](doc/iWatch.helloWave.gif) |
|
||||
| ![Hello3D](documents/Hello3D.gif) | ![iWatch.hello3D](documents/iWatch.hello3D.gif) |
|
||||
| ![MCU](documents/HelloWave.gif) | ![iWatch.helloWave](documents/iWatch.helloWave.gif) |
|
||||
|
||||
## ✨功能介绍
|
||||
### ⚔️卓越的跨平台能力
|
||||
| ARM Linux | STM32 Without OS |
|
||||
| --- | --- |
|
||||
| ![ARM Linux](doc/Linux.gif) | ![MCU](doc/HelloParticle.gif) ![MCU](doc/HelloWave.gif) |
|
||||
| ![ARM Linux](documents/Linux.gif) | ![MCU](documents/HelloParticle.gif) ![MCU](documents/HelloWave.gif) |
|
||||
|
||||
| Windows Mixed Reality | Android |
|
||||
| --- | --- |
|
||||
| ![Win MR](doc/WinMR.gif) | ![Android](doc/Android.gif) |
|
||||
| ![Win MR](documents/WinMR.gif) | ![Android](documents/Android.gif) |
|
||||
|
||||
| macOS | iOS & Apple Watch |
|
||||
| --- | --- |
|
||||
| ![macOS](doc/Mac.gif) | ![iOS.hostMonitor](doc/iOS.gif) ![iOS.particle](doc/iOS.particle.gif) ![iWatch.helloWave](doc/iWatch.helloWave.gif) |
|
||||
| ![macOS](documents/Mac.gif) | ![iOS.hostMonitor](documents/iOS.gif) ![iOS.particle](documents/iOS.particle.gif) ![iWatch.helloWave](documents/iWatch.helloWave.gif) |
|
||||
***
|
||||
### 🔍GuiLite Previewer(所见即所得的GuiLite开发插件)
|
||||
[GuiLite Previewer](https://github.com/idea4good/GuiLitePreviewer)是一个Visual Studio Code插件,它可以自动提取源代码的GUI布局信息,并实时显示在“预览”页面上(所见即所得)
|
||||
![GuiLitePreviewer](doc/Previewer.gif)
|
||||
![GuiLitePreviewer](documents/Previewer.gif)
|
||||
***
|
||||
### 😎浮夸的UI效果
|
||||
![HostMonitor](doc/HostMonitor.gif)![HelloNets-pc](doc/HelloNets-pc.gif)
|
||||
![HostMonitor](documents/HostMonitor.gif)![HelloNets-pc](documents/HelloNets-pc.gif)
|
||||
***
|
||||
### 🔣万国语(unicode):
|
||||
![unicode](doc/unicode.jpg)
|
||||
![unicode](documents/unicode.jpg)
|
||||
***
|
||||
### 🌐IoT(物联网)和📊数据分析
|
||||
- 上报“编译/运行”情况至“云端”:<br>![BuildInfo](doc/BuildInfo.png)
|
||||
- 同步“运行数据”至“云端”:<br>![DataOnCloud](doc/data_on_cloud.png)
|
||||
- 上报“编译/运行”情况至“云端”:<br>![BuildInfo](documents/BuildInfo.png)
|
||||
- 同步“运行数据”至“云端”:<br>![DataOnCloud](documents/data_on_cloud.png)
|
||||
***
|
||||
### 🐋支持Docker
|
||||
我们把GuiLite demo做成了Docker映像,只需一行命令,就可以将最新的GuiLite demo升级/部署/运行在你的设备上了。
|
||||
- `sudo docker run -it --privileged -v /dev:/dev-share idea4good/gui-lite:latest bash /run.sh`
|
||||
***
|
||||
## 📦3D
|
||||
- ![GuiLiteGraphic](doc/GuiLite3D.gif) ![Hello3D](doc/Hello3D.gif)
|
||||
- ![GuiLiteGraphic](documents/GuiLite3D.gif) ![Hello3D](documents/Hello3D.gif)
|
||||
- GuiLite实例[(HelloParticle, HelloWave)](https://gitee.com/idea4good/GuiLiteSamples)运行在Web及3D环境,[代码在这里](https://github.com/idea4good/GuiLiteWeb/blob/master/CubeEx/main.js)
|
||||
- 在单片机上也能运行3D效果(具体参看GuiLiteSamples:Hello3D)
|
||||
***
|
||||
|
@ -93,15 +93,15 @@ GuiLite是最简单,易学的GUI库。
|
|||
2. 只使用C++的基本特性(类和虚函数),不涉及复杂语法
|
||||
3. 图形绘制以描点为基础,不使用任何算法
|
||||
4. 设计简单,配有丰富的文档和实例程序;遇到问题,可以在QQ群获得帮助
|
||||
- [软件设计说明](doc/HowToWork-cn.md)
|
||||
- [如何编译和移植?](doc/HowToBuild.md)
|
||||
- [如何布局UI?](doc/HowLayoutWork.md)
|
||||
- [软件设计说明](documents/HowToWork-cn.md)
|
||||
- [如何编译和移植?](documents/HowToBuild.md)
|
||||
- [如何布局UI?](documents/HowLayoutWork.md)
|
||||
- [如何制作多种文字/位图资源?](https://github.com/idea4good/GuiLiteToolkit)
|
||||
- [如何“换肤”?](https://gitee.com/idea4good/GuiLiteSamples/blob/master/HostMonitor/UIcode/source/resource/resource.cpp)
|
||||
- [如何传递消息?](doc/HowMessageWork.md)
|
||||
- [核心UML示意图](doc/UML.md)
|
||||
- [如何传递消息?](documents/HowMessageWork.md)
|
||||
- [核心UML示意图](documents/UML.md)
|
||||
- GuiLite滑动,及多层叠加原理
|
||||
- ![GuiLiteGraphic](doc/GuiLiteGraphic.gif)
|
||||
- ![GuiLiteGraphic](documents/GuiLiteGraphic.gif)
|
||||
- [完整视频](https://v.youku.com/v_show/id_XNDI4ODE1ODcwOA)
|
||||
- [Source code](https://github.com/idea4good/GuiLiteWeb/blob/master/Graphic/main.js)
|
||||
|
||||
|
@ -122,4 +122,4 @@ GuiLite是最简单,易学的GUI库。
|
|||
[GitHub链接](https://github.com/idea4good/GuiLite)
|
||||
|
||||
## 📞社区交流
|
||||
- 感谢开发者群的所有同学,是你们塑造了今天的GuiLite!也欢迎新的大神/小白加入我们。<br>[<img src="doc/qq.group.jpg">](https://jq.qq.com/?_wv=1027&k=5EO8D9i)
|
||||
- 感谢开发者群的所有同学,是你们塑造了今天的GuiLite!也欢迎新的大神/小白加入我们。<br>[<img src="documents/qq.group.jpg">](https://jq.qq.com/?_wv=1027&k=5EO8D9i)
|
||||
|
|
Before Width: | Height: | Size: 1.1 MiB After Width: | Height: | Size: 1.1 MiB |
Before Width: | Height: | Size: 44 KiB After Width: | Height: | Size: 44 KiB |
Before Width: | Height: | Size: 7.7 KiB After Width: | Height: | Size: 7.7 KiB |
Before Width: | Height: | Size: 1005 KiB After Width: | Height: | Size: 1005 KiB |
Before Width: | Height: | Size: 1001 KiB After Width: | Height: | Size: 1001 KiB |
Before Width: | Height: | Size: 190 KiB After Width: | Height: | Size: 190 KiB |
Before Width: | Height: | Size: 918 KiB After Width: | Height: | Size: 918 KiB |
Before Width: | Height: | Size: 956 KiB After Width: | Height: | Size: 956 KiB |
Before Width: | Height: | Size: 875 KiB After Width: | Height: | Size: 875 KiB |
Before Width: | Height: | Size: 360 KiB After Width: | Height: | Size: 360 KiB |
Before Width: | Height: | Size: 917 KiB After Width: | Height: | Size: 917 KiB |
Before Width: | Height: | Size: 243 KiB After Width: | Height: | Size: 243 KiB |
Before Width: | Height: | Size: 926 KiB After Width: | Height: | Size: 926 KiB |
Before Width: | Height: | Size: 3.2 MiB After Width: | Height: | Size: 3.2 MiB |
Before Width: | Height: | Size: 1.6 MiB After Width: | Height: | Size: 1.6 MiB |
Before Width: | Height: | Size: 972 KiB After Width: | Height: | Size: 972 KiB |
Before Width: | Height: | Size: 2.1 MiB After Width: | Height: | Size: 2.1 MiB |
Before Width: | Height: | Size: 27 KiB After Width: | Height: | Size: 27 KiB |
Before Width: | Height: | Size: 145 KiB After Width: | Height: | Size: 145 KiB |
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 14 KiB |
Before Width: | Height: | Size: 8.8 KiB After Width: | Height: | Size: 8.8 KiB |
Before Width: | Height: | Size: 999 KiB After Width: | Height: | Size: 999 KiB |
Before Width: | Height: | Size: 506 KiB After Width: | Height: | Size: 506 KiB |
Before Width: | Height: | Size: 502 KiB After Width: | Height: | Size: 502 KiB |
Before Width: | Height: | Size: 206 KiB After Width: | Height: | Size: 206 KiB |
Before Width: | Height: | Size: 162 KiB After Width: | Height: | Size: 162 KiB |
Before Width: | Height: | Size: 125 KiB After Width: | Height: | Size: 125 KiB |
Before Width: | Height: | Size: 135 KiB After Width: | Height: | Size: 135 KiB |
Before Width: | Height: | Size: 57 KiB After Width: | Height: | Size: 57 KiB |
Before Width: | Height: | Size: 10 KiB After Width: | Height: | Size: 10 KiB |
Before Width: | Height: | Size: 32 KiB After Width: | Height: | Size: 32 KiB |
Before Width: | Height: | Size: 72 KiB After Width: | Height: | Size: 72 KiB |
Before Width: | Height: | Size: 80 KiB After Width: | Height: | Size: 80 KiB |