Thu, 10 Jul 2025 22:13:39 +0200
improve signatures of other text functions and make them linkable symbols
src/ascension/ui/text.h | file | annotate | diff | comparison | revisions | |
src/text.c | file | annotate | diff | comparison | revisions |
--- a/src/ascension/ui/text.h Wed Jul 09 22:30:52 2025 +0200 +++ b/src/ascension/ui/text.h Thu Jul 10 22:13:39 2025 +0200 @@ -105,14 +105,10 @@ * * @param node the text node */ -static inline void asc_text_alignment( - AscSceneNode *node, +void asc_text_alignment( + AscText *node, enum asc_text_alignment alignment -) { - // TODO: does not need to be static - asc_set_flag_masked(node->flags, ASC_TEXT_ALIGNMENT_MASK, alignment); - asc_node_update(node); -} +); /** * Decides whether the text shall be centered. @@ -120,18 +116,7 @@ * @param node the text node * @param centered true when the text shall be centered */ -static inline void asc_text_centered( - AscSceneNode *node, - bool centered -) { - // TODO: does not need to be static - if (centered) { - asc_clear_flag(node->flags, ASC_TEXT_ALIGN_CENTERED); - } else { - asc_set_flag(node->flags, ASC_TEXT_ALIGN_CENTERED); - } - asc_node_update(node); -} +void asc_text_centered(AscText *node, bool centered); /** * Sets a new maximum width for the text. @@ -139,24 +124,17 @@ * @param node the text node * @param max_width the new maximum width */ -static inline void asc_text_max_width( - AscSceneNode *node, - unsigned max_width -) { - // TODO: does not need to be static - ((AscText*)node)->max_width = max_width; - asc_node_update(node); -} +void asc_text_max_width(AscText *node, unsigned max_width); /** * Updates the content of a text node with formatted text. * - * @param text_node the node + * @param node the node * @param format the format string * @param ... the format arguments */ void asc_text_printf( - AscText *text_node, + AscText *node, const char *format, ... );
--- a/src/text.c Wed Jul 09 22:30:52 2025 +0200 +++ b/src/text.c Thu Jul 10 22:13:39 2025 +0200 @@ -126,20 +126,44 @@ return node; } +void asc_text_alignment( + AscText *node, + enum asc_text_alignment alignment +) { + asc_ptr_cast(AscSceneNode, snode, node); + asc_set_flag_masked(snode->flags, ASC_TEXT_ALIGNMENT_MASK, alignment); + asc_node_update(snode); +} + +void asc_text_centered(AscText *node, bool centered) { + asc_ptr_cast(AscSceneNode, snode, node); + if (centered) { + asc_clear_flag(snode->flags, ASC_TEXT_ALIGN_CENTERED); + } else { + asc_set_flag(snode->flags, ASC_TEXT_ALIGN_CENTERED); + } + asc_node_update(snode); +} + +void asc_text_max_width(AscText *node, unsigned max_width) { + node->max_width = max_width; + asc_node_update((AscSceneNode*)node); +} + void asc_text_printf( - AscText *text_node, + AscText *node, const char *format, ... ) { va_list ap; va_start(ap, format); cx_vsprintf( - &text_node->text.ptr, - &text_node->text.length, + &node->text.ptr, + &node->text.length, format, ap ); va_end(ap); - asc_node_update((AscSceneNode*)text_node); + asc_node_update((AscSceneNode*)node); }