metaforce/Editor/Space.cpp

63 lines
1.7 KiB
C++
Raw Normal View History

#include "Space.hpp"
#include "ViewManager.hpp"
2016-01-04 05:31:02 +00:00
#include "ResourceOutliner.hpp"
namespace RUDE
{
2016-01-05 00:01:02 +00:00
static LogVisor::LogModule Log("RUDE::Space");
2016-01-05 00:01:02 +00:00
Specter::View* Space::buildSpaceView(Specter::ViewResources& res)
{
m_space.reset(new Specter::Space(res, m_vm.rootView(), Specter::Toolbar::Position::Bottom));
2016-01-05 00:01:02 +00:00
Specter::View* sview = buildContentView(res);
m_space->setContentView(sview);
if (usesToolbar())
buildToolbarView(res, m_space->toolbar());
return m_space.get();
}
2016-01-04 05:31:02 +00:00
Specter::View* SplitSpace::buildContentView(Specter::ViewResources& res)
{
m_splitView.reset(new Specter::SplitView(res, m_vm.rootView(), Specter::SplitView::Axis::Horizontal));
2016-01-05 00:01:02 +00:00
if (m_slots[0])
m_splitView->setContentView(0, m_slots[0]->buildSpaceView(res));
if (m_slots[1])
m_splitView->setContentView(1, m_slots[1]->buildSpaceView(res));
return m_splitView.get();
}
2016-01-05 00:01:02 +00:00
void SplitSpace::setSpaceSlot(unsigned slot, std::unique_ptr<Space>&& space)
2016-01-04 05:31:02 +00:00
{
2016-01-05 00:01:02 +00:00
if (slot > 1)
Log.report(LogVisor::FatalError, "invalid slot %u for SplitView", slot);
m_slots[slot] = std::move(space);
}
template <class Reader>
static Space* BuildNewSpace(ViewManager& vm, Space::Class cls, Reader& r)
{
using Class = Space::Class;
switch (cls)
2016-01-04 05:31:02 +00:00
{
case Class::SplitSpace:
return new SplitSpace(vm, r);
case Class::ResourceOutliner:
return new ResourceOutliner(vm, r);
default: break;
}
return nullptr;
}
2016-01-05 00:01:02 +00:00
Space* Space::NewSpaceFromConfigStream(ViewManager& vm, ConfigReader& r)
{
#ifdef RUDE_BINARY_CONFIGS
Class cls = Class(r.readUint32Big());
return BuildNewSpace(vm, cls, r);
#else
Class cls = Class(r.readUint32("class"));
return BuildNewSpace(vm, cls, r);
#endif
}
}