I should have commit when I knew what changes I made.
This commit is contained in:
@@ -63,26 +63,6 @@ void cEventControl::CheckEvents()
|
|||||||
for (it = m_children.begin(); it < m_children.end(); it++) {
|
for (it = m_children.begin(); it < m_children.end(); it++) {
|
||||||
(*it)->OnEvent(event);
|
(*it)->OnEvent(event);
|
||||||
}
|
}
|
||||||
// iVector2 location = { 0, 0 };
|
|
||||||
// switch (event.type)
|
|
||||||
// {
|
|
||||||
// case SDL_KEYUP:
|
|
||||||
// case SDL_KEYDOWN:
|
|
||||||
// case SDL_JOYAXISMOTION:
|
|
||||||
// case SDL_JOYBALLMOTION:
|
|
||||||
// case SDL_JOYHATMOTION:
|
|
||||||
// case SDL_JOYBUTTONDOWN:
|
|
||||||
// case SDL_JOYBUTTONUP:
|
|
||||||
// InputEngine::cInput::Inst().CheckInputs(event);
|
|
||||||
// break;
|
|
||||||
// case SDL_MOUSEBUTTONDOWN:
|
|
||||||
//
|
|
||||||
// SDL_GetMouseState(&location.x, &location.y);
|
|
||||||
// GUIEngine::cGUI::Inst().Event(location, GUIEngine::cGUI::eGUIEventType::MouseButton1);
|
|
||||||
// break;
|
|
||||||
// case SDL_MOUSEBUTTONUP:
|
|
||||||
// break;
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,11 @@
|
|||||||
|
#ifndef _EVENT_H_
|
||||||
|
#define _EVENT_H_
|
||||||
|
|
||||||
|
/*** Custom Header Files ***/
|
||||||
|
|
||||||
|
/*** DLL Header File ***/
|
||||||
|
#include "dllExport.h"
|
||||||
|
|
||||||
|
#define CLASS(X)
|
||||||
|
|
||||||
|
#endif/// END IFNDEF _EVENT_H_
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
#include "cButtonEvent.hpp"
|
||||||
|
|
||||||
|
#include "../../MathEngine/cInside.hpp"
|
||||||
|
|
||||||
|
using GUIEventEngine::cButtonEvent;
|
||||||
|
|
||||||
|
/// protected:
|
||||||
|
cButtonEvent::cButtonEvent( const unsigned int id )
|
||||||
|
: cGUIEvent(GUIHelpers::eEventType::BUTTON, id)
|
||||||
|
{}
|
||||||
|
|
||||||
|
/*virtual*/ cButtonEvent::~cButtonEvent()
|
||||||
|
{}
|
||||||
|
|
||||||
|
/// public:
|
||||||
|
/*virtual*/ void cButtonEvent::OnLButtonDown( int mX, int mY )
|
||||||
|
{
|
||||||
|
// if (MathEngine::cInside::isInside(mX, mY, m_button->getArea()) == true)
|
||||||
|
// ;
|
||||||
|
}
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
#ifndef _CBUTTONEVENT_HPP_
|
||||||
|
#define _CBUTTONEVENT_HPP_
|
||||||
|
|
||||||
|
/*** Custom Header Files ***/
|
||||||
|
#include "../../EventEngine/cEvent.hpp"
|
||||||
|
|
||||||
|
//#include "../cButton.hpp"
|
||||||
|
#include "cGUIEvent.hpp"
|
||||||
|
|
||||||
|
|
||||||
|
/*** DLL Header File ***/
|
||||||
|
#include "dllExport.h"
|
||||||
|
|
||||||
|
namespace GUIEventEngine {
|
||||||
|
class EXPORT_FROM_MYDLL cButtonEvent : public cGUIEvent
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
cButtonEvent( const unsigned int id );
|
||||||
|
virtual ~cButtonEvent();
|
||||||
|
|
||||||
|
//bool operator == ( const cButtonEvent& other );
|
||||||
|
|
||||||
|
public:
|
||||||
|
/// Functions
|
||||||
|
virtual void OnLButtonDown( int mX, int mY );
|
||||||
|
|
||||||
|
/// Sets
|
||||||
|
|
||||||
|
/// Gets
|
||||||
|
|
||||||
|
private:
|
||||||
|
/// Variables
|
||||||
|
//GUIEngine::cButton* m_button;
|
||||||
|
};/// END CLASS DEFINITION cButtonEvent
|
||||||
|
}/// END NAMESPACE DEFINITION GUIEventEngine
|
||||||
|
#endif/// END IFNDEF _CBUTTONEVENT_HPP_
|
||||||
@@ -0,0 +1,297 @@
|
|||||||
|
#include "cGUIEvent.hpp"
|
||||||
|
|
||||||
|
using GUIEventEngine::cGUIEvent;
|
||||||
|
|
||||||
|
cGUIEvent::cGUIEvent( const GUIHelpers::eEventType eventType, const unsigned int id )
|
||||||
|
: m_eventType(eventType), m_id(id)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/*virtual*/ cGUIEvent::~cGUIEvent()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/*virtual*/ void cGUIEvent::OnEvent(const SDL_Event& event)
|
||||||
|
{
|
||||||
|
switch (event.type)
|
||||||
|
{
|
||||||
|
case SDL_WINDOWEVENT:
|
||||||
|
OnWindowsEvent(event);
|
||||||
|
break;
|
||||||
|
case SDL_KEYDOWN:
|
||||||
|
OnKeyDown(event.key.keysym.sym, event.key.keysym.mod);// , Event->key.keysym.unicode);
|
||||||
|
break;
|
||||||
|
case SDL_KEYUP:
|
||||||
|
OnKeyUp(event.key.keysym.sym, event.key.keysym.mod);//, Event->key.keysym.unicode);
|
||||||
|
break;
|
||||||
|
case SDL_MOUSEMOTION:
|
||||||
|
OnMouseMove(event.motion.x, event.motion.y, event.motion.xrel, event.motion.yrel, (event.motion.state&SDL_BUTTON(SDL_BUTTON_LEFT)) != 0, (event.motion.state&SDL_BUTTON(SDL_BUTTON_RIGHT)) != 0, (event.motion.state&SDL_BUTTON(SDL_BUTTON_MIDDLE)) != 0);
|
||||||
|
break;
|
||||||
|
case SDL_MOUSEBUTTONDOWN:
|
||||||
|
OnMouseButtonDown(event);
|
||||||
|
break;
|
||||||
|
case SDL_MOUSEBUTTONUP:
|
||||||
|
OnMouseButtonUp(event);
|
||||||
|
break;
|
||||||
|
case SDL_JOYAXISMOTION:
|
||||||
|
OnJoyAxis(event.jaxis.which, event.jaxis.axis, event.jaxis.value);
|
||||||
|
break;
|
||||||
|
case SDL_JOYBALLMOTION:
|
||||||
|
OnJoyBall(event.jball.which, event.jball.ball, event.jball.xrel, event.jball.yrel);
|
||||||
|
break;
|
||||||
|
case SDL_JOYHATMOTION:
|
||||||
|
OnJoyHat(event.jhat.which, event.jhat.hat, event.jhat.value);
|
||||||
|
break;
|
||||||
|
case SDL_JOYBUTTONDOWN:
|
||||||
|
OnJoyButtonDown(event.jbutton.which, event.jbutton.button);
|
||||||
|
break;
|
||||||
|
case SDL_JOYBUTTONUP:
|
||||||
|
OnJoyButtonUp(event.jbutton.which, event.jbutton.button);
|
||||||
|
break;
|
||||||
|
case SDL_QUIT:
|
||||||
|
OnExit();
|
||||||
|
break;
|
||||||
|
case SDL_SYSWMEVENT:
|
||||||
|
//Ignore
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
OnUser(event.user.type, event.user.code, event.user.data1, event.user.data2);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*virtual*/ void cGUIEvent::OnInputFocus()
|
||||||
|
{
|
||||||
|
//Pure virtual, do nothing
|
||||||
|
}
|
||||||
|
|
||||||
|
/*virtual*/ void cGUIEvent::OnInputBlur()
|
||||||
|
{
|
||||||
|
//Pure virtual, do nothing
|
||||||
|
}
|
||||||
|
|
||||||
|
/*virtual*/ void cGUIEvent::OnKeyDown(SDL_Keycode sym, Uint16 mod)//, Uint16 unicode)
|
||||||
|
{
|
||||||
|
sym, mod;
|
||||||
|
//Pure virtual, do nothing
|
||||||
|
}
|
||||||
|
|
||||||
|
/*virtual*/ void cGUIEvent::OnKeyUp(SDL_Keycode sym, Uint16 mod)//, Uint16 unicode)
|
||||||
|
{
|
||||||
|
sym, mod;
|
||||||
|
//Pure virtual, do nothing
|
||||||
|
}
|
||||||
|
|
||||||
|
/*virtual*/ void cGUIEvent::OnMouseFocus()
|
||||||
|
{
|
||||||
|
//Pure virtual, do nothing
|
||||||
|
}
|
||||||
|
|
||||||
|
/*virtual*/ void cGUIEvent::OnMouseBlur()
|
||||||
|
{
|
||||||
|
//Pure virtual, do nothing
|
||||||
|
}
|
||||||
|
|
||||||
|
/*virtual*/ void cGUIEvent::OnMouseMove(int mX, int mY, int relX, int relY, bool Left, bool Right, bool Middle)
|
||||||
|
{
|
||||||
|
mX, mY, relX, relY, Left, Right, Middle;
|
||||||
|
//Pure virtual, do nothing
|
||||||
|
}
|
||||||
|
|
||||||
|
/*virtual*/ void cGUIEvent::OnMouseWheel(bool Up, bool Down)
|
||||||
|
{
|
||||||
|
Up, Down;
|
||||||
|
//Pure virtual, do nothing
|
||||||
|
}
|
||||||
|
|
||||||
|
/*virtual*/ void cGUIEvent::OnLButtonDown(int mX, int mY)
|
||||||
|
{
|
||||||
|
mX, mY;
|
||||||
|
//Pure virtual, do nothing
|
||||||
|
}
|
||||||
|
|
||||||
|
/*virtual*/ void cGUIEvent::OnLButtonUp(int mX, int mY)
|
||||||
|
{
|
||||||
|
mX, mY;
|
||||||
|
//Pure virtual, do nothing
|
||||||
|
}
|
||||||
|
|
||||||
|
/*virtual*/ void cGUIEvent::OnRButtonDown(int mX, int mY)
|
||||||
|
{
|
||||||
|
mX, mY;
|
||||||
|
//Pure virtual, do nothing
|
||||||
|
}
|
||||||
|
|
||||||
|
/*virtual*/ void cGUIEvent::OnRButtonUp(int mX, int mY)
|
||||||
|
{
|
||||||
|
mX, mY;
|
||||||
|
//Pure virtual, do nothing
|
||||||
|
}
|
||||||
|
|
||||||
|
/*virtual*/ void cGUIEvent::OnMButtonDown(int mX, int mY)
|
||||||
|
{
|
||||||
|
mX, mY;
|
||||||
|
//Pure virtual, do nothing
|
||||||
|
}
|
||||||
|
|
||||||
|
/*virtual*/ void cGUIEvent::OnMButtonUp(int mX, int mY)
|
||||||
|
{
|
||||||
|
mX, mY;
|
||||||
|
//Pure virtual, do nothing
|
||||||
|
}
|
||||||
|
|
||||||
|
/*virtual*/ void cGUIEvent::OnJoyAxis(SDL_JoystickID which, Uint8 axis, Sint16 value)
|
||||||
|
{
|
||||||
|
which, axis, value;
|
||||||
|
//Pure virtual, do nothing
|
||||||
|
}
|
||||||
|
|
||||||
|
/*virtual*/ void cGUIEvent::OnJoyButtonDown(SDL_JoystickID which, Uint8 button)
|
||||||
|
{
|
||||||
|
which, button;
|
||||||
|
//Pure virtual, do nothing
|
||||||
|
}
|
||||||
|
|
||||||
|
/*virtual*/ void cGUIEvent::OnJoyButtonUp(SDL_JoystickID which, Uint8 button)
|
||||||
|
{
|
||||||
|
which, button;
|
||||||
|
//Pure virtual, do nothing
|
||||||
|
}
|
||||||
|
|
||||||
|
/*virtual*/ void cGUIEvent::OnJoyHat(SDL_JoystickID which, Uint8 hat, Uint8 value)
|
||||||
|
{
|
||||||
|
which, hat, value;
|
||||||
|
//Pure virtual, do nothing
|
||||||
|
}
|
||||||
|
|
||||||
|
/*virtual*/ void cGUIEvent::OnJoyBall(SDL_JoystickID which, Uint8 ball, Sint16 xrel, Sint16 yrel)
|
||||||
|
{
|
||||||
|
which, ball, xrel, yrel;
|
||||||
|
//Pure virtual, do nothing
|
||||||
|
}
|
||||||
|
|
||||||
|
/*virtual*/ void cGUIEvent::OnMinimize()
|
||||||
|
{
|
||||||
|
//Pure virtual, do nothing
|
||||||
|
}
|
||||||
|
|
||||||
|
/*virtual*/ void cGUIEvent::OnRestore()
|
||||||
|
{
|
||||||
|
//Pure virtual, do nothing
|
||||||
|
}
|
||||||
|
|
||||||
|
/*virtual*/ void cGUIEvent::OnResize(int w, int h)
|
||||||
|
{
|
||||||
|
w, h;
|
||||||
|
//Pure virtual, do nothing
|
||||||
|
}
|
||||||
|
|
||||||
|
/*virtual*/ void cGUIEvent::OnExpose()
|
||||||
|
{
|
||||||
|
//Pure virtual, do nothing
|
||||||
|
}
|
||||||
|
|
||||||
|
/*virtual*/ void cGUIEvent::OnExit()
|
||||||
|
{
|
||||||
|
//Pure virtual, do nothing
|
||||||
|
}
|
||||||
|
|
||||||
|
/*virtual*/ void cGUIEvent::OnUser(Uint32 type, int code, void* data1, void* data2)
|
||||||
|
{
|
||||||
|
type, code, data1, data2;
|
||||||
|
//Pure virtual, do nothing
|
||||||
|
}
|
||||||
|
|
||||||
|
/*virtual*/ void cGUIEvent::OnWindowsEvent(const SDL_Event& event)
|
||||||
|
{
|
||||||
|
switch (event.window.event)
|
||||||
|
{
|
||||||
|
case SDL_WINDOWEVENT_SHOWN:
|
||||||
|
SDL_Log("Window %d shown", event.window.windowID);
|
||||||
|
break;
|
||||||
|
case SDL_WINDOWEVENT_HIDDEN:
|
||||||
|
SDL_Log("Window %d hidden", event.window.windowID);
|
||||||
|
break;
|
||||||
|
case SDL_WINDOWEVENT_EXPOSED:
|
||||||
|
SDL_Log("Window %d exposed", event.window.windowID);
|
||||||
|
break;
|
||||||
|
case SDL_WINDOWEVENT_MOVED:
|
||||||
|
SDL_Log("Window %d moved to %d,%d",
|
||||||
|
event.window.windowID, event.window.data1,
|
||||||
|
event.window.data2);
|
||||||
|
break;
|
||||||
|
case SDL_WINDOWEVENT_RESIZED:
|
||||||
|
SDL_Log("Window %d resized to %dx%d",
|
||||||
|
event.window.windowID, event.window.data1,
|
||||||
|
event.window.data2);
|
||||||
|
break;
|
||||||
|
case SDL_WINDOWEVENT_SIZE_CHANGED:
|
||||||
|
SDL_Log("Window %d size changed to %dx%d",
|
||||||
|
event.window.windowID, event.window.data1,
|
||||||
|
event.window.data2);
|
||||||
|
break;
|
||||||
|
case SDL_WINDOWEVENT_MINIMIZED:
|
||||||
|
SDL_Log("Window %d minimized", event.window.windowID);
|
||||||
|
break;
|
||||||
|
case SDL_WINDOWEVENT_MAXIMIZED:
|
||||||
|
SDL_Log("Window %d maximized", event.window.windowID);
|
||||||
|
break;
|
||||||
|
case SDL_WINDOWEVENT_RESTORED:
|
||||||
|
SDL_Log("Window %d restored", event.window.windowID);
|
||||||
|
break;
|
||||||
|
case SDL_WINDOWEVENT_ENTER:
|
||||||
|
SDL_Log("Mouse entered window %d",
|
||||||
|
event.window.windowID);
|
||||||
|
break;
|
||||||
|
case SDL_WINDOWEVENT_LEAVE:
|
||||||
|
SDL_Log("Mouse left window %d", event.window.windowID);
|
||||||
|
break;
|
||||||
|
case SDL_WINDOWEVENT_FOCUS_GAINED:
|
||||||
|
SDL_Log("Window %d gained keyboard focus",
|
||||||
|
event.window.windowID);
|
||||||
|
break;
|
||||||
|
case SDL_WINDOWEVENT_FOCUS_LOST:
|
||||||
|
SDL_Log("Window %d lost keyboard focus",
|
||||||
|
event.window.windowID);
|
||||||
|
break;
|
||||||
|
case SDL_WINDOWEVENT_CLOSE:
|
||||||
|
SDL_Log("Window %d closed", event.window.windowID);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
SDL_Log("Window %d got unknown event %d",
|
||||||
|
event.window.windowID, event.window.event);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*virtual*/ void cGUIEvent::OnMouseButtonDown(const SDL_Event& event)
|
||||||
|
{
|
||||||
|
switch (event.button.button)
|
||||||
|
{
|
||||||
|
case SDL_BUTTON_LEFT:
|
||||||
|
OnLButtonDown(event.button.x, event.button.y);
|
||||||
|
break;
|
||||||
|
case SDL_BUTTON_RIGHT:
|
||||||
|
OnRButtonDown(event.button.x, event.button.y);
|
||||||
|
break;
|
||||||
|
case SDL_BUTTON_MIDDLE:
|
||||||
|
OnMButtonDown(event.button.x, event.button.y);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*virtual*/ void cGUIEvent::OnMouseButtonUp(const SDL_Event& event)
|
||||||
|
{
|
||||||
|
switch (event.button.button)
|
||||||
|
{
|
||||||
|
case SDL_BUTTON_LEFT:
|
||||||
|
OnLButtonUp(event.button.x, event.button.y);
|
||||||
|
break;
|
||||||
|
case SDL_BUTTON_RIGHT:
|
||||||
|
OnRButtonUp(event.button.x, event.button.y);
|
||||||
|
break;
|
||||||
|
case SDL_BUTTON_MIDDLE:
|
||||||
|
OnMButtonUp(event.button.x, event.button.y);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,86 @@
|
|||||||
|
#ifndef _CGUIEVENT_HPP_
|
||||||
|
#define _CGUIEVENT_HPP_
|
||||||
|
|
||||||
|
/*** Custom Header Files ***/
|
||||||
|
#include "../../EventEngine/cEvent.hpp"
|
||||||
|
#include "../GUIHelpers/Enums.hpp"
|
||||||
|
|
||||||
|
/*** DLL Header File ***/
|
||||||
|
#include "dllExport.h"
|
||||||
|
|
||||||
|
#include "../GUIHelpers/cObject.hpp"
|
||||||
|
|
||||||
|
namespace GUIEventEngine {
|
||||||
|
class EXPORT_FROM_MYDLL cGUIEvent : public EventEngine::cEvent
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
cGUIEvent( const GUIHelpers::eEventType eventType, const unsigned int id );
|
||||||
|
virtual ~cGUIEvent();
|
||||||
|
|
||||||
|
bool operator == (const cGUIEvent& other);
|
||||||
|
|
||||||
|
/// Functions
|
||||||
|
virtual void OnEvent(const SDL_Event& event);
|
||||||
|
|
||||||
|
virtual void OnInputFocus();
|
||||||
|
|
||||||
|
virtual void OnInputBlur();
|
||||||
|
|
||||||
|
virtual void OnKeyDown(SDL_Keycode sym, Uint16 mod);//, Uint16 unicode);
|
||||||
|
|
||||||
|
virtual void OnKeyUp(SDL_Keycode sym, Uint16 mod);//, Uint16 unicode);
|
||||||
|
|
||||||
|
virtual void OnMouseFocus();
|
||||||
|
|
||||||
|
virtual void OnMouseBlur();
|
||||||
|
|
||||||
|
virtual void OnMouseMove(int mX, int mY, int relX, int relY, bool Left, bool Right, bool Middle);
|
||||||
|
|
||||||
|
virtual void OnMouseWheel(bool Up, bool Down); //Not implemented
|
||||||
|
|
||||||
|
virtual void OnLButtonDown(int mX, int mY);
|
||||||
|
|
||||||
|
virtual void OnLButtonUp(int mX, int mY);
|
||||||
|
|
||||||
|
virtual void OnRButtonDown(int mX, int mY);
|
||||||
|
|
||||||
|
virtual void OnRButtonUp(int mX, int mY);
|
||||||
|
|
||||||
|
virtual void OnMButtonDown(int mX, int mY);
|
||||||
|
|
||||||
|
virtual void OnMButtonUp(int mX, int mY);
|
||||||
|
|
||||||
|
virtual void OnJoyAxis(SDL_JoystickID which, Uint8 axis, Sint16 value);
|
||||||
|
|
||||||
|
virtual void OnJoyButtonDown(SDL_JoystickID which, Uint8 button);
|
||||||
|
|
||||||
|
virtual void OnJoyButtonUp(SDL_JoystickID which, Uint8 button);
|
||||||
|
|
||||||
|
virtual void OnJoyHat(SDL_JoystickID which, Uint8 hat, Uint8 value);
|
||||||
|
|
||||||
|
virtual void OnJoyBall(SDL_JoystickID which, Uint8 ball, Sint16 xrel, Sint16 yrel);
|
||||||
|
|
||||||
|
virtual void OnMinimize();
|
||||||
|
|
||||||
|
virtual void OnRestore();
|
||||||
|
|
||||||
|
virtual void OnResize(int w, int h);
|
||||||
|
|
||||||
|
virtual void OnExpose();
|
||||||
|
|
||||||
|
virtual void OnExit();
|
||||||
|
|
||||||
|
virtual void OnUser(Uint32 type, int code, void* data1, void* data2);
|
||||||
|
|
||||||
|
private:
|
||||||
|
void OnWindowsEvent(const SDL_Event& event);
|
||||||
|
void OnMouseButtonDown(const SDL_Event& event);
|
||||||
|
void OnMouseButtonUp(const SDL_Event& event);
|
||||||
|
|
||||||
|
private:
|
||||||
|
/// Variables
|
||||||
|
signed int m_id;// = 0
|
||||||
|
GUIHelpers::eEventType m_eventType;
|
||||||
|
};/// END CLASS DEFINITION cGUIEvent
|
||||||
|
}/// END NAMESPACE DEFINITION GUIEventEngine
|
||||||
|
#endif/// END IFNDEF _CGUIEVENT_HPP_
|
||||||
@@ -0,0 +1,42 @@
|
|||||||
|
#include "cGUIEventHandler.hpp"
|
||||||
|
|
||||||
|
using GUIEventEngine::cGUIEventHandler;
|
||||||
|
|
||||||
|
cGUIEventHandler::cGUIEventHandler()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
cGUIEventHandler::~cGUIEventHandler()
|
||||||
|
{
|
||||||
|
for (unsigned int i = 0; i < m_events.size(); ++i) {
|
||||||
|
delete m_events[i];
|
||||||
|
m_events[i] = nullptr;
|
||||||
|
}
|
||||||
|
m_events.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Functions
|
||||||
|
void cGUIEventHandler::CheckEvents()
|
||||||
|
{
|
||||||
|
SDL_Event event;
|
||||||
|
while (SDL_PollEvent(&event)) {
|
||||||
|
std::vector<GUIEventEngine::cGUIEvent*>::iterator it;
|
||||||
|
|
||||||
|
for (it = m_events.begin(); it < m_events.end(); it++) {
|
||||||
|
(*it)->OnEvent(event);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void cGUIEventHandler::AddEvents(GUIEventEngine::cGUIEvent* event )
|
||||||
|
{
|
||||||
|
m_events.push_back(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Sets
|
||||||
|
|
||||||
|
/// Gets
|
||||||
|
std::vector<GUIEventEngine::cGUIEvent*>& cGUIEventHandler::getEvents()
|
||||||
|
{
|
||||||
|
return m_events;
|
||||||
|
}
|
||||||
@@ -0,0 +1,41 @@
|
|||||||
|
#ifndef _CGUIEVENTHANDLER_HPP_
|
||||||
|
#define _CGUIEVENTHANDLER_HPP_
|
||||||
|
|
||||||
|
/*** C++ STL Files ***/
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
/*** Custom Header Files ***/
|
||||||
|
#include "../GUIHelpers/Enums.hpp"
|
||||||
|
|
||||||
|
/*** DLL Header File ***/
|
||||||
|
#include "dllExport.h"
|
||||||
|
|
||||||
|
#include "cGUIEvent.hpp"
|
||||||
|
|
||||||
|
namespace GUIEventEngine {
|
||||||
|
class EXPORT_FROM_MYDLL cGUIEventHandler
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
cGUIEventHandler();
|
||||||
|
virtual ~cGUIEventHandler();
|
||||||
|
|
||||||
|
bool operator == (const cGUIEventHandler& other);
|
||||||
|
|
||||||
|
/// Functions
|
||||||
|
virtual void CheckEvents();
|
||||||
|
|
||||||
|
void AddEvents( GUIEventEngine::cGUIEvent* event );
|
||||||
|
|
||||||
|
/// Sets
|
||||||
|
|
||||||
|
/// Gets
|
||||||
|
std::vector<GUIEventEngine::cGUIEvent*>& getEvents();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private:
|
||||||
|
/// Variables
|
||||||
|
std::vector<GUIEventEngine::cGUIEvent*> m_events;
|
||||||
|
};/// END CLASS DEFINITION cGUIEvent
|
||||||
|
}/// END NAMESPACE DEFINITION GUIEventEngine
|
||||||
|
#endif/// END IFNDEF _CGUIEVENTHANDLER_HPP_
|
||||||
@@ -42,5 +42,12 @@ namespace GUIHelpers {
|
|||||||
BOTTOM,
|
BOTTOM,
|
||||||
LEFT
|
LEFT
|
||||||
};/// END enum DEFINITION eAlign
|
};/// END enum DEFINITION eAlign
|
||||||
|
|
||||||
|
enum EXPORT_FROM_MYDLL eEventType : unsigned int
|
||||||
|
{
|
||||||
|
DEFAULT_EVENT = 0,
|
||||||
|
/// cButton Press
|
||||||
|
BUTTON
|
||||||
|
};/// END enum DEFINITION eEventType
|
||||||
}/// END NAMESPACE DEFINITION GUIEngine
|
}/// END NAMESPACE DEFINITION GUIEngine
|
||||||
#endif/// END IFNDEF _ENUMS_HPP_
|
#endif/// END IFNDEF _ENUMS_HPP_
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
#ifndef _CGUIEVENT_HPP_
|
||||||
|
#define _CGUIEVENT_HPP_
|
||||||
|
|
||||||
|
/*** Custom Header Files ***/
|
||||||
|
#include "Enums.hpp"
|
||||||
|
|
||||||
|
/*** DLL Header File ***/
|
||||||
|
#include "dllExport.h"
|
||||||
|
|
||||||
|
namespace GUIHelpers {
|
||||||
|
class EXPORT_FROM_MYDLL cGUIEvent
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
cGUIEvent( const GUIHelpers::eEventType eventType );
|
||||||
|
virtual ~cGUIEvent();
|
||||||
|
|
||||||
|
bool operator == ( const cGUIEvent& other );
|
||||||
|
|
||||||
|
/// Functions
|
||||||
|
|
||||||
|
/// Sets
|
||||||
|
|
||||||
|
/// Gets
|
||||||
|
|
||||||
|
private:
|
||||||
|
/// Variables
|
||||||
|
GUIHelpers::eEventType m_eventType;
|
||||||
|
};/// END CLASS DEFINITION cGUIEvent
|
||||||
|
}/// END NAMESPACE DEFINITION GUIEngine
|
||||||
|
#endif/// END IFNDEF _CGUIEVENT_HPP_
|
||||||
@@ -12,12 +12,10 @@ using MathEngine::iVector4;
|
|||||||
|
|
||||||
/*static*/ const cString cButton::sNAME = "button";
|
/*static*/ const cString cButton::sNAME = "button";
|
||||||
|
|
||||||
cButton::cButton()
|
|
||||||
{}
|
|
||||||
|
|
||||||
cButton::cButton( cWindow* parent, const signed int id, const GUIHelpers::eAlign align /*= sALIGN*/, const GUIHelpers::eLayout layout /*= sLAYOUT*/,
|
cButton::cButton( cWindow* parent, const signed int id, const GUIHelpers::eAlign align /*= sALIGN*/, const GUIHelpers::eLayout layout /*= sLAYOUT*/,
|
||||||
const GUIHelpers::Position& pos /*= sPOSITION*/, const GUIHelpers::Size& size /*= sSIZE*/, const GUIHelpers::Padding& padding/* = sPADDING*/,
|
const GUIHelpers::Position& pos /*= sPOSITION*/, const GUIHelpers::Size& size /*= sSIZE*/, const GUIHelpers::Padding& padding/* = sPADDING*/,
|
||||||
const cString& name /*= sNAME*/, VideoEngine::cImage** image /*= nullptr*/ )
|
const cString& name /*= sNAME*/, VideoEngine::cImage** image /*= nullptr*/ )
|
||||||
|
: GUIEventEngine::cButtonEvent(id)
|
||||||
{
|
{
|
||||||
Create(parent, id, align, layout, pos, size, padding, name, image);
|
Create(parent, id, align, layout, pos, size, padding, name, image);
|
||||||
// mp_texture = nullptr;
|
// mp_texture = nullptr;
|
||||||
@@ -57,7 +55,7 @@ void cButton::Display()
|
|||||||
|
|
||||||
m_sprite.setPosition(cWindow::getPosition());
|
m_sprite.setPosition(cWindow::getPosition());
|
||||||
m_sprite.Draw();
|
m_sprite.Draw();
|
||||||
m_sprite.SaveImage("test.bmp", "xml/");
|
//m_sprite.SaveImage("test.bmp", "xml/");
|
||||||
cWindow::Display();
|
cWindow::Display();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -19,17 +19,16 @@
|
|||||||
/*** Custom Header Files ***/
|
/*** Custom Header Files ***/
|
||||||
#include "cLayout.hpp"
|
#include "cLayout.hpp"
|
||||||
#include "../UtilityEngine/cString.hpp"
|
#include "../UtilityEngine/cString.hpp"
|
||||||
#include "../EventEngine/cEvent.hpp"
|
#include "GUIEventEngine/cButtonEvent.hpp"
|
||||||
|
|
||||||
using UtilityEngine::cString;
|
using UtilityEngine::cString;
|
||||||
|
|
||||||
namespace GUIEngine {
|
namespace GUIEngine {
|
||||||
class EXPORT_FROM_MYDLL cButton : public cLayout, public EventEngine::cEvent
|
class EXPORT_FROM_MYDLL cButton : public cLayout, public GUIEventEngine::cButtonEvent
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static const cString sNAME; /*= "button";*/
|
static const cString sNAME; /*= "button";*/
|
||||||
|
|
||||||
cButton();
|
|
||||||
cButton( cWindow* parent, const signed int id, const GUIHelpers::eAlign align = sALIGN, const GUIHelpers::eLayout layout = sLAYOUT,
|
cButton( cWindow* parent, const signed int id, const GUIHelpers::eAlign align = sALIGN, const GUIHelpers::eLayout layout = sLAYOUT,
|
||||||
const GUIHelpers::Position& pos = sPOSITION, const GUIHelpers::Size& size = sSIZE, const GUIHelpers::Padding& padding = sPADDING,
|
const GUIHelpers::Position& pos = sPOSITION, const GUIHelpers::Size& size = sSIZE, const GUIHelpers::Padding& padding = sPADDING,
|
||||||
const cString& name = sNAME, VideoEngine::cImage** image = nullptr );
|
const cString& name = sNAME, VideoEngine::cImage** image = nullptr );
|
||||||
@@ -53,7 +52,6 @@ namespace GUIEngine {
|
|||||||
virtual const GUIHelpers::RGBA& getDebugColour() const;
|
virtual const GUIHelpers::RGBA& getDebugColour() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void CreateLabel();
|
|
||||||
void GenerateImage();
|
void GenerateImage();
|
||||||
void GenerateTexture();
|
void GenerateTexture();
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,6 @@
|
|||||||
|
|
||||||
#include "../UtilityEngine/cUtility.hpp"
|
#include "../UtilityEngine/cUtility.hpp"
|
||||||
#include "GUIHelpers/Enums.hpp"
|
#include "GUIHelpers/Enums.hpp"
|
||||||
#include "cButton.hpp"
|
|
||||||
|
|
||||||
#include "GUIHelpers/cXMLoader.hpp"
|
#include "GUIHelpers/cXMLoader.hpp"
|
||||||
|
|
||||||
|
|||||||
@@ -1,72 +0,0 @@
|
|||||||
#include "cTextButton.hpp"
|
|
||||||
|
|
||||||
using GUIEngine::cTextButton;
|
|
||||||
|
|
||||||
/*static*/ const cString cTextButton::sNAME = "textButton";
|
|
||||||
|
|
||||||
cTextButton::cTextButton( cWindow* parent, const signed int id, const cString& text, const GUIHelpers::eAlign align /*= GUIHelpers::eAlign::CENTER*/,
|
|
||||||
const GUIHelpers::eLayout layout /*= GUIHelpers::eLayout::FILL_PARENT*/, const GUIHelpers::Position& pos /*= POSITION*/,
|
|
||||||
const GUIHelpers::Size& size /*= SIZE*/, const GUIHelpers::Padding& padding /*= PADDING*/, const cString& name /*= NAME*/ )
|
|
||||||
: m_label(this, -1, text)
|
|
||||||
{
|
|
||||||
Create(parent, id, text, align, layout, pos, size, padding, name);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*virtual*/ cTextButton::~cTextButton()
|
|
||||||
{}
|
|
||||||
|
|
||||||
///Functions
|
|
||||||
void cTextButton::Create( cWindow* parent, const signed int id, const cString& text, const GUIHelpers::eAlign align /*= GUIHelpers::eAlign::CENTER*/,
|
|
||||||
const GUIHelpers::eLayout layout /*= GUIHelpers::eLayout::FILL_PARENT*/, const GUIHelpers::Position& pos /*= POSITION*/,
|
|
||||||
const GUIHelpers::Size& size /*= SIZE*/, const GUIHelpers::Padding& padding /*= PADDING*/, const cString& name /*= NAME*/ )
|
|
||||||
{
|
|
||||||
cButton::Create(parent, id, align, layout, pos, size, padding, name);
|
|
||||||
setText(text);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Sets
|
|
||||||
void cTextButton::setText( const cString& text )
|
|
||||||
{
|
|
||||||
m_label.setText(text);
|
|
||||||
}
|
|
||||||
|
|
||||||
void cTextButton::setTextColour( const GUIHelpers::RGBA& colour )
|
|
||||||
{
|
|
||||||
m_label.setFontColour(colour);
|
|
||||||
}
|
|
||||||
|
|
||||||
void cTextButton::setTextSize( const unsigned long int size )
|
|
||||||
{
|
|
||||||
m_label.setSize(size);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Gets
|
|
||||||
const cString& cTextButton::getText() const
|
|
||||||
{
|
|
||||||
return m_label.getText();
|
|
||||||
}
|
|
||||||
|
|
||||||
const GUIHelpers::RGBA& cTextButton::getTextColour()
|
|
||||||
{
|
|
||||||
return m_label.getFontColour();
|
|
||||||
}
|
|
||||||
|
|
||||||
const unsigned long int cTextButton::getTextSize()
|
|
||||||
{
|
|
||||||
return m_label.getFontSize();
|
|
||||||
}
|
|
||||||
|
|
||||||
/*virtual*/ const GUIHelpers::eType cTextButton::getType() const
|
|
||||||
{
|
|
||||||
return GUIHelpers::eType::CTEXTBUTTON;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Private
|
|
||||||
void CreateLabel()
|
|
||||||
{}
|
|
||||||
|
|
||||||
void GenerateImage()
|
|
||||||
{}
|
|
||||||
|
|
||||||
void GenerateTexture()
|
|
||||||
{}
|
|
||||||
@@ -1,63 +0,0 @@
|
|||||||
#ifndef _CTEXTBUTTON_HPP_
|
|
||||||
#define _CTEXTBUTTON_HPP_
|
|
||||||
|
|
||||||
/*** SDL Header Files ***/
|
|
||||||
#include <SDL.h>
|
|
||||||
|
|
||||||
/*** Custom Header Files ***/
|
|
||||||
#include "cButton.hpp"
|
|
||||||
#include "cLabel.hpp"
|
|
||||||
|
|
||||||
#include "GUIHelpers/Enums.hpp"
|
|
||||||
#include "GUIHelpers/GUIUtility.hpp"
|
|
||||||
#include "../VideoEngine/cSprite.hpp"
|
|
||||||
#include "../VideoEngine/cImage.hpp"
|
|
||||||
#include "../MathEngine/iVector/iVector2.hpp"
|
|
||||||
|
|
||||||
/*** DLL Header File ***/
|
|
||||||
#include "dllExport.h"
|
|
||||||
|
|
||||||
/*** Custom Header Files ***/
|
|
||||||
#include "../UtilityEngine/cString.hpp"
|
|
||||||
|
|
||||||
using UtilityEngine::cString;
|
|
||||||
|
|
||||||
namespace GUIEngine {
|
|
||||||
class EXPORT_FROM_MYDLL cTextButton : public cButton
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
static const cString sNAME; /*= "button";*/
|
|
||||||
|
|
||||||
cTextButton( cWindow* parent, const signed int id, const cString& text, const GUIHelpers::eAlign align = GUIHelpers::eAlign::CENTER,
|
|
||||||
const GUIHelpers::eLayout layout = GUIHelpers::eLayout::FILL_PARENT, const GUIHelpers::Position& pos = sPOSITION,
|
|
||||||
const GUIHelpers::Size& size = sSIZE, const GUIHelpers::Padding& padding = sPADDING, const cString& name = sNAME );
|
|
||||||
virtual ~cTextButton();
|
|
||||||
|
|
||||||
/// Functions
|
|
||||||
void Create( cWindow* parent, const signed int id, const cString& text, const GUIHelpers::eAlign align = GUIHelpers::eAlign::CENTER,
|
|
||||||
const GUIHelpers::eLayout layout = GUIHelpers::eLayout::FILL_PARENT, const GUIHelpers::Position& pos = sPOSITION,
|
|
||||||
const GUIHelpers::Size& size = sSIZE, const GUIHelpers::Padding& padding = sPADDING, const cString& name = sNAME );
|
|
||||||
|
|
||||||
/// Sets
|
|
||||||
void setText( const cString& text );
|
|
||||||
void setTextColour( const GUIHelpers::RGBA& colour );
|
|
||||||
void setTextSize( const unsigned long int size );
|
|
||||||
|
|
||||||
/// Gets
|
|
||||||
const cString& getText() const;
|
|
||||||
const GUIHelpers::RGBA& getTextColour();
|
|
||||||
const unsigned long int getTextSize();
|
|
||||||
|
|
||||||
virtual const GUIHelpers::eType getType() const;
|
|
||||||
|
|
||||||
private:
|
|
||||||
void CreateLabel();
|
|
||||||
void GenerateImage();
|
|
||||||
void GenerateTexture();
|
|
||||||
|
|
||||||
private:
|
|
||||||
/// Variables
|
|
||||||
cLabel m_label;/// = nullptr
|
|
||||||
};/// END CLASS DEFINITION cButton
|
|
||||||
}/// END NAMESPACE DEFINITION GUIEngine
|
|
||||||
#endif/// END IFNDEF _CBUTTON_HPP_
|
|
||||||
@@ -1,6 +1,5 @@
|
|||||||
#include "cWindow.hpp"
|
#include "cWindow.hpp"
|
||||||
|
|
||||||
|
|
||||||
#include "../FXEngine/cGFX.hpp"
|
#include "../FXEngine/cGFX.hpp"
|
||||||
#include "../UtilityEngine/cUtility.hpp"
|
#include "../UtilityEngine/cUtility.hpp"
|
||||||
|
|
||||||
@@ -257,6 +256,21 @@ const GUIHelpers::Size cWindow::getSize( const bool pad /*= true*/ ) const
|
|||||||
return rtn;
|
return rtn;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const GUIHelpers::Area cWindow::getArea( const bool pad /*= false*/ ) const
|
||||||
|
{
|
||||||
|
GUIHelpers::Area rtn = { 0, 0, 0, 0 };
|
||||||
|
|
||||||
|
GUIHelpers::Position tmp = getPosition(false);
|
||||||
|
rtn.x = tmp.x;
|
||||||
|
rtn.y = tmp.y;
|
||||||
|
|
||||||
|
GUIHelpers::Size tmp2 = getSize(false);
|
||||||
|
rtn.w = tmp2.x;
|
||||||
|
rtn.h = tmp2.y;
|
||||||
|
|
||||||
|
return rtn;
|
||||||
|
}
|
||||||
|
|
||||||
const GUIHelpers::Padding& cWindow::getPadding() const
|
const GUIHelpers::Padding& cWindow::getPadding() const
|
||||||
{
|
{
|
||||||
return m_padding;
|
return m_padding;
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
#ifndef _CWINDOW_HPP_
|
#ifndef _CWINDOW_HPP_
|
||||||
#define _CWINDOW_HPP_
|
#define _CWINDOW_HPP_
|
||||||
|
|
||||||
|
/*** C++ STL Files ***/
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
/*** SDL Header Files ***/
|
/*** SDL Header Files ***/
|
||||||
#include <SDL.h>
|
#include <SDL.h>
|
||||||
|
|
||||||
@@ -53,7 +56,7 @@ namespace GUIEngine {
|
|||||||
void AddChild( cWindow* obj );
|
void AddChild( cWindow* obj );
|
||||||
|
|
||||||
const bool RemoveChild( cWindow* obj );
|
const bool RemoveChild( cWindow* obj );
|
||||||
|
|
||||||
/// Sets
|
/// Sets
|
||||||
static void PositionDefault( const GUIHelpers::Position& pos );
|
static void PositionDefault( const GUIHelpers::Position& pos );
|
||||||
static void SizeDefault( const GUIHelpers::Size& size );
|
static void SizeDefault( const GUIHelpers::Size& size );
|
||||||
@@ -81,6 +84,7 @@ namespace GUIEngine {
|
|||||||
const GUIHelpers::eLayout getLayout() const;
|
const GUIHelpers::eLayout getLayout() const;
|
||||||
const GUIHelpers::Position getPosition( const bool pad = true ) const;
|
const GUIHelpers::Position getPosition( const bool pad = true ) const;
|
||||||
const GUIHelpers::Size getSize( const bool pad = true ) const;
|
const GUIHelpers::Size getSize( const bool pad = true ) const;
|
||||||
|
const GUIHelpers::Area getArea( const bool pad = false ) const;
|
||||||
const GUIHelpers::Padding& getPadding() const;
|
const GUIHelpers::Padding& getPadding() const;
|
||||||
const GUIHelpers::Size& getContentSize() const;
|
const GUIHelpers::Size& getContentSize() const;
|
||||||
const cString& getName() const;
|
const cString& getName() const;
|
||||||
|
|||||||
@@ -0,0 +1,136 @@
|
|||||||
|
#include "cInside.hpp"
|
||||||
|
|
||||||
|
using MathEngine::cInside;
|
||||||
|
using MathEngine::Vector4;
|
||||||
|
using MathEngine::Vector2;
|
||||||
|
using MathEngine::iVector4;
|
||||||
|
using MathEngine::iVector2;
|
||||||
|
|
||||||
|
cInside::cInside()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
cInside::~cInside()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Functions
|
||||||
|
/*static*/ const Vector2 cInside::Inside(const Vector4& a, const Vector4& b)
|
||||||
|
{
|
||||||
|
Vector2 rtn;
|
||||||
|
rtn.x = 0.0f;
|
||||||
|
rtn.y = 0.0f;
|
||||||
|
|
||||||
|
/// Check if left side of b is inside of a
|
||||||
|
if (b.x < a.x)
|
||||||
|
rtn.x = a.x - b.x;
|
||||||
|
/// Check if right side of b is inside of a
|
||||||
|
if ((b.x + b.z) > (a.x + a.z))
|
||||||
|
rtn.x = (a.x + a.z) - (b.x + b.z);
|
||||||
|
/// Check if top side of b is inside of a
|
||||||
|
if (b.y < a.y)
|
||||||
|
rtn.y = a.y - b.y;
|
||||||
|
/// Check if bottom side of b is inside of a
|
||||||
|
if ((b.y + b.w) > (a.y + a.w))
|
||||||
|
rtn.y = (a.y + a.w) - (b.y + b.w);
|
||||||
|
|
||||||
|
return rtn;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*static*/ const Vector2 cInside::Inside(const SDL_Rect& a, const Vector4& b)
|
||||||
|
{
|
||||||
|
Vector4 temp = a;
|
||||||
|
|
||||||
|
return cInside::Inside(temp, b);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*static*/ const Vector2 cInside::Inside(const Vector4& a, const SDL_Rect& b)
|
||||||
|
{
|
||||||
|
Vector4 temp = b;
|
||||||
|
|
||||||
|
return cInside::Inside(a, temp);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*static*/ const bool cInside::isInside(const signed long int x, const signed long int y, const SDL_Rect& inside)
|
||||||
|
{
|
||||||
|
iVector4 temp = inside;
|
||||||
|
return cInside::isInside(x, y, temp);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*static*/ const bool cInside::isInside(const signed long int x, const signed long int y, const iVector4& inside)
|
||||||
|
{
|
||||||
|
bool rtn = false;
|
||||||
|
if ((inside.x < x) && (inside.w > x)) {
|
||||||
|
if ((inside.y < y) && (inside.z > y))
|
||||||
|
rtn = true;
|
||||||
|
}
|
||||||
|
return rtn;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*static*/ const iVector2 cInside::Inside(const SDL_Rect& a, const SDL_Rect& b)
|
||||||
|
{
|
||||||
|
iVector2 rtn;
|
||||||
|
rtn.x = 0.0f;
|
||||||
|
rtn.y = 0.0f;
|
||||||
|
|
||||||
|
/// Check if left side of b is inside of a
|
||||||
|
if (b.x < a.x)
|
||||||
|
rtn.x = (float)(b.x - a.x);
|
||||||
|
/// Check if right side of b is inside of a
|
||||||
|
if ((b.x + b.w) > (a.x + a.w))
|
||||||
|
rtn.x = (float)((b.x + b.w) - (a.x + a.w));
|
||||||
|
/// Check if top side of b is inside of a
|
||||||
|
if (b.y < a.y)
|
||||||
|
rtn.y = (float)(b.y - a.y);
|
||||||
|
/// Check if bottom side of b is inside of a
|
||||||
|
if ((b.y + b.h) > (a.y + a.h))
|
||||||
|
rtn.y = (float)((b.y + b.h) - (a.y + a.h));
|
||||||
|
|
||||||
|
return rtn;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*static*/ const iVector2 cInside::Inside(const iVector4& a, const iVector4& b)
|
||||||
|
{
|
||||||
|
iVector2 rtn;
|
||||||
|
rtn.x = 0;
|
||||||
|
rtn.y = 0;
|
||||||
|
|
||||||
|
/// Check if left side of b is inside of a
|
||||||
|
if (b.x < a.x)
|
||||||
|
rtn.x = b.x - a.x;
|
||||||
|
/// Check if right side of b is inside of a
|
||||||
|
if ((b.x + b.z) > (a.x + a.z))
|
||||||
|
rtn.x = (b.x + b.z) - (a.x + a.z);
|
||||||
|
/// Check if top side of b is inside of a
|
||||||
|
if (b.y < a.y)
|
||||||
|
rtn.y = b.y - a.y;
|
||||||
|
/// Check if bottom side of b is inside of a
|
||||||
|
if ((b.y + b.w) > (a.y + a.w))
|
||||||
|
rtn.y = (b.y + b.w) - (a.y + a.w);
|
||||||
|
|
||||||
|
return rtn;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*static*/ const iVector2 cInside::Inside(const SDL_Rect& a, const iVector4& b)
|
||||||
|
{
|
||||||
|
iVector4 temp = a;
|
||||||
|
|
||||||
|
return cInside::Inside(temp, b);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*static*/ const iVector2 cInside::Inside(const iVector4& a, const SDL_Rect& b)
|
||||||
|
{
|
||||||
|
return cInside::Inside(b, a);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*static*/ const Vector2 cInside::Inside(const iVector4& a, const Vector4& b)
|
||||||
|
{
|
||||||
|
Vector4 temp = a;
|
||||||
|
|
||||||
|
return cInside::Inside(temp, b);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*static*/ const Vector2 cInside::Inside(const Vector4& a, const iVector4& b)
|
||||||
|
{
|
||||||
|
return cInside::Inside(b, a);
|
||||||
|
}
|
||||||
@@ -0,0 +1,51 @@
|
|||||||
|
#ifndef _CINSIDE_HPP_
|
||||||
|
#define _CINSIDE_HPP_
|
||||||
|
|
||||||
|
/*** SDL Header Files ***/
|
||||||
|
#include <SDL.h>
|
||||||
|
|
||||||
|
/*** DLL Header File ***/
|
||||||
|
#include "dllExport.h"
|
||||||
|
|
||||||
|
/*** Custom Header File ***/
|
||||||
|
#include "Vector/Vector2.hpp"
|
||||||
|
#include "iVector/iVector2.hpp"
|
||||||
|
|
||||||
|
#include "Vector/Vector4.hpp"
|
||||||
|
#include "iVector/iVector4.hpp"
|
||||||
|
|
||||||
|
namespace MathEngine {
|
||||||
|
class EXPORT_FROM_MYDLL cInside
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
cInside();
|
||||||
|
~cInside();
|
||||||
|
|
||||||
|
public:
|
||||||
|
/// Functions
|
||||||
|
/* returns the Vector2 were a over laps b */
|
||||||
|
static const Vector2 Inside(const Vector4& a, const Vector4& b);
|
||||||
|
/* returns the Vector2 were a over laps b */
|
||||||
|
static const Vector2 Inside(const SDL_Rect& a, const Vector4& b);
|
||||||
|
/* returns the Vector2 were a over laps b */
|
||||||
|
static const Vector2 Inside(const Vector4& a, const SDL_Rect& b);
|
||||||
|
|
||||||
|
/* returns true if xy are inside SDL_Rect */
|
||||||
|
static const bool isInside(const signed long int x, const signed long int y, const SDL_Rect& inside);
|
||||||
|
/* returns true if xy are inside iVector4 */
|
||||||
|
static const bool isInside(const signed long int x, const signed long int y, const iVector4& inside);
|
||||||
|
|
||||||
|
/* returns the iVector2 were a over laps b */
|
||||||
|
static const iVector2 Inside(const SDL_Rect& a, const SDL_Rect& b);
|
||||||
|
/* returns the iVector2 were a over laps b */
|
||||||
|
static const iVector2 Inside(const iVector4& a, const iVector4& b);
|
||||||
|
/* returns the iVector2 were a over laps b */
|
||||||
|
static const iVector2 Inside(const SDL_Rect& a, const iVector4& b);
|
||||||
|
/* returns the iVector2 were a over laps b */
|
||||||
|
static const iVector2 Inside(const iVector4& a, const SDL_Rect& b);
|
||||||
|
|
||||||
|
static const Vector2 Inside(const iVector4& a, const Vector4& b);
|
||||||
|
static const Vector2 Inside(const Vector4& a, const iVector4& b);
|
||||||
|
};/// END CLASS DEFINITION cInside
|
||||||
|
}/// END NAMESPACE DEFINITION MathEngine
|
||||||
|
#endif/// END IFNDEF _CINSIDE_HPP_
|
||||||
@@ -132,8 +132,11 @@
|
|||||||
<ClInclude Include="TrooperEngine\GUIEngine\cLayout.hpp" />
|
<ClInclude Include="TrooperEngine\GUIEngine\cLayout.hpp" />
|
||||||
<ClInclude Include="TrooperEngine\GUIEngine\cPanel.hpp" />
|
<ClInclude Include="TrooperEngine\GUIEngine\cPanel.hpp" />
|
||||||
<ClInclude Include="TrooperEngine\GUIEngine\cLabel.hpp" />
|
<ClInclude Include="TrooperEngine\GUIEngine\cLabel.hpp" />
|
||||||
<ClInclude Include="TrooperEngine\GUIEngine\cTextButton.hpp" />
|
|
||||||
<ClInclude Include="TrooperEngine\GUIEngine\cWindow.hpp" />
|
<ClInclude Include="TrooperEngine\GUIEngine\cWindow.hpp" />
|
||||||
|
<ClInclude Include="TrooperEngine\GUIEngine\GUIEventEngine\cButtonEvent.hpp" />
|
||||||
|
<ClInclude Include="TrooperEngine\GUIEngine\GUIEventEngine\cGUIEvent.hpp" />
|
||||||
|
<ClInclude Include="TrooperEngine\GUIEngine\GUIEventEngine\cGUIEventHandler.hpp" />
|
||||||
|
<ClInclude Include="TrooperEngine\GUIEngine\GUIEventEngine\Event.h" />
|
||||||
<ClInclude Include="TrooperEngine\GUIEngine\GUIHelpers\cTexture.hpp" />
|
<ClInclude Include="TrooperEngine\GUIEngine\GUIHelpers\cTexture.hpp" />
|
||||||
<ClInclude Include="TrooperEngine\GUIEngine\GUIHelpers\cObject.hpp" />
|
<ClInclude Include="TrooperEngine\GUIEngine\GUIHelpers\cObject.hpp" />
|
||||||
<ClInclude Include="TrooperEngine\GUIEngine\GUIHelpers\cXMLoader.hpp" />
|
<ClInclude Include="TrooperEngine\GUIEngine\GUIHelpers\cXMLoader.hpp" />
|
||||||
@@ -146,6 +149,7 @@
|
|||||||
<ClInclude Include="TrooperEngine\InputEngine\cMouse.hpp" />
|
<ClInclude Include="TrooperEngine\InputEngine\cMouse.hpp" />
|
||||||
<ClInclude Include="TrooperEngine\InputEngine\cTextInput.hpp" />
|
<ClInclude Include="TrooperEngine\InputEngine\cTextInput.hpp" />
|
||||||
<ClInclude Include="TrooperEngine\MathEngine\cCollision.hpp" />
|
<ClInclude Include="TrooperEngine\MathEngine\cCollision.hpp" />
|
||||||
|
<ClInclude Include="TrooperEngine\MathEngine\cInside.hpp" />
|
||||||
<ClInclude Include="TrooperEngine\MathEngine\iVector\iVector2.hpp" />
|
<ClInclude Include="TrooperEngine\MathEngine\iVector\iVector2.hpp" />
|
||||||
<ClInclude Include="TrooperEngine\MathEngine\iVector\iVector3.hpp" />
|
<ClInclude Include="TrooperEngine\MathEngine\iVector\iVector3.hpp" />
|
||||||
<ClInclude Include="TrooperEngine\MathEngine\iVector\iVector4.hpp" />
|
<ClInclude Include="TrooperEngine\MathEngine\iVector\iVector4.hpp" />
|
||||||
@@ -184,8 +188,10 @@
|
|||||||
<ClCompile Include="TrooperEngine\GUIEngine\cLayout.cpp" />
|
<ClCompile Include="TrooperEngine\GUIEngine\cLayout.cpp" />
|
||||||
<ClCompile Include="TrooperEngine\GUIEngine\cLabel.cpp" />
|
<ClCompile Include="TrooperEngine\GUIEngine\cLabel.cpp" />
|
||||||
<ClCompile Include="TrooperEngine\GUIEngine\cPanel.cpp" />
|
<ClCompile Include="TrooperEngine\GUIEngine\cPanel.cpp" />
|
||||||
<ClCompile Include="TrooperEngine\GUIEngine\cTextButton.cpp" />
|
|
||||||
<ClCompile Include="TrooperEngine\GUIEngine\cWindow.cpp" />
|
<ClCompile Include="TrooperEngine\GUIEngine\cWindow.cpp" />
|
||||||
|
<ClCompile Include="TrooperEngine\GUIEngine\GUIEventEngine\cButtonEvent.cpp" />
|
||||||
|
<ClCompile Include="TrooperEngine\GUIEngine\GUIEventEngine\cGUIEvent.cpp" />
|
||||||
|
<ClCompile Include="TrooperEngine\GUIEngine\GUIEventEngine\cGUIEventHandler.cpp" />
|
||||||
<ClCompile Include="TrooperEngine\GUIEngine\GUIHelpers\cObject.cpp" />
|
<ClCompile Include="TrooperEngine\GUIEngine\GUIHelpers\cObject.cpp" />
|
||||||
<ClCompile Include="TrooperEngine\GUIEngine\GUIHelpers\cTexture.cpp" />
|
<ClCompile Include="TrooperEngine\GUIEngine\GUIHelpers\cTexture.cpp" />
|
||||||
<ClCompile Include="TrooperEngine\GUIEngine\GUIHelpers\cXMLoader.cpp" />
|
<ClCompile Include="TrooperEngine\GUIEngine\GUIHelpers\cXMLoader.cpp" />
|
||||||
@@ -197,6 +203,7 @@
|
|||||||
<ClCompile Include="TrooperEngine\InputEngine\cMouse.cpp" />
|
<ClCompile Include="TrooperEngine\InputEngine\cMouse.cpp" />
|
||||||
<ClCompile Include="TrooperEngine\InputEngine\cTextInput.cpp" />
|
<ClCompile Include="TrooperEngine\InputEngine\cTextInput.cpp" />
|
||||||
<ClCompile Include="TrooperEngine\MathEngine\cCollision.cpp" />
|
<ClCompile Include="TrooperEngine\MathEngine\cCollision.cpp" />
|
||||||
|
<ClCompile Include="TrooperEngine\MathEngine\cInside.cpp" />
|
||||||
<ClCompile Include="TrooperEngine\MathEngine\iVector\iVector2.cpp" />
|
<ClCompile Include="TrooperEngine\MathEngine\iVector\iVector2.cpp" />
|
||||||
<ClCompile Include="TrooperEngine\MathEngine\iVector\iVector3.cpp" />
|
<ClCompile Include="TrooperEngine\MathEngine\iVector\iVector3.cpp" />
|
||||||
<ClCompile Include="TrooperEngine\MathEngine\iVector\iVector4.cpp" />
|
<ClCompile Include="TrooperEngine\MathEngine\iVector\iVector4.cpp" />
|
||||||
|
|||||||
@@ -58,6 +58,9 @@
|
|||||||
<Filter Include="TrooperEngine\TextTypeEngine\TextTypeHelpers">
|
<Filter Include="TrooperEngine\TextTypeEngine\TextTypeHelpers">
|
||||||
<UniqueIdentifier>{b13cf78d-bfda-4467-9cdc-79dcb63fd8a9}</UniqueIdentifier>
|
<UniqueIdentifier>{b13cf78d-bfda-4467-9cdc-79dcb63fd8a9}</UniqueIdentifier>
|
||||||
</Filter>
|
</Filter>
|
||||||
|
<Filter Include="TrooperEngine\GUIEngine\GUIEventEngine">
|
||||||
|
<UniqueIdentifier>{ecc37f2c-0d3c-425e-9db6-deed712faacd}</UniqueIdentifier>
|
||||||
|
</Filter>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="dllExportFiles\dllExport.h">
|
<ClInclude Include="dllExportFiles\dllExport.h">
|
||||||
@@ -198,9 +201,6 @@
|
|||||||
<ClInclude Include="TrooperEngine\GUIEngine\cLabel.hpp">
|
<ClInclude Include="TrooperEngine\GUIEngine\cLabel.hpp">
|
||||||
<Filter>TrooperEngine\GUIEngine</Filter>
|
<Filter>TrooperEngine\GUIEngine</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="TrooperEngine\GUIEngine\cTextButton.hpp">
|
|
||||||
<Filter>TrooperEngine\GUIEngine</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="TrooperEngine\GUIEngine\GUIHelpers\cXMLoader.hpp">
|
<ClInclude Include="TrooperEngine\GUIEngine\GUIHelpers\cXMLoader.hpp">
|
||||||
<Filter>TrooperEngine\GUIEngine\GUIHelpers</Filter>
|
<Filter>TrooperEngine\GUIEngine\GUIHelpers</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
@@ -219,6 +219,21 @@
|
|||||||
<ClInclude Include="TrooperEngine\GUIEngine\cSizer.hpp">
|
<ClInclude Include="TrooperEngine\GUIEngine\cSizer.hpp">
|
||||||
<Filter>TrooperEngine\GUIEngine</Filter>
|
<Filter>TrooperEngine\GUIEngine</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="TrooperEngine\GUIEngine\GUIEventEngine\cButtonEvent.hpp">
|
||||||
|
<Filter>TrooperEngine\GUIEngine\GUIEventEngine</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="TrooperEngine\MathEngine\cInside.hpp">
|
||||||
|
<Filter>TrooperEngine\MathEngine</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="TrooperEngine\GUIEngine\GUIEventEngine\Event.h">
|
||||||
|
<Filter>TrooperEngine\GUIEngine\GUIEventEngine</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="TrooperEngine\GUIEngine\GUIEventEngine\cGUIEvent.hpp">
|
||||||
|
<Filter>TrooperEngine\GUIEngine\GUIEventEngine</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="TrooperEngine\GUIEngine\GUIEventEngine\cGUIEventHandler.hpp">
|
||||||
|
<Filter>TrooperEngine\GUIEngine\GUIEventEngine</Filter>
|
||||||
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="TrooperEngine\AudioEngine\cAudio.cpp">
|
<ClCompile Include="TrooperEngine\AudioEngine\cAudio.cpp">
|
||||||
@@ -344,9 +359,6 @@
|
|||||||
<ClCompile Include="TrooperEngine\GUIEngine\cLabel.cpp">
|
<ClCompile Include="TrooperEngine\GUIEngine\cLabel.cpp">
|
||||||
<Filter>TrooperEngine\GUIEngine</Filter>
|
<Filter>TrooperEngine\GUIEngine</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="TrooperEngine\GUIEngine\cTextButton.cpp">
|
|
||||||
<Filter>TrooperEngine\GUIEngine</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="TrooperEngine\GUIEngine\GUIHelpers\cXMLoader.cpp">
|
<ClCompile Include="TrooperEngine\GUIEngine\GUIHelpers\cXMLoader.cpp">
|
||||||
<Filter>TrooperEngine\GUIEngine\GUIHelpers</Filter>
|
<Filter>TrooperEngine\GUIEngine\GUIHelpers</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
@@ -368,5 +380,17 @@
|
|||||||
<ClCompile Include="TrooperEngine\GUIEngine\cSizer.cpp">
|
<ClCompile Include="TrooperEngine\GUIEngine\cSizer.cpp">
|
||||||
<Filter>TrooperEngine\GUIEngine</Filter>
|
<Filter>TrooperEngine\GUIEngine</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="TrooperEngine\MathEngine\cInside.cpp">
|
||||||
|
<Filter>TrooperEngine\MathEngine</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="TrooperEngine\GUIEngine\GUIEventEngine\cButtonEvent.cpp">
|
||||||
|
<Filter>TrooperEngine\GUIEngine\GUIEventEngine</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="TrooperEngine\GUIEngine\GUIEventEngine\cGUIEvent.cpp">
|
||||||
|
<Filter>TrooperEngine\GUIEngine\GUIEventEngine</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="TrooperEngine\GUIEngine\GUIEventEngine\cGUIEventHandler.cpp">
|
||||||
|
<Filter>TrooperEngine\GUIEngine\GUIEventEngine</Filter>
|
||||||
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
||||||
@@ -70,7 +70,6 @@
|
|||||||
#include "../TrooperEngine/GUIEngine/cLayout.hpp"
|
#include "../TrooperEngine/GUIEngine/cLayout.hpp"
|
||||||
#include "../TrooperEngine/GUIEngine/cLabel.hpp"
|
#include "../TrooperEngine/GUIEngine/cLabel.hpp"
|
||||||
#include "../TrooperEngine/GUIEngine/cButton.hpp"
|
#include "../TrooperEngine/GUIEngine/cButton.hpp"
|
||||||
#include "../TrooperEngine/GUIEngine/cTextButton.hpp"
|
|
||||||
#include "../TrooperEngine/GUIEngine/cSizer.hpp"
|
#include "../TrooperEngine/GUIEngine/cSizer.hpp"
|
||||||
|
|
||||||
/*** GUIHelper ***/
|
/*** GUIHelper ***/
|
||||||
|
|||||||
Binary file not shown.
|
After Width: | Height: | Size: 57 KiB |
Reference in New Issue
Block a user