Canvas control. It should be the root parent for all other controls.
Наследование: Control
Пример #1
0
        public GwenInput(InputManager inputManager)
        {
            this.inputManager = inputManager;

            canvas = null;
            mouseX = 0;
            mouseY = 0;
            m_AltGr = false;

            mouse = inputManager.Mouse;
            if (mouse != null)
            {
                mouse.MouseMove += ProcessMouseMove;
                mouse.MouseDrag += ProcessMouseDrag;
                mouse.MouseButtonPress += ProcessMouseButtonPressed;
                mouse.MouseButtonRelease += ProcessMouseButtonReleased;
                mouse.MouseWheelMove += ProcessMouseWheel;
            }

            keyboard = inputManager.Keyboard;
            if (keyboard != null)
            {
                keyboard.KeyPress += ProcessKeyDown;
                keyboard.KeyRelease += ProcessKeyUp;
                keyboard.KeyText += ProcessText;
            }
        }
Пример #2
0
        public void Init(Renderer renderer, string textureName)
        {
            Renderer = renderer;
            Skin = new TexturedSkin(renderer, textureName);
            Canvas = new Canvas(Skin);

            Init();
        }
Пример #3
0
        public void TestButton()
        {
            using (var canvas = new Canvas(GUI.Skin))
            {
                var control = new Button(canvas);
                control.Text = "Button";

                GUI.AssertUnchanged(canvas, "button1");
            }
        }
Пример #4
0
        void InitializeGui()
        {
            GuiRenderer = new GwenRenderer();

            var textureName = "DefaultSkin.png";
            var defaultFont = new Font("Vera.ttf", 16);

            var resMan = Engine.GetEngine().ResourceManager;
            var options = new ResourceLoadOptions {Name = textureName, AsynchronousLoad = false};
            var imageHandle = resMan.LoadResource<Image>(options);
            if (imageHandle.Id == 0)
                throw new Exception("Could not load GUI texture: " + textureName);

            Skin = new TexturedSkin(GuiRenderer, imageHandle, defaultFont);
            Canvas = new Canvas(Skin);

            Input = new GwenInput(Engine.GetEngine().InputManager);
            Input.Initialize(Canvas);
        }
Пример #5
0
 public void Initialize(Canvas c)
 {
     canvas = c;
 }
Пример #6
0
        public static void RenderOverlay(Canvas canvas, Skins.Skin skin)
        {
            if (CurrentPackage == null)
                return;
            if (CurrentPackage.DrawControl == null)
                return;

            var old = skin.Renderer.RenderOffset;

            skin.Renderer.AddRenderOffset(new Rectangle(
                m_MouseX - SourceControl.X - CurrentPackage.HoldOffset.X,
                m_MouseY - SourceControl.Y - CurrentPackage.HoldOffset.Y, 0, 0));
            CurrentPackage.DrawControl.DoRender(skin);

            skin.Renderer.RenderOffset = old;
        }
Пример #7
0
 public void TestSetup()
 {
     canvas = GUI.guiRenderable.Canvas;
     canvas.Children.Clear();
 }
Пример #8
0
        private void Render(Canvas canvas, string outputPath)
        {
            canvas.RenderCanvas();

            var width = 0;
            var height = 0;
            foreach (var control in canvas.Children)
                RenderBounds(control, ref width, ref height);

            var imageSettings = new Settings { Height = (ushort)height, Width = (ushort)width };
            var renderBuffer = RenderDevice.Backend.CreateRenderBuffer(imageSettings);
            renderBuffer.CreateRenderBuffer(RenderBufferType.Color);
            renderBuffer.CreateRenderBuffer(RenderBufferType.Depth);

            renderBuffer.Context = MainWindow.Context;
            MainView.RenderTarget = renderBuffer;
            MainView.Size = new Vector2i(width, height);
            canvas.SetSize(width, height);

            RenderDevice.ActiveView = MainView;

            if (!renderBuffer.Check())
                throw new Exception("Error creating render buffer");

            renderBuffer.Bind();

            var rb = new RenderBlock();

            Renderer.Render(rb);

            RenderDevice.ClearView();

            RenderDevice.Render(rb);
            Engine.StepFrame();

            var image = renderBuffer.ReadImage(1);

            var imageWriter = new ImageWriter();
            imageWriter.Save(image, outputPath);

            renderBuffer.Unbind();
        }
Пример #9
0
        private bool HasRenderChanged(Canvas canvas, string assertId)
        {
            var baseDirectory = Path.GetFullPath(StoredValuesDirectory);
            var resultImagePath = Path.Combine(baseDirectory, assertId + "_result.png");
            var expectedImagePath = Path.Combine(baseDirectory, assertId + "_expected.png");
            var diffImagePath = Path.Combine(baseDirectory, assertId + "_diff.png");

            Render(canvas, resultImagePath);

            if (!File.Exists(expectedImagePath))
            {
                File.Copy(resultImagePath, expectedImagePath);
                File.Delete(resultImagePath);
                return false;
            }

            if (AreImagesEqual(expectedImagePath, resultImagePath, diffImagePath))
            {
                File.Delete(resultImagePath);
                File.Delete(diffImagePath);
                return false;
            }

            return true;
        }
Пример #10
0
        public void AssertUnchanged(Canvas canvas, string assertId, string assertMessage = "")
        {
            var renderChanged = HasRenderChanged(canvas, assertId);
            var serializationChanged = HasSerializationChanged(canvas, assertId);

            Assert.IsFalse(renderChanged, assertId+" render changed. "+assertMessage);
            Assert.IsFalse(serializationChanged, assertId+" serialization changed. "+assertMessage);
        }
Пример #11
0
        public PaneManager(Canvas canvas)
        {
            container = new Container(canvas) { Dock = Pos.Fill };

            FocusedGroup = new LinkedList<PaneGroup>();
        }