Additional space-tree work

This commit is contained in:
Jack Andersen 2016-01-10 15:46:58 -10:00
parent 08c4270707
commit 69d1b5aa2b
6 changed files with 23 additions and 15 deletions

View File

@ -2,10 +2,12 @@
#define SPECTER_IVIEWMANAGER_HPP
#include "Translator.hpp"
#include "SplitView.hpp"
#include <HECL/HECL.hpp>
namespace Specter
{
struct ISplitSpaceController;
struct IViewManager
{
@ -19,6 +21,8 @@ public:
return vor;
}
virtual void deferSpaceSplit(ISplitSpaceController* split, SplitView::Axis axis, int thisSlot) {}
virtual const std::vector<HECL::SystemString>* recentProjects() const {return nullptr;}
virtual void pushRecentProject(const HECL::SystemString& path) {}

View File

@ -20,6 +20,7 @@ struct ISpaceController
struct ISplitSpaceController
{
virtual SplitView* splitView()=0;
virtual void setSplit(float split)=0;
};
class Space : public View
@ -31,7 +32,6 @@ class Space : public View
bool m_cornerDrag = false;
int m_cornerDragPoint[2];
ISplitSpaceController* m_cornerDragSplitSpace = nullptr;
struct CornerView : View
{

View File

@ -66,6 +66,7 @@ public:
SplitView(ViewResources& res, View& parentView, Axis axis, int clearanceA=-1, int clearanceB=-1);
View* setContentView(int slot, View* view);
void setSplit(float slide);
void setAxis(Axis axis);
void startDragSplit(const boo::SWindowCoord& coord);
void mouseDown(const boo::SWindowCoord&, boo::EMouseButton, boo::EModifierKey);
void mouseUp(const boo::SWindowCoord&, boo::EMouseButton, boo::EModifierKey);

View File

@ -14,6 +14,7 @@ RootView::RootView(IViewManager& viewMan, ViewResources& res, boo::IWindow* wind
m_renderTex = res.m_factory->newRenderTexture(rect.size[0], rect.size[1], 1);
commitResources(res);
resized(rect, rect);
printf("New RootView: %p\n", this);
}
void RootView::destroyed()

View File

@ -25,6 +25,7 @@ Space::Space(ViewResources& res, View& parentView, ISpaceController& controller,
m_cornerView.m_view.reset(new CornerView(res, *this, spaceTriangleColor()));
if (tbPos != Toolbar::Position::None)
m_toolbar.m_view.reset(new Toolbar(res, *this, tbPos));
printf("New Space: %p\n", this);
}
Space::CornerView::CornerView(ViewResources& res, Space& space, const Zeus::CColor& triColor)
@ -109,6 +110,7 @@ View* Space::setContentView(View* view)
View* ret = m_contentView.m_view;
m_contentView.m_view = view;
updateSize();
printf("Set Space: %p [%p]\n", this, view);
return ret;
}
@ -140,37 +142,29 @@ void Space::mouseUp(const boo::SWindowCoord& coord, boo::EMouseButton button, bo
void Space::CornerView::mouseUp(const boo::SWindowCoord& coord, boo::EMouseButton button, boo::EModifierKey mod)
{
if (button == boo::EMouseButton::Primary)
{
m_space.m_cornerDrag = false;
m_space.m_cornerDragSplitSpace = nullptr;
}
}
void Space::mouseMove(const boo::SWindowCoord& coord)
{
if (m_cornerDragSplitSpace)
{
m_cornerDragSplitSpace->splitView()->mouseMove(coord);
}
else if (m_cornerDrag)
if (m_cornerDrag)
{
float pf = rootView().viewRes().pixelFactor();
ISplitSpaceController* cornerDragSplitSpace = nullptr;
if (m_cornerView.m_view->m_flip)
{
if (coord.pixel[0] < m_cornerDragPoint[0] - CORNER_DRAG_THRESHOLD * pf)
m_cornerDragSplitSpace = m_controller.spaceSplit(SplitView::Axis::Vertical, 1);
rootView().viewManager().deferSpaceSplit(&m_controller, SplitView::Axis::Vertical, 1);
else if (coord.pixel[1] < m_cornerDragPoint[1] - CORNER_DRAG_THRESHOLD * pf)
m_cornerDragSplitSpace = m_controller.spaceSplit(SplitView::Axis::Horizontal, 1);
rootView().viewManager().deferSpaceSplit(&m_controller, SplitView::Axis::Horizontal, 1);
}
else
{
if (coord.pixel[0] > m_cornerDragPoint[0] + CORNER_DRAG_THRESHOLD * pf)
m_cornerDragSplitSpace = m_controller.spaceSplit(SplitView::Axis::Vertical, 0);
rootView().viewManager().deferSpaceSplit(&m_controller, SplitView::Axis::Vertical, 0);
else if (coord.pixel[1] > m_cornerDragPoint[1] + CORNER_DRAG_THRESHOLD * pf)
m_cornerDragSplitSpace = m_controller.spaceSplit(SplitView::Axis::Horizontal, 0);
rootView().viewManager().deferSpaceSplit(&m_controller, SplitView::Axis::Horizontal, 0);
}
if (m_cornerDragSplitSpace)
m_cornerDragSplitSpace->splitView()->startDragSplit(coord);
}
else
{

View File

@ -24,6 +24,7 @@ SplitView::SplitView(ViewResources& res, View& parentView, Axis axis, int cleara
m_splitBlockBuf = res.m_factory->newDynamicBuffer(boo::BufferUse::Uniform, sizeof(ViewBlock), 1);
m_splitVertsBinding.initTex(res, 4, m_splitBlockBuf, res.m_splitRes.m_shadingTex);
commitResources(res);
printf("New SplitView: %p\n", this);
}
View* SplitView::setContentView(int slot, View* view)
@ -35,6 +36,7 @@ View* SplitView::setContentView(int slot, View* view)
m_views[slot].m_mouseDown = 0;
m_views[slot].m_mouseIn = false;
updateSize();
printf("Set SplitView: %p [%d,%p]\n", this, slot, view);
return ret;
}
@ -71,6 +73,12 @@ void SplitView::setSplit(float slide)
updateSize();
}
void SplitView::setAxis(Axis axis)
{
m_axis = axis;
setSplit(m_slide);
}
void SplitView::startDragSplit(const boo::SWindowCoord& coord)
{
m_dragging = true;