mirror of https://github.com/AxioDL/metaforce.git
75 lines
2.3 KiB
C++
75 lines
2.3 KiB
C++
|
#ifndef SPECTER_PATHBUTTONS_HPP
|
||
|
#define SPECTER_PATHBUTTONS_HPP
|
||
|
|
||
|
#include "Button.hpp"
|
||
|
#include "ScrollView.hpp"
|
||
|
|
||
|
namespace Specter
|
||
|
{
|
||
|
|
||
|
struct IPathButtonsBinding
|
||
|
{
|
||
|
virtual void pathButtonActivated(size_t idx)=0;
|
||
|
};
|
||
|
|
||
|
class PathButtons : public ScrollView
|
||
|
{
|
||
|
struct ContentView : public View
|
||
|
{
|
||
|
PathButtons& m_pb;
|
||
|
boo::SWindowRect m_scissorRect;
|
||
|
|
||
|
void mouseDown(const boo::SWindowCoord&, boo::EMouseButton, boo::EModifierKey);
|
||
|
void mouseUp(const boo::SWindowCoord&, boo::EMouseButton, boo::EModifierKey);
|
||
|
void mouseMove(const boo::SWindowCoord&);
|
||
|
void mouseLeave(const boo::SWindowCoord&);
|
||
|
|
||
|
int nominalWidth() const
|
||
|
{
|
||
|
int ret = 0;
|
||
|
for (PathButton& b : m_pb.m_pathButtons)
|
||
|
ret += b.m_button.m_view->nominalWidth() + 2;
|
||
|
return ret;
|
||
|
}
|
||
|
int nominalHeight() const
|
||
|
{
|
||
|
return m_pb.m_pathButtons.size() ? m_pb.m_pathButtons[0].m_button.m_view->nominalHeight() : 0;
|
||
|
}
|
||
|
|
||
|
void resized(const boo::SWindowRect& root, const boo::SWindowRect& sub, const boo::SWindowRect& scissor);
|
||
|
void draw(boo::IGraphicsCommandQueue* gfxQ);
|
||
|
|
||
|
ContentView(ViewResources& res, PathButtons& pb)
|
||
|
: View(res, pb), m_pb(pb) {}
|
||
|
};
|
||
|
ViewChild<std::unique_ptr<ContentView>> m_contentView;
|
||
|
|
||
|
int m_pathButtonPending = -1;
|
||
|
IPathButtonsBinding& m_binding;
|
||
|
struct PathButton : IButtonBinding
|
||
|
{
|
||
|
PathButtons& m_pb;
|
||
|
size_t m_idx;
|
||
|
ViewChild<std::unique_ptr<Button>> m_button;
|
||
|
PathButton(PathButtons& pb, ViewResources& res, size_t idx, const HECL::SystemString& str)
|
||
|
: m_pb(pb), m_idx(idx)
|
||
|
{
|
||
|
m_button.m_view.reset(new Button(res, pb, this, HECL::SystemUTF8View(str).str()));
|
||
|
}
|
||
|
const char* name(const Control* control) const {return m_button.m_view->getText().c_str();}
|
||
|
void activated(const Button* button, const boo::SWindowCoord&) {m_pb.m_pathButtonPending = m_idx;}
|
||
|
};
|
||
|
friend struct PathButton;
|
||
|
std::vector<PathButton> m_pathButtons;
|
||
|
|
||
|
public:
|
||
|
PathButtons(ViewResources& res, View& parentView, IPathButtonsBinding& binding);
|
||
|
|
||
|
void setButtons(const std::vector<HECL::SystemString>& comps);
|
||
|
void setMultiplyColor(const Zeus::CColor& color);
|
||
|
};
|
||
|
|
||
|
}
|
||
|
|
||
|
#endif // SPECTER_PATHBUTTONS_HPP
|