Fri, 08 Aug 2025 20:51:14 +0200
add show/hide functions for scene nodes
src/ascension/scene_node.h | file | annotate | diff | comparison | revisions | |
src/scene.c | file | annotate | diff | comparison | revisions | |
src/text.c | file | annotate | diff | comparison | revisions |
--- a/src/ascension/scene_node.h Fri Aug 08 20:51:02 2025 +0200 +++ b/src/ascension/scene_node.h Fri Aug 08 20:51:14 2025 +0200 @@ -315,4 +315,20 @@ asc_scene_node_update_transform(node); } +static inline void asc_scene_node_hide(AscSceneNode *node) { + asc_set_flag(node->flags, ASC_SCENE_NODE_HIDDEN); +} + +static inline void asc_scene_node_show(AscSceneNode *node) { + asc_clear_flag(node->flags, ASC_SCENE_NODE_HIDDEN); +} + +static inline void asc_scene_node_toggle_visibility(AscSceneNode *node) { + asc_toggle_flag(node->flags, ASC_SCENE_NODE_HIDDEN); +} + +static inline bool asc_scene_node_is_hidden(AscSceneNode *node) { + return asc_test_flag(node->flags, ASC_SCENE_NODE_HIDDEN); +} + #endif
--- a/src/scene.c Fri Aug 08 20:51:02 2025 +0200 +++ b/src/scene.c Fri Aug 08 20:51:14 2025 +0200 @@ -152,7 +152,7 @@ ); cx_foreach(AscSceneNode*, node, iter) { // skip hidden nodes (and all their children) - if (asc_test_flag(node->flags, ASC_SCENE_NODE_HIDDEN)) { + if (asc_scene_node_is_hidden(node)) { cxTreeVisitorContinue(iter); }
--- a/src/text.c Fri Aug 08 20:51:02 2025 +0200 +++ b/src/text.c Fri Aug 08 20:51:14 2025 +0200 @@ -63,7 +63,7 @@ TTF_Font *font = asc_font_load(text->font); if (font == NULL) { // cannot load font - hide the text node to avoid errors when trying to draw - asc_set_flag(node->flags, ASC_SCENE_NODE_HIDDEN); + asc_scene_node_hide(node); return; } static TTF_HorizontalAlignment alignments[] = {