/// <summary>
        /// The method to fill the list of buttons, to add buttons to their
        /// view and to connect buttons' clicked event with the proper function call
        /// </summary>
        private void InitializeButtons()
        {
            int    ButtonWidth  = (int)((ButtonVisualView.Size2D[0] - 2 * FrameSize) / 3);
            int    ButtonHeight = (int)ButtonVisualView.Size2D[1];
            Size2D ButtonSize   = new Size2D(ButtonWidth, ButtonHeight);

            Buttons.Add(SetButton("Color Border Gradient", 0, ButtonSize));
            Buttons.Add(SetButton("Images", (ButtonWidth + FrameSize), ButtonSize));
            Buttons.Add(SetButton("Primitives", 2 * (ButtonWidth + FrameSize), ButtonSize));

            for (var i = 0; i < Buttons.Count; i++)
            {
                ButtonVisualView.Add(Buttons[i]);
            }

            Buttons[0].Clicked += OnClickedButton1;
            Buttons[1].Clicked += OnClickedButton2;
            Buttons[2].Clicked += OnClickedButton3;
        }
        /// <summary>
        /// Create TableView, Create PushButtons and add them to tableView.
        /// </summary>
        private void CreateVisuals()
        {
            // Visual View to contain each visual
            mVisualView = new VisualView();
            mVisualView.PositionUsesPivotPoint = true;
            mVisualView.ParentOrigin           = ParentOrigin.CenterLeft;
            mVisualView.PivotPoint             = PivotPoint.CenterLeft;
            // Set the VisualView size for the 14 kind of visuals
            mVisualView.Size2D = new Size2D(14 * 360, mVisualSize.Height);

            Window.Instance.GetDefaultLayer().Add(mVisualView);

            // Default Visual position
            Vector2 visualPosition = new Vector2(180, 0);
            uint    visualIndex    = 0;

            for (; visualIndex < mVisualCount; ++visualIndex)
            {
                // Create each Visual Map
                mVisualView.Add(CreateVisualMap(mVisualType[visualIndex], visualPosition));
                // Update Visual Position for the next visual
                visualPosition += new Vector2(360, 0);
            }
        }
Beispiel #3
0
        /// <summary>
        /// The class's constructor
        /// </summary>
        /// <param name="menuSize">menu size</param>
        /// <param name="stencilContainerPosition">stencil container position</param>
        public SystemMenu(Size2D menuSize, Position2D stencilContainerPosition)
        {
            _systemMenuAnimation               = new Animation(Constants.SystemMenuAnimationDuration);
            _systemMenuAnimation.EndAction     = Animation.EndActions.Cancel;
            _systemSelectorAnimation           = new Animation(Constants.SystemMenuSelectorAnimationDuration);
            _systemSelectorAnimation.EndAction = Animation.EndActions.Cancel;

            _menu      = new View();
            _menu.Name = "systemMenu";
            _menu.WidthResizePolicy      = ResizePolicyType.Fixed;
            _menu.HeightResizePolicy     = ResizePolicyType.FillToParent;
            _menu.ParentOrigin           = ParentOrigin.CenterLeft;
            _menu.PivotPoint             = PivotPoint.CenterLeft;
            _menu.PositionUsesPivotPoint = true;
            _menu.Size2D = new Size2D(menuSize.Width, 0);

            // Add a shadow seperator image between last system icon and Menu ScrollContainer.
            _menuSeparator      = new ImageView(Constants.ResourcePath + "/images/Effect/focus_launcher_shadow_n_enhanced.png");
            _menuSeparator.Name = "menuSeparator";
            _menuSeparator.WidthResizePolicy      = ResizePolicyType.UseNaturalSize;
            _menuSeparator.HeightResizePolicy     = ResizePolicyType.FillToParent;
            _menuSeparator.ParentOrigin           = ParentOrigin.CenterRight;
            _menuSeparator.PivotPoint             = PivotPoint.CenterLeft;
            _menuSeparator.PositionUsesPivotPoint = true;
            _menuSeparator.Position = new Position(-1.0f, 0.0f, 0.0f);
            _menu.Add(_menuSeparator);

            // Calculate layout ratios for icons (so they have correct positions regardless of menu scale).
            float count     = (float)Constants.SystemItemsCount;
            float menuWidth = Constants.SystemMenuWidth;

            _systemIconGap        = (menuWidth - (count * Constants.SystemIconWidth)) / (count + 1);
            _systemIconSeparation = ((menuWidth - _systemIconGap - (count * _systemIconGap)) / count) + _systemIconGap;

            // Add Launcher items to Bottom Container. Launcher is used to display three images on left of Menu ScrollContainer
            _systemIcons = new ImageView[Convert.ToInt32(Constants.SystemItemsCount)];
            for (int icon = 0; icon < Constants.SystemItemsCount; ++icon)
            {
                _systemIcons[icon] = new ImageView(Constants.ResourcePath + "/images/SystemMenu/icon-" + (icon + 1) + ".png");
                // We use the name to keep track of which icon we have selected.
                _systemIcons[icon].Name = icon.ToString();
                _systemIcons[icon].WidthResizePolicy      = ResizePolicyType.UseNaturalSize;
                _systemIcons[icon].HeightResizePolicy     = ResizePolicyType.UseNaturalSize;
                _systemIcons[icon].PivotPoint             = PivotPoint.Center;
                _systemIcons[icon].ParentOrigin           = ParentOrigin.Center;
                _systemIcons[icon].Position               = GetSystemIconPosition(icon, false);
                _systemIcons[icon].PositionUsesPivotPoint = true;
                _systemIcons[icon].Focusable              = true;
                _systemIcons[icon].InheritScale           = false;
                _systemIcons[icon].Scale = new Vector3(0.5f, 0.5f, 0.5f);
                _menu.Add(_systemIcons[icon]);
            }

            // Create the system menu selector highlight.
            _systemSelector = new VisualView();
            _systemSelector.WidthResizePolicy      = ResizePolicyType.Fixed;
            _systemSelector.HeightResizePolicy     = ResizePolicyType.FillToParent;
            _systemSelector.Size2D                 = new Size2D((int)(Constants.SystemMenuWidth / 3.0f) - 1, 0);
            _systemSelector.PositionUsesPivotPoint = true;
            _systemSelector.Focusable              = true;
            _systemSelector.ParentOrigin           = ParentOrigin.Center;
            _systemSelector.PivotPoint             = PivotPoint.Center;

            // Create a color visual that we can animate the color of, allowing us to also use the selector for clipping.
            _systemSelectorColor = new ColorVisual();
            _systemSelectorColor.PositionPolicy = VisualTransformPolicyType.Relative;
            _systemSelectorColor.SizePolicy     = VisualTransformPolicyType.Relative;
            _systemSelectorColor.Origin         = Visual.AlignType.Center;
            _systemSelectorColor.AnchorPoint    = Visual.AlignType.Center;
            _systemSelectorColor.Color          = new Color(1.0f, 0.0f, 0.0f, 0.0f);
            _systemSelector.AddVisual("ColorVisual1", _systemSelectorColor);

            // Create a View to represent the size of the clipping area, so we can use the fast bounding-box clipping mode.
            _systemSelectorClippingBox = new View();
            _systemSelectorClippingBox.WidthResizePolicy      = ResizePolicyType.FillToParent;
            _systemSelectorClippingBox.HeightResizePolicy     = ResizePolicyType.FillToParent;
            _systemSelectorClippingBox.PositionUsesPivotPoint = true;
            _systemSelectorClippingBox.ParentOrigin           = ParentOrigin.Center;
            _systemSelectorClippingBox.PivotPoint             = PivotPoint.Center;

            // The system selector will clip its children as well as rendering its visual to the color buffer.
            _systemSelectorClippingBox.ClippingMode = ClippingModeType.ClipToBoundingBox;

            _systemSelector.Add(_systemSelectorClippingBox);
            _menu.Add(_systemSelector);

            _systemSelectorColors    = new Color[_systemIcons.Length];
            _systemSelectorColors[0] = new Color(1.0f, 0.4f, 0.3f, 0.5f);
            _systemSelectorColors[1] = new Color(0.2f, 0.7f, 0.2f, 0.5f);
            _systemSelectorColors[2] = new Color(0.2f, 0.7f, 0.9f, 0.5f);

            View stencilIconContainer = new View();

            stencilIconContainer.Name = "stencilIconContainer";
            stencilIconContainer.WidthResizePolicy      = ResizePolicyType.Fixed;
            stencilIconContainer.HeightResizePolicy     = ResizePolicyType.Fixed;
            stencilIconContainer.PivotPoint             = PivotPoint.BottomLeft;
            stencilIconContainer.PositionUsesPivotPoint = true;

            // todor
            stencilIconContainer.InheritPosition = false;

            //TODO: DALi: Because we cannot use parent origin with "Inherit Position = false", this menu now needs to know the window/stage size - which it should not have to care about.
            stencilIconContainer.Position2D = stencilContainerPosition;
            stencilIconContainer.Size2D     = menuSize;
            _systemSelectorClippingBox.Add(stencilIconContainer);

            _systemStencilIcons = new ImageView[Convert.ToInt32(Constants.SystemItemsCount)];
            for (int icon = 0; icon < Constants.SystemItemsCount; ++icon)
            {
                _systemStencilIcons[icon] = new ImageView(Constants.ResourcePath + "/images/SystemMenu/icon-" + (icon + 1) + "-active.png");
                // We use the name to keep track of which icon we have selected.
                _systemStencilIcons[icon].Name = icon.ToString();
                _systemStencilIcons[icon].WidthResizePolicy      = ResizePolicyType.UseNaturalSize;
                _systemStencilIcons[icon].HeightResizePolicy     = ResizePolicyType.UseNaturalSize;
                _systemStencilIcons[icon].PivotPoint             = PivotPoint.Center;
                _systemStencilIcons[icon].ParentOrigin           = ParentOrigin.Center;
                _systemStencilIcons[icon].Position               = GetSystemIconPosition(icon, false);
                _systemStencilIcons[icon].PositionUsesPivotPoint = true;
                _systemStencilIcons[icon].InheritScale           = false;
                _systemStencilIcons[icon].Scale = new Vector3(0.5f, 0.5f, 0.5f);
                stencilIconContainer.Add(_systemStencilIcons[icon]);
            }

            _maxIconIndex = _systemIcons.Length - 1;

            // Set up state and position of the selector.
            _focusedIcon = -1;
            MoveSelector(true, true);
        }
        /// <summary>
        /// The method to set the visual view that is visible after clicking
        /// the button1 - contains visuals text, border, color, gradient
        /// </summary>
        /// <returns> The created VisualView </returns>
        private VisualView CreateVisualView1()
        {
            VisualView CurrentVisualView = new VisualView();

            CurrentVisualView.Size2D                 = new Size2D(CurrentWidth, CurrentHeight);
            CurrentVisualView.ParentOrigin           = ParentOrigin.TopLeft;
            CurrentVisualView.PositionUsesPivotPoint = true;
            CurrentVisualView.PivotPoint             = PivotPoint.TopLeft;
            CurrentVisualView.Position2D             = new Position2D(FrameSize, 0);
            CurrentVisualView.BackgroundColor        = Color.White;

            VisualMap ThisVisualMap = null;
            string    VisualType;

            /// the main title
            ThisVisualMap = CreateTextVisual("VISUALS", 20.0f, new RelativeVector2(0.5f, 0.0f));
            CurrentVisualView.AddVisual("TextVisuals", ThisVisualMap);

            /// border visual and its title
            VisualType    = "Border";
            ThisVisualMap = CreateVisualMap(VisualType);
            ThisVisualMap.RelativePosition = new RelativeVector2(0.025f, 0.2f);
            CurrentVisualView.AddVisual(VisualType, ThisVisualMap);

            ThisVisualMap = CreateTextVisual(VisualType, 13.0f, new RelativeVector2(0.175f, 0.4f));
            CurrentVisualView.AddVisual("Text" + VisualType, ThisVisualMap);

            /// border visual - underneath the previous one
            BorderVisual ThisBorderVisual = (BorderVisual)CreateVisualMap(VisualType);

            ThisBorderVisual.Color            = Color.Green;
            ThisBorderVisual.RelativePosition = new RelativeVector2(0.045f, 0.18f);
            ThisBorderVisual.DepthIndex       = ThisVisualMap.DepthIndex - 1;
            CurrentVisualView.AddVisual(VisualType + "2", ThisBorderVisual);

            /// color visual and its title
            VisualType    = "Color";
            ThisVisualMap = CreateVisualMap(VisualType);
            ThisVisualMap.RelativePosition = new RelativeVector2(0.675f, 0.2f);
            CurrentVisualView.AddVisual(VisualType, ThisVisualMap);

            ThisVisualMap = CreateTextVisual(VisualType, 13.0f, new RelativeVector2(0.825f, 0.4f));
            CurrentVisualView.AddVisual("Text" + VisualType, ThisVisualMap);

            /// radial gradient 1
            VisualType    = "Gradient";
            ThisVisualMap = CreateVisualMap("Radial" + VisualType);
            ThisVisualMap.RelativePosition = new RelativeVector2(0.025f, 0.6f);
            CurrentVisualView.AddVisual("Radial" + VisualType + "1", ThisVisualMap);

            /// linear gradient and the title
            ThisVisualMap = CreateVisualMap("Linear" + VisualType);
            ThisVisualMap.RelativePosition = new RelativeVector2(0.350f, 0.6f);
            CurrentVisualView.AddVisual("Linear" + VisualType, ThisVisualMap);

            ThisVisualMap = CreateTextVisual(VisualType, 13.0f, new RelativeVector2(0.5f, 0.8f));
            CurrentVisualView.AddVisual("Text" + VisualType, ThisVisualMap);

            /// radial gradient 2
            GradientVisual ThisGradientVisual = (GradientVisual)CreateVisualMap("Radial" + VisualType);

            ThisGradientVisual.Center    = new Vector2(0.2f, 0.4f);
            ThisGradientVisual.Radius    = 0.2f;
            ThisGradientVisual.StopColor = new PropertyArray();
            ThisGradientVisual.StopColor.Add(new PropertyValue(Color.Blue));
            ThisGradientVisual.StopColor.Add(new PropertyValue(Color.Green));
            ThisGradientVisual.SpreadMethod     = GradientVisualSpreadMethodType.Repeat;
            ThisGradientVisual.RelativePosition = new RelativeVector2(0.675f, 0.6f);
            CurrentVisualView.AddVisual("Radial" + VisualType + "2", ThisGradientVisual);

            /// CurrentVisualView added to the MainVisualView
            MainVisualView.Add(CurrentVisualView);
            return(CurrentVisualView);
        }
Beispiel #5
0
        /// <summary>
        /// Create TableView, Create pushButtons and add them to tableView.
        /// </summary>
        private void Populate()
        {
            Vector2 stagesize = Window.Instance.Size;

            Tizen.NUI.VisualMap  imageVisual = CreateVisualMap("Image", new Vector2(60, 100.0f), image_jpg);
            Tizen.NUI.TextVisual imageText   = CreateTextVisual("ImageVisual", new Vector2(60, 0.0f));
            _visualView.AddVisual("imageVisual", imageVisual);
            _visualView.AddVisual("imageText", imageText);

            Tizen.NUI.VisualMap  gifVisual = CreateVisualMap("Animated", new Vector2(460, 100.0f), image_gif);
            Tizen.NUI.TextVisual gifText   = CreateTextVisual("AnimatedImageVisual", new Vector2(460, 0.0f));
            _visualView.AddVisual("gifVisual", gifVisual);
            _visualView.AddVisual("gifText", gifText);

            Tizen.NUI.VisualMap  colorVisual = CreateVisualMap("Color", new Vector2(860, 100.0f), image_gif);
            Tizen.NUI.TextVisual colorText   = CreateTextVisual("ColorVisual", new Vector2(860, 0.0f));
            _visualView.AddVisual("colorVisual", colorVisual);
            _visualView.AddVisual("colorText", colorText);

            VisualView svgView = new VisualView();

            svgView.PositionUsesPivotPoint = true;
            svgView.ParentOrigin           = ParentOrigin.TopLeft;
            svgView.PivotPoint             = PivotPoint.TopLeft;
            svgView.Position2D             = new Position2D(1280, 100);
            svgView.Size2D = new Size2D(200, 200);
            _visualView.Add(svgView);

            Tizen.NUI.VisualMap  svgVisual = CreateVisualMap("SVG", new Vector2(0, 0.0f), image_svg);
            Tizen.NUI.TextVisual svgText   = CreateTextVisual("SVGVisual", new Vector2(1260, 0.0f));
            svgView.AddVisual("svgVisual", svgVisual);
            _visualView.AddVisual("svgText", svgText);

            Tizen.NUI.VisualMap  nPatchVisual = CreateVisualMap("NPatch", new Vector2(1660, 100.0f), image_9patch);
            Tizen.NUI.TextVisual nPatchText   = CreateTextVisual("NPatchVisual", new Vector2(1660, 0.0f));
            _visualView.AddVisual("nPatchVisual", nPatchVisual);
            _visualView.AddVisual("nPatchText", nPatchText);

            VisualView borderView = new VisualView();

            borderView.BackgroundColor        = new Color(43.0f / 255.0f, 145.0f / 255.0f, 175.0f / 255.0f, 1.0f);
            borderView.PositionUsesPivotPoint = true;
            borderView.ParentOrigin           = ParentOrigin.TopLeft;
            borderView.PivotPoint             = PivotPoint.TopLeft;
            borderView.Position2D             = new Position2D(80, 400);
            borderView.Size2D = new Size2D(200, 200);
            _visualView.Add(borderView);
            Tizen.NUI.VisualMap  borderVisual = CreateVisualMap("Border", new Vector2(0, 0.0f), image_9patch);
            Tizen.NUI.TextVisual borderText   = CreateTextVisual("BorderVisual", new Vector2(60, 300.0f));
            borderView.AddVisual("borderVisual", borderVisual);
            _visualView.AddVisual("borderText", borderText);

            Tizen.NUI.VisualMap  gradientVisual = CreateVisualMap("Gradient", new Vector2(460, 400.0f), image_9patch);
            Tizen.NUI.TextVisual gradientText   = CreateTextVisual("GradientVisual", new Vector2(460, 300.0f));
            _visualView.AddVisual("gradientVisual", gradientVisual);
            _visualView.AddVisual("gradientText", gradientText);

            // primitive visual: Cone
            // Renders a simple 3D shape, such as a cube or sphere. Scaled to fit the control.
            // The shapes are generated with clockwise winding and backface culling on by default.
            // Cone : Equivalent to a conical frustrum with the top radius of zero
            Tizen.NUI.PrimitiveVisual cone     = CreatePrimitiveVisual(PrimitiveVisualShapeType.Cone, new Vector2(860, 400));
            Tizen.NUI.TextVisual      coneText = CreateTextVisual("Cone", new Vector2(860, 300.0f));
            _visualView.AddVisual("coneText", coneText);
            _visualView.AddVisual("cone", cone);

            // primitive visual: Sphere
            // Sphere : A perfectly round geometrical object in the three-dimensional space
            Tizen.NUI.PrimitiveVisual sphere     = CreatePrimitiveVisual(PrimitiveVisualShapeType.Sphere, new Vector2(1260, 400.0f));
            Tizen.NUI.TextVisual      sphereText = CreateTextVisual("Sphere", new Vector2(1260, 300.0f));
            _visualView.AddVisual("sphereText", sphereText);
            _visualView.AddVisual("sphere", sphere);

            // primitive visual: Cylinder
            // Cylinder : Equivalent to a conical frustrum with the top radius of zero
            Tizen.NUI.PrimitiveVisual cylinder     = CreatePrimitiveVisual(PrimitiveVisualShapeType.Cylinder, new Vector2(1660, 400.0f));
            Tizen.NUI.TextVisual      cylinderText = CreateTextVisual("Cylinder", new Vector2(1660, 300.0f));
            _visualView.AddVisual("cylinderText", cylinderText);
            _visualView.AddVisual("cylinder", cylinder);

            // primitive visual: ConicalFrustrum
            // ConicalFrustrum : Equivalent to a conical frustrum with
            // equal radii for the top and bottom circles.
            Tizen.NUI.PrimitiveVisual conicalFrustrum     = CreatePrimitiveVisual(PrimitiveVisualShapeType.ConicalFrustrum, new Vector2(60.0f, 700));
            Tizen.NUI.TextVisual      conicalFrustrumText = CreateTextVisual("ConicalFrustrum", new Vector2(60.0f, 600.0f));
            _visualView.AddVisual("conicalFrustrumText", conicalFrustrumText);
            _visualView.AddVisual("conicalFrustrum", conicalFrustrum);

            // primitive visual: Cube
            // Cube : Equivalent to a conical frustrum with equal radii for the top and bottom
            //     circles.
            Tizen.NUI.PrimitiveVisual cube     = CreatePrimitiveVisual(PrimitiveVisualShapeType.Cube, new Vector2(460.0f, 700.0f));
            Tizen.NUI.TextVisual      cubeText = CreateTextVisual("Cube", new Vector2(460.0f, 600.0f));
            _visualView.AddVisual("cubeText", cubeText);
            _visualView.AddVisual("cube", cube);

            // primitive visual: Octahedron
            // Equivalent to a bevelled cube with a bevel percentage of zero
            Tizen.NUI.PrimitiveVisual octahedron = CreatePrimitiveVisual(PrimitiveVisualShapeType.Octahedron, new Vector2(860.0f, 700.0f));
            Tizen.NUI.TextVisual      octaheText = CreateTextVisual("Octahedron", new Vector2(860.0f, 600.0f));
            _visualView.AddVisual("octaheText", octaheText);
            _visualView.AddVisual("octahedron", octahedron);

            // primitive visual: BevelledCube
            // BevelledCube : Equivalent to a bevelled cube with a bevel percentage of one
            Tizen.NUI.PrimitiveVisual bevelledCube     = CreatePrimitiveVisual(PrimitiveVisualShapeType.BevelledCube, new Vector2(1260, 700.0f));
            Tizen.NUI.TextVisual      bevelledCubeText = CreateTextVisual("BevelledCube", new Vector2(1260, 600.0f));
            _visualView.AddVisual("bevelledCubeText", bevelledCubeText);
            _visualView.AddVisual("bevelledCube", bevelledCube);
        }