2015-11-29 02:55:30 +00:00
|
|
|
#ifndef SPECTER_SCROLLVIEW_HPP
|
|
|
|
#define SPECTER_SCROLLVIEW_HPP
|
|
|
|
|
2016-01-07 00:39:18 +00:00
|
|
|
#include "Button.hpp"
|
|
|
|
#include "IViewManager.hpp"
|
2015-11-29 02:55:30 +00:00
|
|
|
|
|
|
|
namespace Specter
|
|
|
|
{
|
2015-12-02 01:32:15 +00:00
|
|
|
class ViewResources;
|
2016-01-13 01:31:50 +00:00
|
|
|
class Button;
|
2015-11-29 02:55:30 +00:00
|
|
|
|
|
|
|
class ScrollView : public View
|
|
|
|
{
|
|
|
|
public:
|
2015-12-15 21:53:15 +00:00
|
|
|
enum class Style
|
|
|
|
{
|
2015-12-30 02:20:24 +00:00
|
|
|
Plain,
|
2016-01-07 00:39:18 +00:00
|
|
|
ThinIndicator,
|
|
|
|
SideButtons
|
2015-12-15 21:53:15 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
private:
|
2015-12-30 02:20:24 +00:00
|
|
|
Style m_style;
|
2016-01-07 00:39:18 +00:00
|
|
|
ScissorViewChild<View*> m_contentView;
|
2015-12-29 02:02:43 +00:00
|
|
|
int m_scroll[2] = {};
|
2015-12-29 22:58:09 +00:00
|
|
|
int m_targetScroll[2] = {};
|
2015-12-15 21:53:15 +00:00
|
|
|
|
2016-01-01 00:12:19 +00:00
|
|
|
size_t m_consecutiveIdx = 0;
|
|
|
|
double m_consecutiveScroll[16][2] = {};
|
|
|
|
|
2015-12-30 02:20:24 +00:00
|
|
|
bool m_drawInd = false;
|
2016-01-07 00:39:18 +00:00
|
|
|
bool m_drawSideButtons = false;
|
2015-12-30 02:20:24 +00:00
|
|
|
|
|
|
|
SolidShaderVert m_verts[4];
|
2016-01-08 00:06:21 +00:00
|
|
|
VertexBufferBinding m_vertsBinding;
|
2015-12-30 02:20:24 +00:00
|
|
|
|
2016-01-07 00:39:18 +00:00
|
|
|
enum class SideButtonState
|
|
|
|
{
|
|
|
|
None,
|
|
|
|
ScrollLeft,
|
|
|
|
ScrollRight
|
|
|
|
} m_sideButtonState = SideButtonState::None;
|
|
|
|
struct SideButtonBinding : IButtonBinding
|
|
|
|
{
|
|
|
|
ScrollView& m_sv;
|
|
|
|
std::string m_leftName, m_rightName;
|
|
|
|
SideButtonBinding(ScrollView& sv, IViewManager& vm)
|
|
|
|
: m_sv(sv),
|
|
|
|
m_leftName(vm.translateOr("scroll_left", "Scroll Left")),
|
|
|
|
m_rightName(vm.translateOr("scroll_right", "Scroll Right")) {}
|
|
|
|
const char* name(const Control* control) const
|
2016-01-13 01:31:50 +00:00
|
|
|
{
|
|
|
|
return (control == reinterpret_cast<Control*>(m_sv.m_sideButtons[0].m_view.get())) ?
|
|
|
|
m_leftName.c_str() : m_rightName.c_str();
|
|
|
|
}
|
2016-01-07 00:39:18 +00:00
|
|
|
void down(const Button* button, const boo::SWindowCoord& coord)
|
|
|
|
{
|
|
|
|
if (button == m_sv.m_sideButtons[0].m_view.get())
|
|
|
|
m_sv.m_sideButtonState = SideButtonState::ScrollRight;
|
|
|
|
else
|
|
|
|
m_sv.m_sideButtonState = SideButtonState::ScrollLeft;
|
|
|
|
}
|
|
|
|
void up(const Button* button, const boo::SWindowCoord& coord)
|
|
|
|
{
|
|
|
|
m_sv.m_sideButtonState = SideButtonState::None;
|
|
|
|
}
|
|
|
|
} m_sideButtonBind;
|
|
|
|
ViewChild<std::unique_ptr<Button>> m_sideButtons[2];
|
|
|
|
|
2015-12-30 22:04:58 +00:00
|
|
|
bool _scroll(const boo::SScrollDelta& scroll);
|
2016-01-13 01:31:50 +00:00
|
|
|
int scrollAreaWidth() const;
|
2016-01-07 00:39:18 +00:00
|
|
|
|
2015-12-15 21:53:15 +00:00
|
|
|
public:
|
2015-12-30 02:20:24 +00:00
|
|
|
ScrollView(ViewResources& res, View& parentView, Style style);
|
2015-12-23 00:25:46 +00:00
|
|
|
void setContentView(View* v)
|
|
|
|
{
|
2016-01-07 00:39:18 +00:00
|
|
|
m_contentView.m_view = v;
|
2015-12-23 00:25:46 +00:00
|
|
|
updateSize();
|
|
|
|
}
|
2015-12-29 02:02:43 +00:00
|
|
|
|
2016-01-01 00:12:19 +00:00
|
|
|
void mouseDown(const boo::SWindowCoord&, boo::EMouseButton, boo::EModifierKey);
|
|
|
|
void mouseUp(const boo::SWindowCoord&, boo::EMouseButton, boo::EModifierKey);
|
|
|
|
void mouseMove(const boo::SWindowCoord&);
|
|
|
|
void mouseEnter(const boo::SWindowCoord&);
|
|
|
|
void mouseLeave(const boo::SWindowCoord&);
|
2015-12-29 02:02:43 +00:00
|
|
|
void scroll(const boo::SWindowCoord& coord, const boo::SScrollDelta& scroll);
|
2015-12-29 22:58:09 +00:00
|
|
|
int getScrollX() const {return m_scroll[0];}
|
|
|
|
int getScrollY() const {return m_scroll[1];}
|
2015-12-29 02:02:43 +00:00
|
|
|
|
2015-12-29 22:58:09 +00:00
|
|
|
int nominalWidth() const {return subRect().size[0];}
|
|
|
|
int nominalHeight() const {return subRect().size[1];}
|
|
|
|
|
2016-01-13 01:31:50 +00:00
|
|
|
void setMultiplyColor(const Zeus::CColor& color);
|
2015-12-30 02:20:24 +00:00
|
|
|
|
2015-12-29 22:58:09 +00:00
|
|
|
void think();
|
2015-12-29 02:02:43 +00:00
|
|
|
void resized(const boo::SWindowRect& root, const boo::SWindowRect& sub);
|
|
|
|
void draw(boo::IGraphicsCommandQueue* gfxQ);
|
2015-11-29 02:55:30 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // SPECTER_SCROLLVIEW_HPP
|