mirror of
https://github.com/ArthurSonzogni/FTXUI.git
synced 2025-09-28 16:29:34 +08:00
Animation (#355)
This commit is contained in:
@@ -29,14 +29,6 @@ class RadioboxBase : public ComponentBase {
|
||||
int* selected,
|
||||
Ref<RadioboxOption> option)
|
||||
: entries_(entries), selected_(selected), option_(std::move(option)) {
|
||||
#if defined(FTXUI_MICROSOFT_TERMINAL_FALLBACK)
|
||||
// Microsoft terminal do not use fonts able to render properly the default
|
||||
// radiobox glyph.
|
||||
if (option_->style_checked == "◉ ")
|
||||
option_->style_checked = "(*)";
|
||||
if (option_->style_unchecked == "○ ")
|
||||
option_->style_unchecked = "( )";
|
||||
#endif
|
||||
hovered_ = *selected_;
|
||||
}
|
||||
|
||||
@@ -48,19 +40,21 @@ class RadioboxBase : public ComponentBase {
|
||||
for (int i = 0; i < size(); ++i) {
|
||||
bool is_focused = (focused_entry() == i) && is_menu_focused;
|
||||
bool is_selected = (hovered_ == i);
|
||||
|
||||
auto style = is_selected ? (is_focused ? option_->style_selected_focused
|
||||
: option_->style_selected)
|
||||
: (is_focused ? option_->style_focused
|
||||
: option_->style_normal);
|
||||
auto focus_management = !is_selected ? nothing
|
||||
: is_menu_focused ? focus
|
||||
: select;
|
||||
auto state = EntryState{
|
||||
entries_[i],
|
||||
*selected_ == i,
|
||||
is_selected,
|
||||
is_focused,
|
||||
};
|
||||
auto element =
|
||||
(option_->transform
|
||||
? option_->transform
|
||||
: RadioboxOption::Simple().transform)(std::move(state));
|
||||
|
||||
const std::string& symbol =
|
||||
*selected_ == i ? option_->style_checked : option_->style_unchecked;
|
||||
elements.push_back(hbox(text(symbol), text(entries_[i]) | style) |
|
||||
focus_management | reflect(boxes_[i]));
|
||||
elements.push_back(element | focus_management | reflect(boxes_[i]));
|
||||
}
|
||||
return vbox(std::move(elements)) | reflect(box_);
|
||||
}
|
||||
|
Reference in New Issue
Block a user