FTXUI/include/ftxui/component/mouse.hpp

53 lines
1.2 KiB
C++
Raw Normal View History

2023-08-19 19:56:36 +08:00
// Copyright 2020 Arthur Sonzogni. All rights reserved.
// Use of this source code is governed by the MIT license that can be found in
// the LICENSE file.
2021-05-02 02:40:35 +08:00
#ifndef FTXUI_COMPONENT_MOUSE_HPP
#define FTXUI_COMPONENT_MOUSE_HPP
2021-04-25 21:22:38 +08:00
namespace ftxui {
/// @brief A mouse event. It contains the coordinate of the mouse, the button
/// pressed and the modifier (shift, ctrl, meta).
/// @ingroup component
struct Mouse {
enum Button {
Left = 0,
Middle = 1,
Right = 2,
None = 3,
WheelUp = 4,
WheelDown = 5,
};
enum Motion {
Released = 0,
Pressed = 1,
};
// Utility function to check the variations of the mouse state.
bool IsPressed(Button btn = Left) const; // Released => Pressed.
bool IsHeld(Button btn = Left) const; // Pressed => Pressed.
bool IsReleased(Button btn = Left) const; // Pressed => Released.
2021-04-25 21:22:38 +08:00
// Button
Button button = Button::None;
2021-04-25 21:22:38 +08:00
// Motion
Motion motion = Motion::Pressed;
2021-04-25 21:22:38 +08:00
// Modifiers:
bool shift = false;
bool meta = false;
bool control = false;
2021-04-25 21:22:38 +08:00
// Coordinates:
int x = 0;
int y = 0;
// Previous mouse event, if any.
Mouse* previous = nullptr;
2021-04-25 21:22:38 +08:00
};
} // namespace ftxui
2021-05-02 02:40:35 +08:00
#endif /* end of include guard: FTXUI_COMPONENT_MOUSE_HPP */