diff options
author | Kangho Hur <kangho.hur@samsung.com> | 2016-12-27 10:10:23 +0900 |
---|---|---|
committer | Kangho Hur <kangho.hur@samsung.com> | 2016-12-28 13:13:05 +0900 |
commit | 662a44ea670abb40844096b486d97162969ede41 (patch) | |
tree | b87c22549d3081df8169e202f49abad1731c6fa6 | |
parent | 25256d3af9366a33b82553a58dfb3b1da868d412 (diff) | |
download | elm-sharp-662a44ea670abb40844096b486d97162969ede41.tar.gz elm-sharp-662a44ea670abb40844096b486d97162969ede41.tar.bz2 elm-sharp-662a44ea670abb40844096b486d97162969ede41.zip |
Fix Image.Color behavior correctlysubmit/tizen_tv/20161229.044941accepted/tizen/tv/20161229.113256
- Color.Default is now available on Image.Color
- ImageTest3 which is to test Image.color has been added.
Change-Id: I5ad9042e49d124b36bff3227bec007659734fc28
-rw-r--r-- | ElmSharp.Test/ElmSharp.Test.csproj | 4 | ||||
-rw-r--r-- | ElmSharp.Test/TC/ImageTest2.cs | 2 | ||||
-rw-r--r-- | ElmSharp.Test/TC/ImageTest3.cs | 135 | ||||
-rw-r--r-- | ElmSharp.Test/res/btn_delete.png | bin | 0 -> 3826 bytes | |||
-rw-r--r-- | ElmSharp/ElmSharp/Image.cs | 21 |
5 files changed, 152 insertions, 10 deletions
diff --git a/ElmSharp.Test/ElmSharp.Test.csproj b/ElmSharp.Test/ElmSharp.Test.csproj index e89c87a..b874efe 100644 --- a/ElmSharp.Test/ElmSharp.Test.csproj +++ b/ElmSharp.Test/ElmSharp.Test.csproj @@ -63,6 +63,7 @@ <Compile Include="TC\GenListTest3.cs" /> <Compile Include="TC\GenListTest4.cs" /> <Compile Include="TC\GenListTest6.cs" /> + <Compile Include="TC\ImageTest3.cs" /> <Compile Include="TC\ImageTest2.cs" /> <Compile Include="TC\TableTest1.cs" /> <Compile Include="TC\GenListTest8.cs" /> @@ -103,6 +104,7 @@ </ProjectReference> </ItemGroup> <ItemGroup> + <Content Include="res\btn_delete.png" /> <Content Include="res\picture.png"> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> </Content> @@ -184,4 +186,4 @@ </FlavorProperties> </VisualStudio> </ProjectExtensions> -</Project> +</Project>
\ No newline at end of file diff --git a/ElmSharp.Test/TC/ImageTest2.cs b/ElmSharp.Test/TC/ImageTest2.cs index 3243c24..b82f357 100644 --- a/ElmSharp.Test/TC/ImageTest2.cs +++ b/ElmSharp.Test/TC/ImageTest2.cs @@ -118,7 +118,7 @@ namespace ElmSharp.Test void UpdateLabelText(string text) { - lbInfo.Text = "<span color=#ffffff font_size=20>" + text + "</span>"; + lbInfo.Text = "<span color=#ffffff font_size=20> BackgroundColor => " + text + "</span>"; } } } diff --git a/ElmSharp.Test/TC/ImageTest3.cs b/ElmSharp.Test/TC/ImageTest3.cs new file mode 100644 index 0000000..db3617b --- /dev/null +++ b/ElmSharp.Test/TC/ImageTest3.cs @@ -0,0 +1,135 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +using System; +using System.IO; + +namespace ElmSharp.Test +{ + public class ImageTest3 : TestCaseBase + { + public override string TestName => "ImageTest3"; + public override string TestDescription => "To test basic operation of Image"; + + Image image; + Label lbInfo; + + public override void Run(Window window) + { + Conformant conformant = new Conformant(window); + conformant.Show(); + Box box = new Box(window); + conformant.SetContent(box); + box.Show(); + + Box buttonBox1 = new Box(window) { + IsHorizontal = true, + AlignmentX = -1, + AlignmentY = 0, + }; + buttonBox1.Show(); + + Box buttonBox2 = new Box(window) { + IsHorizontal = true, + AlignmentX = -1, + AlignmentY = 0, + }; + buttonBox2.Show(); + + Button btnFile1 = new Button(window) { + Text = "Blue (BG)", + AlignmentX = -1, + AlignmentY = -1, + WeightX = 1, + WeightY = 1 + }; + btnFile1.Show(); + + Button btnFile2 = new Button(window) { + Text = "Default (BG)", + AlignmentX = -1, + AlignmentY = -1, + WeightX = 1, + WeightY = 1 + }; + btnFile2.Show(); + + Button btnFile3 = new Button(window) { + Text = "Blue (FG)", + AlignmentX = -1, + AlignmentY = -1, + WeightX = 1, + WeightY = 1 + }; + btnFile3.Show(); + + Button btnFile4 = new Button(window) { + Text = "Default (FG)", + AlignmentX = -1, + AlignmentY = -1, + WeightX = 1, + WeightY = 1 + }; + btnFile4.Show(); + + buttonBox1.PackEnd(btnFile1); + buttonBox1.PackEnd(btnFile2); + buttonBox2.PackEnd(btnFile3); + buttonBox2.PackEnd(btnFile4); + + lbInfo = new Label(window) { + Color = Color.White, + AlignmentX = -1, + AlignmentY = 0, + WeightX = 1 + }; + lbInfo.Show(); + + image = new Image(window) { + IsFixedAspect = true, + AlignmentX = -1, + AlignmentY = -1, + WeightX = 1, + WeightY = 1 + }; + image.Show(); + image.Load(Path.Combine(TestRunner.ResourceDir, "btn_delete.png")); + image.Clicked += (s, e) => + { + Console.WriteLine("Image has been clicked. (IsFixedAspect = {0}", image.IsFixedAspect); + image.IsFixedAspect = image.IsFixedAspect == true ? false : true; + }; + + btnFile1.Clicked += (s, e) => { image.BackgroundColor = Color.Blue; UpdateLabelText(image.BackgroundColor.ToString()); }; + btnFile2.Clicked += (s, e) => { image.BackgroundColor = Color.Default; UpdateLabelText(image.BackgroundColor.ToString()); }; + btnFile3.Clicked += (s, e) => { image.Color = Color.Blue; UpdateLabelText(image.Color.ToString(), false); }; + btnFile4.Clicked += (s, e) => { image.Color = Color.Default; UpdateLabelText(image.Color.ToString(), false); }; + + box.PackEnd(buttonBox1); + box.PackEnd(buttonBox2); + box.PackEnd(lbInfo); + box.PackEnd(image); + } + + void UpdateLabelText(string text, bool isBackground = true) + { + if(isBackground) + lbInfo.Text = "<span color=#ffffff font_size=20> Background Color => " + text + "</span>"; + else + lbInfo.Text = "<span color=#ffffff font_size=20> Foreground Color => " + text + "</span>"; + } + } +} diff --git a/ElmSharp.Test/res/btn_delete.png b/ElmSharp.Test/res/btn_delete.png Binary files differnew file mode 100644 index 0000000..7bafac6 --- /dev/null +++ b/ElmSharp.Test/res/btn_delete.png diff --git a/ElmSharp/ElmSharp/Image.cs b/ElmSharp/ElmSharp/Image.cs index fece740..89d1aad 100644 --- a/ElmSharp/ElmSharp/Image.cs +++ b/ElmSharp/ElmSharp/Image.cs @@ -26,6 +26,7 @@ namespace ElmSharp bool _canScaleUp = true; bool _canScaleDown = true; SmartEvent _clicked; + Color _color = Color.Default; public Image(EvasObject parent) : base(parent) { @@ -222,21 +223,25 @@ namespace ElmSharp { get { - int r = 255, g = 255, b = 255, a = 255; - IntPtr evasObj = Interop.Elementary.elm_image_object_get(RealHandle); - if (evasObj != IntPtr.Zero) - { - Interop.Evas.evas_object_color_get(evasObj, out r, out g, out b, out a); - } - return Color.FromRgba(r, g, b, a); + return _color; } set { IntPtr evasObj = Interop.Elementary.elm_image_object_get(RealHandle); if (evasObj != IntPtr.Zero) { - Interop.Evas.evas_object_color_set(evasObj, value.R, value.G, value.B, value.A); + if (value.IsDefault) + { + // Currently, we assume the Image.Color property as a blending color (actually, multiply blending). + // Thus we are using Color.White (255,255,255,255) as a default color to ensure original image color. (255/255 * original = original) + Interop.Evas.evas_object_color_set(evasObj, 255, 255, 255, 255); + } + else + { + Interop.Evas.SetPremultipliedColor(evasObj, value.R, value.G, value.B, value.A); + } } + _color = value; } } |