From d726a01260f25e1b69cbf7eed3347601bfb084c3 Mon Sep 17 00:00:00 2001 From: zhouleonlei <56956725+zhouleonlei@users.noreply.github.com> Date: Mon, 8 Jun 2020 19:34:07 +0800 Subject: [PATCH] [NUI]Add layouts and refine codes for Samples (#1595) * [NUI]Add layouts and refine codes for Samples * [NUI] Modified app path issue and layout * [NUI] Modified ItemView * [NUI] Modify layout and display issues * [NUI] Remove Style --- .../Tizen.NUI.Samples/Tizen.NUI.Samples/Program.cs | 2 +- .../Tizen.NUI.Samples/SampleMain.cs | 6 +- .../Tizen.NUI.Samples/Samples/ButtonSample.cs | 449 +++++++++++++-------- .../Tizen.NUI.Samples/Samples/CheckBoxSample.cs | 246 ++++++----- .../Samples/ContactCard/ContactCardLayouter.cs | 13 + .../Samples/ContactCard/ContactCardsSample.cs | 5 +- .../Samples/ContactCard/ContactData.cs | 2 +- .../Samples/ContactCard/MaskedImage.cs | 2 +- .../Samples/CubeTransitionEffectSample.cs | 165 +++++--- .../Tizen.NUI.Samples/Samples/DaliDemo/DaliDemo.cs | 1 + .../Tizen.NUI.Samples/Samples/DropDownSample.cs | 167 +++++--- .../Samples/FlexibleViewSample.cs | 103 +++-- .../Samples/ItemViewDemo/ItemViewSample.cs | 310 +++++++------- .../Tizen.NUI.Samples/Samples/LoadingSample.cs | 341 +++++++++------- .../Tizen.NUI.Samples/Samples/PaginationSample.cs | 177 ++++++-- .../Tizen.NUI.Samples/Samples/PopupSample.cs | 106 +++-- .../Tizen.NUI.Samples/Samples/ProgressSample.cs | 384 ++++++++++-------- .../Tizen.NUI.Samples/Samples/RadioButtonSample.cs | 233 ++++++----- .../Tizen.NUI.Samples/Samples/ScrollBarSample.cs | 357 ++++++++-------- .../Tizen.NUI.Samples/Samples/SliderSample.cs | 283 +++++++------ .../Tizen.NUI.Samples/Samples/SwitchSample.cs | 298 +++++++------- .../Tizen.NUI.Samples/Samples/TabSample.cs | 193 +++++---- .../Tizen.NUI.Samples/Samples/ToastSample.cs | 209 ++++++---- 23 files changed, 2413 insertions(+), 1639 deletions(-) diff --git a/test/Tizen.NUI.Samples/Tizen.NUI.Samples/Program.cs b/test/Tizen.NUI.Samples/Tizen.NUI.Samples/Program.cs index b66e5ea..91627e2 100755 --- a/test/Tizen.NUI.Samples/Tizen.NUI.Samples/Program.cs +++ b/test/Tizen.NUI.Samples/Tizen.NUI.Samples/Program.cs @@ -23,7 +23,7 @@ namespace Tizen.NUI.Samples [STAThread] static void Main(string[] args) { - new DaliDemo(CommonResource.GetDaliResourcePath() + @"../../style/demo-theme.json").Run(args); + new DaliDemo("").Run(args); } } } diff --git a/test/Tizen.NUI.Samples/Tizen.NUI.Samples/SampleMain.cs b/test/Tizen.NUI.Samples/Tizen.NUI.Samples/SampleMain.cs index 8913772..2384c54 100755 --- a/test/Tizen.NUI.Samples/Tizen.NUI.Samples/SampleMain.cs +++ b/test/Tizen.NUI.Samples/Tizen.NUI.Samples/SampleMain.cs @@ -10,17 +10,17 @@ namespace Tizen.NUI.Samples { public static string GetDaliResourcePath() { - return @"/opt/usr/globalapps/org.tizen.example.Tizen.NUI.Samples/res/images/Dali/"; + return Tizen.Applications.Application.Current.DirectoryInfo.Resource + "images/Dali/"; } public static string GetFHResourcePath() { - return @"/opt/usr/globalapps/org.tizen.example.Tizen.NUI.Samples/res/images/FH3/"; + return Tizen.Applications.Application.Current.DirectoryInfo.Resource + "images/FH3/"; } public static string GetTVResourcePath() { - return @"/opt/usr/globalapps/org.tizen.example.Tizen.NUI.Samples/res/images/VD/"; + return Tizen.Applications.Application.Current.DirectoryInfo.Resource + "images/VD/"; } } } diff --git a/test/Tizen.NUI.Samples/Tizen.NUI.Samples/Samples/ButtonSample.cs b/test/Tizen.NUI.Samples/Tizen.NUI.Samples/Samples/ButtonSample.cs index b40eb1a..f306f57 100755 --- a/test/Tizen.NUI.Samples/Tizen.NUI.Samples/Samples/ButtonSample.cs +++ b/test/Tizen.NUI.Samples/Tizen.NUI.Samples/Samples/ButtonSample.cs @@ -6,10 +6,10 @@ namespace Tizen.NUI.Samples { public class ButtonSample : IExample { - private static readonly int XBase = 100; - private static readonly int YBase = 300; - private static readonly int XPadding = 350; private View root; + private View parent1; + private View parent2; + private View parent3; Button textButton; Button iconButton; @@ -28,186 +28,250 @@ namespace Tizen.NUI.Samples public void Activate() { Window window = NUIApplication.GetDefaultWindow(); - - //ImageView imageView1 = new ImageView(); - //imageView1.Size2D = new Size2D(48, 48); - //imageView1.Position2D = new Position2D(200, 200); - //imageView1.ResourceUrl = CommonResource.GetFHResourcePath() + "9. Controller/controller_btn_check.png"; - //window.Add(imageView1); - - //ImageView imageView2 = new ImageView(); - //imageView2.Size2D = new Size2D(48, 48); - //imageView2.Position2D = new Position2D(500, 200); - //imageView2.ResourceUrl = CommonResource.GetFHResourcePath() + "9. Controller/[Controller] App Primary Color/controller_btn_check_on_24c447.png"; - //window.Add(imageView2); - root = new View() { - Size2D = new Size2D(1920, 1080), + Size = new Size(1920, 1080), + BackgroundColor = new Color(0.7f, 0.9f, 0.8f, 1.0f), + Layout = new LinearLayout() + { + LinearAlignment = LinearLayout.Alignment.Center, + LinearOrientation = LinearLayout.Orientation.Horizontal, + CellPadding = new Size(50, 50), + } }; window.Add(root); window.KeyEvent += Window_KeyEvent; + parent1 = new View() + { + Size = new Size(300, 900), + Layout = new LinearLayout() + { + LinearAlignment = LinearLayout.Alignment.Top, + LinearOrientation = LinearLayout.Orientation.Vertical, + CellPadding = new Size(50, 50), + } + }; + + parent2 = new View() + { + Size = new Size(300, 900), + Layout = new LinearLayout() + { + LinearAlignment = LinearLayout.Alignment.Top, + LinearOrientation = LinearLayout.Orientation.Vertical, + CellPadding = new Size(50, 50), + } + }; + + // Only show a text button. textButton = new Button(); - textButton.Style.BackgroundImage = CommonResource.GetTVResourcePath() + "component/c_buttonbasic/c_basic_button_white_bg_normal_9patch.png"; - textButton.Style.BackgroundImageBorder = new Rectangle(4, 4, 5, 5); - textButton.Size2D = new Size2D(300, 80); - textButton.Position2D = new Position2D(100, 100); - textButton.Style.Text.TextShadow = new TextShadow(Color.Blue, new Vector2(2.0f, 2.0f), 5.0f); - textButton.Style.Text.Text = "Button"; - root.Add(textButton); + textButton.BackgroundImage = CommonResource.GetTVResourcePath() + "component/c_buttonbasic/c_basic_button_white_bg_normal_9patch.png"; + textButton.BackgroundImageBorder = new Rectangle(4, 4, 5, 5); + textButton.Size = new Size(300, 80); + textButton.ButtonText.Text = "Button"; + parent1.Add(textButton); + //Only show an icon button. iconButton = new Button(); - iconButton.Style.BackgroundImage = CommonResource.GetTVResourcePath() + "component/c_buttonbasic/c_basic_button_white_bg_normal_9patch.png"; - iconButton.Style.BackgroundImageBorder = new Rectangle(4, 4, 5, 5); - iconButton.Size2D = new Size2D(100, 100); - iconButton.Position2D = new Position2D(600, 100); - iconButton.Style.Icon.ResourceUrl = CommonResource.GetTVResourcePath() + "component/c_radiobutton/c_radiobutton_white_check.png"; - root.Add(iconButton); + iconButton.Text = ""; + iconButton.Name = "IconButton"; + iconButton.BackgroundImage = CommonResource.GetTVResourcePath() + "component/c_buttonbasic/c_basic_button_white_bg_normal_9patch.png"; + iconButton.BackgroundImageBorder = new Rectangle(4, 4, 5, 5); + iconButton.Size = new Size(80, 80); + iconButton.ButtonIcon.ResourceUrl = CommonResource.GetTVResourcePath() + "component/c_radiobutton/c_radiobutton_white_check.png"; + parent2.Add(iconButton); + iconButton.ClickEvent += (ojb, e) => { + var btn = iconButton.ButtonIcon.GetParent() as Button; + string name = btn.Name; + }; + + parent3 = new View() + { + Size = new Size(600, 400), + Layout = new LinearLayout() + { + LinearAlignment = LinearLayout.Alignment.Top, + LinearOrientation = LinearLayout.Orientation.Vertical, + CellPadding = new Size(50, 50), + } + }; + //Show a button with icon and text. iconTextButton = new Button(); - iconTextButton.Style.BackgroundImage = CommonResource.GetTVResourcePath() + "component/c_buttonbasic/c_basic_button_white_bg_normal_9patch.png"; - iconTextButton.Style.BackgroundImageBorder = new Rectangle(4, 4, 5, 5); + iconTextButton.Text = "IconTextButton"; + iconTextButton.BackgroundImage = CommonResource.GetTVResourcePath() + "component/c_buttonbasic/c_basic_button_white_bg_normal_9patch.png"; + iconTextButton.BackgroundImageBorder = new Rectangle(4, 4, 5, 5); iconTextButton.IconRelativeOrientation = Button.IconOrientation.Left; - iconTextButton.Style.Icon.ResourceUrl = CommonResource.GetTVResourcePath() + "component/c_radiobutton/c_radiobutton_white_check.png"; - iconTextButton.Style.IconPadding.Top = 20; - iconTextButton.Style.IconPadding.Bottom = 20; - iconTextButton.Style.IconPadding.Start = 20; - iconTextButton.Style.IconPadding.End = 20; - iconTextButton.Style.Text.Text = "IconTextButton"; - iconTextButton.Style.TextPadding.Top = 20; - iconTextButton.Style.TextPadding.Bottom = 20; - iconTextButton.Style.TextPadding.Start = 20; - iconTextButton.Style.TextPadding.End = 50; - iconTextButton.Size2D = new Size2D(500, 300); - iconTextButton.Position2D = new Position2D(900, 100); - root.Add(iconTextButton); + iconTextButton.ButtonIcon.ResourceUrl = CommonResource.GetTVResourcePath() + "component/c_radiobutton/c_radiobutton_white_check.png"; + iconTextButton.IconPadding = new Extents(20, 20, 20, 20); + iconTextButton.TextPadding = new Extents(20, 50, 20, 20); + iconTextButton.Size = new Size(500, 300); + parent3.Add(iconTextButton); ///////////////////////////////////////////////Create by Property////////////////////////////////////////////////////////// + //Create utility basic style of button. + var utilityBasicButtonStyle = new ButtonStyle() + { + Overlay = new ImageViewStyle() + { + ResourceUrl = new Selector + { + Pressed = CommonResource.GetFHResourcePath() + "3. Button/rectangle_btn_press_overlay.png", + Other = "" + }, + Border = new Rectangle(5, 5, 5, 5) + }, + Text = new TextLabelStyle() + { + TextColor = new Selector + { + Normal = new Color(0, 0, 0, 1), + Pressed = new Color(0, 0, 0, 0.7f), + Selected = new Color(0.058f, 0.631f, 0.92f, 1), + Disabled = new Color(0, 0, 0, 0.4f) + }, + Text = "UtilityBasicButton", + PointSize = 20, + }, + BackgroundImage = CommonResource.GetFHResourcePath() + "3. Button/rectangle_btn_normal.png", + BackgroundImageBorder = new Rectangle(5, 5, 5, 5), + }; utilityBasicButton = new Button(); + utilityBasicButton.ApplyStyle(utilityBasicButtonStyle); utilityBasicButton.IsSelectable = true; - utilityBasicButton.Style.BackgroundImage = CommonResource.GetFHResourcePath() + "3. Button/rectangle_btn_normal.png"; - utilityBasicButton.Style.BackgroundImageBorder = new Rectangle(5, 5, 5, 5); - utilityBasicButton.Style.ImageShadow = new ImageShadow + utilityBasicButton.ImageShadow = new ImageShadow { Url = CommonResource.GetFHResourcePath() + "3. Button/rectangle_btn_shadow.png", Border = new Rectangle(5, 5, 5, 5) }; - utilityBasicButton.Style.Overlay.ResourceUrl = new Selector - { - Pressed = CommonResource.GetFHResourcePath() + "3. Button/rectangle_btn_press_overlay.png", - Other = "" - }; - utilityBasicButton.Style.Overlay.Border = new Rectangle(5, 5, 5, 5); + utilityBasicButton.Size = new Size(300, 80); + utilityBasicButton.IsEnabled = false; + parent1.Add(utilityBasicButton); - utilityBasicButton.Style.Text.TextColor = new Selector + //Create utility service style of button. + var utilityServiceButtonStyle = new ButtonStyle() { - Normal = new Color(0, 0, 0, 1), - Pressed = new Color(0, 0, 0, 0.7f), - Selected = new Color(0.058f, 0.631f, 0.92f, 1), - Disabled = new Color(0, 0, 0, 0.4f) + Overlay = new ImageViewStyle() + { + ResourceUrl = new Selector + { + Pressed = CommonResource.GetFHResourcePath() + "3. Button/rectangle_btn_press_overlay.png", + Other = "" + }, + Border = new Rectangle(5, 5, 5, 5) + }, + Text = new TextLabelStyle() + { + TextColor = new Selector + { + Normal = new Color(1, 1, 1, 1), + Pressed = new Color(1, 1, 1, 0.7f), + Disabled = new Color(1, 1, 1, 0.4f) + }, + Text = "ServiceBasicButton", + PointSize = 20, + }, + BackgroundImage = CommonResource.GetFHResourcePath() + "3. Button/rectangle_point_btn_normal.png", + BackgroundImageBorder = new Rectangle(5, 5, 5, 5) }; - - utilityBasicButton.Size2D = new Size2D(300, 80); - utilityBasicButton.Position2D = new Position2D(XBase, 300); - utilityBasicButton.Style.Text.PointSize = 20; - utilityBasicButton.Style.Text.Text = "UtilityBasicButton"; - utilityBasicButton.IsEnabled = false; - root.Add(utilityBasicButton); - - ///////////////////////////////////////////////////////////////////////////////////////////////////////// utilityServiceButton = new Button(); - utilityServiceButton.Style.BackgroundImage = CommonResource.GetFHResourcePath() + "3. Button/rectangle_point_btn_normal.png"; - utilityServiceButton.Style.BackgroundImageBorder = new Rectangle(5, 5, 5, 5); - utilityServiceButton.Style.ImageShadow = new ImageShadow + utilityServiceButton.ApplyStyle(utilityServiceButtonStyle); + utilityServiceButton.ImageShadow = new ImageShadow { Url = CommonResource.GetFHResourcePath() + "3. Button/rectangle_btn_shadow.png", Border = new Rectangle(5, 5, 5, 5) }; - utilityServiceButton.Style.Overlay.ResourceUrl = new Selector - { - Pressed = CommonResource.GetFHResourcePath() + "3. Button/rectangle_btn_press_overlay.png", - Other = "" - }; - utilityServiceButton.Style.Overlay.Border = new Rectangle(5, 5, 5, 5); - utilityServiceButton.Style.Text.TextColor = new Selector + + utilityServiceButton.Size = new Size(300, 80); + parent1.Add(utilityServiceButton); + + //Create utility toggle style of button. + var utilityToggleButtonStyle = new ButtonStyle() { - Normal = new Color(1, 1, 1, 1), - Pressed = new Color(1, 1, 1, 0.7f), - Disabled = new Color(1, 1, 1, 0.4f) + BackgroundImage = new Selector + { + Normal = CommonResource.GetFHResourcePath() + "3. Button/rectangle_toggle_btn_normal.png", + Selected = CommonResource.GetFHResourcePath() + "3. Button/rectangle_point_btn_normal.png", + }, + Overlay = new ImageViewStyle() + { + ResourceUrl = new Selector + { + Pressed = CommonResource.GetFHResourcePath() + "3. Button/rectangle_btn_press_overlay.png", + Other = "" + } + }, + Text = new TextLabelStyle() + { + TextColor = new Selector + { + Normal = new Color(0.058f, 0.631f, 0.92f, 1), + Selected = new Color(1, 1, 1, 1), + }, + Text = new Selector + { + Normal = "Toggle Off", + Selected = "Toggle On" + }, + PointSize = 20 + }, + BackgroundColor = new Selector() }; - - utilityServiceButton.Size2D = new Size2D(300, 80); - utilityServiceButton.Position2D = new Position2D(XBase, 500); - utilityServiceButton.Style.Text.PointSize = 20; - utilityServiceButton.Style.Text.Text = "ServiceBasicButton"; - root.Add(utilityServiceButton); - ///////////////////////////////////////////////////////////////////////////////////////////////////////// utilityToggleButton = new Button(); + utilityToggleButton.ApplyStyle(utilityToggleButtonStyle); utilityToggleButton.IsSelectable = true; - utilityToggleButton.Style.BackgroundImage = new Selector - { - Normal = CommonResource.GetFHResourcePath() + "3. Button/rectangle_toggle_btn_normal.png", - Selected = CommonResource.GetFHResourcePath() + "3. Button/rectangle_point_btn_normal.png", - }; - - utilityToggleButton.Style.BackgroundImageBorder = new Rectangle(5, 5, 5, 5); - utilityToggleButton.Style.ImageShadow = new ImageShadow + utilityToggleButton.BackgroundImageBorder = new Rectangle(5, 5, 5, 5); + utilityToggleButton.ImageShadow = new ImageShadow { Url = CommonResource.GetFHResourcePath() + "3. Button/rectangle_btn_shadow.png", Border = new Rectangle(5, 5, 5, 5) }; - utilityToggleButton.Style.Overlay.ResourceUrl = new Selector - { - Pressed = CommonResource.GetFHResourcePath() + "3. Button/rectangle_btn_press_overlay.png", - Other = "" - }; - utilityToggleButton.Style.Overlay.Border = new Rectangle(5, 5, 5, 5); + utilityToggleButton.ButtonOverlay.Border = new Rectangle(5, 5, 5, 5); + utilityToggleButton.Size = new Size(300, 80); + parent1.Add(utilityToggleButton); - utilityToggleButton.Style.Text.TextColor = new Selector + //Create utility oval style of button. + var utilityOvalButtonStyle = new ButtonStyle() { - Normal = new Color(0.058f, 0.631f, 0.92f, 1), - Selected = new Color(1, 1, 1, 1), - }; - - utilityToggleButton.Size2D = new Size2D(300, 80); - utilityToggleButton.Position2D = new Position2D(XBase, 700); - utilityToggleButton.Style.Text.PointSize = 20; - utilityToggleButton.Style.Text.Text = new Selector - { - Normal = "Toggle Off", - Selected = "Toggle On" + BackgroundImage = new Selector + { + Normal = CommonResource.GetFHResourcePath() + "3. Button/oval_toggle_btn_normal.png", + Selected = CommonResource.GetFHResourcePath() + "3. Button/oval_toggle_btn_select.png", + }, + Overlay = new ImageViewStyle() + { + ResourceUrl = new Selector + { + Pressed = CommonResource.GetFHResourcePath() + "3. Button/oval_toggle_btn_press_overlay.png", + Other = "" + } + }, + Text = new TextLabelStyle() + { + Text = "", + }, + BackgroundColor = new Selector(), }; - root.Add(utilityToggleButton); - ///////////////////////////////////////////////////////////////////////////////////////////////////////// utilityOvalButton = new Button(); + utilityOvalButton.ApplyStyle(utilityOvalButtonStyle); utilityOvalButton.IsSelectable = true; - utilityOvalButton.Style.BackgroundImage = new Selector - { - Normal = CommonResource.GetFHResourcePath() + "3. Button/oval_toggle_btn_normal.png", - Selected = CommonResource.GetFHResourcePath() + "3. Button/oval_toggle_btn_select.png", - }; - utilityOvalButton.Style.BackgroundImageBorder = new Rectangle(5, 5, 5, 5); - utilityOvalButton.Style.ImageShadow = new ImageShadow + utilityOvalButton.BackgroundImageBorder = new Rectangle(5, 5, 5, 5); + utilityOvalButton.ImageShadow = new ImageShadow { Url = CommonResource.GetFHResourcePath() + "3. Button/oval_toggle_btn_shadow.png", Border = new Rectangle(5, 5, 5, 5) }; - utilityOvalButton.Style.Overlay.ResourceUrl = new Selector - { - Pressed = CommonResource.GetFHResourcePath() + "3. Button/oval_toggle_btn_press_overlay.png", - Other = "" - }; - utilityOvalButton.Style.Overlay.Border = new Rectangle(5, 5, 5, 5); + utilityOvalButton.ButtonOverlay.Border = new Rectangle(5, 5, 5, 5); - utilityOvalButton.Size2D = new Size2D(104, 104); - utilityOvalButton.Position2D = new Position2D(XBase, 900); - utilityOvalButton.Style.Text.PointSize = 20; - root.Add(utilityOvalButton); + utilityOvalButton.Size = new Size(104, 104); + utilityOvalButton.ButtonText.PointSize = 20; + parent1.Add(utilityOvalButton); ///////////////////////////////////////////////Create by Attributes////////////////////////////////////////////////////////// - ButtonStyle familyBasicButtonAttributes = new ButtonStyle + //Create family basic style of Button. + ButtonStyle familyBasicButtonStyle = new ButtonStyle { IsSelectable = true, BackgroundImage = new Selector { All = CommonResource.GetFHResourcePath() + "3. Button/rectangle_btn_normal.png" }, @@ -239,17 +303,15 @@ namespace Tizen.NUI.Samples Selected = new Color(0.141f, 0.769f, 0.278f, 1), Disabled = new Color(0, 0, 0, 0.4f), }, + Text = "FamilyBasicButton", } }; - familyBasicButton = new Button(familyBasicButtonAttributes); - familyBasicButton.Size2D = new Size2D(300, 80); - familyBasicButton.Position2D = new Position2D(XBase + XPadding, 300); - familyBasicButton.Style.Text.PointSize = 20; - familyBasicButton.Style.Text.Text = "FamilyBasicButton"; - root.Add(familyBasicButton); - - ////////////////////////////////////////////////////////////////////////////////////////////////// - ButtonStyle familyServiceButtonAttributes = new ButtonStyle + familyBasicButton = new Button(familyBasicButtonStyle); + familyBasicButton.Size = new Size(300, 80); + parent2.Add(familyBasicButton); + + //Create family service style of button. + ButtonStyle familyServiceButtonStyle = new ButtonStyle { IsSelectable = false, BackgroundImage = new Selector { All = CommonResource.GetFHResourcePath() + "3. Button/[Button] App Primary Color/rectangle_point_btn_normal_24c447.png" }, @@ -281,16 +343,15 @@ namespace Tizen.NUI.Samples Pressed = new Color(1, 1, 1, 0.7f), Disabled = new Color(1, 1, 1, 0.4f), }, + Text = "FamilySeviceButton" } }; - familyServiceButton = new Button(familyServiceButtonAttributes); - familyServiceButton.Size2D = new Size2D(300, 80); - familyServiceButton.Position2D = new Position2D(XBase + XPadding, 500); - familyServiceButton.Style.Text.PointSize = 20; - familyServiceButton.Style.Text.Text = "FamilySeviceButton"; - root.Add(familyServiceButton); - ////////////////////////////////////////////////////////////////////////////////////////////////// - ButtonStyle familyToggleButtonAttributes = new ButtonStyle + familyServiceButton = new Button(familyServiceButtonStyle); + familyServiceButton.Size = new Size(300, 80); + parent2.Add(familyServiceButton); + + //Create family toggle style of button. + ButtonStyle familyToggleButtonStyle = new ButtonStyle { IsSelectable = true, BackgroundImage = new Selector @@ -325,20 +386,19 @@ namespace Tizen.NUI.Samples Normal = new Color(0.141f, 0.769f, 0.278f, 1), Selected = new Color(1, 1, 1, 1), }, + Text = new Selector + { + Normal = "Toggle Off", + Selected = "Toggle On" + } } }; - familyToggleButton = new Button(familyToggleButtonAttributes); - familyToggleButton.Size2D = new Size2D(300, 80); - familyToggleButton.Position2D = new Position2D(XBase + XPadding, 700); - familyToggleButton.Style.Text.PointSize = 20; - familyToggleButton.Style.Text.Text = new Selector - { - Normal = "Toggle Off", - Selected = "Toggle On" - }; - root.Add(familyToggleButton); - ////////////////////////////////////////////////////////////////////////////////////////////////// - ButtonStyle familyOvalButtonAttributes = new ButtonStyle + familyToggleButton = new Button(familyToggleButtonStyle); + familyToggleButton.Size = new Size(300, 80); + parent2.Add(familyToggleButton); + + //Create family oval style of button. + ButtonStyle familyOvalButtonStyle = new ButtonStyle { IsSelectable = true, BackgroundImage = new Selector @@ -360,11 +420,14 @@ namespace Tizen.NUI.Samples Border = new Selector { All = new Rectangle(5, 5, 5, 5) }, }, }; - familyOvalButton = new Button(familyOvalButtonAttributes); - familyOvalButton.Size2D = new Size2D(104, 104); - familyOvalButton.Position2D = new Position2D(XBase + XPadding, 900); - familyOvalButton.Style.Text.PointSize = 20; - root.Add(familyOvalButton); + familyOvalButton = new Button(familyOvalButtonStyle); + familyOvalButton.Size = new Size(104, 104); + parent2.Add(familyOvalButton); + + // Add three layout into root + root.Add(parent1); + root.Add(parent2); + root.Add(parent3); } private void Window_KeyEvent(object sender, Window.KeyEventArgs e) @@ -386,10 +449,10 @@ namespace Tizen.NUI.Samples iconTextButton.IconRelativeOrientation = Button.IconOrientation.Left; break; case "5": - iconTextButton.Style.Icon.Padding.Start = 50; + iconTextButton.ButtonIcon.Padding.Start = 50; break; case "6": - iconTextButton.Style.Icon.Padding.End = 50; + iconTextButton.ButtonIcon.Padding.End = 50; break; case "7": iconTextButton.LayoutDirection = ViewLayoutDirectionType.RTL; @@ -405,8 +468,54 @@ namespace Tizen.NUI.Samples { if (root != null) { + parent1.Remove(textButton); + textButton.Dispose(); + textButton = null; + parent1.Remove(utilityBasicButton); + utilityBasicButton.Dispose(); + utilityBasicButton = null; + parent1.Remove(utilityServiceButton); + utilityServiceButton.Dispose(); + utilityServiceButton = null; + parent1.Remove(utilityToggleButton); + utilityToggleButton.Dispose(); + utilityToggleButton = null; + parent1.Remove(utilityOvalButton); + utilityOvalButton.Dispose(); + utilityOvalButton = null; + + parent1.Remove(familyBasicButton); + familyBasicButton.Dispose(); + familyBasicButton = null; + parent1.Remove(familyServiceButton); + familyServiceButton.Dispose(); + familyServiceButton = null; + parent1.Remove(familyToggleButton); + familyToggleButton.Dispose(); + familyToggleButton = null; + parent1.Remove(familyOvalButton); + familyOvalButton.Dispose(); + familyOvalButton = null; + + parent3.Remove(iconTextButton); + iconTextButton.Dispose(); + iconTextButton = null; + + root.Remove(parent1); + parent1.Dispose(); + parent1 = null; + + root.Remove(parent2); + parent2.Dispose(); + parent2 = null; + + root.Remove(parent3); + parent3.Dispose(); + parent3 = null; + NUIApplication.GetDefaultWindow().Remove(root); root.Dispose(); + root = null; } } } diff --git a/test/Tizen.NUI.Samples/Tizen.NUI.Samples/Samples/CheckBoxSample.cs b/test/Tizen.NUI.Samples/Tizen.NUI.Samples/Samples/CheckBoxSample.cs index 11af1dc..3d05d3c 100755 --- a/test/Tizen.NUI.Samples/Tizen.NUI.Samples/Samples/CheckBoxSample.cs +++ b/test/Tizen.NUI.Samples/Tizen.NUI.Samples/Samples/CheckBoxSample.cs @@ -7,6 +7,10 @@ namespace Tizen.NUI.Samples public class CheckBoxSample : IExample { private View root; + private View left; + private View right; + private View leftbody; + private View rightbody; private TextLabel[] createText = new TextLabel[2]; private TextLabel[] modeText = new TextLabel[4]; @@ -36,176 +40,200 @@ namespace Tizen.NUI.Samples Window window = NUIApplication.GetDefaultWindow(); root = new View() { - Size2D = new Size2D(1920, 1080), - BackgroundColor = Color.White, + Size = new Size(1920, 1080), + BackgroundColor = new Color(0.7f, 0.9f, 0.8f, 1.0f), + Padding = new Extents(40, 40, 40, 40), + Layout = new LinearLayout() + { + LinearOrientation = LinearLayout.Orientation.Horizontal, + CellPadding = new Size(40, 40), + LinearAlignment = LinearLayout.Alignment.Center, + } }; window.Add(root); ///////////////////////////////////////////////Create by Property////////////////////////////////////////////////////////// + left = new View() + { + Size = new Size(920, 800), + Layout = new LinearLayout() + { + LinearOrientation = LinearLayout.Orientation.Vertical, + }, + }; + + //Create description text. createText[0] = new TextLabel(); createText[0].Text = "Create CheckBox just by properties"; createText[0].TextColor = Color.White; - createText[0].Size2D = new Size2D(500, 100); - createText[0].Position2D = new Position2D(400, 100); - root.Add(createText[0]); + createText[0].Size = new Size(800, 100); + left.Add(createText[0]); + leftbody = new View(); + leftbody.Layout = new GridLayout() { Columns = 4 }; int num = 4; for (int i = 0; i < num; i++) { group[i] = new CheckBoxGroup(); modeText[i] = new TextLabel(); modeText[i].Text = mode[i]; - modeText[i].Size2D = new Size2D(200, 48); - modeText[i].Position2D = new Position2D(300 + 200 * i, 200); - root.Add(modeText[i]); + modeText[i].Size = new Size(200, 48); + modeText[i].HorizontalAlignment = HorizontalAlignment.Center; + modeText[i].VerticalAlignment = VerticalAlignment.Center; + leftbody.Add(modeText[i]); } for (int i = 0; i < num; i++) { + //Create utility radio button. utilityCheckBox[i] = new CheckBox(); - utilityCheckBox[i].Size2D = new Size2D(150, 48); - utilityCheckBox[i].Position2D = new Position2D(300, 300 + i * 100); - utilityCheckBox[i].Style.Icon.Size = new Size(48, 48); - utilityCheckBox[i].Style.Icon.Padding.Start = 0; - utilityCheckBox[i].Style.Icon.Padding.End = 0; - utilityCheckBox[i].Style.Icon.Padding.Top = 0; - utilityCheckBox[i].Style.Icon.Padding.Bottom = 0; - utilityCheckBox[i].Style.Icon.Opacity = new Selector + var utilityStyle = utilityCheckBox[i].Style; + utilityStyle.Icon.Opacity = new Selector { Normal = 1.0f, Selected = 1.0f, Disabled = 0.4f, DisabledSelected = 0.4f }; - utilityCheckBox[i].Style.Icon.BackgroundImage = new Selector + utilityStyle.Icon.BackgroundImage = new Selector { Normal = CommonResource.GetFHResourcePath() + "9. Controller/controller_btn_check_off.png", Selected = CommonResource.GetFHResourcePath() + "9. Controller/controller_btn_check_on.png", Disabled = CommonResource.GetFHResourcePath() + "9. Controller/controller_btn_check_off.png", DisabledSelected = CommonResource.GetFHResourcePath() + "9. Controller/controller_btn_check_on.png", }; - utilityCheckBox[i].Style.Icon.ResourceUrl = new Selector + utilityStyle.Icon.ResourceUrl = new Selector { Normal = "", Selected = CommonResource.GetFHResourcePath() + "9. Controller/controller_btn_check.png", Disabled = "", DisabledSelected = CommonResource.GetFHResourcePath() + "9. Controller/controller_btn_check.png", }; - utilityCheckBox[i].Style.Icon.ImageShadow = new Selector + utilityStyle.Icon.ImageShadow = new Selector { Normal = "", Selected = CommonResource.GetFHResourcePath() + "9. Controller/controller_btn_check_shadow.png", Disabled = "", DisabledSelected = CommonResource.GetFHResourcePath() + "9. Controller/controller_btn_check_shadow.png", }; + utilityCheckBox[i].ApplyStyle(utilityStyle); - //utilityCheckBox[i].Text = "Check" + i; - //utilityCheckBox[i].TextAlignment = HorizontalAlignment.Begin; - //utilityCheckBox[i].PointSize = 12; - //utilityCheckBox[i].TextPaddingLeft = 70; + utilityCheckBox[i].Size = new Size(48, 48); + utilityCheckBox[i].Margin = new Extents(76, 76, 25, 25); + utilityCheckBox[i].ButtonIcon.Size = new Size(48, 48); group[0].Add(utilityCheckBox[i]); - ////// + //Create family radio button. familyCheckBox[i] = new CheckBox(); - familyCheckBox[i].Size2D = new Size2D(48, 48); - familyCheckBox[i].Position2D = new Position2D(500, 300 + i * 100); - familyCheckBox[i].Style.Icon.Size = new Size(48, 48); - familyCheckBox[i].Style.Icon.Padding.Start = 0; - familyCheckBox[i].Style.Icon.Padding.End = 0; - familyCheckBox[i].Style.Icon.Padding.Top = 0; - familyCheckBox[i].Style.Icon.Padding.Bottom = 0; - familyCheckBox[i].Style.Icon.Opacity = new Selector + var familyStyle = familyCheckBox[i].Style; + familyStyle.Icon.Opacity = new Selector { Normal = 1.0f, Selected = 1.0f, Disabled = 0.4f, DisabledSelected = 0.4f }; - familyCheckBox[i].Style.Icon.ResourceUrl = new Selector + familyStyle.Icon.BackgroundImage = ""; + familyStyle.Icon.ResourceUrl = new Selector { Normal = CommonResource.GetFHResourcePath() + "9. Controller/controller_btn_check_off.png", Selected = CommonResource.GetFHResourcePath() + "9. Controller/[Controller] App Primary Color/controller_btn_check_on_24c447.png", Disabled = CommonResource.GetFHResourcePath() + "9. Controller/controller_btn_check_off.png", DisabledSelected = CommonResource.GetFHResourcePath() + "9. Controller/[Controller] App Primary Color/controller_btn_check_on_24c447.png", }; + familyCheckBox[i].ApplyStyle(familyStyle); + familyCheckBox[i].Size = new Size(48, 48); + familyCheckBox[i].Margin = new Extents(76, 76, 25, 25); + familyCheckBox[i].ButtonIcon.Size = new Size(48, 48); group[1].Add(familyCheckBox[i]); - ///////// + //Create food radio button. foodCheckBox[i] = new CheckBox(); - foodCheckBox[i].Size2D = new Size2D(48, 48); - foodCheckBox[i].Position2D = new Position2D(700, 300 + i * 100); - foodCheckBox[i].Style.Icon.Size = new Size(48, 48); - foodCheckBox[i].Style.Icon.Padding.Start = 0; - foodCheckBox[i].Style.Icon.Padding.End = 0; - foodCheckBox[i].Style.Icon.Padding.Top = 0; - foodCheckBox[i].Style.Icon.Padding.Bottom = 0; - foodCheckBox[i].Style.Icon.Opacity = new Selector + var foodStyle = foodCheckBox[i].Style; + foodStyle.Icon.Opacity = new Selector { Normal = 1.0f, Selected = 1.0f, Disabled = 0.4f, DisabledSelected = 0.4f }; - foodCheckBox[i].Style.Icon.ResourceUrl = new Selector + foodStyle.Icon.BackgroundImage = ""; + foodStyle.Icon.ResourceUrl = new Selector { Normal = CommonResource.GetFHResourcePath() + "9. Controller/controller_btn_check_off.png", Selected = CommonResource.GetFHResourcePath() + "9. Controller/[Controller] App Primary Color/controller_btn_check_on_ec7510.png", Disabled = CommonResource.GetFHResourcePath() + "9. Controller/controller_btn_check_off.png", DisabledSelected = CommonResource.GetFHResourcePath() + "9. Controller/[Controller] App Primary Color/controller_btn_check_on_ec7510.png", }; + foodCheckBox[i].ApplyStyle(foodStyle); + foodCheckBox[i].Size = new Size(48, 48); + familyCheckBox[i].Margin = new Extents(76, 76, 25, 25); + foodCheckBox[i].ButtonIcon.Size = new Size(48, 48); group[2].Add(foodCheckBox[i]); - //////// + //Create kitchen radio button. kitchenCheckBox[i] = new CheckBox(); - kitchenCheckBox[i].Size2D = new Size2D(48, 48); - kitchenCheckBox[i].Position2D = new Position2D(900, 300 + i * 100); - kitchenCheckBox[i].Style.Icon.Size = new Size(48, 48); - kitchenCheckBox[i].Style.Icon.Padding.Start = 0; - kitchenCheckBox[i].Style.Icon.Padding.End = 0; - kitchenCheckBox[i].Style.Icon.Padding.Top = 0; - kitchenCheckBox[i].Style.Icon.Padding.Bottom = 0; - - kitchenCheckBox[i].Style.Icon.Opacity = new Selector + var kitchenStyle = kitchenCheckBox[i].Style; + kitchenStyle.Icon.Opacity = new Selector { Normal = 1.0f, Selected = 1.0f, Disabled = 0.4f, DisabledSelected = 0.4f }; - kitchenCheckBox[i].Style.Icon.ResourceUrl = new Selector + kitchenStyle.Icon.BackgroundImage = ""; + kitchenStyle.Icon.ResourceUrl = new Selector { Normal = CommonResource.GetFHResourcePath() + "9. Controller/controller_btn_check_off.png", Selected = CommonResource.GetFHResourcePath() + "9. Controller/[Controller] App Primary Color/controller_btn_check_on_9762d9.png", Disabled = CommonResource.GetFHResourcePath() + "9. Controller/controller_btn_check_off.png", DisabledSelected = CommonResource.GetFHResourcePath() + "9. Controller/[Controller] App Primary Color/controller_btn_check_on_9762d9.png", }; + kitchenCheckBox[i].ApplyStyle(kitchenStyle); + kitchenCheckBox[i].WidthSpecification = 48; + kitchenCheckBox[i].HeightSpecification = 48; + kitchenCheckBox[i].Margin = new Extents(76, 76, 25, 25); + kitchenCheckBox[i].ButtonIcon.Size = new Size(48, 48); group[3].Add(kitchenCheckBox[i]); - root.Add(utilityCheckBox[i]); - root.Add(familyCheckBox[i]); - root.Add(foodCheckBox[i]); - root.Add(kitchenCheckBox[i]); + leftbody.Add(utilityCheckBox[i]); + leftbody.Add(familyCheckBox[i]); + leftbody.Add(foodCheckBox[i]); + leftbody.Add(kitchenCheckBox[i]); } /////////////////////////////////////////////Create by Attributes////////////////////////////////////////////////////////// + right = new View() + { + Size = new Size(920, 800), + Layout = new LinearLayout() + { + LinearOrientation = LinearLayout.Orientation.Vertical, + } + }; + + rightbody = new View(); + rightbody.Layout = new GridLayout() { Columns = 4 }; + + //Create description text. createText[1] = new TextLabel(); - createText[1].Text = "Create CheckBox just by Attributes"; + createText[1].Text = "Create CheckBox just by styles"; createText[1].TextColor = Color.White; - createText[1].Size2D = new Size2D(500, 100); - createText[1].Position2D = new Position2D(1200, 100); - root.Add(createText[1]); + createText[1].Size = new Size(800, 100); + right.Add(createText[1]); for (int i = 0; i < num; i++) { group2[i] = new CheckBoxGroup(); modeText2[i] = new TextLabel(); modeText2[i].Text = mode[i]; - modeText2[i].Size2D = new Size2D(200, 48); - modeText2[i].Position2D = new Position2D(1100 + 200 * i, 200); - root.Add(modeText2[i]); + modeText2[i].Size = new Size(200, 48); + modeText2[i].HorizontalAlignment = HorizontalAlignment.Center; + modeText2[i].VerticalAlignment = VerticalAlignment.Center; + rightbody.Add(modeText2[i]); } - - ButtonStyle utilityAttrs = new ButtonStyle + //Create utility style of radio button. + ButtonStyle utilityStyle2 = new ButtonStyle { Icon = new ImageViewStyle { @@ -240,7 +268,8 @@ namespace Tizen.NUI.Samples }, } }; - ButtonStyle familyAttrs = new ButtonStyle + //Create family style of radio button. + ButtonStyle familyStyle2 = new ButtonStyle { Icon = new ImageViewStyle { @@ -261,7 +290,8 @@ namespace Tizen.NUI.Samples }, } }; - ButtonStyle foodAttrs = new ButtonStyle + //Create food style of radio button. + ButtonStyle foodStyle2 = new ButtonStyle { Icon = new ImageViewStyle { @@ -283,7 +313,8 @@ namespace Tizen.NUI.Samples }, }, }; - ButtonStyle kitchenAttrs = new ButtonStyle + //Create kitchen style of radio button. + ButtonStyle kitchenStyle2 = new ButtonStyle { Icon = new ImageViewStyle { @@ -307,32 +338,37 @@ namespace Tizen.NUI.Samples }; for (int i = 0; i < num; i++) { - utilityCheckBox2[i] = new CheckBox(utilityAttrs); - utilityCheckBox2[i].Size2D = new Size2D(48, 48); - utilityCheckBox2[i].Position2D = new Position2D(1100, 300 + i * 100); + utilityCheckBox2[i] = new CheckBox(utilityStyle2); + utilityCheckBox2[i].Size = new Size(48, 48); + utilityCheckBox2[i].Margin = new Extents(76, 76, 25, 25); group2[0].Add(utilityCheckBox2[i]); - familyCheckBox2[i] = new CheckBox(familyAttrs); - familyCheckBox2[i].Size2D = new Size2D(48, 48); - familyCheckBox2[i].Position2D = new Position2D(1300, 300 + i * 100); + familyCheckBox2[i] = new CheckBox(familyStyle2); + familyCheckBox2[i].Size = new Size(48, 48); + familyCheckBox2[i].Margin = new Extents(76, 76, 25, 25); group2[1].Add(familyCheckBox2[i]); - foodCheckBox2[i] = new CheckBox(foodAttrs); - foodCheckBox2[i].Size2D = new Size2D(48, 48); - foodCheckBox2[i].Position2D = new Position2D(1500, 300 + i * 100); + foodCheckBox2[i] = new CheckBox(foodStyle2); + foodCheckBox2[i].Size = new Size(48, 48); + foodCheckBox2[i].Margin = new Extents(76, 76, 25, 25); group2[2].Add(foodCheckBox2[i]); - kitchenCheckBox2[i] = new CheckBox(kitchenAttrs); - kitchenCheckBox2[i].Size2D = new Size2D(48, 48); - kitchenCheckBox2[i].Position2D = new Position2D(1700, 300 + i * 100); + kitchenCheckBox2[i] = new CheckBox(kitchenStyle2); + kitchenCheckBox2[i].Size = new Size(48, 48); + kitchenCheckBox2[i].Margin = new Extents(76, 76, 25, 25); group2[3].Add(kitchenCheckBox2[i]); - root.Add(utilityCheckBox2[i]); - root.Add(familyCheckBox2[i]); - root.Add(foodCheckBox2[i]); - root.Add(kitchenCheckBox2[i]); + rightbody.Add(utilityCheckBox2[i]); + rightbody.Add(familyCheckBox2[i]); + rightbody.Add(foodCheckBox2[i]); + rightbody.Add(kitchenCheckBox2[i]); } + root.Add(left); + root.Add(right); + left.Add(leftbody); + right.Add(rightbody); + utilityCheckBox[2].IsEnabled = false; familyCheckBox[2].IsEnabled = false; foodCheckBox[2].IsEnabled = false; @@ -369,56 +405,70 @@ namespace Tizen.NUI.Samples int num = 4; for (int i = 0; i < num; i++) { - root.Remove(utilityCheckBox[i]); + leftbody.Remove(utilityCheckBox[i]); utilityCheckBox[i].Dispose(); utilityCheckBox[i] = null; - root.Remove(familyCheckBox[i]); + leftbody.Remove(familyCheckBox[i]); familyCheckBox[i].Dispose(); familyCheckBox[i] = null; - root.Remove(foodCheckBox[i]); + leftbody.Remove(foodCheckBox[i]); foodCheckBox[i].Dispose(); foodCheckBox[i] = null; - root.Remove(kitchenCheckBox[i]); + leftbody.Remove(kitchenCheckBox[i]); kitchenCheckBox[i].Dispose(); kitchenCheckBox[i] = null; - root.Remove(modeText[i]); + leftbody.Remove(modeText[i]); modeText[i].Dispose(); modeText[i] = null; - root.Remove(utilityCheckBox2[i]); + rightbody.Remove(utilityCheckBox2[i]); utilityCheckBox2[i].Dispose(); utilityCheckBox2[i] = null; - root.Remove(familyCheckBox2[i]); + rightbody.Remove(familyCheckBox2[i]); familyCheckBox2[i].Dispose(); familyCheckBox2[i] = null; - root.Remove(foodCheckBox2[i]); + rightbody.Remove(foodCheckBox2[i]); foodCheckBox2[i].Dispose(); foodCheckBox2[i] = null; - root.Remove(kitchenCheckBox2[i]); + rightbody.Remove(kitchenCheckBox2[i]); kitchenCheckBox2[i].Dispose(); kitchenCheckBox2[i] = null; - root.Remove(modeText2[i]); + rightbody.Remove(modeText2[i]); modeText2[i].Dispose(); modeText2[i] = null; } - root.Remove(createText[0]); + left.Remove(createText[0]); createText[0].Dispose(); createText[0] = null; - root.Remove(createText[1]); + left.Remove(leftbody); + leftbody.Dispose(); + leftbody = null; + right.Remove(createText[1]); createText[1].Dispose(); createText[1] = null; + right.Remove(rightbody); + rightbody.Dispose(); + rightbody = null; + + root.Remove(left); + left.Dispose(); + left = null; + root.Remove(right); + right.Dispose(); + right = null; NUIApplication.GetDefaultWindow().Remove(root); root.Dispose(); + root = null; } } } diff --git a/test/Tizen.NUI.Samples/Tizen.NUI.Samples/Samples/ContactCard/ContactCardLayouter.cs b/test/Tizen.NUI.Samples/Tizen.NUI.Samples/Samples/ContactCard/ContactCardLayouter.cs index 0de4306..dd2425c 100755 --- a/test/Tizen.NUI.Samples/Tizen.NUI.Samples/Samples/ContactCard/ContactCardLayouter.cs +++ b/test/Tizen.NUI.Samples/Tizen.NUI.Samples/Samples/ContactCard/ContactCardLayouter.cs @@ -41,6 +41,19 @@ namespace Tizen.NUI.Samples Initialize(); } + public void Clear() + { + if (null != rootView) + { + if (null != rootView.GetParent()) + { + rootView.GetParent().Remove(rootView); + } + rootView.Dispose(); + rootView = null; + } + } + private void Initialize() { mContactCardLayoutInfo = new ContactCardLayoutInfo(); diff --git a/test/Tizen.NUI.Samples/Tizen.NUI.Samples/Samples/ContactCard/ContactCardsSample.cs b/test/Tizen.NUI.Samples/Tizen.NUI.Samples/Samples/ContactCard/ContactCardsSample.cs index 872c35d..b82af66 100755 --- a/test/Tizen.NUI.Samples/Tizen.NUI.Samples/Samples/ContactCard/ContactCardsSample.cs +++ b/test/Tizen.NUI.Samples/Tizen.NUI.Samples/Samples/ContactCard/ContactCardsSample.cs @@ -32,7 +32,10 @@ namespace Tizen.NUI.Samples public void Deactivate() { - + if (null != mContactCardLayouter) + { + mContactCardLayouter.Clear(); + } } //private void OnKeyEvent(object sender, Window.KeyEventArgs e) diff --git a/test/Tizen.NUI.Samples/Tizen.NUI.Samples/Samples/ContactCard/ContactData.cs b/test/Tizen.NUI.Samples/Tizen.NUI.Samples/Samples/ContactCard/ContactData.cs index 7dea8ea..19b8011 100755 --- a/test/Tizen.NUI.Samples/Tizen.NUI.Samples/Samples/ContactCard/ContactData.cs +++ b/test/Tizen.NUI.Samples/Tizen.NUI.Samples/Samples/ContactCard/ContactData.cs @@ -9,7 +9,7 @@ namespace Tizen.NUI.Samples public class ContactData { public const int itemSize = 15; - public static readonly string floder = CommonResource.GetFHResourcePath() + "ContactCard/"; + public static readonly string floder = CommonResource.GetDaliResourcePath() + "ContactCard/"; public class Item { public string name; diff --git a/test/Tizen.NUI.Samples/Tizen.NUI.Samples/Samples/ContactCard/MaskedImage.cs b/test/Tizen.NUI.Samples/Tizen.NUI.Samples/Samples/ContactCard/MaskedImage.cs index 672e9cf..15a1aaf 100755 --- a/test/Tizen.NUI.Samples/Tizen.NUI.Samples/Samples/ContactCard/MaskedImage.cs +++ b/test/Tizen.NUI.Samples/Tizen.NUI.Samples/Samples/ContactCard/MaskedImage.cs @@ -10,7 +10,7 @@ namespace Tizen.NUI.Samples { public class MaskedImage { - private static readonly string IMAGE_MASK = CommonResource.GetFHResourcePath() + "ContactCard/contact-cards-mask.png"; + private static readonly string IMAGE_MASK = CommonResource.GetDaliResourcePath() + "ContactCard/contact-cards-mask.png"; public static View Create(string imagePath) { diff --git a/test/Tizen.NUI.Samples/Tizen.NUI.Samples/Samples/CubeTransitionEffectSample.cs b/test/Tizen.NUI.Samples/Tizen.NUI.Samples/Samples/CubeTransitionEffectSample.cs index e0a9458..0a1df5a 100755 --- a/test/Tizen.NUI.Samples/Tizen.NUI.Samples/Samples/CubeTransitionEffectSample.cs +++ b/test/Tizen.NUI.Samples/Tizen.NUI.Samples/Samples/CubeTransitionEffectSample.cs @@ -1,6 +1,6 @@  using Tizen.NUI.BaseComponents; -using Tizen.NUI.UIComponents; +using Tizen.NUI.Components; namespace Tizen.NUI.Samples { @@ -73,8 +73,10 @@ namespace Tizen.NUI.Samples private TextLabel mTitle; private Layer content_layer; private View mContent; - private ToggleButton toggle_button; - private PushButton mSlideshowButton; + private View radiosParent; + private RadioButtonGroup toggle; + private RadioButton[] radios = new RadioButton[3]; + private Button mSlideshowButton; private Texture mCurrentTexture; private Texture mNextTexture; @@ -119,43 +121,50 @@ namespace Tizen.NUI.Samples tool_bar.Add(mTitle); // push button of tool bar - mSlideshowButton = new PushButton(); - PropertyMap unselected_bg_map = new PropertyMap(); - unselected_bg_map.Add(Visual.Property.Type, new PropertyValue((int)Visual.Type.Image)); - unselected_bg_map.Add(ImageVisualProperty.URL, new PropertyValue(SLIDE_SHOW_START_ICON)); - mSlideshowButton.UnselectedBackgroundVisual = unselected_bg_map; - - PropertyMap selected_bg_map = new PropertyMap(); - selected_bg_map.Add(Visual.Property.Type, new PropertyValue((int)Visual.Type.Image)); - selected_bg_map.Add(ImageVisualProperty.URL, new PropertyValue(SLIDE_SHOW_START_ICON_SELECTED)); - mSlideshowButton.SelectedBackgroundVisual = selected_bg_map; - - mSlideshowButton.ParentOrigin = ParentOrigin.TopLeft; - mSlideshowButton.PivotPoint = PivotPoint.TopLeft; - mSlideshowButton.Position2D = new Position2D(800, 32); - mSlideshowButton.Clicked += OnPushButtonClicked; + var style = new ButtonStyle(); + style.Icon.ResourceUrl = new Selector() { Normal = SLIDE_SHOW_START_ICON, Pressed = SLIDE_SHOW_START_ICON_SELECTED }; + style.Position = new Position(800, 32); + style.ParentOrigin = ParentOrigin.TopLeft; + style.PivotPoint = PivotPoint.TopLeft; + style.Size = new Size(58, 58); + mSlideshowButton = new Button(style); + mSlideshowButton.ClickEvent += OnPushButtonClicked; mSlideshowButton.RaiseToTop(); tool_bar.Add(mSlideshowButton); // toggle button of tool bar - toggle_button = new ToggleButton(); - PropertyArray array = new PropertyArray(); - array.Add(new PropertyValue(EFFECT_WAVE_IMAGE)); - array.Add(new PropertyValue(EFFECT_CROSS_IMAGE)); - array.Add(new PropertyValue(EFFECT_FOLD_IMAGE)); - toggle_button.StateVisuals = array; - - toggle_button.ParentOrigin = ParentOrigin.TopLeft; - toggle_button.PivotPoint = PivotPoint.TopLeft; - toggle_button.CellHorizontalAlignment = HorizontalAlignmentType.Right; - toggle_button.Position2D = new Position2D(900, 42); - - toggle_button.Clicked += OnToggleButtonClicked; - - tool_bar.Add(toggle_button); - + radiosParent = new View(); + radiosParent.Size = new Size(200, 40); + radiosParent.Position = new Position(900, 42); + var layout = new LinearLayout(); + layout.LinearOrientation = LinearLayout.Orientation.Horizontal; + layout.CellPadding = new Size(30, 30); + radiosParent.Layout = layout; + tool_bar.Add(radiosParent); + + toggle = new RadioButtonGroup(); + for (int i = 0; i < 3; i++) + { + radios[i] = new RadioButton(); + radios[i].Size = new Size(37, 34); + toggle.Add(radios[i]); + radiosParent.Add(radios[i]); + } + var radioStyle = radios[0].Style; + radioStyle.Icon.BackgroundImage = new Selector() { Normal = EFFECT_WAVE_IMAGE, Selected = EFFECT_WAVE_IMAGE_SELECTED }; + radios[0].ApplyStyle(radioStyle); + radioStyle = radios[1].Style; + radioStyle.Icon.BackgroundImage = new Selector() { Normal = EFFECT_CROSS_IMAGE, Selected = EFFECT_CROSS_IMAGE_SELECTED }; + radios[1].ApplyStyle(radioStyle); + radioStyle = radios[2].Style; + radioStyle.Icon.BackgroundImage = new Selector() { Normal = EFFECT_FOLD_IMAGE, Selected = EFFECT_FOLD_IMAGE_SELECTED }; + radios[2].ApplyStyle(radioStyle); + radios[0].SelectedEvent += OnWaveClicked; + radios[1].SelectedEvent += OnCrossClicked; + radios[2].SelectedEvent += OnFoldClicked; + radios[0].IsSelected = true; // load image mCurrentTexture = LoadStageFillingTexture(IMAGES[mIndex]); @@ -231,17 +240,28 @@ namespace Tizen.NUI.Samples if (mSlideshowButton) { tool_bar.Remove(mSlideshowButton); - mSlideshowButton.Clicked -= OnPushButtonClicked; + mSlideshowButton.ClickEvent -= OnPushButtonClicked; mSlideshowButton.Dispose(); mSlideshowButton = null; } - if (toggle_button) + if (radiosParent) { - tool_bar.Remove(toggle_button); - toggle_button.Clicked -= OnToggleButtonClicked; - toggle_button.Dispose(); - toggle_button = null; + for (int i = 0; i < 3; i++) + { + if (radios[i]) + { + if ( 0 == i) radios[0].SelectedEvent -= OnWaveClicked; + if ( 1 == i) radios[1].SelectedEvent -= OnCrossClicked; + if ( 2 == i) radios[2].SelectedEvent -= OnFoldClicked; + radiosParent.Remove(radios[i]); + radios[i].Dispose(); + radios[i] = null; + } + } + tool_bar.Remove(radiosParent); + radiosParent.Dispose(); + radiosParent = null; } if (tool_bar) @@ -405,22 +425,52 @@ namespace Tizen.NUI.Samples return true; } - private bool OnPushButtonClicked(object sender, global::System.EventArgs args) + private void OnWaveClicked(object sender, global::System.EventArgs args) + { + mContent.Remove(mCurrentEffect); + mCurrentEffect = mCubeWaveEffect; + mTitle.Text = APPLICATION_TITLE_WAVE; + mContent.Add(mCurrentEffect); + + // Set the current image to cube transition effect + // only need to set at beginning or change from another effect + mCurrentEffect.SetCurrentTexture(mCurrentTexture); + } + + private void OnCrossClicked(object sender, global::System.EventArgs args) + { + mContent.Remove(mCurrentEffect); + mCurrentEffect = mCubeCrossEffect; + mTitle.Text = APPLICATION_TITLE_CROSS; + mContent.Add(mCurrentEffect); + + // Set the current image to cube transition effect + // only need to set at beginning or change from another effect + mCurrentEffect.SetCurrentTexture(mCurrentTexture); + } + + private void OnFoldClicked(object sender, global::System.EventArgs args) + { + mContent.Remove(mCurrentEffect); + mCurrentEffect = mCubeFoldEffect; + mTitle.Text = APPLICATION_TITLE_FOLD; + mContent.Add(mCurrentEffect); + + // Set the current image to cube transition effect + // only need to set at beginning or change from another effect + mCurrentEffect.SetCurrentTexture(mCurrentTexture); + } + + private void OnPushButtonClicked(object sender, global::System.EventArgs args) { mSlideshow = !mSlideshow; if (mSlideshow) { mPanGestureDetector.Detach(mContent); - PropertyMap unselected_bg_map = new PropertyMap(); - unselected_bg_map.Add(Visual.Property.Type, new PropertyValue((int)Visual.Type.Image)); - unselected_bg_map.Add(ImageVisualProperty.URL, new PropertyValue(SLIDE_SHOW_STOP_ICON)); - mSlideshowButton.UnselectedBackgroundVisual = unselected_bg_map; - - PropertyMap selected_bg_map = new PropertyMap(); - selected_bg_map.Add(Visual.Property.Type, new PropertyValue((int)Visual.Type.Image)); - selected_bg_map.Add(ImageVisualProperty.URL, new PropertyValue(SLIDE_SHOW_STOP_ICON_SELECTED)); - mSlideshowButton.SelectedBackgroundVisual = selected_bg_map; + var style = mSlideshowButton.Style; + style.Icon.ResourceUrl = new Selector() { Normal = SLIDE_SHOW_STOP_ICON, Pressed = SLIDE_SHOW_STOP_ICON_SELECTED }; + mSlideshowButton.ApplyStyle(style); mPanPosition = new Vector2(NUIApplication.GetDefaultWindow().WindowSize.Width, NUIApplication.GetDefaultWindow().WindowSize.Width * 0.5f); mPanDisplacement = new Vector2(-10.0f, 0.0f); @@ -430,20 +480,11 @@ namespace Tizen.NUI.Samples else { mPanGestureDetector.Attach(mContent); - - PropertyMap unselected_bg_map = new PropertyMap(); - unselected_bg_map.Add(Visual.Property.Type, new PropertyValue((int)Visual.Type.Image)); - unselected_bg_map.Add(ImageVisualProperty.URL, new PropertyValue(SLIDE_SHOW_START_ICON)); - mSlideshowButton.UnselectedBackgroundVisual = unselected_bg_map; - - PropertyMap selected_bg_map = new PropertyMap(); - selected_bg_map.Add(Visual.Property.Type, new PropertyValue((int)Visual.Type.Image)); - selected_bg_map.Add(ImageVisualProperty.URL, new PropertyValue(SLIDE_SHOW_START_ICON_SELECTED)); - mSlideshowButton.SelectedBackgroundVisual = selected_bg_map; - + var style = mSlideshowButton.Style; + style.Icon.ResourceUrl = new Selector() { Normal = SLIDE_SHOW_START_ICON, Pressed = SLIDE_SHOW_START_ICON_SELECTED }; + mSlideshowButton.ApplyStyle(style); mViewTimer.Stop(); } - return true; } } } diff --git a/test/Tizen.NUI.Samples/Tizen.NUI.Samples/Samples/DaliDemo/DaliDemo.cs b/test/Tizen.NUI.Samples/Tizen.NUI.Samples/Samples/DaliDemo/DaliDemo.cs index 72f26fc..e2d2cc8 100755 --- a/test/Tizen.NUI.Samples/Tizen.NUI.Samples/Samples/DaliDemo/DaliDemo.cs +++ b/test/Tizen.NUI.Samples/Tizen.NUI.Samples/Samples/DaliDemo/DaliDemo.cs @@ -92,6 +92,7 @@ namespace Tizen.NUI.Samples protected override void OnCreate() { base.OnCreate(); + StyleManager.Get().ApplyTheme(Tizen.Applications.Application.Current.DirectoryInfo.Resource + "style/demo-theme.json"); CreateDaliDemo(); NUIApplication.GetDefaultWindow().KeyEvent += Instance_KeyEvent; diff --git a/test/Tizen.NUI.Samples/Tizen.NUI.Samples/Samples/DropDownSample.cs b/test/Tizen.NUI.Samples/Tizen.NUI.Samples/Samples/DropDownSample.cs index 84bfa56..c4b97cb 100755 --- a/test/Tizen.NUI.Samples/Tizen.NUI.Samples/Samples/DropDownSample.cs +++ b/test/Tizen.NUI.Samples/Tizen.NUI.Samples/Samples/DropDownSample.cs @@ -7,6 +7,8 @@ namespace Tizen.NUI.Samples public class DropDownSample : IExample { private View root; + private View parent1; + private View parent2; private TextLabel[] createText = new TextLabel[2]; @@ -33,46 +35,71 @@ namespace Tizen.NUI.Samples { Window window = NUIApplication.GetDefaultWindow(); + //Create root view with linear layout. root = new View() { - Size2D = new Size2D(1920, 1080), - BackgroundColor = Color.White, + Size = new Size(1920, 1080), + BackgroundColor = new Color(0.7f, 0.9f, 0.8f, 1.0f), + Layout = new LinearLayout() + { + LinearOrientation = LinearLayout.Orientation.Horizontal, + CellPadding = new Size(50, 50), + LinearAlignment = LinearLayout.Alignment.Center, + } }; window.Add(root); ///////////////////////////////////////////////Create by Property////////////////////////////////////////////////////////// + parent1 = new View() + { + Size = new Size(900, 800), + Layout = new LinearLayout() + { + LinearOrientation = LinearLayout.Orientation.Vertical, + CellPadding = new Size(50, 50), + LinearAlignment = LinearLayout.Alignment.Top, + } + }; + + root.Add(parent1); + // Create a description text. createText[0] = new TextLabel(); createText[0].Text = "Create DropDown just by properties"; - createText[0].Size2D = new Size2D(450, 100); - createText[0].Position2D = new Position2D(200, 100); + createText[0].Size = new Size(800, 100); createText[0].MultiLine = true; - root.Add(createText[0]); + parent1.Add(createText[0]); + //Create a dropdown by property. #region CreateByProperty dropDown = new DropDown(); - dropDown.Size2D = new Size2D(900, 108); - dropDown.Position2D = new Position2D(50, 300); - dropDown.Style.HeaderText.Text = "TitleArea"; - dropDown.Style.HeaderText.TextColor = new Color(0, 0, 0, 1); - dropDown.Style.HeaderText.PointSize = 28; - dropDown.Style.HeaderText.FontFamily = "SamsungOneUI 500C"; - dropDown.Style.Button.Text.Text = "DropDown Text"; - dropDown.Style.Button.Text.TextColor = new Color(0, 0, 0, 1); - dropDown.Style.Button.Text.PointSize = 20; - dropDown.Style.Button.Text.FontFamily = "SamsungOneUI 500"; - dropDown.Style.Button.Icon.ResourceUrl = CommonResource.GetFHResourcePath() + "6. List/list_ic_dropdown.png"; - dropDown.Style.Button.Icon.Size = new Size(48, 48); - dropDown.Style.Button.IconRelativeOrientation = Button.IconOrientation.Right; - dropDown.Style.Button.PositionX = 56; + var style = dropDown.Style; + style.Button.BackgroundImage = ""; + style.Button.Icon.ResourceUrl = CommonResource.GetFHResourcePath() + "6. List/list_ic_dropdown.png"; + style.Button.Text.PointSize = 20; + style.Button.Text.FontFamily = "SamsungOneUI 500"; + style.Button.Text.TextColor = new Color(0, 0, 0, 1); + dropDown.ApplyStyle(style); + dropDown.Size = new Size(900, 108); + dropDown.HeaderText.Text = "TitleArea"; + dropDown.HeaderText.TextColor = new Color(0, 0, 0, 1); + dropDown.HeaderText.PointSize = 28; + dropDown.HeaderText.FontFamily = "SamsungOneUI 500C"; + dropDown.HeaderText.PositionX = 50; + dropDown.Button.ButtonText.Text = "DropDown Text"; + dropDown.Button.ButtonIcon.Size = new Size(48, 48); + dropDown.Button.IconRelativeOrientation = Button.IconOrientation.Right; + dropDown.Button.ParentOrigin = ParentOrigin.CenterLeft; + dropDown.Button.PivotPoint = PivotPoint.CenterLeft; + dropDown.Button.PositionX = 56; dropDown.SpaceBetweenButtonTextAndIcon = 8; - dropDown.Style.ListBackgroundImage.ResourceUrl = CommonResource.GetFHResourcePath() + "10. Drop Down/dropdown_bg.png"; - dropDown.Style.ListBackgroundImage.Border = new Rectangle(51, 51, 51, 51); - dropDown.Style.ListBackgroundImage.Size = new Size(360, 500); + dropDown.ListBackgroundImage.ResourceUrl = CommonResource.GetFHResourcePath() + "10. Drop Down/dropdown_bg.png"; + dropDown.ListBackgroundImage.Border = new Rectangle(51, 51, 51, 51); + dropDown.ListBackgroundImage.Size = new Size(360, 500); dropDown.ListMargin.Start = 20; dropDown.ListMargin.Top = 20; dropDown.ListPadding = new Extents(4, 4, 4, 4); - root.Add(dropDown); - + dropDown.BackgroundColor = new Color(1, 1, 1, 1); + parent1.Add(dropDown); for (int i = 0; i < 8; i++) { DropDown.DropDownDataItem item = new DropDown.DropDownDataItem(); @@ -93,46 +120,42 @@ namespace Tizen.NUI.Samples } dropDown.SelectedItemIndex = 3; - //dropDown.DeleteItem(1); - //DropDown.DropDownItemData insertItem = new DropDown.DropDownItemData(); - //insertItem.Size2D = new Size2D(360, 96); - //insertItem.BackgroundColorSelector = new Selector - //{ - // Pressed = new Color(0, 0, 0, 0.4f), - // Other = new Color(1, 1, 1, 0), - //}; - //insertItem.Text = "Insert Normal list "; - //insertItem.PointSize = 18; - //insertItem.FontFamily = "SamsungOne 500"; - //insertItem.TextPosition2D = new Position2D(28, 0); - //insertItem.CheckImageSize = new Size2D(40, 40); - //insertItem.CheckImageResourceUrl = CommonReosurce.GetFHResourcePath() + "10. Drop Down/dropdown_checkbox_on.png"; - //insertItem.CheckImageRightSpace = 16; - //dropDown.InsertItem(insertItem, 1); ////////Attach scrollbar/////////// scrollBar = new ScrollBar(); scrollBar.Direction = ScrollBar.DirectionType.Vertical; - scrollBar.Position2D = new Position2D(394, 2); - scrollBar.Size2D = new Size2D(4, 446); - scrollBar.Style.Track.BackgroundColor = Color.Green; - scrollBar.Style.Thumb.Size = new Size(4, 30); - scrollBar.Style.Thumb.BackgroundColor = Color.Yellow; - scrollBar.Style.Track.ResourceUrl = CommonResource.GetTVResourcePath() + "component/c_progressbar/c_progressbar_white_buffering.png"; + scrollBar.Size = new Size(4, 446); + scrollBar.TrackColor = Color.Green; + scrollBar.ThumbSize = new Size(4, 30); + scrollBar.ThumbColor = Color.Yellow; + scrollBar.TrackImageURL = CommonResource.GetTVResourcePath() + "component/c_progressbar/c_progressbar_white_buffering.png"; dropDown.AttachScrollBar(scrollBar); #endregion ///////////////////////////////////////////////Create by Attributes////////////////////////////////////////////////////////// + parent2 = new View() + { + Size = new Size(900, 800), + Layout = new LinearLayout() + { + LinearOrientation = LinearLayout.Orientation.Vertical, + CellPadding = new Size(50, 50), + LinearAlignment = LinearLayout.Alignment.Top, + } + }; + root.Add(parent2); + + // Create a description text. createText[1] = new TextLabel(); createText[1].Text = "Create DropDown just by Attributes"; - createText[1].Size2D = new Size2D(450, 100); - createText[1].Position2D = new Position2D(1000, 100); + createText[1].Size = new Size(800, 100); createText[1].MultiLine = true; - root.Add(createText[1]); + parent2.Add(createText[1]); - #region CreateByAttributes + //Create a dropdown by style. + #region CreateByStyle - DropDownStyle attrs = new DropDownStyle + DropDownStyle dropDownStyle = new DropDownStyle { HeaderText = new TextLabelStyle { @@ -140,6 +163,7 @@ namespace Tizen.NUI.Samples PointSize = new Selector { All = 28 }, TextColor = new Selector { All = new Color(0, 0, 0, 1) }, FontFamily = "SamsungOneUI 500C", + PositionX = 50, }, Button = new ButtonStyle @@ -158,6 +182,7 @@ namespace Tizen.NUI.Samples }, IconRelativeOrientation = Button.IconOrientation.Right, PositionX = 56, + BackgroundImage = "", }, ListBackgroundImage = new ImageViewStyle { @@ -171,12 +196,11 @@ namespace Tizen.NUI.Samples ListPadding = new Extents(4, 4, 4, 4), }; - dropDown2 = new DropDown(attrs); - dropDown2.Size2D = new Size2D(900, 108); - dropDown2.Position2D = new Position2D(1000, 300); - root.Add(dropDown2); + dropDown2 = new DropDown(dropDownStyle); + dropDown2.Size = new Size(900, 108); + parent2.Add(dropDown2); - DropDownItemStyle itemAttrs = new DropDownItemStyle + DropDownItemStyle itemStyle = new DropDownItemStyle { BackgroundColor = new Selector { @@ -199,7 +223,7 @@ namespace Tizen.NUI.Samples for (int i = 0; i < 8; i++) { - DropDown.DropDownDataItem item = new DropDown.DropDownDataItem(itemAttrs); + DropDown.DropDownDataItem item = new DropDown.DropDownDataItem(itemStyle); item.Size = new Size(360, 96); item.Text = "Normal list " + i; dropDown2.AddItem(item); @@ -209,15 +233,17 @@ namespace Tizen.NUI.Samples ////////Attach scrollbar/////////// scrollBar2 = new ScrollBar(); scrollBar2.Direction = ScrollBar.DirectionType.Vertical; - scrollBar2.Position2D = new Position2D(394, 2); - scrollBar2.Size2D = new Size2D(4, 446); - scrollBar2.Style.Track.BackgroundColor = Color.Green; - scrollBar2.Style.Thumb.Size = new Size(4, 30); - scrollBar2.Style.Thumb.BackgroundColor = Color.Yellow; - scrollBar2.Style.Track.ResourceUrl = CommonResource.GetTVResourcePath() + "component/c_progressbar/c_progressbar_white_buffering.png"; + scrollBar2.Size = new Size(4, 446); + scrollBar2.TrackColor = Color.Green; + scrollBar2.ThumbSize = new Size(4, 30); + scrollBar2.ThumbColor = Color.Yellow; + scrollBar2.TrackImageURL = CommonResource.GetTVResourcePath() + "component/c_progressbar/c_progressbar_white_buffering.png"; dropDown2.AttachScrollBar(scrollBar2); #endregion + //Add all views into root view. + root.Add(parent1); + root.Add(parent2); } public void Deactivate() @@ -233,7 +259,7 @@ namespace Tizen.NUI.Samples scrollBar = null; } - root.Remove(dropDown); + parent1.Remove(dropDown); dropDown.Dispose(); dropDown = null; } @@ -246,24 +272,31 @@ namespace Tizen.NUI.Samples scrollBar2 = null; } - root.Remove(dropDown2); + parent2.Remove(dropDown2); dropDown2.Dispose(); dropDown2 = null; } if (createText[0] != null) { - root.Remove(createText[0]); + parent1.Remove(createText[0]); createText[0].Dispose(); createText[0] = null; } if (createText[1] != null) { - root.Remove(createText[1]); + parent2.Remove(createText[1]); createText[1].Dispose(); createText[1] = null; } + root.Remove(parent1); + parent1.Dispose(); + parent1 = null; + root.Remove(parent2); + parent2.Dispose(); + parent2 = null; + NUIApplication.GetDefaultWindow().Remove(root); root.Dispose(); root = null; diff --git a/test/Tizen.NUI.Samples/Tizen.NUI.Samples/Samples/FlexibleViewSample.cs b/test/Tizen.NUI.Samples/Tizen.NUI.Samples/Samples/FlexibleViewSample.cs index a159724..2c437c3 100755 --- a/test/Tizen.NUI.Samples/Tizen.NUI.Samples/Samples/FlexibleViewSample.cs +++ b/test/Tizen.NUI.Samples/Tizen.NUI.Samples/Samples/FlexibleViewSample.cs @@ -150,7 +150,6 @@ namespace Tizen.NUI.Samples { //Console.WriteLine($" --Detached: {holder.AdapterPosition}"); } - } public class FlexibleViewSample : IExample @@ -162,14 +161,36 @@ namespace Tizen.NUI.Samples private ScrollBar scrollBar1; private ScrollBar scrollBar2; + private View root, parent; + public void Activate() { Window window = NUIApplication.GetDefaultWindow(); + root = new View() + { + Size = new Size(1920, 1080), + BackgroundColor = new Color(0.7f, 0.9f, 0.8f, 1.0f), + }; + window.Add(root); + parent = new View() + { + Position = new Position(300, 300), + Size = new Size(1150, 450) + }; + parent.Layout = new LinearLayout() + { + LinearOrientation = LinearLayout.Orientation.Horizontal, + LinearAlignment = LinearLayout.Alignment.Bottom, + CellPadding = new Size(50, 50) + }; + root.Add(parent); + + // Create vertical flexibleView flexibleView1 = new FlexibleView(); - flexibleView1.Name = "RecyclerView"; - flexibleView1.Position2D = new Position2D(500, 200); - flexibleView1.Size2D = new Size2D(400, 450); + flexibleView1.Name = "RecyclerView1"; + flexibleView1.WidthSpecification = 400; + flexibleView1.HeightSpecification = 450; flexibleView1.Padding = new Extents(10, 10, 10, 10); flexibleView1.BackgroundColor = new Color(0.0f, 0.0f, 0.0f, 0.4f); @@ -182,12 +203,11 @@ namespace Tizen.NUI.Samples flexibleView1.SetAdapter(adapter); LinearLayoutManager layoutManager1 = new LinearLayoutManager(LinearLayoutManager.VERTICAL); - //GridLayoutManager layoutManager1 = new GridLayoutManager(3, LinearLayoutManager.VERTICAL); flexibleView1.SetLayoutManager(layoutManager1); flexibleView1.FocusedItemIndex = 0; - window.Add(flexibleView1); + parent.Add(flexibleView1); flexibleView1.Focusable = true; @@ -197,19 +217,20 @@ namespace Tizen.NUI.Samples scrollBar1 = new ScrollBar(); scrollBar1.Direction = ScrollBar.DirectionType.Vertical; - scrollBar1.Position2D = new Position2D(394, 2); - scrollBar1.Size2D = new Size2D(4, 446); - scrollBar1.Style.Track.BackgroundColor = Color.Green; - scrollBar1.Style.Thumb.Size = new Size(4, 30); - scrollBar1.Style.Thumb.BackgroundColor = Color.Yellow; - scrollBar1.Style.Track.ResourceUrl = CommonResource.GetTVResourcePath() + "component/c_progressbar/c_progressbar_white_buffering.png"; + scrollBar1.Position = new Position(394, 2); + scrollBar1.WidthSpecification = 4; + scrollBar1.HeightSpecification = 446; + scrollBar1.TrackColor = Color.Green; + scrollBar1.ThumbSize = new Size(4, 30); + scrollBar1.ThumbColor = Color.Yellow; + scrollBar1.TrackImageURL = CommonResource.GetTVResourcePath() + "component/c_progressbar/c_progressbar_white_buffering.png"; flexibleView1.AttachScrollBar(scrollBar1); - + // Create horizontal flexibleView flexibleView2 = new FlexibleView(); - flexibleView2.Name = "RecyclerView"; - flexibleView2.Position2D = new Position2D(500, 800); - flexibleView2.Size2D = new Size2D(700, 200); + flexibleView2.Name = "RecyclerView2"; + flexibleView2.WidthSpecification = 700; + flexibleView2.HeightSpecification = 200; flexibleView2.Padding = new Extents(10, 10, 10, 10); flexibleView2.BackgroundColor = new Color(0.0f, 0.0f, 0.0f, 0.4f); @@ -220,7 +241,7 @@ namespace Tizen.NUI.Samples flexibleView2.FocusedItemIndex = 0; - window.Add(flexibleView2); + parent.Add(flexibleView2); flexibleView2.Focusable = true; @@ -229,16 +250,31 @@ namespace Tizen.NUI.Samples flexibleView2.FocusLost += FlexibleView_FocusLost; scrollBar2 = new ScrollBar(); - scrollBar2.Position2D = new Position2D(2, 194); - scrollBar2.Size2D = new Size2D(696, 4); - scrollBar2.Style.Track.BackgroundColor = Color.Green; - scrollBar2.Style.Thumb.Size = new Size(30, 4); - scrollBar2.Style.Thumb.BackgroundColor = Color.Yellow; - scrollBar2.Style.Track.ResourceUrl = CommonResource.GetTVResourcePath() + "component/c_progressbar/c_progressbar_white_buffering.png"; + scrollBar2.Direction = ScrollBar.DirectionType.Horizontal; + scrollBar2.Position = new Position(2, 194); + scrollBar2.WidthSpecification = 696; + scrollBar2.HeightSpecification = 4; + scrollBar2.TrackColor = Color.Green; + scrollBar2.ThumbSize = new Size(30, 4); + scrollBar2.ThumbColor = Color.Yellow; + scrollBar2.TrackImageURL = CommonResource.GetTVResourcePath() + "component/c_progressbar/c_progressbar_white_buffering.png"; flexibleView2.AttachScrollBar(scrollBar2); - FocusManager.Instance.SetCurrentFocusView(flexibleView1); + FocusManager.Instance.PreFocusChange += onPreFocusChange; + } + + private View onPreFocusChange(object sender, NUI.FocusManager.PreFocusChangeEventArgs e) + { + if (e.CurrentView != null && e.CurrentView.Name == "RecyclerView1" && e.Direction == View.FocusDirection.Right && e.ProposedView == null) + { + return flexibleView2; + } + if (e.CurrentView != null && e.CurrentView.Name == "RecyclerView2" && e.Direction == View.FocusDirection.Left && e.ProposedView == null) + { + return flexibleView1; + } + return e.CurrentView; } private void FlexibleView_FocusLost(object sender, EventArgs e) @@ -316,17 +352,30 @@ namespace Tizen.NUI.Samples public void Deactivate() { + FocusManager.Instance.PreFocusChange -= onPreFocusChange; + FocusManager.Instance.ClearFocus(); + flexibleView1.DetachScrollBar(); scrollBar1.Dispose(); + scrollBar1 = null; flexibleView2.DetachScrollBar(); scrollBar2.Dispose(); + scrollBar2 = null; - Window window = NUIApplication.GetDefaultWindow(); - window.Remove(flexibleView1); + parent.Remove(flexibleView1); flexibleView1.Dispose(); - window.Remove(flexibleView2); + flexibleView1 = null; + parent.Remove(flexibleView2); flexibleView2.Dispose(); + flexibleView2 = null; + + root.Remove(parent); + parent.Dispose(); + parent = null; + NUIApplication.GetDefaultWindow().Remove(root); + root.Dispose(); + root = null; } } } diff --git a/test/Tizen.NUI.Samples/Tizen.NUI.Samples/Samples/ItemViewDemo/ItemViewSample.cs b/test/Tizen.NUI.Samples/Tizen.NUI.Samples/Samples/ItemViewDemo/ItemViewSample.cs index 4091762..5fc9425 100755 --- a/test/Tizen.NUI.Samples/Tizen.NUI.Samples/Samples/ItemViewDemo/ItemViewSample.cs +++ b/test/Tizen.NUI.Samples/Tizen.NUI.Samples/Samples/ItemViewDemo/ItemViewSample.cs @@ -1,6 +1,6 @@ using System; using Tizen.NUI.BaseComponents; -using Tizen.NUI.UIComponents; +using Tizen.NUI.Components; namespace Tizen.NUI.Samples { @@ -39,7 +39,6 @@ namespace Tizen.NUI.Samples private string DEPTH_LAYOUT_IMAGE = CommonResource.GetDaliResourcePath() + "ItemViewDemo/icon-item-view-layout-depth.png"; private string DEPTH_LAYOUT_IMAGE_SELECTED = CommonResource.GetDaliResourcePath() + "ItemViewDemo/icon-item-view-layout-depth-selected.png"; - private ItemView mItemView; private ItemFactoryWrapper mItemFactoryWrapper; private PropertyMap mGridLayout; @@ -52,15 +51,16 @@ namespace Tizen.NUI.Samples private LongPressGestureDetector mLongPressGestureDetector; private TapGestureDetector mTapDetector; - private PushButton mLayoutButton; - private PushButton mEditButton; - private PushButton mDeleteButton; - private PushButton mInsertButton; - private PushButton mReplaceButton; + private Button mLayoutButton; + private Button mEditButton; + private Button mDeleteButton; + private Button mInsertButton; + private Button mReplaceButton; private TextLabel mTitle; - private ImageView mToolBarBackground; - private Layer mToolBarLayer; + private Layer mDefaultLayer; + private View mRootView; + private View mToolBarLayer; private View mContentView; private int mDurationSeconds = 250; @@ -115,22 +115,25 @@ namespace Tizen.NUI.Samples { case (int)AllImagesLayouts.SPIRAL_LAYOUT: { - mLayoutButton.UnselectedBackgroundVisual = CreateImageVisual(SPIRAL_LAYOUT_IMAGE); - mLayoutButton.SelectedBackgroundVisual = CreateImageVisual(SPIRAL_LAYOUT_IMAGE_SELECTED); + var style = mLayoutButton.Style; + style.BackgroundImage = new Selector() { Normal = SPIRAL_LAYOUT_IMAGE, Selected = SPIRAL_LAYOUT_IMAGE_SELECTED }; + mLayoutButton.ApplyStyle(style); break; } case (int)AllImagesLayouts.GRID_LAYOUT: { - mLayoutButton.UnselectedBackgroundVisual = CreateImageVisual(GRID_LAYOUT_IMAGE); - mLayoutButton.SelectedBackgroundVisual = CreateImageVisual(GRID_LAYOUT_IMAGE_SELECTED); + var style = mLayoutButton.Style; + style.BackgroundImage = new Selector() { Normal = GRID_LAYOUT_IMAGE, Selected = GRID_LAYOUT_IMAGE_SELECTED }; + mLayoutButton.ApplyStyle(style); break; } case (int)AllImagesLayouts.DEPTH_LAYOUT: { - mLayoutButton.UnselectedBackgroundVisual = CreateImageVisual(DEPTH_LAYOUT_IMAGE); - mLayoutButton.SelectedBackgroundVisual = CreateImageVisual(DEPTH_LAYOUT_IMAGE_SELECTED); + var style = mLayoutButton.Style; + style.BackgroundImage = new Selector() { Normal = DEPTH_LAYOUT_IMAGE, Selected = DEPTH_LAYOUT_IMAGE_SELECTED }; + mLayoutButton.ApplyStyle(style); break; } default: @@ -166,39 +169,45 @@ namespace Tizen.NUI.Samples public void Activate() { Window window = NUIApplication.GetDefaultWindow(); - window.GetDefaultLayer().Behavior = Layer.LayerBehavior.Layer3D; + mDefaultLayer = window.GetDefaultLayer(); + mDefaultLayer.Behavior = Layer.LayerBehavior.Layer3D; window.BackgroundColor = Color.Black; - CreateContentView(); - //CreateToolBarView(); + + mRootView = new View() + { + Size = new Size(1920, 1080) + }; + mRootView.Layout = new LinearLayout() + { + LinearOrientation = LinearLayout.Orientation.Vertical + }; + mDefaultLayer.Add(mRootView); + CreateToolBarLayer(); + CreateContentView(); - CreateLayoutButton(); - CreateEditButton(); CreateInsertButton(); CreateReplaceButton(); CreateDeleteButton(); + CreateSpiralLayout(); CreateGridLayout(); CreateDepthLayout(); - CreateSpiralLayout(); mLayout = new PropertyArray(); mLayout.PushBack(new PropertyValue(mSpiralLayout)); mLayout.PushBack(new PropertyValue(mDepthLayout)); mLayout.PushBack(new PropertyValue(mGridLayout)); - mItemFactoryWrapper = new ItemFactoryWrapper(); mItemFactoryWrapper.GetNumberDelegate = GetNumberOfItems; mItemFactoryWrapper.NewItemDelegate = NewItemView; - mItemView = new ItemView(mItemFactoryWrapper); - mItemView.PositionUsesPivotPoint = true; - mItemView.ParentOrigin = Position.ParentOriginCenter; - mItemView.PivotPoint = Position.PivotPointCenter; - window.Add(mItemView); - - window.GetDefaultLayer().Behavior = Layer.LayerBehavior.Layer3D; + mItemView = new ItemView(mItemFactoryWrapper) + { + Size = new Size(800, 800, 800) + }; + mContentView.Add(mItemView); mItemView.Layout = mLayout; mItemView.SetMinimumSwipeDistance(MIN_SWIPE_DISTANCE); @@ -219,7 +228,7 @@ namespace Tizen.NUI.Samples { case Gesture.StateType.Started: { - Size2D windowSize = NUIApplication.GetDefaultWindow().Size; + Size windowSize = NUIApplication.GetDefaultWindow().Size; ItemRange range = new ItemRange(0, 0); mItemView.GetItemsRange(range); @@ -260,7 +269,7 @@ namespace Tizen.NUI.Samples } } - Size2D windowSize = window.Size; + Size windowSize = window.Size; if (layoutId == (int)AllImagesLayouts.DEPTH_LAYOUT) { @@ -279,8 +288,6 @@ namespace Tizen.NUI.Samples mItemView.ActivateLayout((uint)layoutId, new Vector3(800, 800, 800), 0.0f); } - - public uint GetNumberOfItems() { return ITEM_COUNT; @@ -299,8 +306,6 @@ namespace Tizen.NUI.Samples propertyMap.Insert(ImageVisualProperty.FittingMode, new PropertyValue((int)VisualFittingModeType.FitKeepAspectRatio)); ImageView actor = new ImageView(); actor.Image = propertyMap; - actor.PositionZ = 0.0f; - actor.Position = new Position(1000.0f, 0, -1000.0f); // Add a border image child actor ImageView borderActor = new ImageView(); @@ -330,7 +335,7 @@ namespace Tizen.NUI.Samples checkBox.PivotPoint = PivotPoint.TopRight; checkBox.Size = spiralItemSize; checkBox.PositionZ = 0.1f; - + PropertyMap solidColorProperty = new PropertyMap(); solidColorProperty.Insert(Visual.Property.Type, new PropertyValue((int)Visual.Type.Color)); solidColorProperty.Insert(ColorVisualProperty.MixColor, new PropertyValue(new Color(0.0f, 0.0f, 0.0f, 0.6f))); @@ -361,111 +366,140 @@ namespace Tizen.NUI.Samples public void Deactivate() { + if (mEditButton != null) + { + mToolBarLayer.Remove(mEditButton); + mEditButton.Dispose(); + mEditButton = null; + } + + if (mTitle != null) + { + mToolBarLayer.Remove(mTitle); + mTitle.Dispose(); + mTitle = null; + } + if (mLayoutButton != null) { - mLayoutButton.GetParent().Remove(mLayoutButton); + mToolBarLayer.Remove(mLayoutButton); mLayoutButton.Dispose(); + mLayoutButton = null; } - if (mEditButton != null) + if (mToolBarLayer != null) { - mEditButton.GetParent().Remove(mEditButton); - mEditButton.Dispose(); + mRootView.Remove(mToolBarLayer); + mToolBarLayer.Dispose(); + mToolBarLayer = null; } if (mReplaceButton != null) { mReplaceButton.GetParent().Remove(mReplaceButton); mReplaceButton.Dispose(); + mReplaceButton = null; } if (mInsertButton != null) { mInsertButton.GetParent().Remove(mInsertButton); mInsertButton.Dispose(); + mInsertButton = null; } if (mDeleteButton != null) { mDeleteButton.GetParent().Remove(mDeleteButton); mDeleteButton.Dispose(); - } - - if (mTitle != null) - { - mTitle.GetParent().Remove(mTitle); - mTitle.Dispose(); - } - - if (mToolBarBackground != null) - { - mToolBarBackground.GetParent().Remove(mToolBarBackground); - mToolBarBackground.Dispose(); + mDeleteButton = null; } if (mItemView != null) { - mItemView.GetParent().Remove(mItemView); + mContentView.Remove(mItemView); mItemView.Dispose(); + mItemView = null; } if (mContentView != null) { - NUIApplication.GetDefaultWindow().Remove(mContentView); + mRootView.Remove(mContentView); mContentView.Dispose(); + mContentView = null; } - if (mToolBarLayer != null) + if (mRootView != null) { - NUIApplication.GetDefaultWindow().RemoveLayer(mToolBarLayer); - mToolBarLayer.Dispose(); + mDefaultLayer.Remove(mRootView); + mRootView.Dispose(); + mRootView = null; } - NUIApplication.GetDefaultWindow().GetDefaultLayer().Behavior = Layer.LayerBehavior.Layer2D; + NUIApplication.GetDefaultWindow().GetDefaultLayer().Behavior = Layer.LayerBehavior.LayerUI; } public void CreateContentView() { - mContentView = new View(); - mContentView.ParentOrigin = ParentOrigin.Center; - mContentView.PivotPoint = PivotPoint.Center; - mContentView.PositionUsesPivotPoint = true; - mContentView.WidthResizePolicy = ResizePolicyType.FillToParent; - mContentView.HeightResizePolicy = ResizePolicyType.FillToParent; - NUIApplication.GetDefaultWindow().Add(mContentView); - - mContentView.LowerToBottom(); + mContentView = new View() + { + Size = new Size(1920, 1080) + }; + mContentView.Layout = new LinearLayout() + { + LinearOrientation = LinearLayout.Orientation.Horizontal, + LinearAlignment = LinearLayout.Alignment.Center + }; + mRootView.Add(mContentView); } private void CreateToolBarLayer() { - mToolBarLayer = new Layer(); - mToolBarLayer.Name = "TOOLBAR"; - mToolBarLayer.SetAnchorPoint(PivotPoint.TopCenter); - mToolBarLayer.SetParentOrigin(ParentOrigin.TopCenter); - mToolBarLayer.SetResizePolicy(ResizePolicyType.FillToParent, DimensionType.Width); - mToolBarLayer.SetSize(0, 80); - NUIApplication.GetDefaultWindow().AddLayer(mToolBarLayer); - + mToolBarLayer = new View() + { + Name = "TOOLBAR", + Size = new Size(1920, 80), + BackgroundImage = TOOLBAR_IMAGE + }; + mToolBarLayer.Layout = new LinearLayout() + { + LinearOrientation = LinearLayout.Orientation.Horizontal, + LinearAlignment = LinearLayout.Alignment.Center + }; + mRootView.Add(mToolBarLayer); mToolBarLayer.RaiseToTop(); - mToolBarBackground = new ImageView(); - mToolBarBackground.ParentOrigin = ParentOrigin.TopLeft; - mToolBarBackground.PivotPoint = PivotPoint.TopLeft; - mToolBarBackground.PositionUsesPivotPoint = true; - mToolBarBackground.WidthResizePolicy = ResizePolicyType.FillToParent; - mToolBarBackground.HeightResizePolicy = ResizePolicyType.FillToParent; - mToolBarBackground.ResourceUrl = TOOLBAR_IMAGE; - mToolBarLayer.Add(mToolBarBackground); + CreateEditButton(); + CreateToolBarTitle(); + CreateLayoutButton(); + } + + public void CreateEditButton() + { + mEditButton = new Button(); + var mEditButtonStyle = new ButtonStyle + { + Text = null, + BackgroundColor = new Selector(), + BackgroundImage = new Selector() { Normal = EDIT_IMAGE, Selected = EDIT_IMAGE_SELECTED } + }; + mEditButton.ApplyStyle(mEditButtonStyle); + mEditButton.IsSelectable = true; + mEditButton.Size = new Size(34, 34); + mEditButton.LeaveRequired = true; + mEditButton.ClickEvent += (obj, e) => + { + SwitchToNextMode(); + }; + mToolBarLayer.Add(mEditButton); + } + private void CreateToolBarTitle() + { mTitle = new TextLabel(); - mTitle.ParentOrigin = ParentOrigin.TopLeft; - mTitle.PivotPoint = PivotPoint.TopLeft; - mTitle.PositionUsesPivotPoint = true; + mTitle.Size = new Size(1800, 80); mTitle.PointSize = 10.0f; - mTitle.WidthResizePolicy = ResizePolicyType.FillToParent; - mTitle.HeightResizePolicy = ResizePolicyType.FillToParent; mTitle.Text = APPLICATION_TITLE; mTitle.VerticalAlignment = VerticalAlignment.Center; mTitle.HorizontalAlignment = HorizontalAlignment.Center; @@ -474,46 +508,30 @@ namespace Tizen.NUI.Samples private void CreateLayoutButton() { - mLayoutButton = new PushButton(); - mLayoutButton.UnselectedBackgroundVisual = CreateImageVisual(SPIRAL_LAYOUT_IMAGE); - mLayoutButton.SelectedBackgroundVisual = CreateImageVisual(SPIRAL_LAYOUT_IMAGE_SELECTED); - mLayoutButton.Size2D = new Size2D(34, 34); - mLayoutButton.ParentOrigin = ParentOrigin.TopRight; - mLayoutButton.PivotPoint = PivotPoint.TopRight; - mLayoutButton.Position2D = new Position2D(0, 25); - mLayoutButton.PositionUsesPivotPoint = true; + mLayoutButton = new Button(); + var mLayoutButtonStyle = new ButtonStyle + { + Text = null, + BackgroundImage = new Selector() + { + Normal = SPIRAL_LAYOUT_IMAGE, + Selected = SPIRAL_LAYOUT_IMAGE_SELECTED + } + }; + mLayoutButton.ApplyStyle(mLayoutButtonStyle); + mLayoutButton.IsSelectable = true; + mLayoutButton.Size = new Size(34, 34); mLayoutButton.LeaveRequired = true; - mLayoutButton.Clicked += (obj, e) => + mLayoutButton.ClickEvent += (obj, e) => { mCurrentLayout = (mCurrentLayout + 1) % (int)mItemView.GetLayoutCount(); ChangeLayout(); - SetLayoutTitle(); SetLayoutImage(); - return true; }; mToolBarLayer.Add(mLayoutButton); } - public void CreateEditButton() - { - mEditButton = new PushButton(); - mEditButton.UnselectedBackgroundVisual = CreateImageVisual(EDIT_IMAGE); - mEditButton.SelectedBackgroundVisual = CreateImageVisual(EDIT_IMAGE_SELECTED); - mEditButton.Size2D = new Size2D(34, 34); - mEditButton.ParentOrigin = ParentOrigin.TopLeft; - mEditButton.PivotPoint = PivotPoint.TopLeft; - mEditButton.Position2D = new Position2D(5, 25); - mEditButton.PositionUsesPivotPoint = true; - mEditButton.LeaveRequired = true; - mEditButton.Clicked += (obj, e) => - { - SwitchToNextMode(); - return true; - }; - mToolBarLayer.Add(mEditButton); - } - private void SetLayoutTitle() { if (Mode.MODE_NORMAL == mMode) @@ -539,18 +557,23 @@ namespace Tizen.NUI.Samples private void CreateDeleteButton() { - mDeleteButton = new PushButton(); + mDeleteButton = new Button(); + var mDeleteButtonStyle = new ButtonStyle + { + Text = null, + BackgroundColor = new Selector(), + BackgroundImage = new Selector() { Normal = DELETE_IMAGE, Selected = DELETE_IMAGE_SELECTED } + }; + mDeleteButton.ApplyStyle(mDeleteButtonStyle); + mDeleteButton.IsSelectable = true; mDeleteButton.ParentOrigin = ParentOrigin.BottomRight; mDeleteButton.PivotPoint = PivotPoint.BottomRight; mDeleteButton.PositionUsesPivotPoint = true; - mDeleteButton.Position2D = new Position2D(BUTTON_BORDER, BUTTON_BORDER); mDeleteButton.DrawMode = DrawModeType.Overlay2D; - mDeleteButton.UnselectedBackgroundVisual = CreateImageVisual(DELETE_IMAGE); - mDeleteButton.SelectedBackgroundVisual = CreateImageVisual(DELETE_IMAGE_SELECTED); - mDeleteButton.Size2D = new Size2D(50, 50); + mDeleteButton.Size = new Size(50, 50); mDeleteButton.LeaveRequired = true; mDeleteButton.Hide(); - mDeleteButton.Clicked += (obj, e) => + mDeleteButton.ClickEvent += (obj, e) => { ItemIdContainer removeList = new ItemIdContainer(); for (uint i = 0; i < mItemView.GetChildCount(); ++i) @@ -571,25 +594,29 @@ namespace Tizen.NUI.Samples { mItemView.RemoveItems(removeList, 0.5f); } - return true; }; NUIApplication.GetDefaultWindow().Add(mDeleteButton); } private void CreateInsertButton() { - mInsertButton = new PushButton(); + mInsertButton = new Button(); + var mInsertButtonStyle = new ButtonStyle + { + Text = null, + BackgroundColor = new Selector(), + BackgroundImage = new Selector() { Normal = INSERT_IMAGE, Selected = INSERT_IMAGE_SELECTED } + }; + mInsertButton.ApplyStyle(mInsertButtonStyle); + mInsertButton.IsSelectable = true; mInsertButton.ParentOrigin = ParentOrigin.BottomRight; mInsertButton.PivotPoint = PivotPoint.BottomRight; mInsertButton.PositionUsesPivotPoint = true; - mInsertButton.Position2D = new Position2D(BUTTON_BORDER, BUTTON_BORDER); mInsertButton.DrawMode = DrawModeType.Overlay2D; - mInsertButton.UnselectedBackgroundVisual = CreateImageVisual(INSERT_IMAGE); - mInsertButton.SelectedBackgroundVisual = CreateImageVisual(INSERT_IMAGE_SELECTED); - mInsertButton.Size2D = new Size2D(50, 50); + mInsertButton.Size = new Size(50, 50); mInsertButton.LeaveRequired = true; mInsertButton.Hide(); - mInsertButton.Clicked += (obj, e) => + mInsertButton.ClickEvent += (obj, e) => { ItemContainer insertList = new ItemContainer(); Random random = new Random(); @@ -610,25 +637,29 @@ namespace Tizen.NUI.Samples { mItemView.InsertItems(insertList, 0.5f); } - return true; }; NUIApplication.GetDefaultWindow().Add(mInsertButton); } private void CreateReplaceButton() { - mReplaceButton = new PushButton(); + mReplaceButton = new Button(); + var mReplaceButtonStyle = new ButtonStyle + { + Text = null, + BackgroundColor = new Selector(), + BackgroundImage = new Selector() { Normal = REPLACE_IMAGE, Selected = REPLACE_IMAGE_SELECTED } + }; + mReplaceButton.ApplyStyle(mReplaceButtonStyle); + mReplaceButton.IsSelectable = true; mReplaceButton.ParentOrigin = ParentOrigin.BottomRight; mReplaceButton.PivotPoint = PivotPoint.BottomRight; mReplaceButton.PositionUsesPivotPoint = true; - mReplaceButton.Position2D = new Position2D(BUTTON_BORDER, BUTTON_BORDER); mReplaceButton.DrawMode = DrawModeType.Overlay2D; - mReplaceButton.UnselectedBackgroundVisual = CreateImageVisual(REPLACE_IMAGE); - mReplaceButton.SelectedBackgroundVisual = CreateImageVisual(REPLACE_IMAGE_SELECTED); - mReplaceButton.Size2D = new Size2D(50, 50); + mReplaceButton.Size = new Size(50, 50); mReplaceButton.LeaveRequired = true; mReplaceButton.Hide(); - mReplaceButton.Clicked += (obj, e) => + mReplaceButton.ClickEvent += (obj, e) => { ItemContainer replaceList = new ItemContainer(); Random random = new Random(); @@ -650,7 +681,6 @@ namespace Tizen.NUI.Samples { mItemView.ReplaceItems(replaceList, 0.5f); } - return true; }; NUIApplication.GetDefaultWindow().Add(mReplaceButton); } @@ -1002,4 +1032,4 @@ namespace Tizen.NUI.Samples } } -} +} \ No newline at end of file diff --git a/test/Tizen.NUI.Samples/Tizen.NUI.Samples/Samples/LoadingSample.cs b/test/Tizen.NUI.Samples/Tizen.NUI.Samples/Samples/LoadingSample.cs index c924917..d5c6bcf 100755 --- a/test/Tizen.NUI.Samples/Tizen.NUI.Samples/Samples/LoadingSample.cs +++ b/test/Tizen.NUI.Samples/Tizen.NUI.Samples/Samples/LoadingSample.cs @@ -6,10 +6,13 @@ namespace Tizen.NUI.Samples { public class LoadingSample : IExample { - private TextLabel board1, board2, board; - private Button button1, button2, button3, button4; - private Loading loading1_1, loading2_1; //1-null para 2-attributes; X_1-color; X_2 image track + private TextLabel[] textLabel = new TextLabel[3]; + private Button[] button = new Button[3]; + private Loading[] loading = new Loading[2]; private View root; + private View gridLayout; + private View[] layout = new View[4]; + private string[] imageArray; public void Activate() { @@ -17,12 +20,27 @@ namespace Tizen.NUI.Samples root = new View() { - Size2D = new Size2D(1920, 1080), + Size = new Size(1920, 1080), + BackgroundColor = new Color(0.7f, 0.9f, 0.8f, 1.0f) }; + window.Add(root); - CreateBoardAndButtons(); - string[] imageArray = new string[36]; - for (int i=0; i<36; i++) + gridLayout = new View() + { + Position = new Position(400, 200), + Size = new Size(1920, 1080) + }; + gridLayout.Layout = new GridLayout() + { + Rows = 4, + GridOrientation = GridLayout.Orientation.Horizontal, + + }; + //parent.Layout.Measure(new MeasureSpecification(new LayoutLength(1000), MeasureSpecification.ModeType.Exactly), new MeasureSpecification(new LayoutLength(780), MeasureSpecification.ModeType.Exactly)); + root.Add(gridLayout); + + imageArray = new string[36]; + for (int i = 0; i < 36; i++) { if (i < 10) { @@ -34,103 +52,144 @@ namespace Tizen.NUI.Samples } } - loading1_1 = new Loading(); - loading1_1.Position2D = new Position2D(100, 350); - loading1_1.Size2D = new Size2D(100, 100); + CreatePropLayout(); + CreateAttrLayout(); + } - loading1_1.Images = imageArray; - root.Add(loading1_1); + void CreatePropLayout() + { + textLabel[0] = new TextLabel(); + textLabel[0].WidthSpecification = 500; + textLabel[0].HeightSpecification = 100; + //To set spacing between grid cells. + textLabel[0].Margin = new Extents(0, 20, 0, 100); + textLabel[0].PointSize = 20; + textLabel[0].HorizontalAlignment = HorizontalAlignment.Center; + textLabel[0].VerticalAlignment = VerticalAlignment.Center; + textLabel[0].BackgroundColor = Color.Magenta; + textLabel[0].Text = "Property construction"; + gridLayout.Add(textLabel[0]); - LoadingStyle style = new LoadingStyle + // layout for loading which is created by properties. + // It'll update the visual when framerate is changed, so put loading into a layout. + layout[1] = new View(); + layout[1].Layout = new LinearLayout() { - Images = imageArray + LinearOrientation = LinearLayout.Orientation.Horizontal, + LinearAlignment = LinearLayout.Alignment.Center }; + loading[0] = new Loading(); + loading[0].Size = new Size(100, 100); + loading[0].Images = imageArray; + layout[1].Add(loading[0]); + gridLayout.Add(layout[1]); - loading2_1 = new Loading(style); - loading2_1.Position2D = new Position2D(500, 350); - loading2_1.Size2D = new Size2D(100, 100); - root.Add(loading2_1); + CreatePropBtnLayout(); - window.Add(root); + textLabel[1] = new TextLabel(); + textLabel[1].PointSize = 20; + textLabel[1].HorizontalAlignment = HorizontalAlignment.Center; + textLabel[1].VerticalAlignment = VerticalAlignment.Center; + textLabel[1].BackgroundColor = Color.Magenta; + textLabel[1].Text = "log pad"; + textLabel[1].PointSize = 15; + gridLayout.Add(textLabel[1]); + } + + void CreatePropBtnLayout() + { + // layout for button. + // To avoid button size same as the grid cell. + layout[0] = new View() {}; + layout[0].Layout = new LinearLayout() + { + LinearOrientation = LinearLayout.Orientation.Horizontal, + LinearAlignment = LinearLayout.Alignment.Center, + CellPadding = new Size(10, 50) + }; + + button[0] = new Button(); + button[0].Size = new Size(200, 50); + button[0].Text = "FPS++"; + button[0].PointSize = 15; + button[0].BackgroundColor = Color.Green; + layout[0].Add(button[0]); + button[0].Focusable = true; + button[0].ClickEvent += propFpsAdd; + FocusManager.Instance.SetCurrentFocusView(button[0]); + + button[1] = new Button(); + button[1].Size = new Size(200, 50); + button[1].Text = "FPS--"; + button[1].PointSize = 15; + button[1].BackgroundColor = Color.Green; + layout[0].Add(button[1]); + button[1].Focusable = true; + button[1].ClickEvent += propFpsMinus; + FocusManager.Instance.SetCurrentFocusView(button[1]); - FocusManager.Instance.SetCurrentFocusView(button1); + gridLayout.Add(layout[0]); + + button[0].RightFocusableView = button[1]; + button[1].LeftFocusableView = button[0]; } - void CreateBoardAndButtons() + private void CreateAttrLayout() { - board = new TextLabel(); - board.Size2D = new Size2D(1000, 100); - board.Position2D = new Position2D(430, 900); - board.PointSize = 30; - board.HorizontalAlignment = HorizontalAlignment.Center; - board.VerticalAlignment = VerticalAlignment.Center; - board.BackgroundColor = Color.Magenta; - board.Text = "log pad"; - root.Add(board); - - board1 = new TextLabel(); - board1.Size2D = new Size2D(300, 70); - board1.Position2D = new Position2D(50, 200); - board1.PointSize = 20; - board1.HorizontalAlignment = HorizontalAlignment.Center; - board1.VerticalAlignment = VerticalAlignment.Center; - board1.BackgroundColor = Color.Magenta; - board1.Text = "NULL parameter construction"; - root.Add(board1); - - board2 = new TextLabel(); - board2.Size2D = new Size2D(300, 70); - board2.Position2D = new Position2D(400, 200); - board2.PointSize = 20; - board2.HorizontalAlignment = HorizontalAlignment.Center; - board2.VerticalAlignment = VerticalAlignment.Center; - board2.BackgroundColor = Color.Magenta; - board2.Text = "Attribute parameter construction"; - root.Add(board2); - - button1 = new Button(); - button1.BackgroundColor = Color.Green; - button1.Position2D = new Position2D(80, 600); - button1.Size2D = new Size2D(100, 50); - button1.Style.Text.Text = "FPS++"; - root.Add(button1); - button1.Focusable = true; - button1.ClickEvent += Loading1FPSAdd; - button1.FocusGained += FocusGained; - button1.FocusLost += FocusLost; - - button2 = new Button(); - button2.BackgroundColor = Color.Green; - button2.Position2D = new Position2D(200, 600); - button2.Size2D = new Size2D(100, 50); - button2.Style.Text.Text = "FPS--"; - root.Add(button2); - button2.Focusable = true; - button2.ClickEvent += Loading1FPSMinus; - button2.FocusGained += FocusGained; - button2.FocusLost += FocusLost; - - button1.RightFocusableView = button2; - button2.LeftFocusableView = button1; - - button3 = new Button(); - button3.BackgroundColor = Color.Green; - button3.Position2D = new Position2D(450, 600); - button3.Size2D = new Size2D(180, 50); - button3.Style.Text.Text = "Normal Loading"; - root.Add(button3); + textLabel[2] = new TextLabel(); + textLabel[2].PointSize = 20; + textLabel[2].HorizontalAlignment = HorizontalAlignment.Center; + textLabel[2].VerticalAlignment = VerticalAlignment.Center; + textLabel[2].BackgroundColor = Color.Magenta; + textLabel[2].Text = "Attribute construction"; + gridLayout.Add(textLabel[2]); + + // layout for loading which is created by attributes. + // It'll update the visual when framerate is changed, so put loading into a layout. + layout[2] = new View(); + layout[2].Layout = new LinearLayout() + { + LinearOrientation = LinearLayout.Orientation.Horizontal, + LinearAlignment = LinearLayout.Alignment.Center + }; + LoadingStyle style = new LoadingStyle + { + Images = imageArray + }; + loading[1] = new Loading(style); + loading[1].Size = new Size(100, 100); + layout[2].Add(loading[1]); + gridLayout.Add(layout[2]); + + // layout for button. + // To avoid button size same as the grid cell. + layout[3] = new View() { }; + layout[3].Layout = new LinearLayout() + { + LinearOrientation = LinearLayout.Orientation.Horizontal, + LinearAlignment = LinearLayout.Alignment.Center + }; + button[2] = new Button(); + button[2].Size = new Size(400, 50); + button[2].Text = "Normal Loading"; + button[2].PointSize = 15; + button[2].BackgroundColor = Color.Green; + layout[3].Add(button[2]); + gridLayout.Add(layout[3]); + button[2].Focusable = true; + FocusManager.Instance.SetCurrentFocusView(button[2]); } - private void Loading1FPSAdd(object sender, global::System.EventArgs e) + private void propFpsAdd(object sender, global::System.EventArgs e) { - loading1_1.FrameRate += 1; - board.Text = "loading1_1 FPS: "+loading1_1.FrameRate.ToString(); + loading[0].FrameRate += 1; + textLabel[1].Text = "loading1_1 FPS: " + loading[0].FrameRate.ToString(); } - private void Loading1FPSMinus(object sender, global::System.EventArgs e) + private void propFpsMinus(object sender, global::System.EventArgs e) { - loading1_1.FrameRate -= 1; - board.Text = "loading1_1 FPS: " + loading1_1.FrameRate.ToString(); + loading[0].FrameRate -= 1; + textLabel[1].Text = "loading1_1 FPS: " + loading[0].FrameRate.ToString(); } private void FocusLost(object sender, global::System.EventArgs e) @@ -147,62 +206,60 @@ namespace Tizen.NUI.Samples public void Deactivate() { - if (board != null) - { - root.Remove(board); - board.Dispose(); - board = null; - } - if (board1 != null) - { - root.Remove(board1); - board1.Dispose(); - board1 = null; - } - if (board2 != null) - { - root.Remove(board2); - board2.Dispose(); - board2 = null; - } - if (button1 != null) - { - button1.ClickEvent -= Loading1FPSAdd; - button1.FocusGained -= FocusGained; - button1.FocusLost -= FocusLost; - root.Remove(button1); - button1.Dispose(); - button1 = null; - } - if (button2 != null) - { - button2.ClickEvent -= Loading1FPSMinus; - button2.FocusGained -= FocusGained; - button2.FocusLost -= FocusLost; - root.Remove(button2); - button2.Dispose(); - button2 = null; - } - if (button3 != null) - { - root.Remove(button3); - button3.Dispose(); - button3 = null; - } - if (loading1_1 != null) - { - root.Remove(loading1_1); - loading1_1.Dispose(); - loading1_1 = null; - } - if (loading2_1 != null) - { - root.Remove(loading2_1); - loading2_1.Dispose(); - loading2_1 = null; - } if (root != null) { + layout[0].Remove(button[0]); + button[0].Dispose(); + button[0] = null; + + layout[0].Remove(button[1]); + button[1].Dispose(); + button[1] = null; + + gridLayout.Remove(layout[0]); + layout[0].Dispose(); + layout[0] = null; + + gridLayout.Remove(textLabel[0]); + textLabel[0].Dispose(); + textLabel[0] = null; + + layout[1].Remove(loading[0]); + loading[0].Dispose(); + loading[0] = null; + + gridLayout.Remove(layout[1]); + layout[1].Dispose(); + layout[1] = null; + + gridLayout.Remove(textLabel[1]); + textLabel[1].Dispose(); + textLabel[1] = null; + + gridLayout.Remove(textLabel[2]); + textLabel[2].Dispose(); + textLabel[2] = null; + + layout[2].Remove(loading[1]); + loading[1].Dispose(); + loading[1] = null; + + gridLayout.Remove(layout[2]); + layout[2].Dispose(); + layout[2] = null; + + layout[3].Remove(button[2]); + button[2].Dispose(); + button[2] = null; + + gridLayout.Remove(layout[3]); + layout[3].Dispose(); + layout[3] = null; + + root.Remove(gridLayout); + gridLayout.Dispose(); + gridLayout = null; + NUIApplication.GetDefaultWindow().Remove(root); root.Dispose(); root = null; diff --git a/test/Tizen.NUI.Samples/Tizen.NUI.Samples/Samples/PaginationSample.cs b/test/Tizen.NUI.Samples/Tizen.NUI.Samples/Samples/PaginationSample.cs index 51fc921..237e3c5 100755 --- a/test/Tizen.NUI.Samples/Tizen.NUI.Samples/Samples/PaginationSample.cs +++ b/test/Tizen.NUI.Samples/Tizen.NUI.Samples/Samples/PaginationSample.cs @@ -5,8 +5,9 @@ namespace Tizen.NUI.Samples { public class PaginationSample : IExample { - private Pagination pagination1; - private Pagination pagination2; + private TextLabel[] board = new TextLabel[2]; + private Pagination[] pagination = new Pagination[2]; + private View[] layout = new View[3]; private readonly int PAGE_COUNT = 5; @@ -14,42 +15,108 @@ namespace Tizen.NUI.Samples { Window window = NUIApplication.GetDefaultWindow(); + // Root layout. + layout[0] = new View() + { + Size = new Size(1920, 1080), + BackgroundColor = new Color(0.7f, 0.9f, 0.8f, 1.0f), + }; + layout[0].Layout = new LinearLayout() + { + LinearOrientation = LinearLayout.Orientation.Vertical, + LinearAlignment = LinearLayout.Alignment.Center, + CellPadding = new Size(20, 50) + }; + window.Add(layout[0]); + window.KeyEvent += Window_KeyEvent; + + // A pagination sample created by properties will be added to this layout. + layout[1]= new View() + { + Size = new Size(700, 70), + Layout = new LinearLayout() + { + LinearOrientation = LinearLayout.Orientation.Horizontal, + LinearAlignment = LinearLayout.Alignment.Center, + CellPadding = new Size(20, 50) + } + }; + layout[0].Add(layout[1]); + + // A pagination sample created by attributes will be added to this layout. + layout[2] = new View() + { + Size = new Size(700, 70), + Layout = new LinearLayout() + { + LinearOrientation = LinearLayout.Orientation.Horizontal, + LinearAlignment = LinearLayout.Alignment.Center, + CellPadding = new Size(20, 50) + } + }; + layout[0].Add(layout[2]); + + createBorads(); + ///////////////////////////////////////////////Create by Properties////////////////////////////////////////////////////////// - pagination1 = new Pagination(); - pagination1.Name = "Pagination1"; - pagination1.Position2D = new Position2D(500, 450); - pagination1.Size2D = new Size2D(400, 30); - pagination1.BackgroundColor = new Color(1.0f, 1.0f, 1.0f, 0.6f); - pagination1.IndicatorSize = new Size(26, 26); - pagination1.IndicatorImageURL = new Selector() + pagination[0] = new Pagination(); + var indicatorImageUrlStyle = new PaginationStyle() { - Normal = CommonResource.GetFHResourcePath() + "9. Controller/pagination_ic_nor.png", - Selected = CommonResource.GetFHResourcePath() + "9. Controller/pagination_ic_sel.png", + IndicatorSize = new Size(26, 26), + IndicatorSpacing = 8, + IndicatorImageURL = new Selector + { + Normal = CommonResource.GetFHResourcePath() + "9. Controller/pagination_ic_nor.png", + Selected = CommonResource.GetFHResourcePath() + "9. Controller/pagination_ic_sel.png" + } }; - pagination1.IndicatorSpacing = 8; - pagination1.IndicatorCount = PAGE_COUNT; - pagination1.SelectedIndex = 0; - window.Add(pagination1); + pagination[0].ApplyStyle(indicatorImageUrlStyle); + pagination[0].Name = "Pagination1"; + pagination[0].Size = new Size(300, 50); + pagination[0].BackgroundColor = new Color(1.0f, 1.0f, 1.0f, 0.6f); + pagination[0].IndicatorCount = PAGE_COUNT; + pagination[0].SelectedIndex = 0; + layout[1].Add(pagination[0]); ///////////////////////////////////////////////Create by Attributes////////////////////////////////////////////////////////// - PaginationStyle style = new PaginationStyle(); - style.IndicatorSize = new Size(15, 15); - style.IndicatorImageURL = new Selector() + PaginationStyle style = new PaginationStyle() { - Normal = CommonResource.GetTVResourcePath() + "component/c_pagination/c_paganation_medium_dot_normal.png", - Selected = CommonResource.GetTVResourcePath() + "component/c_pagination/c_paganation_medium_dot_focus.png", + IndicatorSize = new Size(15, 15), + IndicatorSpacing = 20, + IndicatorImageURL = new Selector + { + Normal = CommonResource.GetFHResourcePath() + "9. Controller/pagination_ic_nor.png", + Selected = CommonResource.GetFHResourcePath() + "9. Controller/pagination_ic_sel.png" + } }; - style.IndicatorSpacing = 14; - pagination2 = new Pagination(style); - pagination2.Name = "Pagination2"; - pagination2.Position2D = new Position2D(500, 500); - pagination2.Size2D = new Size2D(400, 30); - pagination2.BackgroundColor = new Color(1.0f, 1.0f, 1.0f, 0.6f); - pagination2.IndicatorCount = PAGE_COUNT; - pagination2.SelectedIndex = 0; - window.Add(pagination2); + pagination[1] = new Pagination(style); + pagination[1].Name = "Pagination2"; + pagination[1].Size = new Size(300, 50); + pagination[1].BackgroundColor = new Color(1.0f, 1.0f, 1.0f, 0.6f); + pagination[1].IndicatorCount = PAGE_COUNT; + pagination[1].SelectedIndex = 0; + layout[2].Add(pagination[1]); + } - window.KeyEvent += Window_KeyEvent; + void createBorads() + { + board[0] = new TextLabel(); + board[0].Size = new Size(300, 50); + board[0].PointSize = 15; + board[0].HorizontalAlignment = HorizontalAlignment.Center; + board[0].VerticalAlignment = VerticalAlignment.Center; + board[0].BackgroundColor = Color.Magenta; + board[0].Text = "Property construction"; + layout[1].Add(board[0]); + + board[1] = new TextLabel(); + board[1].Size = new Size(300, 50); + board[1].PointSize = 15; + board[1].HorizontalAlignment = HorizontalAlignment.Center; + board[1].VerticalAlignment = VerticalAlignment.Center; + board[1].BackgroundColor = Color.Magenta; + board[1].Text = "Attribute construction"; + layout[2].Add(board[1]); } private void Window_KeyEvent(object sender, Window.KeyEventArgs e) @@ -58,24 +125,24 @@ namespace Tizen.NUI.Samples { if (e.Key.KeyPressedName == "Left") { - if (pagination1.SelectedIndex > 0) + if (pagination[0].SelectedIndex > 0) { - pagination1.SelectedIndex = pagination1.SelectedIndex - 1; + pagination[0].SelectedIndex = pagination[0].SelectedIndex - 1; } - if (pagination2.SelectedIndex > 0) + if (pagination[1].SelectedIndex > 0) { - pagination2.SelectedIndex = pagination2.SelectedIndex - 1; + pagination[1].SelectedIndex = pagination[1].SelectedIndex - 1; } } else if (e.Key.KeyPressedName == "Right") { - if (pagination1.SelectedIndex < pagination1.IndicatorCount - 1) + if (pagination[0].SelectedIndex < pagination[0].IndicatorCount - 1) { - pagination1.SelectedIndex = pagination1.SelectedIndex + 1; + pagination[0].SelectedIndex = pagination[0].SelectedIndex + 1; } - if (pagination2.SelectedIndex < pagination2.IndicatorCount - 1) + if (pagination[1].SelectedIndex < pagination[1].IndicatorCount - 1) { - pagination2.SelectedIndex = pagination2.SelectedIndex + 1; + pagination[1].SelectedIndex = pagination[1].SelectedIndex + 1; } } } @@ -85,11 +152,37 @@ namespace Tizen.NUI.Samples { Window window = NUIApplication.GetDefaultWindow(); window.KeyEvent -= Window_KeyEvent; - window.Remove(pagination1); - window.Remove(pagination2); - pagination1.Dispose(); - pagination2.Dispose(); + if (layout[0] != null) + { + layout[1].Remove(board[0]); + board[0].Dispose(); + board[0] = null; + + layout[1].Remove(pagination[0]); + pagination[0].Dispose(); + pagination[0] = null; + + layout[0].Remove(layout[1]); + layout[1].Dispose(); + layout[1] = null; + + layout[2].Remove(board[1]); + board[1].Dispose(); + board[1] = null; + + layout[2].Remove(pagination[1]); + pagination[1].Dispose(); + pagination[1] = null; + + layout[0].Remove(layout[2]); + layout[2].Dispose(); + layout[2] = null; + + window.Remove(layout[0]); + layout[0].Dispose(); + layout[0] = null; + } } } } diff --git a/test/Tizen.NUI.Samples/Tizen.NUI.Samples/Samples/PopupSample.cs b/test/Tizen.NUI.Samples/Tizen.NUI.Samples/Samples/PopupSample.cs index 8366791..f919549 100755 --- a/test/Tizen.NUI.Samples/Tizen.NUI.Samples/Samples/PopupSample.cs +++ b/test/Tizen.NUI.Samples/Tizen.NUI.Samples/Samples/PopupSample.cs @@ -7,6 +7,8 @@ namespace Tizen.NUI.Samples public class PopupSample : IExample { private View root; + private View parent1; + private View parent2; private TextLabel[] createText = new TextLabel[2]; @@ -38,37 +40,63 @@ namespace Tizen.NUI.Samples root = new View() { - Size2D = new Size2D(1920, 1080), - BackgroundColor = Color.White, + Size = new Size(1920, 1080), + BackgroundColor = new Color(0.7f, 0.9f, 0.8f, 1.0f), }; window.Add(root); + parent1 = new View() + { + Size = new Size(1920, 1080), + }; + parent1.Layout = new LinearLayout() + { + LinearOrientation = LinearLayout.Orientation.Horizontal, + LinearAlignment = LinearLayout.Alignment.Center, + CellPadding = new Size(50, 50) + }; + + parent2 = new View() + { + Size = new Size(1032, 980), + }; + parent2.Layout = new LinearLayout() + { + LinearOrientation = LinearLayout.Orientation.Vertical, + LinearAlignment = LinearLayout.Alignment.CenterHorizontal, + CellPadding = new Size(400, 400) + }; + ///////////////////////////////////////////////Create by Property////////////////////////////////////////////////////////// createText[0] = new TextLabel(); createText[0].Text = "Create Popup just by properties"; - createText[0].Size2D = new Size2D(500, 100); - createText[0].Position2D = new Position2D(500, 50); - root.Add(createText[0]); + createText[0].WidthSpecification = 500; + createText[0].HeightSpecification = 100; + parent2.Add(createText[0]); popup = new Popup(); - popup.MinimumSize = new Size2D(1032, 184); + popup.MinimumSize = new Size(1032, 184); popup.Size = new Size(1032, 400); - popup.Position = new Position(200, 100); + popup.Position = new Position(150, 100); // Title - popup.Style.Title.PointSize = 25; - popup.Style.Title.SizeHeight = 68; - popup.Style.Title.HorizontalAlignment = HorizontalAlignment.Begin; - popup.Style.Title.Position = new Position(64, 52); - popup.Style.Title.Text = "Popup Title"; + popup.Title.PointSize = 25; + popup.Title.Size = new Size(0, 68); + popup.Title.PositionUsesPivotPoint = true; + popup.Title.ParentOrigin = Tizen.NUI.ParentOrigin.TopLeft; + popup.Title.PivotPoint = Tizen.NUI.PivotPoint.TopLeft; + popup.Title.HorizontalAlignment = HorizontalAlignment.Begin; + popup.Title.VerticalAlignment = VerticalAlignment.Bottom; + popup.Title.Position = new Position(64, 52); + popup.Title.Text = "Popup Title"; + popup.Title.Padding = 0; // Shadow - popup.Style.ImageShadow = new ImageShadow + popup.ImageShadow = new ImageShadow { Url = CommonResource.GetFHResourcePath() + "11. Popup/popup_background_shadow.png", Border = new Rectangle(24, 24, 24, 24), - Offset = new Vector2(-24, -24), - Extents = new Vector2(48, 48), + Extents = new Vector2(48, 48) }; // Background @@ -82,9 +110,8 @@ namespace Tizen.NUI.Samples popup.ButtonBackgroundBorder = new Rectangle(5, 5, 5, 5); popup.ButtonOverLayBackgroundColorSelector = new Selector { - Normal = new Color(1.0f, 1.0f, 1.0f, 1.0f), - Pressed = new Color(0.0f, 0.0f, 0.0f, 0.1f), - Selected = new Color(1.0f, 1.0f, 1.0f, 1.0f), + Normal = new Color(1.0f, 1.0f, 1.0f, 0.5f), + Pressed = new Color(0.0f, 0.0f, 0.0f, 0.5f) }; popup.ButtonImageShadow = new ImageShadow { @@ -98,7 +125,7 @@ namespace Tizen.NUI.Samples popup.Post(window); contentText = new TextLabel(); - contentText.Size2D = new Size2D(904, 100); + contentText.Size = new Size(1032, 100); contentText.PointSize = 20; contentText.HorizontalAlignment = HorizontalAlignment.Begin; contentText.VerticalAlignment = VerticalAlignment.Center; @@ -109,20 +136,19 @@ namespace Tizen.NUI.Samples ///////////////////////////////////////////////Create by Attributes////////////////////////////////////////////////////////// createText[1] = new TextLabel(); createText[1].Text = "Create Popup just by Attributes"; - createText[1].Size2D = new Size2D(500, 100); - createText[1].Position2D = new Position2D(500, 550); - root.Add(createText[1]); + createText[1].WidthSpecification = 500; + createText[1].HeightSpecification = 100; + parent2.Add(createText[1]); PopupStyle attrs = new PopupStyle { - MinimumSize = new Size2D(1032, 184), + MinimumSize = new Size(1032, 184), BackgroundImage = new Selector { All = CommonResource.GetFHResourcePath() + "11. Popup/popup_background.png" }, BackgroundImageBorder = new Selector { All = new Rectangle(0, 0, 81, 81) }, ImageShadow = new ImageShadow { Url = CommonResource.GetFHResourcePath() + "11. Popup/popup_background_shadow.png", Border = new Rectangle(24, 24, 24, 24), - Offset = new Vector2(-24, -24), Extents = new Vector2(48, 48), }, Title = new TextLabelStyle @@ -159,9 +185,8 @@ namespace Tizen.NUI.Samples HeightResizePolicy = ResizePolicyType.FillToParent, BackgroundColor = new Selector { - Normal = new Color(1.0f, 1.0f, 1.0f, 1.0f), - Pressed = new Color(0.0f, 0.0f, 0.0f, 0.1f), - Selected = new Color(1.0f, 1.0f, 1.0f, 1.0f), + Normal = new Color(1.0f, 1.0f, 1.0f, 0.5f), + Pressed = new Color(0.0f, 0.0f, 0.0f, 0.5f), } }, Text = new TextLabelStyle @@ -171,14 +196,14 @@ namespace Tizen.NUI.Samples PivotPoint = Tizen.NUI.PivotPoint.Center, HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center, - TextColor = new Selector { All = color[index2] }, + TextColor = new Selector { All = color[index2] } }, }, }; popup2 = new Popup(attrs); popup2.Size = new Size(1032, 400); - popup2.Position = new Position(200, 600); + popup2.Position = new Position(150, 600); popup2.AddButton("Yes"); popup2.AddButton("Exit"); popup2.ButtonHeight = 132; @@ -187,7 +212,7 @@ namespace Tizen.NUI.Samples popup2.Post(window); contentText2 = new TextLabel(); - contentText2.Size2D = new Size2D(904, 100); + contentText2.Size = new Size(1032, 100); contentText2.PointSize = 20; contentText2.HorizontalAlignment = HorizontalAlignment.Begin; contentText2.VerticalAlignment = VerticalAlignment.Center; @@ -195,13 +220,16 @@ namespace Tizen.NUI.Samples popup2.ContentView.Add(contentText2); button = new Button(); - button.Style.BackgroundImage = CommonResource.GetTVResourcePath() + "component/c_buttonbasic/c_basic_button_white_bg_normal_9patch.png"; - button.Style.BackgroundImageBorder = new Rectangle(4, 4, 5, 5); - button.Size2D = new Size2D(580, 80); - button.Position2D = new Position2D(1300, 500); - button.Style.Text.Text = "LayoutDirection is left to right"; + button.BackgroundImage = CommonResource.GetTVResourcePath() + "component/c_buttonbasic/c_basic_button_white_bg_normal_9patch.png"; + button.BackgroundImageBorder = new Rectangle(4, 4, 5, 5); + button.WidthSpecification = 580; + button.HeightSpecification = 80; + button.ButtonText.Text = "LayoutDirection is left to right"; button.ClickEvent += ButtonClickEvent; - root.Add(button); + + parent1.Add(parent2); + parent1.Add(button); + root.Add(parent1); } private void Popup2LayoutDirectionChanged(object sender, View.LayoutDirectionChangedEventArgs e) @@ -256,13 +284,13 @@ namespace Tizen.NUI.Samples { popup.LayoutDirection = ViewLayoutDirectionType.RTL; popup2.LayoutDirection = ViewLayoutDirectionType.RTL; - button.Style.Text.Text = "LayoutDirection is right to left"; + button.ButtonText.Text = "LayoutDirection is right to left"; } else { popup.LayoutDirection = ViewLayoutDirectionType.LTR; popup2.LayoutDirection = ViewLayoutDirectionType.LTR; - button.Style.Text.Text = "LayoutDirection is left to right"; + button.ButtonText.Text = "LayoutDirection is left to right"; } } @@ -280,6 +308,7 @@ namespace Tizen.NUI.Samples } root.Remove(popup); + popup.Dismiss(); popup.Dispose(); popup = null; } @@ -294,6 +323,7 @@ namespace Tizen.NUI.Samples } root.Remove(popup2); + popup2.Dismiss(); popup2.Dispose(); popup2 = null; } diff --git a/test/Tizen.NUI.Samples/Tizen.NUI.Samples/Samples/ProgressSample.cs b/test/Tizen.NUI.Samples/Tizen.NUI.Samples/Samples/ProgressSample.cs index 079d7e8..ccf5429 100755 --- a/test/Tizen.NUI.Samples/Tizen.NUI.Samples/Samples/ProgressSample.cs +++ b/test/Tizen.NUI.Samples/Tizen.NUI.Samples/Samples/ProgressSample.cs @@ -6,48 +6,154 @@ namespace Tizen.NUI.Samples { public class ProgressSample : IExample { - private TextLabel board1, board2, board; - private Button button1, button2, button3, button4, button5; - int status = 0; - private Progress progressBar1_1, progressBar1_2, progressBar2_1, progressBar2_2; //1-null para 2-attributes; X_1-color; X_2 image track - private View root; + private TextLabel[] board = new TextLabel[3]; + private Button[] button = new Button[2]; + private Progress[] progressBar = new Progress[3]; + private View[] layout = new View[4]; public void Activate() { Window window = NUIApplication.GetDefaultWindow(); - root = new View() + // Root layout. + layout[0] = new View() { - Size2D = new Size2D(1920, 1080), + Size = new Size(1920, 1080), + BackgroundColor = new Color(0.7f, 0.9f, 0.8f, 1.0f), }; + layout[0].Layout = new LinearLayout() + { + LinearOrientation = LinearLayout.Orientation.Vertical, + LinearAlignment = LinearLayout.Alignment.Center + }; + window.Add(layout[0]); + + // Layout for progress parent layout. + layout[1] = new View() + { + Size = new Size(1000, 730) + }; + layout[1].Layout = new LinearLayout() + { + LinearOrientation = LinearLayout.Orientation.Horizontal, + LinearAlignment = LinearLayout.Alignment.Center + }; + layout[0].Add(layout[1]); + + // Layout for progress layout which is created by properties. + layout[2] = new View() + { + Size = new Size(450, 630) + }; + layout[2].Layout = new LinearLayout() + { + LinearOrientation = LinearLayout.Orientation.Vertical, + LinearAlignment = LinearLayout.Alignment.CenterHorizontal, + CellPadding = new Size2D(50, 100) + }; + layout[1].Add(layout[2]); + + // Layout for progress layout which is created by attributes. + layout[3] = new View() + { + Size = new Size(450, 630) + }; + layout[3].Layout = new LinearLayout() + { + LinearOrientation = LinearLayout.Orientation.Vertical, + LinearAlignment = LinearLayout.Alignment.CenterHorizontal, + CellPadding = new Size2D(50, 100) + }; + layout[1].Add(layout[3]); + + CreatePropElements(); + CreateAttrElements(); + layout[1].Add(layout[2]); + layout[1].Add(layout[3]); + + board[0] = new TextLabel(); + board[0].WidthSpecification = 900; + board[0].HeightSpecification = 100; + board[0].PointSize = 30; + board[0].HorizontalAlignment = HorizontalAlignment.Center; + board[0].VerticalAlignment = VerticalAlignment.Center; + board[0].BackgroundColor = Color.Magenta; + board[0].Text = "log pad"; + layout[0].Add(board[0]); + board[0].Focusable = true; + board[0].FocusGained += Board_FocusGained; + board[0].FocusLost += Board_FocusLost; + board[0].UpFocusableView = button[0]; + FocusManager.Instance.SetCurrentFocusView(button[0]); + } + + void CreatePropElements() + { + ///////////////////////////////////////////////Create by Properties////////////////////////////////////////////////////////// + board[1] = new TextLabel(); + board[1].WidthSpecification = 380; + board[1].HeightSpecification = 70; + board[1].PointSize = 20; + board[1].HorizontalAlignment = HorizontalAlignment.Center; + board[1].VerticalAlignment = VerticalAlignment.Center; + board[1].BackgroundColor = Color.Magenta; + board[1].Text = "Property construction"; + layout[2].Add(board[1]); + board[1].Focusable = true; + board[1].FocusGained += Board_FocusGained; + board[1].FocusLost += Board_FocusLost; + + progressBar[0] = new Progress(); + progressBar[0].WidthSpecification = 240; + progressBar[0].HeightSpecification = 4; + progressBar[0].MaxValue = 100; + progressBar[0].MinValue = 0; + progressBar[0].CurrentValue = 45; + layout[2].Add(progressBar[0]); + + progressBar[1] = new Progress(); + progressBar[1].WidthSpecification = 240; + progressBar[1].HeightSpecification = 4; + progressBar[1].MaxValue = 100; + progressBar[1].MinValue = 0; + progressBar[1].CurrentValue = 30; + progressBar[1].TrackColor = Color.Yellow; + progressBar[1].ProgressColor = Color.Black; + layout[2].Add(progressBar[1]); + + button[0] = new Button(); + button[0].WidthSpecification = 140; + button[0].HeightSpecification = 50; + button[0].Text = "+"; + button[0].BackgroundColor = Color.Green; + layout[2].Add(button[0]); + button[0].Focusable = true; + button[0].ClickEvent += ProgressAdd; + + button[1] = new Button(); + button[1].WidthSpecification = 140; + button[1].HeightSpecification = 50; + button[1].Text = "-"; + button[1].BackgroundColor = Color.Green; + layout[2].Add(button[1]); + button[1].Focusable = true; + button[1].ClickEvent += ProgressMinus; + } - CreateBoardAndButtons(); - - //button1.ClickEvent += bar1Add; - //button2.ClickEvent += bar1Minus; - //button3.ClickEvent += circle1Add; - //button4.ClickEvent += circle1Minus; - //button5.ClickEvent += circleStatusChanged; - - progressBar1_1 = new Progress(); - progressBar1_1.Position2D = new Position2D(80, 350); - progressBar1_1.Size2D = new Size2D(140, 4); - progressBar1_1.MaxValue = 100; - progressBar1_1.MinValue = 0; - progressBar1_1.CurrentValue = 45; - progressBar1_1.Style.Track.BackgroundColor = Color.Green; - progressBar1_1.Style.Progress.BackgroundColor = Color.Black; - root.Add(progressBar1_1); - - progressBar1_2 = new Progress(); - progressBar1_2.Position2D = new Position2D(80, 420); - progressBar1_2.Size2D = new Size2D(140, 4); - progressBar1_2.MaxValue = 100; - progressBar1_2.MinValue = 0; - progressBar1_2.CurrentValue = 15; - progressBar1_2.Style.Track.BackgroundColor = Color.Green; - progressBar1_2.Style.Progress.BackgroundColor = Color.Black; - - root.Add(progressBar1_2); + private void CreateAttrElements() + { + ///////////////////////////////////////////////Create by attributes////////////////////////////////////////////////////////// + board[2] = new TextLabel(); + board[2].WidthSpecification = 380; + board[2].HeightSpecification = 70; + board[2].PointSize = 20; + board[2].HorizontalAlignment = HorizontalAlignment.Center; + board[2].VerticalAlignment = VerticalAlignment.Center; + board[2].BackgroundColor = Color.Magenta; + board[2].Text = "Attribute construction"; + layout[3].Add(board[2]); + board[2].Focusable = true; + board[2].FocusGained += Board_FocusGained; + board[2].FocusLost += Board_FocusLost; ProgressStyle attr = new ProgressStyle { @@ -55,172 +161,110 @@ namespace Tizen.NUI.Samples { BackgroundColor = new Selector { - All = Color.Cyan, + All = Color.Cyan } }, Progress = new ImageViewStyle { BackgroundColor = new Selector { - All = Color.Black, + All = Color.Red } }, - + Buffer = new ImageViewStyle + { + BackgroundColor = new Selector + { + All = Color.Green + } + } }; - - progressBar2_1 = new Progress(attr); - progressBar2_1.Position2D = new Position2D(380, 350); - progressBar2_1.Size2D = new Size2D(140, 4); - progressBar2_1.MaxValue = 100; - progressBar2_1.MinValue = 0; - progressBar2_1.CurrentValue = 30; - root.Add(progressBar2_1); - - //progressBar2_2 = new Progress(att); - //progressBar2_2.Position2D = new Position2D(80, 560); - //progressBar2_2.Size2D = new Size2D(140, 4); - //progressBar2_2.MaxValue = 100; - //progressBar2_2.MinValue = 0; - //progressBar2_2.CurrentValue = 75; - //progressBar2_2.UpdateValue(); - //progressBar2_2.Direction = Progress.DirectionType.Horizontal; - //root.Add(progressBar2_2); - - board.UpFocusableView = button1; - window.Add(root); - FocusManager.Instance.SetCurrentFocusView(button1); - - } - - void CreateBoardAndButtons() - { - board = new TextLabel(); - board.Size2D = new Size2D(1000, 100); - board.Position2D = new Position2D(430, 900); - board.PointSize = 30; - board.HorizontalAlignment = HorizontalAlignment.Center; - board.VerticalAlignment = VerticalAlignment.Center; - board.BackgroundColor = Color.Magenta; - board.Text = "log pad"; - root.Add(board); - board.Focusable = true; - board.FocusGained += Board_FocusGained; - board.FocusLost += Board_FocusLost; - - board1 = new TextLabel(); - board1.Size2D = new Size2D(300, 70); - board1.Position2D = new Position2D(50, 200); - board1.PointSize = 20; - board1.HorizontalAlignment = HorizontalAlignment.Center; - board1.VerticalAlignment = VerticalAlignment.Center; - board1.BackgroundColor = Color.Magenta; - board1.Text = "NULL parameter construction"; - root.Add(board1); - board1.Focusable = true; - board1.FocusGained += Board_FocusGained; - board1.FocusLost += Board_FocusLost; - - board2 = new TextLabel(); - board2.Size2D = new Size2D(300, 70); - board2.Position2D = new Position2D(400, 200); - board2.PointSize = 20; - board2.HorizontalAlignment = HorizontalAlignment.Center; - board2.VerticalAlignment = VerticalAlignment.Center; - board2.BackgroundColor = Color.Magenta; - board2.Text = "Attribute construction"; - root.Add(board2); - board2.Focusable = true; - board2.FocusGained += Board_FocusGained; - board2.FocusLost += Board_FocusLost; - - button1 = new Button(); - button1.BackgroundColor = Color.Green; - button1.Position2D = new Position2D(100, 700); - button1.Size2D = new Size2D(80, 50); - button1.Style.Text.Text = "+"; - root.Add(button1); - button1.Focusable = true; - button1.ClickEvent += bar1Add; - - button2 = new Button(); - button2.BackgroundColor = Color.Green; - button2.Position2D = new Position2D(200, 700); - button2.Size2D = new Size2D(80, 50); - button2.Style.Text.Text = "-"; - root.Add(button2); - button2.Focusable = true; - button2.ClickEvent += bar1Minus; - - //button3 = new Button(); - //button3.BackgroundColor = Color.Green; - //button3.Position2D = new Position2D(450, 700); - //button3.Size2D = new Size2D(80, 50); - //button3.Text = "+"; - //root.Add(button3); - //button3.Focusable = true; - //button3.ClickEvent += Scroll2Add; - - //button4 = new Button(); - //button4.BackgroundColor = Color.Green; - //button4.Position2D = new Position2D(550, 700); - //button4.Size2D = new Size2D(80, 50); - //button4.Text = "-"; - //root.Add(button4); - //button4.Focusable = true; - //button4.ClickEvent += Scroll2Minus; + progressBar[2] = new Progress(attr); + progressBar[2].WidthSpecification = 240; + progressBar[2].HeightSpecification = 4; + progressBar[2].MaxValue = 100; + progressBar[2].MinValue = 0; + progressBar[2].CurrentValue = 30; + layout[3].Add(progressBar[2]); } private void Board_FocusLost(object sender, global::System.EventArgs e) { - board.BackgroundColor = Color.Magenta; + board[0].BackgroundColor = Color.Magenta; } private void Board_FocusGained(object sender, global::System.EventArgs e) { - board.BackgroundColor = Color.Cyan; - } - - private void bar1Add(object sender, global::System.EventArgs e) - { - board.Text = "+"; - progressBar1_1.CurrentValue++; - } - private void bar1Minus(object sender, global::System.EventArgs e) - { - board.Text = "-"; - progressBar1_1.CurrentValue--; + board[0].BackgroundColor = Color.Cyan; } - private void circleStatusChanged(object sender, global::System.EventArgs e) + private void ProgressAdd(object sender, global::System.EventArgs e) { - global::System.Console.WriteLine("----------------"); - - status++; - if (status > 2) - status = 0; - if (status == 0) + if (progressBar[0].CurrentValue == 100) { - button5.Style.Text.Text = "Buffer"; - //progressCircle1.ProgressState = Progress.ProgressStatusType.Buffering; + board[0].Text = "Current value is: 100"; } - if (status == 1) + else { - button5.Style.Text.Text = "Deter"; - //progressCircle1.ProgressState = Progress.ProgressStatusType.Determinate; + board[0].Text = "Current value is: " + ++progressBar[0].CurrentValue; } - if (status == 2) + } + private void ProgressMinus(object sender, global::System.EventArgs e) + { + if (progressBar[0].CurrentValue == 0) { - button5.Style.Text.Text = "indeter"; - //progressCircle1.ProgressState = Progress.ProgressStatusType.Indeterminate; + board[0].Text = "Current value is: 0"; + } + else + { + board[0].Text = "Current value is: " + --progressBar[0].CurrentValue; } } public void Deactivate() { - if (root != null) + if (layout[0] != null) { - NUIApplication.GetDefaultWindow().Remove(root); - root.Dispose(); + layout[2].Remove(board[1]); + board[1].Dispose(); + board[1] = null; + layout[2].Remove(progressBar[0]); + progressBar[0].Dispose(); + progressBar[0] = null; + layout[2].Remove(progressBar[1]); + progressBar[1].Dispose(); + progressBar[1] = null; + layout[2].Remove(button[0]); + button[0].Dispose(); + button[0] = null; + layout[2].Remove(button[1]); + button[1].Dispose(); + button[1] = null; + + layout[3].Remove(board[2]); + board[2].Dispose(); + board[2] = null; + layout[3].Remove(progressBar[2]); + progressBar[2].Dispose(); + progressBar[2] = null; + + layout[1].Remove(layout[2]); + layout[2].Dispose(); + layout[2] = null; + layout[1].Remove(layout[3]); + layout[3].Dispose(); + layout[3] = null; + + layout[0].Remove(layout[1]); + layout[1].Dispose(); + layout[1] = null; + layout[0].Remove(board[0]); + board[0].Dispose(); + board[0] = null; + + NUIApplication.GetDefaultWindow().Remove(layout[0]); + layout[0].Dispose(); + layout[0] = null; } } } diff --git a/test/Tizen.NUI.Samples/Tizen.NUI.Samples/Samples/RadioButtonSample.cs b/test/Tizen.NUI.Samples/Tizen.NUI.Samples/Samples/RadioButtonSample.cs index 74a325b..cad3352 100755 --- a/test/Tizen.NUI.Samples/Tizen.NUI.Samples/Samples/RadioButtonSample.cs +++ b/test/Tizen.NUI.Samples/Tizen.NUI.Samples/Samples/RadioButtonSample.cs @@ -7,6 +7,10 @@ namespace Tizen.NUI.Samples public class RadioButtonSample : IExample { private View root; + private View left; + private View right; + private View leftbody; + private View rightbody; private TextLabel[] createText = new TextLabel[2]; private TextLabel[] modeText = new TextLabel[4]; @@ -35,156 +39,186 @@ namespace Tizen.NUI.Samples { Window window = NUIApplication.GetDefaultWindow(); + // Create root view. root = new View() { - Size2D = new Size2D(1920, 1080), - BackgroundColor = Color.White, + Size = new Size(1920, 1080), + BackgroundColor = new Color(0.7f, 0.9f, 0.8f, 1.0f), + Padding = new Extents(40, 40, 40, 40), + Layout = new LinearLayout() + { + LinearOrientation = LinearLayout.Orientation.Horizontal, + CellPadding = new Size(40, 40), + LinearAlignment = LinearLayout.Alignment.Center, + } }; window.Add(root); ///////////////////////////////////////////////Create by Property////////////////////////////////////////////////////////// + left = new View() + { + Size = new Size(920, 800), + Layout = new LinearLayout() + { + LinearOrientation = LinearLayout.Orientation.Vertical + } + }; + + //Create left description text. createText[0] = new TextLabel(); createText[0].Text = "Create RadioButton just by properties"; createText[0].TextColor = Color.White; - createText[0].Size2D = new Size2D(500, 100); - createText[0].Position2D = new Position2D(400, 100); - root.Add(createText[0]); + createText[0].Size = new Size(800, 100); + left.Add(createText[0]); + leftbody = new View(); + leftbody.Layout = new GridLayout() { Columns = 4 }; int num = 4; for (int i = 0; i < num; i++) { group[i] = new RadioButtonGroup(); modeText[i] = new TextLabel(); modeText[i].Text = mode[i]; - modeText[i].Size2D = new Size2D(200, 48); - modeText[i].Position2D = new Position2D(300 + 200 * i, 200); - root.Add(modeText[i]); + modeText[i].Size = new Size(200, 48); + modeText[i].HorizontalAlignment = HorizontalAlignment.Center; + modeText[i].VerticalAlignment = VerticalAlignment.Center; + leftbody.Add(modeText[i]); } for (int i = 0; i < num; i++) { + // create utility radio button. utilityRadioButton[i] = new RadioButton(); - utilityRadioButton[i].Size2D = new Size2D(48, 48); - utilityRadioButton[i].Position2D = new Position2D(300, 300 + i * 100); - utilityRadioButton[i].Style.Icon.Size = new Size(48, 48); - utilityRadioButton[i].Style.Icon.Padding.Start = 5; - utilityRadioButton[i].Style.Icon.Padding.End = 5; - utilityRadioButton[i].Style.Icon.Opacity = new Selector + var utilityStyle = utilityRadioButton[i].Style; + utilityStyle.Icon.Opacity = new Selector { Normal = 1.0f, Selected = 1.0f, Disabled = 0.4f, DisabledSelected = 0.4f }; - utilityRadioButton[i].Style.Icon.ResourceUrl = new Selector + utilityStyle.Icon.BackgroundImage = ""; + utilityStyle.Icon.ResourceUrl = new Selector { Normal = CommonResource.GetFHResourcePath() + "9. Controller/controller_btn_radio_off.png", Selected = CommonResource.GetFHResourcePath() + "9. Controller/controller_btn_radio_on.png", Disabled = CommonResource.GetFHResourcePath() + "9. Controller/controller_btn_radio_off.png", DisabledSelected = CommonResource.GetFHResourcePath() + "9. Controller/controller_btn_radio_on.png", }; - + utilityRadioButton[i].ApplyStyle(utilityStyle); + utilityRadioButton[i].Size = new Size(48, 48); + utilityRadioButton[i].ButtonIcon.Size = new Size(48, 48); group[0].Add(utilityRadioButton[i]); - //////// + + // create family radio button. familyRadioButton[i] = new RadioButton(); - familyRadioButton[i].Size2D = new Size2D(48, 48); - familyRadioButton[i].Position2D = new Position2D(500, 300 + i * 100); - familyRadioButton[i].Style.Icon.Size = new Size(48, 48); - familyRadioButton[i].Style.Icon.Padding.Start = 5; - familyRadioButton[i].Style.Icon.Padding.End = 5; - familyRadioButton[i].Style.Icon.Opacity = new Selector + var familyStyle = familyRadioButton[i].Style; + familyStyle.Icon.Opacity = new Selector { Normal = 1.0f, Selected = 1.0f, Disabled = 0.4f, DisabledSelected = 0.4f }; - familyRadioButton[i].Style.Icon.ResourceUrl = new Selector + familyStyle.Icon.BackgroundImage = ""; + familyStyle.Icon.ResourceUrl = new Selector { Normal = CommonResource.GetFHResourcePath() + "9. Controller/controller_btn_radio_off.png", Selected = CommonResource.GetFHResourcePath() + "9. Controller/[Controller] App Primary Color/controller_btn_radio_on_24c447.png", Disabled = CommonResource.GetFHResourcePath() + "9. Controller/controller_btn_radio_off.png", DisabledSelected = CommonResource.GetFHResourcePath() + "9. Controller/[Controller] App Primary Color/controller_btn_radio_on_24c447.png", }; + familyRadioButton[i].ApplyStyle(familyStyle); + familyRadioButton[i].Size = new Size(48, 48); + familyRadioButton[i].ButtonIcon.Size = new Size(48, 48); group[1].Add(familyRadioButton[i]); - ///////// + + // create food radio button. foodRadioButton[i] = new RadioButton(); - foodRadioButton[i].Size2D = new Size2D(150, 48); - foodRadioButton[i].Position2D = new Position2D(700, 300 + i * 100); - foodRadioButton[i].Style.Icon.Size = new Size(48, 48); - foodRadioButton[i].Style.Icon.Padding.Start = 5; - foodRadioButton[i].Style.Icon.Padding.End = 5; - foodRadioButton[i].Style.Icon.Opacity = new Selector + var foodStyle = foodRadioButton[i].Style; + foodStyle.Icon.Opacity = new Selector { Normal = 1.0f, Selected = 1.0f, Disabled = 0.4f, DisabledSelected = 0.4f }; - foodRadioButton[i].Style.Icon.ResourceUrl = new Selector + foodStyle.Icon.BackgroundImage = ""; + foodStyle.Icon.ResourceUrl = new Selector { Normal = CommonResource.GetFHResourcePath() + "9. Controller/controller_btn_radio_off.png", Selected = CommonResource.GetFHResourcePath() + "9. Controller/[Controller] App Primary Color/controller_btn_radio_on_ec7510.png", Disabled = CommonResource.GetFHResourcePath() + "9. Controller/controller_btn_radio_off.png", DisabledSelected = CommonResource.GetFHResourcePath() + "9. Controller/[Controller] App Primary Color/controller_btn_radio_on_ec7510.png", }; - - //foodRadioButton[i].Text = "Radio" + i; - //foodRadioButton[i].TextAlignment = HorizontalAlignment.Begin; - //foodRadioButton[i].PointSize = 12; - //foodRadioButton[i].TextPaddingLeft = 70; + foodRadioButton[i].ApplyStyle(foodStyle); + foodRadioButton[i].Size = new Size(150, 48); + foodRadioButton[i].ButtonIcon.Size = new Size(48, 48); group[2].Add(foodRadioButton[i]); - //////// + + // create kitchen radio button. kitchenRadioButton[i] = new RadioButton(); - kitchenRadioButton[i].Size2D = new Size2D(48, 48); - kitchenRadioButton[i].Position2D = new Position2D(900, 300 + i * 100); - kitchenRadioButton[i].Style.Icon.Size = new Size(48, 48); - kitchenRadioButton[i].Style.Icon.Padding.Start = 5; - kitchenRadioButton[i].Style.Icon.Padding.End = 5; - kitchenRadioButton[i].Style.Icon.Opacity = new Selector + var kitchenStyle = kitchenRadioButton[i].Style; + kitchenStyle.Icon.Opacity = new Selector { Normal = 1.0f, Selected = 1.0f, Disabled = 0.4f, DisabledSelected = 0.4f }; - kitchenRadioButton[i].Style.Icon.ResourceUrl = new Selector + kitchenStyle.Icon.BackgroundImage = ""; + kitchenStyle.Icon.ResourceUrl = new Selector { Normal = CommonResource.GetFHResourcePath() + "9. Controller/controller_btn_radio_off.png", Selected = CommonResource.GetFHResourcePath() + "9. Controller/[Controller] App Primary Color/controller_btn_radio_on_9762d9.png", Disabled = CommonResource.GetFHResourcePath() + "9. Controller/controller_btn_radio_off.png", DisabledSelected = CommonResource.GetFHResourcePath() + "9. Controller/[Controller] App Primary Color/controller_btn_radio_on_9762d9.png", }; + kitchenRadioButton[i].ApplyStyle(kitchenStyle); + kitchenRadioButton[i].Size = new Size(48, 48); + kitchenRadioButton[i].ButtonIcon.Size = new Size(48, 48); group[3].Add(kitchenRadioButton[i]); - root.Add(utilityRadioButton[i]); - root.Add(familyRadioButton[i]); - root.Add(foodRadioButton[i]); - root.Add(kitchenRadioButton[i]); + leftbody.Add(utilityRadioButton[i]); + leftbody.Add(familyRadioButton[i]); + leftbody.Add(foodRadioButton[i]); + leftbody.Add(kitchenRadioButton[i]); } - //foodRadioButton[0].LayoutDirection = ViewLayoutDirectionType.RTL; + ///////////////////////////////////////////////Create by Attributes////////////////////////////////////////////////////////// + right = new View() + { + Size = new Size(920, 800), + Layout = new LinearLayout() + { + LinearOrientation = LinearLayout.Orientation.Vertical, + } + }; + + rightbody = new View(); + rightbody.Layout = new GridLayout() { Columns = 4 }; createText[1] = new TextLabel(); - createText[1].Text = "Create RadioButton just by Attributes"; + createText[1].Text = "Create RadioButton just by styles"; createText[1].TextColor = Color.White; - createText[1].Size2D = new Size2D(500, 100); - createText[1].Position2D = new Position2D(1200, 100); - root.Add(createText[1]); + createText[1].Size = new Size(800, 100); + right.Add(createText[1]); for (int i = 0; i < num; i++) { group2[i] = new RadioButtonGroup(); modeText2[i] = new TextLabel(); modeText2[i].Text = mode[i]; - modeText2[i].Size2D = new Size2D(200, 48); - modeText2[i].Position2D = new Position2D(1100 + 200 * i, 200); - root.Add(modeText2[i]); + modeText2[i].Size = new Size(200, 48); + modeText2[i].HorizontalAlignment = HorizontalAlignment.Center; + modeText2[i].VerticalAlignment = VerticalAlignment.Center; + rightbody.Add(modeText2[i]); } - ButtonStyle utilityAttrs = new ButtonStyle + //Create utility style of radio button. + ButtonStyle utilityStyle2 = new ButtonStyle { Icon = new ImageViewStyle { @@ -204,8 +238,9 @@ namespace Tizen.NUI.Samples DisabledSelected = CommonResource.GetFHResourcePath() + "9. Controller/controller_btn_radio_on.png", }, }, - }; - ButtonStyle familyAttrs = new ButtonStyle + }; + //Create family style of radio button. + ButtonStyle familyStyle2 = new ButtonStyle { Icon = new ImageViewStyle { @@ -226,7 +261,8 @@ namespace Tizen.NUI.Samples }, }, }; - ButtonStyle foodAttrs = new ButtonStyle + //Create food style of radio button. + ButtonStyle foodStyle2 = new ButtonStyle { Icon = new ImageViewStyle { @@ -247,7 +283,8 @@ namespace Tizen.NUI.Samples }, }, }; - ButtonStyle kitchenAttrs = new ButtonStyle + //Create kitchen style of radio button. + ButtonStyle kitchenStyle2 = new ButtonStyle { Icon = new ImageViewStyle { @@ -270,32 +307,33 @@ namespace Tizen.NUI.Samples }; for (int i = 0; i < num; i++) { - utilityRadioButton2[i] = new RadioButton(utilityAttrs); - utilityRadioButton2[i].Size2D = new Size2D(48, 48); - utilityRadioButton2[i].Position2D = new Position2D(1100, 300 + i * 100); + utilityRadioButton2[i] = new RadioButton(utilityStyle2); + utilityRadioButton2[i].Size = new Size(48, 48); group2[0].Add(utilityRadioButton2[i]); - familyRadioButton2[i] = new RadioButton(familyAttrs); - familyRadioButton2[i].Size2D = new Size2D(48, 48); - familyRadioButton2[i].Position2D = new Position2D(1300, 300 + i * 100); + familyRadioButton2[i] = new RadioButton(familyStyle2); + familyRadioButton2[i].Size = new Size(48, 48); group2[1].Add(familyRadioButton2[i]); - foodRadioButton2[i] = new RadioButton(foodAttrs); - foodRadioButton2[i].Size2D = new Size2D(48, 48); - foodRadioButton2[i].Position2D = new Position2D(1500, 300 + i * 100); + foodRadioButton2[i] = new RadioButton(foodStyle2); + foodRadioButton2[i].Size = new Size(48, 48); group2[2].Add(foodRadioButton2[i]); - kitchenRadioButton2[i] = new RadioButton(kitchenAttrs); - kitchenRadioButton2[i].Size2D = new Size2D(48, 48); - kitchenRadioButton2[i].Position2D = new Position2D(1700, 300 + i * 100); + kitchenRadioButton2[i] = new RadioButton(kitchenStyle2); + kitchenRadioButton2[i].Size = new Size(48, 48); group2[3].Add(kitchenRadioButton2[i]); - root.Add(utilityRadioButton2[i]); - root.Add(familyRadioButton2[i]); - root.Add(foodRadioButton2[i]); - root.Add(kitchenRadioButton2[i]); + rightbody.Add(utilityRadioButton2[i]); + rightbody.Add(familyRadioButton2[i]); + rightbody.Add(foodRadioButton2[i]); + rightbody.Add(kitchenRadioButton2[i]); } + root.Add(left); + root.Add(right); + left.Add(leftbody); + right.Add(rightbody); + utilityRadioButton[2].IsEnabled = false; familyRadioButton[2].IsEnabled = false; foodRadioButton[2].IsEnabled = false; @@ -332,56 +370,69 @@ namespace Tizen.NUI.Samples int num = 4; for (int i = 0; i < num; i++) { - root.Remove(utilityRadioButton[i]); + leftbody.Remove(utilityRadioButton[i]); utilityRadioButton[i].Dispose(); utilityRadioButton[i] = null; - root.Remove(familyRadioButton[i]); + leftbody.Remove(familyRadioButton[i]); familyRadioButton[i].Dispose(); familyRadioButton[i] = null; - root.Remove(foodRadioButton[i]); + leftbody.Remove(foodRadioButton[i]); foodRadioButton[i].Dispose(); foodRadioButton[i] = null; - root.Remove(kitchenRadioButton[i]); + leftbody.Remove(kitchenRadioButton[i]); kitchenRadioButton[i].Dispose(); kitchenRadioButton[i] = null; - root.Remove(modeText[i]); + leftbody.Remove(modeText[i]); modeText[i].Dispose(); modeText[i] = null; - root.Remove(utilityRadioButton2[i]); + rightbody.Remove(utilityRadioButton2[i]); utilityRadioButton2[i].Dispose(); utilityRadioButton2[i] = null; - root.Remove(familyRadioButton2[i]); + rightbody.Remove(familyRadioButton2[i]); familyRadioButton2[i].Dispose(); familyRadioButton2[i] = null; - root.Remove(foodRadioButton2[i]); + rightbody.Remove(foodRadioButton2[i]); foodRadioButton2[i].Dispose(); foodRadioButton2[i] = null; - root.Remove(kitchenRadioButton2[i]); + rightbody.Remove(kitchenRadioButton2[i]); kitchenRadioButton2[i].Dispose(); kitchenRadioButton2[i] = null; - root.Remove(modeText2[i]); + rightbody.Remove(modeText2[i]); modeText2[i].Dispose(); modeText2[i] = null; } - root.Remove(createText[0]); + left.Remove(createText[0]); createText[0].Dispose(); createText[0] = null; - root.Remove(createText[1]); + left.Remove(leftbody); + leftbody.Dispose(); + leftbody = null; + right.Remove(createText[1]); createText[1].Dispose(); createText[1] = null; - + right.Remove(rightbody); + rightbody.Dispose(); + rightbody = null; + + root.Remove(left); + left.Dispose(); + left = null; + root.Remove(right); + right.Dispose(); + right = null; NUIApplication.GetDefaultWindow().Remove(root); root.Dispose(); + root = null; } } } diff --git a/test/Tizen.NUI.Samples/Tizen.NUI.Samples/Samples/ScrollBarSample.cs b/test/Tizen.NUI.Samples/Tizen.NUI.Samples/Samples/ScrollBarSample.cs index 429b4f4..4d3d94e 100755 --- a/test/Tizen.NUI.Samples/Tizen.NUI.Samples/Samples/ScrollBarSample.cs +++ b/test/Tizen.NUI.Samples/Tizen.NUI.Samples/Samples/ScrollBarSample.cs @@ -6,47 +6,97 @@ namespace Tizen.NUI.Samples { public class ScrollbarSample : IExample { - private TextLabel board1, board2, board; - private Button button1, button2, button3, button4, button5; - private ScrollBar scrollBar1_1, scrollBar1_2, scrollBar2_1, scrollBar2_2; //1-null para 2-attributes; X_1-color; X_2 image track + private TextLabel text_nullstyle, text_style; + private Button[] button = new Button[4]; + private ScrollBar[] scrollBar = new ScrollBar[3]; private View root; + private View top_parent, bottom_parent, null_style_parent, style_parent; public void Activate() { Window window = NUIApplication.GetDefaultWindow(); - root = new View() { - Size2D = new Size2D(1920, 1080), + Size = new Size(1920, 1080), + BackgroundColor = new Color(0.7f, 0.9f, 0.8f, 1.0f), }; + root.Layout = new LinearLayout() { LinearOrientation = LinearLayout.Orientation.Vertical }; + window.Add(root); + + // TextLabel of Null style construction and Style construction + CreateTopView(); + + // Buttons for moving thumbnail + CreateBottomView(); + } + private void CreateTopView() + { + top_parent = new View() { Size = new Size(1920, 540) }; + top_parent.Layout = new LinearLayout() { LinearOrientation = LinearLayout.Orientation.Horizontal }; + root.Add(top_parent); + CreateNullStylePart(); + CreateStylePart(); + } + + private void CreateNullStylePart() + { + null_style_parent = new View() { Size = new Size(960, 540) }; + null_style_parent.Layout = new LinearLayout() { LinearOrientation = LinearLayout.Orientation.Vertical, LinearAlignment = LinearLayout.Alignment.Center, CellPadding = new Size2D(0, 50) }; + top_parent.Add(null_style_parent); + + // Add Textlabel of "Null style construction" + text_nullstyle = new TextLabel(); + text_nullstyle.Size = new Size(400, 70); + text_nullstyle.PointSize = 20; + text_nullstyle.HorizontalAlignment = HorizontalAlignment.Center; + text_nullstyle.VerticalAlignment = VerticalAlignment.Center; + text_nullstyle.BackgroundColor = Color.Magenta; + text_nullstyle.Text = "Null style construction"; + text_nullstyle.Focusable = true; + null_style_parent.Add(text_nullstyle); + + // Add ScrollBar of Null style construction + scrollBar[0] = new ScrollBar(); + scrollBar[0].Size = new Size(400, 4); + scrollBar[0].TrackColor = Color.Green; + scrollBar[0].MaxValue = (int)scrollBar[0].SizeWidth / 10; + scrollBar[0].MinValue = 0; + scrollBar[0].ThumbSize = new Size(30, 4); + scrollBar[0].CurrentValue = 0; //set after thumbsize + scrollBar[0].ThumbColor = Color.Black; + null_style_parent.Add(scrollBar[0]); + + scrollBar[1] = new ScrollBar(); + scrollBar[1].Size = new Size(400, 4); + scrollBar[1].TrackColor = Color.Green; + scrollBar[1].MaxValue = (int)scrollBar[1].SizeWidth / 10; + scrollBar[1].MinValue = 0; + scrollBar[1].ThumbSize = new Size(30, 4); + scrollBar[1].CurrentValue = 0;//set after thumbsize + scrollBar[1].ThumbColor = Color.Yellow; + scrollBar[1].TrackImageURL = CommonResource.GetTVResourcePath() + "component/c_progressbar/c_progressbar_white_buffering.png"; + null_style_parent.Add(scrollBar[1]); + } + + private void CreateStylePart() + { + style_parent = new View() { Size = new Size(960, 540) }; + style_parent.Layout = new LinearLayout() { LinearOrientation = LinearLayout.Orientation.Vertical, LinearAlignment = LinearLayout.Alignment.CenterVertical, CellPadding = new Size2D(0, 50) }; + top_parent.Add(style_parent); + + // Add Textlabel of "Style construction" + text_style = new TextLabel(); + text_style.Size = new Size(400, 70); + text_style.PointSize = 20; + text_style.HorizontalAlignment = HorizontalAlignment.Center; + text_style.VerticalAlignment = VerticalAlignment.Center; + text_style.BackgroundColor = Color.Magenta; + text_style.Text = "Style construction"; + text_style.Focusable = true; + style_parent.Add(text_style); - CreateBoardAndButtons(); - - scrollBar1_1 = new ScrollBar(); - scrollBar1_1.Position2D = new Position2D(50, 300); - scrollBar1_1.Size2D = new Size2D(300, 4); - scrollBar1_1.Style.Track.BackgroundColor = Color.Green; - scrollBar1_1.MaxValue = (int)scrollBar1_1.SizeWidth / 10; - scrollBar1_1.MinValue = 0; - scrollBar1_1.Style.Thumb.Size = new Size(30, 4); - scrollBar1_1.CurrentValue = 0; //set after thumbsize - scrollBar1_1.Style.Thumb.BackgroundColor = Color.Black; - root.Add(scrollBar1_1); - - scrollBar1_2 = new ScrollBar(); - scrollBar1_2.Position2D = new Position2D(50, 400); - scrollBar1_2.Size2D = new Size2D(300, 4); - scrollBar1_2.Style.Track.BackgroundColor = Color.Green; - scrollBar1_2.MaxValue = (int)scrollBar1_2.SizeWidth / 10; - scrollBar1_2.MinValue = 0; - scrollBar1_2.Style.Thumb.Size = new Size(30, 4); - scrollBar1_2.CurrentValue = 0;//set after thumbsize - scrollBar1_2.Style.Thumb.BackgroundColor = Color.Yellow; - scrollBar1_2.Style.Track.ResourceUrl = CommonResource.GetTVResourcePath() + "component/c_progressbar/c_progressbar_white_buffering.png"; - - root.Add(scrollBar1_2); - - ScrollBarStyle attr = new ScrollBarStyle + // Add ScrollBar of Style construction + ScrollBarStyle st = new ScrollBarStyle { Track = new ImageViewStyle { @@ -63,180 +113,149 @@ namespace Tizen.NUI.Samples } }, }; - - scrollBar2_1 = new ScrollBar(attr); - scrollBar2_1.Position2D = new Position2D(500, 300); - scrollBar2_1.Size2D = new Size2D(300, 4); - scrollBar2_1.MaxValue = (int)scrollBar2_1.SizeWidth / 10; - scrollBar2_1.MinValue = 0; - scrollBar2_1.Style.Thumb.Size = new Size(30, 4); - scrollBar2_1.CurrentValue = 0; //set after thumbsize - root.Add(scrollBar2_1); - - board.UpFocusableView = button1; - - window.Add(root); - - FocusManager.Instance.SetCurrentFocusView(button1); + scrollBar[2] = new ScrollBar(st); + scrollBar[2].Size = new Size(400, 4); + scrollBar[2].MaxValue = (int)scrollBar[2].SizeWidth / 10; + scrollBar[2].MinValue = 0; + scrollBar[2].ThumbSize = new Size(30, 4); + scrollBar[2].CurrentValue = 0;//set after thumbsize + style_parent.Add(scrollBar[2]); } - void CreateBoardAndButtons() + private void CreateBottomView() { + bottom_parent = new View() { Size = new Size(1920, 540) }; + bottom_parent.Layout = new LinearLayout() { LinearOrientation = LinearLayout.Orientation.Horizontal, LinearAlignment = LinearLayout.Alignment.Center, CellPadding = new Size2D(50, 50) }; + root.Add(bottom_parent); - board = new TextLabel(); - board.Size2D = new Size2D(1000, 100); - board.Position2D = new Position2D(430, 900); - board.PointSize = 30; - board.HorizontalAlignment = HorizontalAlignment.Center; - board.VerticalAlignment = VerticalAlignment.Center; - board.BackgroundColor = Color.Magenta; - board.Text = "log pad"; - root.Add(board); - board.Focusable = true; - board.FocusGained += Board_FocusGained; - board.FocusLost += Board_FocusLost; - - board1 = new TextLabel(); - board1.Size2D = new Size2D(300, 70); - board1.Position2D = new Position2D(50, 150); - board1.PointSize = 20; - board1.HorizontalAlignment = HorizontalAlignment.Center; - board1.VerticalAlignment = VerticalAlignment.Center; - board1.BackgroundColor = Color.Magenta; - board1.Text = "NULL parameter construction"; - root.Add(board1); - board1.Focusable = true; - board1.FocusGained += Board_FocusGained; - board1.FocusLost += Board_FocusLost; - - board2 = new TextLabel(); - board2.Size2D = new Size2D(300, 70); - board2.Position2D = new Position2D(500, 150); - board2.PointSize = 20; - board2.HorizontalAlignment = HorizontalAlignment.Center; - board2.VerticalAlignment = VerticalAlignment.Center; - board2.BackgroundColor = Color.Magenta; - board2.Text = "Attribute construction"; - root.Add(board2); - board2.Focusable = true; - board2.FocusGained += Board_FocusGained; - board2.FocusLost += Board_FocusLost; - - button1 = new Button(); - button1.BackgroundColor = Color.Green; - button1.Position2D = new Position2D(100, 700); - button1.Size2D = new Size2D(80, 50); - button1.Style.Text.Text = "+"; - root.Add(button1); - button1.Focusable = true; - button1.ClickEvent += Scroll1Add; - - button2 = new Button(); - button2.BackgroundColor = Color.Green; - button2.Position2D = new Position2D(200, 700); - button2.Size2D = new Size2D(80, 50); - button2.Style.Text.Text = "-"; - root.Add(button2); - button2.Focusable = true; - button2.ClickEvent += Scroll1Minus; - - button5 = new Button(); - button5.BackgroundColor = Color.Green; - button5.Position2D = new Position2D(400, 800); - button5.Size2D = new Size2D(100, 50); - button5.Style.Text.Text = "+ / - 4"; - root.Add(button5); - button5.Focusable = true; - button5.ClickEvent += Scroll1_2move; - - Button button22 = new Button(); - button22.BackgroundColor = Color.Green; - button22.Position2D = new Position2D(100, 800); - button22.Size2D = new Size2D(200, 50); - button22.Style.Text.Text = "change direction"; - root.Add(button22); - button22.Focusable = true; - button22.ClickEvent += Scroll1_2Changed; - - button3 = new Button(); - button3.BackgroundColor = Color.Green; - button3.Position2D = new Position2D(450, 700); - button3.Size2D = new Size2D(80, 50); - button3.Style.Text.Text = "+"; - root.Add(button3); - button3.Focusable = true; - button3.ClickEvent += Scroll2Add; - - button4 = new Button(); - button4.BackgroundColor = Color.Green; - button4.Position2D = new Position2D(550, 700); - button4.Size2D = new Size2D(80, 50); - button4.Style.Text.Text = "-"; - root.Add(button4); - button4.Focusable = true; - button4.ClickEvent += Scroll2Minus; + // Create buttons + CreateButtons(); } - private void Board_FocusLost(object sender, global::System.EventArgs e) + void CreateButtons() { - board.BackgroundColor = Color.Magenta; - } + for (int i = 0; i < 4; i++) + { + button[i] = new Button(); + button[i].BackgroundColor = Color.Green; + button[i].Size = new Size(80, 50); + button[i].Focusable = true; + bottom_parent.Add(button[i]); + } - private void Board_FocusGained(object sender, global::System.EventArgs e) - { - board.BackgroundColor = Color.Cyan; + button[0].Text = "+"; + button[0].ClickEvent += Scroll1Add; + + button[1].Text = "-"; + button[1].ClickEvent += Scroll1Minus; + + button[2].Text = "+ / - 4"; + button[2].ClickEvent += Scroll1_2move; + + button[3].Text = "change direction"; + button[3].ClickEvent += Scroll1_2Changed; + button[3].Size = new Size(180, 50); + + // Set focus to Add Button + FocusManager.Instance.SetCurrentFocusView(button[0]); } private void Scroll1Add(object sender, global::System.EventArgs e) { - scrollBar1_1.CurrentValue++; + scrollBar[0].CurrentValue++; + scrollBar[2].CurrentValue++; } private void Scroll1Minus(object sender, global::System.EventArgs e) { - scrollBar1_1.CurrentValue--; - } - private void Scroll2Add(object sender, global::System.EventArgs e) - { - scrollBar2_1.CurrentValue++; - } - private void Scroll2Minus(object sender, global::System.EventArgs e) - { - scrollBar2_1.CurrentValue--; + scrollBar[0].CurrentValue--; + scrollBar[2].CurrentValue--; } private void Scroll1_2Changed(object sender, global::System.EventArgs e) { - if(scrollBar1_2.LayoutDirection == ViewLayoutDirectionType.LTR) - scrollBar1_2.LayoutDirection= ViewLayoutDirectionType.RTL; + if (scrollBar[1].LayoutDirection == ViewLayoutDirectionType.LTR) + { + scrollBar[1].LayoutDirection = ViewLayoutDirectionType.RTL; + } else - scrollBar1_2.LayoutDirection = ViewLayoutDirectionType.LTR; + { + scrollBar[1].LayoutDirection = ViewLayoutDirectionType.LTR; + } } private void Scroll1_2move(object sender, global::System.EventArgs e) { - if (scrollBar1_2.CurrentValue < scrollBar1_2.MaxValue / 2) + if (scrollBar[1].CurrentValue < scrollBar[1].MaxValue / 2) { - scrollBar1_2.SetCurrentValue(scrollBar1_2.MaxValue - 2); + scrollBar[1].SetCurrentValue(scrollBar[1].MaxValue - 2); } else { - scrollBar1_2.SetCurrentValue(2); + scrollBar[1].SetCurrentValue(2); } } - private void ScrollPan(object sender, global::System.EventArgs e) - { - board.Text = board.Text + " 1"; - if (board.Text.Length > 20) - board.Text = ""; - } - public void Deactivate() { if (root != null) { NUIApplication.GetDefaultWindow().Remove(root); + if (text_nullstyle != null) + { + text_nullstyle.Dispose(); + text_nullstyle = null; + } + + if (text_style != null) + { + text_style.Dispose(); + text_style = null; + } + + for (int i = 0; i < 4; i++) + { + if (button[i] != null) + { + button[i].Dispose(); + button[i] = null; + } + } + + for (int i = 0; i < 3; i++) + { + if (scrollBar[i] != null) + { + scrollBar[i].Dispose(); + scrollBar[i] = null; + } + } + + if (top_parent != null) + { + top_parent.Dispose(); + top_parent = null; + } + + if (bottom_parent != null) + { + bottom_parent.Dispose(); + bottom_parent = null; + } + + if (null_style_parent != null) + { + null_style_parent.Dispose(); + null_style_parent = null; + } + + if (style_parent != null) + { + style_parent.Dispose(); + style_parent = null; + } + root.Dispose(); + root = null; } } } diff --git a/test/Tizen.NUI.Samples/Tizen.NUI.Samples/Samples/SliderSample.cs b/test/Tizen.NUI.Samples/Tizen.NUI.Samples/Samples/SliderSample.cs index 1f94510..fbd5e94 100755 --- a/test/Tizen.NUI.Samples/Tizen.NUI.Samples/Samples/SliderSample.cs +++ b/test/Tizen.NUI.Samples/Tizen.NUI.Samples/Samples/SliderSample.cs @@ -9,10 +9,11 @@ namespace Tizen.NUI.Samples private const float MAX_VALUE = 100; private View root; + private View top_parent, bottom_parent, ver_slider_parent, hori_slider_parent; private TextLabel[] createText = new TextLabel[2]; - private Slider[] slider = new Slider[4]; - private Slider[] slider2 = new Slider[4]; private TextLabel[] inforText = new TextLabel[2]; + private Slider[] slider_null_style = new Slider[4]; + private Slider[] slider_style = new Slider[4]; public void Activate() { @@ -20,41 +21,33 @@ namespace Tizen.NUI.Samples root = new View() { - Size2D = new Size2D(1920, 1080), + Size = new Size(1920, 1080), + BackgroundColor = new Color(0.7f, 0.9f, 0.8f, 1.0f), }; + root.Layout = new LinearLayout() { LinearOrientation = LinearLayout.Orientation.Vertical }; window.Add(root); - CreateInforText(); - - ///////////////////////////////////////////////Create by Property////////////////////////////////////////////////////////// - createText[0] = new TextLabel(); - createText[0].Text = "Create Slider just by properties"; - createText[0].TextColor = Color.White; - createText[0].Size2D = new Size2D(450, 100); - createText[0].Position2D = new Position2D(200, 100); - createText[0].MultiLine = true; - root.Add(createText[0]); - - slider[0] = CreateByProperty(40, 300, 800, 50, 20, Slider.DirectionType.Horizontal); - slider[1] = CreateByProperty(300, 450, 50, 400, 20, Slider.DirectionType.Vertical); - - slider[2] = CreateByProperty(40, 400, 800, 50, 30, Slider.DirectionType.Horizontal); - slider[2].Style.LowIndicator.Text = "SubText"; - slider[2].LowIndicatorSize = new Size(100, 40); - - slider[3] = CreateByProperty(600, 450, 50, 400, 30, Slider.DirectionType.Vertical); - slider[3].Style.LowIndicator.Text = "SubText"; - slider[3].LowIndicatorSize = new Size(100, 40); - - /////////////////////////////////////////////Create by Attributes////////////////////////////////////////////////////////// - createText[1] = new TextLabel(); - createText[1].TextColor = Color.White; - createText[1].Text = "Create Slider just by Attributes"; - createText[1].Size2D = new Size2D(450, 100); - createText[1].Position2D = new Position2D(1000, 100); - createText[1].MultiLine = true; - root.Add(createText[1]); - - SliderStyle attributes = new SliderStyle + + // Textlabel of Null style construction/Style construction and infoText + CreateTopView(); + + // Various kinds of Slider + CreateBottomView(); + } + + private void InitSliders() + { + // Null style construction + slider_null_style[0] = CreateByProperty(800, 50, 20, Slider.DirectionType.Horizontal); + slider_null_style[1] = CreateByProperty(800, 50, 30, Slider.DirectionType.Horizontal); + slider_null_style[1].LowIndicatorText.Text = "SubText"; + slider_null_style[1].LowIndicatorSize = new Size(100, 40); + slider_null_style[2] = CreateByProperty(50, 400, 20, Slider.DirectionType.Vertical); + slider_null_style[3] = CreateByProperty(50, 400, 30, Slider.DirectionType.Vertical); + slider_null_style[3].LowIndicatorText.Text = "SubText"; + slider_null_style[3].LowIndicatorSize = new Size(100, 40); + + // Style construction + SliderStyle st = new SliderStyle { TrackThickness = 4, Track = new ImageViewStyle @@ -86,125 +79,187 @@ namespace Tizen.NUI.Samples Normal = "", Pressed = CommonResource.GetFHResourcePath() + "9. Controller/controller_btn_slide_handler_effect.png", } - }, - //ThumbBackground = new ImageViewStyle - //{ - // Size = new Size(60, 60), - // ResourceUrl = new Selector - // { - // Normal = "", - // Pressed = CommonResource.GetFHResourcePath() + "9. Controller/controller_btn_slide_handler_effect.png", - // } - //} + } }; + slider_style[0] = CreateByStyle(st, 800, 50, 20, Slider.DirectionType.Horizontal); + slider_style[1] = CreateByStyle(st, 800, 50, 30, Slider.DirectionType.Horizontal); + slider_style[1].LowIndicatorText.Text = "SubText"; + slider_style[1].LowIndicatorSize = new Size(100, 40); + slider_style[2] = CreateByStyle(st, 50, 400, 20, Slider.DirectionType.Vertical); + slider_style[3] = CreateByStyle(st, 50, 400, 30, Slider.DirectionType.Vertical); + slider_style[3].LowIndicatorText.Text = "SubText"; + slider_style[3].LowIndicatorSize = new Size(100, 40); + } + + private void CreateTopView() + { + top_parent = new View() { Size = new Size(1920, 240) }; + top_parent.Layout = new GridLayout() { Rows = 2, GridOrientation = GridLayout.Orientation.Horizontal }; + root.Add(top_parent); + + for (int i = 0; i < 2; i++) + { + createText[i] = new TextLabel(); + createText[i].PointSize = 20; + createText[i].TextColor = Color.Black; + createText[i].Size = new Size(600, 100); + createText[i].Margin = new Extents(200, 100, 40, 0); + createText[i].BackgroundColor = Color.Magenta; + createText[i].HorizontalAlignment = HorizontalAlignment.Center; + createText[i].VerticalAlignment = VerticalAlignment.Center; + top_parent.Add(createText[i]); + + inforText[i] = new TextLabel(); + inforText[i].PointSize = 20; + inforText[i].TextColor = Color.Blue; + inforText[i].Text = "currentValue = "; + inforText[i].BackgroundColor = new Color(0, 0, 0, 0.1f); + inforText[i].HorizontalAlignment = HorizontalAlignment.Center; + inforText[i].VerticalAlignment = VerticalAlignment.Center; + top_parent.Add(inforText[i]); + } + + // TextLabel of "Null style construction" + createText[0].Text = "Null style constructions"; + + // TextLabel of "Style construction" + createText[1].Text = "Style construction"; + } + + private void CreateBottomView() + { + bottom_parent = new View() { Size = new Size(1920, 840) }; + bottom_parent.Layout = new LinearLayout() { LinearOrientation = LinearLayout.Orientation.Vertical, CellPadding = new Size2D(0, 0) }; + root.Add(bottom_parent); - slider2[0] = CreateByAttributes(attributes, 890, 300, 800, 50, 20, Slider.DirectionType.Horizontal); - slider2[1] = CreateByAttributes(attributes, 1150, 450, 50, 400, 20, Slider.DirectionType.Vertical); + // Init Sliders + InitSliders(); - slider2[2] = CreateByAttributes(attributes, 890, 400, 800, 50, 30, Slider.DirectionType.Horizontal); - slider2[2].Style.LowIndicator.Text = "SubText"; - slider2[2].LowIndicatorSize = new Size(100, 40); + // Add Horizontal Slider + hori_slider_parent = new View() { Size = new Size(1920, 160) }; + hori_slider_parent.Layout = new GridLayout() { Rows = 2, GridOrientation = GridLayout.Orientation.Horizontal }; + bottom_parent.Add(hori_slider_parent); + slider_null_style[0].Margin = new Extents(100, 0, 30, 0); + hori_slider_parent.Add(slider_null_style[0]); + hori_slider_parent.Add(slider_null_style[1]); + hori_slider_parent.Add(slider_style[0]); + hori_slider_parent.Add(slider_style[1]); - slider2[3] = CreateByAttributes(attributes, 1450, 450, 50, 400, 30, Slider.DirectionType.Vertical); - slider2[3].Style.LowIndicator.Text = "SubText"; - slider2[3].LowIndicatorSize = new Size(100, 40); + // Add vertical Slider + ver_slider_parent = new View() { Size = new Size(1920, 680) }; + ver_slider_parent.Layout = new LinearLayout() { LinearOrientation = LinearLayout.Orientation.Horizontal, LinearAlignment = LinearLayout.Alignment.CenterVertical, CellPadding = new Size2D(200, 0) }; + bottom_parent.Add(ver_slider_parent); + slider_null_style[2].Margin = new Extents(350, 0, 0, 0); + slider_style[2].Margin = new Extents(400, 0, 0, 0); + ver_slider_parent.Add(slider_null_style[2]); + ver_slider_parent.Add(slider_null_style[3]); + ver_slider_parent.Add(slider_style[2]); + ver_slider_parent.Add(slider_style[3]); } public void Deactivate() { if (root != null) { - for (int i = 0; i < 3; i++) - { - if (slider[i] != null) - { - root.Remove(slider[i]); - slider[i].Dispose(); - slider[i] = null; - } - if (slider2[i] != null) - { - root.Remove(slider2[i]); - slider2[i].Dispose(); - slider2[i] = null; - } - } - + NUIApplication.GetDefaultWindow().Remove(root); for (int i = 0; i < 2; i++) { if (createText[i] != null) { - root.Remove(createText[i]); createText[i].Dispose(); createText[i] = null; } if (inforText[i] != null) { - root.Remove(inforText[i]); inforText[i].Dispose(); inforText[i] = null; } } - - NUIApplication.GetDefaultWindow().Remove(root); + + for (int j = 0; j < 4; j++) + { + if (slider_null_style[j] != null) + { + slider_null_style[j].Dispose(); + slider_null_style[j] = null; + } + + if (slider_style[j] != null) + { + slider_style[j].Dispose(); + slider_style[j] = null; + } + } + + if (top_parent != null) + { + top_parent.Dispose(); + top_parent = null; + } + + if (bottom_parent != null) + { + bottom_parent.Dispose(); + bottom_parent = null; + } + + if (ver_slider_parent != null) + { + ver_slider_parent.Dispose(); + ver_slider_parent = null; + } + + if (hori_slider_parent != null) + { + hori_slider_parent.Dispose(); + hori_slider_parent = null; + } root.Dispose(); root = null; } } - private void CreateInforText() + private Slider CreateByProperty(int w, int h, int curValue, Slider.DirectionType dir) { - for (int i = 0; i < 2; i++) - { - inforText[i] = new TextLabel(); - inforText[i].Size2D = new Size2D(450, 60); - inforText[i].Position2D = new Position2D(200 + 800 * i, 200); - inforText[i].PointSize = 20; - inforText[i].TextColor = Color.Blue; - inforText[i].Text = "currentValue = "; - inforText[i].BackgroundColor = new Color(0, 0, 0, 0.1f); - inforText[i].HorizontalAlignment = HorizontalAlignment.Center; - inforText[i].VerticalAlignment = VerticalAlignment.Center; - root.Add(inforText[i]); - } - } - - private Slider CreateByProperty(int posX, int posY, int w, int h, int curValue, Slider.DirectionType dir) - { - Slider source = new Slider(); - source.TrackThickness = 4; - source.Style.Track.BackgroundColor = new Color(0, 0, 0, 0.1f); - source.Style.Progress.BackgroundColor = new Color(0.05f, 0.63f, 0.9f, 1); - source.Style.Thumb.ResourceUrl = new Selector - { - Normal = CommonResource.GetFHResourcePath() + "9. Controller/controller_btn_slide_handler_normal.png", - Pressed = CommonResource.GetFHResourcePath() + "9. Controller/controller_btn_slide_handler_press.png", - }; - source.Style.Thumb.Size = new Size(60, 60); - source.Style.Thumb.BackgroundImage = new Selector + // Setting the property of selector is not supported now, so add these in style first. + SliderStyle st = new SliderStyle { - Normal = "", - Pressed = CommonResource.GetFHResourcePath() + "9. Controller/controller_btn_slide_handler_effect.png", + Thumb = new ImageViewStyle() + { + ResourceUrl = new Selector + { + Normal = CommonResource.GetFHResourcePath() + "9. Controller/controller_btn_slide_handler_normal.png", + Pressed = CommonResource.GetFHResourcePath() + "9. Controller/controller_btn_slide_handler_press.png", + }, + BackgroundImage = new Selector + { + Normal = "", + Pressed = CommonResource.GetFHResourcePath() + "9. Controller/controller_btn_slide_handler_effect.png", + } + } }; + Slider source = new Slider(st); + source.TrackThickness = 4; + source.ThumbSize = new Size(60, 60); + source.BgTrackColor = new Color(0, 0, 0, 0.1f); + source.SlidedTrackColor = new Color(0.05f, 0.63f, 0.9f, 1); source.Direction = dir; - root.Add(source); source.Focusable = true; source.MinValue = MIN_VALUE; source.MaxValue = MAX_VALUE; source.StateChangedEvent += OnStateChanged; source.ValueChangedEvent += OnValueChanged; source.SlidingFinishedEvent += OnSlidingFinished; - - source.Position2D = new Position2D(posX, posY); - source.Size2D = new Size2D(w, h); + source.Size = new Size(w, h); source.CurrentValue = curValue; return source; } - private Slider CreateByAttributes(SliderStyle attrs, int posX, int posY, int w, int h, int curValue, Slider.DirectionType dir) + private Slider CreateByStyle(SliderStyle st, int w, int h, int curValue, Slider.DirectionType dir) { - Slider source = new Slider(attrs); + // input style in construction + Slider source = new Slider(st); source.Direction = dir; root.Add(source); source.Focusable = true; @@ -213,9 +268,7 @@ namespace Tizen.NUI.Samples source.StateChangedEvent += OnStateChanged; source.ValueChangedEvent += OnValueChanged; source.SlidingFinishedEvent += OnSlidingFinished; - - source.Position2D = new Position2D(posX, posY); - source.Size2D = new Size2D(w, h); + source.Size = new Size(w, h); source.CurrentValue = curValue; return source; } @@ -225,7 +278,7 @@ namespace Tizen.NUI.Samples Slider source = sender as Slider; if (source != null) { - if (source == slider2[0] || source == slider2[1] || source == slider2[2] || source == slider2[3]) + if (source == slider_style[0] || source == slider_style[1] || source == slider_style[2] || source == slider_style[3]) { inforText[1].Text = "currentValue = " + args.CurrentValue; } @@ -241,7 +294,7 @@ namespace Tizen.NUI.Samples Slider source = sender as Slider; if (source != null) { - if (source == slider2[0] || source == slider2[1] || source == slider2[2] || source == slider2[3]) + if (source == slider_style[0] || source == slider_style[1] || source == slider_style[2] || source == slider_style[3]) { inforText[1].Text = "Finished currentValue = " + args.CurrentValue; } diff --git a/test/Tizen.NUI.Samples/Tizen.NUI.Samples/Samples/SwitchSample.cs b/test/Tizen.NUI.Samples/Tizen.NUI.Samples/Samples/SwitchSample.cs index 3374af9..33c1502 100755 --- a/test/Tizen.NUI.Samples/Tizen.NUI.Samples/Samples/SwitchSample.cs +++ b/test/Tizen.NUI.Samples/Tizen.NUI.Samples/Samples/SwitchSample.cs @@ -7,7 +7,7 @@ namespace Tizen.NUI.Samples public class SwitchSample : IExample { private View root; - + private View[] parentView = new View[3]; private TextLabel[] createText = new TextLabel[2]; private TextLabel[] modeText = new TextLabel[4]; private TextLabel[] modeText2 = new TextLabel[4]; @@ -21,7 +21,6 @@ namespace Tizen.NUI.Samples private Switch[] familySwitch2 = new Switch[4]; private Switch[] foodSwitch2 = new Switch[4]; private Switch[] kitchenSwitch2 = new Switch[4]; - private static string[] mode = new string[] { "Utility", @@ -29,137 +28,92 @@ namespace Tizen.NUI.Samples "Food", "Kitchen", }; + public void Activate() { Window window = NUIApplication.GetDefaultWindow(); root = new View() { - Size2D = new Size2D(1920, 1080), + Size = new Size(1920, 1080), + BackgroundColor = new Color(0.7f, 0.9f, 0.8f, 1.0f), }; + root.Layout = new LinearLayout() { LinearOrientation = LinearLayout.Orientation.Vertical }; window.Add(root); - ///////////////////////////////////////////////Create by Property////////////////////////////////////////////////////////// - createText[0] = new TextLabel(); - createText[0].Text = "Create Switch just by properties"; - createText[0].Size2D = new Size2D(500, 100); - createText[0].Position2D = new Position2D(400, 100); - root.Add(createText[0]); - - int num = 4; - for (int i = 0; i < num; i++) + CreateTextView(); + CreateModeView(); + CreateSwitchView(); + } + + private void CreateTextView() + { + // Init parent of TextView + parentView[0] = new View(); + parentView[0].Size = new Size(1920, 200); + parentView[0].Layout = new LinearLayout() { LinearOrientation = LinearLayout.Orientation.Horizontal, LinearAlignment = LinearLayout.Alignment.CenterVertical, CellPadding = new Size2D(180, 0) }; + root.Add(parentView[0]); + + for (int i = 0; i < 2; i++) { - modeText[i] = new TextLabel(); - modeText[i].Text = mode[i]; - modeText[i].Size2D = new Size2D(200, 48); - modeText[i].Position2D = new Position2D(300 + 200 * i, 200); - root.Add(modeText[i]); + createText[i] = new TextLabel(); + createText[i].Size = new Size(600, 100); + createText[i].PointSize = 20.0f; + createText[i].BackgroundColor = Color.Magenta; + createText[i].HorizontalAlignment = HorizontalAlignment.Center; + createText[i].VerticalAlignment = VerticalAlignment.Center; + parentView[0].Add(createText[i]); } - for (int i = 0; i < num; i++) - { - utilitySwitch[i] = new Switch(); - utilitySwitch[i].Size2D = new Size2D(96, 60); - utilitySwitch[i].Position2D = new Position2D(300, 300 + i * 100); - utilitySwitch[i].Style.Thumb.Size = new Size(60, 60); - utilitySwitch[i].Style.Track.ResourceUrl = new Selector - { - Normal = CommonResource.GetFHResourcePath() + "9. Controller/controller_switch_bg_off.png", - Selected = CommonResource.GetFHResourcePath() + "9. Controller/controller_switch_bg_on.png", - Disabled = CommonResource.GetFHResourcePath() + "9. Controller/controller_switch_bg_off_dim.png", - DisabledSelected = CommonResource.GetFHResourcePath() + "9. Controller/controller_switch_bg_on_dim.png", - }; - utilitySwitch[i].Style.Thumb.ResourceUrl = new Selector - { - Normal = CommonResource.GetFHResourcePath() + "9. Controller/controller_switch_handler.png", - Selected = CommonResource.GetFHResourcePath() + "9. Controller/controller_switch_handler.png", - Disabled = CommonResource.GetFHResourcePath() + "9. Controller/controller_switch_handler_dim.png", - DisabledSelected = CommonResource.GetFHResourcePath() + "9. Controller/controller_switch_handler_dim.png", - }; + // Text of "Create Switch just by properties" + createText[0].Text = "Create Switch just by Properties"; + createText[0].Margin = new Extents(160, 0, 0, 0); - //////// - familySwitch[i] = new Switch(); - familySwitch[i].Size2D = new Size2D(96, 60); - familySwitch[i].Position2D = new Position2D(500, 300 + i * 100); - familySwitch[i].Style.Thumb.Size = new Size(60, 60); - familySwitch[i].Style.Track.ResourceUrl = new Selector - { - Normal = CommonResource.GetFHResourcePath() + "9. Controller/controller_switch_bg_off.png", - Selected = CommonResource.GetFHResourcePath() + "9. Controller/[Controller] App Primary Color/controller_switch_bg_on_24c447.png", - Disabled = CommonResource.GetFHResourcePath() + "9. Controller/controller_switch_bg_off.png", - DisabledSelected = CommonResource.GetFHResourcePath() + "9. Controller/[Controller] App Primary Color/controller_switch_bg_on_dim_24c447.png", - }; - familySwitch[i].Style.Thumb.ResourceUrl = new Selector - { - Normal = CommonResource.GetFHResourcePath() + "9. Controller/controller_switch_handler.png", - Selected = CommonResource.GetFHResourcePath() + "9. Controller/controller_switch_handler.png", - Disabled = CommonResource.GetFHResourcePath() + "9. Controller/controller_switch_handler_dim.png", - DisabledSelected = CommonResource.GetFHResourcePath() + "9. Controller/controller_switch_handler_dim.png", - }; - ///////// - foodSwitch[i] = new Switch(); - foodSwitch[i].Size2D = new Size2D(96, 60); - foodSwitch[i].Position2D = new Position2D(700, 300 + i * 100); - foodSwitch[i].Style.Thumb.Size = new Size(60, 60); - foodSwitch[i].Style.Track.ResourceUrl = new Selector - { - Normal = CommonResource.GetFHResourcePath() + "9. Controller/controller_switch_bg_off.png", - Selected = CommonResource.GetFHResourcePath() + "9. Controller/[Controller] App Primary Color/controller_switch_bg_on_ec7510.png", - Disabled = CommonResource.GetFHResourcePath() + "9. Controller/controller_switch_bg_off.png", - DisabledSelected = CommonResource.GetFHResourcePath() + "9. Controller/[Controller] App Primary Color/controller_switch_bg_on_dim_ec7510.png", - }; - foodSwitch[i].Style.Thumb.ResourceUrl = new Selector - { - Normal = CommonResource.GetFHResourcePath() + "9. Controller/controller_switch_handler.png", - Selected = CommonResource.GetFHResourcePath() + "9. Controller/controller_switch_handler.png", - Disabled = CommonResource.GetFHResourcePath() + "9. Controller/controller_switch_handler_dim.png", - DisabledSelected = CommonResource.GetFHResourcePath() + "9. Controller/controller_switch_handler_dim.png", - }; + // Text of "Create Switch just by Style" + createText[1].Text = "Create Switch just by Style"; + } - //////// - kitchenSwitch[i] = new Switch(); - kitchenSwitch[i].Size2D = new Size2D(96, 60); - kitchenSwitch[i].Position2D = new Position2D(900, 300 + i * 100); - kitchenSwitch[i].Style.Thumb.Size = new Size(60, 60); - kitchenSwitch[i].Style.Track.ResourceUrl = new Selector - { - Normal = CommonResource.GetFHResourcePath() + "9. Controller/controller_switch_bg_off.png", - Selected = CommonResource.GetFHResourcePath() + "9. Controller/[Controller] App Primary Color/controller_switch_bg_on_9762d9.png", - Disabled = CommonResource.GetFHResourcePath() + "9. Controller/controller_switch_bg_off.png", - DisabledSelected = CommonResource.GetFHResourcePath() + "9. Controller/[Controller] App Primary Color/controller_switch_bg_on_dim_9762d9.png", - }; - kitchenSwitch[i].Style.Thumb.ResourceUrl = new Selector - { - Normal = CommonResource.GetFHResourcePath() + "9. Controller/controller_switch_handler.png", - Selected = CommonResource.GetFHResourcePath() + "9. Controller/controller_switch_handler.png", - Disabled = CommonResource.GetFHResourcePath() + "9. Controller/controller_switch_handler_dim.png", - DisabledSelected = CommonResource.GetFHResourcePath() + "9. Controller/controller_switch_handler_dim.png", - }; - - root.Add(utilitySwitch[i]); - root.Add(familySwitch[i]); - root.Add(foodSwitch[i]); - root.Add(kitchenSwitch[i]); + private void CreateModeView() + { + // Init parent of ModeView + parentView[1] = new View(); + parentView[1].Size = new Size(1920, 100); + parentView[1].Layout = new LinearLayout() { LinearOrientation = LinearLayout.Orientation.Horizontal, CellPadding = new Size2D(0, 0) }; + root.Add(parentView[1]); + + // Create mode text + for (int i = 0; i < 4; i++) + { + modeText[i] = new TextLabel(); + modeText[i].Text = mode[i]; + modeText[i].Size = new Size(196, 48); + modeText[i].PointSize = 20.0f; + parentView[1].Add(modeText[i]); } + modeText[0].Margin = new Extents(100, 0, 0, 0); - ///////////////////////////////////////////////Create by Attributes////////////////////////////////////////////////////////// - createText[1] = new TextLabel(); - createText[1].Text = "Create Switch just by Attributes"; - createText[1].Size2D = new Size2D(500, 100); - createText[1].Position2D = new Position2D(1200, 100); - root.Add(createText[1]); - - for (int i = 0; i < num; i++) + for (int j = 0; j < 4; j++) { - modeText2[i] = new TextLabel(); - modeText2[i].Text = mode[i]; - modeText2[i].Size2D = new Size2D(200, 48); - modeText2[i].Position2D = new Position2D(1100 + 200 * i, 200); - root.Add(modeText2[i]); + modeText2[j] = new TextLabel(); + modeText2[j].Text = mode[j]; + modeText2[j].Size = new Size(196, 48); + modeText2[j].PointSize = 20.0f; + parentView[1].Add(modeText2[j]); } + } - SwitchStyle utilityAttrs = new SwitchStyle + private void CreateSwitchView() + { + // Init parent of SwitchView + parentView[2] = new View(); + parentView[2].Size = new Size(1920, 680); + parentView[2].Layout = new GridLayout() { Rows = 4, GridOrientation = GridLayout.Orientation.Horizontal }; + root.Add(parentView[2]); + + // Create switch styles + SwitchStyle utilitySt = new SwitchStyle { + Size = new Size(96, 60), IsSelectable = true, Track = new ImageViewStyle { @@ -170,6 +124,7 @@ namespace Tizen.NUI.Samples Disabled = CommonResource.GetFHResourcePath() + "9. Controller/controller_switch_bg_off_dim.png", DisabledSelected = CommonResource.GetFHResourcePath() + "9. Controller/controller_switch_bg_on_dim.png", }, + Border = new Rectangle(30, 30, 30, 30), }, Thumb = new ImageViewStyle { @@ -182,8 +137,8 @@ namespace Tizen.NUI.Samples DisabledSelected = CommonResource.GetFHResourcePath() + "9. Controller/controller_switch_handler_dim.png", }, }, - }; - SwitchStyle familyAttrs = new SwitchStyle + }; + SwitchStyle familySt = new SwitchStyle { IsSelectable = true, Track = new ImageViewStyle @@ -195,6 +150,7 @@ namespace Tizen.NUI.Samples Disabled = CommonResource.GetFHResourcePath() + "9. Controller/controller_switch_bg_off_dim.png", DisabledSelected = CommonResource.GetFHResourcePath() + "9. Controller/[Controller] App Primary Color/controller_switch_bg_on_dim_24c447.png", }, + Border = new Rectangle(30, 30, 30, 30), }, Thumb = new ImageViewStyle { @@ -208,7 +164,7 @@ namespace Tizen.NUI.Samples }, }, }; - SwitchStyle foodAttrs = new SwitchStyle + SwitchStyle foodSt = new SwitchStyle { IsSelectable = true, Track = new ImageViewStyle @@ -220,6 +176,7 @@ namespace Tizen.NUI.Samples Disabled = CommonResource.GetFHResourcePath() + "9. Controller/controller_switch_bg_off_dim.png", DisabledSelected = CommonResource.GetFHResourcePath() + "9. Controller/[Controller] App Primary Color/controller_switch_bg_on_dim_ec7510.png", }, + Border = new Rectangle(30, 30, 30, 30), }, Thumb = new ImageViewStyle { @@ -233,7 +190,7 @@ namespace Tizen.NUI.Samples }, }, }; - SwitchStyle kitchenAttrs = new SwitchStyle + SwitchStyle kitchenSt = new SwitchStyle { IsSelectable = true, Track = new ImageViewStyle @@ -245,10 +202,11 @@ namespace Tizen.NUI.Samples Disabled = CommonResource.GetFHResourcePath() + "9. Controller/controller_switch_bg_off_dim.png", DisabledSelected = CommonResource.GetFHResourcePath() + "9. Controller/[Controller] App Primary Color/controller_switch_bg_on_dim_9762d9.png", }, + Border = new Rectangle(30, 30, 30, 30), }, Thumb = new ImageViewStyle { - Size = new Size(60, 60), + Size = new Size(60, 60), ResourceUrl = new Selector { Normal = CommonResource.GetFHResourcePath() + "9. Controller/controller_switch_handler.png", @@ -256,30 +214,69 @@ namespace Tizen.NUI.Samples Disabled = CommonResource.GetFHResourcePath() + "9. Controller/controller_switch_handler_dim.png", DisabledSelected = CommonResource.GetFHResourcePath() + "9. Controller/controller_switch_handler_dim.png", }, - }, + }, }; - for (int i = 0; i < num; i++) + + ///////////////////////////////////////////////Create by Property////////////////////////////////////////////////////////// + int i = 0; + for (; i < 4; i++) { - utilitySwitch2[i] = new Switch(utilityAttrs); - utilitySwitch2[i].Size2D = new Size2D(96, 60); - utilitySwitch2[i].Position2D = new Position2D(1100, 300 + i * 100); - - familySwitch2[i] = new Switch(familyAttrs); - familySwitch2[i].Size2D = new Size2D(96, 60); - familySwitch2[i].Position2D = new Position2D(1300, 300 + i * 100); - - foodSwitch2[i] = new Switch(foodAttrs); - foodSwitch2[i].Size2D = new Size2D(96, 60); - foodSwitch2[i].Position2D = new Position2D(1500, 300 + i * 100); - - kitchenSwitch2[i] = new Switch(kitchenAttrs); - kitchenSwitch2[i].Size2D = new Size2D(96, 60); - kitchenSwitch2[i].Position2D = new Position2D(1700, 300 + i * 100); - - root.Add(utilitySwitch2[i]); - root.Add(familySwitch2[i]); - root.Add(foodSwitch2[i]); - root.Add(kitchenSwitch2[i]); + utilitySwitch[i] = new Switch(); + utilitySwitch[i].ApplyStyle(utilitySt); + utilitySwitch[i].Size = new Size(96, 60); + utilitySwitch[i].Margin = new Extents(100, 0, 20, 0); + parentView[2].Add(utilitySwitch[i]); + } + for (i = 0; i < 4; i++) + { + familySwitch[i] = new Switch(); + familySwitch[i].ApplyStyle(familySt); + familySwitch[i].Size = new Size(96, 60); + parentView[2].Add(familySwitch[i]); + } + for (i = 0; i < 4; i++) + { + foodSwitch[i] = new Switch(); + foodSwitch[i].ApplyStyle(foodSt); + foodSwitch[i].Size = new Size(96, 60); + parentView[2].Add(foodSwitch[i]); + } + for (i = 0; i < 4; i++) + { + kitchenSwitch[i] = new Switch(); + kitchenSwitch[i].ApplyStyle(kitchenSt); + kitchenSwitch[i].Size = new Size(96, 60); + parentView[2].Add(kitchenSwitch[i]); + } + + ///////////////////////////////////////////////Create by Style////////////////////////////////////////////////////////// + for (i = 0; i < 4; i++) + { + utilitySwitch2[i] = new Switch(); + utilitySwitch2[i].ApplyStyle(utilitySt); + utilitySwitch2[i].Size = new Size(96, 60); + parentView[2].Add(utilitySwitch2[i]); + } + for (i = 0; i < 4; i++) + { + familySwitch2[i] = new Switch(); + familySwitch2[i].ApplyStyle(familySt); + familySwitch2[i].Size = new Size(96, 60); + parentView[2].Add(familySwitch2[i]); + } + for (i = 0; i < 4; i++) + { + foodSwitch2[i] = new Switch(); + foodSwitch2[i].ApplyStyle(foodSt); + foodSwitch2[i].Size = new Size(96, 60); + parentView[2].Add(foodSwitch2[i]); + } + for (i = 0; i < 4; i++) + { + kitchenSwitch2[i] = new Switch(); + kitchenSwitch2[i].ApplyStyle(kitchenSt); + kitchenSwitch2[i].Size = new Size(96, 60); + parentView[2].Add(kitchenSwitch2[i]); } utilitySwitch[2].IsEnabled = false; @@ -318,56 +315,53 @@ namespace Tizen.NUI.Samples int num = 4; for (int i = 0; i < num; i++) { - root.Remove(utilitySwitch[i]); utilitySwitch[i].Dispose(); utilitySwitch[i] = null; - root.Remove(familySwitch[i]); familySwitch[i].Dispose(); familySwitch[i] = null; - root.Remove(foodSwitch[i]); foodSwitch[i].Dispose(); foodSwitch[i] = null; - root.Remove(kitchenSwitch[i]); kitchenSwitch[i].Dispose(); kitchenSwitch[i] = null; - root.Remove(modeText[i]); modeText[i].Dispose(); modeText[i] = null; - root.Remove(utilitySwitch2[i]); utilitySwitch2[i].Dispose(); utilitySwitch2[i] = null; - root.Remove(familySwitch2[i]); familySwitch2[i].Dispose(); familySwitch2[i] = null; - root.Remove(foodSwitch2[i]); foodSwitch2[i].Dispose(); foodSwitch2[i] = null; - root.Remove(kitchenSwitch2[i]); kitchenSwitch2[i].Dispose(); kitchenSwitch2[i] = null; - root.Remove(modeText2[i]); modeText2[i].Dispose(); modeText2[i] = null; } - root.Remove(createText[0]); createText[0].Dispose(); createText[0] = null; - root.Remove(createText[1]); createText[1].Dispose(); createText[1] = null; + for (int j = 0; j < 3; j++) + { + if (parentView[j] != null) + { + parentView[j].Dispose(); + parentView[j] = null; + } + } NUIApplication.GetDefaultWindow().Remove(root); root.Dispose(); + root = null; } } } diff --git a/test/Tizen.NUI.Samples/Tizen.NUI.Samples/Samples/TabSample.cs b/test/Tizen.NUI.Samples/Tizen.NUI.Samples/Samples/TabSample.cs index ee7b2fd..1bd506f 100755 --- a/test/Tizen.NUI.Samples/Tizen.NUI.Samples/Samples/TabSample.cs +++ b/test/Tizen.NUI.Samples/Tizen.NUI.Samples/Samples/TabSample.cs @@ -7,12 +7,11 @@ namespace Tizen.NUI.Samples public class TabSample : IExample { private View root; + private View[] parentView = new View[3]; private TextLabel[] createText = new TextLabel[2]; - private Tab tab = null; private Tab tab2 = null; - private Button button = null; private Button button2 = null; private int index = 0; @@ -31,50 +30,78 @@ namespace Tizen.NUI.Samples new Color(0.75f, 0.46f, 0.06f, 1),//#ffec7510 Food new Color(0.59f, 0.38f, 0.85f, 1),//#ff9762d9 Kitchen }; + public void Activate() { Window window = NUIApplication.GetDefaultWindow(); root = new View() { - Size2D = new Size2D(1920, 1080), + Size = new Size(1920, 1080), + BackgroundColor = new Color(0.7f, 0.9f, 0.8f, 1.0f), }; + root.Layout = new LinearLayout() { LinearOrientation = LinearLayout.Orientation.Vertical }; window.Add(root); - ///////////////////////////////////////////////Create by Property////////////////////////////////////////////////////////// - createText[0] = new TextLabel(); - createText[0].Text = "Create Tab just by properties"; - createText[0].Size2D = new Size2D(450, 100); - createText[0].Position2D = new Position2D(200, 100); - createText[0].MultiLine = true; - root.Add(createText[0]); + CreateTextView(); + CreateTabView(); + CreateButtonView(); + } + private void CreateTextView() + { + // Init parent of TextView + parentView[0] = new View(); + parentView[0].Size = new Size(1920, 300); + parentView[0].Layout = new LinearLayout() { LinearOrientation = LinearLayout.Orientation.Horizontal, LinearAlignment = LinearLayout.Alignment.Center, CellPadding = new Size2D(100, 0) }; + root.Add(parentView[0]); + + for (int i = 0; i < 2; i++) + { + createText[i] = new TextLabel(); + createText[i].Size = new Size(500, 100); + createText[i].PointSize = 20.0f; + createText[i].BackgroundColor = Color.Magenta; + createText[i].HorizontalAlignment = HorizontalAlignment.Center; + createText[i].VerticalAlignment = VerticalAlignment.Center; + createText[i].MultiLine = true; + parentView[0].Add(createText[i]); + } + + // Text of "Create Switch just by Properties" + createText[0].Text = "Create Tab just by Properties"; + // Text of "Create Switch just by Style" + createText[1].Text = "Create Tab just by Style"; + } + + private void CreateTabView() + { + // Init parent of TabView + parentView[1] = new View(); + parentView[1].Size = new Size(1920, 200); + parentView[1].Layout = new LinearLayout() { LinearOrientation = LinearLayout.Orientation.Horizontal, LinearAlignment = LinearLayout.Alignment.Center, CellPadding = new Size2D(100, 0) }; + root.Add(parentView[1]); + + ///////////////////////////////////////////////Create by Property////////////////////////////////////////////////////////// tab = new Tab(); - tab.Size2D = new Size2D(700, 108); - tab.Position2D = new Position2D(100, 300); + tab.Size = new Size(700, 108); tab.BackgroundColor = new Color(1.0f, 1.0f, 1.0f, 0.5f); - //tab.IsNatureTextWidth = true; - //tab.ItemGap = 40; - //tab.LeftSpace = 56; - //tab.RightSpace = 56; - //tab.TopSpace = 1; - //tab.BottomSpace = 0; - tab.Style.UnderLine.Size = new Size(1, 3); - tab.Style.UnderLine.BackgroundColor = color[0]; - tab.Style.Text.PointSize = 25; - tab.Style.Text.TextColor = new Selector + tab.Underline.Size = new Size(1, 3); + tab.Underline.BackgroundColor = color[0]; + tab.PointSize = 25; + tab.TextColorSelector = new ColorSelector { Normal = Color.Black, Selected = color[0], }; tab.ItemChangedEvent += TabItemChangedEvent; - root.Add(tab); + parentView[1].Add(tab); for (int i = 0; i < 3; i++) { Tab.TabItemData item = new Tab.TabItemData(); item.Text = "Tab " + i; - if(i==1) + if (i == 1) { item.Text = "Long Tab " + i; } @@ -82,15 +109,8 @@ namespace Tizen.NUI.Samples } tab.SelectedItemIndex = 0; - ///////////////////////////////////////////////Create by Attributes////////////////////////////////////////////////////////// - createText[1] = new TextLabel(); - createText[1].Text = "Create Tab just by Attributes"; - createText[1].Size2D = new Size2D(450, 100); - createText[1].Position2D = new Position2D(1000, 100); - createText[1].MultiLine = true; - root.Add(createText[1]); - - TabStyle attrs = new TabStyle + ///////////////////////////////////////////////Create by Style////////////////////////////////////////////////////////// + TabStyle st = new TabStyle { //IsNatureTextWidth = false, ItemPadding = new Extents(56, 56, 1, 0), @@ -100,7 +120,7 @@ namespace Tizen.NUI.Samples PositionUsesPivotPoint = true, ParentOrigin = Tizen.NUI.ParentOrigin.BottomLeft, PivotPoint = Tizen.NUI.PivotPoint.BottomLeft, - BackgroundColor = new Selector { All = color[0]}, + BackgroundColor = new Selector { All = color[0] }, }, Text = new TextLabelStyle { @@ -110,15 +130,14 @@ namespace Tizen.NUI.Samples Normal = Color.Black, Selected = color[0], }, - }, + }, }; - tab2 = new Tab(attrs); - tab2.Size2D = new Size2D(500, 108); - tab2.Position2D = new Position2D(900, 300); + tab2 = new Tab(st); + tab2.Size = new Size(500, 108); tab2.BackgroundColor = new Color(1.0f, 1.0f, 1.0f, 0.5f); tab2.ItemChangedEvent += Tab2ItemChangedEvent; - root.Add(tab2); + parentView[1].Add(tab2); for (int i = 0; i < 3; i++) { @@ -127,24 +146,57 @@ namespace Tizen.NUI.Samples tab2.AddItem(item); } tab2.SelectedItemIndex = 0; + } + + private void CreateButtonView() + { + // Init parent of ButtonView + parentView[2] = new View(); + parentView[2].Size = new Size(1920, 200); + parentView[2].Layout = new LinearLayout() { LinearOrientation = LinearLayout.Orientation.Horizontal, LinearAlignment = LinearLayout.Alignment.Center, CellPadding = new Size2D(100, 0) }; + root.Add(parentView[2]); - button = new Button(); - button.Style.BackgroundImage = CommonResource.GetTVResourcePath() + "component/c_buttonbasic/c_basic_button_white_bg_normal_9patch.png"; - button.Style.BackgroundImageBorder = new Rectangle(4, 4, 5, 5); - button.Size2D = new Size2D(280, 80); - button.Position2D = new Position2D(400, 700); - button.Style.Text.Text = mode[index]; + // Create Buttons + var buttonStyle = new ButtonStyle() + { + Size = new Size(300, 80), + Overlay = new ImageViewStyle() + { + ResourceUrl = new Selector + { + Pressed = CommonResource.GetFHResourcePath() + "3. Button/rectangle_btn_press_overlay.png", + Other = "" + }, + Border = new Rectangle(5, 5, 5, 5) + }, + Text = new TextLabelStyle() + { + TextColor = new Selector + { + Normal = new Color(0, 0, 0, 1), + Pressed = new Color(0, 0, 0, 0.7f), + Selected = new Color(0.058f, 0.631f, 0.92f, 1), + Disabled = new Color(0, 0, 0, 0.4f) + }, + PointSize = 18, + }, + BackgroundImage = CommonResource.GetFHResourcePath() + "3. Button/rectangle_btn_normal.png", + BackgroundImageBorder = new Rectangle(5, 5, 5, 5), + }; + + // Button of switching mode + button = new Button(buttonStyle); + button.Size = new Size(500, 80); + button.ButtonText.Text = mode[index]; button.ClickEvent += ButtonClickEvent; - root.Add(button); - - button2 = new Button(); - button2.Style.BackgroundImage = CommonResource.GetTVResourcePath() + "component/c_buttonbasic/c_basic_button_white_bg_normal_9patch.png"; - button2.Style.BackgroundImageBorder = new Rectangle(4, 4, 5, 5); - button2.Size2D = new Size2D(580, 80); - button2.Position2D = new Position2D(250, 500); - button2.Style.Text.Text = "LayoutDirection is left to right"; + parentView[2].Add(button); + + // Button of LayoutDirection + button2 = new Button(buttonStyle); + button2.Size = new Size(500, 80); + button2.ButtonText.Text = "LayoutDirection is left to right"; button2.ClickEvent += ButtonClickEvent2; - root.Add(button2); + parentView[2].Add(button2); } private void TabItemChangedEvent(object sender, Tab.ItemChangedEventArgs e) @@ -158,44 +210,49 @@ namespace Tizen.NUI.Samples { if (button != null) { - root.Remove(button); button.Dispose(); button = null; } if (button2 != null) { - root.Remove(button2); button2.Dispose(); button2 = null; } if (tab != null) { - root.Remove(tab); tab.Dispose(); tab = null; } + if (tab2 != null) { - root.Remove(tab2); tab2.Dispose(); tab2 = null; } if (createText[0] != null) { - root.Remove(createText[0]); createText[0].Dispose(); createText[0] = null; } + if (createText[1] != null) { - root.Remove(createText[1]); createText[1].Dispose(); createText[1] = null; } + for (int j = 0; j < 3; j++) + { + if (parentView[j] != null) + { + parentView[j].Dispose(); + parentView[j] = null; + } + } + NUIApplication.GetDefaultWindow().Remove(root); root.Dispose(); root = null; @@ -204,21 +261,21 @@ namespace Tizen.NUI.Samples private void Tab2ItemChangedEvent(object sender, Tab.ItemChangedEventArgs e) { - createText[1].Text = "Create Tab just by Attributes, Selected index from " + e.PreviousIndex + " to " + e.CurrentIndex; + createText[1].Text = "Create Tab just by Style, Selected index from " + e.PreviousIndex + " to " + e.CurrentIndex; } private void ButtonClickEvent(object sender, Button.ClickEventArgs e) { index = (index + 1) % 4; - button.Style.Text.Text = mode[index]; - tab.Style.UnderLine.BackgroundColor = color[index]; - tab.Style.Text.TextColor = new Selector + button.ButtonText.Text = mode[index]; + tab.Underline.BackgroundColor = color[index]; + tab.TextColorSelector = new ColorSelector { Normal = Color.Black, Selected = color[index], }; - tab2.Style.UnderLine.BackgroundColor = color[index]; - tab2.Style.Text.TextColor = new Selector + tab2.Underline.BackgroundColor = color[index]; + tab2.TextColorSelector = new ColorSelector { Normal = Color.Black, Selected = color[index], @@ -231,13 +288,13 @@ namespace Tizen.NUI.Samples { tab.LayoutDirection = ViewLayoutDirectionType.RTL; tab2.LayoutDirection = ViewLayoutDirectionType.RTL; - button2.Style.Text.Text = "LayoutDirection is right to left"; + button2.ButtonText.Text = "LayoutDirection is right to left"; } else { tab.LayoutDirection = ViewLayoutDirectionType.LTR; tab2.LayoutDirection = ViewLayoutDirectionType.LTR; - button2.Style.Text.Text = "LayoutDirection is left to right"; + button2.ButtonText.Text = "LayoutDirection is left to right"; } } } diff --git a/test/Tizen.NUI.Samples/Tizen.NUI.Samples/Samples/ToastSample.cs b/test/Tizen.NUI.Samples/Tizen.NUI.Samples/Samples/ToastSample.cs index 17ea88b..2076a69 100755 --- a/test/Tizen.NUI.Samples/Tizen.NUI.Samples/Samples/ToastSample.cs +++ b/test/Tizen.NUI.Samples/Tizen.NUI.Samples/Samples/ToastSample.cs @@ -6,10 +6,11 @@ namespace Tizen.NUI.Samples { public class ToastSample : IExample { - private TextLabel board1, board2, board; - private Button button1, button2; + private TextLabel[] text = new TextLabel[3]; + private Button[] button = new Button[2]; private Toast toast1_1, toast2_1; //1-null para 2-attributes; X_1-color; X_2 image track private View root; + private View[] parentView = new View[3]; public void Activate() { @@ -18,128 +19,174 @@ namespace Tizen.NUI.Samples root = new View() { Size = new Size(1920, 1080), - BackgroundColor = new Color(0.8f, 0.8f, 0.8f, 0.6f), + BackgroundColor = new Color(0.7f, 0.9f, 0.8f, 1.0f), }; + root.Layout = new LinearLayout() { LinearOrientation = LinearLayout.Orientation.Vertical }; + window.Add(root); - CreateBoardAndButtons(); + CreateTextView(); + CreateToastView(); + CreateLogPadView(); + } + + private void CreateTextView() + { + // Init parent of TextView + parentView[0] = new View(); + parentView[0].Size = new Size(1920, 200); + parentView[0].Layout = new LinearLayout() { LinearOrientation = LinearLayout.Orientation.Horizontal, LinearAlignment = LinearLayout.Alignment.Center, CellPadding = new Size2D(300, 0) }; + root.Add(parentView[0]); + + for (int i = 0; i < 2; i++) + { + text[i] = new TextLabel(); + text[i].Size = new Size(400, 70); + text[i].PointSize = 20.0f; + text[i].BackgroundColor = Color.Magenta; + text[i].HorizontalAlignment = HorizontalAlignment.Center; + text[i].VerticalAlignment = VerticalAlignment.Center; + text[i].Focusable = true; + text[i].FocusGained += Board_FocusGained; + text[i].FocusLost += Board_FocusLost; + parentView[0].Add(text[i]); + } + + // Text of "Create Switch just by properties" + text[0].Text = "Null Style construction"; + + // Text of "Create Switch just by Style" + text[1].Text = "Style construction"; + } + + private void CreateToastView() + { + // Init parent of ToastView + parentView[1] = new View(); + parentView[1].Size = new Size(1920, 500); + parentView[1].Layout = new LinearLayout() { LinearOrientation = LinearLayout.Orientation.Horizontal, LinearAlignment = LinearLayout.Alignment.Center, CellPadding = new Size2D(300, 0) }; + root.Add(parentView[1]); - toast1_1 = Toast.FromText("null parameter construction", 1000); - toast1_1.Size = new Size(500, 132); - toast1_1.Post(window); + // Create Toasts + toast1_1 = Toast.FromText("Null parameter construction", 1000); + toast1_1.Size = new Size(700, 132); + toast1_1.Post(NUIApplication.GetDefaultWindow()); ToastStyle attr = new ToastStyle { - Size = new Size(512, 132), + Size = new Size(712, 132), BackgroundImage = CommonResource.GetFHResourcePath() + "12. Toast Popup/toast_background.png", BackgroundImageBorder = new Rectangle(64, 64, 4, 4), Duration = 3000 }; - - toast2_1 = new Toast(attr); - toast2_1.Message = "attibute parameter construction"; - toast2_1.Post(window); - //root.Add(toast2_1); + toast2_1 = new Toast(attr); + toast2_1.Message = "Style parameter construction"; + toast2_1.Post(NUIApplication.GetDefaultWindow()); - board.UpFocusableView = button1; - window.Add(root); + // Create Buttons + CreateBoardAndButtons(); + } - FocusManager.Instance.SetCurrentFocusView(button1); + private void CreateLogPadView() + { + // Init parent of LogPadView + parentView[2] = new View(); + parentView[2].Size = new Size(1920, 380); + parentView[2].Layout = new LinearLayout() { LinearOrientation = LinearLayout.Orientation.Horizontal, LinearAlignment = LinearLayout.Alignment.Center}; + root.Add(parentView[2]); + + // Create log pad + text[2] = new TextLabel(); + text[2].Size = new Size(1000, 100); + text[2].PointSize = 30.0f; + text[2].HorizontalAlignment = HorizontalAlignment.Center; + text[2].VerticalAlignment = VerticalAlignment.Center; + text[2].BackgroundColor = Color.Magenta; + text[2].Text = "log pad"; + text[2].Focusable = true; + text[2].FocusGained += Board_FocusGained; + text[2].FocusLost += Board_FocusLost; + text[2].UpFocusableView = button[0]; + parentView[2].Add(text[2]); } void CreateBoardAndButtons() { - board = new TextLabel(); - board.Size = new Size(1000, 100); - board.Position = new Position(430, 900); - board.PointSize = 30; - board.HorizontalAlignment = HorizontalAlignment.Center; - board.VerticalAlignment = VerticalAlignment.Center; - board.BackgroundColor = Color.Magenta; - board.Text = "log pad"; - root.Add(board); - board.Focusable = true; - board.FocusGained += Board_FocusGained; - board.FocusLost += Board_FocusLost; - - board1 = new TextLabel(); - board1.Size = new Size(300, 70); - board1.Position = new Position(50, 200); - board1.PointSize = 20; - board1.HorizontalAlignment = HorizontalAlignment.Center; - board1.VerticalAlignment = VerticalAlignment.Center; - board1.BackgroundColor = Color.Magenta; - board1.Text = "NULL parameter construction"; - root.Add(board1); - board1.Focusable = true; - board1.FocusGained += Board_FocusGained; - board1.FocusLost += Board_FocusLost; - - board2 = new TextLabel(); - board2.Size = new Size(300, 70); - board2.Position = new Position(650, 200); - board2.PointSize = 20; - board2.HorizontalAlignment = HorizontalAlignment.Center; - board2.VerticalAlignment = VerticalAlignment.Center; - board2.BackgroundColor = Color.Magenta; - board2.Text = "Attribute construction"; - root.Add(board2); - board2.Focusable = true; - board2.FocusGained += Board_FocusGained; - board2.FocusLost += Board_FocusLost; - - button1 = new Button(); - button1.BackgroundColor = Color.Green; - button1.Position = new Position(80, 600); - button1.Size = new Size(200, 50); - button1.Style.Text.Text = "toast1_1 Show"; - root.Add(button1); - button1.Focusable = true; - button1.ClickEvent += toast1_1Show; - - button2 = new Button(); - button2.BackgroundColor = Color.Green; - button2.Position = new Position(700, 600); - button2.Size = new Size(100, 50); - button2.Style.Text.Text = "toast2_1 Show"; - root.Add(button2); - button2.Focusable = true; - button2.ClickEvent += toast2_1Show; + for (int i = 0; i < 2; i++) + { + button[i] = new Button(); + button[i].BackgroundColor = Color.Green; + button[i].Size = new Size(200, 50); + button[i].Focusable = true; + parentView[1].Add(button[i]); + } + button[0].Text = "toast1_1 Show"; + button[0].ClickEvent += toast1_1Show; + button[1].Text = "toast2_1 Show"; + button[1].ClickEvent += toast2_1Show; + + // Set init focus + FocusManager.Instance.SetCurrentFocusView(button[0]); } private void Board_FocusLost(object sender, global::System.EventArgs e) { - board.BackgroundColor = Color.Magenta; + text[2].BackgroundColor = Color.Magenta; } private void Board_FocusGained(object sender, global::System.EventArgs e) { - board.BackgroundColor = Color.Cyan; + text[2].BackgroundColor = Color.Cyan; } private void toast1_1Show(object sender, global::System.EventArgs e) { - board.Text = "toast1_1 show: "; + text[2].Text = "toast1_1 show: "; toast1_1.Show(); } private void toast2_1Show(object sender, global::System.EventArgs e) { - board.Text = "toast2_1 show: "; + text[2].Text = "toast2_1 show: "; toast2_1.Show(); } - private void toast1FPSMinus(object sender, global::System.EventArgs e) - { - //board.Text = "toast1_1 FPS: " + toast1_1.FPS.ToString(); - } - public void Deactivate() { if (root != null) { NUIApplication.GetDefaultWindow().Remove(root); + + if (toast1_1 != null) + { + NUIApplication.GetDefaultWindow().Remove(toast1_1); + toast1_1.Dispose(); + toast1_1 = null; + } + + if (toast2_1 != null) + { + NUIApplication.GetDefaultWindow().Remove(toast2_1); + toast2_1.Dispose(); + toast2_1 = null; + } + + int i = 0; + for (; i < 2; i++) + { + button[i].Dispose(); + button[i] = null; + } + + for (i = 0; i < 3; i++) + { + text[i].Dispose(); + text[i] = null; + parentView[i].Dispose(); + parentView[i] = null; + } root.Dispose(); + root = null; } } } -- 2.7.4