/********************************************************************
*
* Created: 15/7/2014 09:06
*
* File: fsCRollOverGui.h
*
* Author: Martin P King
*
* Purpose: Roll over that renders when the mouse is over any
* of the registered entities
*
*********************************************************************/
#ifndef fsCRollOverGuihdr
#define fsCRollOverGuihdr
#include <fsCore/src/fsCUniqueId.h>
#include <fsAppCore/src/components/gui/fsIMessageListenerGuiComponent.h>
#include <fsCore/fsPoint.h>
class fsITransformationComponent;
class fsCRollOverGui : public fsIMessageListenerGuiComponent
{
friend class fsCComponentFactory;
public:
static const fsCUniqueId mTypeId;
struct fsSRollOver
{
fsSRollOver(const fsStr& pTxt, fsCEntity* const pEnt) :
mTxt(pTxt),
mEnt(pEnt)
{
}
fsStr mTxt;
fsCEntity* mEnt;
};
static const fsCUniqueId mDeactivateMsg;
void candidatesDeregister();
void candidatesRegister(std::vector<fsSRollOver>& pCandidates);
void candidateRegister(const fsSRollOver& pCandidate);
void candidateDeRegister(fsCEntity* pEnt);
void listenersRegisterDo() override;
void listenersDeregisterDo() override;
fsBool messageProcessDo(const fsCUniqueId& pMessageType,
const fsIMessageDispatcher::sMessageParameters& pParam) override;
protected:
void initialiseFromVariableTableDo(const fsCVariableTable& pVars) override;
static fsIComponent* create(fsCEntity* pParent);
fsCRollOverGui(fsCEntity* pParent);
virtual ~fsCRollOverGui();<--- Destructor in derived class
void posSet(const fsPoint& pMousePos, fsCEntity* pEnt);
void textSet(const fsSRollOver& pRollOver);
fsBool newTarget(const fsSRollOver& pRollOver) const;
virtual void rollOverCandidatesCheck(const fsPoint& pPos);
std::vector<fsSRollOver> mRollOvers;
private:
fsITransformationComponent* transformationChildComponentGet() const;
void close();
void positionCorrectForScreenBoundry(fsPoint& pPos, fsS32 pTargetH, fsPoint pRollOverGuiSize);
void maxStrWidthCalculate(const fsCVariableTable& pVars);
fsS32 mStrWidthInPixels;
fsPoint mFixedPos;
};
#endif