mirror of
https://gitee.com/zlgopen/awtk.git
synced 2024-12-02 03:58:33 +08:00
improve lcd rotation
This commit is contained in:
parent
0545906c9f
commit
173f166fff
@ -1,4 +1,8 @@
|
||||
# 最新动态
|
||||
|
||||
2022/02/22
|
||||
* 统一lcd旋转的方向为逆时针和增加相关接口的说明(感谢智明提供补丁)。
|
||||
|
||||
2022/02/21
|
||||
* 修复fscript global对象初始化的问题。
|
||||
* 修复value\_int64/value\_uint64对大数的处理。
|
||||
|
@ -99,7 +99,7 @@ bool_t tk_is_pointer_pressed(void);
|
||||
|
||||
/**
|
||||
* @method tk_set_lcd_orientation
|
||||
* 设置屏幕的旋转方向(XXX:目前仅支持0度和90度)。
|
||||
* 设置屏幕的旋转方向(XXX:目前仅支持0度,90度,180度和270度,旋转方向为逆时针方向)。
|
||||
* @param {int} orientation 旋转方向。
|
||||
*
|
||||
* @return {ret_t} 返回RET_OK表示成功,否则表示失败。
|
||||
|
@ -99,13 +99,8 @@ ret_t pointer_event_rotate(pointer_event_t* evt, system_info_t* info) {
|
||||
|
||||
switch (info->lcd_orientation) {
|
||||
case LCD_ORIENTATION_90: {
|
||||
#ifdef WITH_GPU
|
||||
evt->y = info->lcd_w - x - 1;
|
||||
evt->x = y;
|
||||
#else
|
||||
evt->y = x;
|
||||
evt->x = info->lcd_h - y - 1;
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
case LCD_ORIENTATION_180: {
|
||||
@ -114,13 +109,8 @@ ret_t pointer_event_rotate(pointer_event_t* evt, system_info_t* info) {
|
||||
break;
|
||||
}
|
||||
case LCD_ORIENTATION_270: {
|
||||
#ifdef WITH_GPU
|
||||
evt->y = x;
|
||||
evt->x = info->lcd_h - y - 1;
|
||||
#else
|
||||
evt->y = info->lcd_w - x - 1;
|
||||
evt->x = y;
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
default:
|
||||
|
@ -970,7 +970,7 @@ event_t* window_event_init(window_event_t* event, uint32_t type, void* target, w
|
||||
|
||||
/**
|
||||
* @method pointer_event_rotate
|
||||
* 根据屏幕旋转方向修正pointer_event中的坐标。
|
||||
* 根据屏幕旋转方向修正pointer_event中的坐标。(旋转方向为逆时针)
|
||||
* @param {pointer_event_t*} evt 指针事件对象。
|
||||
* @param {system_info_t*} info 系统信息。
|
||||
*
|
||||
|
@ -40,13 +40,13 @@ static ret_t vgcanvas_nanovg_begin_frame(vgcanvas_t* vgcanvas, const dirty_rects
|
||||
angle = 0.0f;
|
||||
break;
|
||||
case LCD_ORIENTATION_90:
|
||||
angle = TK_D2R(90);
|
||||
angle = TK_D2R(270);
|
||||
break;
|
||||
case LCD_ORIENTATION_180:
|
||||
angle = TK_D2R(180);
|
||||
break;
|
||||
case LCD_ORIENTATION_270:
|
||||
angle = TK_D2R(270);
|
||||
angle = TK_D2R(90);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -19,6 +19,20 @@ TEST(Events, pointer_event_rotate) {
|
||||
e.y = 20;
|
||||
info.lcd_orientation = LCD_ORIENTATION_90;
|
||||
ASSERT_EQ(pointer_event_rotate(&e, &info), RET_OK);
|
||||
ASSERT_EQ(e.y, 10);
|
||||
ASSERT_EQ(e.x, 459);
|
||||
|
||||
e.x = 10;
|
||||
e.y = 20;
|
||||
info.lcd_orientation = LCD_ORIENTATION_180;
|
||||
ASSERT_EQ(pointer_event_rotate(&e, &info), RET_OK);
|
||||
ASSERT_EQ(e.y, 459);
|
||||
ASSERT_EQ(e.x, 309);
|
||||
|
||||
e.x = 10;
|
||||
e.y = 20;
|
||||
info.lcd_orientation = LCD_ORIENTATION_270;
|
||||
ASSERT_EQ(pointer_event_rotate(&e, &info), RET_OK);
|
||||
ASSERT_EQ(e.y, 309);
|
||||
ASSERT_EQ(e.x, 20);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user