Class DefaultToolRenderer<T>
A default implementation of a IToolRenderer.
Inherited Members
Namespace: Gorgon.Editor.Rendering
Assembly: Gorgon.Editor.API.dll
Syntax
public class DefaultToolRenderer<T> : GorgonNamedObject, IToolRenderer, IGorgonNamedObject, IDisposable where T : class, IEditorTool
Type Parameters
Name | Description |
---|---|
T | The type of view model for the renderer. Must implement the IEditorTool interface, and be a reference type. |
Remarks
This renderer does the bare minimum to present content on the view. Tool plug in UI developers should inherit from this class to take advantage of the default functionality it provides.
The default renderer provides basic support for rendering tool specific content.
Renderers will also receive access to the view model applied to the view, so the renderer can respond to changes on the tool UI and adjust the visuals appropriately. The view model must implement the IEditorTool interface before they can be used with a renderer.
Constructors
| Edit this page View SourceDefaultToolRenderer(string, Gorgon2D, GorgonSwapChain, T)
Initializes a new instance of the DefaultToolRenderer<T> class.
Declaration
protected DefaultToolRenderer(string name, Gorgon2D renderer, GorgonSwapChain swapChain, T dataContext)
Parameters
Type | Name | Description |
---|---|---|
string | name | The name of the renderer. |
Gorgon2D | renderer | The main renderer for the content view. |
GorgonSwapChain | swapChain | The swap chain for the content view. |
T | dataContext | The view model to assign to the renderer. |
See Also
Properties
| Edit this page View SourceBackgroundColor
Property to set or return the color to use when clearing the swap chain.
Declaration
public GorgonColor BackgroundColor { get; set; }
Property Value
Type | Description |
---|---|
GorgonColor |
Remarks
This value defaults to the background color of the view.
See Also
| Edit this page View SourceBackgroundPattern
Property to return the default texture used to draw the background.
Declaration
protected GorgonTexture2DView BackgroundPattern { get; }
Property Value
Type | Description |
---|---|
GorgonTexture2DView |
See Also
| Edit this page View SourceClientSize
Property to return the size of the view client area.
Declaration
public Size2 ClientSize { get; }
Property Value
Type | Description |
---|---|
Size2 |
See Also
| Edit this page View SourceDataContext
Property to return the data context assigned to this view.
Declaration
public T DataContext { get; }
Property Value
Type | Description |
---|---|
T |
See Also
| Edit this page View SourceGraphics
Property to return the graphics interface used to create graphics objects.
Declaration
protected GorgonGraphics Graphics { get; }
Property Value
Type | Description |
---|---|
GorgonGraphics |
See Also
| Edit this page View SourceIsEnabled
Property to set or return whether the renderer is enabled.
Declaration
public bool IsEnabled { get; set; }
Property Value
Type | Description |
---|---|
bool |
See Also
| Edit this page View SourceMainRenderTarget
Property to return the primary render target.
Declaration
protected GorgonRenderTarget2DView MainRenderTarget { get; }
Property Value
Type | Description |
---|---|
GorgonRenderTarget2DView |
Remarks
Developers can use this property to reset the render target back to the original target after rendering to another target.
See Also
| Edit this page View SourcePixelFormat
Property to return the pixel format for the view.
Declaration
protected BufferFormat PixelFormat { get; }
Property Value
Type | Description |
---|---|
BufferFormat |
See Also
| Edit this page View SourceRenderer
Property to return the 2D renderer used to draw onto the content view.
Declaration
protected Gorgon2D Renderer { get; }
Property Value
Type | Description |
---|---|
Gorgon2D |
See Also
Methods
| Edit this page View SourceCalculateScaling(Size2F, Size2F)
Function to calculate scaling to the specified size, bounded by the client area of the rendering control.
Declaration
protected float CalculateScaling(Size2F size, Size2F windowSize)
Parameters
Type | Name | Description |
---|---|---|
Size2F | size | The size of the area to zoom into. |
Size2F | windowSize | The size of the window. |
Returns
Type | Description |
---|---|
float | The scaling factor to apply. |
See Also
| Edit this page View SourceDispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
Declaration
public void Dispose()
See Also
| Edit this page View SourceDispose(bool)
Releases unmanaged and - optionally - managed resources.
Declaration
protected virtual void Dispose(bool disposing)
Parameters
Type | Name | Description |
---|---|---|
bool | disposing |
|
See Also
| Edit this page View SourceLoadResources()
Function to load resources for the renderer.
Declaration
public void LoadResources()
Remarks
This method is used to load any required temporary resources for the renderer prior to rendering content. This must be paired with a call to UnloadResources() when the renderer is no longer in use to ensure efficient memory usage.
See Also
| Edit this page View SourceOnLoad()
Function called when the renderer needs to load any resource data.
Declaration
protected virtual void OnLoad()
Remarks
Developers can override this method to set up their own resources specific to their renderer. Any resources set up in this method should be cleaned up in the associated OnUnload() method.
See Also
| Edit this page View SourceOnPropertyChanged(string)
Function called when a property on the DataContext has been changed.
Declaration
protected virtual void OnPropertyChanged(string propertyName)
Parameters
Type | Name | Description |
---|---|---|
string | propertyName | The name of the property that was changed. |
Remarks
Developers should override this method to detect changes on the content view model and reflect those changes in the rendering.
See Also
| Edit this page View SourceOnPropertyChanging(string)
Function called when a property on the DataContext is changing.
Declaration
protected virtual void OnPropertyChanging(string propertyName)
Parameters
Type | Name | Description |
---|---|---|
string | propertyName | The name of the property that is changing. |
Remarks
Developers should override this method to detect changes on the content view model and reflect those changes in the rendering.
See Also
| Edit this page View SourceOnRenderBackground()
Function to render the background.
Declaration
protected virtual void OnRenderBackground()
Remarks
Developers can override this method to render a custom background.
See Also
| Edit this page View SourceOnRenderContent()
Function to render the content.
Declaration
protected virtual void OnRenderContent()
Remarks
This is the method that developers should override in order to draw their content to the view.
See Also
| Edit this page View SourceOnResizeBegin()
Function called when the view is about to be resized.
Declaration
protected virtual void OnResizeBegin()
Remarks
Developers can override this method to handle cases where the view window is resized and the content has size dependent data (e.g. render targets).
See Also
| Edit this page View SourceOnResizeEnd()
Function called when the view has been resized.
Declaration
protected virtual void OnResizeEnd()
Remarks
Developers can override this method to handle cases where the view window is resized and the content has size dependent data (e.g. render targets).
See Also
| Edit this page View SourceOnUnload()
Function called when the renderer needs to clean up any resource data.
Declaration
protected virtual void OnUnload()
Remarks
Developers should always override this method if they've overridden the OnLoad() method. Failure to do so can cause memory leakage.
See Also
| Edit this page View SourceRender()
Function to render the content.
Declaration
public void Render()
Remarks
This method is called by the view to render the content.
See Also
| Edit this page View SourceUnloadResources()
Function to unload resources from the renderer.
Declaration
public void UnloadResources()
Remarks
This method is used to unload temporary resources for the renderer when it is no longer needed. Failure to call this may result in memory leakage.