示例#1
0
            protected internal override void Draw(ref Rect area, IGUIRenderer renderer)
            {
                renderer.DrawRect(ref area, Control.Color);
                for (int i = 0; i < Control.items.Count; i++)
                {
                    Rect rect = new Rect(area.X, -Control.scrollbar.Value + area.Y + i * Control.Font.Size, area.W, Control.Font.Size);
                    Rect tmp;
                    if (renderer.SetSubRectDrawableArea(ref area, ref rect, out tmp))
                    {
                        Color c = (i == Control.selectedIndex ? Control.SelectedColor : (i % 2 == 0 ? Control.Color : Control.StripeColor));

                        renderer.DrawRect(ref rect, c);
                        renderer.DrawString(Control.Font, Control.items[i].ToString(), ref rect, Control.TextColor, TextAlignment.Left);
                    }
                }

                if (Control.items.Count * Control.Font.Size > Control.size.Y)
                {
                    Rect scrollRect = new Rect(area.X + Control.scrollbar.X, area.Y, Control.scrollbar.Width, area.H);
                    if (renderer.SetSubRectDrawableArea(ref area, ref scrollRect, out scrollRect))
                    {
                        Control.scrollbar.Draw(ref scrollRect, renderer);
                    }
                }
            }
示例#2
0
 protected internal override void Draw(ref Rect area, IGUIRenderer renderer)
 {
     renderer.DrawRect(ref area, Control.BackgroundColor);
     if (Control.Animation != null)
     {
         renderer.DrawFrame(Control.Animation.CurrentFrame, ref area, Control.AnimationColor);
     }
 }
示例#3
0
            protected internal override void Draw(ref Rect area, IGUIRenderer renderer)
            {
                renderer.DrawRect(ref area, Control.BackgroundColor);

                if (Control.IsChecked)
                {
                    renderer.DrawFrame(Control.checkedFrame, ref area, Control.BackgroundColor);
                }
            }
        protected internal override void Draw(ref Graphics.Rect drawableArea, IGUIRenderer renderer)
        {
            Color c = this.focused ? this.BackgroundColor : Color.AddContrast(this.BackgroundColor, 0.2f);

            drawableArea.W = this.Width;
            drawableArea.H = this.Height;

            renderer.DrawRect(ref drawableArea, c);
            if (Image != null)
                renderer.DrawFrame(Image, ref drawableArea, ImageColor);
        }
示例#5
0
            protected internal override void Draw(ref Rect area, IGUIRenderer batch)
            {
                batch.DrawRect(ref area, Control.BackgroundColor);
                Rect _contentRect = new Rect(area.X + Control.padding.X, area.Y + Control.padding.Y,
                                             area.W - Control.padding.X - Control.padding.W,
                                             area.H - Control.padding.H - Control.padding.Y);

                if (batch.SetSubRectDrawableArea(ref area, ref _contentRect, out _contentRect))
                {
                    batch.DrawMarkedString(Control.Font, Control.editText, ref _contentRect, Control.TextColor, Control.SelectedColor, TextAlignment.Left);
                }
            }
示例#6
0
        protected internal override void Draw(ref Graphics.Rect drawableArea, IGUIRenderer renderer)
        {
            Color c = this.focused ? this.BackgroundColor : Color.AddContrast(this.BackgroundColor, 0.2f);

            drawableArea.W = this.Width;
            drawableArea.H = this.Height;

            renderer.DrawRect(ref drawableArea, c);
            if (Image != null)
            {
                renderer.DrawFrame(Image, ref drawableArea, ImageColor);
            }
        }
示例#7
0
        protected internal override void DrawContent(ref Rect drawableArea, IGUIRenderer renderer)
        {
            if (this.BackgroundImage != null)
            {
                renderer.DrawFrame(this.BackgroundImage, ref drawableArea, BackgroundColor);
            }
            else
            {
                renderer.DrawRect(ref drawableArea, BackgroundColor);
            }

            base.DrawContent(ref drawableArea, renderer);
        }
示例#8
0
        protected internal override void DrawContent(ref Rect drawableArea, IGUIRenderer renderer)
        {
            if (this.BackgroundImage != null)
            {
                renderer.DrawFrame(this.BackgroundImage, ref drawableArea, BackgroundColor);
            }
            else
            {
                renderer.DrawRect(ref drawableArea, BackgroundColor);
            }


            base.DrawContent(ref drawableArea, renderer);
        }
示例#9
0
            protected internal override void Draw(ref Rect area, IGUIRenderer renderer)
            {
                renderer.DrawRect(ref area, Control.BackgroundColor);

                Rect _contentRect = Control.ContentArea;

                _contentRect.Displace(area.TopLeft);
                if (renderer.SetSubRectDrawableArea(ref area, ref _contentRect, out _contentRect))
                {
                    Vector2 offset = new Vector2(Control.HScrollBar.Value, Control.VScrollBar.Value);
                    renderer.DrawMarkedMultiLineString(Control.Font, Control.editText,
                                                       ref _contentRect, ref offset, Control.TextColor,
                                                       Control.SelectedColor);
                }
            }
示例#10
0
        protected internal override void Draw(ref Rect area, IGUIRenderer batch)
        {
            base.Draw(ref area, batch);
            if (Focused)
            {
                Color bgc = Color.AddContrast(this.BackgroundColor, 0.2f);
                Color fc = Color.AddContrast(this.FilledColor, 0.2f);
                Color bc = Color.AddContrast(this.ButtonColor, 0.2f);

                this.Draw(ref area, batch, bgc, fc, bc);
            }
            else
            {
                this.Draw(ref area, batch, this.BackgroundColor, this.FilledColor, this.ButtonColor);
            }
        }
示例#11
0
        protected internal override void Draw(ref Rect area, IGUIRenderer batch)
        {
            base.Draw(ref area, batch);
            if (Focused)
            {
                Color bgc = Color.AddContrast(this.BackgroundColor, 0.2f);
                Color fc  = Color.AddContrast(this.FilledColor, 0.2f);
                Color bc  = Color.AddContrast(this.ButtonColor, 0.2f);

                this.Draw(ref area, batch, bgc, fc, bc);
            }
            else
            {
                this.Draw(ref area, batch, this.BackgroundColor, this.FilledColor, this.ButtonColor);
            }
        }
示例#12
0
            protected internal override void Draw(ref Rect area, IGUIRenderer renderer)
            {
                renderer.DrawRect(ref area, Control.BackgroundColor);

                Rect _contentRect = new Rect(area.X + Control.padding.X, area.Y + Control.padding.Y,
                                             area.W - Control.padding.X - Control.padding.W,
                                             area.H - Control.padding.H);

                if (renderer.SetSubRectDrawableArea(ref area, ref _contentRect, out _contentRect))
                {
                    if (Control.editText.Length > 0)
                    {
                        Vector2 offset = new Vector2(Control.HScrollBar.Value, Control.VScrollBar.Value);
                        renderer.DrawMultiLineString(Control.Font, Control.Text, ref _contentRect, Control.TextColor, ref offset);
                    }
                }
            }
示例#13
0
        private void Draw(ref Rect area, IGUIRenderer renderer, Color c)
        {
            renderer.DrawRect(ref area, c);

            Rect textRect = new Rect(area.X + this.padding.X, area.Y + area.H - this.Font.Size, area.W - this.padding.W - this.padding.X, this.Font.Size);

            renderer.DrawString(this.Font, this.Text, ref textRect, this.TextColor, TextAlignment.Left);

            if (this.Icon != null)
            {
                Rect rect = new Rect(area.X + (this.size.X / 4),
                                     area.Y + (this.size.Y / 4),
                                     this.size.X / 2,
                                     this.size.Y / 2);

                renderer.DrawFrame(this.Icon, ref rect, this.IconColor);
            }
        }
示例#14
0
        protected internal override void DrawContent(ref Rect drawableArea, IGUIRenderer renderer)
        {
            Vector2 _offset = drawableArea.TopLeft + this.Bounds.TopLeft - this.ScrollOffset;

            foreach (var control in this.controls)
            {
                if (!control.Visible)
                {
                    continue;
                }

                Rect bounds = control.Bounds;
                bounds.Displace(_offset);
                if (renderer.SetSubRectDrawableArea(ref drawableArea, ref bounds, out bounds))
                {
                    control.Draw(ref bounds, renderer);
                }
            }
        }
示例#15
0
            protected internal override void Draw(ref Rect area, IGUIRenderer renderer)
            {
                renderer.DrawRect(ref area, Control.BackgroundColor);

                Rect _contentRect = new Rect(area.X + Control.padding.X, area.Y + Control.padding.Y,
                                             area.W - Control.padding.X - Control.padding.W,
                                             area.H - Control.padding.H);

                if (renderer.SetSubRectDrawableArea(ref area, ref _contentRect, out _contentRect))
                {
                    if (Control.editText.Length > 0)
                    {
                        renderer.DrawString(Control.Font, Control.Text, ref _contentRect, Control.TextColor, TextAlignment.Left);
                    }
                    else
                    {
                        renderer.DrawString(Control.Font, Control.Hint, ref _contentRect, Control.HintColor, TextAlignment.Left);
                    }
                }
            }
        protected internal override sealed void Draw(ref Rect area, IGUIRenderer renderer)
        {
            this.DrawContent(ref area, renderer);

            if (this.vScrollbar.Visible)
            {
                Rect scrollArea = new Rect(area.X + this.vScrollbar.X, area.Y, this.vScrollbar.Width, this.vScrollbar.Height);
                if(renderer.SetSubRectDrawableArea(ref area, ref scrollArea, out scrollArea))
                    this.vScrollbar.Draw(ref scrollArea, renderer);
            }

            if (this.hScrollbar.Visible)
            {
                Rect scrollArea = new Rect(area.X, area.Y + this.hScrollbar.Y, this.hScrollbar.Width, this.hScrollbar.Height);

                if (renderer.SetSubRectDrawableArea(ref area, ref scrollArea, out scrollArea))
                    this.hScrollbar.Draw(ref scrollArea, renderer);

            }
        }
        private void Draw(ref Rect area, IGUIRenderer renderer, Color bgc, Color bc)
        {
            renderer.DrawRect(ref area, bgc);

            float center = this.Value / (this.MaxValue - this.MinValue);
            Rect bounds = this.Bounds;
            Rect button;
            if (Orientation == EntityGUI.Orientation.Horizontal)
            {
                button = area;
                button.W = MathHelper.Clamp(MIN_SCROLLBAR_BUTTON_SIZE, this.size.X / 2, this.size.X / ((this.MaxValue - this.MinValue) / Step) * 2);
                button.X += MathHelper.Clamp(0, area.W - button.W, center * (bounds.W - button.W));
            }
            else
            {
                button = area;
                button.H = MathHelper.Clamp(MIN_SCROLLBAR_BUTTON_SIZE, this.size.Y / 2, this.size.Y / ((this.MaxValue - this.MinValue) / Step) * 2);
                button.Y += MathHelper.Clamp(0, area.H - button.H, center * (bounds.H - button.H));
            }
            renderer.DrawRect(ref button, bc);
        }
示例#18
0
        private void Draw(ref Rect area, IGUIRenderer renderer, Color bgc, Color bc)
        {
            renderer.DrawRect(ref area, bgc);

            float center = this.Value / (this.MaxValue - this.MinValue);
            Rect  bounds = this.Bounds;
            Rect  button;

            if (Orientation == EntityGUI.Orientation.Horizontal)
            {
                button    = area;
                button.W  = MathHelper.Clamp(MIN_SCROLLBAR_BUTTON_SIZE, this.size.X / 2, this.size.X / ((this.MaxValue - this.MinValue) / Step) * 2);
                button.X += MathHelper.Clamp(0, area.W - button.W, center * (bounds.W - button.W));
            }
            else
            {
                button    = area;
                button.H  = MathHelper.Clamp(MIN_SCROLLBAR_BUTTON_SIZE, this.size.Y / 2, this.size.Y / ((this.MaxValue - this.MinValue) / Step) * 2);
                button.Y += MathHelper.Clamp(0, area.H - button.H, center * (bounds.H - button.H));
            }
            renderer.DrawRect(ref button, bc);
        }
示例#19
0
        private void Draw(ref Rect area, IGUIRenderer batch, Color bgc, Color fc, Color bc)
        {
            batch.DrawRect(ref area, bgc);

            float center = this.Value / (this.MaxValue - this.MinValue);
            Rect button;
            Rect filled = area;
            if (Orientation == EntityGUI.Orientation.Horizontal)
            {
                button = new Rect(area.X, area.Y, area.H, area.H);
                button.X += center * (area.W - area.H);
                filled.W = button.X - filled.X;
            }
            else
            {
                button = new Rect(area.X, area.Y, area.W, area.W);
                button.Y += center * (area.H - area.W);
                filled.H = button.Y - filled.Y;
            }
            batch.DrawRect(ref filled, fc);
            batch.DrawRect(ref button, bc);
        }
示例#20
0
        private void Draw(ref Rect area, IGUIRenderer batch, Color bgc, Color fc, Color bc)
        {
            batch.DrawRect(ref area, bgc);

            float center = this.Value / (this.MaxValue - this.MinValue);
            Rect  button;
            Rect  filled = area;

            if (Orientation == EntityGUI.Orientation.Horizontal)
            {
                button    = new Rect(area.X, area.Y, area.H, area.H);
                button.X += center * (area.W - area.H);
                filled.W  = button.X - filled.X;
            }
            else
            {
                button    = new Rect(area.X, area.Y, area.W, area.W);
                button.Y += center * (area.H - area.W);
                filled.H  = button.Y - filled.Y;
            }
            batch.DrawRect(ref filled, fc);
            batch.DrawRect(ref button, bc);
        }
        protected internal override sealed void Draw(ref Rect area, IGUIRenderer renderer)
        {
            this.DrawContent(ref area, renderer);

            if (this.vScrollbar.Visible)
            {
                Rect scrollArea = new Rect(area.X + this.vScrollbar.X, area.Y, this.vScrollbar.Width, this.vScrollbar.Height);
                if (renderer.SetSubRectDrawableArea(ref area, ref scrollArea, out scrollArea))
                {
                    this.vScrollbar.Draw(ref scrollArea, renderer);
                }
            }

            if (this.hScrollbar.Visible)
            {
                Rect scrollArea = new Rect(area.X, area.Y + this.hScrollbar.Y, this.hScrollbar.Width, this.hScrollbar.Height);

                if (renderer.SetSubRectDrawableArea(ref area, ref scrollArea, out scrollArea))
                {
                    this.hScrollbar.Draw(ref scrollArea, renderer);
                }
            }
        }
示例#22
0
        void window_Load(object sender, EventArgs e)
        {
            this.GraphicsContext = new DebugGraphicsContext(new OpenGLGraphicsContext());
            var locator = new ServiceLocator();

            locator.RegisterService <IGraphicsContext>(this.GraphicsContext);

            var resourceLoader = new ResourceLoader();

            resourceLoader.AddImportersAndProcessors(typeof(ResourceLoader).Assembly);

            this.Resourses = new ResourceContext(locator, new TypeReaderFactory(), new TypeWriterFactory(), resourceLoader,
                                                 Path.Combine(this.resourceFolder, "Assets"), this.resourceFolder);
            this.Resourses.ShouldSaveAllLoadedAssets = false;

            pixel = this.Resourses.LoadAsset <TextureAtlas>("Fonts\\Metro_W_Pixel.atlas")["pixel"];
            var effect = this.Resourses.LoadAsset <ShaderProgram>("Basic.effect");

            this.spriteBuffer = new SpriteBuffer(this.GraphicsContext, effect);
            this.guiRenderer  = new GUIRenderer(this.spriteBuffer, pixel);


            window.VSync = VSyncMode.Off;
            window.Keyboard.KeyRepeat = true;

            // Other state
            GraphicsContext.Enable(EnableCap.Blend);
            GraphicsContext.Enable(EnableCap.ScissorTest);
            GraphicsContext.BlendFunc(BlendingFactorSrc.One, BlendingFactorDest.OneMinusSrcAlpha);

            var factory = CreateGUIFactory();

            this.Load(factory);

            clock = new Clock();
        }
示例#23
0
 protected internal override void Draw(ref Rect drawableArea, IGUIRenderer batch)
 {
     batch.DrawRect(ref drawableArea, this.BackgroundColor);
     batch.DrawString(this.Font, this.Text, ref drawableArea, this.TextColor, this.Alignment);
 }
示例#24
0
 protected internal override void Draw(ref Graphics.Rect area, IGUIRenderer batch)
 {
     throw new NotImplementedException();
 }
示例#25
0
            protected internal override void Draw(ref Rect area, IGUIRenderer renderer)
            {
                Color c = new Color(Control.BackgroundColor, 1f);

                this.Control.Draw(ref area, renderer, c);
            }
示例#26
0
            protected internal override void Draw(ref Rect area, IGUIRenderer renderer)
            {
                Color c = Color.AddContrast(Control.BackgroundColor, 0.2f);

                this.Control.Draw(ref area, renderer, c);
            }
示例#27
0
 protected internal override void Draw(ref Rect area, IGUIRenderer renderer)
 {
     this.Control.Draw(ref area, renderer, Control.BackgroundColor);
 }
示例#28
0
 internal protected abstract void Draw(ref Rect drawableArea, IGUIRenderer renderer);
 protected internal abstract void DrawContent(ref Rect area, IGUIRenderer renderer);
 protected internal abstract void DrawContent(ref Rect area, IGUIRenderer renderer);
        protected internal override void Draw(ref Rect area, IGUIRenderer renderer)
        {
            base.Draw(ref area, renderer);

            this.Draw(ref area, renderer, this.BackgroundColor, this.ButtonColor);
        }
示例#32
0
 internal void Draw(ref Rect drawableArea, IGUIRenderer batch)
 {
     ActiveState.Draw(ref drawableArea, batch);
 }
示例#33
0
        protected internal override void Draw(ref Rect area, IGUIRenderer renderer)
        {
            base.Draw(ref area, renderer);

            this.Draw(ref area, renderer, this.BackgroundColor, this.ButtonColor);
        }
        void window_Load(object sender, EventArgs e)
        {
            this.GraphicsContext = new DebugGraphicsContext(new OpenGLGraphicsContext());
            var locator = new ServiceLocator();
            locator.RegisterService<IGraphicsContext>(this.GraphicsContext);

            var resourceLoader = new ResourceLoader();
            resourceLoader.AddImportersAndProcessors(typeof(ResourceLoader).Assembly);

            this.Resourses = new ResourceContext(locator, new TypeReaderFactory(), new TypeWriterFactory(), resourceLoader,
                                                        Path.Combine(this.resourceFolder, "Assets"), this.resourceFolder);
            this.Resourses.ShouldSaveAllLoadedAssets = false;

            pixel = this.Resourses.LoadAsset<TextureAtlas>("Fonts\\Metro_W_Pixel.atlas")["pixel"];
            var effect = this.Resourses.LoadAsset<ShaderProgram>("Basic.effect");
            this.spriteBuffer = new SpriteBuffer(this.GraphicsContext, effect);
            this.guiRenderer = new GUIRenderer(this.spriteBuffer, pixel);

            window.VSync = VSyncMode.Off;
            window.Keyboard.KeyRepeat = true;

            // Other state
            GraphicsContext.Enable(EnableCap.Blend);
            GraphicsContext.Enable(EnableCap.ScissorTest);
            GraphicsContext.BlendFunc(BlendingFactorSrc.One, BlendingFactorDest.OneMinusSrcAlpha);

            var factory = CreateGUIFactory();
            this.Load(factory);

            clock = new Clock();
        }
示例#35
0
 protected internal override void Draw(ref Rect drawableArea, IGUIRenderer renderer)
 {
     fsm.Draw(ref drawableArea, renderer);
 }
示例#36
0
 protected internal abstract void Draw(ref Rect area, IGUIRenderer batch);