mirror of
				https://github.com/ArthurSonzogni/FTXUI.git
				synced 2025-10-31 18:48:11 +08:00 
			
		
		
		
	Update example/component/gallery.cpp
This commit is contained in:
		| @@ -1,6 +1,8 @@ | |||||||
| #include "ftxui/component/container.hpp" | #include "ftxui/component/container.hpp" | ||||||
| #include "ftxui/component/input.hpp" | #include "ftxui/component/input.hpp" | ||||||
| #include "ftxui/component/menu.hpp" | #include "ftxui/component/menu.hpp" | ||||||
|  | #include "ftxui/component/radiobox.hpp" | ||||||
|  | #include "ftxui/component/checkbox.hpp" | ||||||
| #include "ftxui/component/screen_interactive.hpp" | #include "ftxui/component/screen_interactive.hpp" | ||||||
| #include "ftxui/component/toggle.hpp" | #include "ftxui/component/toggle.hpp" | ||||||
|  |  | ||||||
| @@ -9,8 +11,12 @@ using namespace ftxui; | |||||||
| class MyComponent : public Component { | class MyComponent : public Component { | ||||||
|   Container container = Container::Vertical(); |   Container container = Container::Vertical(); | ||||||
|   Menu menu; |   Menu menu; | ||||||
|   Input input; |  | ||||||
|   Toggle toggle; |   Toggle toggle; | ||||||
|  |   Container checkbox_container = Container::Vertical(); | ||||||
|  |   CheckBox checkbox1; | ||||||
|  |   CheckBox checkbox2; | ||||||
|  |   RadioBox radiobox; | ||||||
|  |   Input input; | ||||||
|  |  | ||||||
|  public: |  public: | ||||||
|   MyComponent() { |   MyComponent() { | ||||||
| @@ -31,18 +37,40 @@ class MyComponent : public Component { | |||||||
|     }; |     }; | ||||||
|     container.Add(&toggle); |     container.Add(&toggle); | ||||||
|  |  | ||||||
|  |     container.Add(&checkbox_container); | ||||||
|  |     checkbox1.label = L"checkbox1"; | ||||||
|  |     checkbox_container.Add(&checkbox1); | ||||||
|  |     checkbox2.label = L"checkbox2"; | ||||||
|  |     checkbox_container.Add(&checkbox2); | ||||||
|  |  | ||||||
|  |     radiobox.entries = { | ||||||
|  |         L"Browse the web", | ||||||
|  |         L"Meditate", | ||||||
|  |         L"Sleep", | ||||||
|  |         L"Eat", | ||||||
|  |     }; | ||||||
|  |     container.Add(&radiobox); | ||||||
|  |  | ||||||
|     input.placeholder = L"Input placeholder"; |     input.placeholder = L"Input placeholder"; | ||||||
|     container.Add(&input); |     container.Add(&input); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|  |   Element Render(std::wstring name, Component& component) { | ||||||
|  |     return hbox(text(name) | size(10,1), separator(), component.Render()); | ||||||
|  |   } | ||||||
|  |  | ||||||
|   Element Render() override { |   Element Render() override { | ||||||
|     return |     return | ||||||
|       vbox( |       vbox( | ||||||
|         hbox(text(L"menu") | size(10,1), separator(), menu.Render()), |         Render(L"menu", menu), | ||||||
|         separator(), |         separator(), | ||||||
|         hbox(text(L"toggle") | size(10,1), separator(), toggle.Render()), |         Render(L"toggle", toggle), | ||||||
|         separator(), |         separator(), | ||||||
|         hbox(text(L"input") | size(10,1), separator(), input.Render()) |         Render(L"checkbox", checkbox_container), | ||||||
|  |         separator(), | ||||||
|  |         Render(L"radiobox", radiobox), | ||||||
|  |         separator(), | ||||||
|  |         Render(L"input", input) | ||||||
|       ) | frame; |       ) | frame; | ||||||
|   } |   } | ||||||
| }; | }; | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Arthur Sonzogni
					Arthur Sonzogni