Tue, 09 Apr 2024 21:18:52 +0200
add texture.h
universe@3 | 1 | /* |
universe@3 | 2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. |
universe@3 | 3 | * Copyright 2023 Mike Becker. All rights reserved. |
universe@3 | 4 | * |
universe@3 | 5 | * Redistribution and use in source and binary forms, with or without |
universe@3 | 6 | * modification, are permitted provided that the following conditions are met: |
universe@3 | 7 | * |
universe@3 | 8 | * 1. Redistributions of source code must retain the above copyright |
universe@3 | 9 | * notice, this list of conditions and the following disclaimer. |
universe@3 | 10 | * |
universe@3 | 11 | * 2. Redistributions in binary form must reproduce the above copyright |
universe@3 | 12 | * notice, this list of conditions and the following disclaimer in the |
universe@3 | 13 | * documentation and/or other materials provided with the distribution. |
universe@3 | 14 | * |
universe@3 | 15 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
universe@3 | 16 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
universe@3 | 17 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
universe@3 | 18 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE |
universe@3 | 19 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
universe@3 | 20 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
universe@3 | 21 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
universe@3 | 22 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
universe@3 | 23 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
universe@3 | 24 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
universe@3 | 25 | * POSSIBILITY OF SUCH DAMAGE. |
universe@3 | 26 | */ |
universe@3 | 27 | |
universe@48 | 28 | #ifndef ASCENSION_UI_TEXT_H |
universe@48 | 29 | #define ASCENSION_UI_TEXT_H |
universe@3 | 30 | |
universe@16 | 31 | #include "font.h" |
universe@48 | 32 | #include "../scene.h" |
universe@50 | 33 | #include "../texture.h" |
universe@11 | 34 | |
universe@25 | 35 | typedef struct AscText { |
universe@29 | 36 | extend_asc_scene_node; |
universe@23 | 37 | char *text; |
universe@19 | 38 | AscFont const *font; |
universe@19 | 39 | asc_col4i color; |
universe@19 | 40 | unsigned max_width; |
universe@17 | 41 | bool hidden; |
universe@19 | 42 | bool centered; |
universe@50 | 43 | AscTexture tex; |
universe@25 | 44 | } AscText; |
universe@4 | 45 | |
universe@4 | 46 | |
universe@4 | 47 | /** |
universe@19 | 48 | * Creates a text node. |
universe@4 | 49 | * |
universe@36 | 50 | * The current context ink and font will be used. |
universe@11 | 51 | * |
universe@19 | 52 | * @param x the position where to draw the text |
universe@19 | 53 | * @param y the position where to draw the text |
universe@19 | 54 | * @param text the text to draw |
universe@36 | 55 | * @return the scene node |
universe@36 | 56 | * |
universe@16 | 57 | * @see asc_ink() |
universe@16 | 58 | * @see asc_font() |
universe@4 | 59 | */ |
universe@36 | 60 | AscSceneNode *asc_text(int x, int y, char const* text); |
universe@36 | 61 | |
universe@36 | 62 | /** |
universe@36 | 63 | * Provides access to the text data fields. |
universe@36 | 64 | * |
universe@36 | 65 | * @param node scene node created by asc_text() |
universe@36 | 66 | */ |
universe@36 | 67 | #define asc_text_data(node) ((AscText*)node) |
universe@11 | 68 | |
universe@11 | 69 | /** |
universe@19 | 70 | * Releases all the memory of this node. |
universe@19 | 71 | * |
universe@19 | 72 | * @param node the text node |
universe@19 | 73 | */ |
universe@25 | 74 | void asc_text_free(AscText *node); |
universe@16 | 75 | |
universe@48 | 76 | #endif //ASCENSION_UI_TEXT_H |