diff options
Diffstat (limited to 'include/cru')
-rw-r--r-- | include/cru/platform/native/input_method.hpp | 19 | ||||
-rw-r--r-- | include/cru/platform/native/ui_application.hpp | 3 | ||||
-rw-r--r-- | include/cru/platform/native/window.hpp | 4 | ||||
-rw-r--r-- | include/cru/win/graph/direct/text_layout.hpp | 4 | ||||
-rw-r--r-- | include/cru/win/native/input_method.hpp | 2 | ||||
-rw-r--r-- | include/cru/win/native/window.hpp | 4 |
6 files changed, 30 insertions, 6 deletions
diff --git a/include/cru/platform/native/input_method.hpp b/include/cru/platform/native/input_method.hpp index 48895f84..4034be4e 100644 --- a/include/cru/platform/native/input_method.hpp +++ b/include/cru/platform/native/input_method.hpp @@ -1,8 +1,10 @@ #pragma once #include "../resource.hpp" #include "base.hpp" + #include "cru/common/event.hpp" +#include <iostream> #include <memory> #include <vector> @@ -21,6 +23,23 @@ struct CompositionText { TextRange selection; }; +inline std::ostream& operator<<(std::ostream& stream, + const CompositionText& composition_text) { + stream << "text: " << composition_text.text << "\n" + << "clauses:\n"; + for (int i = 0; i < composition_text.clauses.size(); i++) { + const auto& clause = composition_text.clauses[i]; + stream << "\t" << i << ". start:" << clause.start << " end:" << clause.end; + if (clause.target) { + stream << " target"; + } + stream << "\n"; + } + stream << "selection: position:" << composition_text.selection.position + << " count:" << composition_text.selection.count; + return stream; +} + struct IInputMethodContext : virtual INativeResource { // Return true if you should draw composition text manually. Return false if // system will take care of that for you. diff --git a/include/cru/platform/native/ui_application.hpp b/include/cru/platform/native/ui_application.hpp index 92222929..006255db 100644 --- a/include/cru/platform/native/ui_application.hpp +++ b/include/cru/platform/native/ui_application.hpp @@ -47,4 +47,7 @@ struct IUiApplication : public virtual INativeResource { virtual ICursorManager* GetCursorManager() = 0; virtual IInputMethodManager* GetInputMethodManager() = 0; }; + +// Bootstrap from this. +std::unique_ptr<IUiApplication> CreateUiApplication(); } // namespace cru::platform::native diff --git a/include/cru/platform/native/window.hpp b/include/cru/platform/native/window.hpp index dcb9effa..49b00023 100644 --- a/include/cru/platform/native/window.hpp +++ b/include/cru/platform/native/window.hpp @@ -3,7 +3,7 @@ #include "base.hpp" #include "cru/common/event.hpp" -#include <string> +#include <string_view> namespace cru::platform::native { // Represents a native window, which exposes some low-level events and @@ -57,7 +57,7 @@ struct INativeWindow : virtual INativeResource { virtual IEvent<NativeMouseButtonEventArgs>* MouseUpEvent() = 0; virtual IEvent<NativeKeyEventArgs>* KeyDownEvent() = 0; virtual IEvent<NativeKeyEventArgs>* KeyUpEvent() = 0; - virtual IEvent<std::string>* CharEvent() = 0; + virtual IEvent<std::string_view>* CharEvent() = 0; }; // See INativeWindow for more info. diff --git a/include/cru/win/graph/direct/text_layout.hpp b/include/cru/win/graph/direct/text_layout.hpp index 5f7be9f3..462a5fd3 100644 --- a/include/cru/win/graph/direct/text_layout.hpp +++ b/include/cru/win/graph/direct/text_layout.hpp @@ -45,8 +45,8 @@ class DWriteTextLayout : public DirectGraphResource, std::string text_; std::wstring w_text_; std::shared_ptr<DWriteFont> font_; - float max_width_ = 0.0f; - float max_height_ = 0.0f; + float max_width_ = 10000.0f; + float max_height_ = 10000.0f; Microsoft::WRL::ComPtr<IDWriteTextLayout> text_layout_; }; } // namespace cru::platform::graph::win::direct diff --git a/include/cru/win/native/input_method.hpp b/include/cru/win/native/input_method.hpp index 566eada2..8e17abd5 100644 --- a/include/cru/win/native/input_method.hpp +++ b/include/cru/win/native/input_method.hpp @@ -64,6 +64,8 @@ class WinInputMethodContext : public WinNativeResource, private: void OnWindowNativeMessage(WindowNativeMessageEventArgs& args); + std::string GetResultString(); + std::optional<AutoHIMC> TryGetHIMC(); private: diff --git a/include/cru/win/native/window.hpp b/include/cru/win/native/window.hpp index 45f1f16a..83497fa6 100644 --- a/include/cru/win/native/window.hpp +++ b/include/cru/win/native/window.hpp @@ -72,7 +72,7 @@ class WinNativeWindow : public WinNativeResource, public virtual INativeWindow { IEvent<platform::native::NativeKeyEventArgs>* KeyUpEvent() override { return &key_up_event_; } - IEvent<std::string>* CharEvent() override { return &char_event_; }; + IEvent<std::string_view>* CharEvent() override { return &char_event_; }; IEvent<WindowNativeMessageEventArgs&>* NativeMessageEvent() { return &native_message_event_; @@ -146,7 +146,7 @@ class WinNativeWindow : public WinNativeResource, public virtual INativeWindow { Event<platform::native::NativeMouseButtonEventArgs> mouse_up_event_; Event<platform::native::NativeKeyEventArgs> key_down_event_; Event<platform::native::NativeKeyEventArgs> key_up_event_; - Event<std::string> char_event_; + Event<std::string_view> char_event_; Event<WindowNativeMessageEventArgs&> native_message_event_; |