2015-12-11 02:37:54 +00:00
|
|
|
#ifndef RUDE_SPACE_HPP
|
|
|
|
#define RUDE_SPACE_HPP
|
|
|
|
|
|
|
|
#include <Athena/DNAYaml.hpp>
|
2015-12-12 00:37:32 +00:00
|
|
|
#include <Specter/Specter.hpp>
|
2015-12-11 02:37:54 +00:00
|
|
|
|
|
|
|
namespace Specter
|
|
|
|
{
|
|
|
|
class View;
|
|
|
|
class SplitView;
|
|
|
|
class ViewResources;
|
|
|
|
class Toolbar;
|
|
|
|
}
|
|
|
|
namespace RUDE
|
|
|
|
{
|
|
|
|
class ViewManager;
|
|
|
|
|
2015-12-12 00:37:32 +00:00
|
|
|
struct SpaceState : Athena::io::DNAYaml<Athena::BigEndian> {Delete _d;};
|
2015-12-11 02:37:54 +00:00
|
|
|
|
|
|
|
class Space
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
enum class Class
|
|
|
|
{
|
|
|
|
None,
|
2015-12-12 00:37:32 +00:00
|
|
|
SplitSpace,
|
|
|
|
TestSpace,
|
2015-12-11 02:37:54 +00:00
|
|
|
ResourceOutliner,
|
|
|
|
};
|
|
|
|
protected:
|
2015-12-12 00:37:32 +00:00
|
|
|
friend class ViewManager;
|
2015-12-11 02:37:54 +00:00
|
|
|
ViewManager& m_vm;
|
|
|
|
Class m_class = Class::None;
|
2015-12-12 00:37:32 +00:00
|
|
|
std::unique_ptr<Specter::Space> m_space;
|
2015-12-11 02:37:54 +00:00
|
|
|
Space(ViewManager& vm, Class cls) : m_vm(vm), m_class(cls) {}
|
2015-12-12 00:37:32 +00:00
|
|
|
Space(ViewManager& vm, Class cls, Athena::io::IStreamReader& r) : m_vm(vm), m_class(cls)
|
|
|
|
{if (spaceState()) spaceState()->read(r);}
|
2015-12-11 02:37:54 +00:00
|
|
|
void writeState(Athena::io::IStreamWriter& w) const;
|
|
|
|
|
|
|
|
/* Allows common Space code to access DNA-encoded state */
|
2015-12-12 00:37:32 +00:00
|
|
|
virtual SpaceState* spaceState() {return nullptr;}
|
2015-12-11 02:37:54 +00:00
|
|
|
|
|
|
|
/* 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:
|
2015-12-12 00:37:32 +00:00
|
|
|
Specter::Space* buildSpace(Specter::ViewResources& res);
|
2015-12-11 02:37:54 +00:00
|
|
|
};
|
|
|
|
|
2015-12-12 00:37:32 +00:00
|
|
|
class SplitSpace : public Space
|
2015-12-11 02:37:54 +00:00
|
|
|
{
|
2015-12-12 00:37:32 +00:00
|
|
|
friend class ViewManager;
|
|
|
|
std::unique_ptr<Specter::SplitView> m_splitView;
|
2015-12-11 02:37:54 +00:00
|
|
|
struct State : SpaceState
|
|
|
|
{
|
|
|
|
DECL_YAML
|
|
|
|
Value<float> m_split;
|
|
|
|
} m_state;
|
2015-12-12 00:37:32 +00:00
|
|
|
SpaceState* spaceState() {return &m_state;}
|
|
|
|
|
|
|
|
public:
|
|
|
|
SplitSpace(ViewManager& vm)
|
|
|
|
: Space(vm, Class::SplitSpace) {}
|
|
|
|
Specter::View* buildContent(Specter::ViewResources& res);
|
|
|
|
};
|
|
|
|
|
|
|
|
class TestSpace : public Space
|
|
|
|
{
|
|
|
|
std::unique_ptr<Specter::Button> m_button;
|
|
|
|
std::unique_ptr<Specter::MultiLineTextView> m_textView;
|
|
|
|
|
|
|
|
std::string m_contentStr;
|
|
|
|
std::string m_buttonStr;
|
|
|
|
|
|
|
|
Specter::IButtonBinding* m_binding;
|
|
|
|
|
|
|
|
public:
|
|
|
|
TestSpace(ViewManager& vm, const std::string& content, const std::string& button,
|
|
|
|
Specter::IButtonBinding* binding)
|
|
|
|
: Space(vm, Class::TestSpace), m_contentStr(content), m_buttonStr(button), m_binding(binding)
|
|
|
|
{}
|
|
|
|
|
|
|
|
struct State : SpaceState
|
|
|
|
{
|
|
|
|
DECL_YAML
|
|
|
|
} m_state;
|
|
|
|
SpaceState* spaceState() {return &m_state;}
|
|
|
|
|
|
|
|
bool usesToolbar() const {return true;}
|
|
|
|
void buildToolbar(Specter::ViewResources& res, Specter::Toolbar& tb)
|
|
|
|
{
|
|
|
|
m_button.reset(new Specter::Button(res, tb, m_binding, m_buttonStr));
|
|
|
|
tb.push_back(m_button.get());
|
|
|
|
}
|
|
|
|
|
|
|
|
Specter::View* buildContent(Specter::ViewResources& res)
|
|
|
|
{
|
|
|
|
m_textView.reset(new Specter::MultiLineTextView(res, *m_space, res.m_heading14));
|
|
|
|
m_textView->setBackground(res.themeData().viewportBackground());
|
|
|
|
m_textView->typesetGlyphs(m_contentStr, res.themeData().uiText());
|
|
|
|
return m_textView.get();
|
|
|
|
}
|
2015-12-11 02:37:54 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // RUDE_SPACE_HPP
|