mirror of https://github.com/AxioDL/metaforce.git
Architectual adjustments for space splitting
This commit is contained in:
parent
3bd462a4a5
commit
7f07e516e9
|
@ -184,15 +184,20 @@ class ResourceBrowser : public Space, public Specter::IPathButtonsBinding
|
|||
std::unique_ptr<View> m_view;
|
||||
|
||||
public:
|
||||
ResourceBrowser(ViewManager& vm)
|
||||
: Space(vm, Class::ResourceBrowser),
|
||||
ResourceBrowser(ViewManager& vm, Space* parent)
|
||||
: Space(vm, Class::ResourceBrowser, parent),
|
||||
m_fileListingBind(*this, vm)
|
||||
{
|
||||
m_state.path = vm.project()->getProjectWorkingPath().getRelativePathUTF8();
|
||||
reloadState();
|
||||
}
|
||||
ResourceBrowser(ViewManager& vm, ConfigReader& r)
|
||||
: ResourceBrowser(vm)
|
||||
ResourceBrowser(ViewManager& vm, Space* parent, const ResourceBrowser& other)
|
||||
: ResourceBrowser(vm, parent)
|
||||
{
|
||||
m_state = other.m_state;
|
||||
reloadState();
|
||||
}
|
||||
ResourceBrowser(ViewManager& vm, Space* parent, ConfigReader& r)
|
||||
: ResourceBrowser(vm, parent)
|
||||
{
|
||||
m_state.read(r);
|
||||
reloadState();
|
||||
|
@ -200,11 +205,23 @@ public:
|
|||
|
||||
void reloadState()
|
||||
{
|
||||
navigateToPath(HECL::ProjectPath(*m_vm.project(), m_state.path));
|
||||
HECL::ProjectPath pp(*m_vm.project(), m_state.path);
|
||||
if (m_state.path.empty() || pp.getPathType() == HECL::ProjectPath::Type::None)
|
||||
{
|
||||
m_state.path = m_vm.project()->getProjectWorkingPath().getRelativePathUTF8();
|
||||
navigateToPath(HECL::ProjectPath(*m_vm.project(), m_state.path));
|
||||
}
|
||||
else
|
||||
navigateToPath(pp);
|
||||
}
|
||||
|
||||
bool navigateToPath(const HECL::ProjectPath& path);
|
||||
|
||||
Space* copy(Space* parent) const
|
||||
{
|
||||
return new ResourceBrowser(m_vm, parent, *this);
|
||||
}
|
||||
|
||||
Specter::View* buildContentView(Specter::ViewResources& res)
|
||||
{
|
||||
m_view.reset(new View(*this, res));
|
||||
|
|
|
@ -10,7 +10,7 @@ Specter::View* Space::buildSpaceView(Specter::ViewResources& res)
|
|||
{
|
||||
if (usesToolbar())
|
||||
{
|
||||
m_space.reset(new Specter::Space(res, m_vm.rootView(), Specter::Toolbar::Position::Bottom));
|
||||
m_space.reset(new Specter::Space(res, m_vm.rootView(), *this, Specter::Toolbar::Position::Bottom));
|
||||
Specter::View* sview = buildContentView(res);
|
||||
m_space->setContentView(sview);
|
||||
buildToolbarView(res, *m_space->toolbar());
|
||||
|
@ -18,7 +18,7 @@ Specter::View* Space::buildSpaceView(Specter::ViewResources& res)
|
|||
}
|
||||
else
|
||||
{
|
||||
m_space.reset(new Specter::Space(res, m_vm.rootView(), Specter::Toolbar::Position::None));
|
||||
m_space.reset(new Specter::Space(res, m_vm.rootView(), *this, Specter::Toolbar::Position::None));
|
||||
Specter::View* sview = buildContentView(res);
|
||||
m_space->setContentView(sview);
|
||||
return m_space.get();
|
||||
|
@ -35,23 +35,72 @@ Specter::View* SplitSpace::buildContentView(Specter::ViewResources& res)
|
|||
return m_splitView.get();
|
||||
}
|
||||
|
||||
void SplitSpace::setSpaceSlot(unsigned slot, std::unique_ptr<Space>&& space)
|
||||
void SplitSpace::setChildSlot(unsigned slot, std::unique_ptr<Space>&& space)
|
||||
{
|
||||
if (slot > 1)
|
||||
Log.report(LogVisor::FatalError, "invalid slot %u for SplitView", slot);
|
||||
m_slots[slot] = std::move(space);
|
||||
m_slots[slot]->m_parent = this;
|
||||
}
|
||||
|
||||
Specter::ISplitSpaceController* Space::spaceSplit(Specter::SplitView::Axis axis, int thisSlot)
|
||||
{
|
||||
if (m_parent)
|
||||
{
|
||||
SplitSpace* ss = new SplitSpace(m_vm, m_parent);
|
||||
ss->setChildSlot(thisSlot, std::move(m_parent->exchangeSpaceSplitJoin(this, std::unique_ptr<Space>(ss))));
|
||||
ss->setChildSlot(thisSlot ^ 1, std::unique_ptr<Space>(copy(ss)));
|
||||
m_parent->buildSpaceView(m_vm.rootView().viewRes());
|
||||
return ss;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
std::unique_ptr<Space> RootSpace::exchangeSpaceSplitJoin(Space* removeSpace, std::unique_ptr<Space>&& keepSpace)
|
||||
{
|
||||
std::unique_ptr<Space> ret = std::move(keepSpace);
|
||||
|
||||
if (removeSpace == m_child.get())
|
||||
{
|
||||
m_child.swap(ret);
|
||||
m_child->m_parent = this;
|
||||
}
|
||||
else
|
||||
Log.report(LogVisor::FatalError, "RootSpace::exchangeSpaceSplitJoin() failure");
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
std::unique_ptr<Space> SplitSpace::exchangeSpaceSplitJoin(Space* removeSpace, std::unique_ptr<Space>&& keepSpace)
|
||||
{
|
||||
std::unique_ptr<Space> ret = std::move(keepSpace);
|
||||
|
||||
if (removeSpace == m_slots[0].get())
|
||||
{
|
||||
m_slots[0].swap(ret);
|
||||
m_slots[0]->m_parent = this;
|
||||
}
|
||||
else if (removeSpace == m_slots[1].get())
|
||||
{
|
||||
m_slots[1].swap(ret);
|
||||
m_slots[1]->m_parent = this;
|
||||
}
|
||||
else
|
||||
Log.report(LogVisor::FatalError, "SplitSpace::exchangeSpaceSplitJoin() failure");
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
template <class Reader>
|
||||
static Space* BuildNewSpace(ViewManager& vm, Space::Class cls, Reader& r)
|
||||
static Space* BuildNewSpace(ViewManager& vm, Space::Class cls, Space* parent, Reader& r)
|
||||
{
|
||||
using Class = Space::Class;
|
||||
switch (cls)
|
||||
{
|
||||
case Class::SplitSpace:
|
||||
return new SplitSpace(vm, r);
|
||||
return new SplitSpace(vm, parent, r);
|
||||
case Class::ResourceBrowser:
|
||||
return new ResourceBrowser(vm, r);
|
||||
return new ResourceBrowser(vm, parent, r);
|
||||
default: break;
|
||||
}
|
||||
return nullptr;
|
||||
|
@ -69,14 +118,29 @@ void Space::saveState(Athena::io::YAMLDocWriter& w) const
|
|||
spaceState().write(w);
|
||||
}
|
||||
|
||||
Space* Space::NewSpaceFromConfigStream(ViewManager& vm, ConfigReader& r)
|
||||
Space* Space::NewSpaceFromConfigStream(ViewManager& vm, Space* parent, ConfigReader& r)
|
||||
{
|
||||
#ifdef URDE_BINARY_CONFIGS
|
||||
Class cls = Class(r.readUint32Big());
|
||||
return BuildNewSpace(vm, cls, parent, r);
|
||||
#else
|
||||
Class cls = Class(r.readUint32("class"));
|
||||
return BuildNewSpace(vm, cls, parent, r);
|
||||
#endif
|
||||
}
|
||||
|
||||
RootSpace* Space::NewRootSpaceFromConfigStream(ViewManager& vm, ConfigReader& r)
|
||||
{
|
||||
#ifdef URDE_BINARY_CONFIGS
|
||||
Class cls = Class(r.readUint32Big());
|
||||
if (cls != Class::RootSpace)
|
||||
return nullptr;
|
||||
return BuildNewSpace(vm, cls, r);
|
||||
#else
|
||||
Class cls = Class(r.readUint32("class"));
|
||||
return BuildNewSpace(vm, cls, r);
|
||||
if (cls != Class::RootSpace)
|
||||
return nullptr;
|
||||
return new RootSpace(vm, r);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
126
Editor/Space.hpp
126
Editor/Space.hpp
|
@ -15,31 +15,37 @@ class Toolbar;
|
|||
namespace URDE
|
||||
{
|
||||
class ViewManager;
|
||||
class RootSpace;
|
||||
|
||||
class Space
|
||||
class Space : public Specter::ISpaceController
|
||||
{
|
||||
friend class SplitSpace;
|
||||
public:
|
||||
virtual ~Space() = default;
|
||||
Space(const Space& other) = delete;
|
||||
Space& operator=(const Space& other) = delete;
|
||||
|
||||
enum class Class
|
||||
{
|
||||
None,
|
||||
RootSpace,
|
||||
SplitSpace,
|
||||
TestSpace,
|
||||
ResourceBrowser,
|
||||
};
|
||||
|
||||
struct State : Athena::io::DNAYaml<Athena::BigEndian> {Delete _d;};
|
||||
static Space* NewSpaceFromConfigStream(ViewManager& vm, ConfigReader& r);
|
||||
static Space* NewSpaceFromConfigStream(ViewManager& vm, Space* parent, ConfigReader& r);
|
||||
static RootSpace* NewRootSpaceFromConfigStream(ViewManager& vm, ConfigReader& r);
|
||||
|
||||
protected:
|
||||
friend class ViewManager;
|
||||
friend class RootSpace;
|
||||
ViewManager& m_vm;
|
||||
Class m_class = Class::None;
|
||||
Space* m_parent;
|
||||
std::unique_ptr<Specter::Space> m_space;
|
||||
Space(ViewManager& vm, Class cls) : m_vm(vm), m_class(cls) {}
|
||||
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 */
|
||||
virtual const Space::State& spaceState() const=0;
|
||||
|
@ -56,9 +62,80 @@ public:
|
|||
virtual void reloadState() {}
|
||||
|
||||
virtual void think() {}
|
||||
|
||||
virtual Space* copy(Space* parent) const=0;
|
||||
bool spaceSplitAllowed() const {return true;}
|
||||
|
||||
Specter::ISplitSpaceController* spaceSplit(Specter::SplitView::Axis axis, int thisSlot);
|
||||
virtual std::unique_ptr<Space> exchangeSpaceSplitJoin(Space* removeSpace, std::unique_ptr<Space>&& keepSpace)
|
||||
{return std::unique_ptr<Space>();}
|
||||
};
|
||||
|
||||
class SplitSpace : public Space
|
||||
class RootSpace : public Space
|
||||
{
|
||||
friend class ViewManager;
|
||||
std::unique_ptr<Space> m_child;
|
||||
struct State : Space::State
|
||||
{
|
||||
DECL_YAML
|
||||
} m_state;
|
||||
const Space::State& spaceState() const {return m_state;}
|
||||
|
||||
public:
|
||||
RootSpace(ViewManager& vm) : Space(vm, Class::RootSpace, nullptr) {}
|
||||
RootSpace(ViewManager& vm, ConfigReader& r)
|
||||
: RootSpace(vm)
|
||||
{
|
||||
m_state.read(r);
|
||||
#ifdef URDE_BINARY_CONFIGS
|
||||
m_child.reset(NewSpaceFromConfigStream(vm, this, r));
|
||||
#else
|
||||
r.enterSubRecord("child");
|
||||
m_child.reset(NewSpaceFromConfigStream(vm, this, r));
|
||||
r.leaveSubRecord();
|
||||
#endif
|
||||
}
|
||||
|
||||
void saveState(Athena::io::IStreamWriter& w) const
|
||||
{
|
||||
w.writeUint32Big(atUint32(m_class));
|
||||
m_state.write(w);
|
||||
|
||||
if (m_child)
|
||||
m_child->saveState(w);
|
||||
else
|
||||
w.writeUint32Big(0);
|
||||
}
|
||||
|
||||
void saveState(Athena::io::YAMLDocWriter& w) const
|
||||
{
|
||||
w.writeUint32("class", atUint32(m_class));
|
||||
m_state.write(w);
|
||||
|
||||
w.enterSubRecord("child");
|
||||
if (m_child)
|
||||
m_child->saveState(w);
|
||||
else
|
||||
w.writeUint32("class", 0);
|
||||
w.leaveSubRecord();
|
||||
}
|
||||
|
||||
void setChild(std::unique_ptr<Space>&& space)
|
||||
{
|
||||
m_child = std::move(space);
|
||||
m_child->m_parent = this;
|
||||
}
|
||||
|
||||
Space* copy(Space* parent) const {return nullptr;}
|
||||
bool spaceSplitAllowed() const {return false;}
|
||||
|
||||
Specter::View* buildSpaceView(Specter::ViewResources& res) {return buildContentView(res);}
|
||||
Specter::View* buildContentView(Specter::ViewResources& res) {return m_child->buildSpaceView(res);}
|
||||
|
||||
std::unique_ptr<Space> exchangeSpaceSplitJoin(Space* removeSpace, std::unique_ptr<Space>&& keepSpace);
|
||||
};
|
||||
|
||||
class SplitSpace : public Space, public Specter::ISplitSpaceController
|
||||
{
|
||||
friend class ViewManager;
|
||||
std::unique_ptr<Space> m_slots[2];
|
||||
|
@ -71,20 +148,20 @@ class SplitSpace : public Space
|
|||
const Space::State& spaceState() const {return m_state;}
|
||||
|
||||
public:
|
||||
SplitSpace(ViewManager& vm) : Space(vm, Class::SplitSpace) {}
|
||||
SplitSpace(ViewManager& vm, ConfigReader& r)
|
||||
: SplitSpace(vm)
|
||||
SplitSpace(ViewManager& vm, Space* parent) : Space(vm, Class::SplitSpace, parent) {}
|
||||
SplitSpace(ViewManager& vm, Space* parent, ConfigReader& r)
|
||||
: SplitSpace(vm, parent)
|
||||
{
|
||||
m_state.read(r);
|
||||
#ifdef URDE_BINARY_CONFIGS
|
||||
m_slots[0].reset(NewSpaceFromConfigStream(vm, r));
|
||||
m_slots[1].reset(NewSpaceFromConfigStream(vm, r));
|
||||
m_slots[0].reset(NewSpaceFromConfigStream(vm, this, r));
|
||||
m_slots[1].reset(NewSpaceFromConfigStream(vm, this, r));
|
||||
#else
|
||||
r.enterSubRecord("slot0");
|
||||
m_slots[0].reset(NewSpaceFromConfigStream(vm, r));
|
||||
m_slots[0].reset(NewSpaceFromConfigStream(vm, this, r));
|
||||
r.leaveSubRecord();
|
||||
r.enterSubRecord("slot1");
|
||||
m_slots[1].reset(NewSpaceFromConfigStream(vm, r));
|
||||
m_slots[1].reset(NewSpaceFromConfigStream(vm, this, r));
|
||||
r.leaveSubRecord();
|
||||
#endif
|
||||
}
|
||||
|
@ -126,10 +203,31 @@ public:
|
|||
w.leaveSubRecord();
|
||||
}
|
||||
|
||||
void setSpaceSlot(unsigned slot, std::unique_ptr<Space>&& space);
|
||||
void setChildSlot(unsigned slot, std::unique_ptr<Space>&& space);
|
||||
|
||||
Specter::View* buildSpaceView(Specter::ViewResources& res) {return buildContentView(res);}
|
||||
Specter::View* buildContentView(Specter::ViewResources& res);
|
||||
|
||||
Space* copy(Space* parent) const {return nullptr;}
|
||||
bool spaceSplitAllowed() const {return false;}
|
||||
|
||||
ISpaceController* spaceJoin(int keepSlot)
|
||||
{
|
||||
if (m_parent)
|
||||
{
|
||||
ISpaceController* ret = m_slots[keepSlot].get();
|
||||
m_parent->exchangeSpaceSplitJoin(this, std::move(m_slots[keepSlot]));
|
||||
return ret;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
std::unique_ptr<Space> exchangeSpaceSplitJoin(Space* removeSpace, std::unique_ptr<Space>&& keepSpace);
|
||||
|
||||
Specter::SplitView* splitView()
|
||||
{
|
||||
return m_splitView.get();
|
||||
}
|
||||
};
|
||||
|
||||
class TestSpace : public Space
|
||||
|
@ -143,9 +241,9 @@ class TestSpace : public Space
|
|||
Specter::IButtonBinding* m_binding;
|
||||
|
||||
public:
|
||||
TestSpace(ViewManager& vm, const std::string& content, const std::string& button,
|
||||
TestSpace(ViewManager& vm, Space* parent, const std::string& content, const std::string& button,
|
||||
Specter::IButtonBinding* binding)
|
||||
: Space(vm, Class::TestSpace), m_contentStr(content), m_buttonStr(button), m_binding(binding)
|
||||
: Space(vm, Class::TestSpace, parent), m_contentStr(content), m_buttonStr(button), m_binding(binding)
|
||||
{}
|
||||
|
||||
struct State : Space::State
|
||||
|
|
|
@ -43,7 +43,7 @@ class SplashScreen : public Specter::ModalWindow
|
|||
m_splash.m_fileBrowser.m_view.reset(
|
||||
new Specter::FileBrowser(m_splash.rootView().viewRes(),
|
||||
m_splash, m_splash.m_newString,
|
||||
Specter::FileBrowser::Type::SaveDirectory,
|
||||
Specter::FileBrowser::Type::NewHECLProject,
|
||||
[&](bool ok, const HECL::SystemString& path)
|
||||
{
|
||||
if (ok)
|
||||
|
|
|
@ -33,10 +33,12 @@ SplashScreen* ViewManager::SetupSplashView()
|
|||
|
||||
void ViewManager::SetupEditorView()
|
||||
{
|
||||
SplitSpace* split = new SplitSpace(*this);
|
||||
split->setSpaceSlot(0, std::make_unique<ResourceBrowser>(*this));
|
||||
split->setSpaceSlot(1, std::make_unique<ResourceBrowser>(*this));
|
||||
m_rootSpace.reset(split);
|
||||
m_rootSpace.reset(new RootSpace(*this));
|
||||
|
||||
SplitSpace* split = new SplitSpace(*this, nullptr);
|
||||
m_rootSpace->setChild(std::unique_ptr<Space>(split));
|
||||
split->setChildSlot(0, std::make_unique<ResourceBrowser>(*this, split));
|
||||
split->setChildSlot(1, std::make_unique<ResourceBrowser>(*this, split));
|
||||
|
||||
std::vector<Specter::View*>& cViews = m_rootView->accessContentViews();
|
||||
cViews.clear();
|
||||
|
@ -47,7 +49,7 @@ void ViewManager::SetupEditorView()
|
|||
|
||||
void ViewManager::SetupEditorView(ConfigReader& r)
|
||||
{
|
||||
m_rootSpace.reset(Space::NewSpaceFromConfigStream(*this, r));
|
||||
m_rootSpace.reset(Space::NewRootSpaceFromConfigStream(*this, r));
|
||||
std::vector<Specter::View*>& cViews = m_rootView->accessContentViews();
|
||||
cViews.clear();
|
||||
cViews.push_back(BuildSpaceViews(m_rootSpace.get()));
|
||||
|
@ -96,7 +98,7 @@ void ViewManager::init(boo::IApplication* app)
|
|||
float pixelFactor = 1.0;
|
||||
|
||||
boo::IGraphicsDataFactory* gf = m_mainWindow->getMainContextDataFactory();
|
||||
m_viewResources.init(gf, &m_fontCache, Specter::ThemeData(), pixelFactor);
|
||||
m_viewResources.init(gf, &m_fontCache, &m_themeData, pixelFactor);
|
||||
m_viewResources.prepFontCacheAsync(m_mainWindow.get());
|
||||
Specter::RootView* root = SetupRootView();
|
||||
m_showSplash = true;
|
||||
|
|
|
@ -17,13 +17,14 @@ class ViewManager : public Specter::IViewManager
|
|||
HECL::CVarManager& m_cvarManager;
|
||||
ProjectManager m_projManager;
|
||||
Specter::FontCache m_fontCache;
|
||||
Specter::DefaultThemeData m_themeData;
|
||||
Specter::ViewResources m_viewResources;
|
||||
Specter::Translator m_translator;
|
||||
std::unique_ptr<boo::IWindow> m_mainWindow;
|
||||
|
||||
std::unique_ptr<Specter::RootView> m_rootView;
|
||||
std::unique_ptr<SplashScreen> m_splash;
|
||||
std::unique_ptr<Space> m_rootSpace;
|
||||
std::unique_ptr<RootSpace> m_rootSpace;
|
||||
Specter::View* m_rootSpaceView = nullptr;
|
||||
|
||||
std::vector<HECL::SystemString> m_recentProjects;
|
||||
|
|
2
hecl
2
hecl
|
@ -1 +1 @@
|
|||
Subproject commit 1b3bdb7c2e72c1c9971c2bb46f06c65a3b78ae1e
|
||||
Subproject commit fcedcb508e0f2c8edb4ad857738e1e664f2d6c95
|
|
@ -1 +1 @@
|
|||
Subproject commit e63ddda724ec6a3760077ec1be6192ca123bbb15
|
||||
Subproject commit 168b7c8cceb306c53cdaf1b30f3d5c5344f89205
|
Loading…
Reference in New Issue