metaforce/Runtime/GuiSys/CGuiSliderGroup.hpp

68 lines
1.8 KiB
C++
Raw Normal View History

2018-10-07 03:42:33 +00:00
#pragma once
2016-03-10 03:47:37 +00:00
2016-03-17 22:19:25 +00:00
#include <functional>
#include <memory>
#include "Runtime/GuiSys/CGuiCompoundWidget.hpp"
2016-03-10 03:47:37 +00:00
2018-12-08 05:30:43 +00:00
namespace urde {
class CSimplePool;
2016-03-10 03:47:37 +00:00
2018-12-08 05:30:43 +00:00
class CGuiSliderGroup : public CGuiCompoundWidget {
public:
2019-01-22 04:23:51 +00:00
enum class EState { None, Decreasing, Increasing, MouseMove };
private:
2018-12-08 05:30:43 +00:00
float xb8_minVal;
float xbc_maxVal;
float xc0_roundedCurVal;
float xc4_curVal;
float xc8_increment;
CGuiWidget* xcc_sliderRangeWidgets[2] = {};
std::function<void(CGuiSliderGroup*, float)> xd8_changeCallback;
EState xf0_state = EState::None;
union {
struct {
bool xf4_24_inputPending : 1;
2019-01-22 04:23:51 +00:00
mutable bool m_mouseInside : 1;
bool m_mouseDown : 1;
};
2019-01-22 04:23:51 +00:00
u32 _dummy = 0;
2018-12-08 05:30:43 +00:00
};
2019-01-22 04:23:51 +00:00
mutable float m_mouseT = 0.f;
2018-12-08 05:30:43 +00:00
void StartDecreasing();
void StartIncreasing();
2016-03-11 00:23:16 +00:00
public:
2018-12-08 05:30:43 +00:00
CGuiSliderGroup(const CGuiWidgetParms& parms, float a, float b, float c, float d);
FourCC GetWidgetTypeID() const override { return FOURCC('SLGP'); }
2018-12-08 05:30:43 +00:00
EState GetState() const { return xf0_state; }
void SetSelectionChangedCallback(std::function<void(CGuiSliderGroup*, float)>&& func);
void SetIncrement(float inc) { xc8_increment = inc; }
void SetMinVal(float min) {
xb8_minVal = min;
SetCurVal(xc0_roundedCurVal);
}
void SetMaxVal(float max) {
xbc_maxVal = max;
SetCurVal(xc0_roundedCurVal);
}
void SetCurVal(float cur);
float GetGurVal() const { return xc0_roundedCurVal; }
bool TestCursorHit(const zeus::CMatrix4f& vp, const zeus::CVector2f& point) const override;
2019-01-22 04:23:51 +00:00
void ProcessUserInput(const CFinalInput& input) override;
void Update(float dt) override;
2018-12-08 05:30:43 +00:00
bool AddWorkerWidget(CGuiWidget* worker) override;
CGuiWidget* GetWorkerWidget(int id) const override;
2018-12-08 05:30:43 +00:00
static std::shared_ptr<CGuiWidget> Create(CGuiFrame* frame, CInputStream& in, CSimplePool* sp);
2016-03-11 00:23:16 +00:00
};
2016-03-10 03:47:37 +00:00
2018-12-08 05:30:43 +00:00
} // namespace urde