mirror of
https://github.com/ArthurSonzogni/FTXUI.git
synced 2025-06-24 16:21:12 +08:00
Fix compile error
This commit is contained in:
parent
4bf4c36519
commit
a5207536a9
@ -24,9 +24,9 @@ struct Mouse {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Utility function to check the variations of the mouse state.
|
// Utility function to check the variations of the mouse state.
|
||||||
bool IsPressed(Button button = Left) const;
|
bool IsPressed(Button btn = Left) const; // Released => Pressed.
|
||||||
bool IsHeld(Button button = Left) const;
|
bool IsHeld(Button btn = Left) const; // Pressed => Pressed.
|
||||||
bool IsReleased(Button button = Left) const;
|
bool IsReleased(Button btn = Left) const; // Pressed => Released.
|
||||||
|
|
||||||
// Button
|
// Button
|
||||||
Button button = Button::None;
|
Button button = Button::None;
|
||||||
|
@ -7,33 +7,30 @@
|
|||||||
namespace ftxui {
|
namespace ftxui {
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
bool IsDown(const Mouse& mouse, Mouse::Button button) {
|
bool IsDown(const Mouse* mouse, Mouse::Button btn) {
|
||||||
return mouse.button == button && mouse.motion == Mouse::Pressed;
|
return mouse->button == btn && mouse->motion == Mouse::Pressed;
|
||||||
}
|
}
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
|
|
||||||
/// Return whether the mouse transitionned from released to pressed.
|
/// Return whether the mouse transitionned from released to pressed.
|
||||||
/// This is useful to detect a click.
|
/// This is useful to detect a click.
|
||||||
/// @arg button The button to check.
|
/// @arg btn The button to check.
|
||||||
bool Mouse::IsPressed(Button button) const {
|
bool Mouse::IsPressed(Button btn) const {
|
||||||
return IsDown(*this, button) &&
|
return IsDown(this, btn) && (!previous || !IsDown(previous, btn));
|
||||||
(!previous || !IsDown(*previous, button));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Return whether the mouse is currently held.
|
/// Return whether the mouse is currently held.
|
||||||
/// This is useful to detect a drag.
|
/// This is useful to detect a drag.
|
||||||
/// @arg button The button to check.
|
/// @arg btn The button to check.
|
||||||
bool Mouse::IsHeld(Button button) const {
|
bool Mouse::IsHeld(Button btn) const {
|
||||||
return IsDown(*this, button) && previous && IsDown(*previous, button);
|
return IsDown(this, btn) && previous && IsDown(previous, btn);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Return whether the mouse transitionned from pressed to released.
|
/// Return whether the mouse transitionned from pressed to released.
|
||||||
/// This is useful to detect a click.
|
/// This is useful to detect a click.
|
||||||
/// @arg button The button to check.
|
/// @arg btn The button to check.
|
||||||
bool Mouse::IsReleased(Button button) const {
|
bool Mouse::IsReleased(Button btn) const {
|
||||||
return !IsDown(*this, button) &&
|
return !IsDown(this, btn) && (previous && IsDown(previous, btn));
|
||||||
(previous && IsDown(*previous, button));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace ftxui
|
} // namespace ftxui
|
||||||
|
Loading…
Reference in New Issue
Block a user