- Added initial version of Hierarchical Menu
- Beautified the Message Box a bit
This commit is contained in:
@@ -10,6 +10,8 @@
|
||||
#include "Display_Objects.h"
|
||||
#include "Display_Message_Box_Icons.h"
|
||||
|
||||
#include "Hierarchical_Menu.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
|
||||
@@ -93,6 +95,7 @@ void Display_Objects_Clear(void)
|
||||
{
|
||||
Object_Value_Bar_Arc *VA;
|
||||
Object_Menu_Ring *MR;
|
||||
Object_Menu_Hierarchical* MH;
|
||||
Object_Canvas *C;
|
||||
|
||||
for (uint i = 0; i < _Objects.Size; i++)
|
||||
@@ -155,6 +158,13 @@ void Display_Objects_Clear(void)
|
||||
}
|
||||
free(MR);
|
||||
break;
|
||||
case MENU_HIERARCHICAL:
|
||||
MH = (Object_Menu_Hierarchical*)(O->Data);
|
||||
if (MH->Transition_Animation != NULL) {
|
||||
free(MH->Transition_Animation);
|
||||
}
|
||||
free(MH);
|
||||
break;
|
||||
case SELECT_YESNO:
|
||||
free((Object_Select_YesNo*)(O->Data));
|
||||
break;
|
||||
@@ -612,16 +622,15 @@ Object_ID Display_Objects_Add_Canvas(Anchor_Point anchor_point, Coordinates_Type
|
||||
return Display_Objects_Add(CANVAS, anchor_point, coordinates_type, x, y, selectable, (void *)Canvas, style_id, animation_id);
|
||||
}
|
||||
|
||||
Object_ID Display_Objects_Add_Message_Box(Anchor_Point anchor_point, Coordinates_Type coordinates_type, int16_t x, int16_t y, char* text, Font_ID font, Object_Message_Box_Icon icon, Display_Color color, Style_ID style_id)
|
||||
Object_ID Display_Objects_Add_Message_Box(Anchor_Point anchor_point, Coordinates_Type coordinates_type, int16_t x, int16_t y, char* text, Object_Message_Box_Icon icon, const Message_Box_Style* style)
|
||||
{
|
||||
Object_Message_Box *Message_Box = malloc(sizeof(Object_Message_Box));
|
||||
Message_Box->Length = sprintf(Message_Box->Text, "%s", text);
|
||||
Message_Box->Font = Display_Objects_Font_From_ID(font);
|
||||
Message_Box->Color = color;
|
||||
Message_Box->Icon = icon;
|
||||
Message_Box->Style = style;
|
||||
Message_Box->Show_Ticks_Left = 0;
|
||||
|
||||
return Display_Objects_Add(MESSAGE_BOX, anchor_point, coordinates_type, x, y, NOT_SELECTABLE, (void *)Message_Box, style_id, NO_ANIMATION);
|
||||
return Display_Objects_Add(MESSAGE_BOX, anchor_point, coordinates_type, x, y, NOT_SELECTABLE, (void *)Message_Box, NO_STYLE, NO_ANIMATION);
|
||||
}
|
||||
|
||||
Object_ID Display_Objects_Add_Menu_Select(char* menu_titles, uint32_t menu_entry_count, uint32_t title_char_length, uint32_t* selected_entry, Configuration_Menu_Select* config)
|
||||
@@ -700,6 +709,37 @@ Object_ID Display_Objects_Add_Menu_Ring(Menu_Ring_Item_Config* items, uint32_t i
|
||||
return Display_Objects_Add(MENU_RING, LEFT_TOP, BOTH_IN_PIXEL, 0, 0, SELECTABLE, (void *)Menu_Ring, NO_STYLE, NO_ANIMATION);
|
||||
}
|
||||
|
||||
Object_ID Display_Objects_Add_Menu_Hierarchical(const Menu_List** current_list, int32_t* selected_item, int32_t* scroll_offset, Configuration_Menu_Hierarchical* config)
|
||||
{
|
||||
Object_Menu_Hierarchical* Menu_Hierarchical = malloc(sizeof(Object_Menu_Hierarchical));
|
||||
Menu_Hierarchical->Current_List = current_list;
|
||||
Menu_Hierarchical->Selected_Item = selected_item;
|
||||
Menu_Hierarchical->Scroll_Offset = scroll_offset;
|
||||
Menu_Hierarchical->Config = config;
|
||||
|
||||
Menu_Hierarchical->Animation_Counter = 0;
|
||||
Menu_Hierarchical->Transition_Progress = 0.0f;
|
||||
Menu_Hierarchical->Last_Selected_Item = *selected_item;
|
||||
|
||||
Menu_Hierarchical->Last_Current_List = *current_list;
|
||||
Menu_Hierarchical->Last_Selected_Item_Value = *selected_item;
|
||||
Menu_Hierarchical->Last_Scroll_Offset_Value = *scroll_offset;
|
||||
|
||||
Menu_Hierarchical->Transition_Animation = malloc(sizeof(Menu_Hierarchical_Transition_Animation));
|
||||
Menu_Hierarchical->Transition_Animation->State = MENU_HIERARCHICAL_TRANSITION_STATE_IDLE;
|
||||
Menu_Hierarchical->Transition_Animation->Direction = MENU_TRANSITION_ENTER_SUBMENU;
|
||||
Menu_Hierarchical->Transition_Animation->Transition_Counter = 0;
|
||||
Menu_Hierarchical->Transition_Animation->Total_Transition_Frames = MENU_HIERARCHICAL_TRANSITION_FRAMES;
|
||||
Menu_Hierarchical->Transition_Animation->Previous_List = NULL;
|
||||
Menu_Hierarchical->Transition_Animation->Target_List = NULL;
|
||||
Menu_Hierarchical->Transition_Animation->Current_Menu_X_Offset = 0;
|
||||
Menu_Hierarchical->Transition_Animation->Target_Menu_X_Offset = 0;
|
||||
|
||||
Menu_Hierarchical->Transition_Animation_Active = false;
|
||||
|
||||
return Display_Objects_Add(MENU_HIERARCHICAL, LEFT_TOP, BOTH_IN_PIXEL, 0, 0, NOT_SELECTABLE, (void *)Menu_Hierarchical, NO_STYLE, NO_ANIMATION);
|
||||
}
|
||||
|
||||
Object_ID Display_Objects_Add_Select_YesNo(char* title, uint32_t title_length, bool* value, Configuration_Select_YesNo* config)
|
||||
{
|
||||
Object_Select_YesNo* Select_YesNo = malloc(sizeof(Object_Select_YesNo));
|
||||
@@ -737,7 +777,7 @@ Object_ID Display_Objects_Add_Select_Value(char* title, uint32_t title_length, i
|
||||
return Display_Objects_Add(SELECT_VALUE, LEFT_TOP, BOTH_IN_PIXEL, 0, 0, NOT_SELECTABLE, (void *)Select_Value, NO_STYLE, NO_ANIMATION);
|
||||
}
|
||||
|
||||
Object_ID Display_Objects_Add_Select_RGB(RGB_Color* color_value, uint8_t* current_component, Configuration_Select_RGB* config)
|
||||
Object_ID Display_Objects_Add_Select_RGB(LED_Data_t* color_value, uint8_t* current_component, Configuration_Select_RGB* config)
|
||||
{
|
||||
if (color_value == NULL || config == NULL) {
|
||||
return -1; // Invalid parameters
|
||||
@@ -1397,27 +1437,31 @@ Dimension Display_Objects_Get_Content_Size(Display_Object *object)
|
||||
break;
|
||||
|
||||
case MESSAGE_BOX:
|
||||
Display_Font_Set_Font(((Object_Message_Box *)Data)->Font->Font);
|
||||
Dimension.Height = Display_Font_Get_Font_Height() + MESSAGE_BOX_TEXT_BAR_DISTANCE + MESSAGE_BOX_BAR_HEIGHT;
|
||||
Dimension.Width = Display_Font_Width_String((((Object_Message_Box *)Data)->Text), ((Object_Message_Box *)Data)->Length, ((Object_Message_Box *)Data)->Font->Character_Spacing);
|
||||
|
||||
if((((Object_Message_Box *)Data)->Icon) != MESSAGE_BOX_ICON_NONE) {
|
||||
Dimension.Width += MESSAGE_BOX_TEXT_ICON_DISTANCE + Display_Message_Box_Icons_Get_Icon_Width(((Object_Message_Box *)Data)->Icon);
|
||||
Object_Message_Box* MB = (Object_Message_Box *)Data;
|
||||
const Message_Box_Style* Style = MB->Style;
|
||||
|
||||
if(Style == NULL) {
|
||||
return Dimension;
|
||||
}
|
||||
|
||||
|
||||
if(Display_Message_Box_Icons_Get_Icon_Height(((Object_Message_Box *)Data)->Icon) > Display_Font_Get_Font_Height()) {
|
||||
Dimension.Height = Display_Message_Box_Icons_Get_Icon_Height(((Object_Message_Box *)Data)->Icon) + MESSAGE_BOX_TEXT_BAR_DISTANCE + MESSAGE_BOX_BAR_HEIGHT;
|
||||
}
|
||||
Display_Font_Set_Font(Style->Font);
|
||||
Dimension.Height = Display_Font_Get_Font_Height() + 2 * Style->Border_Thickness + Style->Padding[PADDING_TOP] + Style->Padding[PADDING_BOTTOM];
|
||||
Dimension.Width = Display_Font_Width_String(MB->Text, MB->Length, DISPLAY_DEFAULT_CHAR_SPACING) + 2 * Style->Border_Thickness + Style->Padding[PADDING_LEFT] + Style->Padding[PADDING_RIGHT];
|
||||
|
||||
if(MB->Icon != MESSAGE_BOX_ICON_NONE) {
|
||||
Dimension.Width += (MESSAGE_BOX_TEXT_ICON_DISTANCE + Display_Message_Box_Icons_Get_Icon_Width(MB->Icon));
|
||||
}
|
||||
break;
|
||||
|
||||
case MENU_SELECT:
|
||||
case MENU_ICON_ROW:
|
||||
case MENU_RING:
|
||||
case MENU_HIERARCHICAL:
|
||||
case SELECT_YESNO:
|
||||
case SELECT_LIST:
|
||||
case SELECT_VALUE:
|
||||
case SELECT_RGB:
|
||||
Dimension.Height = 0;
|
||||
Dimension.Width = 0;
|
||||
break;
|
||||
|
||||
default:
|
||||
|
||||
Reference in New Issue
Block a user