juk3n/fluffypublic Fork
⑂ cc750ae
Commits
⬇ Clone ▾
git clone https://git.rickub.com/juk3n/fluffy.git
git clone ssh://git@rickub.com/juk3n/fluffy.git

Host key fingerprint (ed25519): SHA256:iycHnxEyq0Q7uyVpB7JlznP0G7JrTPXLYRcAU5CSLhc — verify it before your first connect.

added horizontal menu

Adrian Duraj committed 2024-06-23T13:13:08+02:00 Browse files
cc750ae parent: d0e0dee
modified src/main.cpp +41 -7
@@ -190,18 +190,26 @@ int main(int argc, char const *argv[]) {
190190 int choice = 0;
191191 do {
192192 system("clear");
193- auto document = vbox({
193+
194+ auto header = vbox({
194195 center(text(L" Fluffy v0.1 ")),
195196 });
196197
197- document = document | size(WIDTH, LESS_THAN, 120);
198+ header = header | size(WIDTH, LESS_THAN, 120);
198199
199- auto screen = Screen::Create(Dimension::Full(), Dimension::Fit(document));
200- Render(screen, document);
200+ auto headerScreen = Screen::Create(Dimension::Full(), Dimension::Fit(header));
201+ Render(headerScreen, header);
201202
202- std::cout << screen.ToString() << '\0' << std::endl;
203-
203+ std::cout << headerScreen.ToString() << '\0' << std::endl;
204204
205+ std::vector<std::string> menuOptions{
206+ "Games",
207+ "Info",
208+ };
209+ int menuOptionSelected{ 0 };
210+ auto menuOptionToggle = Toggle(&menuOptions, &menuOptionSelected);
211+
212+
205213 auto menu_screen = ScreenInteractive::TerminalOutput();
206214
207215 std::vector<std::string> localGames = {};
@@ -210,10 +218,36 @@ int main(int argc, char const *argv[]) {
210218 }
211219 localGames.push_back("Exit");
212220
221+
222+ std::vector<std::string> info{
223+ "test",
224+ };
225+ int info_selected = 0;
226+
213227 MenuOption option;
214228 option.on_enter = menu_screen.ExitLoopClosure();
215229 auto menu = Menu(&localGames, &choice, option);
216- menu_screen.Loop(menu);
230+
231+ auto appContainer = Container::Tab({
232+ Menu(&localGames, &choice, option),
233+ Radiobox(&info, &info_selected),
234+ }, &menuOptionSelected);
235+
236+ auto container = Container::Horizontal({
237+ menuOptionToggle,
238+ appContainer,
239+ });
240+
241+ auto renderer = Renderer(container, [&] {
242+ return vbox({
243+ menuOptionToggle->Render(),
244+ separator(),
245+ appContainer->Render(),
246+ }) | border;
247+ });
248+
249+
250+ menu_screen.Loop(renderer);
217251
218252 if (choice != exit_id) {
219253 int i{ 0 };
@@ -190,18 +190,26 @@ int main(int argc, char const *argv[]) {
190 int choice = 0;190 int choice = 0;
191 do {191 do {
192 system("clear");192 system("clear");
193- auto document = vbox({193+
194+ auto header = vbox({
194 center(text(L" Fluffy v0.1 ")),195 center(text(L" Fluffy v0.1 ")),
195 });196 });
196 197
197- document = document | size(WIDTH, LESS_THAN, 120);198+ header = header | size(WIDTH, LESS_THAN, 120);
198 199
199- auto screen = Screen::Create(Dimension::Full(), Dimension::Fit(document));200+ auto headerScreen = Screen::Create(Dimension::Full(), Dimension::Fit(header));
200- Render(screen, document);201+ Render(headerScreen, header);
201 202
202- std::cout << screen.ToString() << '\0' << std::endl;203+ std::cout << headerScreen.ToString() << '\0' << std::endl;
203-
204 204
205+ std::vector<std::string> menuOptions{
206+ "Games",
207+ "Info",
208+ };
209+ int menuOptionSelected{ 0 };
210+ auto menuOptionToggle = Toggle(&menuOptions, &menuOptionSelected);
211+
212+
205 auto menu_screen = ScreenInteractive::TerminalOutput();213 auto menu_screen = ScreenInteractive::TerminalOutput();
206 214
207 std::vector<std::string> localGames = {};215 std::vector<std::string> localGames = {};
@@ -210,10 +218,36 @@ int main(int argc, char const *argv[]) {
210 }218 }
211 localGames.push_back("Exit");219 localGames.push_back("Exit");
212 220
221+
222+ std::vector<std::string> info{
223+ "test",
224+ };
225+ int info_selected = 0;
226+
213 MenuOption option;227 MenuOption option;
214 option.on_enter = menu_screen.ExitLoopClosure();228 option.on_enter = menu_screen.ExitLoopClosure();
215 auto menu = Menu(&localGames, &choice, option);229 auto menu = Menu(&localGames, &choice, option);
216- menu_screen.Loop(menu);230+
231+ auto appContainer = Container::Tab({
232+ Menu(&localGames, &choice, option),
233+ Radiobox(&info, &info_selected),
234+ }, &menuOptionSelected);
235+
236+ auto container = Container::Horizontal({
237+ menuOptionToggle,
238+ appContainer,
239+ });
240+
241+ auto renderer = Renderer(container, [&] {
242+ return vbox({
243+ menuOptionToggle->Render(),
244+ separator(),
245+ appContainer->Render(),
246+ }) | border;
247+ });
248+
249+
250+ menu_screen.Loop(renderer);
217 251
218 if (choice != exit_id) {252 if (choice != exit_id) {
219 int i{ 0 };253 int i{ 0 };