New module: Platform - Split window management from Utility module (#128)
* New module: Platform - Split window management from Utility module Final touch * NDK/SDK: Bring back initialization of Utility
This commit is contained in:
committed by
Jérôme Leclercq
parent
41a1b5d493
commit
5aa072cee3
@@ -27,32 +27,29 @@
|
||||
#ifndef NAZARA_CONFIG_UTILITY_HPP
|
||||
#define NAZARA_CONFIG_UTILITY_HPP
|
||||
|
||||
/// Chaque modification d'un paramètre du module nécessite une recompilation de celui-ci
|
||||
/// Each modification of a parameter needs a recompilation of the module
|
||||
|
||||
// Utilise un manager de mémoire pour gérer les allocations dynamiques (détecte les leaks au prix d'allocations/libérations dynamiques plus lentes)
|
||||
// Use the MemoryManager to manage dynamic allocations (can detect memory leak but allocations/frees are slower)
|
||||
#define NAZARA_UTILITY_MANAGE_MEMORY 0
|
||||
|
||||
// Active les tests de sécurité basés sur le code (Conseillé pour le développement)
|
||||
// Activate the security tests based on the code (Advised for development)
|
||||
#define NAZARA_UTILITY_SAFE 1
|
||||
|
||||
// Lors du parsage d'une ressource, déclenche un avertissement si une erreur non-critique est repérée dans une ressource (Plus lent)
|
||||
// When a resource is being parsed, it triggers a warning if a non-critical error is found in the resource (Slower)
|
||||
#define NAZARA_UTILITY_STRICT_RESOURCE_PARSING 1
|
||||
|
||||
// Protège les classes des accès concurrentiels
|
||||
// Protect the classes against data race
|
||||
//#define NAZARA_UTILITY_THREADSAFE 1
|
||||
|
||||
// Force les buffers à posséder un stride multiple de 32 bytes (Gain de performances sur certaines cartes/plus de consommation mémoire)
|
||||
#define NAZARA_UTILITY_VERTEX_DECLARATION_FORCE_STRIDE_MULTIPLE_OF_32 0 ///FIXME: Ne peut pas être utilisé pour l'instant
|
||||
// Force the buffers to have a stride which is a multiple of 32 bytes (Gain of performances on certain cards/more memory consumption)
|
||||
#define NAZARA_UTILITY_VERTEX_DECLARATION_FORCE_STRIDE_MULTIPLE_OF_32 0 ///FIXME: Can not be used for the moment
|
||||
|
||||
// Sous Windows, fait en sorte que les touches ALT et F10 n'activent pas le menu de la fenêtre
|
||||
#define NAZARA_UTILITY_WINDOWS_DISABLE_MENU_KEYS 1
|
||||
/// Each modification of a parameter following implies a modification (often minor) of the code
|
||||
|
||||
/// Chaque modification d'un paramètre ci-dessous implique une modification (souvent mineure) du code
|
||||
|
||||
// Le nombre maximum de poids affectant un sommet (En cas de dépassement, les poids supplémentaires seront ignorés et les autres renormalisés)
|
||||
// The maximal number of weights acting on a vertex (In case of overflow, the surnumerous weights would be ignored and the others renormalized)
|
||||
#define NAZARA_UTILITY_SKINNING_MAX_WEIGHTS 4
|
||||
|
||||
/// Vérification des valeurs et types de certaines constantes
|
||||
/// Checking the values and types of certain constants
|
||||
#include <Nazara/Utility/ConfigCheck.hpp>
|
||||
|
||||
#if defined(NAZARA_STATIC)
|
||||
|
||||
@@ -7,12 +7,12 @@
|
||||
#ifndef NAZARA_CONFIG_CHECK_UTILITY_HPP
|
||||
#define NAZARA_CONFIG_CHECK_UTILITY_HPP
|
||||
|
||||
/// Ce fichier sert à vérifier la valeur des constantes du fichier Config.hpp
|
||||
/// This file is used to check the constant values defined in Config.hpp
|
||||
|
||||
#include <type_traits>
|
||||
#define NazaraCheckTypeAndVal(name, type, op, val, err) static_assert(std::is_ ##type <decltype(name)>::value && name op val, #type err)
|
||||
|
||||
// On force la valeur de MANAGE_MEMORY en mode debug
|
||||
// We force the value of MANAGE_MEMORY in debug
|
||||
#if defined(NAZARA_DEBUG) && !NAZARA_UTILITY_MANAGE_MEMORY
|
||||
#undef NAZARA_UTILITY_MANAGE_MEMORY
|
||||
#define NAZARA_UTILITY_MANAGE_MEMORY 0
|
||||
|
||||
@@ -1,71 +0,0 @@
|
||||
// Copyright (C) 2017 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine - Utility module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_CURSOR_HPP
|
||||
#define NAZARA_CURSOR_HPP
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Core/ObjectRef.hpp>
|
||||
#include <Nazara/Math/Vector2.hpp>
|
||||
#include <Nazara/Utility/Config.hpp>
|
||||
#include <Nazara/Utility/Image.hpp>
|
||||
#include <array>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
class CursorImpl;
|
||||
|
||||
class Cursor;
|
||||
|
||||
using CursorConstRef = ObjectRef<const Cursor>;
|
||||
using CursorRef = ObjectRef<Cursor>;
|
||||
|
||||
class NAZARA_UTILITY_API Cursor : public RefCounted
|
||||
{
|
||||
friend class Utility;
|
||||
friend class WindowImpl;
|
||||
|
||||
public:
|
||||
inline Cursor();
|
||||
inline Cursor(const Image& cursor, const Vector2i& hotSpot, SystemCursor placeholder);
|
||||
Cursor(const Cursor&) = delete;
|
||||
Cursor(Cursor&&) = delete;
|
||||
inline ~Cursor();
|
||||
|
||||
bool Create(const Image& cursor, const Vector2i& hotSpot, SystemCursor placeholder);
|
||||
|
||||
void Destroy();
|
||||
|
||||
inline const Image& GetImage() const;
|
||||
inline SystemCursor GetSystemCursor() const;
|
||||
|
||||
inline bool IsValid() const;
|
||||
|
||||
Cursor& operator=(const Cursor&) = delete;
|
||||
Cursor& operator=(Cursor&&) = delete;
|
||||
|
||||
static inline Cursor* Get(SystemCursor cursor);
|
||||
template<typename... Args> static CursorRef New(Args&&... args);
|
||||
|
||||
private:
|
||||
inline explicit Cursor(SystemCursor systemCursor);
|
||||
|
||||
bool Create(SystemCursor cursor);
|
||||
|
||||
static bool Initialize();
|
||||
static void Uninitialize();
|
||||
|
||||
Image m_cursorImage;
|
||||
SystemCursor m_systemCursor;
|
||||
CursorImpl* m_impl;
|
||||
|
||||
static std::array<Cursor, SystemCursor_Max + 1> s_systemCursors;
|
||||
};
|
||||
}
|
||||
|
||||
#include <Nazara/Utility/Cursor.inl>
|
||||
|
||||
#endif // NAZARA_CURSOR_HPP
|
||||
@@ -1,69 +0,0 @@
|
||||
// Copyright (C) 2017 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine - Utility module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#include <Nazara/Utility/Cursor.hpp>
|
||||
#include <Nazara/Core/ErrorFlags.hpp>
|
||||
#include <Nazara/Utility/Debug.hpp>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
inline Cursor::Cursor() :
|
||||
m_impl(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
inline Cursor::Cursor(const Image& cursor, const Vector2i& hotSpot, SystemCursor placeholder)
|
||||
{
|
||||
ErrorFlags flags(ErrorFlag_ThrowException, true);
|
||||
Create(cursor, hotSpot, placeholder);
|
||||
}
|
||||
|
||||
inline Cursor* Cursor::Get(SystemCursor cursor)
|
||||
{
|
||||
return &s_systemCursors[cursor];
|
||||
}
|
||||
|
||||
inline Cursor::Cursor(SystemCursor systemCursor) :
|
||||
Cursor()
|
||||
{
|
||||
ErrorFlags flags(ErrorFlag_ThrowException, true);
|
||||
Create(systemCursor);
|
||||
}
|
||||
|
||||
inline Cursor::~Cursor()
|
||||
{
|
||||
Destroy();
|
||||
}
|
||||
|
||||
inline const Image& Cursor::GetImage() const
|
||||
{
|
||||
NazaraAssert(IsValid(), "Invalid cursor");
|
||||
NazaraAssert(m_cursorImage.IsValid(), "System cursors have no image");
|
||||
|
||||
return m_cursorImage;
|
||||
}
|
||||
|
||||
inline SystemCursor Cursor::GetSystemCursor() const
|
||||
{
|
||||
NazaraAssert(IsValid(), "Invalid cursor");
|
||||
|
||||
return m_systemCursor;
|
||||
}
|
||||
|
||||
inline bool Cursor::IsValid() const
|
||||
{
|
||||
return m_impl != nullptr;
|
||||
}
|
||||
|
||||
template<typename... Args>
|
||||
CursorRef Cursor::New(Args&&... args)
|
||||
{
|
||||
std::unique_ptr<Cursor> object(new Cursor(std::forward<Args>(args)...));
|
||||
object->SetPersistent(false);
|
||||
|
||||
return object.release();
|
||||
}
|
||||
}
|
||||
|
||||
#include <Nazara/Utility/DebugOff.hpp>
|
||||
@@ -1,42 +0,0 @@
|
||||
// Copyright (C) 2017 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine - Utility module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_CURSORCONTROLLER_HPP
|
||||
#define NAZARA_CURSORCONTROLLER_HPP
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Core/HandledObject.hpp>
|
||||
#include <Nazara/Core/ObjectHandle.hpp>
|
||||
#include <Nazara/Core/Signal.hpp>
|
||||
#include <Nazara/Utility/Cursor.hpp>
|
||||
#include <Nazara/Utility/Enums.hpp>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
class CursorController;
|
||||
|
||||
using CursorControllerHandle = ObjectHandle<CursorController>;
|
||||
|
||||
class CursorController : public HandledObject<CursorController>
|
||||
{
|
||||
public:
|
||||
CursorController() = default;
|
||||
CursorController(const CursorController&) = delete;
|
||||
CursorController(CursorController&&) = default;
|
||||
~CursorController() = default;
|
||||
|
||||
inline void UpdateCursor(const CursorRef& cursor);
|
||||
|
||||
CursorController& operator=(const CursorController&) = delete;
|
||||
CursorController& operator=(CursorController&&) = default;
|
||||
|
||||
NazaraSignal(OnCursorUpdated, const CursorController* /*cursorController*/, const CursorRef& /*cursor*/);
|
||||
};
|
||||
}
|
||||
|
||||
#include <Nazara/Utility/CursorController.inl>
|
||||
|
||||
#endif // NAZARA_CURSORCONTROLLER_HPP
|
||||
@@ -1,16 +0,0 @@
|
||||
// Copyright (C) 2017 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine - Utility module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#include <Nazara/Utility/CursorController.hpp>
|
||||
#include <Nazara/Utility/Debug.hpp>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
inline void CursorController::UpdateCursor(const CursorRef& cursor)
|
||||
{
|
||||
OnCursorUpdated(this, cursor);
|
||||
}
|
||||
}
|
||||
|
||||
#include <Nazara/Utility/DebugOff.hpp>
|
||||
@@ -92,8 +92,8 @@ namespace Nz
|
||||
|
||||
enum CubemapFace
|
||||
{
|
||||
// Cette énumération est prévue pour remplacer l'argument "z" des méthodes de Image contenant un cubemap
|
||||
// L'ordre est X, -X, Y, -Y, Z, -Z
|
||||
// This enumeration is intended to replace the "z" argument of Image's methods containing cubemap
|
||||
// The order is X, -X, Y, -Y, Z, -Z
|
||||
CubemapFace_PositiveX = 0,
|
||||
CubemapFace_PositiveY = 2,
|
||||
CubemapFace_PositiveZ = 4,
|
||||
@@ -307,30 +307,6 @@ namespace Nz
|
||||
SamplerWrap_Max = SamplerWrap_Repeat
|
||||
};
|
||||
|
||||
enum SystemCursor
|
||||
{
|
||||
SystemCursor_Crosshair,
|
||||
SystemCursor_Default,
|
||||
SystemCursor_Hand,
|
||||
SystemCursor_Help,
|
||||
SystemCursor_Move,
|
||||
SystemCursor_None,
|
||||
SystemCursor_Pointer,
|
||||
SystemCursor_Progress,
|
||||
SystemCursor_ResizeE,
|
||||
SystemCursor_ResizeN,
|
||||
SystemCursor_ResizeNE,
|
||||
SystemCursor_ResizeNW,
|
||||
SystemCursor_ResizeS,
|
||||
SystemCursor_ResizeSE,
|
||||
SystemCursor_ResizeSW,
|
||||
SystemCursor_ResizeW,
|
||||
SystemCursor_Text,
|
||||
SystemCursor_Wait,
|
||||
|
||||
SystemCursor_Max = SystemCursor_Wait
|
||||
};
|
||||
|
||||
enum StencilOperation
|
||||
{
|
||||
StencilOperation_Decrement,
|
||||
@@ -370,7 +346,7 @@ namespace Nz
|
||||
{
|
||||
VertexComponent_Unused = -1,
|
||||
|
||||
// Nous nous limitons à 16 composants de sommets car c'est le minimum supporté par le GPU
|
||||
// We limit to 16 components by vertex since it's the minimal number supported by the GPU
|
||||
VertexComponent_InstanceData0,
|
||||
VertexComponent_InstanceData1,
|
||||
VertexComponent_InstanceData2,
|
||||
@@ -398,7 +374,7 @@ namespace Nz
|
||||
|
||||
enum VertexLayout
|
||||
{
|
||||
// Déclarations destinées au rendu
|
||||
// Declarations meant for the rendering
|
||||
VertexLayout_XY,
|
||||
VertexLayout_XY_Color,
|
||||
VertexLayout_XY_UV,
|
||||
@@ -411,57 +387,11 @@ namespace Nz
|
||||
VertexLayout_XYZ_Normal_UV_Tangent_Skinning,
|
||||
VertexLayout_XYZ_UV,
|
||||
|
||||
// Déclarations destinées à l'instancing
|
||||
// Declarations meant for the instancing
|
||||
VertexLayout_Matrix4,
|
||||
|
||||
VertexLayout_Max = VertexLayout_Matrix4
|
||||
};
|
||||
|
||||
enum WindowEventType
|
||||
{
|
||||
WindowEventType_GainedFocus,
|
||||
WindowEventType_LostFocus,
|
||||
WindowEventType_KeyPressed,
|
||||
WindowEventType_KeyReleased,
|
||||
WindowEventType_MouseButtonDoubleClicked,
|
||||
WindowEventType_MouseButtonPressed,
|
||||
WindowEventType_MouseButtonReleased,
|
||||
WindowEventType_MouseEntered,
|
||||
WindowEventType_MouseLeft,
|
||||
WindowEventType_MouseMoved,
|
||||
WindowEventType_MouseWheelMoved,
|
||||
WindowEventType_Moved,
|
||||
WindowEventType_Quit,
|
||||
WindowEventType_Resized,
|
||||
WindowEventType_TextEntered,
|
||||
|
||||
WindowEventType_Max = WindowEventType_TextEntered
|
||||
};
|
||||
|
||||
enum WindowStyle
|
||||
{
|
||||
WindowStyle_None, ///< Window has no border nor titlebar.
|
||||
WindowStyle_Fullscreen, ///< At the window creation, the OS tries to set it in fullscreen.
|
||||
|
||||
WindowStyle_Closable, ///< Allows the window to be closed by a button in the titlebar, generating a Quit event.
|
||||
WindowStyle_Resizable, ///< Allows the window to be resized by dragging its corners or by a button of the titlebar.
|
||||
WindowStyle_Titlebar, ///< Adds a titlebar to the window, this option is automatically enabled if buttons of the titlebar are enabled.
|
||||
|
||||
WindowStyle_Threaded, ///< Runs the window into a thread, allowing the application to keep updating while resizing/dragging the window.
|
||||
|
||||
WindowStyle_Max = WindowStyle_Threaded
|
||||
};
|
||||
|
||||
template<>
|
||||
struct EnumAsFlags<WindowStyle>
|
||||
{
|
||||
static constexpr bool value = true;
|
||||
static constexpr int max = WindowStyle_Max;
|
||||
};
|
||||
|
||||
using WindowStyleFlags = Flags<WindowStyle>;
|
||||
|
||||
constexpr WindowStyleFlags WindowStyle_Default = WindowStyle_Closable | WindowStyle_Resizable | WindowStyle_Titlebar;
|
||||
}
|
||||
|
||||
#endif // NAZARA_ENUMS_UTILITY_HPP
|
||||
|
||||
@@ -1,121 +0,0 @@
|
||||
// Copyright (C) 2017 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine - Utility module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
// Interface inspirée de la SFML par Laurent Gomila
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_EVENT_HPP
|
||||
#define NAZARA_EVENT_HPP
|
||||
|
||||
#include <Nazara/Utility/Enums.hpp>
|
||||
#include <Nazara/Utility/Keyboard.hpp>
|
||||
#include <Nazara/Utility/Mouse.hpp>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
struct WindowEvent
|
||||
{
|
||||
// Utilisé par:
|
||||
// -WindowEventType_KeyPressed
|
||||
// -WindowEventType_KeyReleased
|
||||
struct KeyEvent
|
||||
{
|
||||
Keyboard::Key code;
|
||||
bool alt;
|
||||
bool control;
|
||||
bool repeated;
|
||||
bool shift;
|
||||
bool system;
|
||||
};
|
||||
|
||||
// Utilisé par:
|
||||
// -WindowEventType_MouseButtonDoubleClicked
|
||||
// -WindowEventType_MouseButtonPressed
|
||||
struct MouseButtonEvent
|
||||
{
|
||||
Mouse::Button button;
|
||||
unsigned int x;
|
||||
unsigned int y;
|
||||
};
|
||||
|
||||
// Utilisé par:
|
||||
// -WindowEventType_MouseMoved
|
||||
struct MouseMoveEvent
|
||||
{
|
||||
int deltaX;
|
||||
int deltaY;
|
||||
unsigned int x;
|
||||
unsigned int y;
|
||||
};
|
||||
|
||||
// Utilisé par:
|
||||
// -WindowEventType_MouseWheelMoved
|
||||
struct MouseWheelEvent
|
||||
{
|
||||
float delta;
|
||||
};
|
||||
|
||||
// Utilisé par:
|
||||
// -WindowEventType_Moved
|
||||
struct PositionEvent
|
||||
{
|
||||
int x;
|
||||
int y;
|
||||
};
|
||||
|
||||
// Utilisé par:
|
||||
// -WindowEventType_Resized
|
||||
struct SizeEvent
|
||||
{
|
||||
unsigned int height;
|
||||
unsigned int width;
|
||||
};
|
||||
|
||||
// Utilisé par:
|
||||
// -WindowEventType_TextEntered
|
||||
struct TextEvent
|
||||
{
|
||||
bool repeated;
|
||||
char32_t character;
|
||||
};
|
||||
|
||||
WindowEventType type;
|
||||
|
||||
union
|
||||
{
|
||||
// Utilisé par:
|
||||
// -WindowEventType_KeyPressed
|
||||
// -WindowEventType_KeyReleased
|
||||
KeyEvent key;
|
||||
|
||||
// Utilisé par:
|
||||
// -WindowEventType_MouseButtonDoubleClicked
|
||||
// -WindowEventType_MouseButtonPressed
|
||||
MouseButtonEvent mouseButton;
|
||||
|
||||
// Utilisé par:
|
||||
// -WindowEventType_MouseMoved
|
||||
MouseMoveEvent mouseMove;
|
||||
|
||||
// Utilisé par:
|
||||
// -WindowEventType_MouseWheelMoved
|
||||
MouseWheelEvent mouseWheel;
|
||||
|
||||
// Utilisé par:
|
||||
// -WindowEventType_Moved
|
||||
PositionEvent position;
|
||||
|
||||
// Utilisé par:
|
||||
// -WindowEventType_Resized
|
||||
SizeEvent size;
|
||||
|
||||
// Utilisé par:
|
||||
// -WindowEventType_TextEntered
|
||||
TextEvent text;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
#endif // NAZARA_EVENT_HPP
|
||||
@@ -1,57 +0,0 @@
|
||||
// Copyright (C) 2017 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine - Utility module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_EVENTHANDLER_HPP
|
||||
#define NAZARA_EVENTHANDLER_HPP
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Core/HandledObject.hpp>
|
||||
#include <Nazara/Core/ObjectHandle.hpp>
|
||||
#include <Nazara/Core/Signal.hpp>
|
||||
#include <Nazara/Utility/Config.hpp>
|
||||
#include <Nazara/Utility/Event.hpp>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
class EventHandler;
|
||||
|
||||
using EventHandlerHandle = ObjectHandle<EventHandler>;
|
||||
|
||||
class EventHandler : public HandledObject<EventHandler>
|
||||
{
|
||||
public:
|
||||
EventHandler() = default;
|
||||
explicit EventHandler(const EventHandler&);
|
||||
EventHandler(EventHandler&&) = default;
|
||||
~EventHandler() = default;
|
||||
|
||||
inline void Dispatch(const WindowEvent& event);
|
||||
|
||||
EventHandler& operator=(const EventHandler&) = delete;
|
||||
EventHandler& operator=(EventHandler&&) = default;
|
||||
|
||||
NazaraSignal(OnEvent, const EventHandler* /*eventHandler*/, const WindowEvent& /*event*/);
|
||||
NazaraSignal(OnGainedFocus, const EventHandler* /*eventHandler*/);
|
||||
NazaraSignal(OnLostFocus, const EventHandler* /*eventHandler*/);
|
||||
NazaraSignal(OnKeyPressed, const EventHandler* /*eventHandler*/, const WindowEvent::KeyEvent& /*event*/);
|
||||
NazaraSignal(OnKeyReleased, const EventHandler* /*eventHandler*/, const WindowEvent::KeyEvent& /*event*/);
|
||||
NazaraSignal(OnMouseButtonDoubleClicked, const EventHandler* /*eventHandler*/, const WindowEvent::MouseButtonEvent& /*event*/);
|
||||
NazaraSignal(OnMouseButtonPressed, const EventHandler* /*eventHandler*/, const WindowEvent::MouseButtonEvent& /*event*/);
|
||||
NazaraSignal(OnMouseButtonReleased, const EventHandler* /*eventHandler*/, const WindowEvent::MouseButtonEvent& /*event*/);
|
||||
NazaraSignal(OnMouseEntered, const EventHandler* /*eventHandler*/);
|
||||
NazaraSignal(OnMouseLeft, const EventHandler* /*eventHandler*/);
|
||||
NazaraSignal(OnMouseMoved, const EventHandler* /*eventHandler*/, const WindowEvent::MouseMoveEvent& /*event*/);
|
||||
NazaraSignal(OnMouseWheelMoved, const EventHandler* /*eventHandler*/, const WindowEvent::MouseWheelEvent& /*event*/);
|
||||
NazaraSignal(OnMoved, const EventHandler* /*eventHandler*/, const WindowEvent::PositionEvent& /*event*/);
|
||||
NazaraSignal(OnQuit, const EventHandler* /*eventHandler*/);
|
||||
NazaraSignal(OnResized, const EventHandler* /*eventHandler*/, const WindowEvent::SizeEvent& /*event*/);
|
||||
NazaraSignal(OnTextEntered, const EventHandler* /*eventHandler*/, const WindowEvent::TextEvent& /*event*/);
|
||||
};
|
||||
}
|
||||
|
||||
#include <Nazara/Utility/EventHandler.inl>
|
||||
|
||||
#endif // NAZARA_EVENTHANDLER_HPP
|
||||
@@ -1,85 +0,0 @@
|
||||
// Copyright (C) 2017 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine - Utility module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#include <Nazara/Utility/EventHandler.hpp>
|
||||
#include <memory>
|
||||
#include <Nazara/Utility/Debug.hpp>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
inline EventHandler::EventHandler(const EventHandler& other) :
|
||||
HandledObject(other)
|
||||
{
|
||||
}
|
||||
|
||||
inline void EventHandler::Dispatch(const WindowEvent& event)
|
||||
{
|
||||
OnEvent(this, event);
|
||||
|
||||
switch (event.type)
|
||||
{
|
||||
case WindowEventType_GainedFocus:
|
||||
OnGainedFocus(this);
|
||||
break;
|
||||
|
||||
case WindowEventType_KeyPressed:
|
||||
OnKeyPressed(this, event.key);
|
||||
break;
|
||||
|
||||
case WindowEventType_KeyReleased:
|
||||
OnKeyReleased(this, event.key);
|
||||
break;
|
||||
|
||||
case WindowEventType_LostFocus:
|
||||
OnLostFocus(this);
|
||||
break;
|
||||
|
||||
case WindowEventType_MouseButtonDoubleClicked:
|
||||
OnMouseButtonDoubleClicked(this, event.mouseButton);
|
||||
break;
|
||||
|
||||
case WindowEventType_MouseButtonPressed:
|
||||
OnMouseButtonPressed(this, event.mouseButton);
|
||||
break;
|
||||
|
||||
case WindowEventType_MouseButtonReleased:
|
||||
OnMouseButtonReleased(this, event.mouseButton);
|
||||
break;
|
||||
|
||||
case WindowEventType_MouseEntered:
|
||||
OnMouseEntered(this);
|
||||
break;
|
||||
|
||||
case WindowEventType_MouseLeft:
|
||||
OnMouseLeft(this);
|
||||
break;
|
||||
|
||||
case WindowEventType_MouseMoved:
|
||||
OnMouseMoved(this, event.mouseMove);
|
||||
break;
|
||||
|
||||
case WindowEventType_MouseWheelMoved:
|
||||
OnMouseWheelMoved(this, event.mouseWheel);
|
||||
break;
|
||||
|
||||
case WindowEventType_Moved:
|
||||
OnMoved(this, event.position);
|
||||
break;
|
||||
|
||||
case WindowEventType_Quit:
|
||||
OnQuit(this);
|
||||
break;
|
||||
|
||||
case WindowEventType_Resized:
|
||||
OnResized(this, event.size);
|
||||
break;
|
||||
|
||||
case WindowEventType_TextEntered:
|
||||
OnTextEntered(this, event.text);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#include <Nazara/Utility/DebugOff.hpp>
|
||||
@@ -1,47 +0,0 @@
|
||||
// Copyright (C) 2017 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine - Utility module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_ICON_HPP
|
||||
#define NAZARA_ICON_HPP
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Core/ObjectRef.hpp>
|
||||
#include <Nazara/Math/Vector2.hpp>
|
||||
#include <Nazara/Utility/Config.hpp>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
class Image;
|
||||
class IconImpl;
|
||||
|
||||
class Icon;
|
||||
|
||||
using IconRef = ObjectRef<Icon>;
|
||||
|
||||
class NAZARA_UTILITY_API Icon : public RefCounted
|
||||
{
|
||||
friend class WindowImpl;
|
||||
|
||||
public:
|
||||
inline Icon();
|
||||
inline explicit Icon(const Image& icon);
|
||||
inline ~Icon();
|
||||
|
||||
bool Create(const Image& icon);
|
||||
void Destroy();
|
||||
|
||||
inline bool IsValid() const;
|
||||
|
||||
template<typename... Args> static IconRef New(Args&&... args);
|
||||
|
||||
private:
|
||||
IconImpl* m_impl;
|
||||
};
|
||||
}
|
||||
|
||||
#include <Nazara/Utility/Icon.inl>
|
||||
|
||||
#endif // NAZARA_ICON_HPP
|
||||
@@ -1,42 +0,0 @@
|
||||
// Copyright (C) 2017 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine - Utility module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#include <Nazara/Utility/Cursor.hpp>
|
||||
#include <Nazara/Core/ErrorFlags.hpp>
|
||||
#include <Nazara/Utility/Debug.hpp>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
Icon::Icon() :
|
||||
m_impl(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
inline Icon::Icon(const Image& icon)
|
||||
{
|
||||
ErrorFlags flags(ErrorFlag_ThrowException, true);
|
||||
Create(icon);
|
||||
}
|
||||
|
||||
Icon::~Icon()
|
||||
{
|
||||
Destroy();
|
||||
}
|
||||
|
||||
bool Icon::IsValid() const
|
||||
{
|
||||
return m_impl != nullptr;
|
||||
}
|
||||
|
||||
template<typename... Args>
|
||||
IconRef Icon::New(Args&&... args)
|
||||
{
|
||||
std::unique_ptr<Icon> object(new Icon(std::forward<Args>(args)...));
|
||||
object->SetPersistent(false);
|
||||
|
||||
return object.release();
|
||||
}
|
||||
}
|
||||
|
||||
#include <Nazara/Utility/DebugOff.hpp>
|
||||
@@ -1,27 +0,0 @@
|
||||
// Copyright (C) 2017 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine - Utility module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_JOYSTICK_HPP
|
||||
#define NAZARA_JOYSTICK_HPP
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Core/String.hpp>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
class NAZARA_UTILITY_API Joystick
|
||||
{
|
||||
public:
|
||||
Joystick() = delete;
|
||||
~Joystick() = delete;
|
||||
|
||||
static unsigned int GetMaxJoystickCount();
|
||||
|
||||
static void Update();
|
||||
};
|
||||
}
|
||||
|
||||
#endif // NAZARA_JOYSTICK_HPP
|
||||
@@ -1,175 +0,0 @@
|
||||
// Copyright (C) 2017 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine - Utility module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
// Interface inspirée de la SFML par Laurent Gomila
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_KEYBOARD_HPP
|
||||
#define NAZARA_KEYBOARD_HPP
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Core/String.hpp>
|
||||
#include <Nazara/Utility/Config.hpp>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
class NAZARA_UTILITY_API Keyboard
|
||||
{
|
||||
public:
|
||||
enum Key
|
||||
{
|
||||
Undefined = -1,
|
||||
|
||||
// Lettres
|
||||
A,
|
||||
B,
|
||||
C,
|
||||
D,
|
||||
E,
|
||||
F,
|
||||
G,
|
||||
H,
|
||||
I,
|
||||
J,
|
||||
K,
|
||||
L,
|
||||
M,
|
||||
N,
|
||||
O,
|
||||
P,
|
||||
Q,
|
||||
R,
|
||||
S,
|
||||
T,
|
||||
U,
|
||||
V,
|
||||
W,
|
||||
X,
|
||||
Y,
|
||||
Z,
|
||||
|
||||
// Touches de fonction
|
||||
F1,
|
||||
F2,
|
||||
F3,
|
||||
F4,
|
||||
F5,
|
||||
F6,
|
||||
F7,
|
||||
F8,
|
||||
F9,
|
||||
F10,
|
||||
F11,
|
||||
F12,
|
||||
F13,
|
||||
F14,
|
||||
F15,
|
||||
|
||||
// Flèches directionnelles
|
||||
Down,
|
||||
Left,
|
||||
Right,
|
||||
Up,
|
||||
|
||||
// Pavé numérique
|
||||
Add,
|
||||
Decimal,
|
||||
Divide,
|
||||
Multiply,
|
||||
Numpad0,
|
||||
Numpad1,
|
||||
Numpad2,
|
||||
Numpad3,
|
||||
Numpad4,
|
||||
Numpad5,
|
||||
Numpad6,
|
||||
Numpad7,
|
||||
Numpad8,
|
||||
Numpad9,
|
||||
Subtract,
|
||||
|
||||
// Divers
|
||||
Backslash,
|
||||
Backspace,
|
||||
Clear,
|
||||
Comma,
|
||||
Dash,
|
||||
Delete,
|
||||
End,
|
||||
Equal,
|
||||
Escape,
|
||||
Home,
|
||||
Insert,
|
||||
LAlt,
|
||||
LBracket,
|
||||
LControl,
|
||||
LShift,
|
||||
LSystem,
|
||||
Num0,
|
||||
Num1,
|
||||
Num2,
|
||||
Num3,
|
||||
Num4,
|
||||
Num5,
|
||||
Num6,
|
||||
Num7,
|
||||
Num8,
|
||||
Num9,
|
||||
PageDown,
|
||||
PageUp,
|
||||
Pause,
|
||||
Period,
|
||||
Print,
|
||||
PrintScreen,
|
||||
Quote,
|
||||
RAlt,
|
||||
RBracket,
|
||||
RControl,
|
||||
Return,
|
||||
RShift,
|
||||
RSystem,
|
||||
Semicolon,
|
||||
Slash,
|
||||
Space,
|
||||
Tab,
|
||||
Tilde,
|
||||
|
||||
// Touches navigateur
|
||||
Browser_Back,
|
||||
Browser_Favorites,
|
||||
Browser_Forward,
|
||||
Browser_Home,
|
||||
Browser_Refresh,
|
||||
Browser_Search,
|
||||
Browser_Stop,
|
||||
|
||||
// Touches de contrôle de lecture
|
||||
Media_Next,
|
||||
Media_Play,
|
||||
Media_Previous,
|
||||
Media_Stop,
|
||||
|
||||
// Touches de contrôle du volume
|
||||
Volume_Down,
|
||||
Volume_Mute,
|
||||
Volume_Up,
|
||||
|
||||
// Touches à verrouillage
|
||||
CapsLock,
|
||||
NumLock,
|
||||
ScrollLock,
|
||||
|
||||
Count
|
||||
};
|
||||
|
||||
Keyboard() = delete;
|
||||
~Keyboard() = delete;
|
||||
|
||||
static String GetKeyName(Key key);
|
||||
static bool IsKeyPressed(Key key);
|
||||
};
|
||||
}
|
||||
|
||||
#endif // NAZARA_KEYBOARD_HPP
|
||||
@@ -1,47 +0,0 @@
|
||||
// Copyright (C) 2017 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine - Utility module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
// Interface inspirée de la SFML par Laurent Gomila
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_MOUSE_HPP
|
||||
#define NAZARA_MOUSE_HPP
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Math/Vector2.hpp>
|
||||
#include <Nazara/Utility/Config.hpp>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
class Window;
|
||||
|
||||
class NAZARA_UTILITY_API Mouse
|
||||
{
|
||||
public:
|
||||
enum Button
|
||||
{
|
||||
Left,
|
||||
Middle,
|
||||
Right,
|
||||
XButton1,
|
||||
XButton2,
|
||||
|
||||
Max = XButton2
|
||||
};
|
||||
|
||||
Mouse() = delete;
|
||||
~Mouse() = delete;
|
||||
|
||||
static Vector2i GetPosition();
|
||||
static Vector2i GetPosition(const Window& relativeTo);
|
||||
static bool IsButtonPressed(Button button);
|
||||
static void SetPosition(const Vector2i& position);
|
||||
static void SetPosition(const Vector2i& position, const Window& relativeTo, bool ignoreEvent = true);
|
||||
static void SetPosition(int x, int y);
|
||||
static void SetPosition(int x, int y, const Window& relativeTo, bool ignoreEvent = true);
|
||||
};
|
||||
}
|
||||
|
||||
#endif // NAZARA_MOUSE_HPP
|
||||
@@ -9,7 +9,6 @@
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Core/Initializer.hpp>
|
||||
#include <Nazara/Core/ParameterList.hpp>
|
||||
#include <Nazara/Utility/Config.hpp>
|
||||
#include <Nazara/Utility/Enums.hpp>
|
||||
|
||||
@@ -25,15 +24,12 @@ namespace Nz
|
||||
|
||||
static bool IsInitialized();
|
||||
|
||||
static void SetParameters(const ParameterList& parameters);
|
||||
|
||||
static void Uninitialize();
|
||||
|
||||
static unsigned int ComponentCount[ComponentType_Max+1];
|
||||
static std::size_t ComponentStride[ComponentType_Max+1];
|
||||
|
||||
private:
|
||||
static ParameterList s_initializationParameters;
|
||||
static unsigned int s_moduleReferenceCounter;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,43 +0,0 @@
|
||||
// Copyright (C) 2017 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine - Utility module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
// Interface inspirée de la SFML par Laurent Gomila
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_VIDEOMODE_HPP
|
||||
#define NAZARA_VIDEOMODE_HPP
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Utility/Config.hpp>
|
||||
#include <vector>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
class NAZARA_UTILITY_API VideoMode
|
||||
{
|
||||
public:
|
||||
VideoMode();
|
||||
VideoMode(unsigned int w, unsigned int h);
|
||||
VideoMode(unsigned int w, unsigned int h, UInt8 bpp);
|
||||
|
||||
bool IsFullscreenValid() const;
|
||||
|
||||
UInt8 bitsPerPixel;
|
||||
unsigned int height;
|
||||
unsigned int width;
|
||||
|
||||
static VideoMode GetDesktopMode();
|
||||
static const std::vector<VideoMode>& GetFullscreenModes();
|
||||
};
|
||||
|
||||
bool operator==(const VideoMode& left, const VideoMode& right);
|
||||
bool operator!=(const VideoMode& left, const VideoMode& right);
|
||||
bool operator<(const VideoMode& left, const VideoMode& right);
|
||||
bool operator<=(const VideoMode& left, const VideoMode& right);
|
||||
bool operator>(const VideoMode& left, const VideoMode& right);
|
||||
bool operator>=(const VideoMode& left, const VideoMode& right);
|
||||
}
|
||||
|
||||
#endif // NAZARA_VIDEOMODE_HPP
|
||||
@@ -1,143 +0,0 @@
|
||||
// Copyright (C) 2017 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine - Utility module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
// Interface inspirée de la SFML par Laurent Gomila
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_WINDOW_HPP
|
||||
#define NAZARA_WINDOW_HPP
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Core/ConditionVariable.hpp>
|
||||
#include <Nazara/Core/Mutex.hpp>
|
||||
#include <Nazara/Core/String.hpp>
|
||||
#include <Nazara/Math/Vector2.hpp>
|
||||
#include <Nazara/Utility/Config.hpp>
|
||||
#include <Nazara/Utility/Cursor.hpp>
|
||||
#include <Nazara/Utility/CursorController.hpp>
|
||||
#include <Nazara/Utility/Enums.hpp>
|
||||
#include <Nazara/Utility/EventHandler.hpp>
|
||||
#include <Nazara/Utility/Icon.hpp>
|
||||
#include <Nazara/Utility/VideoMode.hpp>
|
||||
#include <Nazara/Utility/WindowHandle.hpp>
|
||||
#include <queue>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
class Image;
|
||||
class WindowImpl;
|
||||
|
||||
class NAZARA_UTILITY_API Window
|
||||
{
|
||||
friend WindowImpl;
|
||||
friend class Mouse;
|
||||
friend class Utility;
|
||||
|
||||
public:
|
||||
Window();
|
||||
inline Window(VideoMode mode, const String& title, WindowStyleFlags style = WindowStyle_Default);
|
||||
inline explicit Window(WindowHandle handle);
|
||||
Window(const Window&) = delete;
|
||||
inline Window(Window&& window) noexcept;
|
||||
virtual ~Window();
|
||||
|
||||
inline void Close();
|
||||
|
||||
bool Create(VideoMode mode, const String& title, WindowStyleFlags style = WindowStyle_Default);
|
||||
bool Create(WindowHandle handle);
|
||||
|
||||
void Destroy();
|
||||
|
||||
inline void EnableCloseOnQuit(bool closeOnQuit);
|
||||
|
||||
NAZARA_DEPRECATED("Event pooling/waiting is deprecated, please use the EventHandler system")
|
||||
inline void EnableEventPolling(bool enable);
|
||||
|
||||
void EnableKeyRepeat(bool enable);
|
||||
void EnableSmoothScrolling(bool enable);
|
||||
|
||||
inline const CursorRef& GetCursor() const;
|
||||
inline CursorController& GetCursorController();
|
||||
inline EventHandler& GetEventHandler();
|
||||
WindowHandle GetHandle() const;
|
||||
unsigned int GetHeight() const;
|
||||
Vector2i GetPosition() const;
|
||||
Vector2ui GetSize() const;
|
||||
WindowStyleFlags GetStyle() const;
|
||||
String GetTitle() const;
|
||||
unsigned int GetWidth() const;
|
||||
|
||||
bool HasFocus() const;
|
||||
|
||||
bool IsMinimized() const;
|
||||
inline bool IsOpen(bool checkClosed = true);
|
||||
inline bool IsOpen() const;
|
||||
inline bool IsValid() const;
|
||||
bool IsVisible() const;
|
||||
|
||||
NAZARA_DEPRECATED("Event pooling/waiting is deprecated, please use the EventHandler system")
|
||||
bool PollEvent(WindowEvent* event);
|
||||
|
||||
void ProcessEvents(bool block = false);
|
||||
|
||||
void SetCursor(CursorRef cursor);
|
||||
inline void SetCursor(SystemCursor systemCursor);
|
||||
void SetEventListener(bool listener);
|
||||
void SetFocus();
|
||||
void SetIcon(IconRef icon);
|
||||
void SetMaximumSize(const Vector2i& maxSize);
|
||||
void SetMaximumSize(int width, int height);
|
||||
void SetMinimumSize(const Vector2i& minSize);
|
||||
void SetMinimumSize(int width, int height);
|
||||
void SetPosition(const Vector2i& position);
|
||||
void SetPosition(int x, int y);
|
||||
void SetSize(const Vector2i& size);
|
||||
void SetSize(unsigned int width, unsigned int height);
|
||||
void SetStayOnTop(bool stayOnTop);
|
||||
void SetTitle(const String& title);
|
||||
void SetVisible(bool visible);
|
||||
|
||||
NAZARA_DEPRECATED("Event pooling/waiting is deprecated, please use the EventHandler system")
|
||||
bool WaitEvent(WindowEvent* event);
|
||||
|
||||
Window& operator=(const Window&) = delete;
|
||||
inline Window& operator=(Window&& window);
|
||||
|
||||
protected:
|
||||
virtual bool OnWindowCreated();
|
||||
virtual void OnWindowDestroy();
|
||||
virtual void OnWindowResized();
|
||||
|
||||
WindowImpl* m_impl;
|
||||
|
||||
private:
|
||||
void IgnoreNextMouseEvent(int mouseX, int mouseY) const;
|
||||
inline void HandleEvent(const WindowEvent& event);
|
||||
inline void PushEvent(const WindowEvent& event);
|
||||
|
||||
static bool Initialize();
|
||||
static void Uninitialize();
|
||||
|
||||
std::queue<WindowEvent> m_events;
|
||||
std::vector<WindowEvent> m_pendingEvents;
|
||||
ConditionVariable m_eventCondition;
|
||||
CursorController m_cursorController;
|
||||
CursorRef m_cursor;
|
||||
EventHandler m_eventHandler;
|
||||
IconRef m_icon;
|
||||
Mutex m_eventMutex;
|
||||
Mutex m_eventConditionMutex;
|
||||
bool m_asyncWindow;
|
||||
bool m_closed;
|
||||
bool m_closeOnQuit;
|
||||
bool m_eventPolling;
|
||||
bool m_ownsWindow;
|
||||
bool m_waitForEvent;
|
||||
};
|
||||
}
|
||||
|
||||
#include <Nazara/Utility/Window.inl>
|
||||
|
||||
#endif // NAZARA_WINDOW_HPP
|
||||
@@ -1,176 +0,0 @@
|
||||
// Copyright (C) 2017 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine - Core module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#include <Nazara/Utility/Window.hpp>
|
||||
#include <Nazara/Core/ErrorFlags.hpp>
|
||||
#include <Nazara/Core/LockGuard.hpp>
|
||||
#include <Nazara/Utility/Debug.hpp>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
/*!
|
||||
* \class Nz::Window
|
||||
*/
|
||||
|
||||
inline Window::Window(VideoMode mode, const String& title, WindowStyleFlags style) :
|
||||
Window()
|
||||
{
|
||||
ErrorFlags flags(ErrorFlag_ThrowException, true);
|
||||
Create(mode, title, style);
|
||||
}
|
||||
|
||||
inline Window::Window(WindowHandle handle) :
|
||||
Window()
|
||||
{
|
||||
ErrorFlags flags(ErrorFlag_ThrowException, true);
|
||||
Create(handle);
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Constructs a Window object by moving another one
|
||||
*/
|
||||
inline Window::Window(Window&& window) noexcept :
|
||||
m_impl(window.m_impl),
|
||||
m_events(std::move(window.m_events)),
|
||||
m_pendingEvents(std::move(window.m_pendingEvents)),
|
||||
m_eventCondition(std::move(window.m_eventCondition)),
|
||||
m_eventHandler(std::move(window.m_eventHandler)),
|
||||
m_eventMutex(std::move(window.m_eventMutex)),
|
||||
m_eventConditionMutex(std::move(window.m_eventConditionMutex)),
|
||||
m_closed(window.m_closed),
|
||||
m_closeOnQuit(window.m_closeOnQuit),
|
||||
m_eventPolling(window.m_eventPolling),
|
||||
m_ownsWindow(window.m_ownsWindow),
|
||||
m_waitForEvent(window.m_waitForEvent)
|
||||
{
|
||||
window.m_impl = nullptr;
|
||||
}
|
||||
|
||||
inline void Window::Close()
|
||||
{
|
||||
m_closed = true; // The window will be closed at the next non-const IsOpen() call
|
||||
}
|
||||
|
||||
inline void Window::EnableCloseOnQuit(bool closeOnQuit)
|
||||
{
|
||||
m_closeOnQuit = closeOnQuit;
|
||||
}
|
||||
|
||||
inline void Window::EnableEventPolling(bool enable)
|
||||
{
|
||||
m_eventPolling = enable;
|
||||
if (!m_eventPolling)
|
||||
{
|
||||
while (!m_events.empty())
|
||||
m_events.pop();
|
||||
}
|
||||
}
|
||||
|
||||
inline const CursorRef& Window::GetCursor() const
|
||||
{
|
||||
return m_cursor;
|
||||
}
|
||||
|
||||
inline CursorController& Nz::Window::GetCursorController()
|
||||
{
|
||||
return m_cursorController;
|
||||
}
|
||||
|
||||
inline EventHandler& Nz::Window::GetEventHandler()
|
||||
{
|
||||
return m_eventHandler;
|
||||
}
|
||||
|
||||
inline bool Window::IsOpen(bool checkClosed)
|
||||
{
|
||||
if (!m_impl)
|
||||
return false;
|
||||
|
||||
if (checkClosed && m_closed)
|
||||
{
|
||||
Destroy();
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
inline bool Window::IsOpen() const
|
||||
{
|
||||
return m_impl != nullptr;
|
||||
}
|
||||
|
||||
inline bool Window::IsValid() const
|
||||
{
|
||||
return m_impl != nullptr;
|
||||
}
|
||||
|
||||
inline void Window::SetCursor(SystemCursor systemCursor)
|
||||
{
|
||||
SetCursor(Cursor::Get(systemCursor));
|
||||
}
|
||||
|
||||
inline void Window::HandleEvent(const WindowEvent& event)
|
||||
{
|
||||
if (m_eventPolling)
|
||||
m_events.push(event);
|
||||
|
||||
m_eventHandler.Dispatch(event);
|
||||
|
||||
if (event.type == WindowEventType_Resized)
|
||||
OnWindowResized();
|
||||
|
||||
if (event.type == WindowEventType_Quit && m_closeOnQuit)
|
||||
Close();
|
||||
}
|
||||
|
||||
inline void Window::PushEvent(const WindowEvent& event)
|
||||
{
|
||||
if (!m_asyncWindow)
|
||||
HandleEvent(event);
|
||||
else
|
||||
{
|
||||
{
|
||||
LockGuard eventLock(m_eventMutex);
|
||||
|
||||
m_pendingEvents.push_back(event);
|
||||
}
|
||||
|
||||
if (m_waitForEvent)
|
||||
{
|
||||
m_eventConditionMutex.Lock();
|
||||
m_eventCondition.Signal();
|
||||
m_eventConditionMutex.Unlock();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Moves a window to another window object
|
||||
* \return A reference to the object
|
||||
*/
|
||||
inline Window& Window::operator=(Window&& window)
|
||||
{
|
||||
Destroy();
|
||||
|
||||
m_closed = window.m_closed;
|
||||
m_closeOnQuit = window.m_closeOnQuit;
|
||||
m_eventCondition = std::move(window.m_eventCondition);
|
||||
m_eventConditionMutex = std::move(window.m_eventConditionMutex);
|
||||
m_eventHandler = std::move(window.m_eventHandler);
|
||||
m_eventMutex = std::move(window.m_eventMutex);
|
||||
m_eventPolling = window.m_eventPolling;
|
||||
m_impl = window.m_impl;
|
||||
m_events = std::move(window.m_events);
|
||||
m_pendingEvents = std::move(window.m_pendingEvents);
|
||||
m_ownsWindow = window.m_ownsWindow;
|
||||
m_waitForEvent = window.m_waitForEvent;
|
||||
|
||||
window.m_impl = nullptr;
|
||||
|
||||
return *this;
|
||||
}
|
||||
}
|
||||
|
||||
#include <Nazara/Utility/DebugOff.hpp>
|
||||
@@ -1,28 +0,0 @@
|
||||
// Copyright (C) 2017 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine - Utility module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_WINDOWHANDLE_HPP
|
||||
#define NAZARA_WINDOWHANDLE_HPP
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#if defined(NAZARA_PLATFORM_X11)
|
||||
#include <xcb/xcb.h>
|
||||
#endif
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
#if defined(NAZARA_PLATFORM_WINDOWS)
|
||||
// http://msdn.microsoft.com/en-us/library/aa383751(v=vs.85).aspx
|
||||
typedef void* WindowHandle;
|
||||
#elif defined(NAZARA_PLATFORM_X11)
|
||||
// http://en.wikipedia.org/wiki/Xlib#Data_types
|
||||
using WindowHandle = xcb_window_t;
|
||||
#else
|
||||
#error Lack of implementation: WindowHandle
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif // NAZARA_WINDOWHANDLE_HPP
|
||||
Reference in New Issue
Block a user