24 enum class TextID : uint32_t;
52 float4 ownerPixelRect = {},
IntRect ownerSnappedRect = {})
noexcept
53 : m_renderer(&renderer), m_storage(&storage),
54 m_elementRef(elementRef),
55 m_elementRect(elementRectLayout), m_innerRect(innerRectLayout),
56 m_clipRect(clipRectScreen),
57 m_renderTransform(renderTransform),
58 m_currentTransform(renderTransform),
59 m_windowOffset(windowOffset),
60 m_textSystem(textSystem),
61 m_ownerPixelRect(ownerPixelRect), m_ownerSnappedRect(ownerSnappedRect) {}
134 float cornerRadius = 0.0f,
140 float cornerRadius = 0.0f,
171 const LineStyle& style,
float cornerRadius = 0.0f)
const;
185 return m_currentSpaceIsLocal ? (rectAbs - m_innerRect.position) : rectAbs;
196 int2 m_windowOffset{};
197 ITextSystem* m_textSystem =
nullptr;
200 float4 m_ownerPixelRect {};
201 IntRect m_ownerSnappedRect {};
202 IntRect SnappedPixelRect(IntRect rect)
const;
203 bool m_currentSpaceIsLocal =
true;
225 : m_storage(&storage), m_elementRef(ref),
226 m_elementRect(elementRectLayout), m_innerRect(innerRectLayout),
227 m_contentTransform(contentTransform) {}
void RenderBox(IntRect rect, IntRect subClip, 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,...
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.
Definition gui_custom_draw_context.h:46
void RenderCircle(float2 center, float radius, const LineStyle &style) const
A circle outline, stroked with style; see GUIRenderer::RenderCircle.
int2 ScreenToCurrent(int2 screenPoint) const
Convert a SCREEN-space input (e.g.
ElementRef GetParentRef(const ElementRef &ref) const noexcept
Tree navigation for other elements.
void RenderDisc(int2 center, float radius, VisualColorStyleIndex colorStyleIndex) const
A filled, anti-aliased disc (a quad rounded to a circle).
void RenderText(TextID textId, IntRect rect, float extraScale=1.0f) const
Draw a previously-registered text (textSystem->RegisterText) within rect, expressed in the CURRENT sp...
int2 GetInnerSize(const ElementRef &ref) const noexcept
Size of an element's padding-box, in pixels.
void RenderFilledPolygon(std::span< const float2 > points, VisualColorStyleIndex colorStyleIndex, ImageIndex textureIndex=ImageIndex::Invalid) const
Filled convex polygon via fan triangulation.
int2 GetContentSize(const ElementRef &ref) const noexcept
Size of the bounds of an element's children (can exceed its inner size when it scrolls),...
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, VisualBoxStyleIndex styleIndex, ElementState state, VisualColorStyleIndex colorStyleIndex={}, ImageIndex textureIndex=ImageIndex::Invalid) const
A styled box (background, border, radius) like an element's.
void RenderDot(float2 pos, float size, color4f color) const
A filled, anti-aliased dot centered on pos; size is its diameter.
void RenderBox(IntRect rect, VisualBoxStyleIndex styleIndex, VisualColorStyleIndex colorStyleIndex={}, ImageIndex textureIndex=ImageIndex::Invalid) const
IntRect ClipRect() const noexcept
Scissor region in SCREEN space. Applied implicitly by every Render* method.
Definition gui_custom_draw_context.h:73
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).
ElementRef Ref() const noexcept
ElementRef this callback was registered on.
Definition gui_custom_draw_context.h:64
void RenderPolyline(std::span< const int2 > points, bool closed, const LineStyle &style, float cornerRadius=0.0f) const
Outlined polyline.
float3x2 CurrentTransform() const noexcept
The current space -> window-local transform.
Definition gui_custom_draw_context.h:84
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.
IntRect GetInnerRect(const ElementRef &ref) const noexcept
Padding-box of another element, in the CURRENT space; empty when not found.
IntRect ElementRect() const noexcept
Border-box of the registered element, in the CURRENT space.
Definition gui_custom_draw_context.h:67
IntRect ElementInnerRect() const noexcept
Padding-box (inner content area) of the registered element, in the CURRENT space.
Definition gui_custom_draw_context.h:70
void RenderLine(int2 p0, int2 p1, const LineStyle &style) const
A straight line from p0 to p1.
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 SetSpace(DrawSpace space)
Set the current coordinate space.
void SetSpaceRaw(float3x2 spaceToWindowLocal)
Set an arbitrary current space; spaceToWindowLocal maps current-space -> window-local.
ElementRef GetNextSiblingRef(const ElementRef &ref) const noexcept
IntRect GetElementRect(const ElementRef &ref) const noexcept
Lookups for OTHER elements (returns rects in the CURRENT space).
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 RenderCircle(int2 center, float radius, const LineStyle &style) const
see above
The frame's element tree.
Definition gui_element_storage.h:100
Definition gui_renderer.h:43
Text and icon registration, measurement, rendering and editing.
Definition gui_text_system.h:178
ElementRef GetNextSiblingRef(const ElementRef &ref) const noexcept
IntRect GetElementRect(const ElementRef &ref) const noexcept
Lookups for other elements, as on CustomDrawContext but with rects in layout space.
ElementRef GetParentRef(const ElementRef &ref) const noexcept
int2 GetContentSize(const ElementRef &ref) const noexcept
IntRect ElementRect() const noexcept
Definition gui_custom_draw_context.h:231
IntRect GetInnerRect(const ElementRef &ref) const noexcept
int2 GetInnerSize(const ElementRef &ref) const noexcept
IntRect ElementInnerRect() const noexcept
Definition gui_custom_draw_context.h:232
PostLayoutContext(ElementStorage &storage, ElementRef ref, IntRect elementRectLayout, IntRect innerRectLayout, float3x2 contentTransform) noexcept
Built by the layout pass; callbacks receive it.
Definition gui_custom_draw_context.h:222
ElementRef Ref() const noexcept
The registered element, its border-box and padding-box, and its contentTransform.
Definition gui_custom_draw_context.h:230
float3x2 ContentTransform() const noexcept
Definition gui_custom_draw_context.h:233
TriangleEdges
A triangle's edges, for the ones drawn without a soft edge: where it meets another triangle of the sa...
Definition gui_renderer.h:23
ImageIndex
Index of an image in the graphics context's image set, as the shaders sample it.
Definition gui_image.h:37
DrawSpace
The coordinate space a CustomDrawContext draws in.
Definition gui_custom_draw_context.h:29
@ None
Definition gui_renderer.h:24
@ Invalid
Definition gui_image.h:37
@ Screen
Absolute layout pixels: the space of stored element rects and event.state.screenPos.
Definition gui_custom_draw_context.h:33
@ Local
The default: the registered element's content space, (0,0) at its padding box's top-left.
Definition gui_custom_draw_context.h:30
VisualColorStyleIndex
Index into StyleManager's color style pool; Invalid (0) draws nothing (transparent).
Definition gui_style.h:33
TextID
Handle for text registered with the text system (ITextSystem::RegisterText and friends).
Definition gui_style_text.h:13
VisualBoxStyleIndex
Index into StyleManager's visual box style pool; Invalid (0) = none.
Definition gui_style_ref.h:17
ElementState
Interaction state bits of an element; they pick the Style::states variant it draws with.
Definition gui_style.h:42
Definition gui_logging.h:24
An element's slot in ElementStorage: its depth and index within that depth.
Definition gui_element.h:127
Definition gui_base_types.h:407
Definition gui_renderer.h:32
Definition gui_base_types.h:395
Definition gui_base_types.h:121
2D affine transform matrix (2 rows x 3 columns): x' = r0.x*x + r0.y*y + r0.z y' = r1....
Definition gui_base_types.h:219
Definition gui_base_types.h:174
Integer 2D vector.
Definition gui_base_types.h:19