2015-12-11 02:37:54 +00:00
|
|
|
#include "Space.hpp"
|
2015-12-12 00:37:32 +00:00
|
|
|
#include "ViewManager.hpp"
|
2016-01-04 05:31:02 +00:00
|
|
|
#include "ResourceOutliner.hpp"
|
2015-12-11 02:37:54 +00:00
|
|
|
|
2016-01-05 09:53:16 +00:00
|
|
|
namespace URDE
|
2015-12-11 02:37:54 +00:00
|
|
|
{
|
2016-01-05 09:53:16 +00:00
|
|
|
static LogVisor::LogModule Log("URDE::Space");
|
2015-12-11 02:37:54 +00:00
|
|
|
|
2016-01-05 00:01:02 +00:00
|
|
|
Specter::View* Space::buildSpaceView(Specter::ViewResources& res)
|
2015-12-12 00:37:32 +00:00
|
|
|
{
|
|
|
|
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());
|
2015-12-12 00:37:32 +00:00
|
|
|
return m_space.get();
|
|
|
|
}
|
|
|
|
|
2016-01-04 05:31:02 +00:00
|
|
|
Specter::View* SplitSpace::buildContentView(Specter::ViewResources& res)
|
2015-12-12 00:37:32 +00:00
|
|
|
{
|
|
|
|
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));
|
2015-12-12 00:37:32 +00:00
|
|
|
return m_splitView.get();
|
|
|
|
}
|
2015-12-11 02:37:54 +00:00
|
|
|
|
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)
|
|
|
|
{
|
2016-01-05 09:53:16 +00:00
|
|
|
#ifdef URDE_BINARY_CONFIGS
|
2016-01-05 00:01:02 +00:00
|
|
|
Class cls = Class(r.readUint32Big());
|
|
|
|
return BuildNewSpace(vm, cls, r);
|
|
|
|
#else
|
|
|
|
Class cls = Class(r.readUint32("class"));
|
|
|
|
return BuildNewSpace(vm, cls, r);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2015-12-11 02:37:54 +00:00
|
|
|
}
|