1 module modernui.ui.render;
2 
3 import modernui.ui.core;
4 
5 abstract class TextFormat
6 {
7 }
8 
9 abstract class TextLayout
10 {
11 	abstract @property string text();
12 	abstract @property Size layoutBox();
13 	abstract @property Size layoutSize();
14 }
15 
16 enum FontStretch
17 {
18 	ultraCondensed,
19 	extraCondensed,
20 	condensed,
21 	semiCondensed,
22 	normal,
23 	semiExpanded,
24 	expanded,
25 	extraExpanded,
26 	ultraExpanded
27 }
28 
29 enum FontStyle
30 {
31 	normal, italic, oblique
32 }
33 
34 abstract class Image
35 {
36 }
37 
38 abstract class ImageBrush
39 {
40 }
41 
42 struct SolidColorBrush
43 {
44 	private Color myColor;
45 
46 	@property Color color() { return myColor; }
47 	@property void color(Color value) { myColor = value; }
48 }
49 
50 struct GradientColorStop
51 {
52 	private float myPosition;
53 	private Color myColor;
54 
55 	@property float position() { return myPosition; }
56 	@property void position(float value) { myPosition = value; }
57 
58 	@property Color color() { return myColor; }
59 	@property void color(Color value) { myColor = value; }
60 
61 	this(float position, Color color)
62 	{
63 		myPosition = position;
64 		myColor = color;
65 	}
66 }
67 
68 class GradientColorBrush
69 {
70 	private float myOrientation;
71 	private GradientColorStop[] myStops;
72 
73 	@property float orientation() { return myOrientation; }
74 	@property void orientation(float value) { myOrientation = value; }
75 
76 	@property const(GradientColorStop[]) stops() { return myStops; }
77 
78 	this(float orientation, GradientColorStop[] stops)
79 	{
80 		myOrientation = orientation;
81 		myStops = stops;
82 	}
83 }
84 
85 abstract class RenderContext
86 {
87 	abstract void begin();
88 	abstract void end();
89 	abstract void resize();
90 	abstract void clear(Color color);
91 	abstract void drawText(double x, double y, TextLayout textLayout);
92 	abstract TextFormat createTextFormat(string fontFamily, float size, FontStyle style=FontStyle.normal, int weight=400, FontStretch stretch=FontStretch.normal);
93 	abstract TextLayout createTextLayout(TextFormat format, string text="", Size box=Size(0.0, 0.0));
94 	abstract ImageBrush createImageBrush(Image image);
95 }