From ac4e01daf643994cb21e7c906257f2879ee7df49 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A2=A6=E5=87=8C=E6=B1=90?= Date: Thu, 19 Dec 2024 20:48:30 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E5=96=84Menu=E7=B1=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/Menu.h | 107 +++++++++++++++++++++++++++++++++++++++ components/Menu_test.cpp | 44 ++++++++++++++++ 2 files changed, 151 insertions(+) create mode 100644 components/Menu.h create mode 100644 components/Menu_test.cpp diff --git a/components/Menu.h b/components/Menu.h new file mode 100644 index 0000000..9ce4c70 --- /dev/null +++ b/components/Menu.h @@ -0,0 +1,107 @@ +#ifndef MENU_H +#define MENU_H + +#include "BaseComponent.h" +#include "TextLine.h" +#include "../mystl/my_vector.h" +#include "../utils/RichText.h" +#include "../utils/Color.h" +#include + +struct MenuOption { + std::string id, title; + + MenuOption(const std::string& id, const std::string& title) : id(id), title(title) {} + MenuOption() : id(), title() {} +}; + +class Menu : public BaseComponent { +private: + struct Option { + MenuOption option; + Text* text; + + Option(MenuOption option, Text* text) : option(option), text(text) {} + Option() : option(), text(nullptr) {} + }; + MyVector