diff options
author | crupest <crupest@outlook.com> | 2019-04-04 14:14:07 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2019-04-04 14:14:07 +0800 |
commit | dcd866074615ba357b62b6128f1c64d56ed4ad16 (patch) | |
tree | 86db346cfa104d173b4e9dd7449d51ec36f0b5b3 /include | |
parent | d732b99cd1436144d4625382954eb4a1cf832a1f (diff) | |
download | cru-dcd866074615ba357b62b6128f1c64d56ed4ad16.tar.gz cru-dcd866074615ba357b62b6128f1c64d56ed4ad16.tar.bz2 cru-dcd866074615ba357b62b6128f1c64d56ed4ad16.zip |
...
Diffstat (limited to 'include')
-rw-r--r-- | include/cru/platform/graph_factory.hpp | 7 | ||||
-rw-r--r-- | include/cru/platform/text_layout.hpp | 3 | ||||
-rw-r--r-- | include/cru/platform/win/win_text_layout.hpp | 18 |
3 files changed, 27 insertions, 1 deletions
diff --git a/include/cru/platform/graph_factory.hpp b/include/cru/platform/graph_factory.hpp index f2e5f286..312dc0ea 100644 --- a/include/cru/platform/graph_factory.hpp +++ b/include/cru/platform/graph_factory.hpp @@ -3,12 +3,19 @@ #include "cru/common/ui_base.hpp" +#include <string> +#include <string_view> + namespace cru::platform { struct SolidColorBrush; struct GeometryBuilder; +struct FontDescriptor; +struct TextLayout; struct GraphFactory : virtual Interface { virtual SolidColorBrush* CreateSolidColorBrush(const ui::Color& color) = 0; virtual GeometryBuilder* CreateGeometryBuilder() = 0; + virtual FontDescriptor* CreateFontDescriptor(const std::wstring_view& font_family) = 0; + virtual TextLayout* CreateTextLayout(std::shared_ptr<FontDescriptor> font, std::wstring text) = 0; }; } // namespace cru::platform diff --git a/include/cru/platform/text_layout.hpp b/include/cru/platform/text_layout.hpp index fce6ce5f..7bcf01fe 100644 --- a/include/cru/platform/text_layout.hpp +++ b/include/cru/platform/text_layout.hpp @@ -4,9 +4,12 @@ #include "cru/common/ui_base.hpp" #include <vector> +#include <string> namespace cru::platform { struct TextLayout : virtual Interface { + virtual std::wstring GetText() = 0; + virtual void SetText(std::wstring new_text) = 0; virtual void SetMaxWidth(float max_width) = 0; virtual void SetMaxHeight(float max_height) = 0; virtual ui::Rect GetTextBounds() = 0; diff --git a/include/cru/platform/win/win_text_layout.hpp b/include/cru/platform/win/win_text_layout.hpp index 68961dd7..277bbcae 100644 --- a/include/cru/platform/win/win_text_layout.hpp +++ b/include/cru/platform/win/win_text_layout.hpp @@ -7,18 +7,34 @@ #include <memory> namespace cru::platform::win { +class GraphManager; + class WinTextLayout : public Object, public virtual TextLayout { public: - explicit WinTextLayout(std::shared_ptr<WinFontDescriptor> font); + explicit WinTextLayout(GraphManager* graph_manager, + std::shared_ptr<WinFontDescriptor> font, std::wstring text); WinTextLayout(const WinTextLayout& other) = delete; WinTextLayout(WinTextLayout&& other) = delete; WinTextLayout& operator=(const WinTextLayout& other) = delete; WinTextLayout& operator=(WinTextLayout&& other) = delete; ~WinTextLayout() override; + std::wstring GetText() override; + void SetText(std::wstring new_text) override; + void SetMaxWidth(float max_width) override; + void SetMaxHeight(float max_height) override; + ui::Rect GetTextBounds() override; + std::vector<ui::Rect> TextRangeRect( + const ui::TextRange& text_range) override; + IDWriteTextLayout* GetDWriteTextLayout() const { return text_layout_.Get(); } private: + GraphManager* graph_manager_; + std::wstring text_; + std::shared_ptr<WinFontDescriptor> font_descriptor_; + float max_width_ = 0.0f; + float max_height_ = 0.0f; Microsoft::WRL::ComPtr<IDWriteTextLayout> text_layout_; }; } // namespace cru::platform::win |