Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Clark Lin
hw3d
Commits
2f5bddb5
Commit
2f5bddb5
authored
Jul 01, 2019
by
chili
Browse files
ability to disable cursor
dissing
parent
88ecc24b
Changes
3
Hide whitespace changes
Inline
Side-by-side
hw3d/App.cpp
View file @
2f5bddb5
...
@@ -16,6 +16,7 @@ App::App()
...
@@ -16,6 +16,7 @@ App::App()
light
(
wnd
.
Gfx
()
)
light
(
wnd
.
Gfx
()
)
{
{
wnd
.
Gfx
().
SetProjection
(
dx
::
XMMatrixPerspectiveLH
(
1.0
f
,
9.0
f
/
16.0
f
,
0.5
f
,
40.0
f
)
);
wnd
.
Gfx
().
SetProjection
(
dx
::
XMMatrixPerspectiveLH
(
1.0
f
,
9.0
f
/
16.0
f
,
0.5
f
,
40.0
f
)
);
wnd
.
DisableCursor
();
}
}
void
App
::
DoFrame
()
void
App
::
DoFrame
()
...
...
hw3d/Window.cpp
View file @
2f5bddb5
...
@@ -119,6 +119,18 @@ void Window::SetTitle( const std::string& title )
...
@@ -119,6 +119,18 @@ void Window::SetTitle( const std::string& title )
}
}
}
}
void
Window
::
EnableCursor
()
{
cursorEnabled
=
true
;
ShowCursor
();
}
void
Window
::
DisableCursor
()
{
cursorEnabled
=
false
;
HideCursor
();
}
std
::
optional
<
int
>
Window
::
ProcessMessages
()
noexcept
std
::
optional
<
int
>
Window
::
ProcessMessages
()
noexcept
{
{
MSG
msg
;
MSG
msg
;
...
@@ -150,6 +162,16 @@ Graphics& Window::Gfx()
...
@@ -150,6 +162,16 @@ Graphics& Window::Gfx()
return
*
pGfx
;
return
*
pGfx
;
}
}
void
Window
::
HideCursor
()
{
while
(
::
ShowCursor
(
FALSE
)
>=
0
);
}
void
Window
::
ShowCursor
()
{
while
(
::
ShowCursor
(
TRUE
)
<
0
);
}
LRESULT
CALLBACK
Window
::
HandleMsgSetup
(
HWND
hWnd
,
UINT
msg
,
WPARAM
wParam
,
LPARAM
lParam
)
noexcept
LRESULT
CALLBACK
Window
::
HandleMsgSetup
(
HWND
hWnd
,
UINT
msg
,
WPARAM
wParam
,
LPARAM
lParam
)
noexcept
{
{
// use create parameter passed in from CreateWindow() to store window class pointer at WinAPI side
// use create parameter passed in from CreateWindow() to store window class pointer at WinAPI side
...
@@ -233,6 +255,17 @@ LRESULT Window::HandleMsg( HWND hWnd,UINT msg,WPARAM wParam,LPARAM lParam ) noex
...
@@ -233,6 +255,17 @@ LRESULT Window::HandleMsg( HWND hWnd,UINT msg,WPARAM wParam,LPARAM lParam ) noex
/************* MOUSE MESSAGES ****************/
/************* MOUSE MESSAGES ****************/
case
WM_MOUSEMOVE
:
case
WM_MOUSEMOVE
:
{
{
// cursorless exclusive gets first dibs
if
(
!
cursorEnabled
)
{
if
(
!
mouse
.
IsInWindow
()
)
{
SetCapture
(
hWnd
);
mouse
.
OnMouseEnter
();
HideCursor
();
}
break
;
}
// stifle this mouse message if imgui wants to capture
// stifle this mouse message if imgui wants to capture
if
(
imio
.
WantCaptureMouse
)
if
(
imio
.
WantCaptureMouse
)
{
{
...
...
hw3d/Window.h
View file @
2f5bddb5
...
@@ -75,9 +75,13 @@ public:
...
@@ -75,9 +75,13 @@ public:
Window
(
const
Window
&
)
=
delete
;
Window
(
const
Window
&
)
=
delete
;
Window
&
operator
=
(
const
Window
&
)
=
delete
;
Window
&
operator
=
(
const
Window
&
)
=
delete
;
void
SetTitle
(
const
std
::
string
&
title
);
void
SetTitle
(
const
std
::
string
&
title
);
void
EnableCursor
();
void
DisableCursor
();
static
std
::
optional
<
int
>
ProcessMessages
()
noexcept
;
static
std
::
optional
<
int
>
ProcessMessages
()
noexcept
;
Graphics
&
Gfx
();
Graphics
&
Gfx
();
private:
private:
void
HideCursor
();
void
ShowCursor
();
static
LRESULT
CALLBACK
HandleMsgSetup
(
HWND
hWnd
,
UINT
msg
,
WPARAM
wParam
,
LPARAM
lParam
)
noexcept
;
static
LRESULT
CALLBACK
HandleMsgSetup
(
HWND
hWnd
,
UINT
msg
,
WPARAM
wParam
,
LPARAM
lParam
)
noexcept
;
static
LRESULT
CALLBACK
HandleMsgThunk
(
HWND
hWnd
,
UINT
msg
,
WPARAM
wParam
,
LPARAM
lParam
)
noexcept
;
static
LRESULT
CALLBACK
HandleMsgThunk
(
HWND
hWnd
,
UINT
msg
,
WPARAM
wParam
,
LPARAM
lParam
)
noexcept
;
LRESULT
HandleMsg
(
HWND
hWnd
,
UINT
msg
,
WPARAM
wParam
,
LPARAM
lParam
)
noexcept
;
LRESULT
HandleMsg
(
HWND
hWnd
,
UINT
msg
,
WPARAM
wParam
,
LPARAM
lParam
)
noexcept
;
...
@@ -85,6 +89,7 @@ public:
...
@@ -85,6 +89,7 @@ public:
Keyboard
kbd
;
Keyboard
kbd
;
Mouse
mouse
;
Mouse
mouse
;
private:
private:
bool
cursorEnabled
=
false
;
int
width
;
int
width
;
int
height
;
int
height
;
HWND
hWnd
;
HWND
hWnd
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment