metaforce/specter/include/Specter/SplitView.hpp

119 lines
3.7 KiB
C++
Raw Normal View History

#ifndef SPECTER_SPLITVIEW_HPP
#define SPECTER_SPLITVIEW_HPP
#include "Specter/View.hpp"
namespace Specter
{
2016-01-12 00:44:54 +00:00
struct ISplitSpaceController;
class SplitView : public View
{
2016-01-12 00:44:54 +00:00
friend class RootView;
friend class Space;
public:
class Resources
{
friend class ViewResources;
friend class SplitView;
boo::ITextureS* m_shadingTex;
void init(boo::IGraphicsDataFactory* factory, const IThemeData& theme);
};
2016-01-31 01:07:52 +00:00
enum class ArrowDir
{
Up,
Down,
Left,
Right
};
enum class Axis
{
Horizontal,
Vertical
};
private:
2016-01-12 00:44:54 +00:00
ISplitSpaceController* m_controller;
Axis m_axis;
float m_slide = 0.5;
void _setSplit(float slide);
bool m_dragging = false;
2015-12-20 21:59:23 +00:00
ViewChild<View*> m_views[2];
ViewBlock m_splitBlock;
boo::IGraphicsBufferD* m_splitBlockBuf;
2015-12-05 00:42:46 +00:00
TexShaderVert m_splitVerts[4];
2015-12-22 01:33:27 +00:00
int m_clearanceA, m_clearanceB;
void setHorizontalVerts(int width)
{
2015-12-02 06:13:43 +00:00
m_splitVerts[0].m_pos.assign(0, 2, 0);
m_splitVerts[0].m_uv.assign(0, 0);
m_splitVerts[1].m_pos.assign(0, -1, 0);
m_splitVerts[1].m_uv.assign(1, 0);
2015-12-02 06:13:43 +00:00
m_splitVerts[2].m_pos.assign(width, 2, 0);
m_splitVerts[2].m_uv.assign(0, 0);
m_splitVerts[3].m_pos.assign(width, -1, 0);
m_splitVerts[3].m_uv.assign(1, 0);
}
void setVerticalVerts(int height)
{
m_splitVerts[0].m_pos.assign(-1, height, 0);
m_splitVerts[0].m_uv.assign(0, 0);
m_splitVerts[1].m_pos.assign(-1, 0, 0);
m_splitVerts[1].m_uv.assign(0, 0);
2015-12-02 06:13:43 +00:00
m_splitVerts[2].m_pos.assign(2, height, 0);
m_splitVerts[2].m_uv.assign(1, 0);
2015-12-02 06:13:43 +00:00
m_splitVerts[3].m_pos.assign(2, 0, 0);
m_splitVerts[3].m_uv.assign(1, 0);
}
VertexBufferBinding m_splitVertsBinding;
2016-01-31 01:07:52 +00:00
public:
2016-01-12 00:44:54 +00:00
SplitView(ViewResources& res, View& parentView, ISplitSpaceController* controller,
Axis axis, float split, int clearanceA=-1, int clearanceB=-1);
View* setContentView(int slot, View* view);
2016-01-12 00:44:54 +00:00
void setSplit(float split);
2016-01-11 01:46:58 +00:00
void setAxis(Axis axis);
2016-01-12 00:44:54 +00:00
Axis axis() const {return m_axis;}
float split() const {return m_slide;}
bool testSplitHover(const boo::SWindowCoord& coord);
bool testJoinArrowHover(const boo::SWindowCoord& coord, int& origSlotOut,
SplitView*& splitOut, int& slotOut,
boo::SWindowRect& rectOut, ArrowDir& dirOut, int forceSlot=-1);
2016-01-31 01:07:52 +00:00
void getJoinArrowHover(int slot, boo::SWindowRect& rectOut, ArrowDir& dirOut);
bool testSplitLineHover(const boo::SWindowCoord& coord, int& slotOut, boo::SWindowRect& rectOut, float& splitOut, Axis& axisOut);
void getSplitLineHover(int slot, boo::SWindowRect& rectOut, Axis& axisOut);
void startDragSplit(const boo::SWindowCoord& coord);
2016-01-12 00:44:54 +00:00
void endDragSplit();
void moveDragSplit(const boo::SWindowCoord& coord);
void mouseDown(const boo::SWindowCoord&, boo::EMouseButton, boo::EModifierKey);
void mouseUp(const boo::SWindowCoord&, boo::EMouseButton, boo::EModifierKey);
void mouseMove(const boo::SWindowCoord&);
2015-12-05 00:42:46 +00:00
void mouseEnter(const boo::SWindowCoord&);
void mouseLeave(const boo::SWindowCoord&);
void resized(const boo::SWindowRect& rootView, const boo::SWindowRect& sub);
void draw(boo::IGraphicsCommandQueue* gfxQ);
2015-12-22 01:33:27 +00:00
void setMultiplyColor(const Zeus::CColor& color)
{
View::setMultiplyColor(color);
m_splitBlock.m_color = color;
m_splitBlockBuf->load(&m_splitBlock, sizeof(m_splitBlock));
2016-01-04 23:58:38 +00:00
if (m_views[0].m_view)
m_views[0].m_view->setMultiplyColor(color);
if (m_views[1].m_view)
m_views[1].m_view->setMultiplyColor(color);
2015-12-22 01:33:27 +00:00
}
};
}
#endif // SPECTER_SPLITVIEW_HPP