Support alpha to Background
[platform/core/csapi/tizenfx.git] / src / ElmSharp / ElmSharp / Background.cs
1 using System;
2
3 namespace ElmSharp
4 {
5     public class Background : Layout
6     {
7         public Background(EvasObject parent) : base(parent)
8         {
9             Style = "transparent";
10         }
11
12         public override Color Color
13         {
14             get
15             {
16                 int r = 0;
17                 int g = 0;
18                 int b = 0;
19                 int a = 0;
20                 var swallowContent = GetPartContent("elm.swallow.rectangle");
21                 if (swallowContent != IntPtr.Zero)
22                 {
23                     Interop.Evas.evas_object_color_get(swallowContent, out r, out g, out b, out a);
24                 }
25                 return new Color(r, g, b, a);
26             }
27             set
28             {
29                 var swallowContent = GetPartContent("elm.swallow.rectangle");
30                 if(swallowContent == IntPtr.Zero)
31                 {
32                     Interop.Elementary.elm_bg_color_set(Handle, value.R, value.G, value.B);
33                     swallowContent = GetPartContent("elm.swallow.rectangle");
34                 }
35                 Interop.Evas.evas_object_color_set(swallowContent, value.R, value.G, value.B, value.A);
36             }
37         }
38
39         public string File
40         {
41             get
42             {
43                 return Interop.Elementary.BackgroundFileGet(Handle);
44             }
45             set
46             {
47                 Interop.Elementary.elm_bg_file_set(Handle, value, IntPtr.Zero);
48             }
49         }
50
51         public BackgroundOptions BackgroundOption
52         {
53             get
54             {
55                 return (BackgroundOptions) Interop.Elementary.elm_bg_option_get(Handle);
56             }
57             set
58             {
59                 Interop.Elementary.elm_bg_option_set(Handle, (Interop.Elementary.BackgroundOptions) value);
60             }
61         }
62
63         internal override IntPtr CreateHandle(EvasObject parent)
64         {
65             return Interop.Elementary.elm_bg_add(parent.Handle);
66         }
67     }
68
69     public enum BackgroundOptions
70     {
71         Center,
72         Scale,
73         Stretch,
74         Tile
75     }
76 }