窗口

此控件为开发者提供了一个虚拟区域,用于放置应用程序所需的控件。开发者可以根据需求创建相对于屏幕的空间。 例如,图1创建了一个与屏幕尺寸相同的区域,而开发者也可以创建不同尺寸的空间,如图2所示。

图1

图2

下图中的控件将以窗口控件的左上角作为初始坐标。


使用方法

创建窗口控件

可以通过 gui_win_create(void *parent, const char *name, int16_t x, int16_t y, int16_t w, int16_t h) 该API创建一个窗口控件, 其中 w/h 是窗口控件的宽度和高度。

API

Functions

gui_win_t *gui_win_create(void *parent, const char *name, int16_t x, int16_t y, int16_t w, int16_t h)

create a window widget.

参数:
  • parent – the father widget the window nested in.

  • filename – the window widget name.

  • x – the X-axis coordinate.

  • x – the Y-axis coordinate.

  • w – the width.

  • h – the hight.

返回:

return the widget object pointer

void gui_win_set_animate(gui_win_t *_this, uint32_t dur, int repeat_count, void *callback, void *p)
参数:
  • o – widget object pointer

  • dur – Animation duration

  • repeat_count – Repeat play times, -1 means play on repeat forever

  • callback – animate frame callback

  • p – parameter

void gui_win_left(gui_win_t *_this, void *callback, void *parameter)
参数:
  • b

  • callback

  • parameter

void gui_win_right(gui_win_t *_this, void *callback, void *parameter)
参数:
  • b

  • callback

  • parameter

void gui_win_up(gui_win_t *_this, void *callback, void *parameter)
参数:
  • b

  • callback

  • parameter

void gui_win_down(gui_win_t *_this, void *callback, void *parameter)
参数:
  • b

  • callback

  • parameter

void gui_win_press(gui_win_t *_this, void *callback, void *parameter)
参数:
  • b

  • callback

  • parameter

void gui_win_release(gui_win_t *_this, void *callback, void *parameter)
参数:
  • b

  • callback

  • parameter

void gui_win_long(gui_win_t *_this, void *callback, void *parameter)
参数:
  • b

  • callback

  • parameter

void gui_win_click(gui_win_t *_this, void *callback, void *parameter)
参数:
  • b

  • callback

  • parameter

void gui_win_hole_tp(gui_win_t *_this, bool hold_tp)
参数:
  • _this

  • hold_tp

float gui_win_get_aniamtion_progress_percent(gui_win_t *win)

Get the animation progress percentage.

参数:
  • win – Pointer to the window structure that contains the animation.

返回:

The current animation progress percentage.

void gui_win_set_scale_rate(gui_win_t *win, float scale_rate_horizontal, float scale_rate_vertical)

Set the scale rate for the window both horizontally and vertically.

参数:
  • win – Pointer to the window structure.

  • scale_rate_horizontal – The horizontal scale rate.

  • scale_rate_vertical – The vertical scale rate.

void gui_win_set_scope(gui_win_t *win, bool enable)

Enable or disable the scope for the window.

参数:
  • win – Pointer to the window structure.

  • enable – A boolean value to enable or disable the scope.

void gui_win_set_opacity(gui_win_t *win, unsigned char opacity_value)

Set the opacity value for the window.

参数:
  • win – Pointer to the window structure.

  • opacity_value – The desired opacity value to set.

bool gui_win_is_animation_end_frame(gui_win_t *win)

Check if the animation is at its end frame.

参数:
  • win – Pointer to the window structure that contains the animation.

返回:

true if the end_frame is not 0, false otherwise.

void gui_win_start_animation(gui_win_t *win)

Start the animation by setting the animate field to 1.

参数:
  • win – Pointer to the window structure that contains the animation. If win or win->animate is NULL, the function will log an error message.

void gui_win_stop_animation(gui_win_t *win)

Stop the animation by setting the animate field to 0.

参数:
  • win – Pointer to the window structure that contains the animation. If win or win->animate is NULL, the function will log an error message.

struct gui_win_t
#include <gui_win.h>

window structure

Public Members

gui_obj_t base
gui_animate_t *animate
float scale
float scale_y
bool press_flag
bool long_flag
bool release_flag
bool enter_auto_scale
bool event5_flag
uint8_t checksum
bool scope
bool hold_tp