Exemplo n.º 1
0
        protected internal override void Draw(GuiRender render)
        => Elements.ForEach((element) =>
        {
            render.PushTransform(element.Transform);

            element.Draw(render);

            render.PopTransform();
        });
Exemplo n.º 2
0
        protected internal override void Draw(GuiRender render)
        {
            var colorGroup = Contain(Gui.Position) ? Style.Cover : Style.Color;
            var position   = new Point2f(
                (Size.Width - mTextBuffer.Size.Width) * 0.5f,
                (Size.Height - mTextBuffer.Size.Height) * 0.5f);

            render.FillRectangle(
                new Rectanglef(0, 0, Size.Width, Size.Height),
                colorGroup.Background);
            render.DrawText(position, mTextBuffer, colorGroup.Text);
        }
Exemplo n.º 3
0
        public VisualGuiSystem(GpuDevice device, Rectangle <int> area) : base("VisualGuiSystem")
        {
            RequireComponents.AddRequireComponentType <TransformGuiComponent>();
            RequireComponents.AddRequireComponentType <VisualGuiComponent>();

            Area = area;

            mRender = new GuiRender(device);

            mCanvas = new Image(
                new Size <int>(Area.Right - Area.Left, Area.Bottom - Area.Top),
                PixelFormat.RedBlueGreenAlpha8bit,
                mRender.Device);
        }
Exemplo n.º 4
0
        protected internal override void Draw(GuiRender render)
        {
            var padding        = 2.0f;
            var cursorHeight   = FontSize * 0.9f;
            var textPosition   = new Point2f(padding * 2, Utility.Center(Size.Height, mTextBuffer.Size.Height));
            var cursorPosition = new Point2f(textPosition.X + (
                                                 Cursor == 0 ? 0 : mTextBuffer.GetCharacterPostLocation(Cursor - 1)), Utility.Center(Size.Height, cursorHeight));
            var area = new Rectanglef(0, 0, Size.Width, Size.Height);

            render.FillRectangle(area, Style.Background);
            render.DrawRectangle(area, Style.Padding, padding);
            render.DrawText(textPosition, mTextBuffer, Style.Text);

            if (mPassTime < HalfDuration || Gui.GlobalElementStatus.FocusElement != this)
            {
                return;
            }

            render.DrawLine(cursorPosition, cursorPosition + new Vector2f(0, cursorHeight), Style.Cursor, padding);
        }
Exemplo n.º 5
0
        internal static void Initialize()
        {
            mRender = new GuiRender(GameSystems.GpuDevice);

            ///auto size, if true means when window size is changed, the canvas size is also changed.
            ///false means we do not change the size when window size changed.
            AutoSize = true;

            ///resize the canvas size
            ReSizeCanvas(GameSystems.EngineWindow.Size);

            GameSystems.EngineWindow.OnSizeChangeEvent += (sender, eventArg) =>
            {
                if (AutoSize == false)
                {
                    return;
                }

                ReSizeCanvas(eventArg.After);
            };

            ///add input mapped
            ///axis input mapped
            InputMapped.Mapped(InputProperty.MouseX, GuiProperty.InputMoveX);
            InputMapped.Mapped(InputProperty.MouseY, GuiProperty.InputMoveY);
            InputMapped.Mapped(InputProperty.MouseWheel, GuiProperty.InputWheel);
            ///button input mapped
            InputMapped.Mapped(InputProperty.LeftButton, GuiProperty.InputClick);
            ///mapped the keycode to input key
            foreach (var keycode in InputProperty.KeyCodeMapped)
            {
                InputMapped.Mapped(keycode.Value, GuiProperty.InputKey);
            }

            LogEmitter.Apply(LogLevel.Information, "[Initialize Gui System Finish] from [Gui]");
        }
Exemplo n.º 6
0
 protected internal virtual void Draw(GuiRender render)
 {
 }
Exemplo n.º 7
0
 protected internal override void Draw(GuiRender render)
 {
     render.DrawText(new Point2f(0, 0), mTextBuffer, Color);
 }