🚧 adjust a bit to fit with new TUI API

This commit is contained in:
Vladislav Nepogodin 2022-03-19 02:50:36 +04:00
parent 02a4b195b3
commit 617e756b16
No known key found for this signature in database
GPG Key ID: B62C3D10C54D5DA9
4 changed files with 19 additions and 24 deletions

View File

@ -59,9 +59,7 @@ void follow_process_log_widget(const std::vector<std::string>& vec, Decorator bo
screen.ExitLoopClosure()(); screen.ExitLoopClosure()();
}; };
auto button_option = ButtonOption(); auto button_back = Button("Back", handle_exit, ButtonOption::WithoutBorder());
button_option.border = false;
auto button_back = Button("Back", handle_exit, &button_option);
auto container = Container::Horizontal({button_back}); auto container = Container::Horizontal({button_back});
auto renderer = Renderer(container, [&] { auto renderer = Renderer(container, [&] {

View File

@ -931,7 +931,7 @@ void install_desktop() noexcept {
} }
found = ranges::search(desktop_env, cutefish); found = ranges::search(desktop_env, cutefish);
if (!found.empty()) { if (!found.empty()) {
pkg_list.insert(pkg_list.cend(), {"cutefish", "fish-ui"}); pkg_list.insert(pkg_list.cend(), {"cutefish"});
needed_xorg = true; needed_xorg = true;
} }
found = ranges::search(desktop_env, wayfire); found = ranges::search(desktop_env, wayfire);
@ -952,7 +952,7 @@ void install_desktop() noexcept {
// @see https://github.com/VaughnValle/kofuku // @see https://github.com/VaughnValle/kofuku
found = ranges::search(desktop_env, kofuku); found = ranges::search(desktop_env, kofuku);
if (!found.empty()) { if (!found.empty()) {
pkg_list.insert(pkg_list.cend(), {"bspwm", "sxhkd", "polybar", "lightdm", "cachyos-picom-config", "rofi", "lightdm", "lightdm-webkit2-greeter", "cachyos-kofuku"}); pkg_list.insert(pkg_list.cend(), {"bspwm", "sxhkd", "polybar", "lightdm", "cachyos-picom-config", "rofi", "lightdm-webkit2-greeter", "cachyos-kofuku"});
needed_xorg = true; needed_xorg = true;
} }

View File

@ -56,10 +56,10 @@ Element centered_widget_nocontrols(const std::string_view& title, const Element&
}); });
} }
Component controls_widget(const std::array<std::string_view, 2>&& titles, const std::array<std::function<void()>, 2>&& callbacks, ButtonOption* button_option) noexcept { Component controls_widget(const std::array<std::string_view, 2>&& titles, const std::array<std::function<void()>, 2>&& callbacks) noexcept {
/* clang-format off */ /* clang-format off */
auto button_ok = Button(titles[0].data(), callbacks[0], button_option); auto button_ok = Button(titles[0].data(), callbacks[0], ButtonOption::WithoutBorder());
auto button_quit = Button(titles[1].data(), callbacks[1], button_option); auto button_quit = Button(titles[1].data(), callbacks[1], ButtonOption::WithoutBorder());
/* clang-format on */ /* clang-format on */
auto container = Container::Horizontal({ auto container = Container::Horizontal({
@ -134,9 +134,7 @@ std::vector<std::string> from_checklist_vector(const std::vector<std::string>& o
void msgbox_widget(const std::string_view& content, Decorator boxsize) noexcept { void msgbox_widget(const std::string_view& content, Decorator boxsize) noexcept {
auto screen = ScreenInteractive::Fullscreen(); auto screen = ScreenInteractive::Fullscreen();
/* clang-format off */ /* clang-format off */
auto button_option = ButtonOption(); auto button_back = Button("OK", screen.ExitLoopClosure(), ButtonOption::WithoutBorder());
button_option.border = false;
auto button_back = Button("OK", screen.ExitLoopClosure(), &button_option);
auto container = Container::Horizontal({button_back}); auto container = Container::Horizontal({button_back});
auto renderer = Renderer(container, [&] { auto renderer = Renderer(container, [&] {
@ -160,8 +158,7 @@ bool inputbox_widget(std::string& value, const std::string_view& content, Decora
return multiline_text(utils::make_multiline(content)) | hcenter | boxsize; return multiline_text(utils::make_multiline(content)) | hcenter | boxsize;
}); });
ButtonOption button_option{.border = false}; auto controls_container = controls_widget({"OK", "Cancel"}, {ok_callback, screen.ExitLoopClosure()});
auto controls_container = controls_widget({"OK", "Cancel"}, {ok_callback, screen.ExitLoopClosure()}, &button_option);
auto controls = Renderer(controls_container, [&] { auto controls = Renderer(controls_container, [&] {
return controls_container->Render() | hcenter | size(HEIGHT, LESS_THAN, 3) | size(WIDTH, GREATER_THAN, 25); return controls_container->Render() | hcenter | size(HEIGHT, LESS_THAN, 3) | size(WIDTH, GREATER_THAN, 25);
@ -202,8 +199,7 @@ bool yesno_widget(const std::string_view& content, Decorator boxsize) noexcept {
success = true; success = true;
screen.ExitLoopClosure()(); screen.ExitLoopClosure()();
}; };
ButtonOption button_option{.border = false}; auto controls_container = controls_widget({"OK", "Cancel"}, {ok_callback, screen.ExitLoopClosure()});
auto controls_container = controls_widget({"OK", "Cancel"}, {ok_callback, screen.ExitLoopClosure()}, &button_option);
auto controls = Renderer(controls_container, [&] { auto controls = Renderer(controls_container, [&] {
return controls_container->Render() | hcenter | size(HEIGHT, LESS_THAN, 3) | size(WIDTH, GREATER_THAN, 25); return controls_container->Render() | hcenter | size(HEIGHT, LESS_THAN, 3) | size(WIDTH, GREATER_THAN, 25);
@ -233,8 +229,7 @@ bool yesno_widget(ftxui::Component& container, Decorator boxsize) noexcept {
success = true; success = true;
screen.ExitLoopClosure()(); screen.ExitLoopClosure()();
}; };
ButtonOption button_option{.border = false}; auto controls_container = controls_widget({"OK", "Cancel"}, {ok_callback, screen.ExitLoopClosure()});
auto controls_container = controls_widget({"OK", "Cancel"}, {ok_callback, screen.ExitLoopClosure()}, &button_option);
auto controls = Renderer(controls_container, [&] { auto controls = Renderer(controls_container, [&] {
return controls_container->Render() | hcenter | size(HEIGHT, LESS_THAN, 3) | size(WIDTH, GREATER_THAN, 25); return controls_container->Render() | hcenter | size(HEIGHT, LESS_THAN, 3) | size(WIDTH, GREATER_THAN, 25);
@ -261,8 +256,7 @@ void menu_widget(const std::vector<std::string>& entries, const std::function<vo
return menu->Render() | center | widget_sizes.content_size; return menu->Render() | center | widget_sizes.content_size;
}); });
ButtonOption button_option{.border = false}; auto controls_container = controls_widget({"OK", "Cancel"}, {ok_callback, screen->ExitLoopClosure()});
auto controls_container = controls_widget({"OK", "Cancel"}, {ok_callback, screen->ExitLoopClosure()}, &button_option);
auto controls = Renderer(controls_container, [&] { auto controls = Renderer(controls_container, [&] {
return controls_container->Render() | hcenter | size(HEIGHT, LESS_THAN, 3) | size(WIDTH, GREATER_THAN, 25); return controls_container->Render() | hcenter | size(HEIGHT, LESS_THAN, 3) | size(WIDTH, GREATER_THAN, 25);
@ -300,8 +294,7 @@ void radiolist_widget(const std::vector<std::string>& entries, const std::functi
return radiolist->Render() | center | widget_sizes.content_size; return radiolist->Render() | center | widget_sizes.content_size;
}); });
ButtonOption button_option{.border = false}; auto controls_container = controls_widget({"OK", "Cancel"}, {ok_callback, screen->ExitLoopClosure()});
auto controls_container = controls_widget({"OK", "Cancel"}, {ok_callback, screen->ExitLoopClosure()}, &button_option);
auto controls = Renderer(controls_container, [&] { auto controls = Renderer(controls_container, [&] {
return controls_container->Render() | hcenter | size(HEIGHT, LESS_THAN, 3) | size(WIDTH, GREATER_THAN, 25); return controls_container->Render() | hcenter | size(HEIGHT, LESS_THAN, 3) | size(WIDTH, GREATER_THAN, 25);
@ -336,8 +329,7 @@ void checklist_widget(const std::vector<std::string>& opts, const std::function<
return checklist->Render() | center | widget_sizes.content_size; return checklist->Render() | center | widget_sizes.content_size;
}); });
ButtonOption button_option{.border = false}; auto controls_container = controls_widget({"OK", "Cancel"}, {ok_callback, screen->ExitLoopClosure()});
auto controls_container = controls_widget({"OK", "Cancel"}, {ok_callback, screen->ExitLoopClosure()}, &button_option);
auto controls = Renderer(controls_container, [&] { auto controls = Renderer(controls_container, [&] {
return controls_container->Render() | hcenter | size(HEIGHT, LESS_THAN, 3) | size(WIDTH, GREATER_THAN, 25); return controls_container->Render() | hcenter | size(HEIGHT, LESS_THAN, 3) | size(WIDTH, GREATER_THAN, 25);

View File

@ -31,6 +31,7 @@ ftxui_dom_lib = static_library('ftxui_dom',
'include/ftxui/dom/node.hpp', 'include/ftxui/dom/node.hpp',
'include/ftxui/dom/requirement.hpp', 'include/ftxui/dom/requirement.hpp',
'include/ftxui/dom/take_any_args.hpp', 'include/ftxui/dom/take_any_args.hpp',
'src/ftxui/dom/automerge.cpp',
'src/ftxui/dom/blink.cpp', 'src/ftxui/dom/blink.cpp',
'src/ftxui/dom/bold.cpp', 'src/ftxui/dom/bold.cpp',
'src/ftxui/dom/border.cpp', 'src/ftxui/dom/border.cpp',
@ -73,17 +74,21 @@ ftxui_dom_lib = static_library('ftxui_dom',
ftxui_component_lib = static_library('ftxui_component', ftxui_component_lib = static_library('ftxui_component',
sources : [ sources : [
'include/ftxui/component/animation.hpp',
'include/ftxui/component/captured_mouse.hpp', 'include/ftxui/component/captured_mouse.hpp',
'include/ftxui/component/component.hpp', 'include/ftxui/component/component.hpp',
'include/ftxui/component/component_base.hpp', 'include/ftxui/component/component_base.hpp',
'include/ftxui/component/component_options.hpp',
'include/ftxui/component/event.hpp', 'include/ftxui/component/event.hpp',
'include/ftxui/component/mouse.hpp', 'include/ftxui/component/mouse.hpp',
'include/ftxui/component/receiver.hpp', 'include/ftxui/component/receiver.hpp',
'include/ftxui/component/screen_interactive.hpp', 'include/ftxui/component/screen_interactive.hpp',
'src/ftxui/component/animation.cpp',
'src/ftxui/component/button.cpp', 'src/ftxui/component/button.cpp',
'src/ftxui/component/catch_event.cpp', 'src/ftxui/component/catch_event.cpp',
'src/ftxui/component/checkbox.cpp', 'src/ftxui/component/checkbox.cpp',
'src/ftxui/component/component.cpp', 'src/ftxui/component/component.cpp',
'src/ftxui/component/component_options.cpp',
'src/ftxui/component/container.cpp', 'src/ftxui/component/container.cpp',
'src/ftxui/component/dropdown.cpp', 'src/ftxui/component/dropdown.cpp',
'src/ftxui/component/event.cpp', 'src/ftxui/component/event.cpp',
@ -98,7 +103,7 @@ ftxui_component_lib = static_library('ftxui_component',
'src/ftxui/component/slider.cpp', 'src/ftxui/component/slider.cpp',
'src/ftxui/component/terminal_input_parser.cpp', 'src/ftxui/component/terminal_input_parser.cpp',
'src/ftxui/component/terminal_input_parser.hpp', 'src/ftxui/component/terminal_input_parser.hpp',
'src/ftxui/component/toggle.cpp' 'src/ftxui/component/util.cpp'
], ],
include_directories : [ftxui_inc, ftxui_priv_inc], include_directories : [ftxui_inc, ftxui_priv_inc],
link_with : [ftxui_dom_lib], link_with : [ftxui_dom_lib],