2015-12-06 01:27:02 +00:00
|
|
|
#include "ViewManager.hpp"
|
2015-12-08 04:27:35 +00:00
|
|
|
#include "Specter/Control.hpp"
|
2015-12-06 01:27:02 +00:00
|
|
|
|
|
|
|
namespace RUDE
|
|
|
|
{
|
|
|
|
|
2015-12-08 04:27:35 +00:00
|
|
|
struct SetTo1 : Specter::IButtonBinding
|
|
|
|
{
|
|
|
|
ViewManager& m_vm;
|
|
|
|
std::string m_name = "SetTo1";
|
|
|
|
std::string m_help = "Sets scale factor to 1.0";
|
|
|
|
SetTo1(ViewManager& vm) : m_vm(vm) {}
|
|
|
|
|
|
|
|
const std::string& name() const {return m_name;}
|
|
|
|
const std::string& help() const {return m_help;}
|
|
|
|
void pressed(const boo::SWindowCoord& coord)
|
|
|
|
{
|
|
|
|
m_vm.rootView().viewRes().resetPixelFactor(1.0);
|
|
|
|
m_vm.rootView().resetResources(m_vm.rootView().viewRes());
|
|
|
|
m_vm.ResetResources();
|
|
|
|
m_vm.rootView().updateSize();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
struct SetTo2 : Specter::IButtonBinding
|
|
|
|
{
|
|
|
|
ViewManager& m_vm;
|
|
|
|
std::string m_name = "SetTo2";
|
|
|
|
std::string m_help = "Sets scale factor to 2.0";
|
|
|
|
SetTo2(ViewManager& vm) : m_vm(vm) {}
|
|
|
|
|
|
|
|
const std::string& name() const {return m_name;}
|
|
|
|
const std::string& help() const {return m_help;}
|
|
|
|
void pressed(const boo::SWindowCoord& coord)
|
|
|
|
{
|
|
|
|
m_vm.rootView().viewRes().resetPixelFactor(2.0);
|
|
|
|
m_vm.rootView().resetResources(m_vm.rootView().viewRes());
|
|
|
|
m_vm.ResetResources();
|
|
|
|
m_vm.rootView().updateSize();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
void ViewManager::ResetResources()
|
|
|
|
{
|
|
|
|
Specter::MultiLineTextView* textView1 = new Specter::MultiLineTextView(m_viewResources, *m_space1, m_viewResources.m_heading18);
|
|
|
|
m_space1->setContentView(std::unique_ptr<Specter::MultiLineTextView>(textView1));
|
|
|
|
|
|
|
|
Specter::MultiLineTextView* textView2 = new Specter::MultiLineTextView(m_viewResources, *m_space2, m_viewResources.m_heading18);
|
|
|
|
m_space2->setContentView(std::unique_ptr<Specter::MultiLineTextView>(textView2));
|
|
|
|
|
|
|
|
textView1->typesetGlyphs("Hello, World!\n\n", m_viewResources.themeData().uiText());
|
|
|
|
textView2->typesetGlyphs("こんにちは世界!\n\n", m_viewResources.themeData().uiText());
|
|
|
|
|
|
|
|
textView1->setBackground(m_viewResources.themeData().viewportBackground());
|
|
|
|
textView2->setBackground(m_viewResources.themeData().viewportBackground());
|
|
|
|
}
|
|
|
|
|
2015-12-06 01:27:02 +00:00
|
|
|
void ViewManager::SetupRootView()
|
|
|
|
{
|
|
|
|
m_rootView.reset(new Specter::RootView(*this, m_viewResources, m_mainWindow.get()));
|
|
|
|
Specter::SplitView* splitView = new Specter::SplitView(m_viewResources, *m_rootView, Specter::SplitView::Axis::Horizontal);
|
|
|
|
m_rootView->setContentView(std::unique_ptr<Specter::SplitView>(splitView));
|
|
|
|
|
|
|
|
m_test1 = m_cvarManager.newCVar("hello_button", "Help for Hello Button", false,
|
|
|
|
HECL::CVar::EFlags::Archive | HECL::CVar::EFlags::Editor);
|
2015-12-08 04:27:35 +00:00
|
|
|
m_space1 = new Specter::Space(m_viewResources, *splitView, Specter::Toolbar::Position::Top);
|
|
|
|
m_space1->toolbar().push_back(std::make_unique<Specter::Button>(m_viewResources, m_space1->toolbar(),
|
|
|
|
std::make_unique<SetTo1>(*this), "Hello Button"));
|
2015-12-06 01:27:02 +00:00
|
|
|
|
|
|
|
m_test2 = m_cvarManager.newCVar("hello_button_jp", "Help for Japanese Hello Button", false,
|
|
|
|
HECL::CVar::EFlags::Archive | HECL::CVar::EFlags::Editor);
|
2015-12-08 04:27:35 +00:00
|
|
|
m_space2 = new Specter::Space(m_viewResources, *splitView, Specter::Toolbar::Position::Bottom);
|
|
|
|
m_space2->toolbar().push_back(std::make_unique<Specter::Button>(m_viewResources, m_space2->toolbar(),
|
|
|
|
std::make_unique<SetTo2>(*this), "こんにちはボタン"));
|
2015-12-06 01:27:02 +00:00
|
|
|
|
2015-12-08 04:27:35 +00:00
|
|
|
splitView->setContentView(0, std::unique_ptr<Specter::Space>(m_space1));
|
|
|
|
splitView->setContentView(1, std::unique_ptr<Specter::Space>(m_space2));
|
2015-12-06 01:27:02 +00:00
|
|
|
|
|
|
|
m_rootView->setBackground(Zeus::CColor::skGrey);
|
2015-12-08 04:27:35 +00:00
|
|
|
|
|
|
|
ResetResources();
|
2015-12-06 01:27:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ViewManager::init(boo::IApplication* app)
|
|
|
|
{
|
|
|
|
m_mainWindow = std::unique_ptr<boo::IWindow>(app->newWindow(_S("RUDE")));
|
|
|
|
m_mainWindow->showWindow();
|
|
|
|
m_mainWindow->setWaitCursor(true);
|
|
|
|
|
2015-12-08 05:43:28 +00:00
|
|
|
float pixelFactor = 2.0;
|
2015-12-08 01:49:54 +00:00
|
|
|
m_cvPixelFactor = m_cvarManager.newCVar("ed_pixelfactor", "User-selected UI Scale",
|
|
|
|
pixelFactor, HECL::CVar::EFlags::Editor | HECL::CVar::EFlags::Archive);
|
2015-12-06 01:27:02 +00:00
|
|
|
|
|
|
|
boo::IGraphicsDataFactory* gf = m_mainWindow->getMainContextDataFactory();
|
2015-12-08 01:49:54 +00:00
|
|
|
m_viewResources.init(gf, &m_fontCache, Specter::ThemeData(), pixelFactor);
|
2015-12-06 01:27:02 +00:00
|
|
|
SetupRootView();
|
|
|
|
|
|
|
|
m_mainWindow->setWaitCursor(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool ViewManager::proc()
|
|
|
|
{
|
|
|
|
boo::IGraphicsCommandQueue* gfxQ = m_mainWindow->getCommandQueue();
|
|
|
|
if (m_rootView->isDestroyed())
|
|
|
|
return false;
|
2015-12-08 01:49:54 +00:00
|
|
|
#if 0
|
|
|
|
if (m_cvPixelFactor->isModified())
|
2015-12-06 01:27:02 +00:00
|
|
|
{
|
2015-12-08 01:49:54 +00:00
|
|
|
float pixelFactor = m_cvPixelFactor->toFloat();
|
|
|
|
m_viewResources.resetPixelFactor(pixelFactor);
|
2015-12-06 01:27:02 +00:00
|
|
|
m_rootView->resetResources(m_viewResources);
|
2015-12-08 01:49:54 +00:00
|
|
|
m_cvPixelFactor->clearModified();
|
2015-12-06 01:27:02 +00:00
|
|
|
}
|
2015-12-08 01:49:54 +00:00
|
|
|
#endif
|
2015-12-06 01:27:02 +00:00
|
|
|
m_rootView->dispatchEvents();
|
|
|
|
m_rootView->draw(gfxQ);
|
|
|
|
gfxQ->execute();
|
|
|
|
m_mainWindow->waitForRetrace();
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ViewManager::stop()
|
|
|
|
{
|
|
|
|
m_mainWindow->getCommandQueue()->stopRenderer();
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|