mirror of
https://github.com/ArthurSonzogni/FTXUI.git
synced 2024-11-22 18:59:59 +08:00
Use vscroll_indicator in examples.
This commit is contained in:
parent
535974d291
commit
84287eb217
@ -24,7 +24,8 @@ int main(int argc, const char* argv[]) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
auto renderer = Renderer(container, [&] {
|
auto renderer = Renderer(container, [&] {
|
||||||
return container->Render() | frame | size(HEIGHT, LESS_THAN, 10) | border;
|
return container->Render() | vscroll_indicator | frame |
|
||||||
|
size(HEIGHT, LESS_THAN, 10) | border;
|
||||||
});
|
});
|
||||||
|
|
||||||
auto screen = ScreenInteractive::FitComponent();
|
auto screen = ScreenInteractive::FitComponent();
|
||||||
|
@ -214,23 +214,25 @@ int main(int argc, const char* argv[]) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
auto compiler_renderer = Renderer(compiler_component, [&] {
|
auto compiler_renderer = Renderer(compiler_component, [&] {
|
||||||
auto compiler_win = window(text("Compiler"), compiler->Render() | frame);
|
auto compiler_win = window(text("Compiler"),
|
||||||
auto flags_win = window(text("Flags"), flags->Render() | frame);
|
compiler->Render() | vscroll_indicator | frame);
|
||||||
|
auto flags_win =
|
||||||
|
window(text("Flags"), flags->Render() | vscroll_indicator | frame);
|
||||||
auto executable_win = window(text("Executable:"), executable_->Render());
|
auto executable_win = window(text("Executable:"), executable_->Render());
|
||||||
auto input_win =
|
auto input_win =
|
||||||
window(text("Input"),
|
window(text("Input"), hbox({
|
||||||
hbox({
|
vbox({
|
||||||
vbox({
|
hbox({
|
||||||
hbox({
|
text("Add: "),
|
||||||
text("Add: "),
|
input_add->Render(),
|
||||||
input_add->Render(),
|
}) | size(WIDTH, EQUAL, 20) |
|
||||||
}) | size(WIDTH, EQUAL, 20) |
|
size(HEIGHT, EQUAL, 1),
|
||||||
size(HEIGHT, EQUAL, 1),
|
filler(),
|
||||||
filler(),
|
}),
|
||||||
}),
|
separator(),
|
||||||
separator(),
|
input->Render() | vscroll_indicator | frame |
|
||||||
input->Render() | frame | size(HEIGHT, EQUAL, 3) | flex,
|
size(HEIGHT, EQUAL, 3) | flex,
|
||||||
}));
|
}));
|
||||||
return vbox({
|
return vbox({
|
||||||
hbox({
|
hbox({
|
||||||
compiler_win,
|
compiler_win,
|
||||||
@ -240,7 +242,7 @@ int main(int argc, const char* argv[]) {
|
|||||||
input_win | size(WIDTH, EQUAL, 60),
|
input_win | size(WIDTH, EQUAL, 60),
|
||||||
}),
|
}),
|
||||||
filler(),
|
filler(),
|
||||||
}) | size(HEIGHT, LESS_THAN, 6),
|
}) | size(HEIGHT, LESS_THAN, 8),
|
||||||
hflow(render_command()) | flex_grow,
|
hflow(render_command()) | flex_grow,
|
||||||
}) |
|
}) |
|
||||||
flex_grow | border;
|
flex_grow | border;
|
||||||
|
@ -18,7 +18,8 @@ int main(int argc, const char* argv[]) {
|
|||||||
entries.push_back("Entry " + std::to_string(i));
|
entries.push_back("Entry " + std::to_string(i));
|
||||||
auto radiobox = Menu(&entries, &selected);
|
auto radiobox = Menu(&entries, &selected);
|
||||||
auto renderer = Renderer(radiobox, [&] {
|
auto renderer = Renderer(radiobox, [&] {
|
||||||
return radiobox->Render() | frame | size(HEIGHT, LESS_THAN, 10) | border;
|
return radiobox->Render() | vscroll_indicator | frame |
|
||||||
|
size(HEIGHT, LESS_THAN, 10) | border;
|
||||||
});
|
});
|
||||||
|
|
||||||
auto screen = ScreenInteractive::FitComponent();
|
auto screen = ScreenInteractive::FitComponent();
|
||||||
|
@ -18,7 +18,8 @@ int main(int argc, const char* argv[]) {
|
|||||||
entries.push_back("RadioBox " + std::to_string(i));
|
entries.push_back("RadioBox " + std::to_string(i));
|
||||||
auto radiobox = Radiobox(&entries, &selected);
|
auto radiobox = Radiobox(&entries, &selected);
|
||||||
auto renderer = Renderer(radiobox, [&] {
|
auto renderer = Renderer(radiobox, [&] {
|
||||||
return radiobox->Render() | frame | size(HEIGHT, LESS_THAN, 10) | border;
|
return radiobox->Render() | vscroll_indicator | frame |
|
||||||
|
size(HEIGHT, LESS_THAN, 10) | border;
|
||||||
});
|
});
|
||||||
|
|
||||||
auto screen = ScreenInteractive::FitComponent();
|
auto screen = ScreenInteractive::FitComponent();
|
||||||
|
@ -31,17 +31,20 @@ Element vscroll_indicator(Element child) {
|
|||||||
|
|
||||||
const Box& stencil = screen.stencil;
|
const Box& stencil = screen.stencil;
|
||||||
|
|
||||||
float size_inner = box_.y_max - box_.y_min;
|
int size_inner = box_.y_max - box_.y_min;
|
||||||
float size_outter = stencil.y_max - stencil.y_min;
|
int size_outter = stencil.y_max - stencil.y_min;
|
||||||
float start_y = stencil.y_min +
|
if (size_outter >= size_inner)
|
||||||
(stencil.y_min - box_.y_min) * size_outter / size_inner;
|
return;
|
||||||
float end_y = stencil.y_min +
|
|
||||||
(stencil.y_max - box_.y_min) * size_outter / size_inner;
|
int start_y = 2 * stencil.y_min + 2 * float(stencil.y_min - box_.y_min) *
|
||||||
|
(size_outter - 1) / size_inner;
|
||||||
|
int size = 2 * float(size_outter) * (size_outter - 1) / size_inner + 2;
|
||||||
|
size = std::max(size, 1);
|
||||||
|
|
||||||
const int x = stencil.x_max;
|
const int x = stencil.x_max;
|
||||||
for (int y = stencil.y_min; y <= stencil.y_max; ++y) {
|
for (int y = stencil.y_min; y <= stencil.y_max; ++y) {
|
||||||
bool up = (2 * y + -1 >= 2 * start_y) && (2 * y + -1 <= 2 * end_y);
|
bool up = (2 * y + -1 >= start_y) && (2 * y - 1 <= start_y + size);
|
||||||
bool down = (2 * y + 0 >= 2 * start_y) && (2 * y + 0 <= 2 * end_y);
|
bool down = (2 * y - 0 >= start_y) && (2 * y - 0 <= start_y + size);
|
||||||
|
|
||||||
const char* c = up ? (down ? "┃" : "╹") : (down ? "╻" : " ");
|
const char* c = up ? (down ? "┃" : "╹") : (down ? "╻" : " ");
|
||||||
screen.PixelAt(x, y).character = c;
|
screen.PixelAt(x, y).character = c;
|
||||||
|
Loading…
Reference in New Issue
Block a user