Add "frame" : scrollable area.

This commit is contained in:
Arthur Sonzogni
2019-01-19 22:06:05 +01:00
parent cb4df0b56f
commit fddcbdea65
50 changed files with 543 additions and 243 deletions

View File

@@ -5,12 +5,14 @@ function(example name)
endfunction(example)
example(checkbox)
example(checkbox_in_frame)
example(gallery)
example(input)
example(menu)
example(menu2)
example(menu_style)
example(radiobox)
example(radiobox_in_frame)
example(tab_horizontal)
example(tab_vertical)
example(toggle)

View File

@@ -22,19 +22,10 @@ class MyComponent : public Component {
box_3_.label = L"Use WebAssembly";
box_3_.state = true;
}
Element Render() {
return
window(text(L" Checkbox "),
hbox(
container_.Render()
)
);
}
};
int main(int argc, const char *argv[]) {
auto screen = ScreenInteractive::FixedSize(30,5);
auto screen = ScreenInteractive::TerminalOutput();
MyComponent component;
screen.Loop(&component);
return 0;

View File

@@ -0,0 +1,42 @@
#include "ftxui/component/checkbox.hpp"
#include "ftxui/component/container.hpp"
#include "ftxui/component/input.hpp"
#include "ftxui/component/menu.hpp"
#include "ftxui/component/checkbox.hpp"
#include "ftxui/component/screen_interactive.hpp"
#include "ftxui/component/toggle.hpp"
#include "ftxui/screen/string.hpp"
using namespace ftxui;
class MyComponent : public Component {
public:
MyComponent() {
Add(&container);
checkbox.resize(30);
for(int i = 0; i<checkbox.size(); ++i) {
checkbox[i].label = (L"CheckBox " + to_wstring(i));
container.Add(&checkbox[i]);
}
}
Element Render() override {
Elements content;
for(auto& it : checkbox) {
content.push_back(it.Render());
}
return vbox(std::move(content)) | frame | size(20, 10) | border;
}
private:
std::vector<CheckBox> checkbox;
Container container = Container::Vertical();
};
int main(int argc, const char* argv[]) {
auto screen = ScreenInteractive::FitComponent();
MyComponent component;
screen.Loop(&component);
return 0;
}

View File

@@ -69,7 +69,7 @@ class MyComponent : public Component {
Render(L"radiobox", radiobox),
separator(),
Render(L"input", input)
) | frame;
) | border | frame | size(10,10) | border;
}
};

View File

@@ -30,7 +30,7 @@ class MyComponent : public Component {
Element Render() override {
return
frame(
border(
vbox(
hbox(text(L" input_1 : "), input_1.Render()),
hbox(text(L" input_2 : "), input_2.Render()),

View File

@@ -34,7 +34,7 @@ class MyComponent : public Component {
Element Render() override {
int sum = left_menu.selected * 10 + right_menu.selected;
return
frame(
border(
vbox(
// -------- Top panel --------------
hbox(

View File

@@ -26,21 +26,21 @@ class MyComponent : public Component {
}
menu_2.selected_style = color(Color::Blue);
menu_2.active_style = bold | color(Color::Blue);
menu_2.focused_style = bold | color(Color::Blue);
menu_3.selected_style = color(Color::Blue);
menu_3.active_style = bgcolor(Color::Blue);
menu_3.focused_style = bgcolor(Color::Blue);
menu_4.selected_style = bgcolor(Color::Blue);
menu_4.active_style = bgcolor(Color::BlueLight);
menu_4.focused_style = bgcolor(Color::BlueLight);
menu_5.normal_style = bgcolor(Color::Blue);
menu_5.selected_style = bgcolor(Color::Yellow);
menu_5.active_style = bgcolor(Color::Red);
menu_5.focused_style = bgcolor(Color::Red);
menu_6.normal_style = dim | color(Color::Blue);
menu_6.selected_style = color(Color::Blue);
menu_6.active_style = bold | color(Color::Blue);
menu_6.focused_style = bold | color(Color::Blue);
}
std::function<void()> on_enter = [](){};
@@ -62,7 +62,7 @@ class MyComponent : public Component {
menu_4.Render() | flex, separator(),
menu_5.Render() | flex, separator(),
menu_6.Render() | flex
) | frame;
) | border;
}
};

View File

@@ -0,0 +1,34 @@
#include "ftxui/component/checkbox.hpp"
#include "ftxui/component/container.hpp"
#include "ftxui/component/input.hpp"
#include "ftxui/component/menu.hpp"
#include "ftxui/component/radiobox.hpp"
#include "ftxui/component/screen_interactive.hpp"
#include "ftxui/component/toggle.hpp"
#include "ftxui/screen/string.hpp"
using namespace ftxui;
class MyComponent : public Component {
RadioBox radiobox;
public:
MyComponent() {
for(int i = 0; i<30; ++i) {
radiobox.entries.push_back(L"RadioBox " + to_wstring(i));
}
Add(&radiobox);
}
Element Render() override {
return radiobox.Render() | frame | size(20,10) | border;
}
};
int main(int argc, const char* argv[]) {
auto screen = ScreenInteractive::FitComponent();
MyComponent component;
screen.Loop(&component);
return 0;
}

View File

@@ -50,7 +50,7 @@ class MyComponent : public Component {
toggle_.Render(),
separator(),
tab_container_.Render()
) | frame;
) | border;
}
private:

View File

@@ -4,7 +4,7 @@ function(example name)
endfunction(example)
example(dbox)
example(frame)
example(border)
example(gauge)
example(package_manager)
example(separator)

View File

@@ -15,13 +15,11 @@ int main(int argc, const char *argv[])
text(L"Line 1"),
text(L"Line 2"),
text(L"Line 3"),
frame(
vbox(
text(L"Line 4"),
text(L"Line 5"),
text(L"Line 6")
)
),
vbox(
text(L"Line 4"),
text(L"Line 5"),
text(L"Line 6")
) | border,
hbox(
window(text(L"frame 2"),
vbox(

View File

@@ -7,20 +7,14 @@ int main(int argc, const char *argv[])
using namespace ftxui;
auto document =
dbox(
frame(
vbox(
text(L"line_1"),
text(L"line_2"),
text(L"line_3"),
text(L"line_4"),
text(L"line_5")
)
),
center(
frame(
text(L"overlay")
)
)
vbox(
text(L"line_1"),
text(L"line_2"),
text(L"line_3"),
text(L"line_4"),
text(L"line_5")
) | border,
text(L"overlay") | border | center
);
auto screen = Screen::TerminalOutput(document);
Render(screen, document.get());

View File

@@ -24,7 +24,7 @@ int main(int argc, const char *argv[])
)
);
}
auto document = hbox(vbox(std::move(entries)) | frame, filler());
auto document = hbox(vbox(std::move(entries)) | border, filler());
auto screen = Screen::TerminalOutput(document);
Render(screen, document.get());
std::cout << reset_position << screen.ToString() << std::flush;