include/ui_text_layout.h is deleted. runtime/text_props.kry declares TextElementKind as a one-line #type enum and TextElement (which stores the script-generated IconType and Texture2D) and TextLayout (pointer spans) as one-line #type records; ParseTextLayout, ReflowTextLayout, GetTextLayoutHeight, and FreeTextLayout are "#extern #export" declarations. ui_internal.h, the layout host, kryon.h, and the paragraph layout test include the props header directly. Gates: generated-runtime-parity-test, fast-test, k2c/k2cpp/k2go-syntax-test, go-runtime-test, examples-syntax-test, kryon-boundary-check, and the refreshed public-API snapshot pass.
108 lines
4.6 KiB
C
108 lines
4.6 KiB
C
/* Generated by k2c from runtime/text_props.kry. */
|
|
#ifndef K_RUNTIME_TEXT_PROPS_H
|
|
#define K_RUNTIME_TEXT_PROPS_H
|
|
|
|
#include <stdint.h>
|
|
#include <stdbool.h>
|
|
#include "kry_bounds.h"
|
|
|
|
#ifndef KIR_STRING_VALUE_DEFINED
|
|
#define KIR_STRING_VALUE_DEFINED
|
|
#include <stddef.h>
|
|
#include <string.h>
|
|
/* Immutable borrowed UTF-8 bytes; length preserves embedded nulls. */
|
|
typedef struct String { const char *data; size_t length; } String;
|
|
static inline String StringView(const char *data, size_t length) {
|
|
String value = {data, length};
|
|
return value;
|
|
}
|
|
static inline bool StringEqual(String a, String b) {
|
|
return a.length == b.length && (a.length == 0 || memcmp(a.data, b.data, a.length) == 0);
|
|
}
|
|
#endif
|
|
#include "ui_control_props.generated.h"
|
|
#include "kryon_compat.generated.h"
|
|
#include "ui_icon_types.h"
|
|
#define Text8 8
|
|
#define Text12 12
|
|
#define Text14 14
|
|
#define Text16 16
|
|
#define Text18 18
|
|
#define Text20 20
|
|
#define Text24 24
|
|
#define Text32 32
|
|
#define Text48 48
|
|
#define TextBaseSize 16
|
|
|
|
typedef enum { TEXT_ELEMENT_TEXT = 0, TEXT_ELEMENT_ICON = 1, TEXT_ELEMENT_LINE_BREAK = 2 } TextElementKind;
|
|
|
|
typedef struct { TextElementKind type; const char *text; Texture2D icon; IconType icon_type; int icon_size; int text_width; } TextElement;
|
|
|
|
typedef struct TextLayout { TextElement *elements; int element_count; int *line_breaks; int line_count; int *line_widths; int total_height; int line_height; int last_reflow_width; } TextLayout;
|
|
|
|
typedef enum TextWrap {
|
|
TextWrapAuto = 0,
|
|
TextWrapNone = 1,
|
|
} TextWrap;
|
|
|
|
typedef enum TextAlign {
|
|
TextAlignStart = 0,
|
|
TextAlignCenter = 1,
|
|
TextAlignEnd = 2,
|
|
} TextAlign;
|
|
|
|
typedef struct TextProps {
|
|
Rectangle bounds;
|
|
const char* text;
|
|
int32_t font;
|
|
int32_t class_name;
|
|
TextWrap wrap;
|
|
TextAlign align;
|
|
TextAlign vertical_align;
|
|
bool disabled;
|
|
bool selectable;
|
|
bool strikethrough;
|
|
} TextProps;
|
|
TextLayout ParseTextLayout(const char* input, Texture2D icon, IconType icon_type, int32_t icon_size);
|
|
void ReflowTextLayout(TextLayout* layout, int32_t max_width, int32_t font_size, int32_t line_height);
|
|
int32_t GetTextLayoutHeight(TextLayout* layout);
|
|
void FreeTextLayout(TextLayout* layout);
|
|
Font GetTextFont(void);
|
|
int32_t EnsureDefaultFont(void);
|
|
int32_t RegisterTextFont(const char* name, Font font);
|
|
int32_t RegisterSmallTextFont(const char* name, Font font);
|
|
int32_t RegisterTextFontSource(const char* name, const char* file_type, const uint8_t* font_data, uint32_t font_size, const int32_t* codepoints, int32_t codepoint_count);
|
|
int32_t RegisterTextFontSourceForText(const char* name, const char* file_type, const uint8_t* font_data, uint32_t font_size, const char* text);
|
|
int32_t RegisterFixedTextFontSource(const char* name, const char* file_type, const uint8_t* font_data, uint32_t font_size, const int32_t* codepoints, int32_t codepoint_count);
|
|
int32_t RegisterTextFontFileSource(const char* name, const char* path, const int32_t* codepoints, int32_t codepoint_count);
|
|
int32_t RegisterTextFontFileSourceForText(const char* name, const char* path, const char* text);
|
|
int32_t UseTextFont(const char* name);
|
|
int32_t PushTextFont(const char* name);
|
|
void PopTextFont(int32_t token);
|
|
int32_t TextFontHasGlyph(Font font, int32_t codepoint);
|
|
Font LoadTextFontFromMemory(const char* file_type, const uint8_t* font_data, uint32_t font_size, int32_t base_size);
|
|
Font LoadTextFontAsset(const char* path, int32_t base_size);
|
|
void UnloadTextFont(Font* font);
|
|
void ClearTextFonts(void);
|
|
void TextFontMemoryReport(const char* tag);
|
|
int32_t MeasureTextWidth(const char* text, int32_t font_size, const char* typeface);
|
|
Font GetTextFontForCodepoint(int32_t codepoint, int32_t font_size);
|
|
Font GetTextFontForSize(int32_t font_size);
|
|
float GetTextFontScale(Font font, int32_t font_size);
|
|
int32_t RenderTextGlyph(uint32_t codepoint, int32_t x, int32_t y, int32_t font_size, Color color);
|
|
int32_t TextFontReady(Font font);
|
|
int32_t TextFontBaseSize(Font font);
|
|
int32_t TextFontGlyphPadding(Font font);
|
|
GlyphInfo TextFontGlyph(Font font, int32_t codepoint);
|
|
Rectangle TextFontAtlasRec(Font font, int32_t codepoint);
|
|
Texture2D TextFontAtlasTexture(Font font);
|
|
int32_t TextFontAdvance(Font font, int32_t codepoint);
|
|
int32_t TextFontHasGlyphValue(Font font, int32_t codepoint);
|
|
int32_t TextFontGlyphCount(Font font);
|
|
int32_t TextFontHasNativeText(Font font);
|
|
int32_t TextFontNativeTextWidth(Font font, const char* text, int32_t byte_len);
|
|
int32_t TextFontNativeTextHeight(Font font);
|
|
int32_t TextFontDrawNativeText(Font font, const char* text, int32_t byte_len, int32_t x, int32_t y, int32_t font_size, Color color);
|
|
|
|
#endif /* K_RUNTIME_TEXT_PROPS_H */
|