|
TachyonUI 0.1.0
High-performance UI for building tools.
|
Passed to custom-draw callbacks (ElementStorage::AddCustomDraw / AddCustomDrawAfter): geometry lookups and drawing calls in a current space the callback switches with SetSpace or SetSpaceRaw, also between calls. More...
#include <gui_core/graphics/gui_custom_draw_context.h>
Public Member Functions | |
| CustomDrawContext (GUIRenderer &renderer, ElementStorage &storage, ElementRef elementRef, IntRect elementRectLayout, IntRect innerRectLayout, IntRect clipRectScreen, float3x2 renderTransform, int2 windowOffset, ITextSystem *textSystem=nullptr, float4 ownerPixelRect={}, IntRect ownerSnappedRect={}) noexcept | |
| Built by the renderer; callbacks receive it. | |
| ElementRef | Ref () const noexcept |
| ElementRef this callback was registered on. | |
| IntRect | ElementRect () const noexcept |
| Border-box of the registered element, in the CURRENT space. | |
| IntRect | ElementInnerRect () const noexcept |
| Padding-box (inner content area) of the registered element, in the CURRENT space. | |
| IntRect | ClipRect () const noexcept |
| Scissor region in SCREEN space. Applied implicitly by every Render* method. | |
| void | SetSpace (DrawSpace space) |
| Set the current coordinate space. | |
| void | SetSpaceRaw (float3x2 spaceToWindowLocal) |
| Set an arbitrary current space; spaceToWindowLocal maps current-space -> window-local. | |
| float3x2 | CurrentTransform () const noexcept |
| The current space -> window-local transform. | |
| int2 | ScreenToCurrent (int2 screenPoint) const |
| Convert a SCREEN-space input (e.g. | |
| IntRect | GetElementRect (const ElementRef &ref) const noexcept |
| Lookups for OTHER elements (returns rects in the CURRENT space). | |
| IntRect | GetInnerRect (const ElementRef &ref) const noexcept |
| Padding-box of another element, in the CURRENT space; empty when not found. | |
| ElementRef | GetParentRef (const ElementRef &ref) const noexcept |
| Tree navigation for other elements. | |
| ElementRef | GetNextSiblingRef (const ElementRef &ref) const noexcept |
| int2 | GetContentSize (const ElementRef &ref) const noexcept |
| Size of the bounds of an element's children (can exceed its inner size when it scrolls), in pixels. | |
| int2 | GetInnerSize (const ElementRef &ref) const noexcept |
| Size of an element's padding-box, in pixels. | |
| void | RenderBox (IntRect rect, VisualBoxStyleIndex styleIndex, ElementState state, VisualColorStyleIndex colorStyleIndex={}, ImageIndex textureIndex=ImageIndex::Invalid) const |
| A styled box (background, border, radius) like an element's. | |
| void | RenderBox (IntRect rect, VisualBoxStyleIndex styleIndex, VisualColorStyleIndex colorStyleIndex={}, ImageIndex textureIndex=ImageIndex::Invalid) const |
| void | RenderBox (IntRect rect, VisualBoxStyleIndex styleIndex, ElementState fromState, ElementState toState, float t) const |
| A styled box part way from its fromState variant to its toState one: t = 0 is all fromState, 1 all toState. | |
| void | RenderBox (IntRect rect, IntRect subClip, VisualBoxStyleIndex styleIndex, ElementState state, VisualColorStyleIndex colorStyleIndex={}, ImageIndex textureIndex=ImageIndex::Invalid) const |
| RenderBox variants with a sub-clip. | |
| void | RenderBox (IntRect rect, IntRect subClip, VisualBoxStyleIndex styleIndex, VisualColorStyleIndex colorStyleIndex={}, ImageIndex textureIndex=ImageIndex::Invalid) const |
| void | RenderQuad (IntRect rect, VisualColorStyleIndex colorStyleIndex, float cornerRadius=0.0f, ImageIndex textureIndex=ImageIndex::Invalid) const |
| A plain filled rect (no border or element state), optionally rounded or textured. | |
| void | RenderQuad (IntRect rect, IntRect subClip, VisualColorStyleIndex colorStyleIndex, float cornerRadius=0.0f, ImageIndex textureIndex=ImageIndex::Invalid) const |
| RenderQuad with a sub-clip in the same space as rect. | |
| void | RenderLine (int2 p0, int2 p1, const LineStyle &style) const |
| A straight line from p0 to p1. | |
| void | RenderLine (int2 p0, int2 p1, int2 p2, int2 p3, const LineStyle &style) const |
| A curve from p0 to p3 shaped by the control points p1 and p2 (Bezier-like). | |
| void | RenderDot (float2 pos, float size, color4f color) const |
| A filled, anti-aliased dot centered on pos; size is its diameter. | |
| void | RenderTriangle (float2 p0, float2 p1, float2 p2, VisualColorStyleIndex colorStyleIndex, ImageIndex textureIndex=ImageIndex::Invalid, TriangleEdges hardEdges=TriangleEdges::None) const |
| A filled triangle; see GUIRenderer::RenderTriangle for hardEdges. | |
| void | RenderCircle (float2 center, float radius, const LineStyle &style) const |
| A circle outline, stroked with style; see GUIRenderer::RenderCircle. | |
| void | RenderCircle (int2 center, float radius, const LineStyle &style) const |
| see above | |
| void | RenderDisc (int2 center, float radius, VisualColorStyleIndex colorStyleIndex) const |
| A filled, anti-aliased disc (a quad rounded to a circle). | |
| void | RenderFilledPolygon (std::span< const float2 > points, VisualColorStyleIndex colorStyleIndex, ImageIndex textureIndex=ImageIndex::Invalid) const |
| Filled convex polygon via fan triangulation. | |
| void | RenderPolyline (std::span< const int2 > points, bool closed, const LineStyle &style, float cornerRadius=0.0f) const |
| Outlined polyline. | |
| void | RenderText (TextID textId, IntRect rect, float extraScale=1.0f) const |
| Draw a previously-registered text (textSystem->RegisterText) within rect, expressed in the CURRENT space like every other Render* coord. | |
Passed to custom-draw callbacks (ElementStorage::AddCustomDraw / AddCustomDrawAfter): geometry lookups and drawing calls in a current space the callback switches with SetSpace or SetSpaceRaw, also between calls.
Render* coordinates and the rects the accessors return are in the current space, so they pass straight through; convert other inputs, such as the cursor position, with ScreenToCurrent. In Screen space a rect matches the screen only for elements without a transformed ancestor.
|
inlinenoexcept |
Built by the renderer; callbacks receive it.
|
inlinenoexcept |
ElementRef this callback was registered on.
|
inlinenoexcept |
Border-box of the registered element, in the CURRENT space.
|
inlinenoexcept |
Padding-box (inner content area) of the registered element, in the CURRENT space.
|
inlinenoexcept |
Scissor region in SCREEN space. Applied implicitly by every Render* method.
| void tachyon::CustomDrawContext::SetSpace | ( | DrawSpace | space | ) |
Set the current coordinate space.
Local (default) = the registered element's content space; Screen = absolute layout (same space as stored rects / screenPos). Re-points the renderer transform for subsequent Render* calls.
| void tachyon::CustomDrawContext::SetSpaceRaw | ( | float3x2 | spaceToWindowLocal | ) |
Set an arbitrary current space; spaceToWindowLocal maps current-space -> window-local.
|
inlinenoexcept |
The current space -> window-local transform.
Convert a SCREEN-space input (e.g.
cursor position, in absolute layout) into the current space. For foreign inputs that are not themselves rendering values.
|
noexcept |
Lookups for OTHER elements (returns rects in the CURRENT space).
|
noexcept |
Padding-box of another element, in the CURRENT space; empty when not found.
|
noexcept |
Tree navigation for other elements.
|
noexcept |
|
noexcept |
Size of the bounds of an element's children (can exceed its inner size when it scrolls), in pixels.
|
noexcept |
Size of an element's padding-box, in pixels.
| void tachyon::CustomDrawContext::RenderBox | ( | IntRect | rect, |
| VisualBoxStyleIndex | styleIndex, | ||
| ElementState | state, | ||
| VisualColorStyleIndex | colorStyleIndex = {}, | ||
| ImageIndex | textureIndex = ImageIndex::Invalid ) const |
A styled box (background, border, radius) like an element's.
state picks the style's hover / pressed / ... variant; without it the base style is used. colorStyleIndex overrides the background; textureIndex fills it with an image.
| void tachyon::CustomDrawContext::RenderBox | ( | IntRect | rect, |
| VisualBoxStyleIndex | styleIndex, | ||
| VisualColorStyleIndex | colorStyleIndex = {}, | ||
| ImageIndex | textureIndex = ImageIndex::Invalid ) const |
| void tachyon::CustomDrawContext::RenderBox | ( | IntRect | rect, |
| VisualBoxStyleIndex | styleIndex, | ||
| ElementState | fromState, | ||
| ElementState | toState, | ||
| float | t ) const |
A styled box part way from its fromState variant to its toState one: t = 0 is all fromState, 1 all toState.
| void tachyon::CustomDrawContext::RenderBox | ( | IntRect | rect, |
| IntRect | subClip, | ||
| VisualBoxStyleIndex | styleIndex, | ||
| ElementState | state, | ||
| VisualColorStyleIndex | colorStyleIndex = {}, | ||
| ImageIndex | textureIndex = ImageIndex::Invalid ) const |
RenderBox variants with a sub-clip.
Final scissor = ClipRect() & subClip. subClip is in the same space as rect.
| void tachyon::CustomDrawContext::RenderBox | ( | IntRect | rect, |
| IntRect | subClip, | ||
| VisualBoxStyleIndex | styleIndex, | ||
| VisualColorStyleIndex | colorStyleIndex = {}, | ||
| ImageIndex | textureIndex = ImageIndex::Invalid ) const |
| void tachyon::CustomDrawContext::RenderQuad | ( | IntRect | rect, |
| VisualColorStyleIndex | colorStyleIndex, | ||
| float | cornerRadius = 0.0f, | ||
| ImageIndex | textureIndex = ImageIndex::Invalid ) const |
A plain filled rect (no border or element state), optionally rounded or textured.
| void tachyon::CustomDrawContext::RenderQuad | ( | IntRect | rect, |
| IntRect | subClip, | ||
| VisualColorStyleIndex | colorStyleIndex, | ||
| float | cornerRadius = 0.0f, | ||
| ImageIndex | textureIndex = ImageIndex::Invalid ) const |
RenderQuad with a sub-clip in the same space as rect.
A straight line from p0 to p1.
| void tachyon::CustomDrawContext::RenderLine | ( | int2 | p0, |
| int2 | p1, | ||
| int2 | p2, | ||
| int2 | p3, | ||
| const LineStyle & | style ) const |
A curve from p0 to p3 shaped by the control points p1 and p2 (Bezier-like).
A filled, anti-aliased dot centered on pos; size is its diameter.
| void tachyon::CustomDrawContext::RenderTriangle | ( | float2 | p0, |
| float2 | p1, | ||
| float2 | p2, | ||
| VisualColorStyleIndex | colorStyleIndex, | ||
| ImageIndex | textureIndex = ImageIndex::Invalid, | ||
| TriangleEdges | hardEdges = TriangleEdges::None ) const |
A filled triangle; see GUIRenderer::RenderTriangle for hardEdges.
| void tachyon::CustomDrawContext::RenderCircle | ( | float2 | center, |
| float | radius, | ||
| const LineStyle & | style ) const |
A circle outline, stroked with style; see GUIRenderer::RenderCircle.
| void tachyon::CustomDrawContext::RenderCircle | ( | int2 | center, |
| float | radius, | ||
| const LineStyle & | style ) const |
see above
| void tachyon::CustomDrawContext::RenderDisc | ( | int2 | center, |
| float | radius, | ||
| VisualColorStyleIndex | colorStyleIndex ) const |
A filled, anti-aliased disc (a quad rounded to a circle).
| void tachyon::CustomDrawContext::RenderFilledPolygon | ( | std::span< const float2 > | points, |
| VisualColorStyleIndex | colorStyleIndex, | ||
| ImageIndex | textureIndex = ImageIndex::Invalid ) const |
Filled convex polygon via fan triangulation.
| void tachyon::CustomDrawContext::RenderPolyline | ( | std::span< const int2 > | points, |
| bool | closed, | ||
| const LineStyle & | style, | ||
| float | cornerRadius = 0.0f ) const |
Outlined polyline.
cornerRadius > 0 (open polylines) turns each bend into a short arc between the straight runs, up to half of either neighbouring run.
| void tachyon::CustomDrawContext::RenderText | ( | TextID | textId, |
| IntRect | rect, | ||
| float | extraScale = 1.0f ) const |
Draw a previously-registered text (textSystem->RegisterText) within rect, expressed in the CURRENT space like every other Render* coord.
The glyph raster scale is taken from the current transform (so it stays crisp under DPI/zoom); extraScale multiplies it. No-op if the context has no text system.