From ed368423531b24e8735db0afe38c7486145caa56 Mon Sep 17 00:00:00 2001 From: crupest Date: Fri, 15 Oct 2021 20:35:17 +0800 Subject: ... --- demos/CMakeLists.txt | 8 ++++---- demos/input_method/main.cpp | 23 ++++++++++++----------- 2 files changed, 16 insertions(+), 15 deletions(-) (limited to 'demos') diff --git a/demos/CMakeLists.txt b/demos/CMakeLists.txt index f975a6e9..1a86c69f 100644 --- a/demos/CMakeLists.txt +++ b/demos/CMakeLists.txt @@ -1,14 +1,14 @@ add_library(cru_demo_base INTERFACE) -target_link_libraries(cru_demo_base INTERFACE cru_platform_boostrap) +target_link_libraries(cru_demo_base INTERFACE cru_platform_bootstrap) if(WIN32) # Currently only enable tests on Windows. add_subdirectory(main) add_subdirectory(scroll_view) add_subdirectory(input_method) -endif() - -if(UNIX AND NOT APPLE) +elseif(APPLE) + add_subdirectory(input_method) +elseif(UNIX) add_subdirectory(xcb) endif() diff --git a/demos/input_method/main.cpp b/demos/input_method/main.cpp index b509cd97..7c22783c 100644 --- a/demos/input_method/main.cpp +++ b/demos/input_method/main.cpp @@ -7,41 +7,42 @@ #include "cru/platform/gui/Window.hpp" int main() { + using namespace cru; using namespace cru::platform; using namespace cru::platform::graphics; using namespace cru::platform::gui; - IUiApplication* application = boostrap::CreateUiApplication(); + IUiApplication* application = bootstrap::CreateUiApplication(); - auto graph_factory = application->GetGraphFactory(); + auto graphics_factory = application->GetGraphicsFactory(); auto window = application->CreateWindow(nullptr); auto input_method_context = window->GetInputMethodContext(); - auto brush = graph_factory->CreateSolidColorBrush(); + auto brush = graphics_factory->CreateSolidColorBrush(); brush->SetColor(colors::black); - auto odd_clause_brush = graph_factory->CreateSolidColorBrush(); + auto odd_clause_brush = graphics_factory->CreateSolidColorBrush(); odd_clause_brush->SetColor(colors::yellow); - auto even_clause_brush = graph_factory->CreateSolidColorBrush(); + auto even_clause_brush = graphics_factory->CreateSolidColorBrush(); even_clause_brush->SetColor(colors::green); - auto target_clause_brush = graph_factory->CreateSolidColorBrush(); + auto target_clause_brush = graphics_factory->CreateSolidColorBrush(); target_clause_brush->SetColor(colors::blue); - std::shared_ptr font = graph_factory->CreateFont(u"等线", 30); + std::shared_ptr font = graphics_factory->CreateFont(u"等线", 30); float window_width = 10000; auto prompt_text_layout = - graph_factory->CreateTextLayout(font, + graphics_factory->CreateTextLayout(font, u"Alt+F1: Enable IME\n" u"Alt+F2: Disable IME\n" u"Alt+F3: Complete composition.\n" u"Alt+F4: Cancel composition."); std::optional optional_composition_text; - std::u16string committed_text; + String committed_text; window->ResizeEvent()->AddHandler( [&prompt_text_layout, &window_width](const Size& size) { @@ -57,7 +58,7 @@ int main() { const auto anchor_y = prompt_text_layout->GetTextBounds().height; - auto text_layout = graph_factory->CreateTextLayout( + auto text_layout = graphics_factory->CreateTextLayout( font, committed_text + (optional_composition_text ? optional_composition_text->text : u"")); @@ -121,7 +122,7 @@ int main() { }); input_method_context->TextEvent()->AddHandler( - [window, &committed_text](const std::u16string_view& c) { + [window, &committed_text](const StringView& c) { committed_text += c; window->RequestRepaint(); }); -- cgit v1.2.3