示例#1
0
        /// <summary>
        /// Set the area that the mouse cursor is constrained to.
        /// </summary>
        /// <param name="area">
        /// Pointer to a URect object that describes the area of the display that the mouse is allowed to occupy.
        /// The given area will be clipped to the current Renderer screen area - it is never possible for the mouse
        /// to leave this area.  If this parameter is NULL, the constraint is set to the size of the current Renderer
        /// screen area.
        /// </param>
        public void SetUnifiedConstraintArea(URect?area)
        {
            var rendererArea = new Rectf(Lunatics.Mathematics.Vector2.Zero,
                                         System.GetSingleton().GetRenderer().GetDisplaySize());

            if (area.HasValue)
            {
                d_constraints = area.Value;
            }
            else
            {
                d_constraints.d_min.d_x = UDim.Relative(rendererArea.d_min.X / rendererArea.Width);
                d_constraints.d_min.d_y = UDim.Relative(rendererArea.d_min.Y / rendererArea.Height);
                d_constraints.d_max.d_x = UDim.Relative(rendererArea.d_max.X / rendererArea.Width);
                d_constraints.d_max.d_y = UDim.Relative(rendererArea.d_max.Y / rendererArea.Height);
            }

            ConstrainPosition();
        }
示例#2
0
        /// <summary>
        /// Set the area that the mouse cursor is constrained to.
        /// </summary>
        /// <param name="area">
        /// Pointer to a Rect object that describes the area of the display that the mouse is allowed to occupy.
        /// The given area will be clipped to the current Renderer screen area - it is never possible for the
        /// mouse to leave this area. If this parameter is NULL, the constraint is set to the size of the current
        /// Renderer screen area.
        ///  </param>
        public void SetConstraintArea(Rectf?area)
        {
            var rendererArea = new Rectf(Vector2f.Zero, System.GetSingleton().GetRenderer().GetDisplaySize());

            if (!area.HasValue)
            {
                d_constraints.d_min.d_x = UDim.Relative(rendererArea.d_min.d_x / rendererArea.Width);
                d_constraints.d_min.d_y = UDim.Relative(rendererArea.d_min.d_y / rendererArea.Height);
                d_constraints.d_max.d_x = UDim.Relative(rendererArea.d_max.d_x / rendererArea.Width);
                d_constraints.d_max.d_y = UDim.Relative(rendererArea.d_max.d_y / rendererArea.Height);
            }
            else
            {
                var finalArea = area.Value.GetIntersection(rendererArea);

                d_constraints.d_min.d_x = UDim.Relative(finalArea.d_min.d_x / rendererArea.Width);
                d_constraints.d_min.d_y = UDim.Relative(finalArea.d_min.d_y / rendererArea.Height);
                d_constraints.d_max.d_x = UDim.Relative(finalArea.d_max.d_x / rendererArea.Width);
                d_constraints.d_max.d_y = UDim.Relative(finalArea.d_max.d_y / rendererArea.Height);
            }

            ConstrainPosition();
        }