class GUICurves

GUI element that displays one or multiple curves.

Public

Methods

staticGetGuiTypeName

static const String &GetGuiTypeName()

Returns type name of the GUI element used for finding GUI element styles.

SetCurves

void SetCurves(const Vector<CurveDrawInfo> &curves)

Animation curves to display.

GetCurves

const Vector<CurveDrawInfo> &GetCurves() const

SetRange

void SetRange(float xRange, float yRange)

Changes the visible range that the GUI element displays.

xRange
Range of the horizontal area. Displayed area will range from [0, xRange].
yRange
Range of the vertical area. Displayed area will range from [-yRange * 0.5, yRange * 0.5]

SetOffset

void SetOffset(const Vector2 &offset)

Returns the offset at which the displayed timeline values start at.

offset
Value to start the timeline values at, where x = time, y = value.

CenterAndZoom

void CenterAndZoom()

Centers and zooms the view to fully display the provided set of curves.

PixelToCurveSpace

bool PixelToCurveSpace(const GUILogicalPoint &pixelCoords, Vector2 &curveCoords, bool padding = false) const

Converts pixel coordinates into coordinates in curve space.

pixelCoords
Coordinates relative to this GUI element, in pixels.
curveCoords
Curve coordinates within the range as specified by setRange(). Only valid when function returns true.
padding
Determines should coordinates over the area reserved for padding be registered.

Returns: True if the coordinates are within the curve area, false otherwise.

CurveToPixelSpace

GUILogicalPoint CurveToPixelSpace(const Vector2 &curveCoords) const

Converts coordinate in curve space (time, value) into pixel coordinates relative to this element's origin.

curveCoords
Time and value of the location to convert.

Returns: Coordinates relative to this element's origin, in pixels.

FindCurve

u32 FindCurve(const GUILogicalPoint &pixelCoords)

Attempts to find a curve under the provided coordinates.

pixelCoords
Coordinates relative to this GUI element in pixels.

Returns: Index of the curve, or -1 if none found.

FindKeyFrame

bool FindKeyFrame(const GUILogicalPoint &pixelCoords, KeyframeRef &keyframe)

Attempts to find a keyframe under the provided coordinates.

pixelCoords
Coordinates relative to this GUI element in pixels.
keyframe
Output object containing keyframe index and index of the curve it belongs to. Only valid if method returns true.

Returns: True if there is a keyframe under the coordinates, false otherwise.

FindTangent

bool FindTangent(const GUILogicalPoint &pixelCoords, TangentRef &tangent)

Attempts to find a a tangent handle under the provided coordinates.

pixelCoords
Coordinates relative to this GUI element in pixels.
tangent
Output object containing keyframe information and tangent type. Only valid if method returns true.

Returns: True if there is a tangent handle under the coordinates, false otherwise.

SelectKeyframe

void SelectKeyframe(const KeyframeRef &keyframeRef, const TangentMode &tangentMode, bool selected)

Marks the specified key-frame as selected, changing the way it is displayed.

keyframeRef
Keyframe reference containing the curve and keyframe index.
tangentMode
Type of tangent to display on the selected keyframe.
selected
True to select it, false to deselect it.

ClearSelectedKeyframes

void ClearSelectedKeyframes()

Clears any key-frames that were marked as selected.

staticCreate

static GUIElementType *Create(const ContentType &contents, const String &styleClass, const TInlineArray<GUIOption, 4> &options)

Creates a new GUI element.

contents
Structure describing the contents of the GUI element to create.
styleClass
Style class that will be used for determining GUI element visuals from the current style sheet. If no class is provided, default style is determined based on GUI element type.
options
Additional options that control GUI element size and position. This will override options set in the style sheet.

Fields

OnClicked

Event<void ()> OnClicked

Triggered when the user clicks on the GUI element.

Internal

Constructors

GUICurves

GUICurves(PrivatelyConstruct, const GUICurvesContent &content, const String &styleName, const GUISizeConstraints &sizeConstraints)

Protected

Methods

~GUICurves

~GUICurves() noexcept override = default

TangentToNormal

Vector2 TangentToNormal(float tangent) const

Converts a keyframe tangent (slope) value into a 2D normal vector.

tangent
Keyframe tangent (slope).

Returns: Normalized 2D vector pointing in the direction of the tangent.

GetTangentPosition

GUILogicalPoint GetTangentPosition(const TKeyframe<float> &keyFrame, TangentType type) const

Returns the position of the tangent, in element's pixel space.

keyFrame
Keyframe that the tangent belongs to.
type
Which tangent to retrieve the position for.

Returns: Position of the tangent, relative to the this GUI element's origin, in pixels.

IsTangentDisplayed

bool IsTangentDisplayed(TangentMode mode, TangentType type) const

Checks if the tangent should be displayed, depending on the active tangent mode.

mode
Tangent mode for the keyframe.
type
Which tangent to check for.

Returns: True if the tangent should be displayed.

IsSelected

bool IsSelected(int curveIdx, int keyIdx) const

Checks is the provided key-frame currently marked as selected.

curveIdx
Index of the curve the keyframe is on.
keyIdx
Index of the keyframe.

Returns: True if selected, false otherwise.

DrawFrameMarker

void DrawFrameMarker(float t, Color color, bool onTop)

Draws a vertical frame marker on the curve area.

t
Time at which to draw the marker.
color
Color with which to draw the marker.
onTop
Determines should the marker be drawn above or below the curve.

DrawCenterLine

void DrawCenterLine()

Draws a horizontal line representing the line at y = 0.

DrawDiamond

void DrawDiamond(GUILogicalPoint center, GUILogicalUnit size, Color innerColor, Color outerColor)

Draws a diamond shape of the specified size at the coordinates.

center
Position at which to place the diamond's center, in pixel coordinates.
size
Determines number of pixels to extend the diamond in each direction.
innerColor
Color of the diamond's background.
outerColor
Color of the diamond's outline.

DrawKeyframe

void DrawKeyframe(float t, float y, bool selected)

Draws a keyframe a the specified time and value.

t
Time to draw the keyframe at.
y
Y value to draw the keyframe at.
selected
Determines should the keyframe be drawing using the selected color scheme, or normally.

DrawTangents

void DrawTangents(const TKeyframe<float> &keyFrame, TangentMode tangentMode)

Draws zero, one or two tangents for the specified keyframe.

Whether tangents are drawn depends on the provided mode.

keyFrame
Keyframe to draw the tangents for.
tangentMode
Type of tangents in the keyframe.

DrawCurve

void DrawCurve(const TAnimationCurve<float> &curve, const Color &color)

Draws the curve using the provided color.

curve
Curve to draw within the currently set range.
color
Color to draw the curve with.

DrawCurveRange

void DrawCurveRange(const Vector<TAnimationCurve<float>> &curves, Color color)

UpdateRenderElements

void UpdateRenderElements() override

Recreates the internal render elements.

Must be called before GetRenderElementVertexAndIndexData/FillBuffer if element is dirty. Marks the element as non dirty.

DoOnMouseEvent

bool DoOnMouseEvent(const GUIMouseEvent &ev) override

Called when a mouse event is received on any GUI element the mouse is interacting with.

Return true if you have processed the event and don't want other elements to process it.

Private

Fields

mCurves

Vector<CurveDrawInfo> mCurves

mSelectedKeyframes

Vector<SelectedKeyframe> mSelectedKeyframes

mYRange

float mYRange

mYOffset

float mYOffset

mDrawOptions

CurveDrawOptions mDrawOptions

mTickHandler

GUIGraphTicks mTickHandler