FifeGUI 0.3.0
A C++ GUI library designed for games.
mouseinput.cpp
1// SPDX-License-Identifier: LGPL-2.1-or-later OR BSD-3-Clause
2// SPDX-FileCopyrightText: 2004 - 2008 Olof Naessén and Per Larsson
3// SPDX-FileCopyrightText: 2013 - 2026 Fifengine contributors
4
5// Corresponding header include
6#include "fifechan/mouseinput.hpp"
7
8// Standard library includes
9#include <cassert>
10
11namespace fcn
12{
13 MouseInput::MouseInput(Button button, Type type, int x, int y, int timeStamp) :
14 mType(type), mButton(button), mTimeStamp(timeStamp), mX(x), mY(y)
15 {
16 assert(
17 "Type must be valid" &&
18 (type == Type::Pressed || type == Type::Released || type == Type::Moved || type == Type::WheelMovedUp ||
19 type == Type::WheelMovedDown || type == Type::WheelMovedRight || type == Type::WheelMovedLeft));
20 assert(
21 "Button must be valid" && (button == Button::Empty || button == Button::Left || button == Button::Right ||
22 button == Button::Middle || button == Button::X1 || button == Button::X2));
23 assert("Time stamp must be non-negative" && timeStamp >= 0);
24 }
25
27 {
28 assert(
29 "Type must be valid" &&
30 (type == Type::Pressed || type == Type::Released || type == Type::Moved || type == Type::WheelMovedUp ||
31 type == Type::WheelMovedDown || type == Type::WheelMovedRight || type == Type::WheelMovedLeft));
32 mType = type;
33 }
34
36 {
37 return mType;
38 }
39
41 {
42 assert(
43 "Button must be valid" && (button == Button::Empty || button == Button::Left || button == Button::Right ||
44 button == Button::Middle || button == Button::X1 || button == Button::X2));
45 mButton = button;
46 }
47
49 {
50 return mButton;
51 }
52
54 {
55 return mTimeStamp;
56 }
57
58 void MouseInput::setTimeStamp(int timeStamp)
59 {
60 assert("Time stamp must be non-negative" && timeStamp >= 0);
61 mTimeStamp = timeStamp;
62 }
63
64 void MouseInput::setX(int x)
65 {
66 mX = x;
67 }
68
69 int MouseInput::getX() const
70 {
71 return mX;
72 }
73
74 void MouseInput::setY(int y)
75 {
76 mY = y;
77 }
78
79 int MouseInput::getY() const
80 {
81 return mY;
82 }
83} // namespace fcn
void setX(int x)
Sets the x coordinate of the mouse input.
Button mButton
Holds the button of the mouse input.
int mX
Holds the x coordinate of the mouse input.
void setTimeStamp(int timeStamp)
Sets the timestamp for the mouse input.
void setY(int y)
Sets the y coordinate of the mouse input.
int mTimeStamp
Holds the timestamp of the mouse input.
Button
Mouse button.
int mY
Holds the y coordinate of the mouse input.
Type getType() const
Gets the type of the mouse input.
void setType(Type type)
Sets the type of the mouse input.
Button getButton() const
Gets the button pressed.
int getX() const
Gets the x coordinate of the mouse input.
void setButton(Button button)
Sets the button pressed.
Type mType
Holds the type of the mouse input.
Type
Type of mouse input.
int getY() const
Gets the y coordinate of the mouse input.
int getTimeStamp() const
Gets the time stamp of the input.
Used replacement tokens by configure_file():