コード例 #1
0
        public void RenderVisual()
        {
            EnsureRenderContext();

            var oldScissorRectangle = CrossEngineStuff.GetScissor();

            _renderContext.Begin();

            CrossEngineStuff.SetScissor(InternalBounds);
            _renderContext.View    = InternalBounds;
            _renderContext.Opacity = Opacity;

            if (Stylesheet.Current.DesktopStyle != null &&
                Stylesheet.Current.DesktopStyle.Background != null)
            {
                _renderContext.Draw(Stylesheet.Current.DesktopStyle.Background, InternalBounds);
            }

            foreach (var widget in ChildrenCopy)
            {
                if (widget.Visible)
                {
                    widget.Render(_renderContext);
                }
            }

            _renderContext.End();

            CrossEngineStuff.SetScissor(oldScissorRectangle);
        }
コード例 #2
0
        public void Render()
        {
            var newBounds = BoundsFetcher();

            if (_bounds != newBounds)
            {
                InvalidateLayout();
            }

            _bounds = newBounds;

            if (_bounds.IsEmpty)
            {
                return;
            }

            UpdateInput();
            UpdateLayout();

            if (_scheduleMouseWheelFocus != null)
            {
                if (_scheduleMouseWheelFocus.AcceptsMouseWheelFocus)
                {
                    _previousMouseWheelFocus = FocusedMouseWheelWidget;
                    FocusedMouseWheelWidget  = _scheduleMouseWheelFocus;
                }

                _scheduleMouseWheelFocus = null;
            }

            EnsureRenderContext();

            var oldScissorRectangle = CrossEngineStuff.GetScissor();

            _renderContext.Begin();

            CrossEngineStuff.SetScissor(_bounds);
            _renderContext.View    = _bounds;
            _renderContext.Opacity = Opacity;

            if (Stylesheet.Current.DesktopStyle != null &&
                Stylesheet.Current.DesktopStyle.Background != null)
            {
                _renderContext.Draw(Stylesheet.Current.DesktopStyle.Background, _bounds);
            }

            foreach (var widget in ChildrenCopy)
            {
                if (widget.Visible)
                {
                    widget.Render(_renderContext);
                }
            }

            _renderContext.End();

            CrossEngineStuff.SetScissor(oldScissorRectangle);
        }
コード例 #3
0
ファイル: Desktop.cs プロジェクト: communityus-branch/Myra
        public void Render()
        {
            if (Bounds.IsEmpty)
            {
                return;
            }

            UpdateInput();
            UpdateLayout();

            EnsureRenderContext();

            var oldScissorRectangle = CrossEngineStuff.GetScissor();

            _renderContext.Begin();

            CrossEngineStuff.SetScissor(Bounds);
            _renderContext.View    = Bounds;
            _renderContext.Opacity = Opacity;

            if (Stylesheet.Current.DesktopStyle != null &&
                Stylesheet.Current.DesktopStyle.Background != null)
            {
                _renderContext.Draw(Stylesheet.Current.DesktopStyle.Background, Bounds);
            }

            foreach (var widget in ChildrenCopy)
            {
                if (widget.Visible)
                {
                    widget.Render(_renderContext);
                }
            }

            _renderContext.End();

            CrossEngineStuff.SetScissor(oldScissorRectangle);
        }
コード例 #4
0
ファイル: Widget.cs プロジェクト: Unimat2809/Myra
        public virtual void Render(RenderContext context)
        {
            if (!Visible)
            {
                return;
            }

            UpdateLayout();

            var view = Rectangle.Intersect(context.View, Bounds);

            if (view.Width == 0 || view.Height == 0)
            {
                return;
            }

            var batch = context.Batch;
            var oldScissorRectangle = CrossEngineStuff.GetScissor();

            if (ClipToBounds && !MyraEnvironment.DisableClipping)
            {
                var newScissorRectangle = Rectangle.Intersect(oldScissorRectangle, view);

                if (newScissorRectangle.IsEmpty)
                {
                    return;
                }

                context.Flush();

                CrossEngineStuff.SetScissor(newScissorRectangle);
            }

            var oldOpacity = context.Opacity;

            context.Opacity *= Opacity;

            // Background
            var background = GetCurrentBackground();

            if (background != null)
            {
                context.Draw(background, Bounds);
            }

            var oldView = context.View;

            context.View = view;
            InternalRender(context);
            context.View = oldView;

            // Border
            var border = GetCurrentBorder();

            if (border != null)
            {
                context.Draw(border, Bounds);
            }

            if (MyraEnvironment.DrawWidgetsFrames)
            {
                batch.DrawRectangle(Bounds, Color.LightGreen);
            }

            if (MyraEnvironment.DrawFocusedWidgetFrame && IsFocused)
            {
                batch.DrawRectangle(Bounds, Color.Red);
            }

            if (ClipToBounds && !MyraEnvironment.DisableClipping)
            {
                context.Flush();
                CrossEngineStuff.SetScissor(oldScissorRectangle);
            }

            context.Opacity = oldOpacity;
        }
コード例 #5
0
ファイル: Widget.cs プロジェクト: randomcrab/Myra
        public void Render(RenderContext context)
        {
            if (!Visible)
            {
                return;
            }

            UpdateLayout();

            var view = Rectangle.Intersect(context.View, Bounds);

            if (view.Width == 0 || view.Height == 0)
            {
                return;
            }

            var batch = context.Batch;
            var oldScissorRectangle = CrossEngineStuff.GetScissor();

            if (ClipToBounds && !MyraEnvironment.DisableClipping)
            {
                var newScissorRectangle = Rectangle.Intersect(oldScissorRectangle, view);

                if (newScissorRectangle.IsEmpty)
                {
                    return;
                }

                context.Flush();

                CrossEngineStuff.SetScissor(newScissorRectangle);
            }

            var oldOpacity = context.Opacity;
            var oldView    = context.View;

            context.Opacity *= Opacity;
            context.View     = view;

            BeforeRender?.Invoke(context);

            // Background
            var background = GetCurrentBackground();

            if (background != null)
            {
                context.Draw(background, BackgroundBounds);
            }

            // Borders
            var border = GetCurrentBorder();

            if (border != null)
            {
                var borderBounds = BorderBounds;
                if (BorderThickness.Left > 0)
                {
                    context.Draw(border, new Rectangle(borderBounds.X, borderBounds.Y, BorderThickness.Left, borderBounds.Height));
                }

                if (BorderThickness.Top > 0)
                {
                    context.Draw(border, new Rectangle(borderBounds.X, borderBounds.Y, borderBounds.Width, BorderThickness.Top));
                }

                if (BorderThickness.Right > 0)
                {
                    context.Draw(border, new Rectangle(borderBounds.Right - BorderThickness.Right, borderBounds.Y, BorderThickness.Right, borderBounds.Height));
                }

                if (BorderThickness.Bottom > 0)
                {
                    context.Draw(border, new Rectangle(borderBounds.X, borderBounds.Bottom - BorderThickness.Bottom, borderBounds.Width, BorderThickness.Bottom));
                }
            }

            InternalRender(context);

            AfterRender?.Invoke(context);

            // Restore context settings
            context.View    = oldView;
            context.Opacity = oldOpacity;

            // Optional debug rendering
            if (MyraEnvironment.DrawWidgetsFrames)
            {
                batch.DrawRectangle(Bounds, Color.LightGreen);
            }

            if (MyraEnvironment.DrawKeyboardFocusedWidgetFrame && IsKeyboardFocused)
            {
                batch.DrawRectangle(Bounds, Color.Red);
            }

            if (MyraEnvironment.DrawMouseWheelFocusedWidgetFrame && IsMouseWheelFocused)
            {
                batch.DrawRectangle(Bounds, Color.Yellow);
            }

            if (ClipToBounds && !MyraEnvironment.DisableClipping)
            {
                // Restore scissor
                context.Flush();
                CrossEngineStuff.SetScissor(oldScissorRectangle);
            }
        }