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; } }
public void Init(Renderer renderer, string textureName) { Renderer = renderer; Skin = new TexturedSkin(renderer, textureName); Canvas = new Canvas(Skin); Init(); }
public void TestButton() { using (var canvas = new Canvas(GUI.Skin)) { var control = new Button(canvas); control.Text = "Button"; GUI.AssertUnchanged(canvas, "button1"); } }
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); }
public void Initialize(Canvas c) { canvas = c; }
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; }
public void TestSetup() { canvas = GUI.guiRenderable.Canvas; canvas.Children.Clear(); }
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(); }
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; }
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); }
public PaneManager(Canvas canvas) { container = new Container(canvas) { Dock = Pos.Fill }; FocusedGroup = new LinkedList<PaneGroup>(); }