metaforce/specter/lib/PathButtons.cpp

84 lines
2.9 KiB
C++
Raw Normal View History

2016-03-04 23:03:47 +00:00
#include "specter/PathButtons.hpp"
#include "specter/RootView.hpp"
#include "specter/ViewResources.hpp"
2018-12-08 05:24:02 +00:00
namespace specter {
PathButtons::PathButtons(ViewResources& res, View& parentView, IPathButtonsBinding& binding, bool fillContainer)
2018-12-08 05:24:02 +00:00
: ScrollView(res, parentView, ScrollView::Style::SideButtons), m_binding(binding), m_fillContainer(fillContainer) {
m_contentView.m_view.reset(new ContentView(res, *this));
setContentView(m_contentView.m_view.get());
}
2018-12-08 05:24:02 +00:00
void PathButtons::setButtons(const std::vector<hecl::SystemString>& comps) {
m_pathButtons.clear();
m_pathButtons.reserve(comps.size());
size_t idx = 0;
ViewResources& res = rootView().viewRes();
for (const hecl::SystemString& c : comps)
m_pathButtons.emplace_back(*this, res, idx++, c);
}
2018-12-08 05:24:02 +00:00
void PathButtons::setMultiplyColor(const zeus::CColor& color) {
ScrollView::setMultiplyColor(color);
for (PathButton& b : m_pathButtons)
b.m_button.m_view->setMultiplyColor(color);
}
2018-12-08 05:24:02 +00:00
void PathButtons::ContentView::mouseDown(const boo::SWindowCoord& coord, boo::EMouseButton button,
boo::EModifierKey mod) {
for (PathButton& b : m_pb.m_pathButtons)
b.m_button.mouseDown(coord, button, mod);
}
2018-12-08 05:24:02 +00:00
void PathButtons::ContentView::mouseUp(const boo::SWindowCoord& coord, boo::EMouseButton button,
boo::EModifierKey mod) {
for (PathButton& b : m_pb.m_pathButtons)
b.m_button.mouseUp(coord, button, mod);
if (m_pb.m_pathButtonPending >= 0) {
m_pb.m_binding.pathButtonActivated(m_pb.m_pathButtonPending);
m_pb.m_pathButtonPending = -1;
}
}
2018-12-08 05:24:02 +00:00
void PathButtons::ContentView::mouseMove(const boo::SWindowCoord& coord) {
for (PathButton& b : m_pb.m_pathButtons)
b.m_button.mouseMove(coord);
}
2018-12-08 05:24:02 +00:00
void PathButtons::ContentView::mouseLeave(const boo::SWindowCoord& coord) {
for (PathButton& b : m_pb.m_pathButtons)
b.m_button.mouseLeave(coord);
}
void PathButtons::ContentView::resized(const boo::SWindowRect& root, const boo::SWindowRect& sub,
2018-12-08 05:24:02 +00:00
const boo::SWindowRect& scissor) {
View::resized(root, sub);
m_scissorRect = scissor;
m_scissorRect.size[1] += 2;
boo::SWindowRect pathRect = sub;
for (PathButton& b : m_pb.m_pathButtons) {
pathRect.size[0] = b.m_button.m_view->nominalWidth();
pathRect.size[1] = b.m_button.m_view->nominalHeight();
b.m_button.m_view->resized(root, pathRect);
pathRect.location[0] += pathRect.size[0] + 2;
}
}
2018-12-08 05:24:02 +00:00
void PathButtons::containerResized(const boo::SWindowRect& root, const boo::SWindowRect& sub) {
if (m_fillContainer) {
boo::SWindowRect fillRect = sub;
fillRect.size[1] = 20 * rootView().viewRes().pixelFactor();
View::resized(root, fillRect);
}
2016-03-01 03:07:58 +00:00
}
2018-12-08 05:24:02 +00:00
void PathButtons::ContentView::draw(boo::IGraphicsCommandQueue* gfxQ) {
gfxQ->setScissor(m_scissorRect);
for (PathButton& b : m_pb.m_pathButtons)
b.m_button.m_view->draw(gfxQ);
gfxQ->setScissor(rootView().subRect());
}
2018-12-08 05:24:02 +00:00
} // namespace specter