整定一版

This commit is contained in:
冯佳
2025-12-19 17:01:27 +08:00
parent 294a49f207
commit 8bddc34c88
43 changed files with 7273 additions and 956 deletions

104
src/core/menu_stack.h Normal file
View File

@ -0,0 +1,104 @@
/**
**********************************************************************************************************************
* @file menu_stack.h
* @brief 菜单组件栈管理功能声明
* @author menu_component
* @date 2025-12-19
**********************************************************************************************************************
*/
#ifndef MENU_STACK_H
#define MENU_STACK_H
/* Includes ----------------------------------------------------------------------------------------------------------*/
#include "menu_types.h"
/* 函数声明 ---------------------------------------------------------------------------------------------------------*/
/**
* @brief 初始化菜单栈
* @param stack 栈指针
* @param max_depth 最大深度
*/
void menu_stack_init(MenuStack* stack, uint8_t max_depth);
/**
* @brief 检查栈是否为空
* @param stack 栈指针
* @return true为空false不为空
*/
bool menu_stack_is_empty(const MenuStack* stack);
/**
* @brief 检查栈是否已满
* @param stack 栈指针
* @return true已满false未满
*/
bool menu_stack_is_full(const MenuStack* stack);
/**
* @brief 获取栈的当前深度
* @param stack 栈指针
* @return 当前深度
*/
uint8_t menu_stack_get_depth(const MenuStack* stack);
/**
* @brief 向栈中压入元素
* @param stack 栈指针
* @param node_id 要压入的节点ID
* @return 错误码
*/
MenuErrCode menu_stack_push(MenuStack* stack, MenuNodeId node_id);
/**
* @brief 从栈中弹出元素
* @param stack 栈指针
* @param node_id 用于存储弹出的节点ID
* @return 错误码
*/
MenuErrCode menu_stack_pop(MenuStack* stack, MenuNodeId* node_id);
/**
* @brief 获取栈顶元素
* @param stack 栈指针
* @param node_id 用于存储栈顶节点ID
* @return 错误码
*/
MenuErrCode menu_stack_peek(const MenuStack* stack, MenuNodeId* node_id);
/**
* @brief 清空栈
* @param stack 栈指针
*/
void menu_stack_clear(MenuStack* stack);
/**
* @brief 初始化菜单导航路径
* @param nav_path 导航路径指针
* @param max_depth 最大深度
*/
void menu_nav_path_init(MenuNavPath* nav_path, uint8_t max_depth);
/**
* @brief 添加导航路径节点
* @param nav_path 导航路径指针
* @param node_id 要添加的节点ID
* @return 错误码
*/
MenuErrCode menu_nav_path_add(MenuNavPath* nav_path, MenuNodeId node_id);
/**
* @brief 移除导航路径最后一个节点
* @param nav_path 导航路径指针
* @return 错误码
*/
MenuErrCode menu_nav_path_remove_last(MenuNavPath* nav_path);
/**
* @brief 清空导航路径
* @param nav_path 导航路径指针
*/
void menu_nav_path_clear(MenuNavPath* nav_path);
#endif /* MENU_STACK_H */