R-Type  2
Doom but in better
Loading...
Searching...
No Matches
MouseInfo.hpp
Go to the documentation of this file.
1/*
2** EPITECH PROJECT, 2024
3** rtype (Workspace)
4** File description:
5** MouseInfo.hpp
6*/
7
13#pragma once
14
15#include <any>
16#include <utility>
17#include <optional>
18#include <SFML/Window/Event.hpp>
19
20#include "Log.hpp"
21#include "LogMacros.hpp"
22#include "Utilities.hpp"
24
25namespace GUI
26{
27 namespace ECS
28 {
29 namespace Systems
30 {
35 enum class MouseWheel
36 {
37 Vertical,
39 };
40 class MouseInfo : public EntityNode {
41 public:
42 MouseInfo(const std::uint32_t entityId = 0);
43 ~MouseInfo();
44
45 void update(const std::any &event);
46 void update(const MouseInfo &entity);
47 void update(const std::pair<int, int> &position);
48
49 const std::pair<int, int> getMousePosition() const;
50
51 const bool isMouseInFocus() const;
52 const bool isMouseLeftButtonClicked() const;
53 const bool isMouseMiddleButtonClicked() const;
54 const bool isMouseRightButtonClicked() const;
55 const bool isMouseExtra1ButtonClicked() const;
56 const bool isMouseExtra2ButtonClicked() const;
57 const bool isMouseWheelScrolled() const;
58 const bool isMouseWheelScrolledUp() const;
59 const bool isMouseWheelScrolledDown() const;
60 const bool isMouseWheelScrolledLeft() const;
61 const bool isMouseWheelScrolledRight() const;
62
63 const float getScrollIndex() const;
64
65 const MouseWheel getScrollDirection() const;
66
67 const int getPositionX() const;
68 const int getPositionY() const;
77 const std::string getInfo(const unsigned int indent = 0) const;
78
79 void clear();
80
82
83 private:
84 bool _mouseInFocus = false;
85 bool _leftButtonClicked = false;
86 bool _rightButtonClicked = false;
87 bool _middleButtonClicked = false;
88 bool _extra1ButtonClicked = false;
89 bool _extra2ButtonClicked = false;
90 std::pair<int, int> _mousePosition = { 0,0 };
91 sf::Event::MouseWheelScrolled _mouseWheel;
92 };
93
102 std::ostream &operator<<(std::ostream &os, const MouseInfo &item);
103 }
104 }
105}
This is the file that links the EntityNode children.
Macro definitions for logging messages with varying levels of detail and formatting.
This is the file in charge of containing the Log class (the one in charge of outputing info only when...
~MouseInfo()
Destroys the MouseInfo object.
Definition MouseInfo.cpp:31
const bool isMouseWheelScrolled() const
Check if the mouse has scrolled.
const float getScrollIndex() const
Function in charge of returning the scroll index of the mouse.
const std::string getInfo(const unsigned int indent=0) const
This is a function meant for debugging purposes It will dump the current state of the variables upon ...
const bool isMouseExtra2ButtonClicked() const
Checks if the extra2 mouse button is pressed.
const MouseWheel getScrollDirection() const
Function in charge of returning the direction in which the user scrolled.
const int getPositionX() const
Retrieves the x-coordinate of the mouse position.
MouseInfo & operator=(const GUI::ECS::Systems::MouseInfo &copy)
Update the content of the class using the '=' sign overloader.
const std::pair< int, int > getMousePosition() const
Retrieves the current mouse position.
const bool isMouseWheelScrolledDown() const
Check if the mouse has scrolled downwards.
const bool isMouseExtra1ButtonClicked() const
Checks if the extra1 mouse button is pressed.
const bool isMouseWheelScrolledRight() const
Check if the mouse has scrolled to the right.
const int getPositionY() const
Retrieves the y-coordinate of the mouse position.
const bool isMouseWheelScrolledLeft() const
Check if the mouse has scrolled to the left.
void clear()
Resets the internal state of the MouseInfo object.
const bool isMouseLeftButtonClicked() const
Checks if the left mouse button is pressed.
const bool isMouseWheelScrolledUp() const
Check if the mouse has scrolled upwards.
void update(const std::any &event)
Processes and updates the internal state based on a given sf::Event.
Definition MouseInfo.cpp:38
const bool isMouseRightButtonClicked() const
Checks if the right mouse button is pressed.
const bool isMouseInFocus() const
Checks if the mouse is in the window.
const bool isMouseMiddleButtonClicked() const
Checks if the middle mouse button is pressed.
MouseInfo(const std::uint32_t entityId=0)
Constructs a new MouseInfo object with default values.
Definition MouseInfo.cpp:19
MouseWheel
An enum class to allow the user to know which direction the mouse has scrolled.
Definition MouseInfo.hpp:36
@ Vertical
The vertical mouse wheel.
@ Horizontal
The horizontal mouse wheel.
std::ostream & operator<<(std::ostream &os, const Clock &item)
Outputs the clock's info to a stream.
Definition Clock.cpp:73