/********************************************************************
*
* Created: 31/3/2014 14:38
*
* File: fsCSliderComponent.h
*
* Author: Mick Waites
*
* Purpose: Gui element generally used for volume settings.
*
*********************************************************************/
#ifndef fsCSliderComponenthdr
#define fsCSliderComponenthdr
#include <fsCore/src/fsCUniqueId.h>
#include "../../fsIGestureHandlingComponent.h"
class fsCBrush;
class fsCSliderComponent : public fsIGestureHandlingComponent
{
friend class fsCComponentFactory;
public:
struct sSliderMsgParam : public fsIMessageDispatcher::sMessageParameters
{
sSliderMsgParam(const fsStr& pParentName) : mParentName(pParentName), mValue(0.0f)
{
}
const fsStr& mParentName;
fsF32 mValue;
};
static const fsCUniqueId mTypeId;
static const fsCUniqueId mEventSliderMovedMsg;
static const fsCUniqueId mEventSliderReleasedMsg;
void valueSet(fsF32 pValue);
protected:
void initialiseDo() override;
fsBool acceptingInputGet() const override;
fsBool highlightSetDo() override;
void onDragStart(const fsPoint& pStartPos) override;
void onDragMove(const fsPoint& pCurrPos) override;
void onDragEnd(const fsPoint& pEndPos) override;
static fsIComponent* create(fsCEntity* pParent);
void initialiseFromVariableTableDo(const fsCVariableTable& pVars) override;
fsCSliderComponent(fsCEntity* pParent);
virtual ~fsCSliderComponent();<--- Destructor in derived class
sSliderMsgParam mMessageParams;
std::shared_ptr<fsCBrush> mBrush;
std::shared_ptr<fsCBrush> mOverBrush;
fsVec2d mOrigPointerPos;
fsPoint mKnobLeftPos;
fsF32 mRange;
fsF32 mOrigValue;
fsBool mPointerOver;
fsBool mWaitingForPointerUp;
fsBool mArc;
private:
void spriteInitialise(const fsCVariableTable& pVars);
void rangeAndPosInitialise(const fsCVariableTable& pVars);
void knobPositionSetByValue();
};
#endif