mirror of
https://github.com/CachyOS/New-Cli-Installer.git
synced 2025-02-02 22:07:13 +08:00
🔥 make it scrollable
This commit is contained in:
parent
00e43ff34e
commit
d33c29c516
24
src/tui.cpp
24
src/tui.cpp
@ -150,9 +150,9 @@ void set_xkbmap() noexcept {
|
||||
screen.ExitLoopClosure()();
|
||||
};
|
||||
|
||||
// TODO: menu should be scrollable
|
||||
static constexpr auto xkbmap_body = "\nSelect Desktop Environment Keymap.\n";
|
||||
detail::menu_widget(xkbmap_list, ok_callback, &selected, &screen, xkbmap_body, {5, 0, size(ftxui::HEIGHT, ftxui::GREATER_THAN, 1)});
|
||||
const auto& content_size = size(HEIGHT, GREATER_THAN, 10) | size(WIDTH, GREATER_THAN, 40) | vscroll_indicator | yframe | flex;
|
||||
detail::menu_widget(xkbmap_list, ok_callback, &selected, &screen, xkbmap_body, {content_size, size(ftxui::HEIGHT, ftxui::GREATER_THAN, 1)});
|
||||
|
||||
/* clang-format off */
|
||||
if (!success) { return; }
|
||||
@ -183,7 +183,8 @@ bool set_timezone() noexcept {
|
||||
};
|
||||
|
||||
static constexpr auto timezone_body = "The time zone is used to correctly set your system clock.";
|
||||
detail::menu_widget(zone_list, ok_callback, &selected, &screen, timezone_body, {5, 40, size(ftxui::HEIGHT, ftxui::GREATER_THAN, 1)});
|
||||
const auto& content_size = size(HEIGHT, GREATER_THAN, 10) | size(WIDTH, GREATER_THAN, 40);
|
||||
detail::menu_widget(zone_list, ok_callback, &selected, &screen, timezone_body, {content_size, size(HEIGHT, GREATER_THAN, 1)});
|
||||
}
|
||||
/* clang-format off */
|
||||
if (zone.empty()) { return false; }
|
||||
@ -203,7 +204,8 @@ bool set_timezone() noexcept {
|
||||
};
|
||||
|
||||
static constexpr auto sub_timezone_body = "Select the city nearest to you.";
|
||||
detail::menu_widget(city_list, ok_callback, &selected, &screen, sub_timezone_body, {5, 40, size(ftxui::HEIGHT, ftxui::GREATER_THAN, 1)});
|
||||
const auto& content_size = size(HEIGHT, GREATER_THAN, 10) | size(WIDTH, GREATER_THAN, 40) | vscroll_indicator | yframe | flex;
|
||||
detail::menu_widget(city_list, ok_callback, &selected, &screen, sub_timezone_body, {content_size, size(HEIGHT, GREATER_THAN, 1)});
|
||||
}
|
||||
|
||||
/* clang-format off */
|
||||
@ -236,7 +238,8 @@ void set_hw_clock() noexcept {
|
||||
};
|
||||
|
||||
static constexpr auto hw_clock_body = "UTC is the universal time standard,\nand is recommended unless dual-booting with Windows.";
|
||||
detail::menu_widget(menu_entries, ok_callback, &selected, &screen, hw_clock_body, {5, 40, size(ftxui::HEIGHT, ftxui::GREATER_THAN, 1)});
|
||||
const auto& content_size = size(HEIGHT, GREATER_THAN, 10) | size(WIDTH, GREATER_THAN, 40);
|
||||
detail::menu_widget(menu_entries, ok_callback, &selected, &screen, hw_clock_body, {content_size, size(HEIGHT, GREATER_THAN, 1)});
|
||||
}
|
||||
|
||||
void set_root_password() noexcept {
|
||||
@ -538,7 +541,7 @@ void install_base() noexcept {
|
||||
|
||||
auto screen = ScreenInteractive::Fullscreen();
|
||||
auto content = Renderer(kernels, [&] {
|
||||
return kernels->Render() | vscroll_indicator | center | size(HEIGHT, GREATER_THAN, 10) | size(WIDTH, GREATER_THAN, 40);
|
||||
return kernels->Render() | center | size(HEIGHT, GREATER_THAN, 10) | size(WIDTH, GREATER_THAN, 40) | vscroll_indicator | yframe | flex;
|
||||
});
|
||||
|
||||
std::string packages{};
|
||||
@ -656,7 +659,8 @@ void config_base_menu() noexcept {
|
||||
};
|
||||
|
||||
static constexpr auto config_base_body = "Basic configuration of the base.";
|
||||
detail::menu_widget(menu_entries, ok_callback, &selected, &screen, config_base_body, {5, 40, size(ftxui::HEIGHT, ftxui::GREATER_THAN, 1)});
|
||||
const auto& content_size = size(HEIGHT, GREATER_THAN, 10) | size(WIDTH, GREATER_THAN, 40);
|
||||
detail::menu_widget(menu_entries, ok_callback, &selected, &screen, config_base_body, {content_size, size(ftxui::HEIGHT, ftxui::GREATER_THAN, 1)});
|
||||
}
|
||||
|
||||
void bios_bootloader() {
|
||||
@ -924,7 +928,7 @@ void mount_opts() noexcept {
|
||||
|
||||
auto screen = ScreenInteractive::Fullscreen();
|
||||
auto content = Renderer(flags, [&] {
|
||||
return flags->Render() | center | size(HEIGHT, GREATER_THAN, 10) | size(WIDTH, GREATER_THAN, 40) | vscroll_indicator;
|
||||
return flags->Render() | center | size(HEIGHT, GREATER_THAN, 10) | size(WIDTH, GREATER_THAN, 40) | vscroll_indicator | yframe | flex;
|
||||
});
|
||||
|
||||
auto& mount_opts_info = std::get<std::string>(config_data["MOUNT_OPTS"]);
|
||||
@ -1255,7 +1259,7 @@ void make_esp() noexcept {
|
||||
|
||||
auto screen = ScreenInteractive::Fullscreen();
|
||||
auto content = Renderer(component, [&] {
|
||||
return component->Render() | center | size(HEIGHT, GREATER_THAN, 10) | size(WIDTH, GREATER_THAN, 40) | vscroll_indicator;
|
||||
return component->Render() | center | size(HEIGHT, GREATER_THAN, 10) | size(WIDTH, GREATER_THAN, 40) | vscroll_indicator | yframe | flex;
|
||||
});
|
||||
|
||||
config_data["ANSWER"] = "";
|
||||
@ -1726,7 +1730,7 @@ void prep_menu() noexcept {
|
||||
break;
|
||||
}
|
||||
};
|
||||
detail::menu_widget(menu_entries, ok_callback, &selected, &screen, "", {15, 50});
|
||||
detail::menu_widget(menu_entries, ok_callback, &selected, &screen, "", {size(HEIGHT, GREATER_THAN, 15) | size(WIDTH, GREATER_THAN, 50)});
|
||||
}
|
||||
|
||||
void init() noexcept {
|
||||
|
@ -257,11 +257,11 @@ bool yesno_widget(ftxui::Component& container, Decorator boxsize) noexcept {
|
||||
return success;
|
||||
}
|
||||
|
||||
void menu_widget(const std::vector<std::string>& entries, const std::function<void()>&& ok_callback, std::int32_t* selected, ScreenInteractive* screen, const std::string_view& text, const ContentBoxSize content_size) noexcept {
|
||||
void menu_widget(const std::vector<std::string>& entries, const std::function<void()>&& ok_callback, std::int32_t* selected, ScreenInteractive* screen, const std::string_view& text, const WidgetBoxSize widget_sizes) noexcept {
|
||||
MenuOption menu_option{.on_enter = ok_callback};
|
||||
auto menu = Menu(&entries, selected, &menu_option);
|
||||
auto content = Renderer(menu, [&] {
|
||||
return menu->Render() | vscroll_indicator | center | size(HEIGHT, GREATER_THAN, content_size.height) | size(WIDTH, GREATER_THAN, content_size.width);
|
||||
return menu->Render() | center | widget_sizes.content_size;
|
||||
});
|
||||
|
||||
ButtonOption button_option{.border = false};
|
||||
@ -274,7 +274,7 @@ void menu_widget(const std::vector<std::string>& entries, const std::function<vo
|
||||
Components children{};
|
||||
if (!text.empty()) {
|
||||
children = {
|
||||
Renderer([&] { return detail::multiline_text(utils::make_multiline(text)) | content_size.text_size; }),
|
||||
Renderer([&] { return detail::multiline_text(utils::make_multiline(text)) | widget_sizes.text_size; }),
|
||||
Renderer([] { return separator(); }),
|
||||
content,
|
||||
Renderer([] { return separator(); }),
|
||||
|
@ -18,10 +18,9 @@ namespace ftxui { struct ButtonOption; }
|
||||
|
||||
namespace tui {
|
||||
namespace detail {
|
||||
struct ContentBoxSize {
|
||||
int height;
|
||||
int width;
|
||||
ftxui::Decorator text_size = size(ftxui::HEIGHT, ftxui::GREATER_THAN, 5);
|
||||
struct WidgetBoxSize {
|
||||
ftxui::Decorator content_size = size(ftxui::HEIGHT, ftxui::GREATER_THAN, 10) | size(ftxui::WIDTH, ftxui::GREATER_THAN, 40);
|
||||
ftxui::Decorator text_size = size(ftxui::HEIGHT, ftxui::GREATER_THAN, 5);
|
||||
};
|
||||
|
||||
auto centered_widget(ftxui::Component& container, const std::string_view& title, const ftxui::Element& widget) noexcept -> ftxui::Element;
|
||||
@ -36,7 +35,7 @@ namespace detail {
|
||||
void infobox_widget(const std::string_view& content, ftxui::Decorator boxsize = size(ftxui::HEIGHT, ftxui::GREATER_THAN, 5)) noexcept;
|
||||
bool yesno_widget(const std::string_view& content, ftxui::Decorator boxsize = size(ftxui::HEIGHT, ftxui::GREATER_THAN, 5)) noexcept;
|
||||
bool yesno_widget(ftxui::Component& container, ftxui::Decorator boxsize = size(ftxui::HEIGHT, ftxui::GREATER_THAN, 5)) noexcept;
|
||||
void menu_widget(const std::vector<std::string>& entries, const std::function<void()>&& ok_callback, std::int32_t* selected, ftxui::ScreenInteractive* screen, const std::string_view& text = "", const ContentBoxSize content_size = {10, 40}) noexcept;
|
||||
void menu_widget(const std::vector<std::string>& entries, const std::function<void()>&& ok_callback, std::int32_t* selected, ftxui::ScreenInteractive* screen, const std::string_view& text = "", const WidgetBoxSize widget_sizes = {}) noexcept;
|
||||
} // namespace detail
|
||||
} // namespace tui
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user