Commit 831090e4 authored by chili's avatar chili
Browse files

housekp: optional mouse evt

parent 1a760aaa
...@@ -51,7 +51,7 @@ bool Mouse::RightIsPressed() const noexcept ...@@ -51,7 +51,7 @@ bool Mouse::RightIsPressed() const noexcept
return rightIsPressed; return rightIsPressed;
} }
Mouse::Event Mouse::Read() noexcept std::optional<Mouse::Event> Mouse::Read() noexcept
{ {
if( buffer.size() > 0u ) if( buffer.size() > 0u )
{ {
...@@ -59,10 +59,7 @@ Mouse::Event Mouse::Read() noexcept ...@@ -59,10 +59,7 @@ Mouse::Event Mouse::Read() noexcept
buffer.pop(); buffer.pop();
return e; return e;
} }
else return {};
{
return Mouse::Event();
}
} }
void Mouse::Flush() noexcept void Mouse::Flush() noexcept
......
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
******************************************************************************************/ ******************************************************************************************/
#pragma once #pragma once
#include <queue> #include <queue>
#include <optional>
class Mouse class Mouse
{ {
...@@ -39,7 +40,6 @@ public: ...@@ -39,7 +40,6 @@ public:
Move, Move,
Enter, Enter,
Leave, Leave,
Invalid
}; };
private: private:
Type type; Type type;
...@@ -48,14 +48,6 @@ public: ...@@ -48,14 +48,6 @@ public:
int x; int x;
int y; int y;
public: public:
Event() noexcept
:
type( Type::Invalid ),
leftIsPressed( false ),
rightIsPressed( false ),
x( 0 ),
y( 0 )
{}
Event( Type type,const Mouse& parent ) noexcept Event( Type type,const Mouse& parent ) noexcept
: :
type( type ), type( type ),
...@@ -64,10 +56,6 @@ public: ...@@ -64,10 +56,6 @@ public:
x( parent.x ), x( parent.x ),
y( parent.y ) y( parent.y )
{} {}
bool IsValid() const noexcept
{
return type != Type::Invalid;
}
Type GetType() const noexcept Type GetType() const noexcept
{ {
return type; return type;
...@@ -103,7 +91,7 @@ public: ...@@ -103,7 +91,7 @@ public:
bool IsInWindow() const noexcept; bool IsInWindow() const noexcept;
bool LeftIsPressed() const noexcept; bool LeftIsPressed() const noexcept;
bool RightIsPressed() const noexcept; bool RightIsPressed() const noexcept;
Mouse::Event Read() noexcept; std::optional<Mouse::Event> Read() noexcept;
bool IsEmpty() const noexcept bool IsEmpty() const noexcept
{ {
return buffer.empty(); return buffer.empty();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment