More space-tree work

This commit is contained in:
Jack Andersen 2016-01-10 16:17:08 -10:00
parent 7f07e516e9
commit 1a5f3bec0d
7 changed files with 111 additions and 51 deletions

View File

@ -176,6 +176,7 @@ class ResourceBrowser : public Space, public Specter::IPathButtonsBinding
commitResources(res); commitResources(res);
m_pathButtons.m_view.reset(new Specter::PathButtons(res, *this, ro)); m_pathButtons.m_view.reset(new Specter::PathButtons(res, *this, ro));
m_fileListing.m_view.reset(new Specter::Table(res, *this, &ro.m_fileListingBind, &ro.m_fileListingBind, 3)); m_fileListing.m_view.reset(new Specter::Table(res, *this, &ro.m_fileListingBind, &ro.m_fileListingBind, 3));
printf("New ResView: %p\n", this);
} }
void resized(const boo::SWindowRect& root, const boo::SWindowRect& sub); void resized(const boo::SWindowRect& root, const boo::SWindowRect& sub);

View File

@ -10,28 +10,36 @@ Specter::View* Space::buildSpaceView(Specter::ViewResources& res)
{ {
if (usesToolbar()) if (usesToolbar())
{ {
m_space.reset(new Specter::Space(res, m_vm.rootView(), *this, Specter::Toolbar::Position::Bottom)); m_spaceView.reset(new Specter::Space(res, m_vm.rootView(), *this, Specter::Toolbar::Position::Bottom));
Specter::View* sview = buildContentView(res); Specter::View* sview = buildContentView(res);
m_space->setContentView(sview); m_spaceView->setContentView(sview);
buildToolbarView(res, *m_space->toolbar()); buildToolbarView(res, *m_spaceView->toolbar());
return m_space.get(); return m_spaceView.get();
} }
else else
{ {
m_space.reset(new Specter::Space(res, m_vm.rootView(), *this, Specter::Toolbar::Position::None)); m_spaceView.reset(new Specter::Space(res, m_vm.rootView(), *this, Specter::Toolbar::Position::None));
Specter::View* sview = buildContentView(res); Specter::View* sview = buildContentView(res);
m_space->setContentView(sview); m_spaceView->setContentView(sview);
return m_space.get(); return m_spaceView.get();
} }
} }
Specter::View* RootSpace::buildSpaceView(Specter::ViewResources& res)
{
Specter::View* newRoot = buildContentView(res);
m_vm.RootSpaceViewBuilt(newRoot);
return newRoot;
}
Specter::View* SplitSpace::buildContentView(Specter::ViewResources& res) Specter::View* SplitSpace::buildContentView(Specter::ViewResources& res)
{ {
m_splitView.reset(new Specter::SplitView(res, m_vm.rootView(), Specter::SplitView::Axis::Horizontal)); m_splitView.reset(new Specter::SplitView(res, m_vm.rootView(), m_state.axis));
if (m_slots[0]) if (m_slots[0])
m_splitView->setContentView(0, m_slots[0]->buildSpaceView(res)); m_splitView->setContentView(0, m_slots[0]->buildSpaceView(res));
if (m_slots[1]) if (m_slots[1])
m_splitView->setContentView(1, m_slots[1]->buildSpaceView(res)); m_splitView->setContentView(1, m_slots[1]->buildSpaceView(res));
m_splitView->setSplit(m_state.split);
return m_splitView.get(); return m_splitView.get();
} }
@ -47,10 +55,10 @@ Specter::ISplitSpaceController* Space::spaceSplit(Specter::SplitView::Axis axis,
{ {
if (m_parent) if (m_parent)
{ {
SplitSpace* ss = new SplitSpace(m_vm, m_parent); SplitSpace* ss = new SplitSpace(m_vm, m_parent, axis);
ss->setChildSlot(thisSlot, std::move(m_parent->exchangeSpaceSplitJoin(this, std::unique_ptr<Space>(ss)))); ss->setChildSlot(thisSlot, std::move(m_parent->exchangeSpaceSplitJoin(this, std::unique_ptr<Space>(ss))));
ss->setChildSlot(thisSlot ^ 1, std::unique_ptr<Space>(copy(ss))); ss->setChildSlot(thisSlot ^ 1, std::unique_ptr<Space>(copy(ss)));
m_parent->buildSpaceView(m_vm.rootView().viewRes()); m_vm.BuildSpaceViews();
return ss; return ss;
} }
return nullptr; return nullptr;
@ -60,10 +68,10 @@ std::unique_ptr<Space> RootSpace::exchangeSpaceSplitJoin(Space* removeSpace, std
{ {
std::unique_ptr<Space> ret = std::move(keepSpace); std::unique_ptr<Space> ret = std::move(keepSpace);
if (removeSpace == m_child.get()) if (removeSpace == m_spaceTree.get())
{ {
m_child.swap(ret); m_spaceTree.swap(ret);
m_child->m_parent = this; m_spaceTree->m_parent = this;
} }
else else
Log.report(LogVisor::FatalError, "RootSpace::exchangeSpaceSplitJoin() failure"); Log.report(LogVisor::FatalError, "RootSpace::exchangeSpaceSplitJoin() failure");

View File

@ -44,7 +44,7 @@ protected:
ViewManager& m_vm; ViewManager& m_vm;
Class m_class = Class::None; Class m_class = Class::None;
Space* m_parent; Space* m_parent;
std::unique_ptr<Specter::Space> m_space; std::unique_ptr<Specter::Space> m_spaceView;
Space(ViewManager& vm, Class cls, Space* parent) : m_vm(vm), m_class(cls), m_parent(parent) {} Space(ViewManager& vm, Class cls, Space* parent) : m_vm(vm), m_class(cls), m_parent(parent) {}
/* Allows common Space code to access DNA-encoded state */ /* Allows common Space code to access DNA-encoded state */
@ -74,7 +74,7 @@ public:
class RootSpace : public Space class RootSpace : public Space
{ {
friend class ViewManager; friend class ViewManager;
std::unique_ptr<Space> m_child; std::unique_ptr<Space> m_spaceTree;
struct State : Space::State struct State : Space::State
{ {
DECL_YAML DECL_YAML
@ -90,8 +90,8 @@ public:
#ifdef URDE_BINARY_CONFIGS #ifdef URDE_BINARY_CONFIGS
m_child.reset(NewSpaceFromConfigStream(vm, this, r)); m_child.reset(NewSpaceFromConfigStream(vm, this, r));
#else #else
r.enterSubRecord("child"); r.enterSubRecord("spaceTree");
m_child.reset(NewSpaceFromConfigStream(vm, this, r)); m_spaceTree.reset(NewSpaceFromConfigStream(vm, this, r));
r.leaveSubRecord(); r.leaveSubRecord();
#endif #endif
} }
@ -101,8 +101,8 @@ public:
w.writeUint32Big(atUint32(m_class)); w.writeUint32Big(atUint32(m_class));
m_state.write(w); m_state.write(w);
if (m_child) if (m_spaceTree)
m_child->saveState(w); m_spaceTree->saveState(w);
else else
w.writeUint32Big(0); w.writeUint32Big(0);
} }
@ -112,9 +112,9 @@ public:
w.writeUint32("class", atUint32(m_class)); w.writeUint32("class", atUint32(m_class));
m_state.write(w); m_state.write(w);
w.enterSubRecord("child"); w.enterSubRecord("spaceTree");
if (m_child) if (m_spaceTree)
m_child->saveState(w); m_spaceTree->saveState(w);
else else
w.writeUint32("class", 0); w.writeUint32("class", 0);
w.leaveSubRecord(); w.leaveSubRecord();
@ -122,15 +122,15 @@ public:
void setChild(std::unique_ptr<Space>&& space) void setChild(std::unique_ptr<Space>&& space)
{ {
m_child = std::move(space); m_spaceTree = std::move(space);
m_child->m_parent = this; m_spaceTree->m_parent = this;
} }
Space* copy(Space* parent) const {return nullptr;} Space* copy(Space* parent) const {return nullptr;}
bool spaceSplitAllowed() const {return false;} bool spaceSplitAllowed() const {return false;}
Specter::View* buildSpaceView(Specter::ViewResources& res) {return buildContentView(res);} Specter::View* buildSpaceView(Specter::ViewResources& res);
Specter::View* buildContentView(Specter::ViewResources& res) {return m_child->buildSpaceView(res);} Specter::View* buildContentView(Specter::ViewResources& res) {return m_spaceTree->buildSpaceView(res);}
std::unique_ptr<Space> exchangeSpaceSplitJoin(Space* removeSpace, std::unique_ptr<Space>&& keepSpace); std::unique_ptr<Space> exchangeSpaceSplitJoin(Space* removeSpace, std::unique_ptr<Space>&& keepSpace);
}; };
@ -143,14 +143,19 @@ class SplitSpace : public Space, public Specter::ISplitSpaceController
struct State : Space::State struct State : Space::State
{ {
DECL_YAML DECL_YAML
Value<float> split; Value<Specter::SplitView::Axis> axis = Specter::SplitView::Axis::Horizontal;
Value<float> split = 0.5;
} m_state; } m_state;
const Space::State& spaceState() const {return m_state;} const Space::State& spaceState() const {return m_state;}
public: public:
SplitSpace(ViewManager& vm, Space* parent) : Space(vm, Class::SplitSpace, parent) {} SplitSpace(ViewManager& vm, Space* parent, Specter::SplitView::Axis axis) : Space(vm, Class::SplitSpace, parent)
{
m_state.axis = axis;
reloadState();
}
SplitSpace(ViewManager& vm, Space* parent, ConfigReader& r) SplitSpace(ViewManager& vm, Space* parent, ConfigReader& r)
: SplitSpace(vm, parent) : SplitSpace(vm, parent, Specter::SplitView::Axis::Horizontal)
{ {
m_state.read(r); m_state.read(r);
#ifdef URDE_BINARY_CONFIGS #ifdef URDE_BINARY_CONFIGS
@ -164,6 +169,20 @@ public:
m_slots[1].reset(NewSpaceFromConfigStream(vm, this, r)); m_slots[1].reset(NewSpaceFromConfigStream(vm, this, r));
r.leaveSubRecord(); r.leaveSubRecord();
#endif #endif
reloadState();
}
void reloadState()
{
m_state.split = std::min(1.f, std::max(0.f, m_state.split));
if (m_state.axis != Specter::SplitView::Axis::Horizontal &&
m_state.axis != Specter::SplitView::Axis::Vertical)
m_state.axis = Specter::SplitView::Axis::Horizontal;
if (m_splitView)
{
m_splitView->setSplit(m_state.split);
m_splitView->setAxis(m_state.axis);
}
} }
void saveState(Athena::io::IStreamWriter& w) const void saveState(Athena::io::IStreamWriter& w) const
@ -224,9 +243,16 @@ public:
std::unique_ptr<Space> exchangeSpaceSplitJoin(Space* removeSpace, std::unique_ptr<Space>&& keepSpace); std::unique_ptr<Space> exchangeSpaceSplitJoin(Space* removeSpace, std::unique_ptr<Space>&& keepSpace);
Specter::SplitView* splitView() Specter::SplitView* splitView() {return m_splitView.get();}
void setSplit(float split)
{ {
return m_splitView.get(); m_state.split = split;
reloadState();
}
void setAxis(Specter::SplitView::Axis axis)
{
m_state.axis = axis;
reloadState();
} }
}; };
@ -261,7 +287,7 @@ public:
Specter::View* buildContentView(Specter::ViewResources& res) Specter::View* buildContentView(Specter::ViewResources& res)
{ {
m_textView.reset(new Specter::MultiLineTextView(res, *m_space, res.m_heading14)); m_textView.reset(new Specter::MultiLineTextView(res, *m_spaceView, res.m_heading14));
m_textView->setBackground(res.themeData().viewportBackground()); m_textView->setBackground(res.themeData().viewportBackground());
m_textView->typesetGlyphs(m_contentStr, res.themeData().uiText()); m_textView->typesetGlyphs(m_contentStr, res.themeData().uiText());
return m_textView.get(); return m_textView.get();

View File

@ -10,9 +10,9 @@ using YAMLNode = Athena::io::YAMLNode;
namespace URDE namespace URDE
{ {
Specter::View* ViewManager::BuildSpaceViews(URDE::Space* space) Specter::View* ViewManager::BuildSpaceViews()
{ {
m_rootSpaceView = space->buildSpaceView(m_viewResources); m_rootSpaceView = m_rootSpace->buildSpaceView(m_viewResources);
return m_rootSpaceView; return m_rootSpaceView;
} }
@ -31,30 +31,32 @@ SplashScreen* ViewManager::SetupSplashView()
return m_splash.get(); return m_splash.get();
} }
void ViewManager::RootSpaceViewBuilt(Specter::View *view)
{
std::vector<Specter::View*>& cViews = m_rootView->accessContentViews();
cViews.clear();
cViews.push_back(view);
printf("RootView Set: %p [%p]\n\n", m_rootView.get(), view);
cViews.push_back(m_splash.get());
m_rootView->updateSize();
}
void ViewManager::SetupEditorView() void ViewManager::SetupEditorView()
{ {
m_rootSpace.reset(new RootSpace(*this)); m_rootSpace.reset(new RootSpace(*this));
SplitSpace* split = new SplitSpace(*this, nullptr); SplitSpace* split = new SplitSpace(*this, nullptr, Specter::SplitView::Axis::Horizontal);
m_rootSpace->setChild(std::unique_ptr<Space>(split)); m_rootSpace->setChild(std::unique_ptr<Space>(split));
split->setChildSlot(0, std::make_unique<ResourceBrowser>(*this, split)); split->setChildSlot(0, std::make_unique<ResourceBrowser>(*this, split));
split->setChildSlot(1, std::make_unique<ResourceBrowser>(*this, split)); split->setChildSlot(1, std::make_unique<ResourceBrowser>(*this, split));
std::vector<Specter::View*>& cViews = m_rootView->accessContentViews(); BuildSpaceViews();
cViews.clear();
cViews.push_back(BuildSpaceViews(m_rootSpace.get()));
cViews.push_back(m_splash.get());
m_rootView->updateSize();
} }
void ViewManager::SetupEditorView(ConfigReader& r) void ViewManager::SetupEditorView(ConfigReader& r)
{ {
m_rootSpace.reset(Space::NewRootSpaceFromConfigStream(*this, r)); m_rootSpace.reset(Space::NewRootSpaceFromConfigStream(*this, r));
std::vector<Specter::View*>& cViews = m_rootView->accessContentViews(); BuildSpaceViews();
cViews.clear();
cViews.push_back(BuildSpaceViews(m_rootSpace.get()));
cViews.push_back(m_splash.get());
m_rootView->updateSize();
} }
void ViewManager::SaveEditorView(ConfigWriter& w) void ViewManager::SaveEditorView(ConfigWriter& w)
@ -118,10 +120,13 @@ bool ViewManager::proc()
{ {
m_viewResources.resetPixelFactor(m_reqPf); m_viewResources.resetPixelFactor(m_reqPf);
Specter::RootView* root = SetupRootView(); Specter::RootView* root = SetupRootView();
std::vector<Specter::View*>& cViews = root->accessContentViews();
if (m_rootSpace) if (m_rootSpace)
cViews.push_back(BuildSpaceViews(m_rootSpace.get())); BuildSpaceViews();
else
{
std::vector<Specter::View*>& cViews = m_rootView->accessContentViews();
cViews.push_back(SetupSplashView()); cViews.push_back(SetupSplashView());
}
root->updateSize(); root->updateSize();
m_updatePf = false; m_updatePf = false;
} }
@ -132,6 +137,12 @@ bool ViewManager::proc()
if (m_splash) if (m_splash)
m_splash->think(); m_splash->think();
if (m_deferSplit)
{
m_deferSplit->spaceSplit(m_deferSplitAxis, m_deferSplitThisSlot);
m_deferSplit = nullptr;
}
++m_editorFrames; ++m_editorFrames;
if (m_rootSpaceView && m_editorFrames <= 30) if (m_rootSpaceView && m_editorFrames <= 30)
m_rootSpaceView->setMultiplyColor(Zeus::CColor::lerp({1,1,1,0}, {1,1,1,1}, m_editorFrames / 30.0)); m_rootSpaceView->setMultiplyColor(Zeus::CColor::lerp({1,1,1,0}, {1,1,1,1}, m_editorFrames / 30.0));

View File

@ -12,6 +12,8 @@ class SplashScreen;
class ViewManager : public Specter::IViewManager class ViewManager : public Specter::IViewManager
{ {
friend class ProjectManager; friend class ProjectManager;
friend class Space;
friend class RootSpace;
HECL::Runtime::FileStoreManager& m_fileStoreManager; HECL::Runtime::FileStoreManager& m_fileStoreManager;
HECL::CVarManager& m_cvarManager; HECL::CVarManager& m_cvarManager;
@ -33,9 +35,10 @@ class ViewManager : public Specter::IViewManager
bool m_updatePf = false; bool m_updatePf = false;
float m_reqPf; float m_reqPf;
Specter::View* BuildSpaceViews(URDE::Space* space); Specter::View* BuildSpaceViews();
Specter::RootView* SetupRootView(); Specter::RootView* SetupRootView();
SplashScreen* SetupSplashView(); SplashScreen* SetupSplashView();
void RootSpaceViewBuilt(Specter::View* view);
void SetupEditorView(); void SetupEditorView();
void SetupEditorView(ConfigReader& r); void SetupEditorView(ConfigReader& r);
void SaveEditorView(ConfigWriter& w); void SaveEditorView(ConfigWriter& w);
@ -46,6 +49,10 @@ class ViewManager : public Specter::IViewManager
unsigned m_editorFrames = 120; unsigned m_editorFrames = 120;
void FadeInEditors() {m_editorFrames = 0;} void FadeInEditors() {m_editorFrames = 0;}
Space* m_deferSplit = nullptr;
Specter::SplitView::Axis m_deferSplitAxis;
int m_deferSplitThisSlot;
public: public:
ViewManager(HECL::Runtime::FileStoreManager& fileMgr, HECL::CVarManager& cvarMgr); ViewManager(HECL::Runtime::FileStoreManager& fileMgr, HECL::CVarManager& cvarMgr);
~ViewManager(); ~ViewManager();
@ -61,6 +68,13 @@ public:
HECL::Database::Project* project() {return m_projManager.project();} HECL::Database::Project* project() {return m_projManager.project();}
const Specter::Translator* getTranslator() const {return &m_translator;} const Specter::Translator* getTranslator() const {return &m_translator;}
void deferSpaceSplit(Specter::ISpaceController* split, Specter::SplitView::Axis axis, int thisSlot)
{
m_deferSplit = static_cast<Space*>(split);
m_deferSplitAxis = axis;
m_deferSplitThisSlot = thisSlot;
}
const std::vector<HECL::SystemString>* recentProjects() const {return &m_recentProjects;} const std::vector<HECL::SystemString>* recentProjects() const {return &m_recentProjects;}
void pushRecentProject(const HECL::SystemString& path); void pushRecentProject(const HECL::SystemString& path);

2
hecl

@ -1 +1 @@
Subproject commit fcedcb508e0f2c8edb4ad857738e1e664f2d6c95 Subproject commit 08bfbddf4db2f4018e8b494aff83795c74857eb7

@ -1 +1 @@
Subproject commit 168b7c8cceb306c53cdaf1b30f3d5c5344f89205 Subproject commit 77c8e7e4b9317943abfd4366f5f38abf7185dba4