blob: b861fda748ac2e1e714da79cf7302f95af6aef89 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
#pragma once
#include "../win_pre_config.hpp"
#include "cru/platform/graph/text_layout.hpp"
#include <memory>
namespace cru::win::graph {
class GraphManager;
class WinFontDescriptor;
class WinTextLayout : public Object, public virtual platform::graph::TextLayout {
public:
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 = default;
std::wstring GetText() override;
void SetText(std::wstring new_text) override;
std::shared_ptr<platform::graph::FontDescriptor> GetFont();
void SetFont(std::shared_ptr<platform::graph::FontDescriptor> font);
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
|