Skip to content

Commit

Permalink
Merge branch 'main' of github.com:simul/Platform
Browse files Browse the repository at this point in the history
  • Loading branch information
rvkennedy committed Dec 2, 2024
2 parents e46bff4 + 45f41d5 commit 8eaa782
Show file tree
Hide file tree
Showing 7 changed files with 180 additions and 132 deletions.
26 changes: 11 additions & 15 deletions Core/BaseMouseHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,33 +8,33 @@ BaseMouseHandler::BaseMouseHandler()
,fDeltaY(0)
,MouseX(0)
,MouseY(0)
, view_width(750)
, view_height(750)
,mouseButtons(core::NoButton)
,view_width(750)
,view_height(750)
,mouseButtons(core::MouseButtons::NoButton)
{
}

BaseMouseHandler::~BaseMouseHandler()
{
}

void BaseMouseHandler::mouseRelease(int button,int x,int y)
void BaseMouseHandler::mouseRelease(MouseButtons button, int x, int y)
{
*((int*)&mouseButtons)&=(~button);
mouseButtons&=~button;
MouseX=x;
MouseY=y;
UpdateViews();
}

void BaseMouseHandler::mousePress(int button,int x,int y)
void BaseMouseHandler::mousePress(MouseButtons button, int x, int y)
{
*((int*)&mouseButtons)|=button;
mouseButtons|=button;
MouseX=x;
MouseY=y;
UpdateViews();
}

void BaseMouseHandler::mouseDoubleClick(int ,int x,int y)
void BaseMouseHandler::mouseDoubleClick(MouseButtons, int x, int y)
{
MouseX=x;
MouseY=y;
Expand Down Expand Up @@ -81,17 +81,13 @@ void BaseMouseHandler::SetViewSize(int w, int h)
}



void BaseMouseHandler::KeyboardProc(unsigned int /*nChar*/, bool bKeyDown, bool )
void BaseMouseHandler::KeyboardProc(KeyboardModifiers modifiers, bool bKeyDown)
{
if(bKeyDown)
{
}
if(updateViews)
UpdateViews();
}

MouseButtons BaseMouseHandler::getMouseButtons() const
MouseButtons BaseMouseHandler::getMouseButtons() const
{
return mouseButtons;
return mouseButtons;
}
20 changes: 13 additions & 7 deletions Core/BaseMouseHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,16 @@

#include <functional>
#include "Platform/Core/Export.h"
#include "Platform/Core/EnumClassBitwiseOperators.h"

#ifdef _MSC_VER
#pragma warning(disable:4251)
#endif
namespace platform
{
namespace core
{
enum MouseButtons
enum class MouseButtons : uint16_t
{
NoButton = 0,
LeftButton = 1,
Expand All @@ -19,31 +21,35 @@ namespace platform
Button4 = 8,
Button5 = 16,
};
enum class KeyboardModifiers
enum class KeyboardModifiers : uint16_t
{
NoModifier = 0,
Shift = 1,
Alt = 2,
Ctrl = 4,
};

// A simple render delegate, it will usually be a function partially bound with std::bind.
typedef std::function<void()> VoidFnDelegate;
class PLATFORM_CORE_EXPORT BaseMouseHandler
{
public:
BaseMouseHandler();
virtual ~BaseMouseHandler();
virtual void mousePress(int button, int x, int y);
virtual void mouseRelease(int button, int x, int y);
virtual void mouseDoubleClick(int button, int x, int y);
virtual void mousePress(MouseButtons button, int x, int y);
virtual void mouseRelease(MouseButtons button, int x, int y);
virtual void mouseDoubleClick(MouseButtons button, int x, int y);
virtual void mouseMove(int x, int y);
virtual void getMousePosition(int &x, int &y) const;
virtual void mouseWheel(int delta, int modifiers);
virtual void KeyboardProc(unsigned int nChar, bool bKeyDown, bool bAltDown);
virtual MouseButtons getMouseButtons() const;
virtual void KeyboardProc(KeyboardModifiers modifiers, bool bKeyDown);
virtual MouseButtons getMouseButtons() const;
void SetViewSize(int w, int h);

public:
VoidFnDelegate updateViews;
VoidFnDelegate valuesChanged;

protected:
float fDeltaX, fDeltaY;
int MouseX, MouseY;
Expand Down
5 changes: 5 additions & 0 deletions Core/PropertyMacros.h
Original file line number Diff line number Diff line change
Expand Up @@ -835,6 +835,7 @@ template<class T, T minimum, T maximum> void META_StaticLimit(T &t)
#pragma warning(pop)
#endif

#if 0
#define SIMUL_BIT_FLAG(Enum,T) \
inline Enum operator|(const Enum &a, const Enum &b) \
{ \
Expand All @@ -859,4 +860,8 @@ inline Enum operator~(const Enum &a) \
Enum b = static_cast<Enum>(~static_cast<T>(a)); \
return b; \
}
#else
#define SIMUL_BIT_FLAG(Enum, T)
#endif

#include "Platform/Core/EnumClassBitwiseOperators.h"
6 changes: 5 additions & 1 deletion Core/Settings.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
#pragma once
#include "Platform/Core/Export.h"
#include "Platform/Core/SimpleIni.h"
#include "Platform/Core/RuntimeError.h"

#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN
#endif
#include "Platform/Core/SimpleIni.h"

#ifdef _MSC_VER
#pragma warning(disable : 4251)
#endif
Expand Down
Loading

0 comments on commit 8eaa782

Please sign in to comment.