blob: 69afc7b30ddc439d2552056066f4f8c5826999eb (
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
#pragma once
#include "../graphic_base.hpp"
#include "../native_resource.hpp"
#include "brush.hpp"
#include "font.hpp"
#include "geometry.hpp"
#include "text_layout.hpp"
#include <memory>
#include <string>
#include <string_view>
namespace cru::platform::graph {
// Entry point of the graph module.
// If you create a IUiApplication instance, then you should not create
// IGraphFactory manually. IUiApplication will call
// IGraphFactory::CreateInstance and set auto-delete to true.
// The manual creation method of IGraphFactory provides a you a way to use graph
// related tools without interact with actual ui like window system.
class GraphFactory : public NativeResource {
public:
// Create a platform-specific instance and save it as the global instance.
// Do not create the instance twice. Implements should assert for that.
// After creating, get the instance by GetInstance.
static GraphFactory* CreateInstance();
// Get the global instance. If it is not created, then return nullptr.
static GraphFactory* GetInstance();
protected:
GraphFactory() = default;
public:
GraphFactory(const GraphFactory& other) = delete;
GraphFactory& operator=(const GraphFactory& other) = delete;
GraphFactory(GraphFactory&& other) = delete;
GraphFactory& operator=(GraphFactory&& other) = delete;
~GraphFactory() override = default;
public:
virtual SolidColorBrush* CreateSolidColorBrush() = 0;
SolidColorBrush* CreateSolidColorBrush(const Color& color) {
const auto brush = CreateSolidColorBrush();
brush->SetColor(color);
return brush;
}
virtual GeometryBuilder* CreateGeometryBuilder() = 0;
virtual Font* CreateFont(const std::wstring_view& font_family,
float font_size) = 0;
virtual TextLayout* CreateTextLayout(std::shared_ptr<Font> font,
std::wstring text) = 0;
};
} // namespace cru::platform::graph
|