Mulling around with space state tracking system

This commit is contained in:
Jack Andersen 2015-12-10 16:37:54 -10:00
parent dae5e4b44e
commit d3af294056
7 changed files with 81 additions and 16 deletions

View File

@ -8,7 +8,8 @@ set(SPACE_SOURCES
ResourceOutliner/ResourceOutliner.cpp)
add_executable(rude WIN32
main.cpp ISpace.hpp
main.cpp
Space.hpp Space.cpp
${SPACE_HEADERS} ${SPACE_SOURCES}
ViewManager.hpp ViewManager.cpp)

View File

@ -1,13 +0,0 @@
#ifndef RUDE_ISPACE_HPP
#define RUDE_ISPACE_HPP
namespace RUDE
{
class ISpace
{
};
}
#endif // RUDE_ISPACE_HPP

View File

@ -1,13 +1,20 @@
#ifndef RUDE_RESOURCE_OUTLINER_HPP
#define RUDE_RESOURCE_OUTLINER_HPP
#include "ISpace.hpp"
#include "Space.hpp"
namespace RUDE
{
class ResourceOutliner : public ISpace
struct ResourceOutlinerState : SpaceState
{
DECL_YAML
};
class ResourceOutliner : public Space
{
ResourceOutlinerState m_state;
SpaceState& spaceState() {return m_state;}
};
}

7
Editor/Space.cpp Normal file
View File

@ -0,0 +1,7 @@
#include "Space.hpp"
namespace RUDE
{
}

60
Editor/Space.hpp Normal file
View File

@ -0,0 +1,60 @@
#ifndef RUDE_SPACE_HPP
#define RUDE_SPACE_HPP
#include <Athena/DNAYaml.hpp>
#include <Specter/Space.hpp>
namespace Specter
{
class View;
class SplitView;
class ViewResources;
class Toolbar;
}
namespace RUDE
{
class ViewManager;
struct SpaceState : Athena::io::DNAYaml<Athena::BigEndian> {};
class Space
{
std::unique_ptr<Specter::Space> m_space;
public:
enum class Class
{
None,
Split,
ResourceOutliner,
};
protected:
ViewManager& m_vm;
Class m_class = Class::None;
Space(ViewManager& vm, Class cls) : m_vm(vm), m_class(cls) {}
Space(ViewManager& vm, Class cls, Athena::io::IStreamReader& r) : m_vm(vm), m_class(cls) {}
void writeState(Athena::io::IStreamWriter& w) const;
/* Allows common Space code to access DNA-encoded state */
virtual SpaceState& spaceState()=0;
/* Structural control */
virtual bool usesToolbar() const {return false;}
virtual void buildToolbar(Specter::ViewResources& res, Specter::Toolbar& tb) {}
virtual Specter::View* buildContent(Specter::ViewResources& res)=0;
public:
};
class Split : public Space
{
std::unique_ptr<Specter::SplitView> m_split;
struct State : SpaceState
{
DECL_YAML
Value<float> m_split;
} m_state;
SpaceState& spaceState() {return m_state;}
};
}
#endif // RUDE_SPACE_HPP

View File

@ -1,6 +1,8 @@
#include "ViewManager.hpp"
#include "Specter/Control.hpp"
using YAMLNode = Athena::io::YAMLNode;
namespace RUDE
{

View File

@ -3,6 +3,7 @@
#include <Specter/Specter.hpp>
#include <HECL/CVarManager.hpp>
#include "Space.hpp"
namespace RUDE
{