mirror of
https://gitee.com/zlgopen/awtk.git
synced 2024-11-30 02:58:26 +08:00
improve lcd
This commit is contained in:
parent
bdfc494670
commit
535bd16cf2
@ -1,5 +1,8 @@
|
|||||||
# 最新动态
|
# 最新动态
|
||||||
|
|
||||||
|
2021/08/23
|
||||||
|
* 修复多次调用 lcd 旋转的功能的问题(感谢智明提供补丁)
|
||||||
|
|
||||||
2021/08/21
|
2021/08/21
|
||||||
* 修改lcd\_profile编译问题。
|
* 修改lcd\_profile编译问题。
|
||||||
|
|
||||||
|
@ -405,15 +405,16 @@ ret_t tk_quit() {
|
|||||||
|
|
||||||
ret_t tk_set_lcd_orientation(lcd_orientation_t orientation) {
|
ret_t tk_set_lcd_orientation(lcd_orientation_t orientation) {
|
||||||
main_loop_t* loop = main_loop();
|
main_loop_t* loop = main_loop();
|
||||||
|
lcd_orientation_t old_orientation;
|
||||||
system_info_t* info = system_info();
|
system_info_t* info = system_info();
|
||||||
return_value_if_fail(loop != NULL && info != NULL, RET_OK);
|
return_value_if_fail(loop != NULL && info != NULL, RET_OK);
|
||||||
|
|
||||||
if (info->lcd_orientation != orientation) {
|
if (info->lcd_orientation != orientation) {
|
||||||
orientation_event_t e;
|
orientation_event_t e;
|
||||||
|
old_orientation = info->lcd_orientation;
|
||||||
system_info_set_lcd_orientation(info, orientation);
|
system_info_set_lcd_orientation(info, orientation);
|
||||||
|
|
||||||
orientation_event_init(&e, EVT_ORIENTATION_WILL_CHANGED, NULL, orientation);
|
orientation_event_init(&e, EVT_ORIENTATION_WILL_CHANGED, NULL, old_orientation, orientation);
|
||||||
widget_dispatch(window_manager(), (event_t*)&e);
|
widget_dispatch(window_manager(), (event_t*)&e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -135,13 +135,14 @@ event_t* wheel_event_init(wheel_event_t* event, uint32_t type, void* target, int
|
|||||||
}
|
}
|
||||||
|
|
||||||
event_t* orientation_event_init(orientation_event_t* event, uint32_t type, void* target,
|
event_t* orientation_event_init(orientation_event_t* event, uint32_t type, void* target,
|
||||||
lcd_orientation_t orientation) {
|
lcd_orientation_t old_orientation, lcd_orientation_t new_orientation) {
|
||||||
return_value_if_fail(event != NULL, NULL);
|
return_value_if_fail(event != NULL, NULL);
|
||||||
memset(event, 0x00, sizeof(orientation_event_t));
|
memset(event, 0x00, sizeof(orientation_event_t));
|
||||||
|
|
||||||
event->e = event_init(type, target);
|
event->e = event_init(type, target);
|
||||||
event->e.size = sizeof(*event);
|
event->e.size = sizeof(*event);
|
||||||
event->orientation = orientation;
|
event->orientation = new_orientation;
|
||||||
|
event->old_orientation = old_orientation;
|
||||||
|
|
||||||
return (event_t*)event;
|
return (event_t*)event;
|
||||||
}
|
}
|
||||||
|
@ -557,6 +557,12 @@ typedef struct _orientation_event_t {
|
|||||||
* 屏幕方向。
|
* 屏幕方向。
|
||||||
*/
|
*/
|
||||||
lcd_orientation_t orientation;
|
lcd_orientation_t orientation;
|
||||||
|
/**
|
||||||
|
* @property {int32_t} old_orientation
|
||||||
|
* @annotation ["readable", "scriptable"]
|
||||||
|
* 旧的屏幕方向。
|
||||||
|
*/
|
||||||
|
lcd_orientation_t old_orientation;
|
||||||
} orientation_event_t;
|
} orientation_event_t;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -573,14 +579,15 @@ orientation_event_t* orientation_event_cast(event_t* event);
|
|||||||
* @method orientation_event_init
|
* @method orientation_event_init
|
||||||
* 初始化事件。
|
* 初始化事件。
|
||||||
* @param {orientation_event_t*} event event对象。
|
* @param {orientation_event_t*} event event对象。
|
||||||
* @param {void*} target 事件目标。
|
|
||||||
* @param {uint32_t} type 事件类型。
|
* @param {uint32_t} type 事件类型。
|
||||||
* @param {int32_t} dy 滚轮的y值。
|
* @param {void*} target 事件目标。
|
||||||
|
* @param {lcd_orientation_t} old_orientation 旧的屏幕方向。
|
||||||
|
* @param {lcd_orientation_t} new_orientation 新的屏幕方向。
|
||||||
*
|
*
|
||||||
* @return {event_t*} event对象。
|
* @return {event_t*} event对象。
|
||||||
*/
|
*/
|
||||||
event_t* orientation_event_init(orientation_event_t* event, uint32_t type, void* target,
|
event_t* orientation_event_init(orientation_event_t* event, uint32_t type, void* target,
|
||||||
lcd_orientation_t orientation);
|
lcd_orientation_t old_orientation, lcd_orientation_t new_orientation);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @class value_change_event_t
|
* @class value_change_event_t
|
||||||
|
@ -339,10 +339,10 @@ ret_t lcd_resize(lcd_t* lcd, wh_t w, wh_t h, uint32_t line_length) {
|
|||||||
return RET_FAIL;
|
return RET_FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret_t lcd_set_orientation(lcd_t* lcd, lcd_orientation_t orientation) {
|
ret_t lcd_set_orientation(lcd_t* lcd, lcd_orientation_t old_orientation, lcd_orientation_t new_orientation) {
|
||||||
return_value_if_fail(lcd != NULL, RET_BAD_PARAMS);
|
return_value_if_fail(lcd != NULL, RET_BAD_PARAMS);
|
||||||
if (lcd->set_orientation != NULL) {
|
if (lcd->set_orientation != NULL) {
|
||||||
return lcd->set_orientation(lcd, orientation);
|
return lcd->set_orientation(lcd, old_orientation, new_orientation);
|
||||||
}
|
}
|
||||||
return RET_FAIL;
|
return RET_FAIL;
|
||||||
}
|
}
|
||||||
|
@ -51,7 +51,7 @@ typedef const dirty_rects_t* (*lcd_get_dirty_rects_t)(lcd_t* lcd);
|
|||||||
typedef ret_t (*lcd_begin_frame_t)(lcd_t* lcd, const dirty_rects_t* dirty_rects);
|
typedef ret_t (*lcd_begin_frame_t)(lcd_t* lcd, const dirty_rects_t* dirty_rects);
|
||||||
typedef ret_t (*lcd_set_clip_rect_t)(lcd_t* lcd, const rect_t* rect);
|
typedef ret_t (*lcd_set_clip_rect_t)(lcd_t* lcd, const rect_t* rect);
|
||||||
typedef ret_t (*lcd_get_clip_rect_t)(lcd_t* lcd, rect_t* rect);
|
typedef ret_t (*lcd_get_clip_rect_t)(lcd_t* lcd, rect_t* rect);
|
||||||
typedef ret_t (*lcd_set_orientation_t)(lcd_t* lcd, lcd_orientation_t orientation);
|
typedef ret_t (*lcd_set_orientation_t)(lcd_t* lcd, lcd_orientation_t old_orientation, lcd_orientation_t new_orientation);
|
||||||
typedef ret_t (*lcd_resize_t)(lcd_t* lcd, wh_t w, wh_t h, uint32_t line_length);
|
typedef ret_t (*lcd_resize_t)(lcd_t* lcd, wh_t w, wh_t h, uint32_t line_length);
|
||||||
typedef ret_t (*lcd_get_text_metrics_t)(lcd_t* lcd, float_t* ascent, float_t* descent,
|
typedef ret_t (*lcd_get_text_metrics_t)(lcd_t* lcd, float_t* ascent, float_t* descent,
|
||||||
float_t* line_hight);
|
float_t* line_hight);
|
||||||
@ -719,7 +719,7 @@ bool_t lcd_is_support_dirty_rect(lcd_t* lcd);
|
|||||||
/* private */
|
/* private */
|
||||||
bool_t lcd_is_dirty(lcd_t* lcd);
|
bool_t lcd_is_dirty(lcd_t* lcd);
|
||||||
ret_t lcd_set_canvas(lcd_t* lcd, canvas_t* c);
|
ret_t lcd_set_canvas(lcd_t* lcd, canvas_t* c);
|
||||||
ret_t lcd_set_orientation(lcd_t* lcd, lcd_orientation_t orientation);
|
ret_t lcd_set_orientation(lcd_t* lcd, lcd_orientation_t old_orientation, lcd_orientation_t new_orientation);
|
||||||
|
|
||||||
END_C_DECLS
|
END_C_DECLS
|
||||||
|
|
||||||
|
@ -65,10 +65,10 @@ static ret_t lcd_profile_resize(lcd_t* lcd, wh_t w, wh_t h, uint32_t line_length
|
|||||||
return lcd_resize(profile->impl, w, h, line_length);
|
return lcd_resize(profile->impl, w, h, line_length);
|
||||||
}
|
}
|
||||||
|
|
||||||
static ret_t lcd_profile_set_orientation(lcd_t* lcd, lcd_orientation_t orientation) {
|
static ret_t lcd_profile_set_orientation(lcd_t* lcd, lcd_orientation_t old_orientation, lcd_orientation_t new_orientation) {
|
||||||
lcd_profile_t* profile = LCD_PROFILE(lcd);
|
lcd_profile_t* profile = LCD_PROFILE(lcd);
|
||||||
|
|
||||||
return lcd_set_orientation(profile->impl, orientation);
|
return lcd_set_orientation(profile->impl, old_orientation, new_orientation);
|
||||||
}
|
}
|
||||||
|
|
||||||
static ret_t lcd_profile_set_global_alpha(lcd_t* lcd, uint8_t alpha) {
|
static ret_t lcd_profile_set_global_alpha(lcd_t* lcd, uint8_t alpha) {
|
||||||
|
@ -46,6 +46,16 @@ ret_t native_window_resize(native_window_t* win, wh_t w, wh_t h, bool_t force) {
|
|||||||
return RET_OK;
|
return RET_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ret_t native_window_set_orientation(native_window_t* win, lcd_orientation_t old_orientation, lcd_orientation_t new_orientation) {
|
||||||
|
return_value_if_fail(win != NULL && win->vt != NULL, RET_BAD_PARAMS);
|
||||||
|
|
||||||
|
if (win->vt->set_orientation != NULL) {
|
||||||
|
return win->vt->set_orientation(win, old_orientation, new_orientation);
|
||||||
|
}
|
||||||
|
|
||||||
|
return RET_OK;
|
||||||
|
}
|
||||||
|
|
||||||
canvas_t* native_window_get_canvas(native_window_t* win) {
|
canvas_t* native_window_get_canvas(native_window_t* win) {
|
||||||
return_value_if_fail(win != NULL && win->vt != NULL, NULL);
|
return_value_if_fail(win != NULL && win->vt != NULL, NULL);
|
||||||
|
|
||||||
|
@ -45,6 +45,7 @@ typedef struct _native_window_info_t {
|
|||||||
typedef canvas_t* (*native_window_get_canvas_t)(native_window_t* win);
|
typedef canvas_t* (*native_window_get_canvas_t)(native_window_t* win);
|
||||||
typedef ret_t (*native_window_move_t)(native_window_t* win, xy_t x, xy_t y);
|
typedef ret_t (*native_window_move_t)(native_window_t* win, xy_t x, xy_t y);
|
||||||
typedef ret_t (*native_window_resize_t)(native_window_t* win, wh_t w, wh_t h);
|
typedef ret_t (*native_window_resize_t)(native_window_t* win, wh_t w, wh_t h);
|
||||||
|
typedef ret_t (*native_window_set_orientation_t)(native_window_t* win, lcd_orientation_t old_orientation, lcd_orientation_t new_orientation);
|
||||||
typedef ret_t (*native_window_gl_make_current_t)(native_window_t* win);
|
typedef ret_t (*native_window_gl_make_current_t)(native_window_t* win);
|
||||||
typedef ret_t (*native_window_swap_buffer_t)(native_window_t* win);
|
typedef ret_t (*native_window_swap_buffer_t)(native_window_t* win);
|
||||||
typedef ret_t (*native_window_preprocess_event_t)(native_window_t* win, event_t* e);
|
typedef ret_t (*native_window_preprocess_event_t)(native_window_t* win, event_t* e);
|
||||||
@ -73,6 +74,7 @@ typedef struct _native_window_vtable_t {
|
|||||||
native_window_show_border_t show_border;
|
native_window_show_border_t show_border;
|
||||||
native_window_set_fullscreen_t set_fullscreen;
|
native_window_set_fullscreen_t set_fullscreen;
|
||||||
native_window_set_cursor_t set_cursor;
|
native_window_set_cursor_t set_cursor;
|
||||||
|
native_window_set_orientation_t set_orientation;
|
||||||
} native_window_vtable_t;
|
} native_window_vtable_t;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -123,6 +125,19 @@ ret_t native_window_move(native_window_t* win, xy_t x, xy_t y, bool_t force);
|
|||||||
*/
|
*/
|
||||||
ret_t native_window_resize(native_window_t* win, wh_t w, wh_t h, bool_t force);
|
ret_t native_window_resize(native_window_t* win, wh_t w, wh_t h, bool_t force);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @method native_window_set_orientation
|
||||||
|
* 调整窗口旋转。
|
||||||
|
*
|
||||||
|
* @annotation ["scriptable"]
|
||||||
|
* @param {native_window_t*} win win对象。
|
||||||
|
* @param {lcd_orientation_t} old_orientation 旧的旋转角度。
|
||||||
|
* @param {lcd_orientation_t} new_orientation 新的旋转角度。
|
||||||
|
*
|
||||||
|
* @return {ret_t} 返回RET_OK表示成功,否则表示失败。
|
||||||
|
*/
|
||||||
|
ret_t native_window_set_orientation(native_window_t* win, lcd_orientation_t old_orientation, lcd_orientation_t new_orientation);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @method native_window_minimize
|
* @method native_window_minimize
|
||||||
* 最小化窗口。
|
* 最小化窗口。
|
||||||
|
@ -399,3 +399,16 @@ const char* system_info_fix_font_name(const char* name) {
|
|||||||
|
|
||||||
return (name && *name) ? name : system_info()->default_font;
|
return (name && *name) ? name : system_info()->default_font;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool_t tk_is_swap_size_by_orientation(lcd_orientation_t old_orientation, lcd_orientation_t new_orientation) {
|
||||||
|
if (old_orientation == LCD_ORIENTATION_0 || old_orientation == LCD_ORIENTATION_180) {
|
||||||
|
if (new_orientation == LCD_ORIENTATION_90 || new_orientation == LCD_ORIENTATION_270) {
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (new_orientation == LCD_ORIENTATION_0 || new_orientation == LCD_ORIENTATION_180) {
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
@ -309,6 +309,8 @@ ret_t system_info_set_app_info(system_info_t* info, app_type_t app_type, const c
|
|||||||
ret_t system_info_eval_exprs(system_info_t* info, const char* exprs, tk_visit_t on_expr_result,
|
ret_t system_info_eval_exprs(system_info_t* info, const char* exprs, tk_visit_t on_expr_result,
|
||||||
void* ctx);
|
void* ctx);
|
||||||
|
|
||||||
|
bool_t tk_is_swap_size_by_orientation(lcd_orientation_t old_orientation, lcd_orientation_t new_orientation);
|
||||||
|
|
||||||
END_C_DECLS
|
END_C_DECLS
|
||||||
|
|
||||||
#endif /*TK_SYSTEM_INFO_H*/
|
#endif /*TK_SYSTEM_INFO_H*/
|
||||||
|
@ -394,8 +394,8 @@ static ret_t lcd_mem_resize(lcd_t* lcd, wh_t w, wh_t h, uint32_t line_length) {
|
|||||||
return RET_OK;
|
return RET_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static ret_t lcd_mem_set_orientation(lcd_t* lcd, lcd_orientation_t orientation) {
|
static ret_t lcd_mem_set_orientation(lcd_t* lcd, lcd_orientation_t old_orientation, lcd_orientation_t new_orientation) {
|
||||||
if (orientation == LCD_ORIENTATION_90 || orientation == LCD_ORIENTATION_270) {
|
if (tk_is_swap_size_by_orientation(old_orientation, new_orientation)) {
|
||||||
return lcd_mem_resize(lcd, lcd->h, lcd->w, 0);
|
return lcd_mem_resize(lcd, lcd->h, lcd->w, 0);
|
||||||
}
|
}
|
||||||
return RET_OK;
|
return RET_OK;
|
||||||
|
@ -281,8 +281,8 @@ static ret_t lcd_mem_fragment_resize(lcd_t* lcd, wh_t w, wh_t h, uint32_t line_l
|
|||||||
return RET_OK;
|
return RET_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static ret_t lcd_mem_fragment_set_orientation(lcd_t* lcd, lcd_orientation_t orientation) {
|
static ret_t lcd_mem_fragment_set_orientation(lcd_t* lcd, lcd_orientation_t old_orientation, lcd_orientation_t new_orientation) {
|
||||||
if (orientation == LCD_ORIENTATION_90 || orientation == LCD_ORIENTATION_270) {
|
if (tk_is_swap_size_by_orientation(old_orientation, new_orientation)) {
|
||||||
return lcd_mem_fragment_resize(lcd, lcd->h, lcd->w, 0);
|
return lcd_mem_fragment_resize(lcd, lcd->h, lcd->w, 0);
|
||||||
}
|
}
|
||||||
return RET_OK;
|
return RET_OK;
|
||||||
|
@ -173,8 +173,8 @@ static ret_t lcd_mono_resize(lcd_t* lcd, wh_t w, wh_t h, uint32_t line_length) {
|
|||||||
return lcd_sdl2_mono_reinit(lcd, w, h, line_length);
|
return lcd_sdl2_mono_reinit(lcd, w, h, line_length);
|
||||||
}
|
}
|
||||||
|
|
||||||
static ret_t lcd_mono_set_orientation(lcd_t* lcd, lcd_orientation_t orientation) {
|
static ret_t lcd_mono_set_orientation(lcd_t* lcd, lcd_orientation_t old_orientation, lcd_orientation_t new_orientation) {
|
||||||
if (orientation == LCD_ORIENTATION_90 || orientation == LCD_ORIENTATION_270) {
|
if (tk_is_swap_size_by_orientation(old_orientation, new_orientation)) {
|
||||||
return lcd_mono_resize(lcd, lcd->h, lcd->w, 0);
|
return lcd_mono_resize(lcd, lcd->h, lcd->w, 0);
|
||||||
}
|
}
|
||||||
return RET_OK;
|
return RET_OK;
|
||||||
|
@ -45,8 +45,8 @@ static ret_t lcd_vgcanvas_resize(lcd_t* lcd, wh_t w, wh_t h, uint32_t line_lengt
|
|||||||
return RET_OK;
|
return RET_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static ret_t lcd_vgcanvas_set_orientation(lcd_t* lcd, lcd_orientation_t orientation) {
|
static ret_t lcd_vgcanvas_set_orientation(lcd_t* lcd, lcd_orientation_t old_orientation, lcd_orientation_t new_orientation) {
|
||||||
if (orientation == LCD_ORIENTATION_90 || orientation == LCD_ORIENTATION_270) {
|
if (tk_is_swap_size_by_orientation(old_orientation, new_orientation)) {
|
||||||
return lcd_vgcanvas_resize(lcd, lcd->h, lcd->w, 0);
|
return lcd_vgcanvas_resize(lcd, lcd->h, lcd->w, 0);
|
||||||
}
|
}
|
||||||
return RET_OK;
|
return RET_OK;
|
||||||
|
@ -102,7 +102,7 @@ static ret_t native_window_fb_gl_resize(native_window_t* win, wh_t w, wh_t h) {
|
|||||||
|
|
||||||
fb_gl->w = win->rect.w = w;
|
fb_gl->w = win->rect.w = w;
|
||||||
fb_gl->h = win->rect.h = h;
|
fb_gl->h = win->rect.h = h;
|
||||||
if (system_info()->lcd_orientation == LCD_ORIENTATION_0 && (w != info.w || h != info.h)) {
|
if (w != info.w || h != info.h) {
|
||||||
ret = lcd_resize(fb_gl->canvas.lcd, w, h, 0);
|
ret = lcd_resize(fb_gl->canvas.lcd, w, h, 0);
|
||||||
return_value_if_fail(ret == RET_OK, ret);
|
return_value_if_fail(ret == RET_OK, ret);
|
||||||
system_info_set_lcd_w(system_info(), w);
|
system_info_set_lcd_w(system_info(), w);
|
||||||
@ -112,6 +112,24 @@ static ret_t native_window_fb_gl_resize(native_window_t* win, wh_t w, wh_t h) {
|
|||||||
return RET_OK;
|
return RET_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static ret_t native_window_fb_gl_set_orientation(native_window_t* win, lcd_orientation_t old_orientation, lcd_orientation_t new_orientation) {
|
||||||
|
wh_t w, h;
|
||||||
|
ret_t ret = RET_OK;
|
||||||
|
native_window_info_t info;
|
||||||
|
native_window_fb_gl_t* fb_gl = NATIVE_WINDOW_FB_GL(win);
|
||||||
|
native_window_get_info(win, &info);
|
||||||
|
w = info.w;
|
||||||
|
h = info.h;
|
||||||
|
if (tk_is_swap_size_by_orientation(old_orientation, new_orientation)) {
|
||||||
|
w = info.h;
|
||||||
|
h = info.w;
|
||||||
|
}
|
||||||
|
|
||||||
|
fb_gl->w = win->rect.w = w;
|
||||||
|
fb_gl->h = win->rect.h = h;
|
||||||
|
return RET_OK;
|
||||||
|
}
|
||||||
|
|
||||||
static canvas_t* native_window_fb_gl_get_canvas(native_window_t* win) {
|
static canvas_t* native_window_fb_gl_get_canvas(native_window_t* win) {
|
||||||
native_window_fb_gl_t* fb_gl = NATIVE_WINDOW_FB_GL(win);
|
native_window_fb_gl_t* fb_gl = NATIVE_WINDOW_FB_GL(win);
|
||||||
|
|
||||||
@ -153,6 +171,7 @@ static const native_window_vtable_t s_native_window_vtable = {
|
|||||||
.move = native_window_fb_gl_move,
|
.move = native_window_fb_gl_move,
|
||||||
.get_info = native_window_fb_gl_get_info,
|
.get_info = native_window_fb_gl_get_info,
|
||||||
.resize = native_window_fb_gl_resize,
|
.resize = native_window_fb_gl_resize,
|
||||||
|
.set_orientation = native_window_fb_gl_set_orientation,
|
||||||
.swap_buffer = native_window_fb_gl_swap_buffer,
|
.swap_buffer = native_window_fb_gl_swap_buffer,
|
||||||
.gl_make_current = native_window_sdl_gl_make_current,
|
.gl_make_current = native_window_sdl_gl_make_current,
|
||||||
.get_canvas = native_window_fb_gl_get_canvas};
|
.get_canvas = native_window_fb_gl_get_canvas};
|
||||||
|
@ -54,7 +54,7 @@ static ret_t native_window_raw_resize(native_window_t* win, wh_t w, wh_t h) {
|
|||||||
native_window_info_t info;
|
native_window_info_t info;
|
||||||
native_window_get_info(win, &info);
|
native_window_get_info(win, &info);
|
||||||
|
|
||||||
if (system_info()->lcd_orientation == LCD_ORIENTATION_0 && (w != info.w || h != info.h)) {
|
if (w != info.w || h != info.h) {
|
||||||
native_window_raw_t* raw = NATIVE_WINDOW_RAW(win);
|
native_window_raw_t* raw = NATIVE_WINDOW_RAW(win);
|
||||||
|
|
||||||
ret = lcd_resize(raw->canvas.lcd, w, h, 0);
|
ret = lcd_resize(raw->canvas.lcd, w, h, 0);
|
||||||
@ -70,6 +70,25 @@ static ret_t native_window_raw_resize(native_window_t* win, wh_t w, wh_t h) {
|
|||||||
return RET_OK;
|
return RET_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static ret_t native_window_raw_set_orientation(native_window_t* win, lcd_orientation_t old_orientation, lcd_orientation_t new_orientation) {
|
||||||
|
wh_t w, h;
|
||||||
|
ret_t ret = RET_OK;
|
||||||
|
native_window_info_t info;
|
||||||
|
native_window_get_info(win, &info);
|
||||||
|
|
||||||
|
w = info.w;
|
||||||
|
h = info.h;
|
||||||
|
if (new_orientation == LCD_ORIENTATION_90 || new_orientation == LCD_ORIENTATION_270) {
|
||||||
|
w = info.h;
|
||||||
|
h = info.w;
|
||||||
|
}
|
||||||
|
|
||||||
|
win->rect.w = w;
|
||||||
|
win->rect.h = h;
|
||||||
|
|
||||||
|
return RET_OK;
|
||||||
|
}
|
||||||
|
|
||||||
static canvas_t* native_window_raw_get_canvas(native_window_t* win) {
|
static canvas_t* native_window_raw_get_canvas(native_window_t* win) {
|
||||||
native_window_raw_t* raw = NATIVE_WINDOW_RAW(win);
|
native_window_raw_t* raw = NATIVE_WINDOW_RAW(win);
|
||||||
|
|
||||||
|
@ -90,7 +90,7 @@ static ret_t native_window_sdl_resize(native_window_t* win, wh_t w, wh_t h) {
|
|||||||
win->rect.h = h;
|
win->rect.h = h;
|
||||||
|
|
||||||
#if !defined(ANDROID) && !defined(IOS)
|
#if !defined(ANDROID) && !defined(IOS)
|
||||||
if (system_info()->lcd_orientation == LCD_ORIENTATION_0 && (w != info.w || h != info.h)) {
|
if (w != info.w || h != info.h) {
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
w = w * win->ratio;
|
w = w * win->ratio;
|
||||||
h = h * win->ratio;
|
h = h * win->ratio;
|
||||||
@ -106,6 +106,24 @@ static ret_t native_window_sdl_resize(native_window_t* win, wh_t w, wh_t h) {
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static ret_t native_window_sdl_set_orientation(native_window_t* win, lcd_orientation_t old_orientation, lcd_orientation_t new_orientation) {
|
||||||
|
wh_t w, h;
|
||||||
|
native_window_info_t info;
|
||||||
|
native_window_sdl_t* sdl = NATIVE_WINDOW_SDL(win);
|
||||||
|
return_value_if_fail(sdl != NULL, RET_BAD_PARAMS);
|
||||||
|
native_window_get_info(win, &info);
|
||||||
|
w = info.w;
|
||||||
|
h = info.h;
|
||||||
|
if (new_orientation == LCD_ORIENTATION_90 || new_orientation == LCD_ORIENTATION_270) {
|
||||||
|
w = info.h;
|
||||||
|
h = info.w;
|
||||||
|
}
|
||||||
|
|
||||||
|
win->rect.w = w;
|
||||||
|
win->rect.h = h;
|
||||||
|
return RET_OK;
|
||||||
|
}
|
||||||
|
|
||||||
static ret_t native_window_sdl_minimize(native_window_t* win) {
|
static ret_t native_window_sdl_minimize(native_window_t* win) {
|
||||||
native_window_sdl_t* sdl = NATIVE_WINDOW_SDL(win);
|
native_window_sdl_t* sdl = NATIVE_WINDOW_SDL(win);
|
||||||
|
|
||||||
@ -383,6 +401,7 @@ static const native_window_vtable_t s_native_window_vtable = {
|
|||||||
.type = "native_window_sdl",
|
.type = "native_window_sdl",
|
||||||
.move = native_window_sdl_move,
|
.move = native_window_sdl_move,
|
||||||
.resize = native_window_sdl_resize,
|
.resize = native_window_sdl_resize,
|
||||||
|
.set_orientation = native_window_sdl_set_orientation,
|
||||||
.minimize = native_window_sdl_minimize,
|
.minimize = native_window_sdl_minimize,
|
||||||
.maximize = native_window_sdl_maximize,
|
.maximize = native_window_sdl_maximize,
|
||||||
.restore = native_window_sdl_restore,
|
.restore = native_window_sdl_restore,
|
||||||
|
@ -1123,27 +1123,46 @@ static ret_t window_manager_default_is_animating(widget_t* widget, bool_t* playi
|
|||||||
return RET_OK;
|
return RET_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static ret_t window_manager_default_orientation(widget_t* widget, wh_t w, wh_t h, lcd_orientation_t old_orientation, lcd_orientation_t new_orientation) {
|
||||||
|
ret_t ret = RET_OK;
|
||||||
|
rect_t r = rect_init(0, 0, w, h);
|
||||||
|
window_manager_default_t* wm = WINDOW_MANAGER_DEFAULT(widget);
|
||||||
|
return_value_if_fail(wm != NULL, RET_BAD_PARAMS);
|
||||||
|
|
||||||
|
ret = native_window_set_orientation(wm->native_window, old_orientation, new_orientation);
|
||||||
|
return_value_if_fail(ret == RET_OK, ret);
|
||||||
|
|
||||||
|
widget_move_resize(widget, 0, 0, w, h);
|
||||||
|
native_window_invalidate(wm->native_window, &r);
|
||||||
|
native_window_update_last_dirty_rect(wm->native_window);
|
||||||
|
|
||||||
|
return widget_layout_children(widget);
|
||||||
|
}
|
||||||
|
|
||||||
ret_t window_manager_default_on_event(widget_t* widget, event_t* e) {
|
ret_t window_manager_default_on_event(widget_t* widget, event_t* e) {
|
||||||
ret_t ret = RET_OK;
|
ret_t ret = RET_OK;
|
||||||
window_manager_default_t* wm = WINDOW_MANAGER_DEFAULT(widget);
|
window_manager_default_t* wm = WINDOW_MANAGER_DEFAULT(widget);
|
||||||
return_value_if_fail(wm != NULL, RET_BAD_PARAMS);
|
return_value_if_fail(wm != NULL, RET_BAD_PARAMS);
|
||||||
if (e->type == EVT_ORIENTATION_WILL_CHANGED) {
|
if (e->type == EVT_ORIENTATION_WILL_CHANGED) {
|
||||||
wh_t w = wm->lcd_w;
|
wh_t w, h;
|
||||||
wh_t h = wm->lcd_h;
|
lcd_orientation_t new_orientation;
|
||||||
lcd_orientation_t orientation;
|
lcd_orientation_t old_orientation;
|
||||||
orientation_event_t* evt = orientation_event_cast(e);
|
orientation_event_t* evt = orientation_event_cast(e);
|
||||||
lcd_t* lcd = native_window_get_canvas(wm->native_window)->lcd;
|
lcd_t* lcd = native_window_get_canvas(wm->native_window)->lcd;
|
||||||
return_value_if_fail(lcd != NULL && evt != NULL, RET_FAIL);
|
return_value_if_fail(lcd != NULL && evt != NULL, RET_FAIL);
|
||||||
orientation = evt->orientation;
|
w = lcd->w;
|
||||||
|
h = lcd->h;
|
||||||
|
new_orientation = evt->orientation;
|
||||||
|
old_orientation = evt->old_orientation;
|
||||||
native_window_clear_dirty_rect(wm->native_window);
|
native_window_clear_dirty_rect(wm->native_window);
|
||||||
if (orientation == LCD_ORIENTATION_90 || orientation == LCD_ORIENTATION_270) {
|
if (tk_is_swap_size_by_orientation(old_orientation, new_orientation)) {
|
||||||
w = wm->lcd_h;
|
w = lcd->h;
|
||||||
h = wm->lcd_w;
|
h = lcd->w;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = lcd_set_orientation(lcd, orientation);
|
ret = lcd_set_orientation(lcd, old_orientation, new_orientation);
|
||||||
return_value_if_fail(ret == RET_OK, ret);
|
return_value_if_fail(ret == RET_OK, ret);
|
||||||
window_manager_default_resize(widget, w, h);
|
window_manager_default_orientation(widget, w, h, old_orientation, new_orientation);
|
||||||
e->type = EVT_ORIENTATION_CHANGED;
|
e->type = EVT_ORIENTATION_CHANGED;
|
||||||
|
|
||||||
widget_dispatch(widget, e);
|
widget_dispatch(widget, e);
|
||||||
|
Loading…
Reference in New Issue
Block a user