Pipeable decoration and the package_manager example.

- Pipeable decorator.
- package_manager example.
This commit is contained in:
Arthur Sonzogni
2019-01-05 02:03:49 +01:00
parent 178feaa6a9
commit 961e3dcb50
32 changed files with 351 additions and 128 deletions

View File

@@ -3,3 +3,4 @@ example(menu)
example(menu2)
example(menu_style)
example(toggle)
example(tab)

View File

@@ -45,7 +45,7 @@ class MyComponent : ComponentVertical {
};
int main(int argc, const char* argv[]) {
ftxui::ScreenInteractive screen(60, 5);
auto screen = ftxui::ScreenInteractive::TerminalOutput();
MyComponent component(screen.delegate());
component.on_enter = screen.ExitLoopClosure();
screen.Loop();

View File

@@ -7,7 +7,7 @@
int main(int argc, const char *argv[])
{
ftxui::ScreenInteractive screen(30,3);
auto screen = ftxui::ScreenInteractive::FixedSize(30, 3);
ftxui::component::Menu menu(screen.delegate());
menu.entries = {
L"entry 1",

View File

@@ -40,29 +40,25 @@ class MyComponent : ComponentHorizontal {
// -------- Top panel --------------
hbox(
// -------- Left Menu --------------
flex(
vbox(
hcenter(bold(text(L"Percentage by 10%"))),
separator(),
left_menu.Render()
)
),
vbox(
hcenter(bold(text(L"Percentage by 10%"))),
separator(),
left_menu.Render()
) | flex,
// -------- Right Menu --------------
flex(
vbox(
hcenter(bold(text(L"Percentage by 1%"))),
separator(),
right_menu.Render()
)
),
flex()
vbox(
hcenter(bold(text(L"Percentage by 1%"))),
separator(),
right_menu.Render()
) | flex,
filler()
),
separator(),
// -------- Bottom panel --------------
flex(vbox(
vbox(
hbox(text(L" gauge : "), gauge(sum/100.0)),
hbox(text(L" text : "), text(to_wstring(std::to_string(sum) + " %")))
))
) | flex
)
);
}
@@ -70,7 +66,7 @@ class MyComponent : ComponentHorizontal {
int main(int argc, const char *argv[])
{
ftxui::ScreenInteractive screen(60,18);
auto screen = ftxui::ScreenInteractive::TerminalOutput();
MyComponent component(screen.delegate());
component.on_enter = screen.ExitLoopClosure();
screen.Loop();

View File

@@ -33,7 +33,7 @@ class MyComponent : ComponentHorizontal {
}
menu_2.selected_style = color(Color::Blue);
menu_2.active_style = compose(bold, color(Color::Blue));
menu_2.active_style = bold | color(Color::Blue);
menu_3.selected_style = color(Color::Blue);
menu_3.active_style = bgcolor(Color::Blue);
@@ -45,9 +45,9 @@ class MyComponent : ComponentHorizontal {
menu_5.selected_style = bgcolor(Color::Yellow);
menu_5.active_style = bgcolor(Color::Red);
menu_6.normal_style = compose(dim, color(Color::Blue));
menu_6.selected_style = compose(nothing, color(Color::Blue));
menu_6.active_style = compose(bold, color(Color::Blue));
menu_6.normal_style = dim | color(Color::Blue);
menu_6.selected_style = color(Color::Blue);
menu_6.active_style = bold | color(Color::Blue);
Focus(&menu_1);
}
@@ -63,24 +63,21 @@ class MyComponent : ComponentHorizontal {
Element Render() override {
return
vbox(
hbox(
flex(frame(center(text(L" menu_1 ")), menu_1.Render())),
flex(frame(center(text(L" menu_2 ")), menu_2.Render())),
flex(frame(center(text(L" menu_3 ")), menu_3.Render()))
),
hbox(
flex(frame(center(text(L" menu_4 ")), menu_4.Render())),
flex(frame(center(text(L" menu_5 ")), menu_5.Render())),
flex(frame(center(text(L" menu_6 ")), menu_6.Render()))
)
);
menu_1.Render() | flex, separator(),
menu_2.Render() | flex, separator(),
menu_3.Render() | flex, separator(),
menu_4.Render() | flex, separator(),
menu_5.Render() | flex, separator(),
menu_6.Render() | flex
) | frame;
}
};
int main(int argc, const char *argv[])
{
ftxui::ScreenInteractive screen(90,14);
//auto screen = ftxui::ScreenInteractive::TerminalOutput();
auto screen = ftxui::ScreenInteractive::Fullscreen();
MyComponent component(screen.delegate());
component.on_enter = screen.ExitLoopClosure();
screen.Loop();

View File

@@ -0,0 +1,46 @@
#include <iostream>
#include <thread>
#include "ftxui/component/component_vertical.hpp"
#include "ftxui/component/toggle.hpp"
#include "ftxui/component/menu.hpp"
#include "ftxui/screen_interactive.hpp"
#include "ftxui/util/string.hpp"
using namespace ftxui;
using namespace ftxui::component;
using namespace ftxui::dom;
class MyComponent : ComponentVertical {
public:
MyComponent(ftxui::component::Delegate* delegate)
: ComponentVertical(delegate),
toggle(delegate->NewChild()),
menu(delegate->NewChild()) {
toggle.options = {L" left ", L" middle ", L" end "};
menu.entries = {L" top ", L" middle ", L" bottom "};
Focus(&toggle);
}
std::function<void()> on_enter = [](){};
private:
Toggle toggle;
Menu menu;
Element Render() override {
return
vbox(
hbox(frame(toggle.Render()), filler()),
frame(menu.Render()));
}
};
int main(int argc, const char *argv[])
{
auto screen = ftxui::ScreenInteractive::TerminalOutput();
MyComponent component(screen.delegate());
component.on_enter = screen.ExitLoopClosure();
screen.Loop();
}

View File

@@ -62,7 +62,7 @@ class MyComponent : ComponentVertical {
};
int main(int argc, const char* argv[]) {
ftxui::ScreenInteractive screen(70,7);
auto screen = ftxui::ScreenInteractive::TerminalOutput();
MyComponent component(screen.delegate());
component.on_enter = screen.ExitLoopClosure();
screen.Loop();