diff --git a/specter/include/Specter/IViewManager.hpp b/specter/include/Specter/IViewManager.hpp index e9b0fbe86..ca0ed8f37 100644 --- a/specter/include/Specter/IViewManager.hpp +++ b/specter/include/Specter/IViewManager.hpp @@ -2,10 +2,12 @@ #define SPECTER_IVIEWMANAGER_HPP #include "Translator.hpp" +#include "SplitView.hpp" #include 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* recentProjects() const {return nullptr;} virtual void pushRecentProject(const HECL::SystemString& path) {} diff --git a/specter/include/Specter/Space.hpp b/specter/include/Specter/Space.hpp index 858a9acd1..530a10b22 100644 --- a/specter/include/Specter/Space.hpp +++ b/specter/include/Specter/Space.hpp @@ -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 { diff --git a/specter/include/Specter/SplitView.hpp b/specter/include/Specter/SplitView.hpp index c5df79fe8..f60b4c93d 100644 --- a/specter/include/Specter/SplitView.hpp +++ b/specter/include/Specter/SplitView.hpp @@ -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); diff --git a/specter/lib/RootView.cpp b/specter/lib/RootView.cpp index 10e4e4406..92fcfb949 100644 --- a/specter/lib/RootView.cpp +++ b/specter/lib/RootView.cpp @@ -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() diff --git a/specter/lib/Space.cpp b/specter/lib/Space.cpp index 6517f71f0..893a88ac5 100644 --- a/specter/lib/Space.cpp +++ b/specter/lib/Space.cpp @@ -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 { diff --git a/specter/lib/SplitView.cpp b/specter/lib/SplitView.cpp index 9532380f6..6b14d780b 100644 --- a/specter/lib/SplitView.cpp +++ b/specter/lib/SplitView.cpp @@ -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;