Lugdunum  0.1.0
Classes | Public Member Functions | Static Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | List of all members
lug::Window::Window Class Reference

Class for window. More...

#include <Window.hpp>

Inheritance diagram for lug::Window::Window:
[legend]
Collaboration diagram for lug::Window::Window:
[legend]

Classes

struct  InitInfo
 

Public Member Functions

 Window (const Window &)=delete
 
 Window (Window &&)=delete
 
Windowoperator= (const Window &)=delete
 
Windowoperator= (Window &&)=delete
 
virtual ~Window ()
 
bool isOpen () const
 Determines if the window is open. More...
 
virtual bool pollEvent (lug::Window::Event &event)
 Checks if an event is available from the window implementation, and fill it in the event parameter. More...
 
void close ()
 Close the window gracefully. More...
 
void setKeyRepeat (bool state)
 Enables or disables key repeat. More...
 
bool isKeyPressed (Keyboard::Key key) const
 Determines if a key pressed. More...
 
bool isMousePressed (Mouse::Button button) const
 Determines if a mouse button pressed. More...
 
const Math::Vec2i & getMousePos () const
 Retrieves the mouses position. More...
 
void setMousePos (const Math::Vec2i &mousePosition)
 Sets the mouse position. More...
 
Math::Vec2i getWindowSize () const
 Gets the window size. More...
 
void setMouseCursorVisible (bool visible)
 Sets the visibility of the mouse cursor (hide/show) More...
 

Static Public Member Functions

static std::unique_ptr< Windowcreate (const InitInfo &initInfo)
 Utility to create a window. More...
 

Public Attributes

GamePadEvent _gamePadState {{0.0f, 0.0f}, {0.0f, 0.0f}}
 
TouchScreenEvent _touchScreenState {{{0, 0}, {0, 0}}, lug::Window::TouchScreenEvent::GestureState::None, false, false, false}
 

Protected Member Functions

 Window ()
 
bool init (const InitInfo &initInfo)
 
void initKeyState ()
 Inits every key in _keyState to false. More...
 
void initMouseState ()
 Inits every button in _mouseState to false. More...
 

Protected Attributes

priv::WindowImpl_impl {nullptr}
 
VideoMode _mode {800, 600, 8, 8, 8, 60}
 
std::unordered_map< Keyboard::Key, bool > _keyState
 
std::unordered_map< Mouse::Button, bool > _mouseState
 
Math::Vec2i _mousePosition {0, 0}
 

Detailed Description

Class for window.

Definition at line 59 of file Window.hpp.

Constructor & Destructor Documentation

◆ Window() [1/3]

lug::Window::Window::Window ( const Window )
delete

◆ Window() [2/3]

lug::Window::Window::Window ( Window &&  )
delete

◆ ~Window()

lug::Window::Window::~Window ( )
virtual

Reimplemented in lug::Graphics::Vulkan::Render::Window, and lug::Graphics::Render::Window.

Definition at line 22 of file Window.cpp.

◆ Window() [3/3]

lug::Window::Window::Window ( )
protected

Definition at line 17 of file Window.cpp.

Member Function Documentation

◆ operator=() [1/2]

Window& lug::Window::Window::operator= ( const Window )
delete

◆ operator=() [2/2]

Window& lug::Window::Window::operator= ( Window &&  )
delete

◆ create()

std::unique_ptr< Window > lug::Window::Window::create ( const InitInfo initInfo)
static

Utility to create a window.

Parameters
[in]initInfoSee #InitInfo
Returns
A pointer to the created window handle. The ownership is transfered to the caller.

Definition at line 26 of file Window.cpp.

◆ isOpen()

bool lug::Window::Window::isOpen ( ) const

Determines if the window is open.

Returns
True if open, False otherwise.

Definition at line 193 of file Window.cpp.

◆ pollEvent()

bool lug::Window::Window::pollEvent ( lug::Window::Event event)
virtual

Checks if an event is available from the window implementation, and fill it in the event parameter.

Parameters
[out]eventEvent input, to be filled by pollEvent.
Returns
True if an event was polled, false otherwise.

Reimplemented in lug::Graphics::Vulkan::Render::Window.

Definition at line 197 of file Window.cpp.

◆ close()

void lug::Window::Window::close ( )

Close the window gracefully.

Definition at line 255 of file Window.cpp.

◆ setKeyRepeat()

void lug::Window::Window::setKeyRepeat ( bool  state)

Enables or disables key repeat.

The key repeat is set to false by default (i.e. the default, unpressed, behavior)

Parameters
[in]stateDesired state

Definition at line 243 of file Window.cpp.

◆ isKeyPressed()

bool lug::Window::Window::isKeyPressed ( Keyboard::Key  key) const

Determines if a key pressed.

Parameters
[in]keyThe key to check.
Returns
True if the key is pressed, False otherwise.

Definition at line 263 of file Window.cpp.

◆ isMousePressed()

bool lug::Window::Window::isMousePressed ( Mouse::Button  button) const

Determines if a mouse button pressed.

Parameters
[in]buttonThe button to check.
Returns
True if the button is pressed, False otherwise.

Definition at line 267 of file Window.cpp.

◆ getMousePos()

const Math::Vec2i & lug::Window::Window::getMousePos ( ) const

Retrieves the mouses position.

Returns
Position of the cursor (relative to the window).

Definition at line 271 of file Window.cpp.

◆ setMousePos()

void lug::Window::Window::setMousePos ( const Math::Vec2i &  mousePosition)

Sets the mouse position.

Parameters
[in]mousePositionThe position of the cursor (relative to the window)

Definition at line 275 of file Window.cpp.

◆ getWindowSize()

Math::Vec2i lug::Window::Window::getWindowSize ( ) const

Gets the window size.

Returns
The window size.

Definition at line 282 of file Window.cpp.

◆ setMouseCursorVisible()

void lug::Window::Window::setMouseCursorVisible ( bool  visible)

Sets the visibility of the mouse cursor (hide/show)

Parameters
[in]visibleThe state

Definition at line 249 of file Window.cpp.

◆ init()

bool lug::Window::Window::init ( const InitInfo initInfo)
protected

Definition at line 36 of file Window.cpp.

◆ initKeyState()

void lug::Window::Window::initKeyState ( )
protected

Inits every key in _keyState to false.

Definition at line 49 of file Window.cpp.

◆ initMouseState()

void lug::Window::Window::initMouseState ( )
protected

Inits every button in _mouseState to false.

Definition at line 185 of file Window.cpp.

Member Data Documentation

◆ _gamePadState

GamePadEvent lug::Window::Window::_gamePadState {{0.0f, 0.0f}, {0.0f, 0.0f}}

Definition at line 161 of file Window.hpp.

◆ _touchScreenState

TouchScreenEvent lug::Window::Window::_touchScreenState {{{0, 0}, {0, 0}}, lug::Window::TouchScreenEvent::GestureState::None, false, false, false}

Definition at line 162 of file Window.hpp.

◆ _impl

priv::WindowImpl* lug::Window::Window::_impl {nullptr}
protected

Internal representation of the platform specific implementation.

Definition at line 180 of file Window.hpp.

◆ _mode

VideoMode lug::Window::Window::_mode {800, 600, 8, 8, 8, 60}
protected

Default video mode.

Definition at line 185 of file Window.hpp.

◆ _keyState

std::unordered_map<Keyboard::Key, bool> lug::Window::Window::_keyState
protected

Map to store the current state of the keys, used by isKeyPressed.

Definition at line 190 of file Window.hpp.

◆ _mouseState

std::unordered_map<Mouse::Button, bool> lug::Window::Window::_mouseState
protected

Map to store the current state of the mouse buttons, used by isMousePressed.

Definition at line 195 of file Window.hpp.

◆ _mousePosition

Math::Vec2i lug::Window::Window::_mousePosition {0, 0}
protected

Used to store the mouse's position, used by getMousePos.

Definition at line 200 of file Window.hpp.


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