Exemplo n.º 1
0
        /// <summary>
        /// First screen demo Application initialisation
        /// </summary>
        private void OnInitialize()
        {
            Tizen.Log.Debug("NUI", "OnInitialize() is called!");
            _hideScrollContainer = null;
            _stage     = Window.Instance;
            _stageSize = _stage.Size;
            _totalPostersContainers = Constants.TotalPostersContainers;
            _imagePath = Constants.ImageResourcePath;

            _postersContainer = new List <ScrollContainer>();
            _menuContainer    = new ScrollContainer();

            _hideBottomContainerAnimation = new Animation(250);
            _showBottomContainerAnimation = new Animation(250);

            // Create a Top Container for poster items
            _topContainer                        = new View();
            _topContainer.Size2D                 = new Vector2(_stageSize.Width, _stageSize.Height * Constants.TopContainerHeightFactor);
            _topContainer.Position               = new Position(0.0f, _stageSize.Height * Constants.TopContainerPositionFactor - 80, 0.0f);
            _topContainer.ParentOrigin           = ParentOrigin.TopLeft;
            _topContainer.PivotPoint             = PivotPoint.TopLeft;
            _topContainer.PositionUsesPivotPoint = true;

            // Add a background to Top container
            PropertyMap visual = new PropertyMap();

            visual.Insert(Visual.Property.Type, new PropertyValue((int)Visual.Type.Image));
            visual.Insert(ImageVisualProperty.URL, new PropertyValue(_imagePath + "/focuseffect/background.png"));
            _topContainer.Background = visual;
            _topContainer.Name       = "TopControl";

            // Create a Bottom Container
            _bottomContainer                        = new View();
            _bottomContainer.Size2D                 = new Vector2(_stageSize.Width, _stageSize.Height * Constants.BottomContainerHeightFactor);
            _bottomContainer.Position               = new Position(0.0f, _stageSize.Height * Constants.BottomContainerHidePositionFactor, 0.0f);
            _bottomContainer.ParentOrigin           = ParentOrigin.TopLeft;
            _bottomContainer.PivotPoint             = PivotPoint.TopLeft;
            _bottomContainer.PositionUsesPivotPoint = true;

            // Add a background to Bottom Container
            visual = new PropertyMap();
            visual.Insert(Visual.Property.Type, new PropertyValue((int)Visual.Type.Image));
            visual.Insert(ImageVisualProperty.URL, new PropertyValue(_imagePath + "/focuseffect/background.png"));
            _bottomContainer.Background = visual;
            _bottomContainer.Name       = "BottomControl";

            // Add both Top and Bottom Containers to Stage
            _stage.GetDefaultLayer().Add(_topContainer);
            _stage.GetDefaultLayer().Add(_bottomContainer);

            // Add a clip layer to Top Container
            _topClipLayer = new View();
            _topClipLayer.ParentOrigin           = ParentOrigin.BottomCenter;
            _topClipLayer.PivotPoint             = PivotPoint.BottomCenter;
            _topClipLayer.PositionUsesPivotPoint = true;

            _topContainer.Add(_topClipLayer);

            // Create a SpotLight for items / images of both
            // Poster and Menu ScrollContainers
            ImageView spotLight = new ImageView(_imagePath + "/focuseffect/highlight_spot.png");

            spotLight.WidthResizePolicy      = ResizePolicyType.UseNaturalSize;
            spotLight.HeightResizePolicy     = ResizePolicyType.UseNaturalSize;
            spotLight.ParentOrigin           = ParentOrigin.Center;
            spotLight.PivotPoint             = PivotPoint.Center;
            spotLight.PositionUsesPivotPoint = true;
            spotLight.Name = "spotLight";

            // Create a shadowBorder for items / images of Poster ScrollContainers
            ImageView shadowBorder = new ImageView(_imagePath + "/focuseffect/thumbnail_shadow.9.png");

            shadowBorder.ParentOrigin           = ParentOrigin.Center;
            shadowBorder.PivotPoint             = PivotPoint.Center;
            shadowBorder.PositionUsesPivotPoint = true;
            shadowBorder.WidthResizePolicy      = ResizePolicyType.SizeFixedOffsetFromParent;
            shadowBorder.HeightResizePolicy     = ResizePolicyType.SizeFixedOffsetFromParent;
            shadowBorder.SizeModeFactor         = (new Vector3(32.0f, 41.0f, 0.0f));
            shadowBorder.Name = "poster shadowBorder";

            // Create Poster Containers and add them to Top Clip layer
            for (int i = 0; i < _totalPostersContainers; i++)
            {
                _postersContainer.Add(new ScrollContainer());
                _postersContainer[i].Container.Name = "poster" + i;
                if (i == 0)
                {
                    _postersContainer[i].ItemSize = new Vector2((_stageSize.Width * Constants.Poster0ItemWidthFactor) - Constants.PostersContainerPadding,
                                                                _stageSize.Height * Constants.PostersItemHeightFactor);
                }
                else
                {
                    _postersContainer[i].ItemSize = new Vector2((_stageSize.Width * Constants.Poster1ItemWidthFactor) - Constants.PostersContainerPadding,
                                                                _stageSize.Height * Constants.PostersItemHeightFactor);
                }

                _postersContainer[i].Gap                   = Constants.PostersContainerPadding;
                _postersContainer[i].MarginX               = Constants.PostersContainerMargin;
                _postersContainer[i].OffsetYFator          = Constants.PostersContainerOffsetYFactor;
                _postersContainer[i].Width                 = _stageSize.Width;
                _postersContainer[i].Height                = _stageSize.Height * Constants.PostersContainerHeightFactor;
                _postersContainer[i].ShadowBorder          = shadowBorder;
                _postersContainer[i].ShadowBorder.Position = new Position(0.0f, 4.0f, 0.0f);
                _topClipLayer.Add(_postersContainer[i]);
            }

            // Add a clip layer to Bottom Container
            _bottomClipLayer                        = new View();
            _bottomClipLayer.PivotPoint             = PivotPoint.BottomLeft;
            _bottomClipLayer.PositionUsesPivotPoint = true;
            _bottomClipLayer.ParentOrigin           = ParentOrigin.BottomLeft;
            _bottomClipLayer.Position               = new Position(Constants.LauncherWidth, 35, 0);
            _bottomClipLayer.SizeWidth              = _stageSize.Width - Constants.LauncherWidth;
            _bottomClipLayer.SizeHeight             = _stageSize.Height * Constants.MenuContainerHeightFactor;
            _bottomContainer.ClippingMode           = ClippingModeType.ClipChildren;
            _bottomContainer.Add(_bottomClipLayer);

            // Add Launcher items to Bottom Container. Launcher is used
            // to display three images on left of Menu ScrollContainer
            launcherIcon = new ImageView[Convert.ToInt32(Constants.LauncherItemsCount)];
            for (int launcherIndex = 0; launcherIndex < Constants.LauncherItemsCount; launcherIndex++)
            {
                launcherIcon[launcherIndex]      = new ImageView(_imagePath + "/focuseffect/" + launcherIndex + "-normal.png");
                launcherIcon[launcherIndex].Name = "launcherIcon" + launcherIndex;
                launcherIcon[launcherIndex].WidthResizePolicy      = ResizePolicyType.UseNaturalSize;
                launcherIcon[launcherIndex].HeightResizePolicy     = ResizePolicyType.UseNaturalSize;
                launcherIcon[launcherIndex].ParentOrigin           = ParentOrigin.CenterLeft;
                launcherIcon[launcherIndex].PivotPoint             = PivotPoint.CenterLeft;
                launcherIcon[launcherIndex].PositionUsesPivotPoint = true;
                launcherIcon[launcherIndex].Position = new Position(Constants.LauncherIconWidth * launcherIndex + Constants.LauncherLeftMargin, 0.0f, 0.0f);
                _bottomContainer.Add(launcherIcon[launcherIndex]);
            }

            // Add a shadow seperator image between last Launcher
            // icon and Menu ScrollContainer
            _launcherSeparator      = new ImageView(_imagePath + "/focuseffect/focus_launcher_shadow_n.png");
            _launcherSeparator.Name = "launcherSeparator";
            _launcherSeparator.WidthResizePolicy      = ResizePolicyType.UseNaturalSize;
            _launcherSeparator.HeightResizePolicy     = ResizePolicyType.FillToParent;
            _launcherSeparator.ParentOrigin           = ParentOrigin.CenterLeft;
            _launcherSeparator.PivotPoint             = PivotPoint.CenterLeft;
            _launcherSeparator.PositionUsesPivotPoint = true;
            _launcherSeparator.Position = new Position(Constants.LauncherIconWidth * Constants.LauncherItemsCount + Constants.LauncherLeftMargin, 0.0f, 0.0f);
            _bottomContainer.Add(_launcherSeparator);

            // Create Menu Container and add it to Bottom Clip Layer
            Vector2 menuItemSize = new Vector2((_stageSize.Width * Constants.MenuItemWidthFactor) - Constants.MenuContainerPadding,
                                               _stageSize.Height * Constants.MenuItemHeightFactor);

            _menuContainer.Container.Name = "menu";
            _menuContainer.ItemSize       = new Vector2(110, 110);
            Tizen.Log.Fatal("NUI", "ItemSize.Width: " + _menuContainer.ItemSize.Width + "  ItemSize.Height: " + _menuContainer.ItemSize.Height);
            _menuContainer.Gap                                 = Constants.MenuContainerPadding;
            _menuContainer.MarginX                             = Constants.MenuContainerMargin;
            _menuContainer.OffsetYFator                        = Constants.MenuContainerOffsetYFactor;
            _menuContainer.OffsetX                             = Constants.LauncherWidth;
            _menuContainer.Width                               = _stageSize.Width - Constants.LauncherWidth;
            _menuContainer.Height                              = _stageSize.Height * Constants.MenuContainerHeightFactor;
            _menuContainer.ShadowBorder                        = new ImageView(_imagePath + "/focuseffect/focus_launcher_shadow.9.png");
            _menuContainer.ShadowBorder.Name                   = "_menuContainer.ShadowBorder";
            _menuContainer.ShadowBorder.Size2D                 = new Vector2(_menuContainer.ItemSize.Width + 40.0f, _menuContainer.ItemSize.Height + 50.0f);
            _menuContainer.ShadowBorder.Position               = new Position(0.0f, 0.0f, 0.0f);
            _menuContainer.ShadowBorder.ParentOrigin           = ParentOrigin.Center;
            _menuContainer.ShadowBorder.PivotPoint             = PivotPoint.Center;
            _menuContainer.ShadowBorder.PositionUsesPivotPoint = true;
            _menuContainer.ClippingMode                        = ClippingModeType.ClipChildren;
            _bottomClipLayer.Add(_menuContainer);

            // Create Items for Poster ScrollContainer
            CreatePosters();
            // Create Items for Menu ScrollContainer
            CreateMenu();

            // Initialize PreFocusChange event of KeyboardFocusManager
            _keyboardFocusManager = FocusManager.Instance;
            _keyboardFocusManager.PreFocusChange += OnKeyboardPreFocusChangeSignal;

            _keyboardFocusIndicator = new ImageView(_imagePath + "/focuseffect/highlight_stroke.9.png");
            _keyboardFocusIndicator.ParentOrigin           = ParentOrigin.Center;
            _keyboardFocusIndicator.PivotPoint             = PivotPoint.Center;
            _keyboardFocusIndicator.PositionUsesPivotPoint = true;
            _keyboardFocusIndicator.WidthResizePolicy      = ResizePolicyType.FillToParent;
            _keyboardFocusIndicator.HeightResizePolicy     = ResizePolicyType.FillToParent;

            _keyboardFocusManager.FocusIndicator = (_keyboardFocusIndicator);

            _keyboardFocusManager.SetAsFocusGroup(_menuContainer, true);
            _keyboardFocusManager.SetAsFocusGroup(_postersContainer[0], true);
            _keyboardFocusManager.SetAsFocusGroup(_postersContainer[1], true);
            _keyboardFocusManager.FocusGroupLoop = (true);

            _focusEffect = new FocusEffect();

            // Move Focus to Bottom Container (Menu ScrollContainer)
            ShowBottomContainer();
            _menuContainer.Focusable = true;
            _menuContainer.SetFocused(true);

#if true
            //test.
            TextLabel guide = new TextLabel();
            guide = new TextLabel();
            guide.HorizontalAlignment    = HorizontalAlignment.Center;
            guide.VerticalAlignment      = VerticalAlignment.Center;
            guide.PositionUsesPivotPoint = true;
            guide.ParentOrigin           = ParentOrigin.TopLeft;
            guide.PivotPoint             = PivotPoint.TopLeft;
            guide.Size2D          = new Size2D(1920, 100);
            guide.FontFamily      = "Samsung One 600";
            guide.Position2D      = new Position2D(0, 0);
            guide.MultiLine       = false;
            guide.PointSize       = 15.0f;
            guide.Text            = "FirstScreen";
            guide.TextColor       = Color.White;
            guide.BackgroundColor = new Color(43.0f / 255.0f, 145.0f / 255.0f, 175.0f / 255.0f, 1.0f);
            Window.Instance.GetDefaultLayer().Add(guide);
#endif
            Window.Instance.KeyEvent += AppBack;
        }
Exemplo n.º 2
0
 /// <summary>
 /// Perform Focus animation Effect on the current Focused Item on ScrollContainer.
 /// </summary>
 /// <param name="scrollContainer">Scroll Container</param>
 /// <param name="direction">Direction</param>
 private void FocusAnimation(ScrollContainer scrollContainer, FocusEffectDirection direction)
 {
     _focusEffect.FocusAnimation(scrollContainer.GetCurrentFocusedActor(), scrollContainer.ItemSize, 1000, direction);
 }