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
return rightIsPressed;
}
Mouse::Event Mouse::Read() noexcept
std::optional<Mouse::Event> Mouse::Read() noexcept
{
if( buffer.size() > 0u )
{
......@@ -59,10 +59,7 @@ Mouse::Event Mouse::Read() noexcept
buffer.pop();
return e;
}
else
{
return Mouse::Event();
}
return {};
}
void Mouse::Flush() noexcept
......
......@@ -20,6 +20,7 @@
******************************************************************************************/
#pragma once
#include <queue>
#include <optional>
class Mouse
{
......@@ -39,7 +40,6 @@ public:
Move,
Enter,
Leave,
Invalid
};
private:
Type type;
......@@ -48,14 +48,6 @@ public:
int x;
int y;
public:
Event() noexcept
:
type( Type::Invalid ),
leftIsPressed( false ),
rightIsPressed( false ),
x( 0 ),
y( 0 )
{}
Event( Type type,const Mouse& parent ) noexcept
:
type( type ),
......@@ -64,10 +56,6 @@ public:
x( parent.x ),
y( parent.y )
{}
bool IsValid() const noexcept
{
return type != Type::Invalid;
}
Type GetType() const noexcept
{
return type;
......@@ -103,7 +91,7 @@ public:
bool IsInWindow() const noexcept;
bool LeftIsPressed() const noexcept;
bool RightIsPressed() const noexcept;
Mouse::Event Read() noexcept;
std::optional<Mouse::Event> Read() noexcept;
bool IsEmpty() const noexcept
{
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