Fix compile error

This commit is contained in:
ArthurSonzogni 2023-11-05 11:44:36 +01:00
parent 4bf4c36519
commit a5207536a9
No known key found for this signature in database
GPG Key ID: 41D98248C074CD6C
2 changed files with 14 additions and 17 deletions

View File

@ -24,9 +24,9 @@ struct Mouse {
};
// Utility function to check the variations of the mouse state.
bool IsPressed(Button button = Left) const;
bool IsHeld(Button button = Left) const;
bool IsReleased(Button button = Left) const;
bool IsPressed(Button btn = Left) const; // Released => Pressed.
bool IsHeld(Button btn = Left) const; // Pressed => Pressed.
bool IsReleased(Button btn = Left) const; // Pressed => Released.
// Button
Button button = Button::None;

View File

@ -7,33 +7,30 @@
namespace ftxui {
namespace {
bool IsDown(const Mouse& mouse, Mouse::Button button) {
return mouse.button == button && mouse.motion == Mouse::Pressed;
bool IsDown(const Mouse* mouse, Mouse::Button btn) {
return mouse->button == btn && mouse->motion == Mouse::Pressed;
}
} // namespace
/// Return whether the mouse transitionned from released to pressed.
/// This is useful to detect a click.
/// @arg button The button to check.
bool Mouse::IsPressed(Button button) const {
return IsDown(*this, button) &&
(!previous || !IsDown(*previous, button));
/// @arg btn The button to check.
bool Mouse::IsPressed(Button btn) const {
return IsDown(this, btn) && (!previous || !IsDown(previous, btn));
}
/// Return whether the mouse is currently held.
/// This is useful to detect a drag.
/// @arg button The button to check.
bool Mouse::IsHeld(Button button) const {
return IsDown(*this, button) && previous && IsDown(*previous, button);
/// @arg btn The button to check.
bool Mouse::IsHeld(Button btn) const {
return IsDown(this, btn) && previous && IsDown(previous, btn);
}
/// Return whether the mouse transitionned from pressed to released.
/// This is useful to detect a click.
/// @arg button The button to check.
bool Mouse::IsReleased(Button button) const {
return !IsDown(*this, button) &&
(previous && IsDown(*previous, button));
/// @arg btn The button to check.
bool Mouse::IsReleased(Button btn) const {
return !IsDown(this, btn) && (previous && IsDown(previous, btn));
}
} // namespace ftxui