Paradox Game Engine  v1.0.0 beta06
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros Pages
DefaultButtonRenderer.cs
Go to the documentation of this file.
1 // Copyright (c) 2014 Silicon Studio Corp. (http://siliconstudio.co.jp)
2 // This file is distributed under GPL v3. See LICENSE.md for details.
3 
4 using SiliconStudio.Core;
5 using SiliconStudio.Core.Mathematics;
6 using SiliconStudio.Paradox.UI.Controls;
7 
8 namespace SiliconStudio.Paradox.UI.Renderers
9 {
10  /// <summary>
11  /// The default renderer for <see cref="Button"/>.
12  /// </summary>
13  internal class DefaultButtonRenderer : ElementRenderer
14  {
15  public DefaultButtonRenderer(IServiceRegistry services)
16  : base(services)
17  {
18  }
19 
20  public override void RenderColor(UIElement element, UIRenderingContext context)
21  {
22  base.RenderColor(element, context);
23 
24  var button = (Button)element;
25  var color = button.RenderOpacity * Color.White;
26 
27  var image = button.PressedImage;
28  if(!button.IsPressed)
29  image = button.MouseOverState == MouseOverState.MouseOverElement? button.MouseOverImage : button.NotPressedImage;
30 
31  if(image == null || image.Texture == null)
32  return;
33 
34  Batch.DrawImage(image.Texture, image.TextureAlpha, ref button.WorldMatrixInternal, ref image.RegionInternal, ref button.RenderSizeInternal, ref image.BordersInternal, ref color, context.DepthBias, image.Orientation);
35  }
36  }
37 }
Represents a Windows button control, which reacts to the Click event.
Definition: Button.cs:13
A service registry is a IServiceProvider that provides methods to register and unregister services...
Android.Widget.Orientation Orientation
Definition: Section.cs:9