Esempio n. 1
0
        /// <summary>
        /// Measure the layout and its content to determine the measured width and the measured height.<br />
        /// </summary>
        /// <param name="widthMeasureSpec">horizontal space requirements as imposed by the parent.</param>
        /// <param name="heightMeasureSpec">vertical space requirements as imposed by the parent.</param>
        /// <since_tizen> 6 </since_tizen>
        protected override void OnMeasure(MeasureSpecification widthMeasureSpec, MeasureSpecification heightMeasureSpec)
        {
            // Ensure layout respects it's given minimum size
            float maxWidth  = SuggestedMinimumWidth.AsDecimal();
            float maxHeight = SuggestedMinimumHeight.AsDecimal();

            MeasuredSize.StateType childWidthState  = MeasuredSize.StateType.MeasuredSizeOK;
            MeasuredSize.StateType childHeightState = MeasuredSize.StateType.MeasuredSizeOK;

            foreach (LayoutItem childLayout in IterateLayoutChildren())
            {
                // Get size of child with no padding, no margin. we won't support margin, padding for AbsolutLayout.
                MeasureChildWithoutPadding(childLayout, widthMeasureSpec, heightMeasureSpec);

                // Determine the width and height needed by the children using their given position and size.
                // Children could overlap so find the right most child.
                Position2D childPosition = childLayout.Owner.Position2D;
                float      childRight    = childLayout.MeasuredWidth.Size.AsDecimal() + childPosition.X;
                float      childBottom   = childLayout.MeasuredHeight.Size.AsDecimal() + childPosition.Y;

                if (maxWidth < childRight)
                {
                    maxWidth = childRight;
                }

                if (maxHeight < childBottom)
                {
                    maxHeight = childBottom;
                }

                if (childLayout.MeasuredWidth.State == MeasuredSize.StateType.MeasuredSizeTooSmall)
                {
                    childWidthState = MeasuredSize.StateType.MeasuredSizeTooSmall;
                }
                if (childLayout.MeasuredHeight.State == MeasuredSize.StateType.MeasuredSizeTooSmall)
                {
                    childHeightState = MeasuredSize.StateType.MeasuredSizeTooSmall;
                }
            }

            SetMeasuredDimensions(ResolveSizeAndState(new LayoutLength(maxWidth), widthMeasureSpec, childWidthState),
                                  ResolveSizeAndState(new LayoutLength(maxHeight), heightMeasureSpec, childHeightState));
        }
Esempio n. 2
0
        public NUIApplication(Graphics.BackendType backend, WindowMode windowMode = WindowMode.Opaque, Size2D windowSize = null, Position2D windowPosition = null, string styleSheet = "") : base(new NUICoreBackend(styleSheet, windowMode, windowSize, windowPosition))
        {
            //windowMode and styleSheet will be added later. currenlty it's not working as expected.
            Graphics.Backend = backend;
            Tizen.Log.Error("NUI", "Plaese DO NOT set graphical backend type with this constructor! This will give no effect!");

            if (windowSize != null)
            {
                _windowSize2D = windowSize;
            }
            if (windowPosition != null)
            {
                _windowPosition2D = windowPosition;
            }
            Registry.Instance.SavedApplicationThread = Thread.CurrentThread;
            me = this;
            // TODO Enable this after tizen-theme-manager is released.
            // themeLoader.ThemeChanged += TizenThemeChanged;
        }
Esempio n. 3
0
        protected override void OnLayout(bool changed, LayoutLength left, LayoutLength top, LayoutLength right, LayoutLength bottom)
        {
            // Absolute layout positions it's children at their Actor positions.
            // Children could overlap or spill outside the parent, as is the nature of absolute positions.
            foreach (LayoutItem childLayout in _children)
            {
                if (childLayout != null)
                {
                    LayoutLength childWidth  = childLayout.MeasuredWidth.Size;
                    LayoutLength childHeight = childLayout.MeasuredHeight.Size;

                    Position2D childPosition = childLayout.Owner.Position2D;

                    LayoutLength childLeft = new LayoutLength(childPosition.X);
                    LayoutLength childTop  = new LayoutLength(childPosition.Y);

                    childLayout.Layout(childLeft, childTop, childLeft + childWidth, childTop + childHeight);
                }
            }
        }
Esempio n. 4
0
        protected void LayoutForIndependentChild()
        {
            int count = LayoutChildren.Count;

            for (int childIndex = 0; childIndex < count; childIndex++)
            {
                LayoutItem childLayout = LayoutChildren[childIndex];
                if (childLayout != null)
                {
                    if (childLayout.Owner.ExcludeLayouting)
                    {
                        LayoutLength childWidth  = childLayout.MeasuredWidth.Size;
                        LayoutLength childHeight = childLayout.MeasuredHeight.Size;

                        Position2D childPosition = childLayout.Owner.Position2D;

                        LayoutLength childPositionX = new LayoutLength(childPosition.X);
                        LayoutLength childPositionY = new LayoutLength(childPosition.Y);

                        childLayout.Layout(childPositionX, childPositionY, childPositionX + childWidth, childPositionY + childHeight, true);
                    }
                }
            }
        }
Esempio n. 5
0
        // Starts of the actual measuring and layouting from the given root node.
        // Can be called from multiple starting roots but in series.
        void MeasureAndLayout(View root)
        {
            if (root !=null)
            {
                // Get parent MeasureSpecification, this could be the Window or View with an exact size.
                Container parentNode = root.GetParent();
                Size2D rootSize;
                Position2D rootPosition = root.Position2D;
                View parentView = parentNode as View;
                if (parentView)
                {
                    // Get parent View's Size.  If using Legacy size negotiation then should have been set already.
                    rootSize = new Size2D(parentView.Size2D.Width, parentView.Size2D.Height);
                }
                else
                {
                    // Parent not a View so assume it's a Layer which is the size of the window.
                    rootSize = new Size2D(_window.Size.Width, _window.Size.Height);
                }

                // Determine measure specification for root.
                // The root layout policy could be an exact size, be match parent or wrap children.
                // If wrap children then at most it can be the root parent size.
                // If match parent then should be root parent size.
                // If exact then should be that size limited by the root parent size.

                LayoutLength width = new LayoutLength(rootSize.Width);
                LayoutLength height = new LayoutLength(rootSize.Height);
                MeasureSpecification.ModeType widthMode = MeasureSpecification.ModeType.AtMost;
                MeasureSpecification.ModeType heightMode = MeasureSpecification.ModeType.AtMost;

                if (root.WidthSpecification >= 0 )
                {
                    // exact size provided so match width exactly
                    width = new LayoutLength(root.WidthSpecification);
                    widthMode = MeasureSpecification.ModeType.Exactly;
                }
                else if (root.WidthSpecification == LayoutParamPolicies.MatchParent)
                {
                    widthMode = MeasureSpecification.ModeType.Exactly;
                }

                if (root.HeightSpecification >= 0 )
                {
                    // exact size provided so match height exactly
                    height = new LayoutLength(root.HeightSpecification);
                    heightMode = MeasureSpecification.ModeType.Exactly;
                }
                else if (root.HeightSpecification == LayoutParamPolicies.MatchParent)
                {
                    heightMode = MeasureSpecification.ModeType.Exactly;
                }

                MeasureSpecification parentWidthSpecification =
                    new MeasureSpecification( width, widthMode);

                MeasureSpecification parentHeightSpecification =
                    new MeasureSpecification( height, heightMode);

                // Start at root with it's parent's widthSpecification and heightSpecification
                MeasureHierarchy(root, parentWidthSpecification, parentHeightSpecification);

                // Start at root which was just measured.
                PerformLayout( root, new LayoutLength(rootPosition.X),
                                     new LayoutLength(rootPosition.Y),
                                     new LayoutLength(rootPosition.X) + root.Layout.MeasuredWidth.Size,
                                     new LayoutLength(rootPosition.Y) + root.Layout.MeasuredHeight.Size );
            }
        }
Esempio n. 6
0
 /// <summary>
 /// The constructor with stylesheet, window mode, window size and window position.
 /// </summary>
 public NUICoreBackend(string stylesheet, NUIApplication.WindowMode windowMode, Size2D windowSize, Position2D windowPosition)
 {
     this.stylesheet = stylesheet;
     this.windowMode = windowMode;
     if (windowSize != null && windowPosition != null)
     {
         this.windowRectangle = new Rectangle(windowPosition.X, windowPosition.Y, windowSize.Width, windowSize.Height);
     }
 }
Esempio n. 7
0
 public NUIApplication(Size2D windowSize, Position2D windowPosition) : base(new NUICoreBackend("", WindowMode.Opaque, windowSize, windowPosition))
 {
     Registry.Instance.SavedApplicationThread = Thread.CurrentThread;
     _windowSize2D     = windowSize;
     _windowPosition2D = windowPosition;
 }
Esempio n. 8
0
 public NUIApplication(Size2D windowSize, Position2D windowPosition) : base(new NUICoreBackend("", NUIApplication.WindowMode.Opaque, windowSize, windowPosition))
 {
     ExternalThemeManager.Initialize();
 }
Esempio n. 9
0
 public NUIApplication(Size2D windowSize, Position2D windowPosition) : base(new NUICoreBackend("", NUIApplication.WindowMode.Opaque, windowSize, windowPosition))
 {
 }
Esempio n. 10
0
 public NUIApplication(Graphics.BackendType backend, WindowMode windowMode = WindowMode.Opaque, Size2D windowSize = null, Position2D windowPosition = null, string styleSheet = "") : base(new NUICoreBackend(styleSheet, windowMode, windowSize, windowPosition))
 {
     //windowMode and styleSheet will be added later. currently it's not working as expected.
     Graphics.Backend = backend;
     Tizen.Log.Error("NUI", "Plaese DO NOT set graphical backend type with this constructor! This will give no effect!");
 }
Esempio n. 11
0
        private Position2D Divide(Position2D rhs)
        {
            Position2D ret = new Position2D(NDalicPINVOKE.Vector2_Divide__SWIG_0(swigCPtr, Position2D.getCPtr(rhs)), true);

            if (NDalicPINVOKE.SWIGPendingException.Pending)
            {
                throw NDalicPINVOKE.SWIGPendingException.Retrieve();
            }
            return(ret);
        }
Esempio n. 12
0
 public NUIApplication(string styleSheet, WindowMode windowMode, Size2D windowSize, Position2D windowPosition, WindowType type) : base(new NUICoreBackend(styleSheet, windowMode, windowSize, windowPosition, type))
 {
     ExternalThemeManager.Initialize();
 }
Esempio n. 13
0
 /// <summary>
 /// Internal constructor with Graphics Backend Type
 /// </summary>
 /// <param name="backend"></param>
 /// <param name="windowMode"></param>
 /// <param name="windowSize"></param>
 /// <param name="windowPosition"></param>
 /// <param name="styleSheet"></param>
 internal NUIApplication(Graphics.BackendType backend, WindowMode windowMode = WindowMode.Opaque, Size2D windowSize = null, Position2D windowPosition = null, string styleSheet = "") : base(new NUICoreBackend(styleSheet, windowMode))
 {
     //windowMode and styleSheet will be added later. currenlty it's not working as expected.
     Graphics.Backend = backend;
     if (windowSize != null)
     {
         _windowSize2D = windowSize;
     }
     if (windowPosition != null)
     {
         _windowPosition2D = windowPosition;
     }
     Registry.Instance.SavedApplicationThread = Thread.CurrentThread;
 }
Esempio n. 14
0
 public NUIApplication(string styleSheet, Size2D windowSize, Position2D windowPosition, IBorderInterface borderInterface, WindowMode windowMode = WindowMode.Opaque) : base(new NUICoreBackend(styleSheet, windowMode, windowSize, windowPosition))
 {
     borderEnabled        = true;
     this.borderInterface = borderInterface;
 }
Esempio n. 15
0
 public NUIApplication(string styleSheet, WindowMode windowMode, Size2D windowSize, Position2D windowPosition) : base(new NUICoreBackend(styleSheet, windowMode, windowSize, windowPosition))
 {
     Registry.Instance.SavedApplicationThread = Thread.CurrentThread;
     // TODO Enable this after tizen-theme-manager is released.
     // themeLoader.ThemeChanged += TizenThemeChanged;
     _windowSize2D     = windowSize;
     _windowPosition2D = windowPosition;
     me = this;
 }
Esempio n. 16
0
 public NUIApplication(string styleSheet, Size2D windowSize, Position2D windowPosition) : base(new NUICoreBackend(styleSheet))
 {
     Registry.Instance.SavedApplicationThread = Thread.CurrentThread;
     _windowSize2D     = windowSize;
     _windowPosition2D = windowPosition;
 }
Esempio n. 17
0
        private Position2D Multiply(Position2D rhs)
        {
            Position2D ret = new Position2D(Interop.Vector2.Vector2_Multiply__SWIG_0(swigCPtr, Position2D.getCPtr(rhs)), true);

            if (NDalicPINVOKE.SWIGPendingException.Pending)
            {
                throw NDalicPINVOKE.SWIGPendingException.Retrieve();
            }
            return(ret);
        }
Esempio n. 18
0
        protected override void OnMeasure(MeasureSpecification widthMeasureSpec, MeasureSpecification heightMeasureSpec)
        {
            float totalHeight = 0.0f;
            float totalWidth  = 0.0f;

            HeightAndWidthState childState = new HeightAndWidthState(MeasuredSize.StateType.MeasuredSizeOK,
                                                                     MeasuredSize.StateType.MeasuredSizeOK);

            float minPositionX = 0.0f;
            float minPositionY = 0.0f;
            float maxPositionX = 0.0f;
            float maxPositionY = 0.0f;

            // measure children
            foreach (LayoutItem childLayout in _children)
            {
                if (childLayout != null)
                {
                    // Get size of child
                    MeasureChild(childLayout, widthMeasureSpec, heightMeasureSpec);
                    float childWidth  = childLayout.MeasuredWidth.Size.AsDecimal();
                    float childHeight = childLayout.MeasuredHeight.Size.AsDecimal();

                    // Determine the width and height needed by the children using their given position and size.
                    // Children could overlap so find the left most and right most child.
                    Position2D childPosition = childLayout.Owner.Position2D;
                    float      childLeft     = childPosition.X;
                    float      childTop      = childPosition.Y;

                    minPositionX = Math.Min(minPositionX, childLeft);
                    maxPositionX = Math.Max(maxPositionX, childLeft + childWidth);
                    // Children could overlap so find the highest and lowest child.
                    minPositionY = Math.Min(minPositionY, childTop);
                    maxPositionY = Math.Max(maxPositionY, childTop + childHeight);

                    // Store current width and height needed to contain all children.
                    totalWidth  = maxPositionX - minPositionX;
                    totalHeight = maxPositionY - minPositionY;

                    if (childLayout.MeasuredWidthAndState.State == MeasuredSize.StateType.MeasuredSizeTooSmall)
                    {
                        childState.widthState = MeasuredSize.StateType.MeasuredSizeTooSmall;
                    }
                    if (childLayout.MeasuredWidthAndState.State == MeasuredSize.StateType.MeasuredSizeTooSmall)
                    {
                        childState.heightState = MeasuredSize.StateType.MeasuredSizeTooSmall;
                    }
                }
            }


            MeasuredSize widthSizeAndState  = ResolveSizeAndState(new LayoutLength(totalWidth), widthMeasureSpec, MeasuredSize.StateType.MeasuredSizeOK);
            MeasuredSize heightSizeAndState = ResolveSizeAndState(new LayoutLength(totalHeight), heightMeasureSpec, MeasuredSize.StateType.MeasuredSizeOK);

            totalWidth  = widthSizeAndState.Size.AsDecimal();
            totalHeight = heightSizeAndState.Size.AsDecimal();

            // Ensure layout respects it's given minimum size
            totalWidth  = Math.Max(totalWidth, SuggestedMinimumWidth.AsDecimal());
            totalHeight = Math.Max(totalHeight, SuggestedMinimumHeight.AsDecimal());

            widthSizeAndState.State  = childState.widthState;
            heightSizeAndState.State = childState.heightState;

            SetMeasuredDimensions(ResolveSizeAndState(new LayoutLength(totalWidth), widthMeasureSpec, childState.widthState),
                                  ResolveSizeAndState(new LayoutLength(totalHeight), heightMeasureSpec, childState.heightState));
        }
Esempio n. 19
0
 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(Position2D obj)
 {
     return((obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr);
 }
Esempio n. 20
0
 /// <summary>
 /// Creates a Position2D property value.
 /// </summary>
 /// <param name="vectorValue">Position2D values.</param>
 /// <since_tizen> 3 </since_tizen>
 public PropertyValue(Position2D vectorValue) : this(Interop.PropertyValue.NewPropertyValueVector2(Position2D.getCPtr(vectorValue)), true)
 {
     if (NDalicPINVOKE.SWIGPendingException.Pending)
     {
         throw NDalicPINVOKE.SWIGPendingException.Retrieve();
     }
 }
Esempio n. 21
0
 public NUIApplication(Size2D windowSize, Position2D windowPosition, ThemeOptions option) : base(new NUICoreBackend("", NUIApplication.WindowMode.Opaque, windowSize, windowPosition))
 {
     ApplyThemeOption(option);
 }
Esempio n. 22
0
 /// <summary>
 /// The constructor.
 /// </summary>
 /// <param name="position2d">Position2D to create this vector from.</param>
 /// <since_tizen> 3 </since_tizen>
 public Position(Position2D position2d) : this(Interop.Vector3.new_Vector3__SWIG_3(Position2D.getCPtr(position2d)), true)
 {
     if (NDalicPINVOKE.SWIGPendingException.Pending)
     {
         throw NDalicPINVOKE.SWIGPendingException.Retrieve();
     }
 }
Esempio n. 23
0
 public NUIApplication(string styleSheet, Size2D windowSize, Position2D windowPosition) : base(new NUICoreBackend(styleSheet, WindowMode.Opaque, windowSize, windowPosition))
 {
 }
Esempio n. 24
0
 /// <summary>
 /// The constructor with stylesheet, window mode, window size and window position.
 /// </summary>
 public NUICoreBackend(string stylesheet, NUIApplication.WindowMode windowMode, Size2D windowSize, Position2D windowPosition)
 {
     _stylesheet     = stylesheet;
     _windowMode     = windowMode;
     _windowSize     = windowSize;
     _windowPosition = windowPosition;
 }