TachyonUI 0.1.0
High-performance UI for building tools.
Loading...
Searching...
No Matches
tachyon::SkribidiTextSystem Class Reference

Skribidi-based implementation of ITextSystem. More...

#include <gui_core/text/skribidi/gui_text_system_skribidi.h>

Inheritance diagram for tachyon::SkribidiTextSystem:

Public Member Functions

 SkribidiTextSystem ()
 ~SkribidiTextSystem () override
bool Initialize (GraphicsContext *graphicsContext, StyleManager *styleManager, TextAtlasManager *textAtlasManager, GUIStateManager *guiStateManager, IClipboard *clipboard) override
void Shutdown () override
void Update () override
void BeginFrame (int2 screenMousePos, MouseButtons mouseButtons, uint32_t timeMs) override
 Starts a frame, before the UI is built: clears the per-frame editor registrations that this frame's RegisterEditableText calls fill again.
void BeginAtlasRecord (ID scopeId) override
 Records the glyph and icon atlas entries a cached scope's primitives use, until EndAtlasRecord.
void EndAtlasRecord () override
bool ReplayAtlasTouches (ID scopeId) override
void OnKeyboard (ID windowId, KeyCode key, int repeat, KeyModifier modifiers, KeyAction action) override
 Keyboard input for the active text editor.
void OnMouseMove (ID windowId, int2 screenPos, MouseButtons button, KeyModifier modifiers) override
 Mouse movement for text selection and drag-drop.
void OnMouseButton (ID windowId, int2 screenPos, MouseButtons button, KeyModifier modifiers, MouseAction action) override
 Mouse buttons for text editors: caret placement, selection, drag-drop.
void OnMouseScroll (ID windowId, int2 screenPos, float2 scrollOffset, KeyModifier modifiers) override
 Mouse wheel input for text editors.
void OnTextComposition (ID windowId, std::string_view text, int32_t cursor) override
 IME composition (pre-edit) text, UTF-8, shown but not yet committed; empty when composing ends.
void SwitchTextEditor (ID from, ID to) override
 The focused text field changed (GUIStateManager::TextEditorFocus): commit from (ID::Invalid if none) and move the editor to to (ID::Invalid: no editor).
void SetUndoHistory (UndoHistory *history) override
 Where committed text edits go as undo steps (none: not recorded).
ID ActiveElementID () const
 The field the editor holds: the text focus as of the last switch.
bool DoesTextEditorAcceptTabs (ID elementId) const override
 True when the editor elementId inserts tabs (TextEditBehavior::AcceptTabs).
bool IsTextEditor (ID elementId) const override
 True when elementId registered editable text this frame.
void RequestSelectAll (ID elementId) override
 Selects all text of the editor elementId the next time it renders.
TextEditUpdate ConsumeTextEditUpdate (TextID textId, std::string &outText) override
 Takes the pending edit of textId: the edited text goes to outText, the result says whether it changed or was committed.
bool UpdateText (TextID textId, std::string_view text) override
 Replaces the text of textId; true when it changed.
std::string Copy () override
 The active editor's selected text.
std::string Cut () override
 Removes the active editor's selected text and returns it.
void Paste (std::string_view text) override
 Inserts Text into the active editor at the caret, replacing the selection.
bool IsHoveringSelectedText (ID textEditorId, ID windowId, tachyon::int2 screenSpace) const override
 True when the screen point screenSpace is over selected text in textEditorId.
bool TryGetTextDragCursor (ID windowId, tachyon::int2 screenSpace, MouseCursor &outCursor) const override
 The mouse cursor to show while text is dragged; true when it overrides the hover cursor.
bool TryGetTextDragHoverTarget (ID windowId, tachyon::int2 screenSpace, ID &outTargetId) const override
 While text is dragged, sets outTargetId to the drop target under the cursor (ID::Invalid if none) and returns true.
void ClearCache () override
 Drops every registered text and the live editor; earlier TextIDs become invalid.
size_t RegisteredTextCount () const
 Number of registered texts held, for diagnostics.
uint64_t LayoutsMade () const
 Number of text layouts made so far, for diagnostics.
void EnsureCursorVisible (ID textEditorId) override
 Asks for the caret of textEditorId to be scrolled into view; editor input calls it when the caret moves.
std::optional< IntRect > GetCursorRect (ID textEditorId) override
 Takes a pending EnsureCursorVisible request for textEditorId and returns the caret rect, relative to the editor's inner rect.
std::optional< IntRect > GetCaretScreenRect () const override
 The active editor's caret in absolute screen coordinates (through any zoom/pan), to place the IME candidate window.
TextID RegisterEditableText (ID elementId, std::string &text, TextEditBehavior behavior, StyleRef styleIndex, ElementState state, bool &wasModified, const ITextValidator *validator=nullptr) override
 Registers Text as editable by elementId; wasModified is set when an edit changed it.
std::string * ValueEditText (ID elementId, bool &started) override
 The text the focused field elementId edits, kept while it has the focus (its value isn't formatted again under the typing); null when it doesn't have it.
void SetTextColor (TextID textId, VisualColorStyleIndex color) override
 Draw a registered text in color instead of its style's text color, until it is registered again (call after each registration, e.g.
void SetCaretColor (VisualColorStyleIndex color) override
 The text caret's color (the theme's –caret). Set again after the style manager is cleared.
void SetFontDirectory (std::string_view directory) override
 Where the built-in fonts are (default "fonts", relative to the working directory): Inter for text and JetBrains Mono for monospace.
void SetFallbackFontDirectory (std::string_view directory) override
 Where the optional fallback fonts are: Noto, for other scripts, emoji and symbols.
void SetLanguage (std::string_view languageTag) override
 The default language as a BCP 47 tag ("ja", "zh-Hant", "ko"), for text whose style has no language of its own (TextStyle::language / -tachyon-language).
FontID RegisterFontFamily (std::string_view familyName, std::span< const FontFaceSource > faces) override
 Registers a font family from its faces (regular, bold, italic, ...); each face's weight and style come from the file.
TextID RegisterText (ID elementId, IconID iconId, std::string_view text, StyleRef styleIndex, ElementState state) override
 Registers static text, with an optional icon, for elementId.
TextID RegisterRichText (ID elementId, const std::span< ContentRun > &contentRuns, StyleRef styleIndex, ElementState state) override
 Registers text made of runs: styled text, inline icons and links.
TextID RegisterEditableRichText (ID elementId, const std::span< ContentRun > &contentRuns, TextEditBehavior behavior, StyleRef styleIndex, ElementState state, bool &wasModified) override
 Registers rich text that renders like RegisterRichText but can also be selected and copied (the runs' text joined).
TextID GetTextID (ID elementId) const override
 The TextID elementId registered this frame, or TextID::Invalid.
std::string_view GetText (TextID textId) const override
 The text registered as textId.
TextMeasurement GetTextMeasurement (TextID textId) const override
 The unwrapped measurement of textId, in pixels; cached until its text or style changes.
int32_t GetTextHeightWithoutIcon (TextID textId) const override
 How high textId's text is unwrapped, in pixels, without the icon it was registered with (which its measurement has in it).
TextMeasurement MeasureText (TextID textId, const TextWrapContext &wrapContext) const override
 The measurement of textId wrapped to wrapContext.maxWidth, in pixels.
void RenderText (TextID textId, IntRect rect, IntRect innerRect, IntRect clipRect, float pixelScale=1.f, const float3x2 &screenToLayout=float3x2::Identity()) override
 Draws textId into rect (renderer space, window-local), clipped to clipRect.
std::optional< MouseCursor > LinkCursorAt (ID elementId, int32_t localX, int32_t localY) const override
 The cursor of the link at (localX, localY), element-local (its LinkStyle::cursor); none when there's no link there.
intptr_t HitTestContent (TextID textId, int32_t localX, int32_t localY) const override
 The contentId of the run at (localX, localY), element-local; 0 if none.
void SetHoveredContent (TextID textId, intptr_t contentId) override
 Sets the hovered run of textId (by contentId), drawn in its hover style; 0 for none.
bool IsValidIcon (IconID iconId) const override
 True when iconId is a registered icon.
IconID RegisterIconFromSVG (const char *name, const char *svg_data, size_t svg_size) override
 Registers an icon from SVG data under a unique name.
IconID RegisterIconFromSVGFile (const char *path) override
 Registers an icon from an SVG file, named by its path.
IconID RegisterIconFromPixels (const char *name, uint2 size, std::span< const uint8_t > rgba) override
 Registers an icon from size.x x size.y RGBA pixels (straight alpha, rows from the top) under a unique name: a picture in its own colors, drawn untinted.
void UnregisterIcon (IconID iconId) override
 Lets go of an icon from RegisterIconFromPixels: its image slot is freed, the ID draws nothing from then on and isn't given out again, and its name can be registered anew.
IconMeasurement GetIconMeasurement (IconID iconId) const override
 The natural size of iconId, in pixels (same as MeasureIcon).
IconMeasurement MeasureIcon (IconID iconId) const override
 The natural size of iconId, in pixels.
void RenderIcon (IconID iconId, IntRect rect, IntRect clipRect, VisualColorStyleIndex tint, std::span< const VisualShadow > shadows={}) override
 Draws iconId fitted into rect (aspect kept, centered), clipped to clipRect.
FontID RegisterFontFamily (std::string_view familyName, std::span< const std::string_view > faceFiles)
Public Member Functions inherited from tachyon::ITextSystem
virtual ~ITextSystem ()=default
FontID RegisterFontFamily (std::string_view familyName, std::span< const std::string_view > faceFiles)
TextID RegisterText (ID elementId, std::string_view text, StyleRef styleIndex, ElementState state)
template<typename T, typename Converter = TextConverter<T>>
TextID RegisterEditableValue (ID elementId, T &value, TextEditBehavior behavior, StyleRef styleIndex, ElementState state, bool &wasModified, const Converter &converter=DefaultTextConverter< T >())
 Registers a field that edits value as text: converter formats it and parses the edits back (see TextConverter).
template<typename T>
TextID RegisterEditableNumber (ID elementId, T &value, TextEditBehavior behavior, StyleRef styleIndex, ElementState state, bool &wasModified, NumericFieldConfig< T > config={})
 Registers an editable number, clamped to config's [minVal, maxVal] after an edit.
Public Member Functions inherited from tachyon::IPlatformInputHandler
virtual ~IPlatformInputHandler ()=default
virtual void OnFileDrop (tachyon::ID, tachyon::int2, FileDropAction, std::string_view)
 A drag from another application over window id: it came, moved to screenPos (screen pixels), dropped a file or text (data), or ended (dropped, or left the window).

Static Public Member Functions

static void ScreenToTextEditorLocalPoint (tachyon::int2 screenSpace, const IntRect &textEditorInnerRect, tachyon::float2 &outLocal, const float3x2 &screenToLayout=float3x2::Identity())

Detailed Description

Skribidi-based implementation of ITextSystem.

Constructor & Destructor Documentation

◆ SkribidiTextSystem()

tachyon::SkribidiTextSystem::SkribidiTextSystem ( )

◆ ~SkribidiTextSystem()

tachyon::SkribidiTextSystem::~SkribidiTextSystem ( )
override

Member Function Documentation

◆ Initialize()

bool tachyon::SkribidiTextSystem::Initialize ( GraphicsContext * graphicsContext,
StyleManager * styleManager,
TextAtlasManager * textAtlasManager,
GUIStateManager * guiStateManager,
IClipboard * clipboard )
overridevirtual

Implements tachyon::ITextSystem.

◆ Shutdown()

void tachyon::SkribidiTextSystem::Shutdown ( )
overridevirtual

Implements tachyon::ITextSystem.

◆ Update()

void tachyon::SkribidiTextSystem::Update ( )
overridevirtual

Implements tachyon::ITextSystem.

◆ BeginFrame()

void tachyon::SkribidiTextSystem::BeginFrame ( int2 screenMousePos,
MouseButtons mouseButtons,
uint32_t timeMs )
overridevirtual

Starts a frame, before the UI is built: clears the per-frame editor registrations that this frame's RegisterEditableText calls fill again.

Implements tachyon::ITextSystem.

◆ BeginAtlasRecord()

void tachyon::SkribidiTextSystem::BeginAtlasRecord ( ID scopeId)
overridevirtual

Records the glyph and icon atlas entries a cached scope's primitives use, until EndAtlasRecord.

ReplayAtlasTouches keeps them alive on each frame the cached pixels are reused, and returns false when one was evicted or moved: the scope must render again.

Reimplemented from tachyon::ITextSystem.

◆ EndAtlasRecord()

void tachyon::SkribidiTextSystem::EndAtlasRecord ( )
overridevirtual

Reimplemented from tachyon::ITextSystem.

◆ ReplayAtlasTouches()

bool tachyon::SkribidiTextSystem::ReplayAtlasTouches ( ID scopeId)
overridevirtual

Reimplemented from tachyon::ITextSystem.

◆ OnKeyboard()

void tachyon::SkribidiTextSystem::OnKeyboard ( ID windowId,
KeyCode key,
int repeat,
KeyModifier modifiers,
KeyAction action )
overridevirtual

Keyboard input for the active text editor.

Implements tachyon::ITextSystem.

◆ OnMouseMove()

void tachyon::SkribidiTextSystem::OnMouseMove ( ID windowId,
int2 screenPos,
MouseButtons button,
KeyModifier modifiers )
overridevirtual

Mouse movement for text selection and drag-drop.

Implements tachyon::ITextSystem.

◆ OnMouseButton()

void tachyon::SkribidiTextSystem::OnMouseButton ( ID windowId,
int2 screenPos,
MouseButtons button,
KeyModifier modifiers,
MouseAction action )
overridevirtual

Mouse buttons for text editors: caret placement, selection, drag-drop.

Implements tachyon::ITextSystem.

◆ OnMouseScroll()

void tachyon::SkribidiTextSystem::OnMouseScroll ( ID windowId,
int2 screenPos,
float2 scrollOffset,
KeyModifier modifiers )
overridevirtual

Mouse wheel input for text editors.

Implements tachyon::ITextSystem.

◆ OnTextComposition()

void tachyon::SkribidiTextSystem::OnTextComposition ( ID id,
std::string_view text,
int32_t cursor )
overridevirtual

IME composition (pre-edit) text, UTF-8, shown but not yet committed; empty when composing ends.

cursor is the caret's codepoint offset within it. Committed text still arrives as KeyChar.

Implements tachyon::IPlatformInputHandler.

◆ SwitchTextEditor()

void tachyon::SkribidiTextSystem::SwitchTextEditor ( ID from,
ID to )
overridevirtual

The focused text field changed (GUIStateManager::TextEditorFocus): commit from (ID::Invalid if none) and move the editor to to (ID::Invalid: no editor).

Implements tachyon::ITextSystem.

◆ SetUndoHistory()

void tachyon::SkribidiTextSystem::SetUndoHistory ( UndoHistory * history)
inlineoverridevirtual

Where committed text edits go as undo steps (none: not recorded).

Implements tachyon::ITextSystem.

◆ ActiveElementID()

ID tachyon::SkribidiTextSystem::ActiveElementID ( ) const

The field the editor holds: the text focus as of the last switch.

◆ DoesTextEditorAcceptTabs()

bool tachyon::SkribidiTextSystem::DoesTextEditorAcceptTabs ( ID elementId) const
overridevirtual

True when the editor elementId inserts tabs (TextEditBehavior::AcceptTabs).

Implements tachyon::ITextSystem.

◆ IsTextEditor()

bool tachyon::SkribidiTextSystem::IsTextEditor ( ID elementId) const
overridevirtual

True when elementId registered editable text this frame.

Implements tachyon::ITextSystem.

◆ RequestSelectAll()

void tachyon::SkribidiTextSystem::RequestSelectAll ( ID elementId)
overridevirtual

Selects all text of the editor elementId the next time it renders.

Implements tachyon::ITextSystem.

◆ ConsumeTextEditUpdate()

TextEditUpdate tachyon::SkribidiTextSystem::ConsumeTextEditUpdate ( TextID textId,
std::string & outText )
overridevirtual

Takes the pending edit of textId: the edited text goes to outText, the result says whether it changed or was committed.

Implements tachyon::ITextSystem.

◆ UpdateText()

bool tachyon::SkribidiTextSystem::UpdateText ( TextID textId,
std::string_view text )
overridevirtual

Replaces the text of textId; true when it changed.

Implements tachyon::ITextSystem.

◆ Copy()

std::string tachyon::SkribidiTextSystem::Copy ( )
overridevirtual

The active editor's selected text.

Implements tachyon::ITextSystem.

◆ Cut()

std::string tachyon::SkribidiTextSystem::Cut ( )
overridevirtual

Removes the active editor's selected text and returns it.

Implements tachyon::ITextSystem.

◆ Paste()

void tachyon::SkribidiTextSystem::Paste ( std::string_view text)
overridevirtual

Inserts Text into the active editor at the caret, replacing the selection.

Implements tachyon::ITextSystem.

◆ IsHoveringSelectedText()

bool tachyon::SkribidiTextSystem::IsHoveringSelectedText ( ID textEditorId,
ID windowId,
tachyon::int2 screenSpace ) const
overridevirtual

True when the screen point screenSpace is over selected text in textEditorId.

Implements tachyon::ITextSystem.

◆ TryGetTextDragCursor()

bool tachyon::SkribidiTextSystem::TryGetTextDragCursor ( ID windowId,
tachyon::int2 screenSpace,
MouseCursor & outCursor ) const
overridevirtual

The mouse cursor to show while text is dragged; true when it overrides the hover cursor.

Implements tachyon::ITextSystem.

◆ TryGetTextDragHoverTarget()

bool tachyon::SkribidiTextSystem::TryGetTextDragHoverTarget ( ID windowId,
tachyon::int2 screenSpace,
ID & outTargetId ) const
overridevirtual

While text is dragged, sets outTargetId to the drop target under the cursor (ID::Invalid if none) and returns true.

False when no text drag is in progress.

Implements tachyon::ITextSystem.

◆ ClearCache()

void tachyon::SkribidiTextSystem::ClearCache ( )
overridevirtual

Drops every registered text and the live editor; earlier TextIDs become invalid.

The focused field keeps its focus. Call when the styles are reloaded.

Implements tachyon::ITextSystem.

◆ RegisteredTextCount()

size_t tachyon::SkribidiTextSystem::RegisteredTextCount ( ) const

Number of registered texts held, for diagnostics.

◆ LayoutsMade()

uint64_t tachyon::SkribidiTextSystem::LayoutsMade ( ) const

Number of text layouts made so far, for diagnostics.

◆ EnsureCursorVisible()

void tachyon::SkribidiTextSystem::EnsureCursorVisible ( ID textEditorId)
overridevirtual

Asks for the caret of textEditorId to be scrolled into view; editor input calls it when the caret moves.

Doesn't scroll: whoever scrolls takes the request with GetCursorRect.

Implements tachyon::ITextSystem.

◆ GetCursorRect()

std::optional< IntRect > tachyon::SkribidiTextSystem::GetCursorRect ( ID textEditorId)
overridevirtual

Takes a pending EnsureCursorVisible request for textEditorId and returns the caret rect, relative to the editor's inner rect.

Empty when none is pending for it.

Implements tachyon::ITextSystem.

◆ GetCaretScreenRect()

std::optional< IntRect > tachyon::SkribidiTextSystem::GetCaretScreenRect ( ) const
overridevirtual

The active editor's caret in absolute screen coordinates (through any zoom/pan), to place the IME candidate window.

Empty when no editor is active.

Implements tachyon::ITextSystem.

◆ RegisterEditableText()

TextID tachyon::SkribidiTextSystem::RegisterEditableText ( ID elementId,
std::string & text,
TextEditBehavior behavior,
StyleRef styleIndex,
ElementState state,
bool & wasModified,
const ITextValidator * validator = nullptr )
overridevirtual

Registers Text as editable by elementId; wasModified is set when an edit changed it.

validator limits what can be typed, pasted or dropped in; it must outlive the field.

Implements tachyon::ITextSystem.

◆ ValueEditText()

std::string * tachyon::SkribidiTextSystem::ValueEditText ( ID elementId,
bool & started )
overridevirtual

The text the focused field elementId edits, kept while it has the focus (its value isn't formatted again under the typing); null when it doesn't have it.

started is set when the focus just arrived: fill it from the value then.

Implements tachyon::ITextSystem.

◆ SetTextColor()

void tachyon::SkribidiTextSystem::SetTextColor ( TextID textId,
VisualColorStyleIndex color )
overridevirtual

Draw a registered text in color instead of its style's text color, until it is registered again (call after each registration, e.g.

for a NaN value).

Implements tachyon::ITextSystem.

◆ SetCaretColor()

void tachyon::SkribidiTextSystem::SetCaretColor ( VisualColorStyleIndex color)
overridevirtual

The text caret's color (the theme's –caret). Set again after the style manager is cleared.

Implements tachyon::ITextSystem.

◆ SetFontDirectory()

void tachyon::SkribidiTextSystem::SetFontDirectory ( std::string_view directory)
overridevirtual

Where the built-in fonts are (default "fonts", relative to the working directory): Inter for text and JetBrains Mono for monospace.

Empty loads none, for an app that registers its own. Initialize fails when they are set but missing. Call before Initialize.

Implements tachyon::ITextSystem.

◆ SetFallbackFontDirectory()

void tachyon::SkribidiTextSystem::SetFallbackFontDirectory ( std::string_view directory)
overridevirtual

Where the optional fallback fonts are: Noto, for other scripts, emoji and symbols.

Empty (the default) loads none. Only the files an app ships there are used; missing ones are skipped with a warning. Call before Initialize.

Implements tachyon::ITextSystem.

◆ SetLanguage()

void tachyon::SkribidiTextSystem::SetLanguage ( std::string_view languageTag)
overridevirtual

The default language as a BCP 47 tag ("ja", "zh-Hant", "ko"), for text whose style has no language of its own (TextStyle::language / -tachyon-language).

It picks regional letterforms, e.g. Japanese kanji vs Chinese hanzi; empty means Simplified Chinese forms. Changing it lays all text out again.

Implements tachyon::ITextSystem.

◆ RegisterFontFamily() [1/2]

FontID tachyon::SkribidiTextSystem::RegisterFontFamily ( std::string_view familyName,
std::span< const FontFaceSource > faces )
overridevirtual

Registers a font family from its faces (regular, bold, italic, ...); each face's weight and style come from the file.

Returns FontIDFromName(familyName) for use in TextStyle::fontId, or FontID::Invalid if no face could be loaded. Re-registering a family name with the same faces is a no-op; other faces replace the old ones and all text is laid out again (a failed re-registration keeps the previous faces).

Implements tachyon::ITextSystem.

◆ RegisterText()

TextID tachyon::SkribidiTextSystem::RegisterText ( ID elementId,
IconID iconId,
std::string_view text,
StyleRef styleIndex,
ElementState state )
overridevirtual

Registers static text, with an optional icon, for elementId.

Implements tachyon::ITextSystem.

◆ RegisterRichText()

TextID tachyon::SkribidiTextSystem::RegisterRichText ( ID elementId,
const std::span< ContentRun > & contentRuns,
StyleRef styleIndex,
ElementState state )
overridevirtual

Registers text made of runs: styled text, inline icons and links.

Implements tachyon::ITextSystem.

◆ RegisterEditableRichText()

TextID tachyon::SkribidiTextSystem::RegisterEditableRichText ( ID elementId,
const std::span< ContentRun > & contentRuns,
TextEditBehavior behavior,
StyleRef styleIndex,
ElementState state,
bool & wasModified )
overridevirtual

Registers rich text that renders like RegisterRichText but can also be selected and copied (the runs' text joined).

Pass TextEditBehavior::ReadOnly to block edits.

Implements tachyon::ITextSystem.

◆ GetTextID()

TextID tachyon::SkribidiTextSystem::GetTextID ( ID elementId) const
overridevirtual

The TextID elementId registered this frame, or TextID::Invalid.

Lets an event handler find its text for hit-testing and hover.

Implements tachyon::ITextSystem.

◆ GetText()

std::string_view tachyon::SkribidiTextSystem::GetText ( TextID textId) const
overridevirtual

The text registered as textId.

Implements tachyon::ITextSystem.

◆ GetTextMeasurement()

TextMeasurement tachyon::SkribidiTextSystem::GetTextMeasurement ( TextID textId) const
overridevirtual

The unwrapped measurement of textId, in pixels; cached until its text or style changes.

Implements tachyon::ITextSystem.

◆ GetTextHeightWithoutIcon()

int32_t tachyon::SkribidiTextSystem::GetTextHeightWithoutIcon ( TextID textId) const
overridevirtual

How high textId's text is unwrapped, in pixels, without the icon it was registered with (which its measurement has in it).

Implements tachyon::ITextSystem.

◆ MeasureText()

TextMeasurement tachyon::SkribidiTextSystem::MeasureText ( TextID textId,
const TextWrapContext & wrapContext ) const
overridevirtual

The measurement of textId wrapped to wrapContext.maxWidth, in pixels.

Implements tachyon::ITextSystem.

◆ RenderText()

void tachyon::SkribidiTextSystem::RenderText ( TextID textId,
IntRect rect,
IntRect innerRect,
IntRect clipRect,
float pixelScale = 1.f,
const float3x2 & screenToLayout = float3x2::Identity() )
overridevirtual

Draws textId into rect (renderer space, window-local), clipped to clipRect.

rect can be larger than innerRect when the element scrolls its text. innerRect is the visible content area in absolute layout coordinates (the element's ElementRect::innerRect); mouse positions are hit-tested against it after mapping them with screenToLayout, the inverse of any ancestor zoom/pan.

Implements tachyon::ITextSystem.

◆ LinkCursorAt()

std::optional< MouseCursor > tachyon::SkribidiTextSystem::LinkCursorAt ( ID elementId,
int32_t localX,
int32_t localY ) const
overridevirtual

The cursor of the link at (localX, localY), element-local (its LinkStyle::cursor); none when there's no link there.

Implements tachyon::ITextSystem.

◆ HitTestContent()

intptr_t tachyon::SkribidiTextSystem::HitTestContent ( TextID textId,
int32_t localX,
int32_t localY ) const
overridevirtual

The contentId of the run at (localX, localY), element-local; 0 if none.

Implements tachyon::ITextSystem.

◆ SetHoveredContent()

void tachyon::SkribidiTextSystem::SetHoveredContent ( TextID textId,
intptr_t contentId )
overridevirtual

Sets the hovered run of textId (by contentId), drawn in its hover style; 0 for none.

Implements tachyon::ITextSystem.

◆ IsValidIcon()

bool tachyon::SkribidiTextSystem::IsValidIcon ( IconID iconId) const
overridevirtual

True when iconId is a registered icon.

Implements tachyon::ITextSystem.

◆ RegisterIconFromSVG()

IconID tachyon::SkribidiTextSystem::RegisterIconFromSVG ( const char * name,
const char * svg_data,
size_t svg_size )
overridevirtual

Registers an icon from SVG data under a unique name.

Registering a name again returns the existing icon.

Implements tachyon::ITextSystem.

◆ RegisterIconFromSVGFile()

IconID tachyon::SkribidiTextSystem::RegisterIconFromSVGFile ( const char * path)
overridevirtual

Registers an icon from an SVG file, named by its path.

IconID::Invalid if the file is missing, unreadable or doesn't parse.

Implements tachyon::ITextSystem.

◆ RegisterIconFromPixels()

IconID tachyon::SkribidiTextSystem::RegisterIconFromPixels ( const char * name,
uint2 size,
std::span< const uint8_t > rgba )
overridevirtual

Registers an icon from size.x x size.y RGBA pixels (straight alpha, rows from the top) under a unique name: a picture in its own colors, drawn untinted.

Registering a name again returns the existing icon. Each takes one of the image slots shared with fonts, gradients and images. IconID::Invalid if rgba is too short.

Implements tachyon::ITextSystem.

◆ UnregisterIcon()

void tachyon::SkribidiTextSystem::UnregisterIcon ( IconID iconId)
overridevirtual

Lets go of an icon from RegisterIconFromPixels: its image slot is freed, the ID draws nothing from then on and isn't given out again, and its name can be registered anew.

Does nothing for other icons.

Implements tachyon::ITextSystem.

◆ GetIconMeasurement()

IconMeasurement tachyon::SkribidiTextSystem::GetIconMeasurement ( IconID iconId) const
overridevirtual

The natural size of iconId, in pixels (same as MeasureIcon).

Implements tachyon::ITextSystem.

◆ MeasureIcon()

IconMeasurement tachyon::SkribidiTextSystem::MeasureIcon ( IconID iconId) const
overridevirtual

The natural size of iconId, in pixels.

Implements tachyon::ITextSystem.

◆ RenderIcon()

void tachyon::SkribidiTextSystem::RenderIcon ( IconID iconId,
IntRect rect,
IntRect clipRect,
VisualColorStyleIndex tint,
std::span< const VisualShadow > shadows = {} )
overridevirtual

Draws iconId fitted into rect (aspect kept, centered), clipped to clipRect.

Single-color icons are drawn in tint, like text; colored icons keep their colors. shadows (a text style's textShadows, the first on top) are drawn under it.

Implements tachyon::ITextSystem.

◆ ScreenToTextEditorLocalPoint()

void tachyon::SkribidiTextSystem::ScreenToTextEditorLocalPoint ( tachyon::int2 screenSpace,
const IntRect & textEditorInnerRect,
tachyon::float2 & outLocal,
const float3x2 & screenToLayout = float3x2::Identity() )
static

◆ RegisterFontFamily() [2/2]

FontID tachyon::ITextSystem::RegisterFontFamily ( std::string_view familyName,
std::span< const std::string_view > faceFiles )
inline

The documentation for this class was generated from the following file: