mirror of
https://github.com/ArthurSonzogni/FTXUI.git
synced 2025-12-16 01:48:56 +08:00
Compare commits
3 Commits
c73a35ce01
...
0cd3bdcdab
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0cd3bdcdab | ||
|
|
21b24a1b78 | ||
|
|
bfd07ba309 |
@@ -29,6 +29,8 @@ Next
|
|||||||
### Component
|
### Component
|
||||||
- Fix ScreenInteractive::FixedSize screen stomps on the preceding terminal
|
- Fix ScreenInteractive::FixedSize screen stomps on the preceding terminal
|
||||||
output. Thanks @zozowell in #1064.
|
output. Thanks @zozowell in #1064.
|
||||||
|
- Fix vertical `ftxui::Slider`. The "up" key was previously decreasing the
|
||||||
|
value. Thanks @its-pablo in #1093 for reporting the issue.
|
||||||
|
|
||||||
|
|
||||||
6.1.9 (2025-05-07)
|
6.1.9 (2025-05-07)
|
||||||
|
|||||||
@@ -17,10 +17,12 @@ add_subdirectory(dom)
|
|||||||
if (EMSCRIPTEN)
|
if (EMSCRIPTEN)
|
||||||
get_property(EXAMPLES GLOBAL PROPERTY FTXUI::EXAMPLES)
|
get_property(EXAMPLES GLOBAL PROPERTY FTXUI::EXAMPLES)
|
||||||
foreach(file
|
foreach(file
|
||||||
|
"index.css"
|
||||||
"index.html"
|
"index.html"
|
||||||
"index.mjs"
|
"index.mjs"
|
||||||
"index.css"
|
"run_webassembly.py"
|
||||||
"run_webassembly.py")
|
"sw.js"
|
||||||
|
)
|
||||||
configure_file(${file} ${file})
|
configure_file(${file} ${file})
|
||||||
endforeach(file)
|
endforeach(file)
|
||||||
endif()
|
endif()
|
||||||
|
|||||||
@@ -33,6 +33,20 @@ Decorator flexDirection(Direction direction) {
|
|||||||
return xflex; // NOT_REACHED()
|
return xflex; // NOT_REACHED()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Direction Opposite(Direction d) {
|
||||||
|
switch (d) {
|
||||||
|
case Direction::Up:
|
||||||
|
return Direction::Down;
|
||||||
|
case Direction::Down:
|
||||||
|
return Direction::Up;
|
||||||
|
case Direction::Left:
|
||||||
|
return Direction::Right;
|
||||||
|
case Direction::Right:
|
||||||
|
return Direction::Left;
|
||||||
|
}
|
||||||
|
return d; // NOT_REACHED()
|
||||||
|
}
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
class SliderBase : public SliderOption<T>, public ComponentBase {
|
class SliderBase : public SliderOption<T>, public ComponentBase {
|
||||||
public:
|
public:
|
||||||
@@ -47,59 +61,15 @@ class SliderBase : public SliderOption<T>, public ComponentBase {
|
|||||||
flexDirection(this->direction) | reflect(gauge_box_) | gauge_color;
|
flexDirection(this->direction) | reflect(gauge_box_) | gauge_color;
|
||||||
}
|
}
|
||||||
|
|
||||||
void OnLeft() {
|
void OnDirection(Direction pressed) {
|
||||||
switch (this->direction) {
|
if (pressed == this->direction) {
|
||||||
case Direction::Right:
|
this->value() += this->increment();
|
||||||
this->value() -= this->increment();
|
return;
|
||||||
break;
|
|
||||||
case Direction::Left:
|
|
||||||
this->value() += this->increment();
|
|
||||||
break;
|
|
||||||
case Direction::Up:
|
|
||||||
case Direction::Down:
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
void OnRight() {
|
if (pressed == Opposite(this->direction)) {
|
||||||
switch (this->direction) {
|
this->value() -= this->increment();
|
||||||
case Direction::Right:
|
return;
|
||||||
this->value() += this->increment();
|
|
||||||
break;
|
|
||||||
case Direction::Left:
|
|
||||||
this->value() -= this->increment();
|
|
||||||
break;
|
|
||||||
case Direction::Up:
|
|
||||||
case Direction::Down:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void OnUp() {
|
|
||||||
switch (this->direction) {
|
|
||||||
case Direction::Up:
|
|
||||||
this->value() -= this->increment();
|
|
||||||
break;
|
|
||||||
case Direction::Down:
|
|
||||||
this->value() += this->increment();
|
|
||||||
break;
|
|
||||||
case Direction::Left:
|
|
||||||
case Direction::Right:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void OnDown() {
|
|
||||||
switch (this->direction) {
|
|
||||||
case Direction::Down:
|
|
||||||
this->value() += this->increment();
|
|
||||||
break;
|
|
||||||
case Direction::Up:
|
|
||||||
this->value() -= this->increment();
|
|
||||||
break;
|
|
||||||
case Direction::Left:
|
|
||||||
case Direction::Right:
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -110,16 +80,16 @@ class SliderBase : public SliderOption<T>, public ComponentBase {
|
|||||||
|
|
||||||
T old_value = this->value();
|
T old_value = this->value();
|
||||||
if (event == Event::ArrowLeft || event == Event::Character('h')) {
|
if (event == Event::ArrowLeft || event == Event::Character('h')) {
|
||||||
OnLeft();
|
OnDirection(Direction::Left);
|
||||||
}
|
}
|
||||||
if (event == Event::ArrowRight || event == Event::Character('l')) {
|
if (event == Event::ArrowRight || event == Event::Character('l')) {
|
||||||
OnRight();
|
OnDirection(Direction::Right);
|
||||||
}
|
}
|
||||||
if (event == Event::ArrowUp || event == Event::Character('k')) {
|
if (event == Event::ArrowUp || event == Event::Character('k')) {
|
||||||
OnDown();
|
OnDirection(Direction::Up);
|
||||||
}
|
}
|
||||||
if (event == Event::ArrowDown || event == Event::Character('j')) {
|
if (event == Event::ArrowDown || event == Event::Character('j')) {
|
||||||
OnUp();
|
OnDirection(Direction::Down);
|
||||||
}
|
}
|
||||||
|
|
||||||
this->value() = std::max(this->min(), std::min(this->max(), this->value()));
|
this->value() = std::max(this->min(), std::min(this->max(), this->value()));
|
||||||
|
|||||||
Reference in New Issue
Block a user