Add changelog and example.

This commit is contained in:
ArthurSonzogni 2024-04-06 17:41:43 +02:00
parent c71cf3e4bf
commit 5ff0764e77
No known key found for this signature in database
GPG Key ID: 41D98248C074CD6C
3 changed files with 40 additions and 0 deletions

View File

@ -7,6 +7,7 @@ current (development)
### Component ### Component
- Feature: Add support for `Input`'s insert mode. Add `InputOption::insert` - Feature: Add support for `Input`'s insert mode. Add `InputOption::insert`
option. Added by @mingsheng13. option. Added by @mingsheng13.
- Feature: Add `DropdownOption` to configure the dropdown. See #826.
- Bugfix/Breaking change: `Mouse transition`: - Bugfix/Breaking change: `Mouse transition`:
- Detect when the mouse move, as opposed to being pressed. - Detect when the mouse move, as opposed to being pressed.
The Mouse::Moved motion was added. The Mouse::Moved motion was added.

View File

@ -61,9 +61,44 @@ int main() {
}, },
}); });
auto dropdown_3 = Dropdown({
.radiobox =
{
.entries = &entries,
.transform =
[](const EntryState& s) {
auto t = text(s.label) | borderEmpty;
if (s.active) {
t |= bold;
}
if (s.focused) {
t |= inverted;
}
return t;
},
},
.transform =
[](bool open, Element checkbox, Element radiobox) {
checkbox |= borderEmpty;
if (open) {
return vbox({
checkbox | inverted,
radiobox | vscroll_indicator | frame |
size(HEIGHT, LESS_THAN, 20) | bgcolor(Color::Red),
filler(),
});
}
return vbox({
checkbox | bgcolor(Color::Red),
filler(),
});
},
});
auto screen = ScreenInteractive::FitComponent(); auto screen = ScreenInteractive::FitComponent();
screen.Loop(Container::Horizontal({ screen.Loop(Container::Horizontal({
dropdown_1, dropdown_1,
dropdown_2, dropdown_2,
dropdown_3,
})); }));
} }

View File

@ -268,9 +268,13 @@ struct WindowOptions {
/// @ingroup component /// @ingroup component
/// A dropdown menu is a checkbox opening/closing a radiobox. /// A dropdown menu is a checkbox opening/closing a radiobox.
struct DropdownOption { struct DropdownOption {
/// Whether the dropdown is open or closed:
Ref<bool> open = false; Ref<bool> open = false;
// The options for the checkbox:
CheckboxOption checkbox; CheckboxOption checkbox;
// The options for the radiobox:
RadioboxOption radiobox; RadioboxOption radiobox;
// The transformation function:
std::function<Element(bool open, Element checkbox, Element radiobox)> std::function<Element(bool open, Element checkbox, Element radiobox)>
transform; transform;
}; };