metaforce/Editor/ViewManager.cpp

85 lines
3.6 KiB
C++
Raw Normal View History

#include "ViewManager.hpp"
namespace RUDE
{
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);
Specter::Space* space1 = new Specter::Space(m_viewResources, *splitView, Specter::Toolbar::Position::Top);
space1->toolbar().push_back(std::make_unique<Specter::Button>(m_viewResources, space1->toolbar(),
std::make_unique<Specter::CVarControlBinding>(m_test1), "Hello Button"));
Specter::MultiLineTextView* textView1 = new Specter::MultiLineTextView(m_viewResources, *space1, m_viewResources.m_heading18);
space1->setContentView(std::unique_ptr<Specter::MultiLineTextView>(textView1));
m_test2 = m_cvarManager.newCVar("hello_button_jp", "Help for Japanese Hello Button", false,
HECL::CVar::EFlags::Archive | HECL::CVar::EFlags::Editor);
Specter::Space* space2 = new Specter::Space(m_viewResources, *splitView, Specter::Toolbar::Position::Bottom);
space2->toolbar().push_back(std::make_unique<Specter::Button>(m_viewResources, space2->toolbar(),
std::make_unique<Specter::CVarControlBinding>(m_test2), "こんにちはボタン"));
Specter::MultiLineTextView* textView2 = new Specter::MultiLineTextView(m_viewResources, *space2, m_viewResources.m_heading18);
space2->setContentView(std::unique_ptr<Specter::MultiLineTextView>(textView2));
splitView->setContentView(0, std::unique_ptr<Specter::Space>(space1));
splitView->setContentView(1, std::unique_ptr<Specter::Space>(space2));
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());
m_rootView->setBackground(Zeus::CColor::skGrey);
}
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 01:49:54 +00:00
float pixelFactor = 1.0;
m_cvPixelFactor = m_cvarManager.newCVar("ed_pixelfactor", "User-selected UI Scale",
pixelFactor, HECL::CVar::EFlags::Editor | HECL::CVar::EFlags::Archive);
boo::IGraphicsDataFactory* gf = m_mainWindow->getMainContextDataFactory();
2015-12-08 01:49:54 +00:00
m_viewResources.init(gf, &m_fontCache, Specter::ThemeData(), pixelFactor);
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-08 01:49:54 +00:00
float pixelFactor = m_cvPixelFactor->toFloat();
m_viewResources.resetPixelFactor(pixelFactor);
m_rootView->resetResources(m_viewResources);
2015-12-08 01:49:54 +00:00
m_cvPixelFactor->clearModified();
}
2015-12-08 01:49:54 +00:00
#endif
m_rootView->dispatchEvents();
m_rootView->draw(gfxQ);
gfxQ->execute();
m_mainWindow->waitForRetrace();
return true;
}
void ViewManager::stop()
{
m_mainWindow->getCommandQueue()->stopRenderer();
}
}