📄 im_gui.c
字号:
if (m->last_displayed_item >= m->n_items)
{
m->last_displayed_item = 0;
}
}
else
{
if (m->highlighted_item < m->first_displayed_item)
{
m->first_displayed_item = m->highlighted_item;
}
else if (m->highlighted_item > m->last_displayed_item)
{
U8 done = 0;
S32 total_height = 0, i;
S32 list_height = m->height;
m->last_displayed_item = m->highlighted_item;
for (i = m->last_displayed_item; i >= 0 && (!done); i--)
{
IM_current_fixed_list_display_index = i;
m->item_measure_function(m->items[i], m->common_item_data, &iwidth, &iheight);
total_height += iheight;
if (total_height > list_height)
{
done = 1;
m->first_displayed_item = i + 1;
}
}
}
else
{
U8 done = 0;
S32 total_height = 0, i;
S32 list_height = m->height;
for (i = m->first_displayed_item; i < m->n_items && (!done); i++)
{
IM_current_fixed_list_display_index = i;
m->item_measure_function(m->items[i], m->common_item_data, &iwidth, &iheight);
total_height += iheight;
if (total_height > list_height)
{
done = 1;
m->last_displayed_item = i - 1;
}
}
if (!done)
{
total_height = 0;
for (i = m->n_items - 1; (i >= 0) && (!done); i--)
{
IM_current_fixed_list_display_index = i;
m->item_measure_function(m->items[i], m->common_item_data, &iwidth, &iheight);
total_height += iheight;
if (total_height > list_height)
{
done = 1;
m->first_displayed_item = i + 1;
m->last_displayed_item = m->n_items - 1;
break;
}
}
if (!done)
{
m->first_displayed_item = 0;
m->last_displayed_item = m->n_items - 1;
}
}
if (m->highlighted_item > m->last_displayed_item)
{
done = 0;
total_height = 0;
m->last_displayed_item = m->highlighted_item;
for (i = m->last_displayed_item; i >= 0 && (!done); i--)
{
IM_current_fixed_list_display_index = i;
m->item_measure_function(m->items[i], m->common_item_data, &iwidth, &iheight);
total_height += iheight;
if (total_height > list_height)
{
done = 1;
m->first_displayed_item = i + 1;
//m->first_displayed_item = i;
}
}
}
}
}
/* Located after resized */
m->resized_before_locate = MMI_FALSE;
}
/*****************************************************************************
* FUNCTION
* IM_gui_fixed_list_menu_locate_previous_item
* DESCRIPTION
* Locate the menu item previous to the highlighted item.
* PARAMETERS
* m [IN] fixed list menu object
* RETURNS
* void
*****************************************************************************/
void IM_gui_fixed_list_menu_locate_previous_item(fixed_list_menu *m)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
if (m->flags & UI_LIST_MENU_CENTER_HIGHLIGHTED)
{
if (m->highlighted_item == 0)
{
m->first_displayed_item = m->n_items - 1;
m->last_displayed_item = 1;
}
else
{
m->first_displayed_item = m->highlighted_item - 1;
if (m->first_displayed_item < 0)
{
m->first_displayed_item = m->n_items - 1;
}
m->last_displayed_item = m->highlighted_item + 1;
if (m->last_displayed_item > m->n_items - 1)
{
m->last_displayed_item = 0;
}
}
}
else
{
if (m->highlighted_item < m->first_displayed_item)
{
m->first_displayed_item = m->highlighted_item;
}
else if (m->resized_before_locate)
{
IM_gui_fixed_list_menu_locate_highlighted_item(m);
}
else if (m->highlighted_item == m->last_displayed_item - 1)
{
S32 iwidth, iheight;
U8 done = 0;
S32 total_height = 0, i;
S32 list_height = m->height;
IM_current_fixed_list_display_index = -1;
for (i = m->last_displayed_item; i >= 0 && (!done); i--)
{
IM_current_fixed_list_display_index = i;
m->item_measure_function(m->items[i], m->common_item_data, &iwidth, &iheight);
total_height += iheight;
if (total_height > list_height + 1)
{
done = 1;
//m->first_displayed_item = i + 1;
m->first_displayed_item = i;
}
}
}
}
/* Located after resized */
m->resized_before_locate = MMI_FALSE;
}
/*****************************************************************************
* FUNCTION
* IM_gui_fixed_list_menu_locate_next_item
* DESCRIPTION
* Locate the menu item next to the highlighted item.
* PARAMETERS
* m [IN] fixed list menu object
* RETURNS
* void
*****************************************************************************/
void IM_gui_fixed_list_menu_locate_next_item(fixed_list_menu *m)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
S32 iwidth, iheight;
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
if (m->flags & UI_LIST_MENU_CENTER_HIGHLIGHTED)
{
m->first_displayed_item = m->highlighted_item - 1;
if (m->first_displayed_item < 0)
{
m->first_displayed_item = m->n_items - 1;
}
m->last_displayed_item = m->highlighted_item + 1;
if (m->last_displayed_item >= m->n_items)
{
m->last_displayed_item = 0;
}
}
else
{
if (m->highlighted_item >= m->last_displayed_item - 1)
{
U8 done = 0;
S32 total_height = 0, i;
S32 list_height = m->height;
m->last_displayed_item = m->highlighted_item;
for (i = m->last_displayed_item; i >= 0 && (!done); i--)
{
IM_current_fixed_list_display_index = i;
m->item_measure_function(m->items[i], m->common_item_data, &iwidth, &iheight);
total_height += iheight;
if (total_height > list_height + 1)
{
done = 1;
m->first_displayed_item = i + 1;
}
}
}
else if (m->resized_before_locate)
{
IM_gui_fixed_list_menu_locate_highlighted_item(m);
}
}
/* Located after resized */
m->resized_before_locate = MMI_FALSE;
}
/*****************************************************************************
* FUNCTION
* IM_gui_fixed_list_menu_switch_highlighted_item
* DESCRIPTION
* Switch from the old highlighted item index to the new highlighted item.
* PARAMETERS
* m [IN] fixed list menu object
* last_highlighted_item [IN] old highlighted menu item index
* RETURNS
* void
*****************************************************************************/
static void IM_gui_fixed_list_menu_switch_highlighted_item(fixed_list_menu *m, S32 last_highlighted_item)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
if (last_highlighted_item != m->highlighted_item)
{
if ((last_highlighted_item >= 0) && (last_highlighted_item < m->n_items))
{
m->item_remove_highlight_function(m->items[last_highlighted_item], m->common_item_data);
}
if ((m->highlighted_item >= 0) && (m->highlighted_item < m->n_items))
{
m->item_highlight_function(m->items[m->highlighted_item], m->common_item_data);
}
m->item_unhighlighted(last_highlighted_item);
#ifdef __MMI_TOUCH_SCREEN__
m->pen_event_current_selected_callback_function = m->pen_event_default_selected_callback_function;
#endif
m->item_highlighted(m->highlighted_item);
}
}
/*****************************************************************************
* FUNCTION
* IM_gui_fixed_list_menu_goto_item
* DESCRIPTION
* Go to a specified item index.
* PARAMETERS
* m [IN] fixed list menu object
* i [IN] item index
* RETURNS
* void
*****************************************************************************/
void IM_gui_fixed_list_menu_goto_item(fixed_list_menu *m, S32 i)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
S32 last_highlighted_item;
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
if ((i < 0) || (i > m->n_items - 1))
{
return;
}
if (i == m->highlighted_item)
{
return;
}
last_highlighted_item = m->highlighted_item;
m->highlighted_item = i;
IM_gui_fixed_list_menu_locate_highlighted_item(m);
IM_gui_fixed_list_menu_switch_highlighted_item(m, last_highlighted_item);
}
/*****************************************************************************
* FUNCTION
* IM_gui_fixed_list_menu_goto_next_item
* DESCRIPTION
* Go to the item next to the highlighted item.
* PARAMETERS
* m [IN] fixed list menu object
* RETURNS
* void
*****************************************************************************/
void IM_gui_fixed_list_menu_goto_next_item(fixed_list_menu *m)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
S32 last_highlighted_item;
U8 loop_flag = 0;
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
if (m->highlighted_item >= (m->n_items - 1))
{
if (m->flags & UI_LIST_MENU_LOOP)
{
loop_flag = 1;
}
else
{
return;
}
}
last_highlighted_item = m->highlighted_item;
if (loop_flag)
{
m->highlighted_item = 0;
IM_gui_fixed_list_menu_locate_previous_item(m);
}
else
{
m->highlighted_item++;
IM_gui_fixed_list_menu_locate_next_item(m);
}
IM_gui_fixed_list_menu_switch_highlighted_item(m, last_highlighted_item);
}
/*****************************************************************************
* FUNCTION
* IM_gui_fixed_list_menu_goto_previous_item
* DESCRIPTION
* Go to the item previous to the highlighted item.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -