示例#1
0
        /// <summary>
        /// Renders the canvas. Call in your rendering loop.
        /// </summary>
        public void RenderCanvas()
        {
            DoThink();

            Skin.SkinBase         skin   = Skin;
            Renderer.RendererBase render = skin.Renderer;

            render.Begin();

            render.ClipRegion   = Bounds;
            render.RenderOffset = Point.Zero;

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

            DoRender(skin);

            DragAndDrop.RenderOverlay(this, skin);

            Gwen.Net.ToolTip.RenderToolTip(skin);

            render.EndClip();

            render.End();
        }
        public void Draw(Renderer.RendererBase 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);
        }
示例#3
0
        /// <summary>
        /// Renders the canvas. Call in your rendering loop.
        /// </summary>
        public void RenderCanvas()
        {
            DoThink();

            Renderer.RendererBase render = Skin.Renderer;

            render.Scale = Scale;
            render.Begin();

            Layout(false);

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

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

            DoRender(Skin);
            DragAndDrop.RenderOverlay(this, Skin);

            if (m_ToolTip.IsVisible)
            {
                m_ToolTip.DoRender(Skin);
            }
            render.EndClip();

            render.End();
        }
示例#4
0
        /// <summary>
        /// Renders the canvas. Call in your rendering loop.
        /// </summary>
        public void RenderCanvas()
        {
            doThink();

            Renderer.RendererBase render = Skin.Renderer;

            render.Begin();

            recurseLayout(Skin);

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

            if (ShouldDrawBackground)
            {
                render.DrawColor = backgroundColor;
                render.DrawFilledRect(Bounds);
            }

            DoRender(Skin);

            DragAndDrop.RenderOverlay(this, Skin);

            Gwen.ToolTip.RenderToolTip(Skin);

            render.EndClip();

            render.End();
        }
示例#5
0
        public void Draw(Renderer.RendererBase render, Rectangle r, Color col)
        {
            if (m_Texture == null)
            {
                return;
            }

            render.DrawColor = col;

            // this code would shrink window titles on small windows.
            // i have removed it, but i'm not positive of how it affects others

            // 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, r, 0, 0, 0);
            DrawRect(render, r, 1, 1, 0);
            DrawRect(render, r, 2, 2, 0);
            DrawRect(render, r, 3, 0, 1);
            DrawRect(render, r, 4, 1, 1);
            DrawRect(render, r, 5, 2, 1);
            DrawRect(render, r, 6, 0, 2);
            DrawRect(render, r, 7, 1, 2);
            DrawRect(render, r, 8, 2, 2);
        }
示例#6
0
 private void DrawRect(Renderer.RendererBase render, int i, int x, int y, int w, int h)
 {
     if (w > 0 && h > 0)
     {
         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]);
     }
 }
示例#7
0
        public TexturedBase(Renderer.RendererBase renderer, Stream textureData)
            : base(renderer)
        {
            texture = new Texture(Renderer);
            texture.LoadStream(textureData);

            initializeColors();
            initializeTextures();
        }
示例#8
0
        /// <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.RendererBase renderer, string textureName)
            : base(renderer)
        {
            texture = new Texture(Renderer);
            texture.Load(textureName);

            initializeColors();
            initializeTextures();
        }
示例#9
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SkinBase"/> class.
 /// </summary>
 /// <param name="renderer">Renderer to use.</param>
 protected SkinBase(Renderer.RendererBase renderer)
 {
     if (DefaultSkin == null)
     {
         DefaultSkin = this;
     }
     m_DefaultFont = new Font(renderer);
     m_Renderer    = renderer;
 }
示例#10
0
        public void DrawCenter(Renderer.RendererBase render, Rectangle r)
        {
            if (m_Texture == null)
            {
                return;
            }

            DrawCenter(render, r, Color.White);
        }
示例#11
0
        public void DrawCenter(Renderer.RendererBase 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);
        }
示例#12
0
        public void Draw(Renderer.RendererBase 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]);
        }
示例#13
0
        private void DrawRect(Renderer.RendererBase renderer, Rectangle r, int i, int cellx, int celly)
        {
            System.Diagnostics.Debug.Assert(cellx >= 0 && cellx <= 2 && celly >= 0 && celly <= 2, "BorderedTexture indices out of range");
            var xleft   = r.X;
            var xmid    = r.X + m_Margin.Left;
            var xright  = (r.X + r.Width) - m_Margin.Right;
            var ytop    = r.Y;
            var ymid    = r.Y + m_Margin.Top;
            var ybottom = (r.Y + r.Height) - m_Margin.Bottom;
            int x       = 0;
            int w       = 0;
            int y       = 0;
            int h       = 0;

            switch (cellx)
            {
            case 0:    //left
                x = xleft;
                w = m_Margin.Left;
                break;

            case 1:    //middle
                x = xmid;
                w = r.Width - m_Margin.Left - m_Margin.Right;
                break;

            case 2:    //right
                // x = Math.Max(xmid, xright);
                x = Math.Max(xmid, xright);
                w = m_Margin.Right;
                break;
            }

            switch (celly)
            {
            case 0:    //top
                y = ytop;
                h = m_Margin.Top;
                break;

            case 1:    //middle
                y = ymid;
                h = r.Height - m_Margin.Top - m_Margin.Bottom;
                break;

            case 2:    //bottom
                y = Math.Max(ymid, ybottom);
                h = m_Margin.Bottom;
                break;
            }
            DrawRect(renderer, i, x, y, w, h);
        }
示例#14
0
        /// <summary>
        /// Recursive rendering logic.
        /// </summary>
        /// <param name="skin">Skin to use.</param>
        /// <param name="clipRect">Clipping rectangle.</param>
        protected virtual void RenderRecursive(Skin.SkinBase skin, Rectangle clipRect)
        {
            Renderer.RendererBase render = skin.Renderer;
            Point oldRenderOffset        = render.RenderOffset;

            render.AddRenderOffset(clipRect);

            RenderUnder(skin);

            Rectangle oldRegion = render.ClipRegion;

            if (ShouldClip)
            {
                render.AddClipRegion(RenderBounds);

                if (!render.ClipRegionVisible)
                {
                    render.RenderOffset = oldRenderOffset;
                    render.ClipRegion   = oldRegion;
                    return;
                }

                render.StartClip();
            }

            //Render myself first
            Render(skin);

            if (m_Children.Count > 0)
            {
                //Now render my kids
                foreach (ControlBase child in m_Children)
                {
                    if (child.IsHidden)
                    {
                        continue;
                    }
                    child.DoRender(skin);
                }
            }

            render.ClipRegion = oldRegion;
            render.StartClip();
            RenderOver(skin);

            RenderFocus(skin);

            render.RenderOffset = oldRenderOffset;
        }
示例#15
0
        /// <summary>
        /// Renders over the actual control (overlays).
        /// </summary>
        /// <param name="skin">Skin to use.</param>
        protected override void renderOver(Skin.SkinBase skin)
        {
            if (!drawHover)
            {
                return;
            }

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

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

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

            render.DrawColor = Color.FromArgb(200, 255, 200, 255);
            render.DrawLinedRect(hoverRect);
        }
示例#16
0
        /// <summary>
        /// Renders over the actual control (overlays).
        /// </summary>
        /// <param name="skin">Skin to use.</param>
        protected override void RenderOver(Skin.SkinBase skin)
        {
            if (!m_DrawHover)
            {
                return;
            }

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

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

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

            render.DrawColor = new Color(200, 255, 200, 255);
            render.DrawLinedRect(m_HoverRect);
        }
示例#17
0
        public Simple(Renderer.RendererBase 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);
            Colors.Text.Contrast       = Color.FromArgb(255, Color.FromArgb(0x0077cc));
            Colors.Text.ContrastLow    = Color.FromArgb(255, Color.FromArgb(0x004d84));
            Colors.Text.Foreground     = Color.FromArgb(255, Color.FromArgb(0x374047));
            Colors.Text.Disabled       = Color.FromArgb(255, Color.FromArgb(0x7f8a93));
            Colors.Text.Highlight      = Color.FromArgb(255, Color.FromArgb(0xf8f9f9));
            Colors.Text.Inactive       = Color.FromArgb(255, Color.FromArgb(0xbec4c8));
            Colors.Accent              = Color.FromArgb(255, Color.FromArgb(0x0077cc));
            Colors.AccentHigh          = Color.FromArgb(255, Color.FromArgb(0xc6e1f3));
            Colors.AccentLow           = Color.FromArgb(255, Color.FromArgb(0x004d84));
            Colors.Background          = Color.FromArgb(255, Color.FromArgb(0xf8f9f9));
            Colors.BackgroundHighlight = Color.FromArgb(255, Color.FromArgb(0xebedee));
            Colors.Foreground          = Color.FromArgb(255, Color.FromArgb(0x374047));
            Colors.ForegroundHighlight = Color.FromArgb(255, Color.FromArgb(0xdee1e3));

            Colors.ModalBackground = Color.FromArgb(20, Colors.Background);
        }
示例#18
0
        public Simple(Renderer.RendererBase 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);
        }
示例#19
0
        public Simple(Renderer.RendererBase renderer) : base(renderer)
        {
            borderColor = Color.FromArgb(255, 80, 80, 80);
            //m_colBG = Color.FromArgb(255, 248, 248, 248);
            backgroundDarkColor = Color.FromArgb(255, 235, 235, 235);

            controlColor       = Color.FromArgb(255, 240, 240, 240);
            controlBrightColor = Color.FromArgb(255, 255, 255, 255);
            controlDarkColor   = Color.FromArgb(255, 214, 214, 214);
            controlDarkerColor = Color.FromArgb(255, 180, 180, 180);

            controlOutlineNormalColor  = Color.FromArgb(255, 112, 112, 112);
            controlOutlineLightColor   = Color.FromArgb(255, 144, 144, 144);
            controlOutlineLighterColor = Color.FromArgb(255, 210, 210, 210);

            highlightBackgroundColor = Color.FromArgb(255, 192, 221, 252);
            highlightBorderColor     = Color.FromArgb(255, 51, 153, 255);

            toolTipBackgroundColor = Color.FromArgb(255, 255, 255, 225);
            toolTipBorderColor     = Color.FromArgb(255, 0, 0, 0);

            modalColor = Color.FromArgb(150, 25, 25, 25);
        }
示例#20
0
        /// <summary>
        /// Rendering logic implementation.
        /// </summary>
        /// <param name="skin">Skin to use.</param>
        internal virtual void DoRender(Skin.SkinBase skin)
        {
            // If this control has a different skin,
            // then so does its children.
            if (m_Skin != null)
            {
                skin = m_Skin;
            }

            Renderer.RendererBase render = skin.Renderer;

            if (render.CTT != null && ShouldCacheToTexture)
            {
                DoCacheRender(skin, this);
                return;
            }

            RenderRecursive(skin, Bounds);

            if (DrawDebugOutlines)
            {
                skin.DrawDebugOutlines(this);
            }
        }
示例#21
0
 public LineBreaker(Renderer.RendererBase renderer, Font defaultFont)
     : base(renderer, defaultFont)
 {
 }
示例#22
0
 public LineBreaker(Renderer.RendererBase renderer, Font defaultFont)
 {
     m_Renderer    = renderer;
     m_DefaultFont = defaultFont;
 }
示例#23
0
 // can't have this as default param
 public void Draw(Renderer.RendererBase render, Rectangle r)
 {
     Draw(render, r, Color.White);
 }
示例#24
0
 public LineBreaker(Renderer.RendererBase renderer, Font defaultFont)
     : base(renderer, defaultFont)
 {
     m_Formatter = new LeftFormatter(renderer, defaultFont);
 }
示例#25
0
 public LeftFormatter(Renderer.RendererBase renderer, Font defaultFont)
     : base(renderer, defaultFont)
 {
 }
示例#26
0
        /// <summary>
        /// Renders the control to a cache using specified skin.
        /// </summary>
        /// <param name="skin">Skin to use.</param>
        /// <param name="master">Root parent.</param>
        protected virtual void DoCacheRender(Skin.SkinBase skin, ControlBase master)
        {
            Renderer.RendererBase    render = skin.Renderer;
            Renderer.ICacheToTexture cache  = render.CTT;

            if (cache == null)
            {
                return;
            }

            Point     oldRenderOffset = render.RenderOffset;
            Rectangle oldRegion       = render.ClipRegion;

            if (this != master)
            {
                render.AddRenderOffset(Bounds);
                render.AddClipRegion(Bounds);
            }
            else
            {
                render.RenderOffset = Point.Empty;
                render.ClipRegion   = new Rectangle(0, 0, Width, Height);
            }

            if (m_CacheTextureDirty && render.ClipRegionVisible)
            {
                render.StartClip();

                if (ShouldCacheToTexture)
                {
                    cache.SetupCacheTexture(this);
                }

                //Render myself first
                //var old = render.ClipRegion;
                //render.ClipRegion = Bounds;
                //var old = render.RenderOffset;
                //render.RenderOffset = new Point(Bounds.X, Bounds.Y);
                Render(skin);
                //render.RenderOffset = old;
                //render.ClipRegion = old;

                if (m_Children.Count > 0)
                {
                    //Now render my kids
                    foreach (ControlBase child in m_Children)
                    {
                        if (child.IsHidden)
                        {
                            continue;
                        }
                        child.DoCacheRender(skin, master);
                    }
                }

                if (ShouldCacheToTexture)
                {
                    cache.FinishCacheTexture(this);
                    m_CacheTextureDirty = false;
                }
            }

            render.ClipRegion = oldRegion;
            render.StartClip();
            render.RenderOffset = oldRenderOffset;

            if (ShouldCacheToTexture)
            {
                cache.DrawCachedControlTexture(this);
            }
        }
示例#27
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Base"/> class.
 /// </summary>
 /// <param name="renderer">Renderer to use.</param>
 protected SkinBase(Renderer.RendererBase renderer)
 {
     defaultFont   = new Font(renderer);
     this.renderer = renderer;
 }
示例#28
0
        /// <summary>
        /// Initializes a new instance of the <see cref="SkinBase"/> class.
        /// </summary>
        /// <param name="renderer">Renderer to use.</param>
        protected SkinBase(Renderer.RendererBase renderer)
        {
            m_Renderer = renderer;

            DefaultFont = new Font(renderer);
        }
示例#29
0
 public Formatter(Renderer.RendererBase renderer, Font defaultFont)
 {
     m_Renderer    = renderer;
     m_DefaultFont = defaultFont;
 }
示例#30
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Base"/> class.
 /// </summary>
 /// <param name="renderer">Renderer to use.</param>
 protected Base(Renderer.RendererBase renderer)
 {
     m_DefaultFont = new Font(renderer);
     m_Renderer = renderer;
 }
示例#31
0
 private void drawRect(Renderer.RendererBase render, int i, int x, int y, int w, int h)
 {
     render.DrawTexturedRect(texture,
                             new Rectangle(x, y, w, h),
                             rects[i].uv[0], rects[i].uv[1], rects[i].uv[2], rects[i].uv[3]);
 }