public Screen(IInputManager rawInputs, IUIStyle style, IBatchedDrawingService drawingService, IGameWindowService windowService) { actions = new Queue <Action>(); DrawingService = drawingService ?? throw new ArgumentNullException(nameof(drawingService)); WindowService = windowService ?? throw new ArgumentNullException(nameof(windowService)); FocusManager = new ScreenFocusManager(this); MouseHoverManager = new MouseHoverManager(); Root = new RootPane(this, style); style.StyleResolver.AddRoot(Root); PopUpManager = new PopupManager(Root); inputState = new InputStateImpl(); eventHandler = new ScreenEventHandling(this, Root, rawInputs); eventHandler.AddMousePostProcessor(new PopupClosingEventProcessor(Root)); eventHandler.AddMousePostProcessor(inputState); eventHandler.AddKeyPostProcessor(inputState); if (TracingUtil.InputTracing.Switch.ShouldTrace(TraceEventType.Verbose)) { eventHandler.AddKeyPreProcessor(new TracingEventSink <KeyEventData>()); eventHandler.AddMousePreProcessor(new TracingEventSink <MouseEventData>()); eventHandler.AddTouchPreProcessor(new TracingEventSink <TouchEventData>()); eventHandler.AddGamePadPreProcessor(new TracingEventSink <GamePadEventData>()); } }
protected override void DrawWidgetStateOverlay(IBatchedDrawingService drawingService) { var borderRect = BorderRect; var reservedSize = FrameTexture?.CornerArea.Horizontal ?? 0; var usableWidth = Math.Max(0, borderRect.Width - reservedSize); var range = Math.Max(Max, Min) - Math.Min(Max, Min); var effectiveValue = MathHelper.Clamp(lerpValue.CurrentValue, Min, Max) - Min; var width = usableWidth * effectiveValue / range; if (width > 0) { Rectangle progressRect; if (Direction == ProgressBarDirection.LeftToRight) { progressRect = new Rectangle(borderRect.X, borderRect.Y, (int)(width + reservedSize), borderRect.Height); } else { progressRect = new Rectangle((int)(borderRect.X + (usableWidth - width)), borderRect.Y, (int)(width + reservedSize), borderRect.Height); } drawingService.DrawBox(WidgetStateOverlayTexture, progressRect, WidgetStateOverlayColor); } }
protected override void DrawWidget(IBatchedDrawingService drawingService) { if (blinkAnimation.CurrentValue > 0) { drawingService.FillRect(LayoutRect, Color); } }
protected override void DrawChildren(IBatchedDrawingService drawingService) { for (var i = 0; i < this.Count; i++) { var child = this[i]; if (ReferenceEquals(child, ActiveTab)) { continue; } if (DragState.DragActive && ReferenceEquals(child, DragState.DraggedTab)) { continue; } if (child.Visibility == Visibility.Visible) { child.Draw(drawingService); } } if (ActiveTab?.Visibility == Visibility.Visible) { ActiveTab.Draw(drawingService); } if (DragState.DragActive && DragState.DraggedTab != ActiveTab) { DragState.DraggedTab?.Draw(drawingService); } }
public void Draw(IBatchedDrawingService drawingService, Rectangle rectangle, Vector2 viewportPosition) { //check if combined list is created if not create it. if (Combined == null) { Combined = CombinedList(); } //cycle through each item in combined list //if the value is true its a layer, false its an object group //the key should be the name of the layer or object group foreach (var layer in Combined) { if (layer.Value == true) { if (Layers[layer.Key].Opacity != 0) { Layers[layer.Key].Draw(drawingService, Tilesets.Values, rectangle, viewportPosition, TileWidth, TileHeight, scale); } } else { ObjectGroups[layer.Key].Draw(this, drawingService, rectangle, viewportPosition, TileWidth, TileHeight, scale); } } }
protected override void DrawKeyboardFocus(IBatchedDrawingService drawingService) { if (!IsPressed) { base.DrawKeyboardFocus(drawingService); } }
protected override void DrawChildren(IBatchedDrawingService drawingService) { if (ScrollbarVisible) { base.DrawChildren(drawingService); } }
public void Draw(IBatchedDrawingService drawingService) { for (var index = 0; index < highlights.Count; index++) { var highlight = highlights[index]; highlight.Draw(drawingService, documentView); } }
protected override void DrawChildren(IBatchedDrawingService drawingService) { base.DrawChildren(drawingService); if (DisplayLineNumbers) { lineNumberRenderer.Draw(drawingService); } }
public static void DrawImageFromAtlas(this IBatchedDrawingService ds, IUITexture image, Rectangle destinationRectangle, Rectangle?sourceRectangle, Color color) { ds.Draw(image, destinationRectangle, sourceRectangle, color, 0.0f, Vector2.Zero, SpriteEffects.None, 0.0f); }
public override void Draw(IBatchedDrawingService drawingService) { for (var index = 0; index < lineBreakContent.Count; index++) { var chunk = lineBreakContent[index]; var view = chunk.Chunk; view.Draw(drawingService); } }
public StatefulUIManager( IInputManager inputManager, IBatchedDrawingService drawingService, IGameWindowService windowService, ContentManager contentManager, IGameStateManager stateManager) : base(inputManager, drawingService, windowService, contentManager) { this.stateManager = stateManager; }
public sealed override void Draw(IBatchedDrawingService drawingService) { DrawBox(drawingService); for (var i = 0; i < Count; i += 1) { var child = this[i]; child.Draw(drawingService); } EndDrawBox(drawingService); }
public void Draw(Map result, IBatchedDrawingService d, Rectangle rectangle, Vector2 viewportPosition, int tilewidth, int tileheight, float scale) { foreach (var objects in Objects.Values) { if (objects.Texture != null) { objects.Draw(d, rectangle, new Vector2(this.X * (result.TileWidth), this.Y * result.TileHeight), viewportPosition, this.Opacity, scale); } } }
protected virtual SpriteBatch BeginDraw(IBatchedDrawingService drawingService) { var sb = drawingService.SuspendBatch(); previousViewport = drawingService.GraphicsDevice.Viewport; var viewport = new Viewport(LayoutRect); drawingService.GraphicsDevice.Viewport = viewport; return(sb); }
protected override void DrawChildren(IBatchedDrawingService drawingService) { for (var i = 0; i < this.Count; i++) { var child = this[i]; if (child.Visibility == Visibility.Visible) { child.Draw(drawingService); } } }
protected override void DrawFrameOverlay(IBatchedDrawingService drawingService) { var texture = FrameOverlayTexture; if (texture == null) { return; } float handleAngle; switch (Direction) { case Direction.Left: { handleAngle = Collapsed ? 0f : MathHelper.Pi; break; } case Direction.Right: { handleAngle = Collapsed ? MathHelper.Pi : 0f; break; } case Direction.Up: { handleAngle = Collapsed ? MathHelper.PiOver2 : 3f * MathHelper.PiOver2; break; } case Direction.Down: { handleAngle = Collapsed ? 3f * MathHelper.PiOver2 : MathHelper.PiOver2; break; } default: { throw new NotSupportedException(); } } drawingService.Draw( texture, new Vector2(ContentRect.Center.X, ContentRect.Center.Y), null, FrameOverlayColor, handleAngle, new Vector2(texture.Width / 2f, texture.Height / 2f), 1f, SpriteEffects.None, 0f); }
protected override void DrawMouseState(IBatchedDrawingService drawingService) { if (!IsPressed) { base.DrawMouseState(drawingService); } else { drawingService.DrawBox(DownOverlayTexture, BorderRect, DownOverlayColor * PressedAnimationValue); } }
protected sealed override void DrawWidget(IBatchedDrawingService drawingService) { BeginDraw(drawingService); try { DrawCustomContent(drawingService); } finally { EndDraw(drawingService); } }
public static void DrawClipped(this IWidget w, IBatchedDrawingService ds) { ds.PushScissorRectangle(w.LayoutRect); try { w.Draw(ds); } finally { ds.PopScissorRectangle(); } }
protected override void DrawWidget(IBatchedDrawingService drawingService) { var texture = Texture; if (texture == null) { return; } var targetRect = CalculateImageSize(ContentRect); drawingService.DrawImage(texture, targetRect, TextureColor); }
public UIManager(IInputManager inputManager, IBatchedDrawingService drawingService, IGameWindowService windowService, ContentManager contentManager) { this.inputManager = inputManager ?? throw new ArgumentNullException(nameof(inputManager)); DrawingService = drawingService ?? throw new ArgumentNullException(nameof(drawingService)); this.windowService = windowService ?? throw new ArgumentNullException(nameof(windowService)); var cm = contentManager ?? throw new ArgumentNullException(nameof(contentManager)); UIStyle = new UIStyle(new ContentLoader(cm, drawingService.GraphicsDevice)); }
public GameStateMainMenu(Game game, IBatchedDrawingService drawingService, IInputManager inputManager, IGameStateManager stateService, IGameWindowService windowService) : base(drawingService) { this.frameRateCalculator = new FrameRateCalculator(); this.inputManager = inputManager; this.stateService = stateService; this.windowService = windowService; Game = game; styles = new List <StyleDefinition>(); }
protected override void DrawChildren(IBatchedDrawingService drawingService) { splitterBar.Draw(drawingService); if (displayFirstPane && FirstPane != null) { var clipping = FirstPaneClippingRect(); drawingService.PushScissorRectangle(clipping); FirstPane.Draw(drawingService); drawingService.PopScissorRectangle(); } if (displaySecondPane && SecondPane != null) { drawingService.PushScissorRectangle(SecondPaneClippingRect()); SecondPane.Draw(drawingService); drawingService.PopScissorRectangle(); } }
protected override void DrawWidget(IBatchedDrawingService drawingService) { if (Texture == null) { return; } var origin = new Vector2(Texture.Width / 2f, Texture.Height / 2f); var fadedColor = Color; if (FadeIn) { fadedColor *= fadeInAnim.CurrentValue; } if (Stretch == ScaleMode.None) { var contentRect = ContentRect; drawingService.Draw( Texture, new Vector2(contentRect.Center.X - DesiredSize.Width / 2, contentRect.Center.Y - DesiredSize.Height / 2) + origin, null, fadedColor, rotationValue.CurrentValue, origin, 1f, SpriteEffects.None, 1f); } else { var contentRect = CalculateImageSize(ContentRect); drawingService.Draw( Texture, new Rectangle(contentRect.Left + (int)origin.X, contentRect.Top + (int)origin.Y, contentRect.Width, contentRect.Height), null, fadedColor, rotationValue.CurrentValue, origin, SpriteEffects.None, 1f); } }
protected override void DrawChildren(IBatchedDrawingService drawingService) { if (Clip) { drawingService.PushScissorRectangle(ContentRect); try { base.DrawChildren(drawingService); } finally { drawingService.PopScissorRectangle(); } } else { base.DrawChildren(drawingService); } }
public void Draw(IBatchedDrawingService drawingService, IDocumentView <TDocument> view) { if (Offset == null || EndOffset == null) { return; } Rectangle start; view.ModelToView(Offset.Offset, out start); if (Offset.Bias == Bias.Backward) { start.Width = 0; } Rectangle end; view.ModelToView(EndOffset.Offset, out end); if (EndOffset.Bias == Bias.Backward) { end.Width = 0; } var bounds = view.LayoutRect; if (start.Y == end.Y) { // same line. Can take shortcut .. drawingService.FillRect(start.Union(end), Color); } else { // draw first line drawingService.FillRect(new Rectangle(start.X, start.Y, bounds.Right - start.X, start.Height), Color); // draw inbetween lines using the full view-width as bounds drawingService.FillRect(new Rectangle(bounds.X, start.Bottom, bounds.Width, end.Y - start.Bottom), Color); // draw last line drawingService.FillRect(new Rectangle(bounds.X, end.Y, end.Right - bounds.X, end.Height), Color); } }
protected override void DrawWidget(IBatchedDrawingService drawingService) { base.DrawWidget(drawingService); if (Font != null) { RebuildCache(); var borderRect = BorderRect; for (var index = 0; index < cachedTextPositions.Count; index++) { var pos = cachedTextPositions[index]; if (pos.Item1 == -1) { continue; } drawingService.DrawString(Font, pos.Item2, new Vector2(borderRect.X + Padding.Left, borderRect.Y + pos.Item1), TextColor); } } }
public static void Draw([NotNull] this IBatchedDrawingService ds, [CanBeNull] IUITexture texture, Vector2 position, Rectangle?sourceRectangle, Color color, float rotation, Vector2 origin, float scale, SpriteEffects effects, float layerDepth) { if (texture == null) { return; } var rect = new Rectangle((int)position.X, (int)position.Y, (int)(texture.Width * scale), (int)(texture.Height * scale)); ds.Draw(texture, rect, sourceRectangle, color, rotation, origin, effects, layerDepth); }
public void Draw(IBatchedDrawingService d, Rectangle rectangle, Vector2 offset, Vector2 viewportPosition, float opacity, float scale) { int minX = (int)Math.Floor(viewportPosition.X); int minY = (int)Math.Floor(viewportPosition.Y); int maxX = (int)Math.Ceiling((rectangle.Width + viewportPosition.X)); int maxY = (int)Math.Ceiling((rectangle.Height + viewportPosition.Y)); if (this.X + offset.X + this.Width > minX && this.X + offset.X < maxX) { if (this.Y + offset.Y + this.Height > minY && this.Y + offset.Y < maxY) { float test = (scale - 1) / 2; int x = (int)(this.X + offset.X); int y = (int)(this.Y + offset.Y); float fx = (x * scale) - (viewportPosition.X * scale) - (rectangle.Width * test); float fy = (y * scale) - (viewportPosition.Y * scale) - (rectangle.Height * test); float fw = this.Width * scale; float fh = this.Height * scale; Console.WriteLine(new Vector2(x, y) + " " + new Vector2(fx, fy) + " " + test); d.Draw(new UITexture(this.Texture), new Rectangle((int)fx, (int)fy, (int)fw, (int)fh), new Rectangle(0, 0, _Texture.Width, _Texture.Height), Color.White, 0f, new Vector2(fw / 2, fh / 2), SpriteEffects.None, 0); } } }