Debian Codegraph @

src/ui/castleuicontrols_initial_types.inc

raw
1 {%MainUnit castleuicontrols.pas}
2 {
3 Copyright 2010-2022 Michalis Kamburelis.
4
5 This file is part of "Castle Game Engine".
6
7 "Castle Game Engine" is free software; see the file COPYING.txt,
8 included in this distribution, for details about the copyright.
9
10 "Castle Game Engine" is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13
14 ----------------------------------------------------------------------------
15 }
16
17 {$ifdef read_interface}
18
19 //type
20
21 TBorder = CastleVectors.TBorder;
22
23 TCastleUserInterface = class;
24 TInternalChildrenControls = class;
25 TCastleContainer = class;
26 TCastleTheme = class;
27 TCastleUserInterfaceList = class;
28 TCastleView = class;
29 TCastleViewList = class;
30
31 TContainerEvent = procedure (Container: TCastleContainer);
32 TContainerObjectEvent = procedure (Container: TCastleContainer) of object;
33 TInputPressReleaseEvent = procedure (Container: TCastleContainer; const Event: TInputPressRelease);
34 TInputMotionEvent = procedure (Container: TCastleContainer; const Event: TInputMotion);
35
36 TUiNotifyEvent = procedure (const Sender: TCastleUserInterface) of object;
37 TUiUpdateEvent = procedure (const Sender: TCastleUserInterface;
38 const SecondsPassed: Single; var HandleInput: Boolean) of object;
39 TUiPressReleaseEvent = procedure (const Sender: TCastleUserInterface;
40 const Event: TInputPressRelease; var Handled: Boolean) of object;
41 TUiMotionEvent = procedure (const Sender: TCastleUserInterface;
42 const Event: TInputMotion; var Handled: Boolean) of object;
43
44 { Possible values for TCastleContainer.UIScaling. }
45 TUIScaling = (
46 { Do not scale UI. }
47 usNone,
48
49 { Scale to fake that the container sizes enclose
50 @link(TCastleContainer.UIReferenceWidth) and
51 @link(TCastleContainer.UIReferenceHeight).
52 So one size will be equal to reference size, and the other will be equal
53 or larger to reference.
54
55 Controls that look at @link(TCastleUserInterface.UIScale) will be affected by this.
56 Together with anchors (see @link(TCastleUserInterface.Anchor)),
57 this allows to easily design a scalable UI. }
58 usEncloseReferenceSize,
59
60 { Similar to usEncloseReferenceSize, but automatically flips the reference
61 width and height to adjust to what is currently bigger (width or height),
62 to adjust to mobile orientation changes (portrait vs landscape).
63
64 For example, when UIReferenceWidth = 1600 and UIReferenceHeight = 900,
65 then it will adjust to 1600x900 when device is in landscape mode (width > height),
66 and to 900x1600 when device is in portrait mode (width < height).
67
68 In effect, in contrast to usEncloseReferenceSize:
69
70 @unorderedList(
71 @item(Advantage: On mobile devices, if you allow user to switch
72 between portrait and landscape,
73 the UI will have the same physical size in both portrait and landscape
74 modes. So it looks better on mobile.
75 )
76
77 @item(Disadvantage: Designing for this is a bit harder than
78 for usEncloseReferenceSize, as you need to test both
79 portrait (width smaller than height) and landscape (width bigger than height),
80 as they result in different calculations.
81 )
82 )
83
84 This is different from usEncloseReferenceSize only
85 when both @link(TCastleContainer.UIReferenceWidth) and
86 @link(TCastleContainer.UIReferenceHeight) are set to non-zero values.
87 When one of them is zero, then both usEncloseReferenceSize and
88 usEncloseReferenceSizeAutoOrientation behave the same,
89 they just adjust scaling based on this one non-zero reference size.
90 }
91 usEncloseReferenceSizeAutoOrientation,
92
93 { Scale to fake that the container sizes fit inside
94 @link(TCastleContainer.UIReferenceWidth) and
95 @link(TCastleContainer.UIReferenceHeight).
96 So one size will be equal to reference size, and the other will be equal
97 or smaller to reference.
98
99 Controls that look at @link(TCastleUserInterface.UIScale) will be affected by this.
100 Together with anchors (see @link(TCastleUserInterface.Anchor)),
101 this allows to easily design a scalable UI. }
102 usFitReferenceSize,
103
104 { Scale to fake that the container sizes are smaller/larger
105 by an explicit factor @link(TCastleContainer.UIExplicitScale).
106 Controls that look at @link(TCastleUserInterface.UIScale)
107 will be affected by this.
108
109 Like usEncloseReferenceSize or usFitReferenceSize,
110 this allows to design a scalable UI.
111 In this case, the scale factor has to be calculated by your code
112 (by default @link(TCastleContainer.UIExplicitScale) is 1.0 and the engine will
113 not modify it automatically in any way),
114 which allows customizing the scale to your requirements. }
115 usExplicitScale,
116
117 { Scale to pretend that the container size is smaller/larger
118 by a factor derived from @link(TCastleContainer.Dpi).
119
120 This allows to adjust controls to:
121
122 @unorderedList(
123 @item(The physical size.
124 @link(TCastleContainer.Dpi) on iOS and Android really
125 reflects physical size.
126 )
127 @item(Or at least to follow user preferred UI scaling.
128 @link(TCastleContainer.Dpi) on desktops is often more like "configurable
129 way to scale UI" than derived from actual monitor physical size.
130 )
131 )
132
133 This is the same scaling done by normal desktop applications,
134 e.g. using Lazarus LCL. Using this scaling is best if your user interface
135 using CGE should match (the size of) the user interface done by
136 Lazarus LCL or native applications.
137 }
138 usDpiScale
139 );
140
141 { Things that can cause @link(TCastleUserInterface.VisibleChange) notification. }
142 TCastleUserInterfaceChange = (
143 { The look of this control changed.
144 This concerns all the things that affect what @link(TCastleUserInterface.Render) does.
145
146 Note that changing chRectangle implies that the look changed too.
147 So when chRectangle is in Changes, you should always behave
148 like chRender is also in Changes, regardless if it's there or not. }
149 chRender,
150
151 { The rectangle (size or position) of the control changed.
152 This concerns all the things that affect size
153 or our position inside parent (anchors).
154
155 Note that this is not (necessarily) called when the screen position changed
156 just because the parent screen position changed.
157 We only notify when the size or position changed with respect to the parent.
158
159 Note that changing chRectangle implies that the look changed too.
160 So when chRectangle is in Changes, you should always behave
161 like chRender is also in Changes, regardless if it's there or not. }
162 chRectangle,
163
164 chCursor,
165
166 chExists,
167
168 { A (direct) child control was added or removed. }
169 chChildren,
170
171 { A (direct) child control @link(TCastleUserInterface.Exists) value changed. }
172 chChildrenExists
173 );
174 TCastleUserInterfaceChanges = set of TCastleUserInterfaceChange;
175 TCastleUserInterfaceChangeEvent = procedure(const Sender: TCastleUserInterface;
176 const Changes: TCastleUserInterfaceChanges; const ChangeInitiatedByChildren: boolean)
177 of object;
178
179 { Position for relative layout of one control in respect to another.
180 @deprecated Deprecated, rather use cleaner
181 THorizontalPosition and TVerticalPosition.
182 }
183 TPositionRelative = (
184 prLow,
185 prMiddle,
186 prHigh
187 ) deprecated;
188
189 {$endif read_interface}
190
191 {$ifdef read_implementation}
192
193
194 {$endif read_implementation}