diff --git a/GuiLite.h b/GuiLite.h index c4fc88a..80550e1 100644 --- a/GuiLite.h +++ b/GuiLite.h @@ -1,107 +1,94 @@ #pragma once - -#define REAL_TIME_TASK_CYCLE_MS 50 -#define MAX(a,b) (((a)>(b))?(a):(b)) -#define MIN(a,b) (((a)<(b))?(a):(b)) - -#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* param), void* param); - -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; -}; - -class c_rect -{ -public: - c_rect(){ m_left = m_top = m_right = m_bottom = -1; } - c_rect(int left, int top, int width, int height) - { - set_rect(left, top, width, height); - } - void set_rect(int left, int top, int width, int height) - { - ASSERT(width > 0 && height > 0); - m_left = left; - m_top = top; - m_right = left + width - 1; - m_bottom = top + height -1; - } - bool pt_in_rect(int x, int y) const - { - return x >= m_left && x <= m_right && y >= m_top && y <= m_bottom; - } - int operator==(const c_rect& rect) const - { - return (m_left == rect.m_left) && (m_top == rect.m_top) && (m_right == rect.m_right) && (m_bottom == rect.m_bottom); - } - 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; -}; +#define REAL_TIME_TASK_CYCLE_MS 50 +#define MAX(a,b) (((a)>(b))?(a):(b)) +#define MIN(a,b) (((a)<(b))?(a):(b)) +#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* param), void* param); +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; +}; +class c_rect +{ +public: + c_rect(){ m_left = m_top = m_right = m_bottom = -1; } + c_rect(int left, int top, int width, int height) + { + set_rect(left, top, width, height); + } + void set_rect(int left, int top, int width, int height) + { + ASSERT(width > 0 && height > 0); + m_left = left; + m_top = top; + m_right = left + width - 1; + m_bottom = top + height -1; + } + bool pt_in_rect(int x, int y) const + { + return x >= m_left && x <= m_right && y >= m_top && y <= m_bottom; + } + int operator==(const c_rect& rect) const + { + return (m_left == rect.m_left) && (m_top == rect.m_top) && (m_right == rect.m_right) && (m_bottom == rect.m_bottom); + } + 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; +}; //BITMAP typedef struct struct_bitmap_info { @@ -238,7 +225,7 @@ typedef enum Z_ORDER_LEVEL_2,//highest graphic level Z_ORDER_LEVEL_MAX }Z_ORDER_LEVEL; -struct EXTERNAL_GFX_OP +struct DISPLAY_DRIVER { void(*draw_pixel)(int x, int y, unsigned int rgb); void(*fill_rect)(int x0, int y0, int x1, int y1, unsigned int rgb); @@ -247,18 +234,19 @@ class c_surface; class c_display { friend class c_surface; public: - inline c_display(void* phy_fb, int display_width, int display_height, int surface_width, int surface_height, unsigned int color_bytes, int surface_cnt, EXTERNAL_GFX_OP* gfx_op = 0);//multiple surface or surface_no_fb - inline c_display(void* phy_fb, int display_width, int display_height, c_surface* surface);//single custom surface - inline c_surface* alloc_surface(Z_ORDER_LEVEL max_zorder, c_rect layer_rect = c_rect());//for multiple surfaces + inline c_display(void* phy_fb, int display_width, int display_height, c_surface* surface, DISPLAY_DRIVER* driver = 0);//single custom surface + inline c_display(void* phy_fb, int display_width, int display_height, int surface_width, int surface_height, unsigned int color_bytes, int surface_cnt, DISPLAY_DRIVER* driver = 0);//multiple surface + inline c_surface* alloc_surface(Z_ORDER_LEVEL max_zorder, c_rect layer_rect = c_rect());//for slide group inline int swipe_surface(c_surface* s0, c_surface* s1, int x0, int x1, int y0, int y1, int offset); int get_width() { return m_width; } int get_height() { return m_height; } + void* get_phy_fb() { return m_phy_fb; } void* get_updated_fb(int* width, int* height, bool force_update = false) { if (width && height) { - *width = get_width(); - *height = get_height(); + *width = m_width; + *height = m_height; } if (force_update) { @@ -277,35 +265,123 @@ public: { return -1; } - int width = get_width(); - int height = get_height(); //16 bits framebuffer if (m_color_bytes == 2) { - return build_bmp(file_name, width, height, (unsigned char*)m_phy_fb); + return build_bmp(file_name, m_width, m_height, (unsigned char*)m_phy_fb); } //32 bits framebuffer - unsigned short* p_bmp565_data = new unsigned short[width * height]; + unsigned short* p_bmp565_data = new unsigned short[m_width * m_height]; unsigned int* p_raw_data = (unsigned int*)m_phy_fb; - for (int i = 0; i < width * height; i++) + for (int i = 0; i < m_width * m_height; i++) { unsigned int rgb = *p_raw_data++; p_bmp565_data[i] = GL_RGB_32_to_16(rgb); } - int ret = build_bmp(file_name, width, height, (unsigned char*)p_bmp565_data); + int ret = build_bmp(file_name, m_width, m_height, (unsigned char*)p_bmp565_data); delete[]p_bmp565_data; return ret; } -private: - int m_width; //in pixels - int m_height; //in pixels - int m_color_bytes; //16 bits, 32 bits only - void* m_phy_fb; //physical framebuffer +protected: + virtual void draw_pixel(int x, int y, unsigned int rgb) + { + if ((x >= m_width) || (y >= m_height)) { return; } + if (m_driver && m_driver->draw_pixel) + { + return m_driver->draw_pixel(x, y, rgb); + } + if (m_color_bytes == 2) + { + ((unsigned short*)m_phy_fb)[y * m_width + x] = GL_RGB_32_to_16(rgb); + } + else + { + ((unsigned int*)m_phy_fb)[y * m_width + x] = rgb; + } + } + virtual void fill_rect(int x0, int y0, int x1, int y1, unsigned int rgb) + { + if (m_driver && m_driver->fill_rect) + { + return m_driver->fill_rect(x0, y0, x1, y1, rgb); + } + if (m_driver && m_driver->draw_pixel) + { + for (int y = y0; y <= y1; y++) + { + for (int x = x0; x <= x1; x++) + { + m_driver->draw_pixel(x, y, rgb); + } + } + return; + } + register int _width = m_width; + register int _height = m_height; + int x, y; + if (m_color_bytes == 2) + { + unsigned short* phy_fb; + unsigned int rgb_16 = GL_RGB_32_to_16(rgb); + for (y = y0; y <= y1; y++) + { + phy_fb = &((unsigned short*)m_phy_fb)[y * _width + x0]; + for (x = x0; x <= x1; x++) + { + if ((x < _width) && (y < _height)) + { + *phy_fb++ = rgb_16; + } + } + } + } + else + { + unsigned int* phy_fb; + for (y = y0; y <= y1; y++) + { + phy_fb = &((unsigned int*)m_phy_fb)[y * _width + x0]; + for (x = x0; x <= x1; x++) + { + if ((x < _width) && (y < _height)) + { + *phy_fb++ = rgb; + } + } + } + } + } + virtual int flush_screen(int left, int top, int right, int bottom, void* fb, int fb_width) + { + if ((0 == m_phy_fb) || (0 == fb)) + { + return -1; + } + register int _width = m_width; + register int _height = m_height; + left = (left >= _width) ? (_width - 1) : left; + right = (right >= _width) ? (_width - 1) : right; + top = (top >= _height) ? (_height - 1) : top; + bottom = (bottom >= _height) ? (_height - 1) : bottom; + for (int y = top; y < bottom; y++) + { + void* s_addr = (char*)fb + ((y * fb_width + left) * m_color_bytes); + void* d_addr = (char*)m_phy_fb + ((y * _width + left) * m_color_bytes); + memcpy(d_addr, s_addr, (right - left) * m_color_bytes); + } + return 0; + } + int m_width; //in pixels + int m_height; //in pixels + int m_color_bytes; //16/32 bits for default + void* m_phy_fb; //physical framebuffer for default + struct DISPLAY_DRIVER* m_driver; //Rendering by external method without default physical framebuffer int m_phy_read_index; int m_phy_write_index; c_surface* m_surface_group[SURFACE_CNT_MAX]; int m_surface_cnt; //surface count int m_surface_index; + }; class c_layer { @@ -317,12 +393,10 @@ public: class c_surface { friend class c_display; friend class c_bitmap_operator; public: - c_surface(unsigned int width, unsigned int height, unsigned int color_bytes, Z_ORDER_LEVEL max_zorder = Z_ORDER_LEVEL_0, c_rect overlpa_rect = c_rect()) : m_width(width), m_height(height), m_color_bytes(color_bytes), m_fb(0), m_is_active(false), m_top_zorder(Z_ORDER_LEVEL_0), m_phy_fb(0), m_phy_write_index(0), m_display(0) + c_surface(unsigned int width, unsigned int height, unsigned int color_bytes, Z_ORDER_LEVEL max_zorder = Z_ORDER_LEVEL_0, c_rect overlpa_rect = c_rect()) : m_width(width), m_height(height), m_color_bytes(color_bytes), m_fb(0), m_is_active(false), m_top_zorder(Z_ORDER_LEVEL_0), m_phy_write_index(0), m_display(0) { (overlpa_rect == c_rect()) ? set_surface(max_zorder, c_rect(0, 0, width - 1, height - 1)) : set_surface(max_zorder, overlpa_rect); } - int get_width() { return m_width; } - int get_height() { return m_height; } unsigned int get_pixel(int x, int y, unsigned int z_order) { if (x >= m_width || y >= m_height || x < 0 || y < 0 || z_order >= Z_ORDER_LEVEL_MAX) @@ -332,15 +406,15 @@ public: } if (m_layers[z_order].fb) { - return (m_color_bytes == 4) ? ((unsigned int*)(m_layers[z_order].fb))[y * m_width + x] : GL_RGB_16_to_32(((unsigned short*)(m_layers[z_order].fb))[y * m_width + x]); + return (m_color_bytes == 2) ? GL_RGB_16_to_32(((unsigned short*)(m_layers[z_order].fb))[y * m_width + x]) : ((unsigned int*)(m_layers[z_order].fb))[y * m_width + x]; } else if (m_fb) { - return (m_color_bytes == 4) ? ((unsigned int*)m_fb)[y * m_width + x] : GL_RGB_16_to_32(((unsigned short*)m_fb)[y * m_width + x]); + return (m_color_bytes == 2) ? GL_RGB_16_to_32(((unsigned short*)m_fb)[y * m_width + x]) : ((unsigned int*)m_fb)[y * m_width + x]; } - else if (m_phy_fb) + else if (m_display->m_phy_fb) { - return (m_color_bytes == 4) ? ((unsigned int*)m_phy_fb)[y * m_width + x] : GL_RGB_16_to_32(((unsigned short*)m_phy_fb)[y * m_width + x]); + return (m_color_bytes == 2) ? GL_RGB_16_to_32(((unsigned short*)m_display->m_phy_fb)[y * m_width + x]) : ((unsigned int*)m_display->m_phy_fb)[y * m_width + x]; } return 0; } @@ -357,7 +431,7 @@ public: } if (z_order == m_max_zorder) { - return draw_pixel_on_fb(x, y, rgb); + return draw_pixel_low_level(x, y, rgb); } if (z_order > (unsigned int)m_top_zorder) @@ -367,19 +441,19 @@ public: if (m_layers[z_order].rect.pt_in_rect(x, y)) { c_rect layer_rect = m_layers[z_order].rect; - if (m_color_bytes == 4) + if (m_color_bytes == 2) { - ((unsigned int*)(m_layers[z_order].fb))[(x - layer_rect.m_left) + (y - layer_rect.m_top) * layer_rect.width()] = rgb; + ((unsigned short*)(m_layers[z_order].fb))[(x - layer_rect.m_left) + (y - layer_rect.m_top) * layer_rect.width()] = GL_RGB_32_to_16(rgb); } else { - ((unsigned short*)(m_layers[z_order].fb))[(x - layer_rect.m_left) + (y - layer_rect.m_top) * layer_rect.width()] = GL_RGB_32_to_16(rgb); + ((unsigned int*)(m_layers[z_order].fb))[(x - layer_rect.m_left) + (y - layer_rect.m_top) * layer_rect.width()] = rgb; } } if (z_order == m_top_zorder) { - return draw_pixel_on_fb(x, y, rgb); + return draw_pixel_low_level(x, y, rgb); } bool be_overlapped = false; for (unsigned int tmp_z_order = Z_ORDER_LEVEL_MAX - 1; tmp_z_order > z_order; tmp_z_order--) @@ -392,7 +466,7 @@ public: } if (!be_overlapped) { - draw_pixel_on_fb(x, y, rgb); + draw_pixel_low_level(x, y, rgb); } } virtual void fill_rect(int x0, int y0, int x1, int y1, unsigned int rgb, unsigned int z_order) @@ -403,7 +477,7 @@ public: y1 = (y1 > (m_height - 1)) ? (m_height - 1) : y1; if (z_order == m_max_zorder) { - return fill_rect_on_fb(x0, y0, x1, y1, rgb); + return fill_rect_low_level(x0, y0, x1, y1, rgb); } if (z_order == m_top_zorder) { @@ -416,18 +490,18 @@ public: { if (layer_rect.pt_in_rect(x, y)) { - if (m_color_bytes == 4) + if (m_color_bytes == 2) { - ((unsigned int*)m_layers[z_order].fb)[(y - layer_rect.m_top) * layer_rect.width() + (x - layer_rect.m_left)] = rgb; + ((unsigned short*)m_layers[z_order].fb)[(y - layer_rect.m_top) * layer_rect.width() + (x - layer_rect.m_left)] = rgb_16; } else { - ((unsigned short*)m_layers[z_order].fb)[(y - layer_rect.m_top) * layer_rect.width() + (x - layer_rect.m_left)] = rgb_16; + ((unsigned int*)m_layers[z_order].fb)[(y - layer_rect.m_top) * layer_rect.width() + (x - layer_rect.m_left)] = rgb; } } } } - return fill_rect_on_fb(x0, y0, x1, y1, rgb); + return fill_rect_low_level(x0, y0, x1, y1, rgb); } for (; y0 <= y1; y0++) { @@ -499,27 +573,16 @@ public: } int flush_screen(int left, int top, int right, int bottom) { + if (!m_is_active) + { + return -1; + } if (left < 0 || left >= m_width || right < 0 || right >= m_width || top < 0 || top >= m_height || bottom < 0 || bottom >= m_height) { ASSERT(false); } - if (!m_is_active || (0 == m_phy_fb) || (0 == m_fb)) - { - return -1; - } - int display_width = m_display->get_width(); - int display_height = m_display->get_height(); - left = (left >= display_width) ? (display_width - 1) : left; - right = (right >= display_width) ? (display_width - 1) : right; - top = (top >= display_height) ? (display_height - 1) : top; - bottom = (bottom >= display_height) ? (display_height - 1) : bottom; - for (int y = top; y < bottom; y++) - { - void* s_addr = (char*)m_fb + ((y * m_width + left) * m_color_bytes); - void* d_addr = (char*)m_phy_fb + ((y * display_width + left) * m_color_bytes); - memcpy(d_addr, s_addr, (right - left) * m_color_bytes); - } + m_display->flush_screen(left, top, right, bottom, m_fb, m_width); *m_phy_write_index = *m_phy_write_index + 1; return 0; } @@ -537,90 +600,62 @@ public: { for (int x = rect.m_left; x <= rect.m_right; x++) { - unsigned int rgb = (m_color_bytes == 4) ? ((unsigned int*)fb)[(x - layer_rect.m_left) + (y - layer_rect.m_top) * width] : GL_RGB_16_to_32(((unsigned short*)fb)[(x - layer_rect.m_left) + (y - layer_rect.m_top) * width]); - draw_pixel_on_fb(x, y, rgb); + unsigned int rgb = (m_color_bytes == 2) ? GL_RGB_16_to_32(((unsigned short*)fb)[(x - layer_rect.m_left) + (y - layer_rect.m_top) * width]) : ((unsigned int*)fb)[(x - layer_rect.m_left) + (y - layer_rect.m_top) * width]; + draw_pixel_low_level(x, y, rgb); } } return 0; } 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) - { - int display_width = m_display->get_width(); - int display_height = m_display->get_height(); - if (m_color_bytes == 4) + virtual void fill_rect_low_level(int x0, int y0, int x1, int y1, unsigned int rgb) + {//fill rect on framebuffer of surface + int x, y; + if (m_color_bytes == 2) { - int x; - unsigned int* fb, * phy_fb; - for (; y0 <= y1; y0++) + unsigned short* fb; + unsigned int rgb_16 = GL_RGB_32_to_16(rgb); + for (y = y0; y <= y1; y++) { - x = x0; - fb = m_fb ? &((unsigned int*)m_fb)[y0 * m_width + x] : 0; - phy_fb = &((unsigned int*)m_phy_fb)[y0 * display_width + x]; - *m_phy_write_index = *m_phy_write_index + 1; - for (; x <= x1; x++) + fb = m_fb ? &((unsigned short*)m_fb)[y * m_width + x0] : 0; + if (!fb) { break; } + for (x = x0; x <= x1; x++) { - if (fb) - { - *fb++ = rgb; - } - if (m_is_active && (x < display_width) && (y0 < display_height)) - { - *phy_fb++ = rgb; - } + *fb++ = rgb_16; } } } - else if (m_color_bytes == 2) + else { - int x; - unsigned short* fb, * phy_fb; - rgb = GL_RGB_32_to_16(rgb); - for (; y0 <= y1; y0++) + unsigned int* fb; + for (y = y0; y <= y1; y++) { - x = x0; - fb = m_fb ? &((unsigned short*)m_fb)[y0 * m_width + x] : 0; - phy_fb = &((unsigned short*)m_phy_fb)[y0 * display_width + x]; - *m_phy_write_index = *m_phy_write_index + 1; - for (; x <= x1; x++) + fb = m_fb ? &((unsigned int*)m_fb)[y * m_width + x0] : 0; + if (!fb) { break; } + for (x = x0; x <= x1; x++) { - if (fb) - { - *fb++ = rgb; - } - if (m_is_active && (x < display_width) && (y0 < display_height)) - { - *phy_fb++ = rgb; - } + *fb++ = rgb; } } } + if (!m_is_active) { return; } + m_display->fill_rect(x0, y0, x1, y1, rgb); + *m_phy_write_index = *m_phy_write_index + 1; } - virtual void draw_pixel_on_fb(int x, int y, unsigned int rgb) + virtual void draw_pixel_low_level(int x, int y, unsigned int rgb) { if (m_fb) - { - (m_color_bytes == 4) ? ((unsigned int*)m_fb)[y * m_width + x] = rgb : ((unsigned short*)m_fb)[y * m_width + x] = GL_RGB_32_to_16(rgb); - } - if (m_is_active && (x < m_display->get_width()) && (y < m_display->get_height())) - { - if (m_color_bytes == 4) - { - ((unsigned int*)m_phy_fb)[y * (m_display->get_width()) + x] = rgb; - } - else - { - ((unsigned short*)m_phy_fb)[y * (m_display->get_width()) + x] = GL_RGB_32_to_16(rgb); - } - *m_phy_write_index = *m_phy_write_index + 1; + {//draw pixel on framebuffer of surface + (m_color_bytes == 2) ? ((unsigned short*)m_fb)[y * m_width + x] = GL_RGB_32_to_16(rgb): ((unsigned int*)m_fb)[y * m_width + x] = rgb; } + if (!m_is_active) { return; } + m_display->draw_pixel(x, y, rgb); + *m_phy_write_index = *m_phy_write_index + 1; } void attach_display(c_display* display) { ASSERT(display); m_display = display; - m_phy_fb = display->m_phy_fb; m_phy_write_index = &display->m_phy_write_index; } void set_surface(Z_ORDER_LEVEL max_z_order, c_rect layer_rect) @@ -638,87 +673,22 @@ protected: } int m_width; //in pixels int m_height; //in pixels - int m_color_bytes; //16 bits, 32 bits only + int m_color_bytes; //16 bits, 32 bits for default void* m_fb; //frame buffer you could see c_layer m_layers[Z_ORDER_LEVEL_MAX];//all graphic layers bool m_is_active; //active flag Z_ORDER_LEVEL m_max_zorder; //the highest graphic layer the surface will have Z_ORDER_LEVEL m_top_zorder; //the current highest graphic layer the surface have - void* m_phy_fb; //physical framebufer int* m_phy_write_index; c_display* m_display; }; -class c_surface_no_fb : public c_surface {//No physical framebuffer, render with external graphic interface - friend class c_display; -public: - c_surface_no_fb(unsigned int width, unsigned int height, unsigned int color_bytes, struct EXTERNAL_GFX_OP* gfx_op, Z_ORDER_LEVEL max_zorder = Z_ORDER_LEVEL_0, c_rect overlpa_rect = c_rect()) : c_surface(width, height, color_bytes, max_zorder, overlpa_rect), m_gfx_op(gfx_op) {} -protected: - virtual void fill_rect_on_fb(int x0, int y0, int x1, int y1, unsigned int rgb) - { - if (!m_gfx_op) - { - return; - } - if (m_gfx_op->fill_rect) - { - return m_gfx_op->fill_rect(x0, y0, x1, y1, rgb); - } - if (m_gfx_op->draw_pixel && m_is_active) - { - for (int y = y0; y <= y1; y++) - { - for (int x = x0; x <= x1; x++) - { - m_gfx_op->draw_pixel(x, y, rgb); - } - } - } - if (!m_fb) { return; } - if (m_color_bytes == 4) - { - unsigned int* fb; - for (int y = y0; y <= y1; y++) - { - fb = &((unsigned int*)m_fb)[y0 * m_width + x0]; - for (int x = x0; x <= x1; x++) - { - *fb++ = rgb; - } - } - } - else if (m_color_bytes == 2) - { - unsigned short* fb; - rgb = GL_RGB_32_to_16(rgb); - for (int y = y0; y <= y1; y++) - { - fb = &((unsigned short*)m_fb)[y0 * m_width + x0]; - for (int x = x0; x <= x1; x++) - { - *fb++ = rgb; - } - } - } - } - virtual void draw_pixel_on_fb(int x, int y, unsigned int rgb) - { - if (m_gfx_op && m_gfx_op->draw_pixel && m_is_active) - { - m_gfx_op->draw_pixel(x, y, rgb); - } - if (!m_fb) { return; } - if (m_color_bytes == 4) - { - ((unsigned int*)m_fb)[y * m_width + x] = rgb; - } - else if (m_color_bytes == 2) - { - ((unsigned short*)m_fb)[y * m_width + x] = GL_RGB_32_to_16(rgb); - } - } - struct EXTERNAL_GFX_OP* m_gfx_op;//Rendering by external method -}; -inline c_display::c_display(void* phy_fb, int display_width, int display_height, int surface_width, int surface_height, unsigned int color_bytes, int surface_cnt, EXTERNAL_GFX_OP* gfx_op) : m_width(display_width), m_height(display_height), m_color_bytes(color_bytes), m_phy_fb(phy_fb), m_phy_read_index(0), m_phy_write_index(0), m_surface_cnt(surface_cnt), m_surface_index(0) +inline c_display::c_display(void* phy_fb, int display_width, int display_height, c_surface* surface, DISPLAY_DRIVER* driver) : m_phy_fb(phy_fb), m_width(display_width), m_height(display_height), m_driver(driver), m_phy_read_index(0), m_phy_write_index(0), m_surface_cnt(1), m_surface_index(0) +{ + m_color_bytes = surface->m_color_bytes; + surface->m_is_active = true; + (m_surface_group[0] = surface)->attach_display(this); +} +inline c_display::c_display(void* phy_fb, int display_width, int display_height, int surface_width, int surface_height, unsigned int color_bytes, int surface_cnt, DISPLAY_DRIVER* driver) : m_phy_fb(phy_fb), m_width(display_width), m_height(display_height), m_color_bytes(color_bytes), m_phy_read_index(0), m_phy_write_index(0), m_surface_cnt(surface_cnt), m_driver(driver), m_surface_index(0) { ASSERT(color_bytes == 2 || color_bytes == 4); ASSERT(m_surface_cnt <= SURFACE_CNT_MAX); @@ -726,16 +696,10 @@ inline c_display::c_display(void* phy_fb, int display_width, int display_height, for (int i = 0; i < m_surface_cnt; i++) { - m_surface_group[i] = (phy_fb) ? new c_surface(surface_width, surface_height, color_bytes) : new c_surface_no_fb(surface_width, surface_height, color_bytes, gfx_op); + m_surface_group[i] = new c_surface(surface_width, surface_height, color_bytes); m_surface_group[i]->attach_display(this); } } -inline c_display::c_display(void* phy_fb, int display_width, int display_height, c_surface* surface) : m_width(display_width), m_height(display_height), m_phy_fb(phy_fb), m_phy_read_index(0), m_phy_write_index(0), m_surface_cnt(1), m_surface_index(0) -{ - m_color_bytes = surface->m_color_bytes; - surface->m_is_active = true; - (m_surface_group[0] = surface)->attach_display(this); -} inline c_surface* c_display::alloc_surface(Z_ORDER_LEVEL max_zorder, c_rect layer_rect) { ASSERT(max_zorder < Z_ORDER_LEVEL_MAX && m_surface_index < m_surface_cnt); @@ -744,8 +708,8 @@ inline c_surface* c_display::alloc_surface(Z_ORDER_LEVEL max_zorder, c_rect laye } inline int c_display::swipe_surface(c_surface* s0, c_surface* s1, int x0, int x1, int y0, int y1, int offset) { - int surface_width = s0->get_width(); - int surface_height = s0->get_height(); + register int surface_width = s0->m_width; + register int surface_height = s0->m_height; if (offset < 0 || offset > surface_width || y0 < 0 || y0 >= surface_height || y1 < 0 || y1 >= surface_height || x0 < 0 || x0 >= surface_width || x1 < 0 || x1 >= surface_width) { @@ -767,35 +731,18 @@ inline int c_display::swipe_surface(c_surface* s0, c_surface* s1, int x0, int x1 for (int y = y0; y <= y1; y++) { //Left surface - char* addr_s = ((char*)(s0->m_fb) + (y * (s0->get_width()) + x0 + offset) * m_color_bytes); + char* addr_s = ((char*)(s0->m_fb) + (y * surface_width + x0 + offset) * m_color_bytes); char* addr_d = ((char*)(m_phy_fb)+(y * m_width + x0) * m_color_bytes); memcpy(addr_d, addr_s, (width - offset) * m_color_bytes); //Right surface - addr_s = ((char*)(s1->m_fb) + (y * (s1->get_width()) + x0) * m_color_bytes); + addr_s = ((char*)(s1->m_fb) + (y * surface_width + x0) * m_color_bytes); addr_d = ((char*)(m_phy_fb)+(y * m_width + x0 + (width - offset)) * m_color_bytes); memcpy(addr_d, addr_s, offset * m_color_bytes); } } - else if (m_color_bytes == 4) - { - void(*draw_pixel)(int x, int y, unsigned int rgb) = ((c_surface_no_fb*)s0)->m_gfx_op->draw_pixel; - for (int y = y0; y <= y1; y++) - { - //Left surface - for (int x = x0; x <= (x1 - offset); x++) - { - draw_pixel(x, y, ((unsigned int*)s0->m_fb)[y * m_width + x + offset]); - } - //Right surface - for (int x = x1 - offset; x <= x1; x++) - { - draw_pixel(x, y, ((unsigned int*)s1->m_fb)[y * m_width + x + offset - x1 + x0]); - } - } - } else if (m_color_bytes == 2) { - void(*draw_pixel)(int x, int y, unsigned int rgb) = ((c_surface_no_fb*)s0)->m_gfx_op->draw_pixel; + void(*draw_pixel)(int x, int y, unsigned int rgb) = m_driver->draw_pixel; for (int y = y0; y <= y1; y++) { //Left surface @@ -810,6 +757,23 @@ inline int c_display::swipe_surface(c_surface* s0, c_surface* s1, int x0, int x1 } } } + else //m_color_bytes == 3/4... + { + void(*draw_pixel)(int x, int y, unsigned int rgb) = m_driver->draw_pixel; + for (int y = y0; y <= y1; y++) + { + //Left surface + for (int x = x0; x <= (x1 - offset); x++) + { + draw_pixel(x, y, ((unsigned int*)s0->m_fb)[y * m_width + x + offset]); + } + //Right surface + for (int x = x1 - offset; x <= x1; x++) + { + draw_pixel(x, y, ((unsigned int*)s1->m_fb)[y * m_width + x + offset - x1 + x0]); + } + } + } m_phy_write_index++; return 0; } @@ -3407,22 +3371,12 @@ private: #ifdef GUILITE_ON c_bitmap_operator the_bitmap_op = c_bitmap_operator(); c_image_operator* c_image::image_operator = &the_bitmap_op; +const void* c_theme::s_font_map[FONT_MAX]; +const void* c_theme::s_image_map[IMAGE_MAX]; +unsigned int c_theme::s_color_map[COLOR_MAX]; +c_lattice_font_op the_lattice_font_op = c_lattice_font_op(); +c_font_operator* c_word::fontOperator = &the_lattice_font_op; #endif - -#ifdef GUILITE_ON - -const void* c_theme::s_font_map[FONT_MAX]; -const void* c_theme::s_image_map[IMAGE_MAX]; -unsigned int c_theme::s_color_map[COLOR_MAX]; - -#endif - -#ifdef GUILITE_ON - -c_lattice_font_op the_lattice_font_op = c_lattice_font_op(); -c_font_operator* c_word::fontOperator = &the_lattice_font_op; - -#endif #ifdef GUILITE_ON #if (defined __linux__) || (defined __APPLE__) #include @@ -4264,11 +4218,7 @@ int c_fifo::write(void* buf, int len) #endif #ifdef GUILITE_ON DIALOG_ARRAY c_dialog::ms_the_dialogs[SURFACE_CNT_MAX]; -#endif -#ifdef GUILITE_ON c_keyboard c_edit::s_keyboard; -#endif -#ifdef GUILITE_ON static c_keyboard_button s_key_0, s_key_1, s_key_2, s_key_3, s_key_4, s_key_5, s_key_6, s_key_7, s_key_8, s_key_9; static c_keyboard_button s_key_A, s_key_B, s_key_C, s_key_D, s_key_E, s_key_F, s_key_G, s_key_H, s_key_I, s_key_J; static c_keyboard_button s_key_K, s_key_L, s_key_M, s_key_N, s_key_O, s_key_P, s_key_Q, s_key_R, s_key_S, s_key_T; @@ -4306,12 +4256,12 @@ WND_TREE g_key_board_children[] = {&s_key_B, 'B', 0, ((KEY_WIDTH / 2) + POS_X(5)), POS_Y(2), KEY_WIDTH, KEY_HEIGHT}, {&s_key_N, 'N', 0, ((KEY_WIDTH / 2) + POS_X(6)), POS_Y(2), KEY_WIDTH, KEY_HEIGHT}, {&s_key_M, 'M', 0, ((KEY_WIDTH / 2) + POS_X(7)), POS_Y(2), KEY_WIDTH, KEY_HEIGHT}, - {&s_key_del, 0x7F, 0, ((KEY_WIDTH / 2) + POS_X(8)), POS_Y(2), DEL_WIDTH, KEY_HEIGHT}, + {&s_key_del,0x7F, 0, ((KEY_WIDTH / 2) + POS_X(8)), POS_Y(2), DEL_WIDTH, KEY_HEIGHT}, //Row 4 - {&s_key_esc, 0x1B, 0, POS_X(0), POS_Y(3), ESC_WIDTH, KEY_HEIGHT}, + {&s_key_esc, 0x1B, 0, POS_X(0), POS_Y(3), ESC_WIDTH, KEY_HEIGHT}, {&s_key_num_switch, 0x90, 0, POS_X(2), POS_Y(3), SWITCH_WIDTH, KEY_HEIGHT}, {&s_key_space, ' ', 0, ((KEY_WIDTH / 2) + POS_X(3)), POS_Y(3), SPACE_WIDTH, KEY_HEIGHT}, - {&s_key_dot, '.', 0, ((KEY_WIDTH / 2) + POS_X(6)), POS_Y(3), DOT_WIDTH, KEY_HEIGHT}, + {&s_key_dot, '.', 0, ((KEY_WIDTH / 2) + POS_X(6)), POS_Y(3), DOT_WIDTH, KEY_HEIGHT}, {&s_key_enter, '\n', 0, POS_X(8), POS_Y(3), ENTER_WIDTH, KEY_HEIGHT}, {0,0,0,0,0,0,0} }; @@ -4326,12 +4276,11 @@ WND_TREE g_number_board_children[] = {&s_key_7, '7', 0, POS_X(0), POS_Y(2), KEY_WIDTH, KEY_HEIGHT}, {&s_key_8, '8', 0, POS_X(1), POS_Y(2), KEY_WIDTH, KEY_HEIGHT}, {&s_key_9, '9', 0, POS_X(2), POS_Y(2), KEY_WIDTH, KEY_HEIGHT}, - - {&s_key_esc, 0x1B, 0, POS_X(0), POS_Y(3), KEY_WIDTH, KEY_HEIGHT}, + {&s_key_esc,0x1B, 0, POS_X(0), POS_Y(3), KEY_WIDTH, KEY_HEIGHT}, {&s_key_0, '0', 0, POS_X(1), POS_Y(3), KEY_WIDTH, KEY_HEIGHT}, - {&s_key_dot, '.', 0, POS_X(2), POS_Y(3), KEY_WIDTH, KEY_HEIGHT}, + {&s_key_dot,'.', 0, POS_X(2), POS_Y(3), KEY_WIDTH, KEY_HEIGHT}, {&s_key_del, 0x7F, 0, POS_X(3), POS_Y(0), KEY_WIDTH, KEY_HEIGHT * 2 + 2}, {&s_key_enter,'\n', 0, POS_X(3), POS_Y(2), KEY_WIDTH, KEY_HEIGHT * 2 + 2}, {0,0,0,0,0,0,0} }; -#endif +#endif \ No newline at end of file diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 69a8f82..ea25b6c 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -12,8 +12,8 @@ ADD_DEFINITIONS(-DGUILITE_ON) FILE(GLOB CORE_SRC core/*.cpp) FILE(GLOB CORE_ADAPTER core/adapter/api_linux.cpp core/adapter/audio_linux.cpp) -# gui -FILE(GLOB WIDGETS_SRC widgets/*.cpp) +# widgets +FILE(GLOB WIDGETS_SRC widgets/*.cpp) # build static library ADD_LIBRARY(GuiLite STATIC ${CORE_SRC} ${CORE_ADAPTER} ${WIDGETS_SRC}) diff --git a/src/header-only.sh b/src/GenerateGuiLite.h.sh similarity index 70% rename from src/header-only.sh rename to src/GenerateGuiLite.h.sh index 14808c5..281dc76 100644 --- a/src/header-only.sh +++ b/src/GenerateGuiLite.h.sh @@ -1,42 +1,37 @@ echo "Build header-only library: GuiLite.h" # build GuiLiteRaw.h -cd core_include +cd core cat api.h resource.h theme.h display.h word.h image.h wnd.h > core.h mv core.h ../ +cd .. -cd ../widgets_include +cd widgets cat button.h dialog.h keyboard.h edit.h label.h list_box.h slide_group.h spinbox.h table.h wave_buffer.h wave_ctrl.h > widgets.h mv widgets.h ../ - cd .. + cat core.h widgets.h > GuiLiteRaw.h # build GuiLiteRaw.cpp -cd core -cat *.cpp > core.cpp -mv core.cpp ../ +cp core/core.cpp ./ +cp widgets/widgets.cpp ./ -cd adapter +cd core/adapter cat *.cpp > adapter.cpp mv adapter.cpp ../../ +cd ../.. -cd ../../widgets -cat *.cpp > widgets.cpp -mv widgets.cpp ../ - -cd .. cat core.cpp adapter.cpp widgets.cpp > GuiLiteRaw.cpp - -# remove include core_include widgets_include from GuiLiteRaw.h -sed -i '/^#include.*core_include\|widgets_include.*/d' GuiLiteRaw.h +# remove include core widgets from GuiLiteRaw.h +sed -i '/^#include.*core\|widgets.*/d' GuiLiteRaw.h # remove all #pragma once sed -i '/^#pragma once/d' GuiLiteRaw.h # add #pragma once for 1st line sed -i '1 s/^/#pragma once\n/' GuiLiteRaw.h -# remove include core_include widgets_include from GuiLiteRaw.cpp -sed -i '/^#include.*core_include\|widgets_include.*/d' GuiLiteRaw.cpp +# remove include core widgets from GuiLiteRaw.cpp +sed -i '/^#include.*core\|widgets.*/d' GuiLiteRaw.cpp # Delete empty lines or blank lines sed '/^$/d' GuiLiteRaw.h > GuiLite.h @@ -52,7 +47,7 @@ gcc -c -D GUILITE_ON test.cpp mv GuiLite.h ../ echo "Done!" echo "You could find GuiLite.h in root folder" -./.sync.sh GuiLite-header # clean rm *.h *.cpp *.o +./.sync.sh GuiLite-header diff --git a/src/Gradle/.gitattributes b/src/Gradle/.gitattributes deleted file mode 100644 index 00a51af..0000000 --- a/src/Gradle/.gitattributes +++ /dev/null @@ -1,6 +0,0 @@ -# -# https://help.github.com/articles/dealing-with-line-endings/ -# -# These are explicitly windows files and should use crlf -*.bat text eol=crlf - diff --git a/src/Gradle/.gitignore b/src/Gradle/.gitignore deleted file mode 100644 index cef173b..0000000 --- a/src/Gradle/.gitignore +++ /dev/null @@ -1,10 +0,0 @@ -# Ignore Gradle project-specific cache directory -.gradle - -# Ignore Gradle build output directory -build - -# Ignore IDEA project-specific configuration directory -.idea - -.DS_Store diff --git a/src/Gradle/README.md b/src/Gradle/README.md deleted file mode 100644 index 1dea772..0000000 --- a/src/Gradle/README.md +++ /dev/null @@ -1,24 +0,0 @@ -## 使用Gradle编译Guilite ### - -* ### Windows平台: ### - * 兼容VS各大版本,自动选择最新版本。 - * 兼容Cygwin或MinGW,确保gcc在path中。目前不支持Clang。 - * 按`win+R`输入`cmd`打开命令行运行:`g++ -v`,有打印出版本则正常。 - * 编译Guilite: - ```powershell - cd $GUILITE\workspace\Gradle\ - gradlew produce - ``` - * 输出位置:$GRADLE\build\lib\main\release\shared(static)\ - -* ### Linux和Mac平台: ### - * 将使用系统PATH发现GCC或Clang,请确保已经安装GCC或Clang。 - * 打开终端运行:`g++ -v`,有打印出版本则正常。 - * 编译Guilite: - ```shell - cd $GUILITE/workspace/Gradle/ - gradlew produce - ``` - * 输出位置:$GRADLE/build/lib/main/release/shared(static)/ - -对单片机系统不了解,未支持! \ No newline at end of file diff --git a/src/Gradle/build.gradle b/src/Gradle/build.gradle deleted file mode 100644 index 59bfcc3..0000000 --- a/src/Gradle/build.gradle +++ /dev/null @@ -1,36 +0,0 @@ -plugins { - id("org.gradle.cpp-library") -} - -library { - /** - * Gradle stipulates that the source directory is: $project/src/main/cpp/, - * specifies the `.cpp` source file directory according to the project. - * */ - source.from( - "../core", - "../widgets" - ) - /** - * Gradle conventions the header file directory is: $project/src/main/headers/, - * specify the `.h` header file directory according to the project. - */ - privateHeaders.from( - "../core_include", - "../widgets_include" - ) - /** - * Gradle only exports shared libraries(dynamic libraries) by default, - * adds support for static libraries. - * */ - linkage.add(Linkage.STATIC) -} -/** - * Compile tasks for custom release type dynamic and static libraries - * */ -tasks.register("produce") { - dependsOn( - "assembleReleaseShared", - "assembleReleaseStatic" - ) -} diff --git a/src/Gradle/gradle/wrapper/gradle-wrapper.jar b/src/Gradle/gradle/wrapper/gradle-wrapper.jar deleted file mode 100644 index f3d88b1..0000000 Binary files a/src/Gradle/gradle/wrapper/gradle-wrapper.jar and /dev/null differ diff --git a/src/Gradle/gradle/wrapper/gradle-wrapper.properties b/src/Gradle/gradle/wrapper/gradle-wrapper.properties deleted file mode 100644 index 5b13956..0000000 --- a/src/Gradle/gradle/wrapper/gradle-wrapper.properties +++ /dev/null @@ -1,6 +0,0 @@ -#Thu Jan 23 20:09:34 CST 2020 -distributionUrl=https\://services.gradle.org/distributions/gradle-6.1-all.zip -distributionBase=GRADLE_USER_HOME -distributionPath=wrapper/dists -zipStorePath=wrapper/dists -zipStoreBase=GRADLE_USER_HOME diff --git a/src/Gradle/gradlew b/src/Gradle/gradlew deleted file mode 100644 index 2fe81a7..0000000 --- a/src/Gradle/gradlew +++ /dev/null @@ -1,183 +0,0 @@ -#!/usr/bin/env sh - -# -# Copyright 2015 the original author or authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -############################################################################## -## -## Gradle start up script for UN*X -## -############################################################################## - -# Attempt to set APP_HOME -# Resolve links: $0 may be a link -PRG="$0" -# Need this for relative symlinks. -while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG=`dirname "$PRG"`"/$link" - fi -done -SAVED="`pwd`" -cd "`dirname \"$PRG\"`/" >/dev/null -APP_HOME="`pwd -P`" -cd "$SAVED" >/dev/null - -APP_NAME="Gradle" -APP_BASE_NAME=`basename "$0"` - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' - -# Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD="maximum" - -warn () { - echo "$*" -} - -die () { - echo - echo "$*" - echo - exit 1 -} - -# OS specific support (must be 'true' or 'false'). -cygwin=false -msys=false -darwin=false -nonstop=false -case "`uname`" in - CYGWIN* ) - cygwin=true - ;; - Darwin* ) - darwin=true - ;; - MINGW* ) - msys=true - ;; - NONSTOP* ) - nonstop=true - ;; -esac - -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar - -# Determine the Java command to use to start the JVM. -if [ -n "$JAVA_HOME" ] ; then - if [ -x "$JAVA_HOME/jre/sh/java" ] ; then - # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" - else - JAVACMD="$JAVA_HOME/bin/java" - fi - if [ ! -x "$JAVACMD" ] ; then - die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." - fi -else - JAVACMD="java" - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." -fi - -# Increase the maximum file descriptors if we can. -if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then - MAX_FD_LIMIT=`ulimit -H -n` - if [ $? -eq 0 ] ; then - if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then - MAX_FD="$MAX_FD_LIMIT" - fi - ulimit -n $MAX_FD - if [ $? -ne 0 ] ; then - warn "Could not set maximum file descriptor limit: $MAX_FD" - fi - else - warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" - fi -fi - -# For Darwin, add options to specify how the application appears in the dock -if $darwin; then - GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" -fi - -# For Cygwin or MSYS, switch paths to Windows format before running java -if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then - APP_HOME=`cygpath --path --mixed "$APP_HOME"` - CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` - JAVACMD=`cygpath --unix "$JAVACMD"` - - # We build the pattern for arguments to be converted via cygpath - ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` - SEP="" - for dir in $ROOTDIRSRAW ; do - ROOTDIRS="$ROOTDIRS$SEP$dir" - SEP="|" - done - OURCYGPATTERN="(^($ROOTDIRS))" - # Add a user-defined pattern to the cygpath arguments - if [ "$GRADLE_CYGPATTERN" != "" ] ; then - OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" - fi - # Now convert the arguments - kludge to limit ourselves to /bin/sh - i=0 - for arg in "$@" ; do - CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` - CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option - - if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition - eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` - else - eval `echo args$i`="\"$arg\"" - fi - i=`expr $i + 1` - done - case $i in - 0) set -- ;; - 1) set -- "$args0" ;; - 2) set -- "$args0" "$args1" ;; - 3) set -- "$args0" "$args1" "$args2" ;; - 4) set -- "$args0" "$args1" "$args2" "$args3" ;; - 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; - 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; - 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; - 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; - 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; - esac -fi - -# Escape application args -save () { - for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done - echo " " -} -APP_ARGS=`save "$@"` - -# Collect all arguments for the java command, following the shell quoting and substitution rules -eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" - -exec "$JAVACMD" "$@" diff --git a/src/Gradle/gradlew.bat b/src/Gradle/gradlew.bat deleted file mode 100644 index 9618d8d..0000000 --- a/src/Gradle/gradlew.bat +++ /dev/null @@ -1,100 +0,0 @@ -@rem -@rem Copyright 2015 the original author or authors. -@rem -@rem Licensed under the Apache License, Version 2.0 (the "License"); -@rem you may not use this file except in compliance with the License. -@rem You may obtain a copy of the License at -@rem -@rem https://www.apache.org/licenses/LICENSE-2.0 -@rem -@rem Unless required by applicable law or agreed to in writing, software -@rem distributed under the License is distributed on an "AS IS" BASIS, -@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -@rem See the License for the specific language governing permissions and -@rem limitations under the License. -@rem - -@if "%DEBUG%" == "" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto init - -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto init - -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:init -@rem Get command-line arguments, handling Windows variants - -if not "%OS%" == "Windows_NT" goto win9xME_args - -:win9xME_args -@rem Slurp the command line arguments. -set CMD_LINE_ARGS= -set _SKIP=2 - -:win9xME_args_slurp -if "x%~1" == "x" goto execute - -set CMD_LINE_ARGS=%* - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% - -:end -@rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega diff --git a/src/Gradle/settings.gradle b/src/Gradle/settings.gradle deleted file mode 100644 index 5213c71..0000000 --- a/src/Gradle/settings.gradle +++ /dev/null @@ -1 +0,0 @@ -rootProject.name = "GuiLite" diff --git a/src/GuiLite.uvprojx b/src/GuiLite.uvprojx index 9723acd..67b5cc4 100644 --- a/src/GuiLite.uvprojx +++ b/src/GuiLite.uvprojx @@ -382,35 +382,15 @@ core - - display.cpp - 8 - .\core\display.cpp - - - theme.cpp - 8 - .\core\theme.cpp - - - wnd.cpp - 8 - .\core\wnd.cpp - - - word.cpp - 8 - .\core\word.cpp - api_unknow.cpp 8 .\core\adapter\api_unknow.cpp - image.cpp + core.cpp 8 - .\core\image.cpp + .\core\core.cpp @@ -418,24 +398,9 @@ widgets - button.cpp + widgets.cpp 8 - .\widgets\button.cpp - - - label.cpp - 8 - .\widgets\label.cpp - - - wave_buffer.cpp - 8 - .\widgets\wave_buffer.cpp - - - wave_ctrl.cpp - 8 - .\widgets\wave_ctrl.cpp + .\widgets\widgets.cpp diff --git a/src/GuiLite.vcxproj b/src/GuiLite.vcxproj index 161a405..1ffbfd4 100644 --- a/src/GuiLite.vcxproj +++ b/src/GuiLite.vcxproj @@ -182,7 +182,8 @@ %(AdditionalOptions) /machine:X64 - call "$(SolutionDir)sync_build.bat" "GuiLite" + + @@ -389,22 +390,28 @@ - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/GuiLite.vcxproj.filters b/src/GuiLite.vcxproj.filters index f78d165..5a8c3d8 100644 --- a/src/GuiLite.vcxproj.filters +++ b/src/GuiLite.vcxproj.filters @@ -1,55 +1,13 @@  - + widgets - - widgets - - - widgets - - - widgets - - - widgets - - - widgets - - - widgets - - - widgets - - - widgets - - - widgets - - - widgets - - - core - - - core - - - core - - - core - core\adapter - + core @@ -64,4 +22,60 @@ {691801eb-7076-4af6-aa0c-5ce5b0fcb21c} + + + core + + + core + + + core + + + core + + + core + + + core + + + core + + + widgets + + + widgets + + + widgets + + + widgets + + + widgets + + + widgets + + + widgets + + + widgets + + + widgets + + + widgets + + + widgets + + \ No newline at end of file diff --git a/src/core/adapter/api_linux.cpp b/src/core/adapter/api_linux.cpp index 0a3df41..aa993fa 100644 --- a/src/core/adapter/api_linux.cpp +++ b/src/core/adapter/api_linux.cpp @@ -1,7 +1,7 @@ #ifdef GUILITE_ON #if (defined __linux__) || (defined __APPLE__) -#include "../../core_include/api.h" +#include "../../core/api.h" #include #include #include diff --git a/src/core/adapter/api_unknow.cpp b/src/core/adapter/api_unknow.cpp index 6b84011..feefc7b 100644 --- a/src/core/adapter/api_unknow.cpp +++ b/src/core/adapter/api_unknow.cpp @@ -1,7 +1,7 @@ #ifdef GUILITE_ON #if (!defined _WIN32) && (!defined WIN32) && (!defined _WIN64) && (!defined WIN64) && (!defined __linux__) && (!defined __APPLE__) -#include "../../core_include/api.h" +#include "../../core/api.h" #include static void(*do_assert)(const char* file, int line); diff --git a/src/core/adapter/api_win.cpp b/src/core/adapter/api_win.cpp index 4d9b970..07beb7f 100644 --- a/src/core/adapter/api_win.cpp +++ b/src/core/adapter/api_win.cpp @@ -1,7 +1,7 @@ #ifdef GUILITE_ON #if (defined _WIN32) || (defined WIN32) || (defined _WIN64) || (defined WIN64) -#include "../../core_include/api.h" +#include "../../core/api.h" #include #include #include diff --git a/src/core_include/api.h b/src/core/api.h similarity index 96% rename from src/core_include/api.h rename to src/core/api.h index 36ce38b..23e12cd 100644 --- a/src/core_include/api.h +++ b/src/core/api.h @@ -1,104 +1,104 @@ -#pragma once - -#define REAL_TIME_TASK_CYCLE_MS 50 -#define MAX(a,b) (((a)>(b))?(a):(b)) -#define MIN(a,b) (((a)<(b))?(a):(b)) - -#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* param), void* param); - -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; -}; - -class c_rect -{ -public: - c_rect(){ m_left = m_top = m_right = m_bottom = -1; } - c_rect(int left, int top, int width, int height) - { - set_rect(left, top, width, height); - } - void set_rect(int left, int top, int width, int height) - { - ASSERT(width > 0 && height > 0); - m_left = left; - m_top = top; - m_right = left + width - 1; - m_bottom = top + height -1; - } - bool pt_in_rect(int x, int y) const - { - return x >= m_left && x <= m_right && y >= m_top && y <= m_bottom; - } - int operator==(const c_rect& rect) const - { - return (m_left == rect.m_left) && (m_top == rect.m_top) && (m_right == rect.m_right) && (m_bottom == rect.m_bottom); - } - 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; -}; +#pragma once + +#define REAL_TIME_TASK_CYCLE_MS 50 +#define MAX(a,b) (((a)>(b))?(a):(b)) +#define MIN(a,b) (((a)<(b))?(a):(b)) + +#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* param), void* param); + +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; +}; + +class c_rect +{ +public: + c_rect(){ m_left = m_top = m_right = m_bottom = -1; } + c_rect(int left, int top, int width, int height) + { + set_rect(left, top, width, height); + } + void set_rect(int left, int top, int width, int height) + { + ASSERT(width > 0 && height > 0); + m_left = left; + m_top = top; + m_right = left + width - 1; + m_bottom = top + height -1; + } + bool pt_in_rect(int x, int y) const + { + return x >= m_left && x <= m_right && y >= m_top && y <= m_bottom; + } + int operator==(const c_rect& rect) const + { + return (m_left == rect.m_left) && (m_top == rect.m_top) && (m_right == rect.m_right) && (m_bottom == rect.m_bottom); + } + 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; +}; diff --git a/src/core/core.cpp b/src/core/core.cpp new file mode 100644 index 0000000..9c18447 --- /dev/null +++ b/src/core/core.cpp @@ -0,0 +1,17 @@ +#include "../core/display.h" +#include "../core//image.h" +#include "../core/theme.h" +#include "../core/wnd.h" +#include "../core/word.h" + +#ifdef GUILITE_ON +c_bitmap_operator the_bitmap_op = c_bitmap_operator(); +c_image_operator* c_image::image_operator = &the_bitmap_op; + +const void* c_theme::s_font_map[FONT_MAX]; +const void* c_theme::s_image_map[IMAGE_MAX]; +unsigned int c_theme::s_color_map[COLOR_MAX]; + +c_lattice_font_op the_lattice_font_op = c_lattice_font_op(); +c_font_operator* c_word::fontOperator = &the_lattice_font_op; +#endif diff --git a/src/core/display.cpp b/src/core/display.cpp deleted file mode 100644 index 6da8ac3..0000000 --- a/src/core/display.cpp +++ /dev/null @@ -1 +0,0 @@ -#include "../core_include/display.h" diff --git a/src/core_include/display.h b/src/core/display.h similarity index 63% rename from src/core_include/display.h rename to src/core/display.h index dad6889..54b8b2f 100644 --- a/src/core_include/display.h +++ b/src/core/display.h @@ -1,6 +1,6 @@ #pragma once -#include "../core_include/api.h" +#include "../core/api.h" #include #include #include @@ -15,7 +15,7 @@ typedef enum Z_ORDER_LEVEL_MAX }Z_ORDER_LEVEL; -struct EXTERNAL_GFX_OP +struct DISPLAY_DRIVER { void(*draw_pixel)(int x, int y, unsigned int rgb); void(*fill_rect)(int x0, int y0, int x1, int y1, unsigned int rgb); @@ -25,19 +25,20 @@ class c_surface; class c_display { friend class c_surface; public: - inline c_display(void* phy_fb, int display_width, int display_height, int surface_width, int surface_height, unsigned int color_bytes, int surface_cnt, EXTERNAL_GFX_OP* gfx_op = 0);//multiple surface or surface_no_fb - inline c_display(void* phy_fb, int display_width, int display_height, c_surface* surface);//single custom surface - inline c_surface* alloc_surface(Z_ORDER_LEVEL max_zorder, c_rect layer_rect = c_rect());//for multiple surfaces + inline c_display(void* phy_fb, int display_width, int display_height, c_surface* surface, DISPLAY_DRIVER* driver = 0);//single custom surface + inline c_display(void* phy_fb, int display_width, int display_height, int surface_width, int surface_height, unsigned int color_bytes, int surface_cnt, DISPLAY_DRIVER* driver = 0);//multiple surface + inline c_surface* alloc_surface(Z_ORDER_LEVEL max_zorder, c_rect layer_rect = c_rect());//for slide group inline int swipe_surface(c_surface* s0, c_surface* s1, int x0, int x1, int y0, int y1, int offset); int get_width() { return m_width; } int get_height() { return m_height; } + void* get_phy_fb() { return m_phy_fb; } void* get_updated_fb(int* width, int* height, bool force_update = false) { if (width && height) { - *width = get_width(); - *height = get_height(); + *width = m_width; + *height = m_height; } if (force_update) { @@ -58,40 +59,138 @@ public: return -1; } - int width = get_width(); - int height = get_height(); - //16 bits framebuffer if (m_color_bytes == 2) { - return build_bmp(file_name, width, height, (unsigned char*)m_phy_fb); + return build_bmp(file_name, m_width, m_height, (unsigned char*)m_phy_fb); } //32 bits framebuffer - unsigned short* p_bmp565_data = new unsigned short[width * height]; + unsigned short* p_bmp565_data = new unsigned short[m_width * m_height]; unsigned int* p_raw_data = (unsigned int*)m_phy_fb; - for (int i = 0; i < width * height; i++) + for (int i = 0; i < m_width * m_height; i++) { unsigned int rgb = *p_raw_data++; p_bmp565_data[i] = GL_RGB_32_to_16(rgb); } - int ret = build_bmp(file_name, width, height, (unsigned char*)p_bmp565_data); + int ret = build_bmp(file_name, m_width, m_height, (unsigned char*)p_bmp565_data); delete[]p_bmp565_data; return ret; } -private: - int m_width; //in pixels - int m_height; //in pixels - int m_color_bytes; //16 bits, 32 bits only - void* m_phy_fb; //physical framebuffer +protected: + virtual void draw_pixel(int x, int y, unsigned int rgb) + { + if ((x >= m_width) || (y >= m_height)) { return; } + + if (m_driver && m_driver->draw_pixel) + { + return m_driver->draw_pixel(x, y, rgb); + } + + if (m_color_bytes == 2) + { + ((unsigned short*)m_phy_fb)[y * m_width + x] = GL_RGB_32_to_16(rgb); + } + else + { + ((unsigned int*)m_phy_fb)[y * m_width + x] = rgb; + } + } + + virtual void fill_rect(int x0, int y0, int x1, int y1, unsigned int rgb) + { + if (m_driver && m_driver->fill_rect) + { + return m_driver->fill_rect(x0, y0, x1, y1, rgb); + } + + if (m_driver && m_driver->draw_pixel) + { + for (int y = y0; y <= y1; y++) + { + for (int x = x0; x <= x1; x++) + { + m_driver->draw_pixel(x, y, rgb); + } + } + return; + } + + register int _width = m_width; + register int _height = m_height; + int x, y; + if (m_color_bytes == 2) + { + unsigned short* phy_fb; + unsigned int rgb_16 = GL_RGB_32_to_16(rgb); + for (y = y0; y <= y1; y++) + { + phy_fb = &((unsigned short*)m_phy_fb)[y * _width + x0]; + for (x = x0; x <= x1; x++) + { + if ((x < _width) && (y < _height)) + { + *phy_fb++ = rgb_16; + } + } + } + } + else + { + unsigned int* phy_fb; + for (y = y0; y <= y1; y++) + { + phy_fb = &((unsigned int*)m_phy_fb)[y * _width + x0]; + for (x = x0; x <= x1; x++) + { + if ((x < _width) && (y < _height)) + { + *phy_fb++ = rgb; + } + } + } + } + } + + virtual int flush_screen(int left, int top, int right, int bottom, void* fb, int fb_width) + { + if ((0 == m_phy_fb) || (0 == fb)) + { + return -1; + } + + register int _width = m_width; + register int _height = m_height; + + left = (left >= _width) ? (_width - 1) : left; + right = (right >= _width) ? (_width - 1) : right; + top = (top >= _height) ? (_height - 1) : top; + bottom = (bottom >= _height) ? (_height - 1) : bottom; + + for (int y = top; y < bottom; y++) + { + void* s_addr = (char*)fb + ((y * fb_width + left) * m_color_bytes); + void* d_addr = (char*)m_phy_fb + ((y * _width + left) * m_color_bytes); + memcpy(d_addr, s_addr, (right - left) * m_color_bytes); + } + return 0; + } + + int m_width; //in pixels + int m_height; //in pixels + int m_color_bytes; //16/32 bits for default + void* m_phy_fb; //physical framebuffer for default + struct DISPLAY_DRIVER* m_driver; //Rendering by external method without default physical framebuffer + int m_phy_read_index; int m_phy_write_index; c_surface* m_surface_group[SURFACE_CNT_MAX]; int m_surface_cnt; //surface count int m_surface_index; + }; class c_layer @@ -105,14 +204,11 @@ public: class c_surface { friend class c_display; friend class c_bitmap_operator; public: - c_surface(unsigned int width, unsigned int height, unsigned int color_bytes, Z_ORDER_LEVEL max_zorder = Z_ORDER_LEVEL_0, c_rect overlpa_rect = c_rect()) : m_width(width), m_height(height), m_color_bytes(color_bytes), m_fb(0), m_is_active(false), m_top_zorder(Z_ORDER_LEVEL_0), m_phy_fb(0), m_phy_write_index(0), m_display(0) + c_surface(unsigned int width, unsigned int height, unsigned int color_bytes, Z_ORDER_LEVEL max_zorder = Z_ORDER_LEVEL_0, c_rect overlpa_rect = c_rect()) : m_width(width), m_height(height), m_color_bytes(color_bytes), m_fb(0), m_is_active(false), m_top_zorder(Z_ORDER_LEVEL_0), m_phy_write_index(0), m_display(0) { (overlpa_rect == c_rect()) ? set_surface(max_zorder, c_rect(0, 0, width - 1, height - 1)) : set_surface(max_zorder, overlpa_rect); } - int get_width() { return m_width; } - int get_height() { return m_height; } - unsigned int get_pixel(int x, int y, unsigned int z_order) { if (x >= m_width || y >= m_height || x < 0 || y < 0 || z_order >= Z_ORDER_LEVEL_MAX) @@ -122,15 +218,15 @@ public: } if (m_layers[z_order].fb) { - return (m_color_bytes == 4) ? ((unsigned int*)(m_layers[z_order].fb))[y * m_width + x] : GL_RGB_16_to_32(((unsigned short*)(m_layers[z_order].fb))[y * m_width + x]); + return (m_color_bytes == 2) ? GL_RGB_16_to_32(((unsigned short*)(m_layers[z_order].fb))[y * m_width + x]) : ((unsigned int*)(m_layers[z_order].fb))[y * m_width + x]; } else if (m_fb) { - return (m_color_bytes == 4) ? ((unsigned int*)m_fb)[y * m_width + x] : GL_RGB_16_to_32(((unsigned short*)m_fb)[y * m_width + x]); + return (m_color_bytes == 2) ? GL_RGB_16_to_32(((unsigned short*)m_fb)[y * m_width + x]) : ((unsigned int*)m_fb)[y * m_width + x]; } - else if (m_phy_fb) + else if (m_display->m_phy_fb) { - return (m_color_bytes == 4) ? ((unsigned int*)m_phy_fb)[y * m_width + x] : GL_RGB_16_to_32(((unsigned short*)m_phy_fb)[y * m_width + x]); + return (m_color_bytes == 2) ? GL_RGB_16_to_32(((unsigned short*)m_display->m_phy_fb)[y * m_width + x]) : ((unsigned int*)m_display->m_phy_fb)[y * m_width + x]; } return 0; } @@ -149,7 +245,7 @@ public: if (z_order == m_max_zorder) { - return draw_pixel_on_fb(x, y, rgb); + return draw_pixel_low_level(x, y, rgb); } if (z_order > (unsigned int)m_top_zorder) @@ -160,19 +256,19 @@ public: if (m_layers[z_order].rect.pt_in_rect(x, y)) { c_rect layer_rect = m_layers[z_order].rect; - if (m_color_bytes == 4) + if (m_color_bytes == 2) { - ((unsigned int*)(m_layers[z_order].fb))[(x - layer_rect.m_left) + (y - layer_rect.m_top) * layer_rect.width()] = rgb; + ((unsigned short*)(m_layers[z_order].fb))[(x - layer_rect.m_left) + (y - layer_rect.m_top) * layer_rect.width()] = GL_RGB_32_to_16(rgb); } else { - ((unsigned short*)(m_layers[z_order].fb))[(x - layer_rect.m_left) + (y - layer_rect.m_top) * layer_rect.width()] = GL_RGB_32_to_16(rgb); + ((unsigned int*)(m_layers[z_order].fb))[(x - layer_rect.m_left) + (y - layer_rect.m_top) * layer_rect.width()] = rgb; } } if (z_order == m_top_zorder) { - return draw_pixel_on_fb(x, y, rgb); + return draw_pixel_low_level(x, y, rgb); } bool be_overlapped = false; @@ -187,7 +283,7 @@ public: if (!be_overlapped) { - draw_pixel_on_fb(x, y, rgb); + draw_pixel_low_level(x, y, rgb); } } @@ -200,7 +296,7 @@ public: if (z_order == m_max_zorder) { - return fill_rect_on_fb(x0, y0, x1, y1, rgb); + return fill_rect_low_level(x0, y0, x1, y1, rgb); } if (z_order == m_top_zorder) @@ -214,18 +310,18 @@ public: { if (layer_rect.pt_in_rect(x, y)) { - if (m_color_bytes == 4) + if (m_color_bytes == 2) { - ((unsigned int*)m_layers[z_order].fb)[(y - layer_rect.m_top) * layer_rect.width() + (x - layer_rect.m_left)] = rgb; + ((unsigned short*)m_layers[z_order].fb)[(y - layer_rect.m_top) * layer_rect.width() + (x - layer_rect.m_left)] = rgb_16; } else { - ((unsigned short*)m_layers[z_order].fb)[(y - layer_rect.m_top) * layer_rect.width() + (x - layer_rect.m_left)] = rgb_16; + ((unsigned int*)m_layers[z_order].fb)[(y - layer_rect.m_top) * layer_rect.width() + (x - layer_rect.m_left)] = rgb; } } } } - return fill_rect_on_fb(x0, y0, x1, y1, rgb); + return fill_rect_low_level(x0, y0, x1, y1, rgb); } for (; y0 <= y1; y0++) @@ -308,31 +404,18 @@ public: int flush_screen(int left, int top, int right, int bottom) { + if (!m_is_active) + { + return -1; + } + if (left < 0 || left >= m_width || right < 0 || right >= m_width || top < 0 || top >= m_height || bottom < 0 || bottom >= m_height) { ASSERT(false); } - if (!m_is_active || (0 == m_phy_fb) || (0 == m_fb)) - { - return -1; - } - - int display_width = m_display->get_width(); - int display_height = m_display->get_height(); - - left = (left >= display_width) ? (display_width - 1) : left; - right = (right >= display_width) ? (display_width - 1) : right; - top = (top >= display_height) ? (display_height - 1) : top; - bottom = (bottom >= display_height) ? (display_height - 1) : bottom; - - for (int y = top; y < bottom; y++) - { - void* s_addr = (char*)m_fb + ((y * m_width + left) * m_color_bytes); - void* d_addr = (char*)m_phy_fb + ((y * display_width + left) * m_color_bytes); - memcpy(d_addr, s_addr, (right - left) * m_color_bytes); - } + m_display->flush_screen(left, top, right, bottom, m_fb, m_width); *m_phy_write_index = *m_phy_write_index + 1; return 0; } @@ -354,94 +437,65 @@ public: { for (int x = rect.m_left; x <= rect.m_right; x++) { - unsigned int rgb = (m_color_bytes == 4) ? ((unsigned int*)fb)[(x - layer_rect.m_left) + (y - layer_rect.m_top) * width] : GL_RGB_16_to_32(((unsigned short*)fb)[(x - layer_rect.m_left) + (y - layer_rect.m_top) * width]); - draw_pixel_on_fb(x, y, rgb); + unsigned int rgb = (m_color_bytes == 2) ? GL_RGB_16_to_32(((unsigned short*)fb)[(x - layer_rect.m_left) + (y - layer_rect.m_top) * width]) : ((unsigned int*)fb)[(x - layer_rect.m_left) + (y - layer_rect.m_top) * width]; + draw_pixel_low_level(x, y, rgb); } } return 0; } 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) - { - int display_width = m_display->get_width(); - int display_height = m_display->get_height(); + virtual void fill_rect_low_level(int x0, int y0, int x1, int y1, unsigned int rgb) + {//fill rect on framebuffer of surface + int x, y; + if (m_color_bytes == 2) + { + unsigned short* fb; + unsigned int rgb_16 = GL_RGB_32_to_16(rgb); + for (y = y0; y <= y1; y++) + { + fb = m_fb ? &((unsigned short*)m_fb)[y * m_width + x0] : 0; + if (!fb) { break; } + for (x = x0; x <= x1; x++) + { + *fb++ = rgb_16; + } + } + } + else + { + unsigned int* fb; + for (y = y0; y <= y1; y++) + { + fb = m_fb ? &((unsigned int*)m_fb)[y * m_width + x0] : 0; + if (!fb) { break; } + for (x = x0; x <= x1; x++) + { + *fb++ = rgb; + } + } + } - if (m_color_bytes == 4) - { - int x; - unsigned int* fb, * phy_fb; - for (; y0 <= y1; y0++) - { - x = x0; - fb = m_fb ? &((unsigned int*)m_fb)[y0 * m_width + x] : 0; - phy_fb = &((unsigned int*)m_phy_fb)[y0 * display_width + x]; - *m_phy_write_index = *m_phy_write_index + 1; - for (; x <= x1; x++) - { - if (fb) - { - *fb++ = rgb; - } - if (m_is_active && (x < display_width) && (y0 < display_height)) - { - *phy_fb++ = rgb; - } - } - } - } - else if (m_color_bytes == 2) - { - int x; - unsigned short* fb, * phy_fb; - rgb = GL_RGB_32_to_16(rgb); - for (; y0 <= y1; y0++) - { - x = x0; - fb = m_fb ? &((unsigned short*)m_fb)[y0 * m_width + x] : 0; - phy_fb = &((unsigned short*)m_phy_fb)[y0 * display_width + x]; - *m_phy_write_index = *m_phy_write_index + 1; - for (; x <= x1; x++) - { - if (fb) - { - *fb++ = rgb; - } - if (m_is_active && (x < display_width) && (y0 < display_height)) - { - *phy_fb++ = rgb; - } - } - } - } + if (!m_is_active) { return; } + m_display->fill_rect(x0, y0, x1, y1, rgb); + *m_phy_write_index = *m_phy_write_index + 1; } - virtual void draw_pixel_on_fb(int x, int y, unsigned int rgb) + virtual void draw_pixel_low_level(int x, int y, unsigned int rgb) { if (m_fb) - { - (m_color_bytes == 4) ? ((unsigned int*)m_fb)[y * m_width + x] = rgb : ((unsigned short*)m_fb)[y * m_width + x] = GL_RGB_32_to_16(rgb); - } - - if (m_is_active && (x < m_display->get_width()) && (y < m_display->get_height())) - { - if (m_color_bytes == 4) - { - ((unsigned int*)m_phy_fb)[y * (m_display->get_width()) + x] = rgb; - } - else - { - ((unsigned short*)m_phy_fb)[y * (m_display->get_width()) + x] = GL_RGB_32_to_16(rgb); - } - *m_phy_write_index = *m_phy_write_index + 1; + {//draw pixel on framebuffer of surface + (m_color_bytes == 2) ? ((unsigned short*)m_fb)[y * m_width + x] = GL_RGB_32_to_16(rgb): ((unsigned int*)m_fb)[y * m_width + x] = rgb; } + if (!m_is_active) { return; } + m_display->draw_pixel(x, y, rgb); + *m_phy_write_index = *m_phy_write_index + 1; } void attach_display(c_display* display) { ASSERT(display); m_display = display; - m_phy_fb = display->m_phy_fb; m_phy_write_index = &display->m_phy_write_index; } @@ -462,93 +516,24 @@ protected: int m_width; //in pixels int m_height; //in pixels - int m_color_bytes; //16 bits, 32 bits only + int m_color_bytes; //16 bits, 32 bits for default void* m_fb; //frame buffer you could see c_layer m_layers[Z_ORDER_LEVEL_MAX];//all graphic layers bool m_is_active; //active flag Z_ORDER_LEVEL m_max_zorder; //the highest graphic layer the surface will have Z_ORDER_LEVEL m_top_zorder; //the current highest graphic layer the surface have - void* m_phy_fb; //physical framebufer int* m_phy_write_index; c_display* m_display; }; -class c_surface_no_fb : public c_surface {//No physical framebuffer, render with external graphic interface - friend class c_display; -public: - c_surface_no_fb(unsigned int width, unsigned int height, unsigned int color_bytes, struct EXTERNAL_GFX_OP* gfx_op, Z_ORDER_LEVEL max_zorder = Z_ORDER_LEVEL_0, c_rect overlpa_rect = c_rect()) : c_surface(width, height, color_bytes, max_zorder, overlpa_rect), m_gfx_op(gfx_op) {} -protected: - virtual void fill_rect_on_fb(int x0, int y0, int x1, int y1, unsigned int rgb) - { - if (!m_gfx_op) - { - return; - } - if (m_gfx_op->fill_rect) - { - return m_gfx_op->fill_rect(x0, y0, x1, y1, rgb); - } +inline c_display::c_display(void* phy_fb, int display_width, int display_height, c_surface* surface, DISPLAY_DRIVER* driver) : m_phy_fb(phy_fb), m_width(display_width), m_height(display_height), m_driver(driver), m_phy_read_index(0), m_phy_write_index(0), m_surface_cnt(1), m_surface_index(0) +{ + m_color_bytes = surface->m_color_bytes; + surface->m_is_active = true; + (m_surface_group[0] = surface)->attach_display(this); +} - if (m_gfx_op->draw_pixel && m_is_active) - { - for (int y = y0; y <= y1; y++) - { - for (int x = x0; x <= x1; x++) - { - m_gfx_op->draw_pixel(x, y, rgb); - } - } - } - - if (!m_fb) { return; } - if (m_color_bytes == 4) - { - unsigned int* fb; - for (int y = y0; y <= y1; y++) - { - fb = &((unsigned int*)m_fb)[y0 * m_width + x0]; - for (int x = x0; x <= x1; x++) - { - *fb++ = rgb; - } - } - } - else if (m_color_bytes == 2) - { - unsigned short* fb; - rgb = GL_RGB_32_to_16(rgb); - for (int y = y0; y <= y1; y++) - { - fb = &((unsigned short*)m_fb)[y0 * m_width + x0]; - for (int x = x0; x <= x1; x++) - { - *fb++ = rgb; - } - } - } - } - - virtual void draw_pixel_on_fb(int x, int y, unsigned int rgb) - { - if (m_gfx_op && m_gfx_op->draw_pixel && m_is_active) - { - m_gfx_op->draw_pixel(x, y, rgb); - } - - if (!m_fb) { return; } - if (m_color_bytes == 4) - { - ((unsigned int*)m_fb)[y * m_width + x] = rgb; - } - else if (m_color_bytes == 2) - { - ((unsigned short*)m_fb)[y * m_width + x] = GL_RGB_32_to_16(rgb); - } - } - struct EXTERNAL_GFX_OP* m_gfx_op;//Rendering by external method -}; - -inline c_display::c_display(void* phy_fb, int display_width, int display_height, int surface_width, int surface_height, unsigned int color_bytes, int surface_cnt, EXTERNAL_GFX_OP* gfx_op) : m_width(display_width), m_height(display_height), m_color_bytes(color_bytes), m_phy_fb(phy_fb), m_phy_read_index(0), m_phy_write_index(0), m_surface_cnt(surface_cnt), m_surface_index(0) +inline c_display::c_display(void* phy_fb, int display_width, int display_height, int surface_width, int surface_height, unsigned int color_bytes, int surface_cnt, DISPLAY_DRIVER* driver) : m_phy_fb(phy_fb), m_width(display_width), m_height(display_height), m_color_bytes(color_bytes), m_phy_read_index(0), m_phy_write_index(0), m_surface_cnt(surface_cnt), m_driver(driver), m_surface_index(0) { ASSERT(color_bytes == 2 || color_bytes == 4); ASSERT(m_surface_cnt <= SURFACE_CNT_MAX); @@ -556,18 +541,11 @@ inline c_display::c_display(void* phy_fb, int display_width, int display_height, for (int i = 0; i < m_surface_cnt; i++) { - m_surface_group[i] = (phy_fb) ? new c_surface(surface_width, surface_height, color_bytes) : new c_surface_no_fb(surface_width, surface_height, color_bytes, gfx_op); + m_surface_group[i] = new c_surface(surface_width, surface_height, color_bytes); m_surface_group[i]->attach_display(this); } } -inline c_display::c_display(void* phy_fb, int display_width, int display_height, c_surface* surface) : m_width(display_width), m_height(display_height), m_phy_fb(phy_fb), m_phy_read_index(0), m_phy_write_index(0), m_surface_cnt(1), m_surface_index(0) -{ - m_color_bytes = surface->m_color_bytes; - surface->m_is_active = true; - (m_surface_group[0] = surface)->attach_display(this); -} - inline c_surface* c_display::alloc_surface(Z_ORDER_LEVEL max_zorder, c_rect layer_rect) { ASSERT(max_zorder < Z_ORDER_LEVEL_MAX && m_surface_index < m_surface_cnt); @@ -577,8 +555,8 @@ inline c_surface* c_display::alloc_surface(Z_ORDER_LEVEL max_zorder, c_rect laye inline int c_display::swipe_surface(c_surface* s0, c_surface* s1, int x0, int x1, int y0, int y1, int offset) { - int surface_width = s0->get_width(); - int surface_height = s0->get_height(); + register int surface_width = s0->m_width; + register int surface_height = s0->m_height; if (offset < 0 || offset > surface_width || y0 < 0 || y0 >= surface_height || y1 < 0 || y1 >= surface_height || x0 < 0 || x0 >= surface_width || x1 < 0 || x1 >= surface_width) @@ -604,35 +582,18 @@ inline int c_display::swipe_surface(c_surface* s0, c_surface* s1, int x0, int x1 for (int y = y0; y <= y1; y++) { //Left surface - char* addr_s = ((char*)(s0->m_fb) + (y * (s0->get_width()) + x0 + offset) * m_color_bytes); + char* addr_s = ((char*)(s0->m_fb) + (y * surface_width + x0 + offset) * m_color_bytes); char* addr_d = ((char*)(m_phy_fb)+(y * m_width + x0) * m_color_bytes); memcpy(addr_d, addr_s, (width - offset) * m_color_bytes); //Right surface - addr_s = ((char*)(s1->m_fb) + (y * (s1->get_width()) + x0) * m_color_bytes); + addr_s = ((char*)(s1->m_fb) + (y * surface_width + x0) * m_color_bytes); addr_d = ((char*)(m_phy_fb)+(y * m_width + x0 + (width - offset)) * m_color_bytes); memcpy(addr_d, addr_s, offset * m_color_bytes); } } - else if (m_color_bytes == 4) - { - void(*draw_pixel)(int x, int y, unsigned int rgb) = ((c_surface_no_fb*)s0)->m_gfx_op->draw_pixel; - for (int y = y0; y <= y1; y++) - { - //Left surface - for (int x = x0; x <= (x1 - offset); x++) - { - draw_pixel(x, y, ((unsigned int*)s0->m_fb)[y * m_width + x + offset]); - } - //Right surface - for (int x = x1 - offset; x <= x1; x++) - { - draw_pixel(x, y, ((unsigned int*)s1->m_fb)[y * m_width + x + offset - x1 + x0]); - } - } - } else if (m_color_bytes == 2) { - void(*draw_pixel)(int x, int y, unsigned int rgb) = ((c_surface_no_fb*)s0)->m_gfx_op->draw_pixel; + void(*draw_pixel)(int x, int y, unsigned int rgb) = m_driver->draw_pixel; for (int y = y0; y <= y1; y++) { //Left surface @@ -647,6 +608,23 @@ inline int c_display::swipe_surface(c_surface* s0, c_surface* s1, int x0, int x1 } } } + else //m_color_bytes == 3/4... + { + void(*draw_pixel)(int x, int y, unsigned int rgb) = m_driver->draw_pixel; + for (int y = y0; y <= y1; y++) + { + //Left surface + for (int x = x0; x <= (x1 - offset); x++) + { + draw_pixel(x, y, ((unsigned int*)s0->m_fb)[y * m_width + x + offset]); + } + //Right surface + for (int x = x1 - offset; x <= x1; x++) + { + draw_pixel(x, y, ((unsigned int*)s1->m_fb)[y * m_width + x + offset - x1 + x0]); + } + } + } m_phy_write_index++; return 0; diff --git a/src/core/image.cpp b/src/core/image.cpp deleted file mode 100644 index a778ad1..0000000 --- a/src/core/image.cpp +++ /dev/null @@ -1,8 +0,0 @@ -#include "../core_include/image.h" - -#ifdef GUILITE_ON - -c_bitmap_operator the_bitmap_op = c_bitmap_operator(); -c_image_operator* c_image::image_operator = &the_bitmap_op; - -#endif diff --git a/src/core_include/image.h b/src/core/image.h similarity index 97% rename from src/core_include/image.h rename to src/core/image.h index cf5c07a..f82b501 100644 --- a/src/core_include/image.h +++ b/src/core/image.h @@ -1,8 +1,8 @@ #pragma once -#include "../core_include/api.h" -#include "../core_include/resource.h" -#include "../core_include/display.h" +#include "../core/api.h" +#include "../core/resource.h" +#include "../core/display.h" #define DEFAULT_MASK_COLOR 0xFF080408 class c_surface; diff --git a/src/core_include/resource.h b/src/core/resource.h similarity index 100% rename from src/core_include/resource.h rename to src/core/resource.h diff --git a/src/core/theme.cpp b/src/core/theme.cpp deleted file mode 100644 index ca21ff3..0000000 --- a/src/core/theme.cpp +++ /dev/null @@ -1,9 +0,0 @@ -#include "../core_include/theme.h" - -#ifdef GUILITE_ON - -const void* c_theme::s_font_map[FONT_MAX]; -const void* c_theme::s_image_map[IMAGE_MAX]; -unsigned int c_theme::s_color_map[COLOR_MAX]; - -#endif diff --git a/src/core_include/theme.h b/src/core/theme.h similarity index 96% rename from src/core_include/theme.h rename to src/core/theme.h index 663e9fd..64fe13e 100644 --- a/src/core_include/theme.h +++ b/src/core/theme.h @@ -1,7 +1,7 @@ #pragma once -#include "../core_include/api.h" -#include "../core_include/resource.h" +#include "../core/api.h" +#include "../core/resource.h" //Rebuild gui library once you change this file enum FONT_LIST diff --git a/src/core/wnd.cpp b/src/core/wnd.cpp deleted file mode 100644 index 41186ad..0000000 --- a/src/core/wnd.cpp +++ /dev/null @@ -1 +0,0 @@ -#include "../core_include/wnd.h" diff --git a/src/core_include/wnd.h b/src/core/wnd.h similarity index 98% rename from src/core_include/wnd.h rename to src/core/wnd.h index da74dfa..67555c3 100644 --- a/src/core_include/wnd.h +++ b/src/core/wnd.h @@ -1,8 +1,8 @@ #pragma once -#include "../core_include/api.h" -#include "../core_include/resource.h" -#include "../core_include/display.h" +#include "../core/api.h" +#include "../core/resource.h" +#include "../core/display.h" class c_wnd; class c_surface; diff --git a/src/core/word.cpp b/src/core/word.cpp deleted file mode 100644 index 43a9855..0000000 --- a/src/core/word.cpp +++ /dev/null @@ -1,8 +0,0 @@ -#include "../core_include/word.h" - -#ifdef GUILITE_ON - -c_lattice_font_op the_lattice_font_op = c_lattice_font_op(); -c_font_operator* c_word::fontOperator = &the_lattice_font_op; - -#endif diff --git a/src/core_include/word.h b/src/core/word.h similarity index 98% rename from src/core_include/word.h rename to src/core/word.h index 444e739..44ad086 100644 --- a/src/core_include/word.h +++ b/src/core/word.h @@ -1,8 +1,8 @@ #pragma once -#include "../core_include/api.h" -#include "../core_include/resource.h" -#include "../core_include/display.h" +#include "../core/api.h" +#include "../core/resource.h" +#include "../core/display.h" #include #include diff --git a/src/widgets/button.cpp b/src/widgets/button.cpp deleted file mode 100644 index e011bbd..0000000 --- a/src/widgets/button.cpp +++ /dev/null @@ -1 +0,0 @@ -#include "../widgets_include/button.h" diff --git a/src/widgets_include/button.h b/src/widgets/button.h similarity index 91% rename from src/widgets_include/button.h rename to src/widgets/button.h index ab28f4e..cb1063c 100644 --- a/src/widgets_include/button.h +++ b/src/widgets/button.h @@ -1,11 +1,11 @@ #pragma once -#include "../core_include/api.h" -#include "../core_include/wnd.h" -#include "../core_include/resource.h" -#include "../core_include/word.h" -#include "../core_include/display.h" -#include "../core_include/theme.h" +#include "../core/api.h" +#include "../core/wnd.h" +#include "../core/resource.h" +#include "../core/word.h" +#include "../core/display.h" +#include "../core/theme.h" class c_button : public c_wnd { diff --git a/src/widgets/dialog.cpp b/src/widgets/dialog.cpp deleted file mode 100644 index ac8f40f..0000000 --- a/src/widgets/dialog.cpp +++ /dev/null @@ -1,7 +0,0 @@ -#include "../widgets_include/dialog.h" - -#ifdef GUILITE_ON - -DIALOG_ARRAY c_dialog::ms_the_dialogs[SURFACE_CNT_MAX]; - -#endif diff --git a/src/widgets_include/dialog.h b/src/widgets/dialog.h similarity index 91% rename from src/widgets_include/dialog.h rename to src/widgets/dialog.h index 473ad8e..afee6bc 100644 --- a/src/widgets_include/dialog.h +++ b/src/widgets/dialog.h @@ -1,11 +1,11 @@ #pragma once -#include "../core_include/api.h" -#include "../core_include/wnd.h" -#include "../core_include/display.h" -#include "../core_include/resource.h" -#include "../core_include/word.h" -#include "../core_include/theme.h" +#include "../core/api.h" +#include "../core/wnd.h" +#include "../core/display.h" +#include "../core/resource.h" +#include "../core/word.h" +#include "../core/theme.h" class c_surface; class c_dialog; diff --git a/src/widgets/edit.cpp b/src/widgets/edit.cpp deleted file mode 100644 index 9e36e77..0000000 --- a/src/widgets/edit.cpp +++ /dev/null @@ -1,7 +0,0 @@ -#include "../widgets_include/edit.h" - -#ifdef GUILITE_ON - -c_keyboard c_edit::s_keyboard; - -#endif diff --git a/src/widgets_include/edit.h b/src/widgets/edit.h similarity index 94% rename from src/widgets_include/edit.h rename to src/widgets/edit.h index 94e9dd9..911a2c9 100644 --- a/src/widgets_include/edit.h +++ b/src/widgets/edit.h @@ -1,14 +1,14 @@ #pragma once -#include "../core_include/api.h" -#include "../core_include/wnd.h" -#include "../core_include/resource.h" -#include "../core_include/word.h" -#include "../core_include/display.h" -#include "../core_include/theme.h" -#include "../widgets_include/button.h" -#include "../widgets_include/label.h" -#include "../widgets_include/keyboard.h" +#include "../core/api.h" +#include "../core/wnd.h" +#include "../core/resource.h" +#include "../core/word.h" +#include "../core/display.h" +#include "../core/theme.h" +#include "../widgets/button.h" +#include "../widgets/label.h" +#include "../widgets/keyboard.h" #include #define MAX_EDIT_STRLEN 32 diff --git a/src/widgets_include/keyboard.h b/src/widgets/keyboard.h similarity index 96% rename from src/widgets_include/keyboard.h rename to src/widgets/keyboard.h index 9d3eae6..eaa3daa 100644 --- a/src/widgets_include/keyboard.h +++ b/src/widgets/keyboard.h @@ -1,12 +1,12 @@ #pragma once -#include "../core_include/api.h" -#include "../core_include/resource.h" -#include "../core_include/word.h" -#include "../core_include/wnd.h" -#include "../core_include/display.h" -#include "../core_include/theme.h" -#include "../widgets_include/button.h" +#include "../core/api.h" +#include "../core/resource.h" +#include "../core/word.h" +#include "../core/wnd.h" +#include "../core/display.h" +#include "../core/theme.h" +#include "../widgets/button.h" #include //Changing key width/height will change the width/height of keyboard diff --git a/src/widgets/label.cpp b/src/widgets/label.cpp deleted file mode 100644 index 8381439..0000000 --- a/src/widgets/label.cpp +++ /dev/null @@ -1 +0,0 @@ -#include "../widgets_include/label.h" diff --git a/src/widgets_include/label.h b/src/widgets/label.h similarity index 74% rename from src/widgets_include/label.h rename to src/widgets/label.h index de8c4de..e156556 100644 --- a/src/widgets_include/label.h +++ b/src/widgets/label.h @@ -1,11 +1,11 @@ #pragma once -#include "../core_include/api.h" -#include "../core_include/wnd.h" -#include "../core_include/display.h" -#include "../core_include/resource.h" -#include "../core_include/theme.h" -#include "../core_include/word.h" +#include "../core/api.h" +#include "../core/wnd.h" +#include "../core/display.h" +#include "../core/resource.h" +#include "../core/theme.h" +#include "../core/word.h" class c_label : public c_wnd { diff --git a/src/widgets/list_box.cpp b/src/widgets/list_box.cpp deleted file mode 100644 index 29e94fb..0000000 --- a/src/widgets/list_box.cpp +++ /dev/null @@ -1 +0,0 @@ -#include "../widgets_include/list_box.h" diff --git a/src/widgets_include/list_box.h b/src/widgets/list_box.h similarity index 96% rename from src/widgets_include/list_box.h rename to src/widgets/list_box.h index fd8d866..20f160a 100644 --- a/src/widgets_include/list_box.h +++ b/src/widgets/list_box.h @@ -1,12 +1,12 @@ #pragma once -#include "../core_include/api.h" -#include "../core_include/resource.h" -#include "../core_include/wnd.h" -#include "../core_include/display.h" -#include "../core_include/word.h" -#include "../core_include/theme.h" -#include "../widgets_include/button.h" +#include "../core/api.h" +#include "../core/resource.h" +#include "../core/wnd.h" +#include "../core/display.h" +#include "../core/word.h" +#include "../core/theme.h" +#include "../widgets/button.h" #include #define MAX_ITEM_NUM 4 diff --git a/src/widgets/slide_group.cpp b/src/widgets/slide_group.cpp deleted file mode 100644 index 466165c..0000000 --- a/src/widgets/slide_group.cpp +++ /dev/null @@ -1 +0,0 @@ -#include "../widgets_include/slide_group.h" diff --git a/src/widgets_include/slide_group.h b/src/widgets/slide_group.h similarity index 98% rename from src/widgets_include/slide_group.h rename to src/widgets/slide_group.h index e858597..1c35f11 100644 --- a/src/widgets_include/slide_group.h +++ b/src/widgets/slide_group.h @@ -1,9 +1,9 @@ #pragma once -#include "../core_include/api.h" -#include "../core_include/display.h" -#include "../core_include/wnd.h" -#include "../widgets_include/dialog.h" +#include "../core/api.h" +#include "../core/display.h" +#include "../core/wnd.h" +#include "../widgets/dialog.h" #include #define MAX_PAGES 5 diff --git a/src/widgets/spinbox.cpp b/src/widgets/spinbox.cpp deleted file mode 100644 index 64ef970..0000000 --- a/src/widgets/spinbox.cpp +++ /dev/null @@ -1 +0,0 @@ -#include "../widgets_include/spinbox.h" diff --git a/src/widgets_include/spinbox.h b/src/widgets/spinbox.h similarity index 91% rename from src/widgets_include/spinbox.h rename to src/widgets/spinbox.h index 7596e95..d8ccff3 100644 --- a/src/widgets_include/spinbox.h +++ b/src/widgets/spinbox.h @@ -1,12 +1,12 @@ #pragma once -#include "../core_include/api.h" -#include "../core_include/wnd.h" -#include "../core_include/resource.h" -#include "../core_include/word.h" -#include "../core_include/display.h" -#include "../core_include/theme.h" -#include "../widgets_include/button.h" +#include "../core/api.h" +#include "../core/wnd.h" +#include "../core/resource.h" +#include "../core/word.h" +#include "../core/display.h" +#include "../core/theme.h" +#include "../widgets/button.h" #define ID_BT_ARROW_UP 0x1111 #define ID_BT_ARROW_DOWN 0x2222 diff --git a/src/widgets/table.cpp b/src/widgets/table.cpp deleted file mode 100644 index b66e3d5..0000000 --- a/src/widgets/table.cpp +++ /dev/null @@ -1 +0,0 @@ -#include "../widgets_include/table.h" diff --git a/src/widgets_include/table.h b/src/widgets/table.h similarity index 92% rename from src/widgets_include/table.h rename to src/widgets/table.h index f3951a1..1803f25 100644 --- a/src/widgets_include/table.h +++ b/src/widgets/table.h @@ -1,11 +1,11 @@ #pragma once -#include "../core_include/api.h" -#include "../core_include/resource.h" -#include "../core_include/word.h" -#include "../core_include/display.h" -#include "../core_include/theme.h" -#include "../core_include/wnd.h" +#include "../core/api.h" +#include "../core/resource.h" +#include "../core/word.h" +#include "../core/display.h" +#include "../core/theme.h" +#include "../core/wnd.h" #define MAX_COL_NUM 30 #define MAX_ROW_NUM 30 diff --git a/src/widgets/wave_buffer.cpp b/src/widgets/wave_buffer.cpp deleted file mode 100644 index 5fa8ea9..0000000 --- a/src/widgets/wave_buffer.cpp +++ /dev/null @@ -1 +0,0 @@ -#include "../widgets_include/wave_buffer.h" diff --git a/src/widgets_include/wave_buffer.h b/src/widgets/wave_buffer.h similarity index 98% rename from src/widgets_include/wave_buffer.h rename to src/widgets/wave_buffer.h index 72f2c75..4eb8ed6 100644 --- a/src/widgets_include/wave_buffer.h +++ b/src/widgets/wave_buffer.h @@ -1,6 +1,6 @@ #pragma once -#include "../core_include/api.h" +#include "../core/api.h" #include #include diff --git a/src/widgets/wave_ctrl.cpp b/src/widgets/wave_ctrl.cpp deleted file mode 100644 index 4c06782..0000000 --- a/src/widgets/wave_ctrl.cpp +++ /dev/null @@ -1 +0,0 @@ -#include "../widgets_include/wave_ctrl.h" diff --git a/src/widgets_include/wave_ctrl.h b/src/widgets/wave_ctrl.h similarity index 97% rename from src/widgets_include/wave_ctrl.h rename to src/widgets/wave_ctrl.h index bd3ee6c..0fa0336 100644 --- a/src/widgets_include/wave_ctrl.h +++ b/src/widgets/wave_ctrl.h @@ -1,11 +1,11 @@ #pragma once -#include "../core_include/api.h" -#include "../core_include/wnd.h" -#include "../core_include/display.h" -#include "../core_include/resource.h" -#include "../core_include/word.h" -#include "../widgets_include/wave_buffer.h" +#include "../core/api.h" +#include "../core/wnd.h" +#include "../core/display.h" +#include "../core/resource.h" +#include "../core/word.h" +#include "../widgets/wave_buffer.h" #include #include diff --git a/src/widgets/keyboard.cpp b/src/widgets/widgets.cpp similarity index 82% rename from src/widgets/keyboard.cpp rename to src/widgets/widgets.cpp index 32aa6db..7d7b531 100644 --- a/src/widgets/keyboard.cpp +++ b/src/widgets/widgets.cpp @@ -1,6 +1,18 @@ -#include "../widgets_include/keyboard.h" +#include "../widgets/button.h" +#include "../widgets/dialog.h" +#include "../widgets/keyboard.h" +#include "../widgets/label.h" +#include "../widgets/list_box.h" +#include "../widgets/slide_group.h" +#include "../widgets/spinbox.h" +#include "../widgets/table.h" +#include "../widgets/wave_buffer.h" +#include "../widgets/wave_ctrl.h" +#include "../widgets/edit.h" #ifdef GUILITE_ON +DIALOG_ARRAY c_dialog::ms_the_dialogs[SURFACE_CNT_MAX]; +c_keyboard c_edit::s_keyboard; static c_keyboard_button s_key_0, s_key_1, s_key_2, s_key_3, s_key_4, s_key_5, s_key_6, s_key_7, s_key_8, s_key_9; static c_keyboard_button s_key_A, s_key_B, s_key_C, s_key_D, s_key_E, s_key_F, s_key_G, s_key_H, s_key_I, s_key_J; @@ -40,12 +52,12 @@ WND_TREE g_key_board_children[] = {&s_key_B, 'B', 0, ((KEY_WIDTH / 2) + POS_X(5)), POS_Y(2), KEY_WIDTH, KEY_HEIGHT}, {&s_key_N, 'N', 0, ((KEY_WIDTH / 2) + POS_X(6)), POS_Y(2), KEY_WIDTH, KEY_HEIGHT}, {&s_key_M, 'M', 0, ((KEY_WIDTH / 2) + POS_X(7)), POS_Y(2), KEY_WIDTH, KEY_HEIGHT}, - {&s_key_del, 0x7F, 0, ((KEY_WIDTH / 2) + POS_X(8)), POS_Y(2), DEL_WIDTH, KEY_HEIGHT}, + {&s_key_del,0x7F, 0, ((KEY_WIDTH / 2) + POS_X(8)), POS_Y(2), DEL_WIDTH, KEY_HEIGHT}, //Row 4 - {&s_key_esc, 0x1B, 0, POS_X(0), POS_Y(3), ESC_WIDTH, KEY_HEIGHT}, + {&s_key_esc, 0x1B, 0, POS_X(0), POS_Y(3), ESC_WIDTH, KEY_HEIGHT}, {&s_key_num_switch, 0x90, 0, POS_X(2), POS_Y(3), SWITCH_WIDTH, KEY_HEIGHT}, {&s_key_space, ' ', 0, ((KEY_WIDTH / 2) + POS_X(3)), POS_Y(3), SPACE_WIDTH, KEY_HEIGHT}, - {&s_key_dot, '.', 0, ((KEY_WIDTH / 2) + POS_X(6)), POS_Y(3), DOT_WIDTH, KEY_HEIGHT}, + {&s_key_dot, '.', 0, ((KEY_WIDTH / 2) + POS_X(6)), POS_Y(3), DOT_WIDTH, KEY_HEIGHT}, {&s_key_enter, '\n', 0, POS_X(8), POS_Y(3), ENTER_WIDTH, KEY_HEIGHT}, {0,0,0,0,0,0,0} }; @@ -63,13 +75,14 @@ WND_TREE g_number_board_children[] = {&s_key_7, '7', 0, POS_X(0), POS_Y(2), KEY_WIDTH, KEY_HEIGHT}, {&s_key_8, '8', 0, POS_X(1), POS_Y(2), KEY_WIDTH, KEY_HEIGHT}, {&s_key_9, '9', 0, POS_X(2), POS_Y(2), KEY_WIDTH, KEY_HEIGHT}, - - {&s_key_esc, 0x1B, 0, POS_X(0), POS_Y(3), KEY_WIDTH, KEY_HEIGHT}, + + {&s_key_esc,0x1B, 0, POS_X(0), POS_Y(3), KEY_WIDTH, KEY_HEIGHT}, {&s_key_0, '0', 0, POS_X(1), POS_Y(3), KEY_WIDTH, KEY_HEIGHT}, - {&s_key_dot, '.', 0, POS_X(2), POS_Y(3), KEY_WIDTH, KEY_HEIGHT}, + {&s_key_dot,'.', 0, POS_X(2), POS_Y(3), KEY_WIDTH, KEY_HEIGHT}, {&s_key_del, 0x7F, 0, POS_X(3), POS_Y(0), KEY_WIDTH, KEY_HEIGHT * 2 + 2}, {&s_key_enter,'\n', 0, POS_X(3), POS_Y(2), KEY_WIDTH, KEY_HEIGHT * 2 + 2}, {0,0,0,0,0,0,0} }; -#endif + +#endif \ No newline at end of file