2015-12-10 18:37:54 -08:00
|
|
|
#ifndef RUDE_SPACE_HPP
|
|
|
|
#define RUDE_SPACE_HPP
|
|
|
|
|
|
|
|
#include <Athena/DNAYaml.hpp>
|
2015-12-11 16:37:32 -08:00
|
|
|
#include <Specter/Specter.hpp>
|
2015-12-10 18:37:54 -08:00
|
|
|
|
|
|
|
namespace Specter
|
|
|
|
{
|
|
|
|
class View;
|
|
|
|
class SplitView;
|
|
|
|
class ViewResources;
|
|
|
|
class Toolbar;
|
|
|
|
}
|
|
|
|
namespace RUDE
|
|
|
|
{
|
|
|
|
class ViewManager;
|
|
|
|
|
|
|
|
class Space
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
enum class Class
|
|
|
|
{
|
|
|
|
None,
|
2015-12-11 16:37:32 -08:00
|
|
|
SplitSpace,
|
|
|
|
TestSpace,
|
2015-12-10 18:37:54 -08:00
|
|
|
ResourceOutliner,
|
|
|
|
};
|
2016-01-03 21:31:02 -08:00
|
|
|
|
|
|
|
struct StateHead : Athena::io::DNAYaml<Athena::BigEndian>
|
|
|
|
{
|
|
|
|
DECL_YAML
|
|
|
|
Value<Class> cls;
|
|
|
|
};
|
|
|
|
struct State : Athena::io::DNAYaml<Athena::BigEndian> {Delete _d;};
|
|
|
|
|
|
|
|
static Space* NewSpaceFromYAMLStream(ViewManager& vm, Athena::io::YAMLDocReader& r);
|
|
|
|
|
2015-12-10 18:37:54 -08:00
|
|
|
protected:
|
2015-12-11 16:37:32 -08:00
|
|
|
friend class ViewManager;
|
2015-12-10 18:37:54 -08:00
|
|
|
ViewManager& m_vm;
|
|
|
|
Class m_class = Class::None;
|
2015-12-11 16:37:32 -08:00
|
|
|
std::unique_ptr<Specter::Space> m_space;
|
2015-12-10 18:37:54 -08:00
|
|
|
Space(ViewManager& vm, Class cls) : m_vm(vm), m_class(cls) {}
|
|
|
|
|
|
|
|
/* Allows common Space code to access DNA-encoded state */
|
2016-01-03 21:31:02 -08:00
|
|
|
virtual Space::State& spaceState()=0;
|
2015-12-10 18:37:54 -08:00
|
|
|
|
|
|
|
/* Structural control */
|
|
|
|
virtual bool usesToolbar() const {return false;}
|
2016-01-03 21:31:02 -08:00
|
|
|
virtual void buildToolbarView(Specter::ViewResources& res, Specter::Toolbar& tb) {}
|
|
|
|
virtual Specter::View* buildContentView(Specter::ViewResources& res)=0;
|
|
|
|
Specter::Space* buildSpaceView(Specter::ViewResources& res);
|
2015-12-12 18:27:34 -08:00
|
|
|
public:
|
2015-12-10 18:37:54 -08:00
|
|
|
};
|
|
|
|
|
2015-12-11 16:37:32 -08:00
|
|
|
class SplitSpace : public Space
|
2015-12-10 18:37:54 -08:00
|
|
|
{
|
2015-12-11 16:37:32 -08:00
|
|
|
friend class ViewManager;
|
2016-01-03 21:31:02 -08:00
|
|
|
std::unique_ptr<Space> m_a;
|
|
|
|
std::unique_ptr<Space> m_b;
|
2015-12-11 16:37:32 -08:00
|
|
|
std::unique_ptr<Specter::SplitView> m_splitView;
|
2016-01-03 21:31:02 -08:00
|
|
|
struct State : Space::State
|
2015-12-10 18:37:54 -08:00
|
|
|
{
|
|
|
|
DECL_YAML
|
2016-01-03 21:31:02 -08:00
|
|
|
Value<float> split;
|
2015-12-10 18:37:54 -08:00
|
|
|
} m_state;
|
2016-01-03 21:31:02 -08:00
|
|
|
Space::State& spaceState() {return m_state;}
|
2015-12-11 16:37:32 -08:00
|
|
|
|
|
|
|
public:
|
2016-01-03 21:31:02 -08:00
|
|
|
SplitSpace(ViewManager& vm) : Space(vm, Class::SplitSpace) {}
|
|
|
|
SplitSpace(ViewManager& vm, Athena::io::YAMLDocReader& r)
|
|
|
|
: SplitSpace(vm)
|
|
|
|
{
|
|
|
|
m_state.read(r);
|
|
|
|
m_a.reset(NewSpaceFromYAMLStream(vm, r));
|
|
|
|
m_b.reset(NewSpaceFromYAMLStream(vm, r));
|
|
|
|
}
|
|
|
|
|
|
|
|
Specter::View* buildContentView(Specter::ViewResources& res);
|
2015-12-11 16:37:32 -08:00
|
|
|
};
|
|
|
|
|
|
|
|
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)
|
|
|
|
{}
|
|
|
|
|
2016-01-03 21:31:02 -08:00
|
|
|
struct State : Space::State
|
2015-12-11 16:37:32 -08:00
|
|
|
{
|
|
|
|
DECL_YAML
|
|
|
|
} m_state;
|
2016-01-03 21:31:02 -08:00
|
|
|
Space::State& spaceState() {return m_state;}
|
2015-12-11 16:37:32 -08:00
|
|
|
|
|
|
|
bool usesToolbar() const {return true;}
|
2016-01-03 21:31:02 -08:00
|
|
|
void buildToolbarView(Specter::ViewResources& res, Specter::Toolbar& tb)
|
2015-12-11 16:37:32 -08:00
|
|
|
{
|
|
|
|
m_button.reset(new Specter::Button(res, tb, m_binding, m_buttonStr));
|
|
|
|
tb.push_back(m_button.get());
|
|
|
|
}
|
|
|
|
|
2016-01-03 21:31:02 -08:00
|
|
|
Specter::View* buildContentView(Specter::ViewResources& res)
|
2015-12-11 16:37:32 -08:00
|
|
|
{
|
|
|
|
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-10 18:37:54 -08:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // RUDE_SPACE_HPP
|