Menu

[r331]: / trunk / framework / OSMF / org / osmf / layout / LayoutMetadata.as  Maximize  Restore  History

Download this file

648 lines (602 with data), 16.1 kB

  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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
/*****************************************************
*
* Copyright 2010 Adobe Systems Incorporated. All Rights Reserved.
*
*****************************************************
* The contents of this file are subject to the Mozilla Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS"
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
* License for the specific language governing rights and limitations
* under the License.
*
*
* The Initial Developer of the Original Code is Adobe Systems Incorporated.
* Portions created by Adobe Systems Incorporated are Copyright (C) 2010 Adobe Systems
* Incorporated. All Rights Reserved.
*
*****************************************************/
package org.osmf.layout
{
import org.osmf.metadata.Metadata;
import org.osmf.metadata.MetadataNamespaces;
import org.osmf.metadata.MetadataSynthesizer;
import org.osmf.metadata.NullMetadataSynthesizer;
/**
* Defines a metadata object that contains the properties upon which a layout
* renderer will base its layout.
*
* @langversion 3.0
* @playerversion Flash 10
* @playerversion AIR 1.5
* @productversion OSMF 1.0
*
* @includeExample LayoutMetadataExample.as -noswf
*/
public class LayoutMetadata extends Metadata
{
/**
* Namespace URL for LayoutMetadata objects when added to a MediaElement or
* MediaContainer.
*
* @langversion 3.0
* @playerversion Flash 10
* @playerversion AIR 1.5
* @productversion OSMF 1.0
**/
public static const LAYOUT_NAMESPACE:String = "http://www.osmf.org/layout/1.0";
/**
* Constructor.
*
* @langversion 3.0
* @playerversion Flash 10
* @playerversion AIR 1.5
* @productversion OSMF 1.0
**/
public function LayoutMetadata()
{
super();
}
// LayoutAttributes
//
/**
* Defines the desired position of the target in the display list
* of its context.
*
* @langversion 3.0
* @playerversion Flash 10
* @playerversion AIR 1.5
* @productversion OSMF 1.0
*/
public function get index():Number
{
return lazyOverlay ? lazyOverlay.index : NaN;
}
public function set index(value:Number):void
{
eagerOverlay.index = value;
}
/**
* Defines the desired scaleMode to be applied to the target.
*
* Possible values are on org.osmf.layout.ScaleMode.
*
* @langversion 3.0
* @playerversion Flash 10
* @playerversion AIR 1.5
* @productversion OSMF 1.0
*/
public function get scaleMode():String
{
return lazyAttributes ? lazyAttributes.scaleMode : null;
}
public function set scaleMode(value:String):void
{
eagerAttributes.scaleMode = value;
}
/**
* Defines the desired horizontal alignment to be applied to the
* target when layout of the target leaves surplus horizontal blank
* space.
*
* @langversion 3.0
* @playerversion Flash 10
* @playerversion AIR 1.5
* @productversion OSMF 1.0
*/
public function get horizontalAlign():String
{
return lazyAttributes ? lazyAttributes.horizontalAlign : null;
}
public function set horizontalAlign(value:String):void
{
eagerAttributes.horizontalAlign = value;
}
/**
* Defines the desired vertical alignment to be applied to the
* target when layout of the target leaves surplus vertical blank
* space.
*
* @langversion 3.0
* @playerversion Flash 10
* @playerversion AIR 1.5
* @productversion OSMF 1.0
*/
public function get verticalAlign():String
{
return lazyAttributes ? lazyAttributes.verticalAlign : null;
}
public function set verticalAlign(value:String):void
{
eagerAttributes.verticalAlign = value;
}
/**
* When set to true, the target's calculated position and size will
* be rounded.
*
* @langversion 3.0
* @playerversion Flash 10
* @playerversion AIR 1.5
* @productversion OSMF 1.0
*/
public function get snapToPixel():Boolean
{
return lazyAttributes ? lazyAttributes.snapToPixel : true;
}
public function set snapToPixel(value:Boolean):void
{
eagerAttributes.snapToPixel = value;
}
/**
* When set to LayoutMode.HORIZONTAL or LayoutMode.VERTICAL,
* then the renderer will ignore its target's positioning settings (either
* influencing X or Y, depending on the layoutMode chosen), laying out its elements
* adjacent in the index specified by the 'index' property.
*
* @langversion 3.0
* @playerversion Flash 10
* @playerversion AIR 1.5
* @productversion OSMF 1.0
*/
public function get layoutMode():String
{
return lazyAttributes ? lazyAttributes.layoutMode : LayoutMode.NONE;
}
public function set layoutMode(value:String):void
{
eagerAttributes.layoutMode = value;
}
/**
* When set to true (default), the target will participate in the layout
* process. When set to false, it will be ignored.
*
* @langversion 3.0
* @playerversion Flash 10
* @playerversion AIR 1.5
* @productversion OSMF 1.0
*/
public function get includeInLayout():Boolean
{
return lazyAttributes ? lazyAttributes.includeInLayout : true;
}
public function set includeInLayout(value:Boolean):void
{
eagerAttributes.includeInLayout = value;
}
// AbsoluteLayoutFacet
//
/**
* Defines the desired horizontal offset of a target expressed in
* pixels.
*
* @langversion 3.0
* @playerversion Flash 10
* @playerversion AIR 1.5
* @productversion OSMF 1.0
*/
public function get x():Number
{
return lazyAbsolute ? lazyAbsolute.x : NaN;
}
public function set x(value:Number):void
{
eagerAbsolute.x = value
}
/**
* Defines the desired vertical offset of a target expressed in
* pixels.
*
* @langversion 3.0
* @playerversion Flash 10
* @playerversion AIR 1.5
* @productversion OSMF 1.0
*/
public function get y():Number
{
return lazyAbsolute ? lazyAbsolute.y : NaN;
}
public function set y(value:Number):void
{
eagerAbsolute.y = value
}
/**
* Defines the desired horizontal size of a target expressed in
* pixels.
*
* @langversion 3.0
* @playerversion Flash 10
* @playerversion AIR 1.5
* @productversion OSMF 1.0
*/
public function get width():Number
{
return lazyAbsolute ? lazyAbsolute.width : NaN;
}
public function set width(value:Number):void
{
eagerAbsolute.width = value;
}
/**
* Defines the desired vertical offset of a target expressed in
* pixels.
*
* @langversion 3.0
* @playerversion Flash 10
* @playerversion AIR 1.5
* @productversion OSMF 1.0
*/
public function get height():Number
{
return lazyAbsolute ? lazyAbsolute.height : NaN;
}
public function set height(value:Number):void
{
eagerAbsolute.height = value;
}
// RelativeLayoutFacet
//
/**
* Defines the desired horizontal offset of a target expressed as
* a percentage of its container's width.
*
* @langversion 3.0
* @playerversion Flash 10
* @playerversion AIR 1.5
* @productversion OSMF 1.0
*/
public function get percentX():Number
{
return lazyRelative ? lazyRelative.x : NaN;
}
public function set percentX(value:Number):void
{
eagerRelative.x = value
}
/**
* Defines the desired vertical offset of a target expressed as
* a percentage of its container's height.
*
* @langversion 3.0
* @playerversion Flash 10
* @playerversion AIR 1.5
* @productversion OSMF 1.0
*/
public function get percentY():Number
{
return lazyRelative ? lazyRelative.y : NaN;
}
public function set percentY(value:Number):void
{
eagerRelative.y = value
}
/**
* Defines the desired width of a target expressed as
* a percentage of its container's width.
*
* @langversion 3.0
* @playerversion Flash 10
* @playerversion AIR 1.5
* @productversion OSMF 1.0
*/
public function get percentWidth():Number
{
return lazyRelative ? lazyRelative.width : NaN;
}
public function set percentWidth(value:Number):void
{
eagerRelative.width = value;
}
/**
* Defines the desired height of a target expressed as
* a percentage of its container's height.
*
* @langversion 3.0
* @playerversion Flash 10
* @playerversion AIR 1.5
* @productversion OSMF 1.0
*/
public function get percentHeight():Number
{
return lazyRelative ? lazyRelative.height : NaN;
}
public function set percentHeight(value:Number):void
{
eagerRelative.height = value;
}
// AnchorLayoutFacet
//
/**
* Defines the desired horizontal offset of the target in pixels.
*
* @langversion 3.0
* @playerversion Flash 10
* @playerversion AIR 1.5
* @productversion OSMF 1.0
*/
public function get left():Number
{
return lazyAnchor ? lazyAnchor.left : NaN;
}
public function set left(value:Number):void
{
eagerAnchor.left = value
}
/**
* Defines the desired vertical offset of the target in pixels.
*
* @langversion 3.0
* @playerversion Flash 10
* @playerversion AIR 1.5
* @productversion OSMF 1.0
*/
public function get top():Number
{
return lazyAnchor ? lazyAnchor.top : NaN;
}
public function set top(value:Number):void
{
eagerAnchor.top = value
}
/**
* Defines how many pixels should be present between the right-hand
* side of the target's bounding box, and the right-hand side
* of its container.
*
* @langversion 3.0
* @playerversion Flash 10
* @playerversion AIR 1.5
* @productversion OSMF 1.0
*/
public function get right():Number
{
return lazyAnchor ? lazyAnchor.right : NaN;
}
public function set right(value:Number):void
{
eagerAnchor.right = value;
}
/**
* Defines how many pixels should be present between the bottom
* side of the target's bounding box, and the bottom side
* of its container.
*
* @langversion 3.0
* @playerversion Flash 10
* @playerversion AIR 1.5
* @productversion OSMF 1.0
*/
public function get bottom():Number
{
return lazyAnchor ? lazyAnchor.bottom : NaN;
}
public function set bottom(value:Number):void
{
eagerAnchor.bottom = value;
}
// PaddingLayoutFacet
//
/**
* Defines the thickness of the blank space that is to be placed
* at the target's left-hand side.
*
* @langversion 3.0
* @playerversion Flash 10
* @playerversion AIR 1.5
* @productversion OSMF 1.0
*/
public function get paddingLeft():Number
{
return lazyPadding ? lazyPadding.left : NaN;
}
public function set paddingLeft(value:Number):void
{
eagerPadding.left = value
}
/**
* Defines the thickness of the blank space that is to be placed
* at the target's top side.
*
* @langversion 3.0
* @playerversion Flash 10
* @playerversion AIR 1.5
* @productversion OSMF 1.0
*/
public function get paddingTop():Number
{
return lazyPadding ? lazyPadding.top : NaN;
}
public function set paddingTop(value:Number):void
{
eagerPadding.top = value
}
/**
* Defines the thickness of the blank space that is to be placed
* at the target's right-hand side.
*
* @langversion 3.0
* @playerversion Flash 10
* @playerversion AIR 1.5
* @productversion OSMF 1.0
*/
public function get paddingRight():Number
{
return lazyPadding ? lazyPadding.right : NaN;
}
public function set paddingRight(value:Number):void
{
eagerPadding.right = value;
}
/**
* Defines the thickness of the blank space that is to be placed
* at the target's bottom side.
*
* @langversion 3.0
* @playerversion Flash 10
* @playerversion AIR 1.5
* @productversion OSMF 1.0
*/
public function get paddingBottom():Number
{
return lazyPadding ? lazyPadding.bottom : NaN;
}
public function set paddingBottom(value:Number):void
{
eagerPadding.bottom = value;
}
/**
* @private
*
* @langversion 3.0
* @playerversion Flash 10
* @playerversion AIR 1.5
* @productversion OSMF 1.0
*/
override public function toString():String
{
return "abs ["
+ x + ", "
+ y + ", "
+ width + ", "
+ height + "] "
+ "rel ["
+ percentX + ", "
+ percentY + ", "
+ percentWidth + ", "
+ percentHeight + "] "
+ "anch ("
+ left + ", "
+ top + ")("
+ right + ", "
+ bottom + ") "
+ "pad ["
+ paddingLeft + ", "
+ paddingTop + ", "
+ paddingRight + ", "
+ paddingBottom + "] "
+ "layoutMode: " + layoutMode + " "
+ "index: " + index + " "
+ "scale: " + scaleMode + " "
+ "valign: " + verticalAlign + " "
+ "halign: " + horizontalAlign + " "
+ "snap: " + snapToPixel;
}
/**
* @private
**/
override public function get synthesizer():MetadataSynthesizer
{
return SYNTHESIZER;
}
// Internals
//
private function get lazyAttributes():LayoutAttributesMetadata
{
return getValue(MetadataNamespaces.LAYOUT_ATTRIBUTES) as LayoutAttributesMetadata;
}
private function get eagerAttributes():LayoutAttributesMetadata
{
var result:LayoutAttributesMetadata = lazyAttributes;
if (result == null)
{
result = new LayoutAttributesMetadata();
addValue(MetadataNamespaces.LAYOUT_ATTRIBUTES, result);
}
return result;
}
private function get lazyOverlay():OverlayLayoutMetadata
{
return getValue(MetadataNamespaces.OVERLAY_LAYOUT_PARAMETERS) as OverlayLayoutMetadata;
}
private function get eagerOverlay():OverlayLayoutMetadata
{
var result:OverlayLayoutMetadata = lazyOverlay;
if (result == null)
{
result = new OverlayLayoutMetadata();
addValue(MetadataNamespaces.OVERLAY_LAYOUT_PARAMETERS, result);
}
return result;
}
private function get lazyAbsolute():AbsoluteLayoutMetadata
{
return getValue(MetadataNamespaces.ABSOLUTE_LAYOUT_PARAMETERS) as AbsoluteLayoutMetadata;
}
private function get eagerAbsolute():AbsoluteLayoutMetadata
{
var result:AbsoluteLayoutMetadata = lazyAbsolute;
if (result == null)
{
result = new AbsoluteLayoutMetadata();
addValue(MetadataNamespaces.ABSOLUTE_LAYOUT_PARAMETERS, result);
}
return result;
}
private function get lazyRelative():RelativeLayoutMetadata
{
return getValue(MetadataNamespaces.RELATIVE_LAYOUT_PARAMETERS) as RelativeLayoutMetadata;
}
private function get eagerRelative():RelativeLayoutMetadata
{
var result:RelativeLayoutMetadata = lazyRelative;
if (result == null)
{
result = new RelativeLayoutMetadata();
addValue(MetadataNamespaces.RELATIVE_LAYOUT_PARAMETERS, result);
}
return result;
}
private function get lazyAnchor():AnchorLayoutMetadata
{
return getValue(MetadataNamespaces.ANCHOR_LAYOUT_PARAMETERS) as AnchorLayoutMetadata;
}
private function get eagerAnchor():AnchorLayoutMetadata
{
var result:AnchorLayoutMetadata = lazyAnchor;
if (result == null)
{
result = new AnchorLayoutMetadata();
addValue(MetadataNamespaces.ANCHOR_LAYOUT_PARAMETERS, result);
}
return result;
}
private function get lazyPadding():PaddingLayoutMetadata
{
return getValue(MetadataNamespaces.PADDING_LAYOUT_PARAMETERS) as PaddingLayoutMetadata;
}
private function get eagerPadding():PaddingLayoutMetadata
{
var result:PaddingLayoutMetadata = lazyPadding;
if (result == null)
{
result = new PaddingLayoutMetadata();
addValue(MetadataNamespaces.PADDING_LAYOUT_PARAMETERS, result);
}
return result;
}
/* static */
private const SYNTHESIZER:NullMetadataSynthesizer = new NullMetadataSynthesizer();
}
}
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.