874f5df747cc04a9cb126216bae146181151900f
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / internal / XamlBinding / LayoutOptions.cs
1 using System;
2
3 namespace Tizen.NUI.Binding
4 {
5         [TypeConverter(typeof(LayoutOptionsConverter))]
6         internal struct LayoutOptions
7         {
8                 int _flags;
9
10                 public static readonly LayoutOptions Start = new LayoutOptions(LayoutAlignment.Start, false);
11                 public static readonly LayoutOptions Center = new LayoutOptions(LayoutAlignment.Center, false);
12                 public static readonly LayoutOptions End = new LayoutOptions(LayoutAlignment.End, false);
13                 public static readonly LayoutOptions Fill = new LayoutOptions(LayoutAlignment.Fill, false);
14                 public static readonly LayoutOptions StartAndExpand = new LayoutOptions(LayoutAlignment.Start, true);
15                 public static readonly LayoutOptions CenterAndExpand = new LayoutOptions(LayoutAlignment.Center, true);
16                 public static readonly LayoutOptions EndAndExpand = new LayoutOptions(LayoutAlignment.End, true);
17                 public static readonly LayoutOptions FillAndExpand = new LayoutOptions(LayoutAlignment.Fill, true);
18
19                 public LayoutOptions(LayoutAlignment alignment, bool expands)
20                 {
21                         var a = (int)alignment;
22                         if (a < 0 || a > 3)
23                                 throw new ArgumentOutOfRangeException();
24                         _flags = (int)alignment | (expands ? (int)LayoutExpandFlag.Expand : 0);
25                 }
26
27                 public LayoutAlignment Alignment
28                 {
29                         get { return (LayoutAlignment)(_flags & 3); }
30                         set { _flags = (_flags & ~3) | (int)value; }
31                 }
32
33                 public bool Expands
34                 {
35                         get { return (_flags & (int)LayoutExpandFlag.Expand) != 0; }
36                         set { _flags = (_flags & 3) | (value ? (int)LayoutExpandFlag.Expand : 0); }
37                 }
38         }
39 }