mirror of
https://github.com/ArthurSonzogni/FTXUI.git
synced 2025-09-17 16:38:09 +08:00
Use vscroll_indicator in examples.
This commit is contained in:

committed by
Arthur Sonzogni

parent
535974d291
commit
84287eb217
@@ -31,17 +31,20 @@ Element vscroll_indicator(Element child) {
|
||||
|
||||
const Box& stencil = screen.stencil;
|
||||
|
||||
float size_inner = box_.y_max - box_.y_min;
|
||||
float size_outter = stencil.y_max - stencil.y_min;
|
||||
float start_y = stencil.y_min +
|
||||
(stencil.y_min - box_.y_min) * size_outter / size_inner;
|
||||
float end_y = stencil.y_min +
|
||||
(stencil.y_max - box_.y_min) * size_outter / size_inner;
|
||||
int size_inner = box_.y_max - box_.y_min;
|
||||
int size_outter = stencil.y_max - stencil.y_min;
|
||||
if (size_outter >= size_inner)
|
||||
return;
|
||||
|
||||
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;
|
||||
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 down = (2 * y + 0 >= 2 * start_y) && (2 * y + 0 <= 2 * end_y);
|
||||
bool up = (2 * y + -1 >= start_y) && (2 * y - 1 <= start_y + size);
|
||||
bool down = (2 * y - 0 >= start_y) && (2 * y - 0 <= start_y + size);
|
||||
|
||||
const char* c = up ? (down ? "┃" : "╹") : (down ? "╻" : " ");
|
||||
screen.PixelAt(x, y).character = c;
|
||||
|
Reference in New Issue
Block a user