2015-11-21 01:14:49 +00:00
|
|
|
#ifndef SPECTER_CONTROL_HPP
|
|
|
|
#define SPECTER_CONTROL_HPP
|
|
|
|
|
2015-12-06 01:24:51 +00:00
|
|
|
#include "View.hpp"
|
|
|
|
#include "HECL/CVar.hpp"
|
|
|
|
|
|
|
|
namespace Specter
|
|
|
|
{
|
|
|
|
|
|
|
|
struct IControlBinding
|
|
|
|
{
|
2015-12-13 21:00:30 +00:00
|
|
|
virtual const char* name() const=0;
|
2015-12-15 21:53:15 +00:00
|
|
|
virtual const char* help() const {return nullptr;}
|
2015-12-06 01:24:51 +00:00
|
|
|
};
|
|
|
|
|
2015-12-08 04:26:29 +00:00
|
|
|
struct IButtonBinding : IControlBinding
|
|
|
|
{
|
2015-12-14 04:56:02 +00:00
|
|
|
/** Pressed/Released while Hovering action,
|
|
|
|
* cancellable by holding the button and releasing outside */
|
|
|
|
virtual void activated(const boo::SWindowCoord& coord)=0;
|
2015-12-08 04:26:29 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct IFloatBinding : IControlBinding
|
|
|
|
{
|
|
|
|
virtual float getDefault() const {return 0.0;}
|
|
|
|
virtual std::pair<float,float> getBounds() const {return std::make_pair(FLT_MIN, FLT_MAX);}
|
|
|
|
virtual void changed(float val)=0;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct IIntBinding : IControlBinding
|
|
|
|
{
|
|
|
|
virtual int getDefault() const {return 0;}
|
|
|
|
virtual std::pair<int,int> getBounds() const {return std::make_pair(INT_MIN, INT_MAX);}
|
|
|
|
virtual void changed(int val)=0;
|
|
|
|
};
|
|
|
|
|
2015-12-18 03:26:10 +00:00
|
|
|
struct IStringBinding : IControlBinding
|
|
|
|
{
|
|
|
|
virtual std::string getDefault() const {return "";}
|
|
|
|
virtual void changed(const std::string& val)=0;
|
|
|
|
};
|
|
|
|
|
2015-12-06 01:24:51 +00:00
|
|
|
struct CVarControlBinding : IControlBinding
|
|
|
|
{
|
|
|
|
HECL::CVar* m_cvar;
|
|
|
|
CVarControlBinding(HECL::CVar* cvar)
|
|
|
|
: m_cvar(cvar) {}
|
2015-12-13 21:00:30 +00:00
|
|
|
const char* name() const {return m_cvar->name().c_str();}
|
|
|
|
const char* help() const {return m_cvar->rawHelp().c_str();}
|
2015-12-06 01:24:51 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class Control : public View
|
|
|
|
{
|
|
|
|
protected:
|
2015-12-10 03:14:38 +00:00
|
|
|
IControlBinding* m_controlBinding = nullptr;
|
2015-12-06 01:24:51 +00:00
|
|
|
public:
|
2015-12-10 03:14:38 +00:00
|
|
|
Control(ViewResources& res, View& parentView, IControlBinding* controlBinding);
|
2015-12-06 01:24:51 +00:00
|
|
|
void mouseDown(const boo::SWindowCoord&, boo::EMouseButton, boo::EModifierKey);
|
|
|
|
void mouseUp(const boo::SWindowCoord&, boo::EMouseButton, boo::EModifierKey);
|
|
|
|
void mouseEnter(const boo::SWindowCoord&);
|
|
|
|
void mouseLeave(const boo::SWindowCoord&);
|
|
|
|
|
2015-12-10 03:14:38 +00:00
|
|
|
IControlBinding* setControlBinding(IControlBinding* controlBinding);
|
2015-12-06 01:24:51 +00:00
|
|
|
};
|
2015-12-27 22:42:45 +00:00
|
|
|
|
|
|
|
class ITextInputView : public Control, public boo::ITextInputCallback
|
|
|
|
{
|
|
|
|
protected:
|
|
|
|
static std::recursive_mutex m_textInputLk;
|
|
|
|
ITextInputView(ViewResources& res, View& parentView,
|
|
|
|
IControlBinding* controlBinding)
|
|
|
|
: Control(res, parentView, controlBinding) {}
|
2015-12-27 23:25:10 +00:00
|
|
|
public:
|
|
|
|
virtual void clipboardCopy() {}
|
|
|
|
virtual void clipboardCut() {}
|
|
|
|
virtual void clipboardPaste() {}
|
2015-12-27 22:42:45 +00:00
|
|
|
};
|
2015-12-06 01:24:51 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2015-11-21 01:14:49 +00:00
|
|
|
#endif // SPECTER_CONTROL_HPP
|