mirror of https://github.com/AxioDL/metaforce.git
Recreated test layout in new space architecture
This commit is contained in:
parent
d3af294056
commit
0dad45e894
|
@ -1,6 +1,8 @@
|
||||||
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
|
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
|
||||||
add_subdirectory(locale)
|
add_subdirectory(locale)
|
||||||
|
|
||||||
|
atdna(atdna_Space.cpp Space.hpp)
|
||||||
|
|
||||||
set(SPACE_HEADERS
|
set(SPACE_HEADERS
|
||||||
ResourceOutliner/ResourceOutliner.hpp)
|
ResourceOutliner/ResourceOutliner.hpp)
|
||||||
|
|
||||||
|
@ -9,7 +11,7 @@ set(SPACE_SOURCES
|
||||||
|
|
||||||
add_executable(rude WIN32
|
add_executable(rude WIN32
|
||||||
main.cpp
|
main.cpp
|
||||||
Space.hpp Space.cpp
|
Space.hpp Space.cpp atdna_Space.cpp
|
||||||
${SPACE_HEADERS} ${SPACE_SOURCES}
|
${SPACE_HEADERS} ${SPACE_SOURCES}
|
||||||
ViewManager.hpp ViewManager.cpp)
|
ViewManager.hpp ViewManager.cpp)
|
||||||
|
|
||||||
|
|
|
@ -6,15 +6,13 @@
|
||||||
namespace RUDE
|
namespace RUDE
|
||||||
{
|
{
|
||||||
|
|
||||||
struct ResourceOutlinerState : SpaceState
|
|
||||||
{
|
|
||||||
DECL_YAML
|
|
||||||
};
|
|
||||||
|
|
||||||
class ResourceOutliner : public Space
|
class ResourceOutliner : public Space
|
||||||
{
|
{
|
||||||
ResourceOutlinerState m_state;
|
struct State : SpaceState
|
||||||
SpaceState& spaceState() {return m_state;}
|
{
|
||||||
|
DECL_YAML
|
||||||
|
} m_state;
|
||||||
|
SpaceState* spaceState() {return &m_state;}
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,19 @@
|
||||||
#include "Space.hpp"
|
#include "Space.hpp"
|
||||||
|
#include "ViewManager.hpp"
|
||||||
|
|
||||||
namespace RUDE
|
namespace RUDE
|
||||||
{
|
{
|
||||||
|
|
||||||
|
Specter::Space* Space::buildSpace(Specter::ViewResources& res)
|
||||||
|
{
|
||||||
|
m_space.reset(new Specter::Space(res, m_vm.rootView(), Specter::Toolbar::Position::Bottom));
|
||||||
|
return m_space.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
Specter::View* SplitSpace::buildContent(Specter::ViewResources& res)
|
||||||
|
{
|
||||||
|
m_splitView.reset(new Specter::SplitView(res, m_vm.rootView(), Specter::SplitView::Axis::Horizontal));
|
||||||
|
return m_splitView.get();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
#define RUDE_SPACE_HPP
|
#define RUDE_SPACE_HPP
|
||||||
|
|
||||||
#include <Athena/DNAYaml.hpp>
|
#include <Athena/DNAYaml.hpp>
|
||||||
#include <Specter/Space.hpp>
|
#include <Specter/Specter.hpp>
|
||||||
|
|
||||||
namespace Specter
|
namespace Specter
|
||||||
{
|
{
|
||||||
|
@ -15,44 +15,92 @@ namespace RUDE
|
||||||
{
|
{
|
||||||
class ViewManager;
|
class ViewManager;
|
||||||
|
|
||||||
struct SpaceState : Athena::io::DNAYaml<Athena::BigEndian> {};
|
struct SpaceState : Athena::io::DNAYaml<Athena::BigEndian> {Delete _d;};
|
||||||
|
|
||||||
class Space
|
class Space
|
||||||
{
|
{
|
||||||
std::unique_ptr<Specter::Space> m_space;
|
|
||||||
public:
|
public:
|
||||||
enum class Class
|
enum class Class
|
||||||
{
|
{
|
||||||
None,
|
None,
|
||||||
Split,
|
SplitSpace,
|
||||||
|
TestSpace,
|
||||||
ResourceOutliner,
|
ResourceOutliner,
|
||||||
};
|
};
|
||||||
protected:
|
protected:
|
||||||
|
friend class ViewManager;
|
||||||
ViewManager& m_vm;
|
ViewManager& m_vm;
|
||||||
Class m_class = Class::None;
|
Class m_class = Class::None;
|
||||||
|
std::unique_ptr<Specter::Space> m_space;
|
||||||
Space(ViewManager& vm, Class cls) : m_vm(vm), m_class(cls) {}
|
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) {}
|
Space(ViewManager& vm, Class cls, Athena::io::IStreamReader& r) : m_vm(vm), m_class(cls)
|
||||||
|
{if (spaceState()) spaceState()->read(r);}
|
||||||
void writeState(Athena::io::IStreamWriter& w) const;
|
void writeState(Athena::io::IStreamWriter& w) const;
|
||||||
|
|
||||||
/* Allows common Space code to access DNA-encoded state */
|
/* Allows common Space code to access DNA-encoded state */
|
||||||
virtual SpaceState& spaceState()=0;
|
virtual SpaceState* spaceState() {return nullptr;}
|
||||||
|
|
||||||
/* Structural control */
|
/* Structural control */
|
||||||
virtual bool usesToolbar() const {return false;}
|
virtual bool usesToolbar() const {return false;}
|
||||||
virtual void buildToolbar(Specter::ViewResources& res, Specter::Toolbar& tb) {}
|
virtual void buildToolbar(Specter::ViewResources& res, Specter::Toolbar& tb) {}
|
||||||
virtual Specter::View* buildContent(Specter::ViewResources& res)=0;
|
virtual Specter::View* buildContent(Specter::ViewResources& res)=0;
|
||||||
public:
|
public:
|
||||||
|
Specter::Space* buildSpace(Specter::ViewResources& res);
|
||||||
};
|
};
|
||||||
|
|
||||||
class Split : public Space
|
class SplitSpace : public Space
|
||||||
{
|
{
|
||||||
std::unique_ptr<Specter::SplitView> m_split;
|
friend class ViewManager;
|
||||||
|
std::unique_ptr<Specter::SplitView> m_splitView;
|
||||||
struct State : SpaceState
|
struct State : SpaceState
|
||||||
{
|
{
|
||||||
DECL_YAML
|
DECL_YAML
|
||||||
Value<float> m_split;
|
Value<float> m_split;
|
||||||
} m_state;
|
} m_state;
|
||||||
SpaceState& spaceState() {return m_state;}
|
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();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,44 +1,29 @@
|
||||||
#include "ViewManager.hpp"
|
#include "ViewManager.hpp"
|
||||||
#include "Specter/Control.hpp"
|
#include "Specter/Control.hpp"
|
||||||
|
#include "Specter/Space.hpp"
|
||||||
|
|
||||||
using YAMLNode = Athena::io::YAMLNode;
|
using YAMLNode = Athena::io::YAMLNode;
|
||||||
|
|
||||||
namespace RUDE
|
namespace RUDE
|
||||||
{
|
{
|
||||||
|
|
||||||
|
Specter::View* ViewManager::BuildSpaceViews(RUDE::Space* space)
|
||||||
|
{
|
||||||
|
Specter::Space* sspace = space->buildSpace(m_viewResources);
|
||||||
|
Specter::View* sview = space->buildContent(m_viewResources);
|
||||||
|
sspace->setContentView(sview);
|
||||||
|
if (space->usesToolbar())
|
||||||
|
space->buildToolbar(m_viewResources, sspace->toolbar());
|
||||||
|
return sspace;
|
||||||
|
}
|
||||||
|
|
||||||
void ViewManager::SetupRootView()
|
void ViewManager::SetupRootView()
|
||||||
{
|
{
|
||||||
m_rootView.reset(new Specter::RootView(*this, m_viewResources, m_mainWindow.get()));
|
m_rootView.reset(new Specter::RootView(*this, m_viewResources, m_mainWindow.get()));
|
||||||
m_splitView.reset(new Specter::SplitView(m_viewResources, *m_rootView, Specter::SplitView::Axis::Horizontal));
|
|
||||||
m_rootView->setContentView(m_splitView.get());
|
|
||||||
|
|
||||||
m_space1.reset(new Specter::Space(m_viewResources, *m_splitView, Specter::Toolbar::Position::Top));
|
|
||||||
m_butt1.reset(new Specter::Button(m_viewResources, m_space1->toolbar(),
|
|
||||||
&m_setTo1, "Hello Button"));
|
|
||||||
m_space1->toolbar().push_back(m_butt1.get());
|
|
||||||
|
|
||||||
m_space2.reset(new Specter::Space(m_viewResources, *m_splitView, Specter::Toolbar::Position::Bottom));
|
|
||||||
m_butt2.reset(new Specter::Button(m_viewResources, m_space2->toolbar(),
|
|
||||||
&m_setTo2, "こんにちはボタン"));
|
|
||||||
m_space2->toolbar().push_back(m_butt2.get());
|
|
||||||
|
|
||||||
m_splitView->setContentView(0, m_space1.get());
|
|
||||||
m_splitView->setContentView(1, m_space2.get());
|
|
||||||
|
|
||||||
m_rootView->setBackground(Zeus::CColor::skGrey);
|
m_rootView->setBackground(Zeus::CColor::skGrey);
|
||||||
|
m_rootView->setContentView(m_split.buildContent(m_viewResources));
|
||||||
m_textView1.reset(new Specter::MultiLineTextView(m_viewResources, *m_space1, m_viewResources.m_heading18));
|
m_split.m_splitView->setContentView(0, BuildSpaceViews(&m_space1));
|
||||||
m_space1->setContentView(m_textView1.get());
|
m_split.m_splitView->setContentView(1, BuildSpaceViews(&m_space2));
|
||||||
|
|
||||||
m_textView2.reset(new Specter::MultiLineTextView(m_viewResources, *m_space2, m_viewResources.m_heading18));
|
|
||||||
m_space2->setContentView(m_textView2.get());
|
|
||||||
|
|
||||||
m_textView1->typesetGlyphs("Hello, World!\n\n", m_viewResources.themeData().uiText());
|
|
||||||
m_textView2->typesetGlyphs("こんにちは世界!\n\n", m_viewResources.themeData().uiText());
|
|
||||||
|
|
||||||
m_textView1->setBackground(m_viewResources.themeData().viewportBackground());
|
|
||||||
m_textView2->setBackground(m_viewResources.themeData().viewportBackground());
|
|
||||||
|
|
||||||
m_rootView->updateSize();
|
m_rootView->updateSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
#ifndef RUDE_VIEW_MANAGER_HPP
|
#ifndef RUDE_VIEW_MANAGER_HPP
|
||||||
#define RUDE_VIEW_MANAGER_HPP
|
#define RUDE_VIEW_MANAGER_HPP
|
||||||
|
|
||||||
#include <Specter/Specter.hpp>
|
|
||||||
#include <HECL/CVarManager.hpp>
|
#include <HECL/CVarManager.hpp>
|
||||||
#include "Space.hpp"
|
#include "Space.hpp"
|
||||||
|
|
||||||
|
@ -15,36 +14,15 @@ class ViewManager : Specter::IViewManager
|
||||||
Specter::ViewResources m_viewResources;
|
Specter::ViewResources m_viewResources;
|
||||||
std::unique_ptr<boo::IWindow> m_mainWindow;
|
std::unique_ptr<boo::IWindow> m_mainWindow;
|
||||||
std::unique_ptr<Specter::RootView> m_rootView;
|
std::unique_ptr<Specter::RootView> m_rootView;
|
||||||
std::unique_ptr<Specter::SplitView> m_splitView;
|
|
||||||
|
|
||||||
std::unique_ptr<Specter::Space> m_space1;
|
|
||||||
std::unique_ptr<Specter::Button> m_butt1;
|
|
||||||
std::unique_ptr<Specter::MultiLineTextView> m_textView1;
|
|
||||||
std::unique_ptr<Specter::Space> m_space2;
|
|
||||||
std::unique_ptr<Specter::Button> m_butt2;
|
|
||||||
std::unique_ptr<Specter::MultiLineTextView> m_textView2;
|
|
||||||
|
|
||||||
HECL::CVar* m_cvPixelFactor;
|
HECL::CVar* m_cvPixelFactor;
|
||||||
|
|
||||||
bool m_updatePf = false;
|
bool m_updatePf = false;
|
||||||
float m_reqPf;
|
float m_reqPf;
|
||||||
|
|
||||||
|
Specter::View* BuildSpaceViews(RUDE::Space* space);
|
||||||
void SetupRootView();
|
void SetupRootView();
|
||||||
public:
|
public:
|
||||||
ViewManager(HECL::Runtime::FileStoreManager& fileMgr, HECL::CVarManager& cvarMgr)
|
|
||||||
: m_cvarManager(cvarMgr), m_fontCache(fileMgr), m_setTo1(*this), m_setTo2(*this) {}
|
|
||||||
|
|
||||||
Specter::RootView& rootView() const {return *m_rootView;}
|
|
||||||
void RequestPixelFactor(float pf)
|
|
||||||
{
|
|
||||||
m_reqPf = pf;
|
|
||||||
m_updatePf = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void init(boo::IApplication* app);
|
|
||||||
bool proc();
|
|
||||||
void stop();
|
|
||||||
|
|
||||||
struct SetTo1 : Specter::IButtonBinding
|
struct SetTo1 : Specter::IButtonBinding
|
||||||
{
|
{
|
||||||
ViewManager& m_vm;
|
ViewManager& m_vm;
|
||||||
|
@ -76,6 +54,29 @@ public:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
SetTo2 m_setTo2;
|
SetTo2 m_setTo2;
|
||||||
|
|
||||||
|
SplitSpace m_split;
|
||||||
|
TestSpace m_space1;
|
||||||
|
TestSpace m_space2;
|
||||||
|
|
||||||
|
ViewManager(HECL::Runtime::FileStoreManager& fileMgr, HECL::CVarManager& cvarMgr)
|
||||||
|
: m_cvarManager(cvarMgr), m_fontCache(fileMgr),
|
||||||
|
m_setTo1(*this), m_setTo2(*this),
|
||||||
|
m_split(*this),
|
||||||
|
m_space1(*this, "Hello, World!\n\n", "Hello Button", &m_setTo1),
|
||||||
|
m_space2(*this, "こんにちは世界!\n\n", "こんにちはボタン", &m_setTo2)
|
||||||
|
{}
|
||||||
|
|
||||||
|
Specter::RootView& rootView() const {return *m_rootView;}
|
||||||
|
void RequestPixelFactor(float pf)
|
||||||
|
{
|
||||||
|
m_reqPf = pf;
|
||||||
|
m_updatePf = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void init(boo::IApplication* app);
|
||||||
|
bool proc();
|
||||||
|
void stop();
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue