void DrawRect(Renderer.Base render, int i, int x, int y, int w, int h, Color clr)
 {
     render.DrawTexturedRect(
         mTexture, new Rectangle(x, y, w, h), clr, mRects[i].Uv[0], mRects[i].Uv[1], mRects[i].Uv[2],
         mRects[i].Uv[3]
         );
 }
        public void Draw(Renderer.Base render, Rectangle r, Color col)
        {
            if (m_Texture == null)
            {
                return;
            }

            render.DrawColor = col;

            if (r.Width < m_Width && r.Height < m_Height)
            {
                render.DrawTexturedRect(m_Texture, r, m_Rects[0].uv[0], m_Rects[0].uv[1], m_Rects[8].uv[2], m_Rects[8].uv[3]);
                return;
            }

            DrawRect(render, 0, r.X, r.Y, m_Margin.Left, m_Margin.Top);
            DrawRect(render, 1, r.X + m_Margin.Left, r.Y, r.Width - m_Margin.Left - m_Margin.Right, m_Margin.Top);
            DrawRect(render, 2, (r.X + r.Width) - m_Margin.Right, r.Y, m_Margin.Right, m_Margin.Top);

            DrawRect(render, 3, r.X, r.Y + m_Margin.Top, m_Margin.Left, r.Height - m_Margin.Top - m_Margin.Bottom);
            DrawRect(render, 4, r.X + m_Margin.Left, r.Y + m_Margin.Top, r.Width - m_Margin.Left - m_Margin.Right,
                     r.Height - m_Margin.Top - m_Margin.Bottom);
            DrawRect(render, 5, (r.X + r.Width) - m_Margin.Right, r.Y + m_Margin.Top, m_Margin.Right,
                     r.Height - m_Margin.Top - m_Margin.Bottom);

            DrawRect(render, 6, r.X, (r.Y + r.Height) - m_Margin.Bottom, m_Margin.Left, m_Margin.Bottom);
            DrawRect(render, 7, r.X + m_Margin.Left, (r.Y + r.Height) - m_Margin.Bottom,
                     r.Width - m_Margin.Left - m_Margin.Right, m_Margin.Bottom);
            DrawRect(render, 8, (r.X + r.Width) - m_Margin.Right, (r.Y + r.Height) - m_Margin.Bottom, m_Margin.Right,
                     m_Margin.Bottom);
        }
Beispiel #3
0
        public static void OnMouseMoved(Base hoveredControl, int x, int y, Renderer.Base renderer)
        {
            // Always keep these up to date, they're used to draw the dragged control.
            m_MouseX = x;
            m_MouseY = y;

            // If we're not carrying anything, then check to see if we should
            // pick up from a control that we're holding down. If not, then forget it.
            if (CurrentPackage == null && !ShouldStartDraggingControl(x, y))
            {
                return;
            }

            // Swap to this new hovered control and notify them of the change.
            UpdateHoveredControl(hoveredControl, x, y, renderer);

            if (HoveredControl == null)
            {
                return;
            }

            // Update the hovered control every mouse move, so it can show where
            // the dropped control will land etc..
            HoveredControl.DragAndDrop_Hover(CurrentPackage, x, y);

            // Override the cursor - since it might have been set my underlying controls
            // Ideally this would show the 'being dragged' control. TODO
            renderer.SetCursor(CursorType.Arrow);

            hoveredControl.Redraw();
        }
Beispiel #4
0
        /// <summary>
        /// Renders the canvas. Call in your rendering loop.
        /// </summary>
        public void RenderCanvas()
        {
            DoThink();

            Renderer.Base render = Skin.Renderer;

            render.Begin();

            RecurseLayout(Skin);

            render.ClipRegion   = Bounds;
            render.RenderOffset = Point.Empty;
            render.Scale        = Scale;

            if (ShouldDrawBackground)
            {
                render.DrawColor = m_BackgroundColor;
                render.DrawFilledRect(RenderBounds);
            }

            DoRender(Skin);

            DragAndDrop.RenderOverlay(this, Skin);

            Gwen.ToolTip.RenderToolTip(Skin);

            render.EndClip();

            render.End();
        }
Beispiel #5
0
        public void DrawCenter(Renderer.Base render, Rectangle r)
        {
            if (m_Texture == null)
            {
                return;
            }

            DrawCenter(render, r, Color.White);
        }
Beispiel #6
0
        public void DrawCenter(Renderer.Base render, Rectangle r, Color col)
        {
            r.X     += (int)((r.Width - m_Width) * 0.5);
            r.Y     += (int)((r.Height - m_Height) * 0.5);
            r.Width  = m_Width;
            r.Height = m_Height;

            Draw(render, r, col);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="TexturedBase"/> class.
        /// </summary>
        /// <param name="renderer">Renderer to use.</param>
        /// <param name="textureName">Name of the skin texture map.</param>
        public TexturedBase(Renderer.Base renderer, string textureName)
            : base(renderer)
        {
            m_Texture = new Texture(Renderer);
            m_Texture.Load(textureName);

            InitializeColors();
            InitializeTextures();
        }
        public TexturedBase(Renderer.Base renderer, Stream textureData)
            : base(renderer)
        {
            m_Texture = new Texture(Renderer);
            m_Texture.LoadStream(textureData);

            InitializeColors();
            InitializeTextures();
        }
Beispiel #9
0
        private static void UpdateHoveredControl(Base control, int x, int y, Renderer.Base renderer)
        {
            //
            // We use this global variable to represent our hovered control
            // That way, if the new hovered control gets deleted in one of the
            // Hover callbacks, we won't be left with a hanging pointer.
            // This isn't ideal - but it's minimal.
            //
            m_NewHoveredControl = control;

            // Nothing to change..
            if (HoveredControl == m_NewHoveredControl)
            {
                return;
            }

            // We changed - tell the old hovered control that it's no longer hovered.
            if (HoveredControl != null && HoveredControl != m_NewHoveredControl)
            {
                HoveredControl.DragAndDrop_HoverLeave(CurrentPackage);
            }

            // If we're hovering where the control came from, just forget it.
            // By changing it to null here we're not going to show any error cursors
            // it will just do nothing if you drop it.
            if (m_NewHoveredControl == SourceControl)
            {
                m_NewHoveredControl = null;
            }

            // Check to see if the new potential control can accept this type of package.
            // If not, ignore it and show an error cursor.
            while (m_NewHoveredControl != null && !m_NewHoveredControl.DragAndDrop_CanAcceptPackage(CurrentPackage))
            {
                // We can't drop on this control, so lets try to drop
                // onto its parent..
                m_NewHoveredControl = m_NewHoveredControl.Parent;

                // Its parents are dead. We can't drop it here.
                // Show the NO WAY cursor.
                if (m_NewHoveredControl == null)
                {
                    renderer.SetCursor(CursorType.No);
                }
            }

            // Become out new hovered control
            HoveredControl = m_NewHoveredControl;

            // If we exist, tell us that we've started hovering.
            if (HoveredControl != null)
            {
                HoveredControl.DragAndDrop_HoverEnter(CurrentPackage, x, y);
            }

            m_NewHoveredControl = null;
        }
Beispiel #10
0
        public void Draw(Renderer.Base render, Rectangle r, Color col)
        {
            if (m_Texture == null)
            {
                return;
            }

            render.DrawColor = col;
            render.DrawTexturedRect(m_Texture, r, m_uv[0], m_uv[1], m_uv[2], m_uv[3]);
        }
        // can't have this as default param

        /*public void Draw(Renderer.Base render, Rectangle r, Color col )
         * {
         *  Draw(render, r, Color.Red);
         * }*/

        public void Draw(Renderer.Base render, Rectangle r, Color col)
        {
            if (mTexture == null)
            {
                return;
            }

            render.DrawColor = col;

            if (r.Width < mWidth && r.Height < mHeight)
            {
                render.DrawTexturedRect(
                    mTexture, r, col, mRects[0].Uv[0], mRects[0].Uv[1], mRects[8].Uv[2], mRects[8].Uv[3]
                    );

                return;
            }

            DrawRect(render, 0, r.X, r.Y, mMargin.Left, mMargin.Top, col);
            DrawRect(render, 1, r.X + mMargin.Left, r.Y, r.Width - mMargin.Left - mMargin.Right, mMargin.Top, col);
            DrawRect(render, 2, r.X + r.Width - mMargin.Right, r.Y, mMargin.Right, mMargin.Top, col);

            DrawRect(render, 3, r.X, r.Y + mMargin.Top, mMargin.Left, r.Height - mMargin.Top - mMargin.Bottom, col);
            DrawRect(
                render, 4, r.X + mMargin.Left, r.Y + mMargin.Top, r.Width - mMargin.Left - mMargin.Right,
                r.Height - mMargin.Top - mMargin.Bottom, col
                );

            DrawRect(
                render, 5, r.X + r.Width - mMargin.Right, r.Y + mMargin.Top, mMargin.Right,
                r.Height - mMargin.Top - mMargin.Bottom, col
                );

            DrawRect(render, 6, r.X, r.Y + r.Height - mMargin.Bottom, mMargin.Left, mMargin.Bottom, col);
            DrawRect(
                render, 7, r.X + mMargin.Left, r.Y + r.Height - mMargin.Bottom, r.Width - mMargin.Left - mMargin.Right,
                mMargin.Bottom, col
                );

            DrawRect(
                render, 8, r.X + r.Width - mMargin.Right, r.Y + r.Height - mMargin.Bottom, mMargin.Right,
                mMargin.Bottom, col
                );
        }
        public void Draw(Renderer.Base render, Rectangle r, Color col)
        {
            if (m_Texture == null)
            {
                return;
            }

            render.DrawColor = col;

            if (r.Width < m_Width && r.Height < m_Height)
            {
                //this control is smaller than the texture, so we don't need to do any stretching. Use the top left UV coordinates and the bottom right UV coordinates
                render.DrawTexturedRect(m_Texture, r, m_Rects[0].uv[0], m_Rects[0].uv[1], m_Rects[8].uv[2], m_Rects[8].uv[3]);
                return;
            }

            //This control is larger than the texture, so we need to stretch the textures

            //Draw the upper left rectangle
            DrawRect(render, 0, r.X, r.Y, m_Margin.Left, m_Margin.Top);
            //Draw the upper center rectangle
            DrawRect(render, 1, r.X + m_Margin.Left, r.Y, r.Width - m_Margin.Left - m_Margin.Right, m_Margin.Top);
            //draw the upper right rectangle
            DrawRect(render, 2, (r.X + r.Width) - m_Margin.Right, r.Y, m_Margin.Right, m_Margin.Top);

            //Draw the center left rectangle
            DrawRect(render, 3, r.X, r.Y + m_Margin.Top, m_Margin.Left, r.Height - m_Margin.Top - m_Margin.Bottom);
            //Draw the center center rectangle
            DrawRect(render, 4, r.X + m_Margin.Left, r.Y + m_Margin.Top, r.Width - m_Margin.Left - m_Margin.Right,
                     r.Height - m_Margin.Top - m_Margin.Bottom);
            //Draw the center right rectangle
            DrawRect(render, 5, (r.X + r.Width) - m_Margin.Right, r.Y + m_Margin.Top, m_Margin.Right,
                     r.Height - m_Margin.Top - m_Margin.Bottom);

            //Draw the lower left rectangle
            DrawRect(render, 6, r.X, (r.Y + r.Height) - m_Margin.Bottom, m_Margin.Left, m_Margin.Bottom);
            //Draw the lower center rectangle
            DrawRect(render, 7, r.X + m_Margin.Left, (r.Y + r.Height) - m_Margin.Bottom,
                     r.Width - m_Margin.Left - m_Margin.Right, m_Margin.Bottom);
            //Draw the lower right rectangle
            DrawRect(render, 8, (r.X + r.Width) - m_Margin.Right, (r.Y + r.Height) - m_Margin.Bottom, m_Margin.Right,
                     m_Margin.Bottom);
        }
        /// <summary>
        /// Renders over the actual control (overlays).
        /// </summary>
        /// <param name="skin">Skin to use.</param>
        protected override void RenderOver(Skin.Base skin)
        {
            if (!m_DrawHover)
            {
                return;
            }

            Renderer.Base render = skin.Renderer;
            render.DrawColor = Color.FromArgb(20, 255, 200, 255);
            render.DrawFilledRect(RenderBounds);

            if (m_HoverRect.Width == 0)
            {
                return;
            }

            render.DrawColor = Color.FromArgb(100, 255, 200, 255);
            render.DrawFilledRect(m_HoverRect);

            render.DrawColor = Color.FromArgb(200, 255, 200, 255);
            render.DrawLinedRect(m_HoverRect);
        }
Beispiel #14
0
        public Simple(Renderer.Base renderer) : base(renderer)
        {
            m_colBorderColor = Color.FromArgb(255, 80, 80, 80);
            //m_colBG = Color.FromArgb(255, 248, 248, 248);
            m_colBGDark = Color.FromArgb(255, 235, 235, 235);

            m_colControl       = Color.FromArgb(255, 240, 240, 240);
            m_colControlBright = Color.FromArgb(255, 255, 255, 255);
            m_colControlDark   = Color.FromArgb(255, 214, 214, 214);
            m_colControlDarker = Color.FromArgb(255, 180, 180, 180);

            m_colControlOutlineNormal  = Color.FromArgb(255, 112, 112, 112);
            m_colControlOutlineLight   = Color.FromArgb(255, 144, 144, 144);
            m_colControlOutlineLighter = Color.FromArgb(255, 210, 210, 210);

            m_colHighlightBG     = Color.FromArgb(255, 192, 221, 252);
            m_colHighlightBorder = Color.FromArgb(255, 51, 153, 255);

            m_colToolTipBackground = Color.FromArgb(255, 255, 255, 225);
            m_colToolTipBorder     = Color.FromArgb(255, 0, 0, 0);

            m_colModal = Color.FromArgb(150, 25, 25, 25);
        }
Beispiel #15
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Base"/> class.
 /// </summary>
 /// <param name="renderer">Renderer to use.</param>
 protected Base(Renderer.Base renderer)
 {
     m_DefaultFont = new Font(renderer);
     m_Renderer    = renderer;
 }
Beispiel #16
0
 /// <summary>
 ///     Initializes a new instance of the <see cref="Base" /> class.
 /// </summary>
 /// <param name="renderer">Renderer to use.</param>
 protected Base(Renderer.Base renderer)
 {
     mDefaultFont = null;
     mRenderer    = renderer;
 }
Beispiel #17
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Base"/> class.
 /// </summary>
 /// <param name="renderer">Renderer to use.</param>
 protected Base(Renderer.Base renderer)
 {
     m_DefaultFont = new Font(renderer);
     m_Renderer = renderer;
 }
 void DrawRect(Renderer.Base render, int i, int x, int y, int w, int h)
 {
     render.DrawTexturedRect(m_Texture,
                             new Rectangle(x, y, w, h),
                             m_Rects[i].uv[0], m_Rects[i].uv[1], m_Rects[i].uv[2], m_Rects[i].uv[3]);
 }
Beispiel #19
0
 // can't have this as default param
 public void Draw(Renderer.Base render, Rectangle r)
 {
     Draw(render, r, Color.White);
 }