61 lines
1.3 KiB
C++
61 lines
1.3 KiB
C++
#include "DataModelV3/Gui/BaseButtonInstance.h"
|
|
using namespace B3D;
|
|
|
|
BaseButtonInstance::BaseButtonInstance(void) : Instance()
|
|
{
|
|
actionCode = 0;
|
|
callback = NULL;
|
|
}
|
|
|
|
void BaseButtonInstance::render(RenderDevice* rd)
|
|
{
|
|
//TODO make mouse a member of datamodel
|
|
//Vector2 pos = Vector2(g_usableApp->mouse.x,g_usableApp->mouse.y);
|
|
drawObj(rd, Vector2(0, 0), false);//g_usableApp->mouse.isMouseDown());
|
|
Instance::render(rd);
|
|
}
|
|
|
|
BaseButtonInstance::~BaseButtonInstance(void)
|
|
{
|
|
}
|
|
|
|
void BaseButtonInstance::setActionCode(int actionCode)
|
|
{
|
|
this->actionCode = actionCode;
|
|
}
|
|
|
|
void BaseButtonInstance::drawObj(RenderDevice* rd, Vector2 mousePos, bool mouseDown){}
|
|
|
|
bool BaseButtonInstance::mouseInButton(float mousex, float mousey, RenderDevice* rd){return false;}
|
|
|
|
void BaseButtonInstance::onMouseClick()
|
|
{
|
|
if(callback != NULL)
|
|
{
|
|
ActionParam param = {
|
|
this->getParentDataModel(),
|
|
this,
|
|
this->actionCode
|
|
};
|
|
callback(param);
|
|
}
|
|
}
|
|
|
|
void BaseButtonInstance::setCallback(void (*callback)(const ActionParam &actionParam))
|
|
{
|
|
this->callback = callback;
|
|
}
|
|
|
|
bool BaseButtonInstance::mouseInArea(float point1x, float point1y, float point2x, float point2y, float mousex, float mousey)
|
|
{
|
|
|
|
|
|
if(mousex >= point1x && mousey >= point1y)
|
|
{
|
|
if(mousex < point2x && mousey < point2y)
|
|
{
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
} |