30 using System.Collections.Generic;
31 using System.ComponentModel;
40 private Sizing _horizontalSizing;
41 private Sizing _verticalSizing;
42 private Vector _preferredSize;
43 private double _spaceRequestedByExpandingObjects;
44 private double _spaceRequestedByFixedSizeObjects;
45 private double _spacing = 0;
46 private double _topPadding = 0;
47 private double _bottomPadding = 0;
48 private double _leftPadding = 0;
49 private double _rightPadding = 0;
51 [EditorBrowsable(EditorBrowsableState.Never)]
59 get {
return _spacing; }
60 set { _spacing = value; NotifyParent(); }
68 get {
return _topPadding; }
69 set { _topPadding = value; NotifyParent(); }
77 get {
return _bottomPadding; }
78 set { _bottomPadding = value; NotifyParent(); }
86 get {
return _leftPadding; }
87 set { _leftPadding = value; NotifyParent(); }
95 get {
return _rightPadding; }
96 set { _rightPadding = value; NotifyParent(); }
99 private void NotifyParent()
114 [EditorBrowsable(EditorBrowsableState.Never)]
117 if (objects.Count == 0)
121 double heightOfExpandingObjects = 0;
122 double heightOfFixedSizeObjects = 0;
126 foreach (var o
in objects)
128 if (o.PreferredSize.X > maxWidth)
130 maxWidth = o.PreferredSize.X;
133 if (o.VerticalSizing ==
Sizing.Expanding)
135 verticalSizing =
Sizing.Expanding;
136 heightOfExpandingObjects += o.PreferredSize.Y;
138 else if (o.VerticalSizing ==
Sizing.FixedSize)
140 heightOfFixedSizeObjects += o.PreferredSize.Y;
143 if (o.HorizontalSizing !=
Sizing.FixedSize)
145 horizontalSizing =
Sizing.Expanding;
152 _horizontalSizing = horizontalSizing;
153 _verticalSizing = verticalSizing;
154 _spaceRequestedByExpandingObjects = heightOfExpandingObjects;
155 _spaceRequestedByFixedSizeObjects = heightOfFixedSizeObjects;
156 _preferredSize =
new Vector(preferredWidth, preferredHeight);
159 [EditorBrowsable(EditorBrowsableState.Never)]
162 get {
return _horizontalSizing; }
165 [EditorBrowsable(EditorBrowsableState.Never)]
168 get {
return _verticalSizing; }
171 [EditorBrowsable(EditorBrowsableState.Never)]
174 get {
return _preferredSize; }
177 [EditorBrowsable(EditorBrowsableState.Never)]
183 double fixedScale = 1.0;
184 double expandingScale = 0.0;
186 double availableSpaceForObjects = contentHeight - (objects.Count - 1) *
Spacing;
188 if ((availableSpaceForObjects < _spaceRequestedByFixedSizeObjects) && (_spaceRequestedByFixedSizeObjects > 0))
191 fixedScale = availableSpaceForObjects / _spaceRequestedByFixedSizeObjects;
196 else if ((maximumSize.
Y <
PreferredSize.
Y) && (_spaceRequestedByExpandingObjects > 0))
203 double availableSpaceForExpandingObjects = availableSpaceForObjects - _spaceRequestedByFixedSizeObjects;
204 expandingScale = availableSpaceForExpandingObjects / _spaceRequestedByExpandingObjects;
212 if (_spaceRequestedByExpandingObjects > 0)
215 expandingScale = (availableSpaceForObjects - _spaceRequestedByFixedSizeObjects) / _spaceRequestedByExpandingObjects;
219 foreach (var o
in objects)
221 double scale = (o.VerticalSizing ==
Sizing.FixedSize) ? fixedScale : expandingScale;
222 double height = o.PreferredSize.Y * scale;
223 double width = o.PreferredSize.X;
225 if ((o.PreferredSize.X > contentWidth) || (o.HorizontalSizing ==
Sizing.Expanding))
227 width = contentWidth;
230 o.Size =
new Vector(width, height);
231 o.X = (-maximumSize.X / 2) + (
LeftPadding + contentWidth / 2);
232 o.Y = top - height / 2;
double Spacing
Olioiden väliin jäävä tyhjä tila.
Rajapinta asettelijalle. Asettelija asettelee widgetin lapsioliot siten, että ne mahtuvat widgetin si...
double BottomPadding
Alareunaan jäävä tyhjä tila.
void Update(IList< GameObject > objects, Vector maximumSize)
double TopPadding
Yläreunaan jäävä tyhjä tila.
VerticalLayout()
Luo uuden asettelijan.
Sizing
Olion koon asettaminen asettelijan sisällä.
double RightPadding
Oikeaan reunaan jäävä tyhjä tila.
Asettelee widgetit päällekäin, järjestyksessä ylhäältä alas.
void NotifyParentAboutChangedSizingAttributes()
Should be called whenever properties that might affect layouts are changed.
double LeftPadding
Vasempaan reunaan jäävä tyhjä tila.
Pelialueella liikkuva olio. Käytä fysiikkapeleissä PhysicsObject-olioita.
void UpdateSizeHints(IList< GameObject > objects)