diff --git a/CMakeLists.txt b/CMakeLists.txt index f1cc6b97..e9f9bd9f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -80,6 +80,7 @@ add_library(component include/ftxui/component/captured_mouse.hpp include/ftxui/component/checkbox.hpp include/ftxui/component/component.hpp + include/ftxui/component/component_base.hpp include/ftxui/component/container.hpp include/ftxui/component/event.hpp include/ftxui/component/input.hpp @@ -88,7 +89,6 @@ add_library(component include/ftxui/component/radiobox.hpp include/ftxui/component/receiver.hpp include/ftxui/component/screen_interactive.hpp - include/ftxui/component/slider.hpp include/ftxui/component/toggle.hpp src/ftxui/component/button.cpp src/ftxui/component/checkbox.cpp diff --git a/doc/example_list.md b/doc/example_list.md index efddeab1..5f654036 100644 --- a/doc/example_list.md +++ b/doc/example_list.md @@ -34,6 +34,7 @@ @example ./examples/component/input.cpp @example ./examples/component/homescreen.cpp @example ./examples/component/radiobox.cpp +@example ./examples/component/slider_rgb.cpp @example ./examples/component/menu.cpp @example ./examples/component/menu_style.cpp @example ./examples/component/radiobox_in_frame.cpp diff --git a/doc/mainpage.md b/doc/mainpage.md index 672fda19..94fe5d8a 100644 --- a/doc/mainpage.md +++ b/doc/mainpage.md @@ -31,7 +31,7 @@ int main(void) { Dimension::Fit(document) // Height ); Render(screen, document); - std::cout << screen.ToString() << std::endl; + screen.Print(); return EXIT_SUCCESS; } @@ -142,6 +142,13 @@ This provides: 3. A predefined implementation of "keyboard navigation". 4. A set of predefined widget: CheckBox, RadioBox, Input, Menu, Toggle. + +**List of Component** + +You only need one header: ftxui/dom/component.hpp + +\include ftxui/component/component.hpp + # ftxui/dom Every elements of the dom are declared from: diff --git a/examples/component/CMakeLists.txt b/examples/component/CMakeLists.txt index 07dc0b31..3f4e5f15 100644 --- a/examples/component/CMakeLists.txt +++ b/examples/component/CMakeLists.txt @@ -17,6 +17,7 @@ example(modal_dialog) example(radiobox) example(radiobox_in_frame) example(slider) +example(slider_rgb) example(tab_horizontal) example(tab_vertical) example(toggle) diff --git a/examples/component/button.cpp b/examples/component/button.cpp index dc3ceaf1..2716d5c5 100644 --- a/examples/component/button.cpp +++ b/examples/component/button.cpp @@ -1,51 +1,43 @@ -#include // for function -#include // for unique_ptr, make_u... -#include // for wstring -#include // for move -#include // for vector +#include // for operator+, to_wstring, allocator, wstring -#include "ftxui/component/button.hpp" // for Button -#include "ftxui/component/component.hpp" // for Component +#include "ftxui/component/captured_mouse.hpp" // for ftxui +#include "ftxui/component/component.hpp" // for Button, Make +#include "ftxui/component/component_base.hpp" // for ComponentBase #include "ftxui/component/container.hpp" // for Container #include "ftxui/component/screen_interactive.hpp" // for ScreenInteractive -#include "ftxui/screen/box.hpp" // for ftxui +#include "ftxui/dom/elements.hpp" // for separator, Element, gauge, text, operator|, vbox, border using namespace ftxui; -class MyComponent : public Component { +class MyComponent : public ComponentBase { private: - std::vector> buttons_; - Container container_ = Container::Horizontal(); + std::wstring label_add = L"Increase"; + std::wstring label_rm = L"Decrease"; + int value_ = 50; public: MyComponent() { - Add(&container_); + Add(Container::Horizontal({ + Button(&label_rm, [&] { value_--; }), + Button(&label_add, [&] { value_++; }), + })); + } - auto button_add = std::make_unique