Exemple #1
0
        // This removes a PosterMenu the items from the specified unused Poster ScrollMenu (and Stage) to improve performance.
        private void UnparentPosterMenu(int posterMenuIndex)
        {
            if (posterMenuIndex != -1 && posterMenuIndex != _currentMenuIndex)
            {
                // Finished hiding (via animation end or force), remove from the clean-up list.
                _posterMenuHideStack.Remove(posterMenuIndex);
                ScrollMenu hiddenPosterMenu = _posterMenus[posterMenuIndex].ScrollMenu();

                // Unparent the poster-menu.
                if (hiddenPosterMenu != null && hiddenPosterMenu.Parent != null)
                {
                    hiddenPosterMenu.Parent.Remove(hiddenPosterMenu);
                }
            }
        }
Exemple #2
0
        private void CreatePosterMenus(ImageView spotLight)
        {
            _posterMenus = new List <PosterMenu>();
            int posterMenuHeight = Convert.ToInt32(_windowSize.Height * Constants.TopContainerHeightFactor);

            // Create Poster Containers and add them.
            for (int menuNumber = 0; menuNumber < _configuration.menuDefinitions.Count; ++menuNumber)
            {
                // Create Items for the Poster ScrollContainer.
                String     imagePath  = _resourcePath + "/images/PosterMenu/" + menuNumber;
                PosterMenu posterMenu = new PosterMenu(posterMenuHeight, imagePath, _configuration.menuDefinitions[menuNumber]);

                TextLabel title = new TextLabel(_configuration.menuDefinitions[menuNumber].description);
                title.Name = "menu-title_" + (menuNumber + 1);
                title.WidthResizePolicy      = ResizePolicyType.UseNaturalSize;
                title.PositionUsesPivotPoint = true;
                title.ParentOrigin           = new Position(0.05f, 0.04f, 0.5f);
                title.PivotPoint             = PivotPoint.TopLeft;
                //title.PointSize = Constants.TVBuild ? 29.0f : 23.0f; //TODO: Set with style sheet
                //title.PointSize = Constants.TVBuild ? 8.0f : 23.0f;
                title.PointSize = DeviceCheck.PointSize8;

                ScrollMenu posterMenuView = posterMenu.ScrollMenu();
                String     posterMenuName = "posterMenu-" + menuNumber;
                posterMenuView.Name = posterMenuName;
                posterMenuView.Add(title);
                CreateMenuHighlightEffects(posterMenuView, ("PosterMenu/" + menuNumber), spotLight);
                posterMenuView.PositionY = 200.0f;

                // Create show & hide effects
                Effect showEffect = new Effect(posterMenuView, Constants.ShowPosterDuration);
                showEffect.EndAction = Animation.EndActions.Cancel;
                showEffect.AddAction(new Effect.AnimateTo(posterMenuName, "ColorAlpha", 1.0f, new AlphaFunction(AlphaFunction.BuiltinFunctions.EaseOutSine)));
                showEffect.AddAction(new Effect.AnimateTo(posterMenuName, "PositionY", 0.0f, new AlphaFunction(AlphaFunction.BuiltinFunctions.EaseOutSine)));
                posterMenu.ShowMenuEffect = showEffect;
                Effect hideEffect = new Effect(posterMenuView, Constants.ShowPosterDuration);
                hideEffect.EndAction = Animation.EndActions.StopFinal;
                hideEffect.Finished += OnHidePosterEffectFinished;
                hideEffect.Tag       = menuNumber;
                hideEffect.AddAction(new Effect.AnimateTo(posterMenuName, "ColorAlpha", 0.0f, new AlphaFunction(AlphaFunction.BuiltinFunctions.EaseOutSine)));
                hideEffect.AddAction(new Effect.AnimateTo(posterMenuName, "PositionY", 200.0f, new AlphaFunction(AlphaFunction.BuiltinFunctions.EaseOutSine)));
                posterMenu.HideMenuEffect = hideEffect;

                _posterMenus.Add(posterMenu);
            }
        }
Exemple #3
0
        /// <summary>
        /// Creates and initializes a new instance of the SourceMenu class.
        /// Create Items for Menu ScrollContainer
        /// </summary>
        /// <param name="menuSize">menu size</param>
        /// <param name="itemSize">item size</param>
        public SourceMenu(Size2D menuSize, Size2D itemSize)
        {
            _menuSize           = menuSize;
            _itemSize           = itemSize;
            _showHideMenuEffect = new Effect[2];

            _showMenuAnimation           = new Animation(Constants.ShowMenuDuration);
            _showMenuAnimation.EndAction = Animation.EndActions.Cancel;

            _menu      = new ScrollMenu();
            _menu.Name = "sourceMenu";
            _menu.WidthResizePolicy      = ResizePolicyType.Fixed;
            _menu.HeightResizePolicy     = ResizePolicyType.Fixed;
            _menu.Size2D                 = _menuSize;
            _menu.PositionUsesPivotPoint = true;
            _menu.ParentOrigin           = ParentOrigin.BottomRight;
            _menu.PivotPoint             = PivotPoint.BottomRight;
            _menu.FocusCenter            = false;
            _menu.HoldFocusWhileInactive = true;
            _menu.StartActive            = true;
            _menu.ItemDimensions         = _itemSize;
            _menu.Gap             = Constants.SourceMenuPadding;
            _menu.Margin          = Constants.SourceMenuMargin;
            _menu.FocusScale      = Constants.SourceFocusScale;
            _menu.ScrollEndMargin = Constants.SourceMenuScrollEndMargin;

            _menu.ClippingMode = ClippingModeType.ClipToBoundingBox;

            for (int i = 0; i < Constants.MenuItemsCount; ++i)
            {
                ScrollMenu.ScrollItem scrollItem = new ScrollMenu.ScrollItem();
                scrollItem.item      = new ImageView(Constants.ResourcePath + "/images/SourceMenu/mi" + i + ".png");
                scrollItem.item.Name = ("menu-item_" + _menu.ItemCount);
                _menu.AddItem(scrollItem);
            }
        }
Exemple #4
0
        private void CreateMenuHighlightEffects(ScrollMenu menu, String resourceSubDirectory, ImageView spotLight)
        {
            View highlightContainer = new View();

            highlightContainer.PositionUsesPivotPoint = true;
            highlightContainer.PivotPoint             = Tizen.NUI.PivotPoint.Center;
            highlightContainer.ParentOrigin           = Tizen.NUI.ParentOrigin.Center;
            highlightContainer.WidthResizePolicy      = ResizePolicyType.FillToParent;
            highlightContainer.HeightResizePolicy     = ResizePolicyType.FillToParent;
            ImageView spotlightClip = ClippingImage.Create(_resourcePath + "/images/" + resourceSubDirectory + "/rounded-mask.png");

            spotlightClip.WidthResizePolicy  = ResizePolicyType.FillToParent;
            spotlightClip.HeightResizePolicy = ResizePolicyType.FillToParent;
            ImageView shineClip = ClippingImage.Create(_resourcePath + "/images/" + resourceSubDirectory + "/rounded-border-mask.png");

            shineClip.WidthResizePolicy  = ResizePolicyType.FillToParent;
            shineClip.HeightResizePolicy = ResizePolicyType.FillToParent;
            // We use a member variable for the shine as it gets reparented it can get garbage collected before it is accessed.
            ImageView shine = new ImageView(_resourcePath + "/images/HighlightEffect/source-shine.png");

            shine.Name = "shine";
            shine.WidthResizePolicy  = ResizePolicyType.FillToParent;
            shine.HeightResizePolicy = ResizePolicyType.FillToParent;
            shineClip.Add(shine);
            highlightContainer.Add(spotlightClip);
            highlightContainer.Add(shineClip);
            // TODO: We are only adding these to the menu as they cannot be encapsulated in the Effect class yet.
            menu.SpotLightClip = spotlightClip;
            menu.SpotLight     = spotLight;
            menu.Shine         = shine;

            // Create the selection effect, which includes a moving shine and a spotlight rotating in a circle.
            Effect selectionEffect = new Effect(highlightContainer);

            selectionEffect.Name = "selectionEffect";
            Size2D itemDimensions = menu.ItemDimensions;

            selectionEffect.AddAction(new Effect.AnimateBetween("shine", "PositionX", -itemDimensions.Width, itemDimensions.Width, new AlphaFunction(AlphaFunction.BuiltinFunctions.EaseInOutSine), 0, Constants.ShineDuration));
            Position topLeft      = new Position(-0.25f * itemDimensions.Width, -0.25f * itemDimensions.Height, 0.0f);
            Position topRight     = new Position(0.25f * itemDimensions.Width, -0.25f * itemDimensions.Height, 0.0f);
            Position bottomRight  = new Position(0.25f * itemDimensions.Width, 0.25f * itemDimensions.Height, 0.0f);
            Position bottomLeft   = new Position(-0.25f * itemDimensions.Width, 0.25f * itemDimensions.Height, 0.0f);
            Path     circularPath = new Path();

            circularPath.AddPoint(topLeft);
            circularPath.AddPoint(topRight);
            circularPath.AddPoint(bottomRight);
            circularPath.AddPoint(bottomLeft);
            circularPath.AddPoint(topLeft);
            circularPath.GenerateControlPoints(0.5f);
            Effect.AnimatePath spotlightAction = new Effect.AnimatePath("spotLight", circularPath, new Vector3(0.0f, 0.0f, 0.0f), new AlphaFunction(AlphaFunction.BuiltinFunctions.Default), 0, Constants.SpotLightDuration);
            spotlightAction.Looping = true;
            selectionEffect.AddAction(spotlightAction);
            menu.SelectionEffect = selectionEffect;

            // Create the pulse effect, which is a non-symetric X/Y scale "bounce" effect to the animation.
            Effect pulseEffect = new Effect(highlightContainer);

            pulseEffect.Name = "selectionEffect";
            // Note: The menu will automatically set the target of the pulse effect to the correct menu item itself.
            pulseEffect.AddAction(new Effect.AnimateTo(null, "Scale", new Vector3(1.3f, 1.0f, 1.0f), new AlphaFunction(AlphaFunction.BuiltinFunctions.Bounce)));
            menu.PulseEffect = pulseEffect;
        }
        /// <summary>
        /// Create Items for Poster ScrollContainer
        /// </summary>
        /// <param name="height">height</param>
        /// <param name="imagePath">image path</param>
        /// <param name="menuDefinition">menu definition</param>
        public PosterMenu(int height, String imagePath, TVConfiguration.MenuDefinition menuDefinition)
        {
            _showHideMenuEffect = new Effect[2];

            _menu = new ScrollMenu();
            _menu.PositionUsesPivotPoint = true;
            _menu.ParentOrigin           = ParentOrigin.TopCenter;
            _menu.PivotPoint             = PivotPoint.TopCenter;
            _menu.WidthResizePolicy      = ResizePolicyType.FillToParent;
            _menu.HeightResizePolicy     = ResizePolicyType.Fixed;
            _menu.Size            = new Size(0, height);
            _menu.StartActive     = false;
            _menu.Gap             = Constants.PostersContainerPadding;
            _menu.Margin          = Constants.PostersContainerMargin;
            _menu.ScrollEndMargin = Constants.PostersContainerScrollEndMargin;
            _menu.ItemDimensions  = menuDefinition.posterDimensions;
            _menu.FocusScale      = Constants.PosterFocusScale;

            for (int i = 0; i < menuDefinition.posterTitles.Count; i++)
            {
                ScrollMenu.ScrollItem scrollItem = new ScrollMenu.ScrollItem();

                TextLabel titleText = new TextLabel(menuDefinition.posterTitles[i]);
                titleText.Name = "poster-title_" + (i + 1);
                titleText.WidthResizePolicy      = ResizePolicyType.UseNaturalSize;
                titleText.PositionUsesPivotPoint = true;
                titleText.ParentOrigin           = new Position(0.5f, 0.04f, 0.5f);
                titleText.PivotPoint             = PivotPoint.TopCenter;
                //titleText.PointSize = Constants.TVBuild ? 27.0f : 19.0f; //TODO: Set with style sheet
                //titleText.PointSize = Constants.TVBuild ? 7.0f : 19.0f;
                titleText.PointSize = DeviceCheck.PointSize7;
                if (menuDefinition.whiteText)
                {
                    titleText.TextColor = Color.White;
                }
                else
                {
                    titleText.TextColor = Color.Black;
                }

                scrollItem.title = titleText;

                scrollItem.shadow = new ImageView(Constants.ResourcePath + "/images/Effect/thumbnail_cast_shadow.png");
                scrollItem.shadow.ParentOrigin           = ParentOrigin.BottomCenter;
                scrollItem.shadow.PivotPoint             = PivotPoint.TopCenter;
                scrollItem.shadow.PositionUsesPivotPoint = true;
                scrollItem.shadow.WidthResizePolicy      = ResizePolicyType.SizeRelativeToParent;
                scrollItem.shadow.HeightResizePolicy     = ResizePolicyType.SizeRelativeToParent;
                scrollItem.shadow.SizeModeFactor         = new Vector3(1.1f, 0.4f, 0.0f);
                scrollItem.shadow.Position = new Position(0.0f, 0.0f, 0.0f);
                scrollItem.shadow.Opacity  = 0.7f;

                if (_use3D)
                {
                    VisualView item = new VisualView();
                    item.WidthResizePolicy  = ResizePolicyType.Fixed;
                    item.HeightResizePolicy = ResizePolicyType.Fixed;
                    item.Size     = new Size(400, 400);
                    item.Position = new Position(0.0f, 0.0f, 0.0f);
                    item.PositionUsesPivotPoint = true;
                    item.Focusable    = true;
                    item.ParentOrigin = ParentOrigin.Center;
                    item.PivotPoint   = PivotPoint.Center;

                    MeshVisual meshVisualMap1 = new MeshVisual();
                    meshVisualMap1.ObjectURL = Constants.ResourcePath + "/models/roundedcube-half3.obj";
                    if ((i % 3) == 0)
                    {
                        meshVisualMap1.MaterialtURL = Constants.ResourcePath + "/models/roundedcube-half2.mtl";
                    }
                    else if ((i % 3) == 1)
                    {
                        meshVisualMap1.MaterialtURL = Constants.ResourcePath + "/models/roundedcube-half3.mtl";
                    }
                    else
                    {
                        meshVisualMap1.MaterialtURL = Constants.ResourcePath + "/models/roundedcube-half4.mtl";
                    }

                    meshVisualMap1.TexturesPath   = Constants.ResourcePath + "/images/";
                    meshVisualMap1.ShadingMode    = MeshVisualShadingModeValue.TexturedWithSpecularLighting;
                    meshVisualMap1.Size           = new Size2D(445, 445);
                    meshVisualMap1.Position       = new Position2D(0, 0);
                    meshVisualMap1.PositionPolicy = VisualTransformPolicyType.Absolute;
                    meshVisualMap1.SizePolicy     = VisualTransformPolicyType.Absolute;
                    meshVisualMap1.Origin         = Visual.AlignType.Center;
                    meshVisualMap1.AnchorPoint    = Visual.AlignType.Center;
                    item.AddVisual("meshVisual1", meshVisualMap1);
                    item.Name       = "poster-item_" + (i + 1);
                    scrollItem.item = item;

                    _menu.AddItem(scrollItem);
                }
                else
                {
/*                  string itemURL = _imagePath + "/poster" + j + "/" + (i % 14) + ".jpg";
 *                  View item = new ImageView(itemURL);
 *                  View itemReflection = new ImageView(itemURL);
 *                  item.Name = ("poster-item-" + _postersContainer[j].ItemCount);
 *                  _postersContainer[j].AddItem(item, shadowBorder, itemReflection);
 */
                    string itemURL = imagePath + "/mi" + i + ".png";
                    scrollItem.item      = new ImageView(itemURL);
                    scrollItem.item.Name = "poster-item_" + (i + 1);
                    _menu.AddItem(scrollItem);
                }
            }
        }