From a5207536a9ea8c2ee2413157d7ded2634ab8eb9a Mon Sep 17 00:00:00 2001 From: ArthurSonzogni Date: Sun, 5 Nov 2023 11:44:36 +0100 Subject: [PATCH] Fix compile error --- include/ftxui/component/mouse.hpp | 6 +++--- src/ftxui/component/mouse.cpp | 25 +++++++++++-------------- 2 files changed, 14 insertions(+), 17 deletions(-) diff --git a/include/ftxui/component/mouse.hpp b/include/ftxui/component/mouse.hpp index 72a71f5d..38bf1e15 100644 --- a/include/ftxui/component/mouse.hpp +++ b/include/ftxui/component/mouse.hpp @@ -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; diff --git a/src/ftxui/component/mouse.cpp b/src/ftxui/component/mouse.cpp index 18c6caa2..74e51d2e 100644 --- a/src/ftxui/component/mouse.cpp +++ b/src/ftxui/component/mouse.cpp @@ -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