/
stage_options.dart
135 lines (105 loc) · 5.16 KB
/
stage_options.dart
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
part of '../display.dart';
/// The options used by the [Stage] constructor to setup the stage.
class StageOptions {
/// The [RenderEngine] used to render the [Stage].
///
/// Setting the render engine to WebGL will automatically fallback
/// to Canvas2D if WebGL is not supported.
RenderEngine renderEngine = RenderEngine.WebGL;
/// The [InputEventMode] used for input events on the [Stage].
///
/// You can opt-in for touch events if you set the `TouchOnly` or
/// `TouchAndMouse` value. The second one is recommended because
/// you won't get any input events if you choose `TouchOnly` when
/// there is no touch screen available.
InputEventMode inputEventMode = InputEventMode.MouseOnly;
/// The [StageRenderMode] used to render the [Stage].
StageRenderMode stageRenderMode = StageRenderMode.AUTO;
/// The [StageScaleMode] used to render the [Stage].
///
/// The scale mode configures the way how the content on the stage
/// is scaled when the size of the canvas element changes. You
/// can change the behavior at runtime by changing the [Stage.scaleMode]
/// property.
StageScaleMode stageScaleMode = StageScaleMode.SHOW_ALL;
/// The [StageAlign] used to render the [Stage].
///
/// The align mode configures the way how the content on the stage
/// is aligned on the canvas element. You can change the behavior at
/// runtime by changing the [Stage.align] property.
StageAlign stageAlign = StageAlign.NONE;
/// The background color for the [Stage].
///
/// You can change the background color at runtime by changing the
/// [Stage.backgroundColor] property.
int backgroundColor = Color.White;
/// Initialize the render engine to support transparency for the [Stage].
///
/// Please note that the Canvas2D render engine will always be transparent
/// since the underlying API does not provide a way to change this behavior.
/// The WebGL render engine supports transparency but there is performance
/// penalty for setting this flag to 'true'.
bool transparent = false;
/// Initialize the render engine to support anti-aliasing for the [Stage].
///
/// Please note that the Canvas2D render engine will not be affected by
/// this setting because the underlying API does not provide this feature.
/// The WebGL render engine supports anti-aliasing but there is performance
/// penalty fo setting this flag to 'true'.
bool antialias = false;
/// The maximum pixel ratio used to initialize the [Stage].
///
/// This value will limit the pixel ratio for HiDPI screens. The native
/// pixel ratio of the device may be to high for you application to
/// achieve good performance. If the native pixel ratio is for instance
/// 3.0 you may set the [maxPixelRatio] to 2.0 or even 1.0 if the
/// performance is more important than perfectly sharp edges or pixels.
num maxPixelRatio = 5.0;
/// Prevents the browser's default behavior for touch events.
///
/// This value enabled or disables the default behavior for html touch
/// events that are targeted on the Stage. If the value is `true` the
/// browser will ignore the event. This does not affect the event
/// propagation from the Stage to the display objects.
bool preventDefaultOnTouch = true;
/// Prevents the browser's default behavior for mouse events.
///
/// This value enabled or disables the default behavior for html mouse
/// events that are targeted on the Stage. If the value is `true` the
/// browser will ignore the event. This does not affect the event
/// propagation from the Stage to the display objects.
bool preventDefaultOnMouse = true;
/// Prevents the browser's default behavior for wheel events.
///
/// This value enabled or disables the default behavior for html wheel
/// events that are targeted on the Stage. If the value is `true` the
/// browser will ignore the event. This does not affect the event
/// propagation from the Stage to the display objects.
bool preventDefaultOnWheel = false;
/// Prevents the browser's default behavior for keyboard events.
///
/// This value enabled or disables the default behavior for html keyboard
/// events that are targeted on the Stage. If the value is `true` the
/// browser will ignore the event. This does not affect the event
/// propagation from the Stage to the display objects.
bool preventDefaultOnKeyboard = false;
//---------------------------------------------------------------------------
/// Create a deep clone of this [StageOptions].
StageOptions clone() {
final options = StageOptions();
options.renderEngine = renderEngine;
options.inputEventMode = inputEventMode;
options.stageRenderMode = stageRenderMode;
options.stageScaleMode = stageScaleMode;
options.stageAlign = stageAlign;
options.backgroundColor = backgroundColor;
options.transparent = transparent;
options.antialias = antialias;
options.maxPixelRatio = maxPixelRatio;
options.preventDefaultOnTouch = preventDefaultOnTouch;
options.preventDefaultOnMouse = preventDefaultOnMouse;
options.preventDefaultOnWheel = preventDefaultOnWheel;
options.preventDefaultOnKeyboard = preventDefaultOnKeyboard;
return options;
}
}