cpp-terminal 1.0.0
Small C++ library for writing multiplatform terminal applications
Loading...
Searching...
No Matches
mouse.hpp
Go to the documentation of this file.
1/*
2* cpp-terminal
3* C++ library for writing multi-platform terminal applications.
4*
5* SPDX-FileCopyrightText: 2019-2024 cpp-terminal
6*
7* SPDX-License-Identifier: MIT
8*/
9
10#pragma once
11
12#include <cstddef>
13#include <cstdint>
14
15namespace Term
16{
17
18class Button
19{
20public:
21 enum class Type : std::int8_t
22 {
23 None = -1,
24 Left,
25 Wheel,
26 Right,
27 Button1,
28 Button2,
29 Button3,
30 Button4,
31 Button5,
32 Button6,
33 Button7,
34 Button8,
35 };
36 enum class Action : std::int8_t
37 {
38 None = 0,
39 Pressed,
44 ToRight,
45 ToLeft,
46 };
47 Button() = default;
49 Term::Button::Action action() const noexcept;
50 Term::Button::Type type() const noexcept;
51 bool operator==(const Term::Button& button) const;
52 bool operator!=(const Term::Button& button) const;
53
54private:
57};
58
59class Mouse
60{
61public:
62 Mouse() = default;
63 Mouse(const Term::Button& buttons, const std::uint16_t& row, const std::uint16_t& column) : m_buttons(buttons), m_row(row), m_column(column) {}
64 std::size_t row() const noexcept;
65 std::size_t column() const noexcept;
66 Term::Button getButton() const noexcept;
67 bool is(const Term::Button::Type& type, const Term::Button::Action& action) const noexcept;
68 bool is(const Term::Button::Type& type) const noexcept;
69 bool operator==(const Term::Mouse& mouse) const;
70 bool operator!=(const Term::Mouse& mouse) const;
71
72private:
74 std::uint16_t m_row{0};
75 std::uint16_t m_column{0};
76};
77
78} // namespace Term
Button(const Term::Button::Type &type, const Term::Button::Action &action)
Definition mouse.hpp:48
Button()=default
Term::Button::Action m_action
Definition mouse.hpp:56
Term::Button::Type m_type
Definition mouse.hpp:55
Term::Button::Type type() const noexcept
Definition mouse.cpp:14
Term::Button::Action action() const noexcept
Definition mouse.cpp:12
Mouse(const Term::Button &buttons, const std::uint16_t &row, const std::uint16_t &column)
Definition mouse.hpp:63
std::uint16_t m_column
Definition mouse.hpp:75
std::size_t row() const noexcept
Definition mouse.cpp:26
std::size_t column() const noexcept
Definition mouse.cpp:28
Mouse()=default
std::uint16_t m_row
Definition mouse.hpp:74
bool is(const Term::Button::Type &type, const Term::Button::Action &action) const noexcept
Definition mouse.cpp:20
Term::Button m_buttons
Definition mouse.hpp:73
Term::Button getButton() const noexcept
Definition mouse.cpp:24
Definition args.cpp:13