📄 wgui_categories_mm.c
字号:
/*****************************************************************************
* FUNCTION
* setup_main_menu
* DESCRIPTION
* set main menu values such as number sof itens, size of image
* PARAMETERS
* m [IN] Menu
* x [IN] Start of x position
* y [IN] Start of y position
* n_items [IN] Number of items
* list_of_items [IN] Images of menus
* RETURNS
* void
*****************************************************************************/
void setup_main_menu(matrix_main_menu *m, S32 x, S32 y, S32 n_items, PU8 *list_of_items)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
m->x = x;
m->y = y;
if (n_items < 0)
{
n_items = 0;
}
if (n_items > MAIN_MENU_MAX_ITEMS)
{
n_items = MAIN_MENU_MAX_ITEMS;
}
m->flags = 0;
m->n_items = n_items;
m->list_of_items = list_of_items;
m->highlighted_item = -1;
m->item_highlighted = UI_dummy_function_s32;
m->item_unhighlighted = UI_dummy_function_s32;
m->highlight_area.color_depth = 16;
m->highlight_area.palette = NULL;
m->highlight_area.data = matrix_main_menu_highlight_bitmap_data;
m->highlight_area.xsize = MAIN_MENU_HIGHLIGHTED_IMAGE_WIDTH;
m->highlight_area.ysize = MAIN_MENU_HIGHLIGHTED_IMAGE_HEIGHT;
m->highlight_area.row_bytes = m->highlight_area.xsize * 2;
}
/*****************************************************************************
* FUNCTION
* show_main_menu
* DESCRIPTION
* show main menu
* PARAMETERS
* m [IN] Menu
* RETURNS
* void
*****************************************************************************/
void show_main_menu(matrix_main_menu *m)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
S32 i, row, column, x, y;
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
row = column = 0;
gui_reset_clip();
x = m->x;
y = m->y;
for (i = 0; i < m->n_items; i++)
{
gui_set_clip(x, y, x + MAIN_MENU_NORMAL_IMAGE_CLIP_WIDTH - 1, y + MAIN_MENU_NORMAL_IMAGE_CLIP_HEIGHT - 1);
gui_show_image(
x + DIRECT_MAIN_MENU_FIRST_FRAME_SHIFT_X,
y + DIRECT_MAIN_MENU_FIRST_FRAME_SHIFT_Y,
m->list_of_items[i]);
column++;
x += MAIN_MENU_NORMAL_IMAGE_WIDTH;
if (column >= MAIN_MENU_N_COLUMNS)
{
column = 0;
x = m->x;
row++;
y += MAIN_MENU_NORMAL_IMAGE_HEIGHT;
if (row >= MAIN_MENU_N_ROWS)
{
break;
}
}
}
m->flags &= ~MAIN_MENU_ITEM_HIGHLIGHTED;
if (m->flags & MAIN_MENU_DISPLAY_GRID)
{
color c = MAIN_MENU_NORMAL_GRID_COLOR;
S32 i, x, y, x1, y1, x2, y2;
gui_reset_clip();
x = x1 = m->x;
y = y1 = m->y;
x2 = x1 + (MAIN_MENU_NORMAL_IMAGE_WIDTH * MAIN_MENU_N_COLUMNS);
y2 = y1 + (MAIN_MENU_NORMAL_IMAGE_HEIGHT * MAIN_MENU_N_ROWS);
for (i = 0; i < 4; i++)
{
gui_draw_horizontal_line(x1, x2, y, c);
gui_draw_vertical_line(y1, y2, x, c);
x += MAIN_MENU_NORMAL_IMAGE_WIDTH;
y += MAIN_MENU_NORMAL_IMAGE_HEIGHT;
}
}
}
#if((UI_ENABLE_FRAME_SKIPPING) && (ENABLE_DIRECT_MAIN_MENU_FRAME_SKIPPING))
/*****************************************************************************
* FUNCTION
* update_main_menu_highlight
* DESCRIPTION
* Enlarge the image of highlighted main menu item
* PARAMETERS
* m [IN] Menu
* RETURNS
* void
*****************************************************************************/
void update_main_menu_highlight(matrix_main_menu *m)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
S32 row, column, x, y, tx, ty;
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
gui_reset_clip();
/* Display the screen bitmap grabbed earlier */
if (m->flags & MAIN_MENU_ITEM_HIGHLIGHTED)
{
_show_bitmap(m->save_x, m->save_y, &m->highlight_area);
}
if ((m->highlighted_item < 0) || (m->highlighted_item >= m->n_items))
{
m->flags &= ~MAIN_MENU_ITEM_HIGHLIGHTED;
return;
}
/* Calculate (x,y) for the highlight */
row = m->highlighted_item / MAIN_MENU_N_COLUMNS;
column = m->highlighted_item % MAIN_MENU_N_COLUMNS;
ty = row * MAIN_MENU_NORMAL_IMAGE_HEIGHT;
tx = column * MAIN_MENU_NORMAL_IMAGE_WIDTH;
x = tx - MAIN_MENU_HIGHLIGHT_OFFSET_X;
y = ty - MAIN_MENU_HIGHLIGHT_OFFSET_Y;
if (m->flags & MAIN_MENU_DISPLAY_ITEM_GRID)
{
x -= 1;
y -= 1;
}
#if(DIRECT_MAIN_MENU_BOUNDARY_SPACING)
if (x < 0)
{
x = 0;
}
if ((x + MAIN_MENU_HIGHLIGHTED_IMAGE_WIDTH) > (MAIN_MENU_N_COLUMNS * MAIN_MENU_NORMAL_IMAGE_WIDTH))
{
x = MAIN_MENU_N_COLUMNS * MAIN_MENU_NORMAL_IMAGE_WIDTH - MAIN_MENU_HIGHLIGHTED_IMAGE_WIDTH;
}
if (y < 0)
{
y = 0;
}
if ((y + MAIN_MENU_HIGHLIGHTED_IMAGE_HEIGHT) > (MAIN_MENU_N_ROWS * MAIN_MENU_NORMAL_IMAGE_HEIGHT - 1))
{
y = MAIN_MENU_N_ROWS * MAIN_MENU_NORMAL_IMAGE_HEIGHT - MAIN_MENU_HIGHLIGHTED_IMAGE_HEIGHT - 1;
}
#else /* (DIRECT_MAIN_MENU_BOUNDARY_SPACING) */
if (x < -1)
{
x = -1;
}
if ((x + MAIN_MENU_HIGHLIGHTED_IMAGE_WIDTH) > (MAIN_MENU_N_COLUMNS * MAIN_MENU_NORMAL_IMAGE_WIDTH + 1))
{
x = MAIN_MENU_N_COLUMNS * MAIN_MENU_NORMAL_IMAGE_WIDTH - MAIN_MENU_HIGHLIGHTED_IMAGE_WIDTH + 1;
}
if (y < -1)
{
y = -1;
}
if ((y + MAIN_MENU_HIGHLIGHTED_IMAGE_HEIGHT) > (MAIN_MENU_N_ROWS * MAIN_MENU_NORMAL_IMAGE_HEIGHT))
{
y = MAIN_MENU_N_ROWS * MAIN_MENU_NORMAL_IMAGE_HEIGHT - MAIN_MENU_HIGHLIGHTED_IMAGE_HEIGHT;
}
#endif /* (DIRECT_MAIN_MENU_BOUNDARY_SPACING) */
x += m->x;
y += m->y;
if (m->flags & MAIN_MENU_DISPLAY_ITEM_GRID)
{ /* Grab a new screen bitmap for the portion that will be affected */
_get_bitmap(
x,
y,
x + MAIN_MENU_HIGHLIGHTED_IMAGE_WIDTH,
y + MAIN_MENU_HIGHLIGHTED_IMAGE_HEIGHT,
&m->highlight_area);
m->save_x = x;
m->save_y = y;
/* Display the highlighted item */
mtk_show_animation_frames(x, y, m->list_of_items[m->highlighted_item], 1);
}
else
{ /* Grab a new screen bitmap for the portion that will be affected */
_get_bitmap(
x,
y,
x + MAIN_MENU_HIGHLIGHTED_IMAGE_WIDTH - 1,
y + MAIN_MENU_HIGHLIGHTED_IMAGE_HEIGHT - 1,
&m->highlight_area);
m->save_x = x;
m->save_y = y;
/* Display the highlighted item */
mtk_show_animation_frames(x, y, m->list_of_items[m->highlighted_item], 1);
}
m->flags |= MAIN_MENU_ITEM_HIGHLIGHTED;
gdi_layer_blt_previous(MAIN_MENU_X1, MAIN_MENU_Y1 - 1, MAIN_MENU_X2, MAIN_MENU_Y2);
}
/*****************************************************************************
* FUNCTION
* wgui_matrix_main_menu_end_frame
* DESCRIPTION
* show the frames of main menu animation image of high lighted item
* PARAMETERS
* void
* matrix_main_menu(?) [IN] *m :- menu
* RETURNS
* void
*****************************************************************************/
void wgui_matrix_main_menu_end_frame(void)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
if (wgui_matrix_main_menu_frame_counter >= 1)
{
update_main_menu_highlight(&_wgui_main_menu);
wgui_matrix_main_menu_frame_counter = 0;
gui_start_timer(DIRECT_MAIN_MENU_FRAME_SKIP_RATE, wgui_matrix_main_menu_end_frame);
}
}
/*****************************************************************************
* FUNCTION
* show_main_menu_highlight
* DESCRIPTION
* show main menu highlihgted image
* PARAMETERS
* m [IN] Menu
* RETURNS
* void
*****************************************************************************/
void show_main_menu_highlight(matrix_main_menu *m)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
if (wgui_matrix_main_menu_frame_counter > 0)
{
wgui_matrix_main_menu_frame_counter++;
}
else
{
wgui_matrix_main_menu_frame_counter = 1;
gui_start_timer(UI_FRAME_START_TIMEOUT, wgui_matrix_main_menu_end_frame);
}
}
#else /* ((UI_ENABLE_FRAME_SKIPPING) && (ENABLE_DIRECT_MAIN_MENU_FRAME_SKIPPING)) */
/*****************************************************************************
* FUNCTION
* show_main_menu_highlight
* DESCRIPTION
* Enlarge the image of highlighted main menu item
* PARAMETERS
* m [IN] Menu
* RETURNS
* void
*****************************************************************************/
void show_main_menu_highlight(matrix_main_menu *m)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
S32 row, column, x, y, tx, ty;
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
gui_reset_clip();
/* Display the screen bitmap grabbed earlier */
if (m->flags & MAIN_MENU_ITEM_HIGHLIGHTED)
{
_show_bitmap(m->save_x, m->save_y, &m->highlight_area);
}
if ((m->highlighted_item < 0) || (m->highlighted_item >= m->n_items))
{
m->flags &= ~MAIN_MENU_ITEM_HIGHLIGHTED;
return;
}
/* Calculate (x,y) for the highlight */
row = m->highlighted_item / MAIN_MENU_N_COLUMNS;
column = m->highlighted_item % MAIN_MENU_N_COLUMNS;
ty = row * MAIN_MENU_NORMAL_IMAGE_HEIGHT;
tx = column * MAIN_MENU_NORMAL_IMAGE_WIDTH;
x = tx - MAIN_MENU_HIGHLIGHT_OFFSET_X;
y = ty - MAIN_MENU_HIGHLIGHT_OFFSET_Y;
if (m->flags & MAIN_MENU_DISPLAY_ITEM_GRID)
{
x -= 1;
y -= 1;
}
if (x < 0)
{
x = 0;
}
if (y < 0)
{
y = 0;
}
if ((x + MAIN_MENU_HIGHLIGHTED_IMAGE_WIDTH) > (MAIN_MENU_N_COLUMNS * MAIN_MENU_NORMAL_IMAGE_WIDTH))
{
x = MAIN_MENU_N_COLUMNS * MAIN_MENU_NORMAL_IMAGE_WIDTH - MAIN_MENU_HIGHLIGHTED_IMAGE_WIDTH;
}
if ((y + MAIN_MENU_HIGHLIGHTED_IMAGE_HEIGHT) > (MAIN_MENU_N_ROWS * MAIN_MENU_NORMAL_IMAGE_HEIGHT))
{
y = MAIN_MENU_N_ROWS * MAIN_MENU_NORMAL_IMAGE_HEIGHT - MAIN_MENU_HIGHLIGHTED_IMAGE_HEIGHT;
}
x += m->x;
y += m->y;
if (m->flags & MAIN_MENU_DISPLAY_ITEM_GRID)
{ /* Grab a new screen bitmap for the portion that will be affected */
_get_bitmap(
x,
y,
x + MAIN_MENU_HIGHLIGHTED_IMAGE_WIDTH,
y + MAIN_MENU_HIGHLIGHTED_IMAGE_HEIGHT,
&m->highlight_area);
m->save_x = x;
m->save_y = y;
/* Display the highlighted item */
mtk_show_animation_frames(x, y, m->list_of_items[m->highlighted_item], 1);
}
else
{ /* Grab a new screen bitmap for the portion that will be affected */
_get_bitmap(
x,
y,
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -