FifeGUI 0.3.0
A C++ GUI library designed for games.
fcn::MouseEvent Class Reference

#include <mouseevent.hpp>

Inheritance diagram for fcn::MouseEvent:
fcn::InputEvent fcn::Event

Public Types

enum class  Button : std::uint8_t {
  Empty = 0 , Left , Middle , Right ,
  X1 , X2
}
enum class  Type : std::uint8_t {
  Moved = 0 , Pressed , Released , WheelMovedDown ,
  WheelMovedUp , WheelMovedRight , WheelMovedLeft , Clicked ,
  Entered , Exited , Dragged
}

Public Member Functions

MouseEvent::Button getButton () const
int getClickCount () const
MouseEvent::Type getType () const
int getX () const
int getY () const
 MouseEvent (Widget *source, Widget *distributor, bool isShiftPressed, bool isControlPressed, bool isAltPressed, bool isMetaPressed, MouseEvent::Type type, MouseEvent::Button button, int x, int y, int clickCount)
Public Member Functions inherited from fcn::InputEvent
void consume ()
WidgetgetDistributor () const
uint16_t getModMask () const
 InputEvent (Widget *source, Widget *distributor, bool isShiftPressed, bool isControlPressed, bool isAltPressed, bool isMetaPressed)
bool isAltPressed () const
bool isConsumed () const
bool isControlPressed () const
bool isMetaPressed () const
bool isShiftPressed () const
Public Member Functions inherited from fcn::Event
 Event (Widget *source)
WidgetgetSource () const

Protected Attributes

MouseEvent::Button mButton
int mClickCount
MouseEvent::Type mType
int mX = 0
int mY = 0
Protected Attributes inherited from fcn::InputEvent
WidgetmDistributor
bool mIsConsumed
uint16_t mModMask {0}
Protected Attributes inherited from fcn::Event
WidgetmSource {nullptr}

Friends

class Gui

Additional Inherited Members

Static Public Attributes inherited from fcn::InputEvent
static constexpr uint16_t ModAlt = 1 << 2
static constexpr uint16_t ModControl = 1 << 1
static constexpr uint16_t ModMeta = 1 << 3
static constexpr uint16_t ModShift = 1 << 0

Detailed Description

Represents a mouse event.

Definition at line 25 of file mouseevent.hpp.

Member Enumeration Documentation

◆ Button

enum class fcn::MouseEvent::Button : std::uint8_t
strong

Mouse button types.

Definition at line 49 of file mouseevent.hpp.

◆ Type

enum class fcn::MouseEvent::Type : std::uint8_t
strong

Mouse event types.

Definition at line 31 of file mouseevent.hpp.

Constructor & Destructor Documentation

◆ MouseEvent()

fcn::MouseEvent::MouseEvent ( Widget * source,
Widget * distributor,
bool isShiftPressed,
bool isControlPressed,
bool isAltPressed,
bool isMetaPressed,
MouseEvent::Type type,
MouseEvent::Button button,
int x,
int y,
int clickCount )

Constructor.

Parameters
sourceThe widget the event concerns.
distributorThe distributor of the mouse event.
isShiftPressedTrue if shift is pressed, false otherwise.
isControlPressedTrue if control is pressed, false otherwise.
isAltPressedTrue if alt is pressed, false otherwise.
isMetaPressedTrue if meta is pressed, false otherwise.
typeThe type of the mouse event.
buttonThe button of the mouse event.
xThe x coordinate of the event relative to the source widget.
yThe y coordinate of the event relative the source widget.
clickCountThe number of clicks generated with the same button. It's set to zero if another button is used.

Definition at line 19 of file mouseevent.cpp.

References fcn::InputEvent::InputEvent(), fcn::InputEvent::isAltPressed(), fcn::InputEvent::isControlPressed(), fcn::InputEvent::isMetaPressed(), fcn::InputEvent::isShiftPressed(), mButton, mClickCount, mType, mX, and mY.

Member Function Documentation

◆ getButton()

◆ getClickCount()

int fcn::MouseEvent::getClickCount ( ) const

Gets the number of clicks generated with the same button.

It's set to zero if another button is used.

Returns
The number of clicks generated with the same button.

Definition at line 68 of file mouseevent.cpp.

References mClickCount.

◆ getType()

MouseEvent::Type fcn::MouseEvent::getType ( ) const

Gets the type of the event.

Returns
The type of the event.

Definition at line 73 of file mouseevent.cpp.

References mType.

Referenced by fcn::Gui::distributeMouseEvent().

◆ getX()

int fcn::MouseEvent::getX ( ) const

Gets the x coordinate of the mouse event.

The coordinate relative to widget the mouse listener receiving the events have registered to.

Returns
The x coordinate of the mouse event.
See also
Widget::addMouseListener, Widget::removeMouseListener

Definition at line 58 of file mouseevent.cpp.

References mX.

Referenced by fcn::Widget::isMouseInside(), fcn::ScrollArea::mouseDragged(), fcn::Slider::mouseDragged(), fcn::Window::mouseDragged(), fcn::MenuBar::mousePressed(), fcn::ScrollArea::mousePressed(), fcn::Slider::mousePressed(), fcn::TabbedArea::mousePressed(), fcn::TextBox::mousePressed(), fcn::TextField::mousePressed(), and fcn::Window::mousePressed().

◆ getY()

int fcn::MouseEvent::getY ( ) const

◆ Gui

friend class Gui
friend

Grants Gui privileged access to internal state.

Gui is declared as a friend in order to be able to manipulate the protected member variables of this class and at the same time keep the MouseEvent class as const as possible. Gui updates the x and y coordinates so they are relative to the widget that the mouse listener is registered to.

Definition at line 169 of file mouseevent.hpp.

References Gui.

Referenced by Gui.

Member Data Documentation

◆ mButton

MouseEvent::Button fcn::MouseEvent::mButton
protected

Holds the button of the mouse event.

Definition at line 142 of file mouseevent.hpp.

Referenced by getButton(), and MouseEvent().

◆ mClickCount

int fcn::MouseEvent::mClickCount
protected

The number of clicks generated with the same button.

It's set to zero if another button is used.

Definition at line 158 of file mouseevent.hpp.

Referenced by getClickCount(), and MouseEvent().

◆ mType

MouseEvent::Type fcn::MouseEvent::mType
protected

Holds the type of the mouse event.

Definition at line 137 of file mouseevent.hpp.

Referenced by getType(), and MouseEvent().

◆ mX

int fcn::MouseEvent::mX = 0
protected

Holds the x-coordinate of the mouse event.

Definition at line 147 of file mouseevent.hpp.

Referenced by fcn::Gui::distributeMouseEvent(), getX(), and MouseEvent().

◆ mY

int fcn::MouseEvent::mY = 0
protected

Holds the y-coordinate of the mouse event.

Definition at line 152 of file mouseevent.hpp.

Referenced by fcn::Gui::distributeMouseEvent(), getY(), and MouseEvent().


The documentation for this class was generated from the following files: