Merge branch 'master' into vulkan
This commit is contained in:
@@ -51,6 +51,7 @@ namespace Nz
|
||||
WindowEventType_Moved,
|
||||
WindowEventType_Quit,
|
||||
WindowEventType_Resized,
|
||||
WindowEventType_TextEdited,
|
||||
WindowEventType_TextEntered,
|
||||
|
||||
WindowEventType_Max = WindowEventType_TextEntered
|
||||
|
||||
@@ -9,6 +9,8 @@
|
||||
#ifndef NAZARA_EVENT_HPP
|
||||
#define NAZARA_EVENT_HPP
|
||||
|
||||
#include <array>
|
||||
|
||||
#include <Nazara/Platform/Enums.hpp>
|
||||
#include <Nazara/Platform/Keyboard.hpp>
|
||||
#include <Nazara/Platform/Mouse.hpp>
|
||||
@@ -22,7 +24,8 @@ namespace Nz
|
||||
// -WindowEventType_KeyReleased
|
||||
struct KeyEvent
|
||||
{
|
||||
Keyboard::Key code;
|
||||
Keyboard::Scancode scancode;
|
||||
Keyboard::VKey virtualKey;
|
||||
bool alt;
|
||||
bool control;
|
||||
bool repeated;
|
||||
@@ -83,6 +86,14 @@ namespace Nz
|
||||
char32_t character;
|
||||
};
|
||||
|
||||
// Used by:
|
||||
// -WindowEventType_TextEdited
|
||||
struct EditEvent
|
||||
{
|
||||
int length;
|
||||
std::array<char, 32> text;
|
||||
};
|
||||
|
||||
WindowEventType type;
|
||||
|
||||
union
|
||||
@@ -116,6 +127,10 @@ namespace Nz
|
||||
// Used by:
|
||||
// -WindowEventType_TextEntered
|
||||
TextEvent text;
|
||||
|
||||
// Used by:
|
||||
// -WindowEventType_TextEntered
|
||||
EditEvent edit;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
@@ -49,6 +49,7 @@ namespace Nz
|
||||
NazaraSignal(OnQuit, const EventHandler* /*eventHandler*/);
|
||||
NazaraSignal(OnResized, const EventHandler* /*eventHandler*/, const WindowEvent::SizeEvent& /*event*/);
|
||||
NazaraSignal(OnTextEntered, const EventHandler* /*eventHandler*/, const WindowEvent::TextEvent& /*event*/);
|
||||
NazaraSignal(OnTextEdited, const EventHandler* /*eventHandler*/, const WindowEvent::EditEvent& /*event*/);
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -78,6 +78,10 @@ namespace Nz
|
||||
case WindowEventType_TextEntered:
|
||||
OnTextEntered(this, event.text);
|
||||
break;
|
||||
|
||||
case WindowEventType_TextEdited:
|
||||
OnTextEdited(this, event.edit);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ namespace Nz
|
||||
class NAZARA_PLATFORM_API Keyboard
|
||||
{
|
||||
public:
|
||||
enum Key
|
||||
enum class Scancode
|
||||
{
|
||||
Undefined = -1,
|
||||
|
||||
@@ -78,6 +78,7 @@ namespace Nz
|
||||
Decimal,
|
||||
Divide,
|
||||
Multiply,
|
||||
NumpadReturn,
|
||||
Numpad0,
|
||||
Numpad1,
|
||||
Numpad2,
|
||||
@@ -135,6 +136,8 @@ namespace Nz
|
||||
Space,
|
||||
Tab,
|
||||
Tilde,
|
||||
Menu,
|
||||
ISOBackslash102,
|
||||
|
||||
// Navigator keys
|
||||
Browser_Back,
|
||||
@@ -161,14 +164,169 @@ namespace Nz
|
||||
NumLock,
|
||||
ScrollLock,
|
||||
|
||||
Count
|
||||
Max = ScrollLock
|
||||
};
|
||||
|
||||
enum class VKey
|
||||
{
|
||||
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,
|
||||
|
||||
// Functional keys
|
||||
F1,
|
||||
F2,
|
||||
F3,
|
||||
F4,
|
||||
F5,
|
||||
F6,
|
||||
F7,
|
||||
F8,
|
||||
F9,
|
||||
F10,
|
||||
F11,
|
||||
F12,
|
||||
F13,
|
||||
F14,
|
||||
F15,
|
||||
|
||||
// Directional keys
|
||||
Down,
|
||||
Left,
|
||||
Right,
|
||||
Up,
|
||||
|
||||
// Numerical pad
|
||||
Add,
|
||||
Decimal,
|
||||
Divide,
|
||||
Multiply,
|
||||
NumpadReturn,
|
||||
Numpad0,
|
||||
Numpad1,
|
||||
Numpad2,
|
||||
Numpad3,
|
||||
Numpad4,
|
||||
Numpad5,
|
||||
Numpad6,
|
||||
Numpad7,
|
||||
Numpad8,
|
||||
Numpad9,
|
||||
Subtract,
|
||||
|
||||
// Various
|
||||
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,
|
||||
Menu,
|
||||
ISOBackslash102,
|
||||
|
||||
// Navigator keys
|
||||
Browser_Back,
|
||||
Browser_Favorites,
|
||||
Browser_Forward,
|
||||
Browser_Home,
|
||||
Browser_Refresh,
|
||||
Browser_Search,
|
||||
Browser_Stop,
|
||||
|
||||
// Lecture control keys
|
||||
Media_Next,
|
||||
Media_Play,
|
||||
Media_Previous,
|
||||
Media_Stop,
|
||||
|
||||
// Volume control keys
|
||||
Volume_Down,
|
||||
Volume_Mute,
|
||||
Volume_Up,
|
||||
|
||||
// Locking keys
|
||||
CapsLock,
|
||||
NumLock,
|
||||
ScrollLock,
|
||||
|
||||
Max = ScrollLock
|
||||
};
|
||||
|
||||
Keyboard() = delete;
|
||||
~Keyboard() = delete;
|
||||
|
||||
static String GetKeyName(Key key);
|
||||
static bool IsKeyPressed(Key key);
|
||||
static String GetKeyName(Scancode scancode);
|
||||
static String GetKeyName(VKey key);
|
||||
static bool IsKeyPressed(Scancode scancode);
|
||||
static bool IsKeyPressed(VKey key);
|
||||
static void StartTextInput();
|
||||
static void StopTextInput();
|
||||
static Scancode ToScanCode(VKey key);
|
||||
static VKey ToVirtualKey(Scancode key);
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -37,6 +37,7 @@ namespace Nz
|
||||
static Vector2i GetPosition();
|
||||
static Vector2i GetPosition(const Window& relativeTo);
|
||||
static bool IsButtonPressed(Button button);
|
||||
static bool SetRelativeMouseMode(bool relativeMouseMode);
|
||||
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);
|
||||
|
||||
@@ -32,12 +32,12 @@ namespace Nz
|
||||
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);
|
||||
bool NAZARA_PLATFORM_API operator==(const VideoMode& left, const VideoMode& right);
|
||||
bool NAZARA_PLATFORM_API operator!=(const VideoMode& left, const VideoMode& right);
|
||||
bool NAZARA_PLATFORM_API operator<(const VideoMode& left, const VideoMode& right);
|
||||
bool NAZARA_PLATFORM_API operator<=(const VideoMode& left, const VideoMode& right);
|
||||
bool NAZARA_PLATFORM_API operator>(const VideoMode& left, const VideoMode& right);
|
||||
bool NAZARA_PLATFORM_API operator>=(const VideoMode& left, const VideoMode& right);
|
||||
}
|
||||
|
||||
#endif // NAZARA_VIDEOMODE_HPP
|
||||
|
||||
@@ -32,13 +32,14 @@ namespace Nz
|
||||
class NAZARA_PLATFORM_API Window
|
||||
{
|
||||
friend WindowImpl;
|
||||
friend class EventImpl;
|
||||
friend class Mouse;
|
||||
friend class Platform;
|
||||
|
||||
public:
|
||||
Window();
|
||||
inline Window(VideoMode mode, const String& title, WindowStyleFlags style = WindowStyle_Default);
|
||||
inline explicit Window(WindowHandle handle);
|
||||
inline explicit Window(void* handle);
|
||||
Window(const Window&) = delete;
|
||||
Window(Window&& window);
|
||||
virtual ~Window();
|
||||
@@ -46,7 +47,7 @@ namespace Nz
|
||||
inline void Close();
|
||||
|
||||
bool Create(VideoMode mode, const String& title, WindowStyleFlags style = WindowStyle_Default);
|
||||
bool Create(WindowHandle handle);
|
||||
bool Create(void* handle);
|
||||
|
||||
void Destroy();
|
||||
|
||||
@@ -61,10 +62,10 @@ namespace Nz
|
||||
inline const CursorRef& GetCursor() const;
|
||||
inline CursorController& GetCursorController();
|
||||
inline EventHandler& GetEventHandler();
|
||||
WindowHandle GetHandle() const;
|
||||
Vector2i GetPosition() const;
|
||||
Vector2ui GetSize() const;
|
||||
WindowStyleFlags GetStyle() const;
|
||||
WindowHandle GetSystemHandle() const;
|
||||
String GetTitle() const;
|
||||
|
||||
bool HasFocus() const;
|
||||
@@ -106,6 +107,8 @@ namespace Nz
|
||||
Window& operator=(Window&& window);
|
||||
|
||||
protected:
|
||||
void* GetHandle();
|
||||
|
||||
virtual bool OnWindowCreated();
|
||||
virtual void OnWindowDestroy();
|
||||
virtual void OnWindowResized();
|
||||
@@ -116,6 +119,9 @@ namespace Nz
|
||||
void ConnectSlots();
|
||||
void DisconnectSlots();
|
||||
|
||||
inline WindowImpl* GetImpl();
|
||||
inline const WindowImpl* GetImpl() const;
|
||||
|
||||
void IgnoreNextMouseEvent(int mouseX, int mouseY) const;
|
||||
void HandleEvent(const WindowEvent& event);
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ namespace Nz
|
||||
Create(mode, title, style);
|
||||
}
|
||||
|
||||
inline Window::Window(WindowHandle handle) :
|
||||
inline Window::Window(void* handle) :
|
||||
Window()
|
||||
{
|
||||
ErrorFlags flags(ErrorFlag_ThrowException, true);
|
||||
@@ -109,6 +109,16 @@ namespace Nz
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
inline WindowImpl* Window::GetImpl()
|
||||
{
|
||||
return m_impl;
|
||||
}
|
||||
|
||||
inline const WindowImpl* Window::GetImpl() const
|
||||
{
|
||||
return m_impl;
|
||||
}
|
||||
}
|
||||
|
||||
#include <Nazara/Platform/DebugOff.hpp>
|
||||
|
||||
@@ -8,21 +8,44 @@
|
||||
#define NAZARA_WINDOWHANDLE_HPP
|
||||
|
||||
#include <Nazara/Prerequisites.hpp>
|
||||
#if defined(NAZARA_PLATFORM_X11)
|
||||
#include <xcb/xcb.h>
|
||||
#endif
|
||||
#include <Nazara/Utility/Config.hpp>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
#if defined(NAZARA_PLATFORM_WINDOWS)
|
||||
// http://msdn.microsoft.com/en-us/library/aa383751(v=vs.85).aspx
|
||||
using WindowHandle = void*;
|
||||
#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
|
||||
enum class WindowManager
|
||||
{
|
||||
None,
|
||||
|
||||
X11,
|
||||
Wayland,
|
||||
Windows
|
||||
};
|
||||
|
||||
struct WindowHandle
|
||||
{
|
||||
WindowManager type = WindowManager::None;
|
||||
|
||||
union
|
||||
{
|
||||
struct
|
||||
{
|
||||
void* display; //< Display*
|
||||
void* window; //< Window
|
||||
} x11;
|
||||
|
||||
struct
|
||||
{
|
||||
void* display; //< wl_display*
|
||||
void* surface; //< wl_surface*
|
||||
void* shellSurface; //< wl_shell_surface*
|
||||
} wayland;
|
||||
|
||||
struct
|
||||
{
|
||||
void* window; //< HWND
|
||||
} windows;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
#endif // NAZARA_WINDOWHANDLE_HPP
|
||||
|
||||
Reference in New Issue
Block a user