DPI switching test

This commit is contained in:
Jack Andersen 2015-12-07 18:27:35 -10:00
parent ae4fe6cb98
commit e4478c9ab3
3 changed files with 69 additions and 18 deletions

View File

@ -1,8 +1,60 @@
#include "ViewManager.hpp"
#include "Specter/Control.hpp"
namespace RUDE
{
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());
}
void ViewManager::SetupRootView()
{
m_rootView.reset(new Specter::RootView(*this, m_viewResources, m_mainWindow.get()));
@ -11,29 +63,22 @@ void ViewManager::SetupRootView()
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_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"));
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));
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), "こんにちはボタン"));
splitView->setContentView(0, std::unique_ptr<Specter::Space>(space1));
splitView->setContentView(1, std::unique_ptr<Specter::Space>(space2));
splitView->setContentView(0, std::unique_ptr<Specter::Space>(m_space1));
splitView->setContentView(1, std::unique_ptr<Specter::Space>(m_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);
ResetResources();
}
void ViewManager::init(boo::IApplication* app)

View File

@ -15,6 +15,9 @@ class ViewManager : Specter::IViewManager
std::unique_ptr<boo::IWindow> m_mainWindow;
std::unique_ptr<Specter::RootView> m_rootView;
Specter::Space* m_space1;
Specter::Space* m_space2;
HECL::CVar* m_cvPixelFactor;
HECL::CVar* m_test1;
HECL::CVar* m_test2;
@ -24,6 +27,9 @@ public:
ViewManager(HECL::Runtime::FileStoreManager& fileMgr, HECL::CVarManager& cvarMgr)
: m_cvarManager(cvarMgr), m_fontCache(fileMgr) {}
Specter::RootView& rootView() const {return *m_rootView;}
void ResetResources();
void init(boo::IApplication* app);
bool proc();
void stop();

@ -1 +1 @@
Subproject commit 7a3177c8c8e28751c1fca170799e2fdd6c76e360
Subproject commit 5e43ae0dface8e5ebcda04187e0eb3be6c67d0b6