Sat, 12 Jul 2025 22:06:24 +0200
remove ui subdir in includes
it is not really necessary and without it,
we can have much cleaner includes
make/gcc.mk | file | annotate | diff | comparison | revisions | |
src/Makefile | file | annotate | diff | comparison | revisions | |
src/ascension/context.h | file | annotate | diff | comparison | revisions | |
src/ascension/font.h | file | annotate | diff | comparison | revisions | |
src/ascension/text.h | file | annotate | diff | comparison | revisions | |
src/ascension/ui.h | file | annotate | diff | comparison | revisions | |
src/ascension/ui/font.h | file | annotate | diff | comparison | revisions | |
src/ascension/ui/text.h | file | annotate | diff | comparison | revisions | |
src/font.c | file | annotate | diff | comparison | revisions | |
src/text.c | file | annotate | diff | comparison | revisions | |
test/snake/Makefile | file | annotate | diff | comparison | revisions |
--- a/make/gcc.mk Sat Jul 12 21:49:12 2025 +0200 +++ b/make/gcc.mk Sat Jul 12 22:06:24 2025 +0200 @@ -1,8 +1,8 @@ - # - # gcc toolchain config - # +# +# gcc toolchain config +# - CFLAGS = - DEBUG_CFLAGS = -g -Wall -Wextra -Werror -Wno-missing-field-initializers - RELEASE_CFLAGS = -O3 -DNDEBUG - LDFLAGS = \ No newline at end of file +CFLAGS = +DEBUG_CFLAGS = -g -Wall -Wextra -Werror -Wno-missing-field-initializers +RELEASE_CFLAGS = -O3 -DNDEBUG +LDFLAGS = \ No newline at end of file
--- a/src/Makefile Sat Jul 12 21:49:12 2025 +0200 +++ b/src/Makefile Sat Jul 12 22:06:24 2025 +0200 @@ -48,39 +48,36 @@ ascension/datatypes.h ascension/transform.h ascension/mesh.h \ ascension/constants.h ascension/context.h ascension/window.h \ ascension/glcontext.h ascension/scene.h ascension/camera.h \ - ascension/input.h ascension/ui/font.h ascension/error.h \ - ascension/shader.h + ascension/input.h ascension/font.h ascension/error.h ascension/shader.h @echo "Compiling $<" $(CC) -o $@ $(CFLAGS) -c $< $(BUILD_DIR)/behavior.o: behavior.c ascension/behavior.h \ ascension/scene_node.h ascension/datatypes.h ascension/transform.h \ ascension/context.h ascension/window.h ascension/glcontext.h \ - ascension/scene.h ascension/camera.h ascension/input.h \ - ascension/ui/font.h ascension/scene.h ascension/util.h ascension/error.h + ascension/scene.h ascension/camera.h ascension/input.h ascension/font.h \ + ascension/scene.h ascension/util.h ascension/error.h @echo "Compiling $<" $(CC) -o $@ $(CFLAGS) -c $< $(BUILD_DIR)/camera.o: camera.c ascension/error.h ascension/context.h \ ascension/datatypes.h ascension/window.h ascension/glcontext.h \ ascension/scene.h ascension/scene_node.h ascension/transform.h \ - ascension/camera.h ascension/input.h ascension/ui/font.h \ - ascension/camera.h + ascension/camera.h ascension/input.h ascension/font.h ascension/camera.h @echo "Compiling $<" $(CC) -o $@ $(CFLAGS) -c $< $(BUILD_DIR)/context.o: context.c ascension/context.h \ ascension/datatypes.h ascension/window.h ascension/glcontext.h \ ascension/scene.h ascension/scene_node.h ascension/transform.h \ - ascension/camera.h ascension/input.h ascension/ui/font.h \ - ascension/error.h + ascension/camera.h ascension/input.h ascension/font.h ascension/error.h @echo "Compiling $<" $(CC) -o $@ $(CFLAGS) -c $< $(BUILD_DIR)/error.o: error.c ascension/context.h ascension/datatypes.h \ ascension/window.h ascension/glcontext.h ascension/scene.h \ ascension/scene_node.h ascension/transform.h ascension/camera.h \ - ascension/input.h ascension/ui/font.h ascension/error.h + ascension/input.h ascension/font.h ascension/error.h @echo "Compiling $<" $(CC) -o $@ $(CFLAGS) -c $< @@ -91,8 +88,8 @@ $(BUILD_DIR)/font.o: font.c ascension/error.h ascension/context.h \ ascension/datatypes.h ascension/window.h ascension/glcontext.h \ ascension/scene.h ascension/scene_node.h ascension/transform.h \ - ascension/camera.h ascension/input.h ascension/ui/font.h \ - ascension/filesystem.h ascension/ui/font.h + ascension/camera.h ascension/input.h ascension/font.h \ + ascension/filesystem.h ascension/font.h @echo "Compiling $<" $(CC) -o $@ $(CFLAGS) -c $< @@ -110,8 +107,8 @@ $(BUILD_DIR)/scene.o: scene.c ascension/error.h ascension/context.h \ ascension/datatypes.h ascension/window.h ascension/glcontext.h \ ascension/scene.h ascension/scene_node.h ascension/transform.h \ - ascension/camera.h ascension/input.h ascension/ui/font.h \ - ascension/scene.h ascension/behavior.h ascension/shader.h + ascension/camera.h ascension/input.h ascension/font.h ascension/scene.h \ + ascension/behavior.h ascension/shader.h @echo "Compiling $<" $(CC) -o $@ $(CFLAGS) -c $< @@ -119,14 +116,14 @@ ascension/datatypes.h ascension/transform.h ascension/context.h \ ascension/window.h ascension/glcontext.h ascension/scene.h \ ascension/scene_node.h ascension/camera.h ascension/input.h \ - ascension/ui/font.h ascension/error.h + ascension/font.h ascension/error.h @echo "Compiling $<" $(CC) -o $@ $(CFLAGS) -c $< $(BUILD_DIR)/shader.o: shader.c ascension/shader.h ascension/camera.h \ ascension/datatypes.h ascension/context.h ascension/window.h \ ascension/glcontext.h ascension/scene.h ascension/scene_node.h \ - ascension/transform.h ascension/input.h ascension/ui/font.h \ + ascension/transform.h ascension/input.h ascension/font.h \ ascension/error.h ascension/filesystem.h @echo "Compiling $<" $(CC) -o $@ $(CFLAGS) -c $< @@ -135,38 +132,34 @@ ascension/datatypes.h ascension/transform.h ascension/mesh.h \ ascension/texture.h ascension/camera.h ascension/context.h \ ascension/window.h ascension/glcontext.h ascension/scene.h \ - ascension/input.h ascension/ui/font.h ascension/glcontext.h \ + ascension/input.h ascension/font.h ascension/glcontext.h \ ascension/error.h ascension/mesh.h ascension/shader.h \ ascension/constants.h @echo "Compiling $<" $(CC) -o $@ $(CFLAGS) -c $< -$(BUILD_DIR)/text.o: text.c ascension/ui/text.h ascension/ui/font.h \ - ascension/ui/../mesh.h ascension/ui/../datatypes.h \ - ascension/ui/../texture.h ascension/ui/../scene_node.h \ - ascension/ui/../transform.h ascension/error.h ascension/context.h \ - ascension/datatypes.h ascension/window.h ascension/glcontext.h \ - ascension/scene.h ascension/scene_node.h ascension/camera.h \ - ascension/input.h ascension/ui/font.h ascension/shader.h \ - ascension/constants.h +$(BUILD_DIR)/text.o: text.c ascension/text.h ascension/font.h \ + ascension/mesh.h ascension/datatypes.h ascension/texture.h \ + ascension/scene_node.h ascension/transform.h ascension/error.h \ + ascension/context.h ascension/window.h ascension/glcontext.h \ + ascension/scene.h ascension/camera.h ascension/input.h \ + ascension/shader.h ascension/constants.h @echo "Compiling $<" $(CC) -o $@ $(CFLAGS) -c $< $(BUILD_DIR)/texture.o: texture.c ascension/error.h ascension/context.h \ ascension/datatypes.h ascension/window.h ascension/glcontext.h \ ascension/scene.h ascension/scene_node.h ascension/transform.h \ - ascension/camera.h ascension/input.h ascension/ui/font.h \ + ascension/camera.h ascension/input.h ascension/font.h \ ascension/texture.h ascension/filesystem.h @echo "Compiling $<" $(CC) -o $@ $(CFLAGS) -c $< -$(BUILD_DIR)/ui.o: ui.c ascension/ui.h ascension/ui/text.h \ - ascension/ui/font.h ascension/ui/../mesh.h ascension/ui/../datatypes.h \ - ascension/ui/../texture.h ascension/ui/../scene_node.h \ - ascension/ui/../transform.h ascension/context.h ascension/datatypes.h \ +$(BUILD_DIR)/ui.o: ui.c ascension/ui.h ascension/text.h ascension/font.h \ + ascension/mesh.h ascension/datatypes.h ascension/texture.h \ + ascension/scene_node.h ascension/transform.h ascension/context.h \ ascension/window.h ascension/glcontext.h ascension/scene.h \ - ascension/scene_node.h ascension/camera.h ascension/input.h \ - ascension/ui/font.h ascension/scene.h + ascension/camera.h ascension/input.h ascension/scene.h @echo "Compiling $<" $(CC) -o $@ $(CFLAGS) -c $< @@ -178,7 +171,7 @@ ascension/datatypes.h ascension/glcontext.h ascension/scene.h \ ascension/scene_node.h ascension/transform.h ascension/camera.h \ ascension/context.h ascension/window.h ascension/input.h \ - ascension/ui/font.h + ascension/font.h @echo "Compiling $<" $(CC) -o $@ $(CFLAGS) -c $<
--- a/src/ascension/context.h Sat Jul 12 21:49:12 2025 +0200 +++ b/src/ascension/context.h Sat Jul 12 22:06:24 2025 +0200 @@ -31,7 +31,7 @@ #include "datatypes.h" #include "window.h" #include "input.h" -#include "ui/font.h" +#include "font.h" #include <cx/buffer.h> #include <cx/string.h>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/ascension/font.h Sat Jul 12 22:06:24 2025 +0200 @@ -0,0 +1,80 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * Copyright 2023 Mike Becker. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef ASCENSION_FONT_H +#define ASCENSION_FONT_H + +#include <SDL2/SDL_ttf.h> + +enum AscFontStyle { + ASC_FONT_REGULAR, + ASC_FONT_BOLD, + ASC_FONT_ITALIC, + ASC_FONT_BOLD_ITALIC, +}; + +typedef struct asc_font_s { + /** + * Style of the font. + */ + enum AscFontStyle style; + /** + * Point size. + */ + int size; +} AscFont; + +/** + * Activates a font with the given style and size. + * + * The font is cached and activated faster the next time you call this + * function with the same arguments. However, when you reach the maximum + * number of fonts, the cache is completely cleared and rebuilt. + * + * That means in general, that you should not be using too many fonts of + * different sizes at the same time. + * + * @param style the style + * @param size the point size + */ +void asc_font(enum AscFontStyle style, int size); + +/** + * Loads the specified font. + * + * Loaded fonts are kept within a font cache and returned faster + * on the next invocation. + * + * You will almost never need to use this function on your own. + * Ascension UI elements are loading the required fonts for you. + * + * @param font the font description + * @return a pointer to the SDL TTF font handle, or @c NULL on error + */ +TTF_Font *asc_font_load(AscFont font); + +#endif //ASCENSION_FONT_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/ascension/text.h Sat Jul 12 22:06:24 2025 +0200 @@ -0,0 +1,146 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * Copyright 2023 Mike Becker. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef ASCENSION_UI_TEXT_H +#define ASCENSION_UI_TEXT_H + +#include "font.h" +// TODO: clean up these messy include paths +#include "mesh.h" +#include "texture.h" +#include "scene_node.h" + +#include <cx/string.h> + +typedef struct asc_text_s { + AscSceneNode base; + AscMesh mesh; + AscTexture *texture; + cxmutstr text; + AscFont font; + asc_col4i color; + unsigned short max_width; + /** + * The automatically calculated offset in case the text is centered. + */ + unsigned short offx; + /** + * The automatically calculated text dimension. + */ + asc_vec2u dimension; +} AscText; + +enum asc_text_alignment { + ASC_TEXT_ALIGN_LEFT = 0x00, + ASC_TEXT_ALIGN_CENTERED = 0x01, + ASC_TEXT_ALIGN_RIGHT = 0x02 +}; +#define ASC_TEXT_ALIGNMENT_MASK 0x03 +#define ASC_TEXT_CENTERED_FLAG 0x04 + +struct asc_text_create_args { + int x; + int y; + const char *name; + const char *text; + enum asc_text_alignment alignment; + unsigned short max_width; +}; + +/** + * Creates a text node. + * + * The current context ink and font will be used. + * + * @param args initial arguments for creating the node + * @return the scene node + * + * @see asc_ink() + * @see asc_font() + */ +AscSceneNode *asc_text_create(struct asc_text_create_args args); + +/** + * Creates a text node. + * + * The current context ink and font will be used. + * + * This is a convenience macro that lets you use the arguments + * as named parameters. Usage example: + * @code + * AscSceneNode *mytext = asc_text( .x = 10, .y = 15 ); + * @endcode + * + * @param ... initial arguments for creating the node + * @return the scene node + * + * @see asc_ink() + * @see asc_font() + */ +#define asc_text(...) \ + asc_text_create((struct asc_text_create_args) { __VA_ARGS__ }) + +/** + * Sets the text alignment. + * + * @param node the text node + */ +void asc_text_alignment( + AscText *node, + enum asc_text_alignment alignment +); + +/** + * Decides whether the text shall be centered. + * + * @param node the text node + * @param centered true when the text shall be centered + */ +void asc_text_centered(AscText *node, bool centered); + +/** + * Sets a new maximum width for the text. + * + * @param node the text node + * @param max_width the new maximum width + */ +void asc_text_max_width(AscText *node, unsigned max_width); + +/** + * Updates the content of a text node with formatted text. + * + * @param node the node + * @param format the format string + * @param ... the format arguments + */ +void asc_text_printf( + AscText *node, + const char *format, + ... +); + +#endif //ASCENSION_UI_TEXT_H
--- a/src/ascension/ui.h Sat Jul 12 21:49:12 2025 +0200 +++ b/src/ascension/ui.h Sat Jul 12 22:06:24 2025 +0200 @@ -29,7 +29,7 @@ #define ASCENSION_UI_H #ifndef ASCENSION_UI_IMPLEMENTATION -#include "ui/text.h" +#include "text.h" #endif /**
--- a/src/ascension/ui/font.h Sat Jul 12 21:49:12 2025 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,80 +0,0 @@ -/* - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. - * Copyright 2023 Mike Becker. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef ASCENSION_FONT_H -#define ASCENSION_FONT_H - -#include <SDL2/SDL_ttf.h> - -enum AscFontStyle { - ASC_FONT_REGULAR, - ASC_FONT_BOLD, - ASC_FONT_ITALIC, - ASC_FONT_BOLD_ITALIC, -}; - -typedef struct asc_font_s { - /** - * Style of the font. - */ - enum AscFontStyle style; - /** - * Point size. - */ - int size; -} AscFont; - -/** - * Activates a font with the given style and size. - * - * The font is cached and activated faster the next time you call this - * function with the same arguments. However, when you reach the maximum - * number of fonts, the cache is completely cleared and rebuilt. - * - * That means in general, that you should not be using too many fonts of - * different sizes at the same time. - * - * @param style the style - * @param size the point size - */ -void asc_font(enum AscFontStyle style, int size); - -/** - * Loads the specified font. - * - * Loaded fonts are kept within a font cache and returned faster - * on the next invocation. - * - * You will almost never need to use this function on your own. - * Ascension UI elements are loading the required fonts for you. - * - * @param font the font description - * @return a pointer to the SDL TTF font handle, or @c NULL on error - */ -TTF_Font *asc_font_load(AscFont font); - -#endif //ASCENSION_FONT_H
--- a/src/ascension/ui/text.h Sat Jul 12 21:49:12 2025 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,146 +0,0 @@ -/* - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. - * Copyright 2023 Mike Becker. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef ASCENSION_UI_TEXT_H -#define ASCENSION_UI_TEXT_H - -#include "font.h" -// TODO: clean up these messy include paths -#include "../mesh.h" -#include "../texture.h" -#include "../scene_node.h" - -#include <cx/string.h> - -typedef struct asc_text_s { - AscSceneNode base; - AscMesh mesh; - AscTexture *texture; - cxmutstr text; - AscFont font; - asc_col4i color; - unsigned short max_width; - /** - * The automatically calculated offset in case the text is centered. - */ - unsigned short offx; - /** - * The automatically calculated text dimension. - */ - asc_vec2u dimension; -} AscText; - -enum asc_text_alignment { - ASC_TEXT_ALIGN_LEFT = 0x00, - ASC_TEXT_ALIGN_CENTERED = 0x01, - ASC_TEXT_ALIGN_RIGHT = 0x02 -}; -#define ASC_TEXT_ALIGNMENT_MASK 0x03 -#define ASC_TEXT_CENTERED_FLAG 0x04 - -struct asc_text_create_args { - int x; - int y; - const char *name; - const char *text; - enum asc_text_alignment alignment; - unsigned short max_width; -}; - -/** - * Creates a text node. - * - * The current context ink and font will be used. - * - * @param args initial arguments for creating the node - * @return the scene node - * - * @see asc_ink() - * @see asc_font() - */ -AscSceneNode *asc_text_create(struct asc_text_create_args args); - -/** - * Creates a text node. - * - * The current context ink and font will be used. - * - * This is a convenience macro that lets you use the arguments - * as named parameters. Usage example: - * @code - * AscSceneNode *mytext = asc_text( .x = 10, .y = 15 ); - * @endcode - * - * @param ... initial arguments for creating the node - * @return the scene node - * - * @see asc_ink() - * @see asc_font() - */ -#define asc_text(...) \ - asc_text_create((struct asc_text_create_args) { __VA_ARGS__ }) - -/** - * Sets the text alignment. - * - * @param node the text node - */ -void asc_text_alignment( - AscText *node, - enum asc_text_alignment alignment -); - -/** - * Decides whether the text shall be centered. - * - * @param node the text node - * @param centered true when the text shall be centered - */ -void asc_text_centered(AscText *node, bool centered); - -/** - * Sets a new maximum width for the text. - * - * @param node the text node - * @param max_width the new maximum width - */ -void asc_text_max_width(AscText *node, unsigned max_width); - -/** - * Updates the content of a text node with formatted text. - * - * @param node the node - * @param format the format string - * @param ... the format arguments - */ -void asc_text_printf( - AscText *node, - const char *format, - ... -); - -#endif //ASCENSION_UI_TEXT_H
--- a/src/font.c Sat Jul 12 21:49:12 2025 +0200 +++ b/src/font.c Sat Jul 12 22:06:24 2025 +0200 @@ -28,7 +28,7 @@ #include "ascension/error.h" #include "ascension/context.h" #include "ascension/filesystem.h" -#include "ascension/ui/font.h" +#include "ascension/font.h" #include <assert.h> #include <math.h>
--- a/src/text.c Sat Jul 12 21:49:12 2025 +0200 +++ b/src/text.c Sat Jul 12 22:06:24 2025 +0200 @@ -25,7 +25,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include "ascension/ui/text.h" +#include "ascension/text.h" #include "ascension/error.h" #include "ascension/context.h"
--- a/test/snake/Makefile Sat Jul 12 21:49:12 2025 +0200 +++ b/test/snake/Makefile Sat Jul 12 22:06:24 2025 +0200 @@ -50,14 +50,10 @@ ../../src/ascension/glcontext.h ../../src/ascension/scene.h \ ../../src/ascension/scene_node.h ../../src/ascension/transform.h \ ../../src/ascension/camera.h ../../src/ascension/input.h \ - ../../src/ascension/ui/font.h ../../src/ascension/behavior.h \ - ../../src/ascension/ui.h ../../src/ascension/ui/text.h \ - ../../src/ascension/ui/font.h ../../src/ascension/ui/../mesh.h \ - ../../src/ascension/ui/../datatypes.h \ - ../../src/ascension/ui/../texture.h \ - ../../src/ascension/ui/../scene_node.h ../../src/ascension/sprite.h \ + ../../src/ascension/font.h ../../src/ascension/behavior.h \ + ../../src/ascension/ui.h ../../src/ascension/text.h \ ../../src/ascension/mesh.h ../../src/ascension/texture.h \ - ../../src/ascension/2d.h + ../../src/ascension/sprite.h ../../src/ascension/2d.h @echo "Compiling $<" $(CC) -o $@ $(CFLAGS) -c $<