代码拉取完成,页面将自动刷新
同步操作将从 idea4good/GuiLiteSamples 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
#define GUILITE_ON //Do not define this macro once more!!!
#include "GuiLite.h"
#include <stdlib.h>
#include <string.h>
const int UI_WIDTH = 512;
const int UI_HEIGHT = 768;
//////////////////////// define widgets & map message ////////////////////////
enum WND_ID
{
ID_ROOT = 1,
ID_PAGE1,
ID_PAGE2,
ID_PAGE3,
ID_PAGE4,
ID_PAGE5
};
class c_page : public c_wnd
{
virtual void on_paint();
};
void c_page::on_paint()
{
c_rect rect;
get_screen_rect(rect);
const BITMAP_INFO* bmp = NULL;
switch (m_id)
{
case ID_PAGE1:
bmp = (const BITMAP_INFO*)c_theme::get_image(IMAGE_CUSTOM1);
break;
case ID_PAGE2:
bmp = (const BITMAP_INFO*)c_theme::get_image(IMAGE_CUSTOM2);
break;
case ID_PAGE3:
bmp = (const BITMAP_INFO*)c_theme::get_image(IMAGE_CUSTOM3);
break;
case ID_PAGE4:
bmp = (const BITMAP_INFO*)c_theme::get_image(IMAGE_CUSTOM4);
break;
case ID_PAGE5:
bmp = (const BITMAP_INFO*)c_theme::get_image(IMAGE_CUSTOM5);
break;
default:
break;
}
c_image::draw_image(m_surface, m_z_order, bmp, rect.m_left, rect.m_top);
}
//////////////////////// layout UI ////////////////////////
c_page s_page1, s_page2, s_page3, s_page4, s_page5;
static c_slide_group s_root;
static WND_TREE s_root_children[] =
{
{ NULL,0,0,0,0,0,0 }
};
//////////////////////// start UI ////////////////////////
extern const BITMAP_INFO ten_bmp, jack_bmp, queen_bmp, king_bmp, ace_bmp;
static c_display* s_display;
void load_resource()
{
c_theme::add_image(IMAGE_CUSTOM1, &ten_bmp);
c_theme::add_image(IMAGE_CUSTOM2, &jack_bmp);
c_theme::add_image(IMAGE_CUSTOM3, &queen_bmp);
c_theme::add_image(IMAGE_CUSTOM4, &king_bmp);
c_theme::add_image(IMAGE_CUSTOM5, &ace_bmp);
}
void create_ui(void* phy_fb, int screen_width, int screen_height, int color_bytes)
{
load_resource();
s_display = new c_display(phy_fb, screen_width, screen_height, UI_WIDTH, UI_HEIGHT, color_bytes, (1 + 5)/*1 root + 5 pages*/);
c_surface* surface = s_display->alloc_surface(Z_ORDER_LEVEL_1);
surface->set_active(true);
s_root.set_surface(surface);
s_root.connect(NULL, ID_ROOT, 0, 0, 0, UI_WIDTH, UI_HEIGHT, s_root_children);
s_root.add_slide(&s_page1, ID_PAGE1, 0, 0, UI_WIDTH, UI_HEIGHT, NULL);
s_root.add_slide(&s_page2, ID_PAGE2, 0, 0, UI_WIDTH, UI_HEIGHT, NULL);
s_root.add_slide(&s_page3, ID_PAGE3, 0, 0, UI_WIDTH, UI_HEIGHT, NULL);
s_root.add_slide(&s_page4, ID_PAGE4, 0, 0, UI_WIDTH, UI_HEIGHT, NULL);
s_root.add_slide(&s_page5, ID_PAGE5, 0, 0, UI_WIDTH, UI_HEIGHT, NULL);
s_root.set_active_slide(0);
s_root.show_window();
while(1)
{
thread_sleep(1000000);
}
}
//////////////////////// interface for all platform ////////////////////////
void startHelloSlide(void* phy_fb, int width, int height, int color_bytes)
{
create_ui(phy_fb, width, height, color_bytes);
}
void sendTouch2HelloSlide(int x, int y, bool is_down)
{
is_down ? s_root.on_touch(x, y, TOUCH_DOWN) : s_root.on_touch(x, y, TOUCH_UP);
}
void* getUiOfHelloSlide(int* width, int* height, bool force_update)
{
return s_display->get_updated_fb(width, height, force_update);
}
int captureUiOfHelloSlide()
{
return s_display->snap_shot("snap_short.bmp");
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。