Fixing elemental input and using embedded resources.

This commit is contained in:
Ben Vanik 2015-07-07 22:16:18 -07:00
parent b09ab1f886
commit 6b52f2682e
7 changed files with 46 additions and 17 deletions

1
.gitignore vendored
View File

@ -51,6 +51,7 @@ obj/
*.py[co] *.py[co]
.coverage .coverage
*.o *.o
*.aps
# ============================================================================== # ==============================================================================
# Logs and dumps # Logs and dumps

View File

@ -0,0 +1,5 @@
//{{NO_DEPENDENCIES}}
#include "third_party\\elemental-forms\\resources.rc"
//IDR_xe_debug_ui_resources_skin_bg_tile_png RCDATA ".\\resources\\skin\\bg_tile.png"

View File

@ -84,6 +84,12 @@
<ClCompile Include="main_window.cc" /> <ClCompile Include="main_window.cc" />
<ClCompile Include="xe-debug-ui.cc" /> <ClCompile Include="xe-debug-ui.cc" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<ResourceCompile Include="resources.rc">
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(SolutionDir)third_party/elemental-forms;$(SolutionDir);.</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(SolutionDir)third_party/elemental-forms;$(SolutionDir);.</AdditionalIncludeDirectories>
</ResourceCompile>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets"> <ImportGroup Label="ExtensionTargets">
</ImportGroup> </ImportGroup>

View File

@ -45,4 +45,9 @@
<Filter>src\xenia\debug\ui</Filter> <Filter>src\xenia\debug\ui</Filter>
</ClCompile> </ClCompile>
</ItemGroup> </ItemGroup>
<ItemGroup>
<ResourceCompile Include="resources.rc">
<Filter>src\xenia\debug\ui</Filter>
</ResourceCompile>
</ItemGroup>
</Project> </Project>

View File

@ -10,10 +10,11 @@
#include "xenia/ui/elemental_control.h" #include "xenia/ui/elemental_control.h"
#include "el/animation_manager.h" #include "el/animation_manager.h"
#include "el/util/debug.h"
#include "el/elemental_forms.h" #include "el/elemental_forms.h"
#include "el/io/embedded_file_system.h"
#include "el/io/file_manager.h" #include "el/io/file_manager.h"
#include "el/io/posix_file_system.h" #include "el/io/posix_file_system.h"
#include "el/io/win32_res_file_system.h"
#include "el/message_handler.h" #include "el/message_handler.h"
#include "el/text/font_manager.h" #include "el/text/font_manager.h"
#include "el/util/metrics.h" #include "el/util/metrics.h"
@ -60,19 +61,15 @@ bool ElementalControl::InitializeElemental(Loop* loop,
elemental_loop_ = loop; elemental_loop_ = loop;
if (!el::Initialize(renderer)) { if (!el::Initialize(renderer)) {
XELOGE("Failed to initialize turbobadger core"); XELOGE("Failed to initialize elemental core");
return false; return false;
} }
el::io::FileManager::RegisterFileSystem( el::io::FileManager::RegisterFileSystem(
std::make_unique<el::io::PosixFileSystem>( std::make_unique<el::io::Win32ResFileSystem>("IDR_default_resources_"));
"third_party/elemental-forms/resources/"));
el::io::FileManager::RegisterFileSystem( el::io::FileManager::RegisterFileSystem(
std::make_unique<el::io::PosixFileSystem>( std::make_unique<el::io::PosixFileSystem>(
"third_party/elemental-forms/testbed/resources/")); "third_party/elemental-forms/testbed/resources/"));
auto embedded_file_system = std::make_unique<el::io::EmbeddedFileSystem>();
// TODO(benvanik): bin2c stuff.
el::io::FileManager::RegisterFileSystem(std::move(embedded_file_system));
// Load default translations. // Load default translations.
el::util::StringTable::get()->Load("default_language/language_en.tb.txt"); el::util::StringTable::get()->Load("default_language/language_en.tb.txt");
@ -151,7 +148,7 @@ bool ElementalControl::Create() {
auto message_window = new el::MessageWindow(root_element(), TBIDC("")); auto message_window = new el::MessageWindow(root_element(), TBIDC(""));
message_window->Show("Title", "Hello!"); message_window->Show("Title", "Hello!");
// el::ShowDebugInfoSettingsWindow(root_element()); el::util::ShowDebugInfoSettingsWindow(root_element());
return true; return true;
} }
@ -253,11 +250,12 @@ el::ModifierKeys ElementalControl::GetModifierKeys() {
return modifiers; return modifiers;
} }
void ElementalControl::OnKeyPress(KeyEvent& e, bool is_down) { void ElementalControl::OnKeyPress(KeyEvent& e, bool is_down, bool is_char) {
if (!root_element()) { if (!root_element()) {
return; return;
} }
auto special_key = el::SpecialKey::kUndefined; auto special_key = el::SpecialKey::kUndefined;
if (!is_char) {
switch (e.key_code()) { switch (e.key_code()) {
case 38: case 38:
special_key = el::SpecialKey::kUp; special_key = el::SpecialKey::kUp;
@ -360,11 +358,18 @@ void ElementalControl::OnKeyPress(KeyEvent& e, bool is_down) {
modifier_super_pressed_ = is_down; modifier_super_pressed_ = is_down;
break; break;
} }
}
if (!CheckShortcutKey(e, special_key, is_down)) { if (!CheckShortcutKey(e, special_key, is_down)) {
e.set_handled(root_element()->InvokeKey( int key_code = 0;
special_key != el::SpecialKey::kUndefined ? e.key_code() : 0, if (is_char) {
special_key, GetModifierKeys(), is_down)); key_code = e.key_code();
if (key_code < 32 || (key_code > 126 && key_code < 160)) {
key_code = 0;
}
}
e.set_handled(root_element()->InvokeKey(key_code, special_key,
GetModifierKeys(), is_down));
} }
} }
@ -423,12 +428,18 @@ bool ElementalControl::CheckShortcutKey(KeyEvent& e, el::SpecialKey special_key,
void ElementalControl::OnKeyDown(KeyEvent& e) { void ElementalControl::OnKeyDown(KeyEvent& e) {
super::OnKeyDown(e); super::OnKeyDown(e);
OnKeyPress(e, true); OnKeyPress(e, true, false);
} }
void ElementalControl::OnKeyUp(KeyEvent& e) { void ElementalControl::OnKeyUp(KeyEvent& e) {
super::OnKeyUp(e); super::OnKeyUp(e);
OnKeyPress(e, false); OnKeyPress(e, false, false);
}
void ElementalControl::OnKeyChar(KeyEvent& e) {
super::OnKeyChar(e);
OnKeyPress(e, true, true);
OnKeyPress(e, false, true);
} }
void ElementalControl::OnMouseDown(MouseEvent& e) { void ElementalControl::OnMouseDown(MouseEvent& e) {

View File

@ -49,10 +49,11 @@ class ElementalControl : public PlatformControl {
el::ModifierKeys GetModifierKeys(); el::ModifierKeys GetModifierKeys();
void OnKeyPress(KeyEvent& e, bool is_down); void OnKeyPress(KeyEvent& e, bool is_down, bool is_char);
bool CheckShortcutKey(KeyEvent& e, el::SpecialKey special_key, bool is_down); bool CheckShortcutKey(KeyEvent& e, el::SpecialKey special_key, bool is_down);
void OnKeyDown(KeyEvent& e) override; void OnKeyDown(KeyEvent& e) override;
void OnKeyUp(KeyEvent& e) override; void OnKeyUp(KeyEvent& e) override;
void OnKeyChar(KeyEvent& e) override;
void OnMouseDown(MouseEvent& e) override; void OnMouseDown(MouseEvent& e) override;
void OnMouseMove(MouseEvent& e) override; void OnMouseMove(MouseEvent& e) override;

@ -1 +1 @@
Subproject commit 17b41976c4277b702d8ec2f16e849d75d69cec71 Subproject commit 30adbc89f338caa80693dc6ab48a503f0ef3728f