mirror of
https://github.com/aseprite/aseprite.git
synced 2025-03-03 07:13:45 +00:00
Implement SkiaDisplay::setNativeMouseCursor() on Windows
This commit is contained in:
parent
da3b3de6c1
commit
5eea582365
@ -116,6 +116,7 @@ EventQueue* SkiaDisplay::getEventQueue()
|
|||||||
|
|
||||||
bool SkiaDisplay::setNativeMouseCursor(NativeCursor cursor)
|
bool SkiaDisplay::setNativeMouseCursor(NativeCursor cursor)
|
||||||
{
|
{
|
||||||
|
m_window.setNativeMouseCursor(cursor);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
#include "gfx/size.h"
|
#include "gfx/size.h"
|
||||||
#include "she/event.h"
|
#include "she/event.h"
|
||||||
#include "she/keys.h"
|
#include "she/keys.h"
|
||||||
|
#include "she/native_cursor.h"
|
||||||
|
|
||||||
#ifndef WM_MOUSEHWHEEL
|
#ifndef WM_MOUSEHWHEEL
|
||||||
#define WM_MOUSEHWHEEL 0x020E
|
#define WM_MOUSEHWHEEL 0x020E
|
||||||
@ -32,6 +33,7 @@ namespace she {
|
|||||||
Window() {
|
Window() {
|
||||||
registerClass();
|
registerClass();
|
||||||
m_hwnd = createHwnd(this);
|
m_hwnd = createHwnd(this);
|
||||||
|
m_hcursor = NULL;
|
||||||
m_hasMouse = false;
|
m_hasMouse = false;
|
||||||
m_captureMouse = false;
|
m_captureMouse = false;
|
||||||
m_scale = 1;
|
m_scale = 1;
|
||||||
@ -94,6 +96,58 @@ namespace she {
|
|||||||
SetCursorPos(pos.x, pos.y);
|
SetCursorPos(pos.x, pos.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void setNativeMouseCursor(NativeCursor cursor) {
|
||||||
|
HCURSOR hcursor = NULL;
|
||||||
|
|
||||||
|
switch (cursor) {
|
||||||
|
case kNoCursor:
|
||||||
|
// Do nothing, just set to null
|
||||||
|
break;
|
||||||
|
case kArrowCursor:
|
||||||
|
hcursor = LoadCursor(NULL, IDC_ARROW);
|
||||||
|
break;
|
||||||
|
case kIBeamCursor:
|
||||||
|
hcursor = LoadCursor(NULL, IDC_IBEAM);
|
||||||
|
break;
|
||||||
|
case kWaitCursor:
|
||||||
|
hcursor = LoadCursor(NULL, IDC_WAIT);
|
||||||
|
break;
|
||||||
|
case kLinkCursor:
|
||||||
|
hcursor = LoadCursor(NULL, IDC_HAND);
|
||||||
|
break;
|
||||||
|
case kHelpCursor:
|
||||||
|
hcursor = LoadCursor(NULL, IDC_HELP);
|
||||||
|
break;
|
||||||
|
case kForbiddenCursor:
|
||||||
|
hcursor = LoadCursor(NULL, IDC_NO);
|
||||||
|
break;
|
||||||
|
case kMoveCursor:
|
||||||
|
hcursor = LoadCursor(NULL, IDC_SIZEALL);
|
||||||
|
break;
|
||||||
|
case kSizeNCursor:
|
||||||
|
case kSizeNSCursor:
|
||||||
|
case kSizeSCursor:
|
||||||
|
hcursor = LoadCursor(NULL, IDC_SIZENS);
|
||||||
|
break;
|
||||||
|
case kSizeECursor:
|
||||||
|
case kSizeWCursor:
|
||||||
|
case kSizeWECursor:
|
||||||
|
hcursor = LoadCursor(NULL, IDC_SIZEWE);
|
||||||
|
break;
|
||||||
|
case kSizeNWCursor:
|
||||||
|
case kSizeSECursor:
|
||||||
|
hcursor = LoadCursor(NULL, IDC_SIZENWSE);
|
||||||
|
break;
|
||||||
|
case kSizeNECursor:
|
||||||
|
case kSizeSWCursor:
|
||||||
|
hcursor = LoadCursor(NULL, IDC_SIZENESW);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
SetCursor(hcursor);
|
||||||
|
m_hcursor = hcursor;
|
||||||
|
}
|
||||||
|
|
||||||
void invalidate() {
|
void invalidate() {
|
||||||
InvalidateRect(m_hwnd, NULL, FALSE);
|
InvalidateRect(m_hwnd, NULL, FALSE);
|
||||||
}
|
}
|
||||||
@ -106,6 +160,13 @@ namespace she {
|
|||||||
LRESULT wndProc(UINT msg, WPARAM wparam, LPARAM lparam) {
|
LRESULT wndProc(UINT msg, WPARAM wparam, LPARAM lparam) {
|
||||||
switch (msg) {
|
switch (msg) {
|
||||||
|
|
||||||
|
case WM_SETCURSOR:
|
||||||
|
if (LOWORD(lparam) == HTCLIENT) {
|
||||||
|
SetCursor(m_hcursor);
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
case WM_CLOSE: {
|
case WM_CLOSE: {
|
||||||
Event ev;
|
Event ev;
|
||||||
ev.setType(Event::CloseDisplay);
|
ev.setType(Event::CloseDisplay);
|
||||||
@ -400,7 +461,7 @@ namespace she {
|
|||||||
wcex.cbWndExtra = 0;
|
wcex.cbWndExtra = 0;
|
||||||
wcex.hInstance = instance;
|
wcex.hInstance = instance;
|
||||||
wcex.hIcon = nullptr;
|
wcex.hIcon = nullptr;
|
||||||
wcex.hCursor = LoadCursor(nullptr, IDC_ARROW);
|
wcex.hCursor = NULL;
|
||||||
wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
|
wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
|
||||||
wcex.lpszMenuName = nullptr;
|
wcex.lpszMenuName = nullptr;
|
||||||
wcex.lpszClassName = SHE_WND_CLASS_NAME;
|
wcex.lpszClassName = SHE_WND_CLASS_NAME;
|
||||||
@ -444,6 +505,7 @@ namespace she {
|
|||||||
}
|
}
|
||||||
|
|
||||||
mutable HWND m_hwnd;
|
mutable HWND m_hwnd;
|
||||||
|
HCURSOR m_hcursor;
|
||||||
gfx::Size m_clientSize;
|
gfx::Size m_clientSize;
|
||||||
gfx::Size m_restoredSize;
|
gfx::Size m_restoredSize;
|
||||||
int m_scale;
|
int m_scale;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user