intermediate

This commit is contained in:
Vicente Ferrari Smith 2025-07-15 07:29:37 +02:00
parent ad439a5509
commit 68096796dc
17 changed files with 171 additions and 88 deletions

View File

@ -6,7 +6,7 @@
NAME :: "mexplore"; NAME :: "mexplore";
VERSION :: "0.1"; VERSION :: "0.1";
JAI_VERSION :: "beta 0.2.014, built on 24 May 2025"; JAI_VERSION :: "beta 0.2.014, built on 24 May 2025";
RELEASE_DATE :: "10 July 2025, 18:49:46"; RELEASE_DATE :: "13 July 2025, 19:51:19";
GIT_BRANCH :: "main"; GIT_BRANCH :: "main";
GIT_REVISION :: "af1f9cfbeb018704986b1d45d62c802538a29ef2"; GIT_REVISION :: "ad439a550931e9088715ccfbe161757bcead4a9a";
DEBUG :: true; DEBUG :: true;

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -32,6 +32,8 @@ SDL_WINDOW_NOT_FOCUSABLE :: 0x0000000080000000; /**< window should not
#if OS == .WINDOWS { #if OS == .WINDOWS {
#load "windows.jai"; #load "windows.jai";
#import "Windows";
} else #if OS == .MACOS { } else #if OS == .MACOS {
#load "macos.jai"; #load "macos.jai";

View File

@ -33563,7 +33563,7 @@ SDL_GetStorageSpaceRemaining :: (storage: *SDL_Storage) -> Uint64 #foreign sdl3;
SDL_GlobStorageDirectory :: (storage: *SDL_Storage, path: *u8, pattern: *u8, flags: SDL_GlobFlags, count: *s32) -> **u8 #foreign sdl3; SDL_GlobStorageDirectory :: (storage: *SDL_Storage, path: *u8, pattern: *u8, flags: SDL_GlobFlags, count: *s32) -> **u8 #foreign sdl3;
tagMSG :: struct {} tagMSG :: struct {}
MSG :: tagMSG; //MSG :: tagMSG;
/** /**
* A callback to be used with SDL_SetWindowsMessageHook. * A callback to be used with SDL_SetWindowsMessageHook.

View File

@ -6,10 +6,12 @@
#import "File"; #import "File";
#import "String"; #import "String";
#import "stb_image"; #import "stb_image";
#import "stb_rect_pack"; #import "Windows_Utf8";
#import "Windows";
using SDL3 :: #import "SDL3"; using SDL3 :: #import "SDL3";
#import "kb_text_shape"; #import "kb_text_shape";
#import "stb_rect_pack";
#load "text.jai"; #load "text.jai";
#load "ui.jai"; #load "ui.jai";
@ -41,6 +43,9 @@ icon_font_big : Font;
main :: () { main :: () {
log("Hello, Sailor!"); log("Hello, Sailor!");
#if OS == .WINDOWS
SetConsoleOutputCP(65001); // CP_UTF8
SDL_Init(SDL_INIT_VIDEO); SDL_Init(SDL_INIT_VIDEO);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3); SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3);
@ -60,28 +65,65 @@ main :: () {
SDL_StartTextInput(window); SDL_StartTextInput(window);
while (running) { while (running) {
input_state.last_char = 0;
event : SDL_Event; event : SDL_Event;
while SDL_PollEvent(*event) { while SDL_PollEvent(*event) {
transition : InputTransition;
if event.type == { if event.type == {
case SDL_EVENT_QUIT; case SDL_EVENT_QUIT;
running = false; running = false;
case SDL_EVENT_KEY_DOWN;
if event.key.key == SDLK_ESCAPE
running = false;
case SDL_EVENT_MOUSE_MOTION;
transition.motion_delta = .{event.motion.xrel, event.motion.yrel};
case SDL_EVENT_MOUSE_WHEEL;
transition.mouse_wheel = xx event.wheel.y;
case SDL_EVENT_MOUSE_BUTTON_DOWN;
if event.button.button == SDL_BUTTON_LEFT {
transition.left_down = true;
input_state.left_mouse = true;
}
if event.button.button == SDL_BUTTON_RIGHT {
transition.right_down = true;
input_state.right_mouse = true;
}
case SDL_EVENT_MOUSE_BUTTON_UP;
if event.button.button == SDL_BUTTON_LEFT {
transition.left_up = true;
input_state.left_mouse = false;
}
if event.button.button == SDL_BUTTON_RIGHT {
transition.right_up = true;
input_state.right_mouse = false;
}
case SDL_EVENT_TEXT_INPUT; case SDL_EVENT_TEXT_INPUT;
//input_state.last_char = xx it.utf32; //input_state.last_char = xx it.utf32;
text : string = to_string(event.text.text); text : string = to_string(event.text.text);
text_utf32 : [..]u32; log("%", text);
defer array_free(text_utf32);
StringAt : u64; StringAt : u64;
while StringAt < xx text.count { while StringAt < xx text.count {
Decode : kbts_decode = kbts_DecodeUtf8(text.data + StringAt, xx text.count - StringAt); Decode : kbts_decode = kbts_DecodeUtf8(text.data + StringAt, xx text.count - StringAt);
StringAt += Decode.SourceCharactersConsumed; StringAt += Decode.SourceCharactersConsumed;
if Decode.Valid { if Decode.Valid {
array_add(*text_utf32, Decode.Codepoint); input_state.last_char = xx Decode.Codepoint;
} }
} }
} }
array_add(*input_transitions, transition);
} }
glClearColor(0.5, 0.1, 0.5, 0.0); glClearColor(0.5, 0.1, 0.5, 0.0);
@ -96,7 +138,7 @@ main :: () {
ui_context.sizing_y = .GROW; ui_context.sizing_y = .GROW;
ui_context.colours.normal = Vector4.{0.13, 0.16, 0.22, 1}; ui_context.colours.normal = Vector4.{0.13, 0.16, 0.22, 1};
ui_context.colours.hover = Vector4.{0.13, 0.16, 0.22, 1}; ui_context.colours.hover = Vector4.{0.23, 0.26, 0.32, 1};
ui_context.colours.active = Vector4.{0.13, 0.16, 0.22, 1}; ui_context.colours.active = Vector4.{0.13, 0.16, 0.22, 1};
ui_context.colours.background = Vector4.{0.07, 0.09, 0.16, 1}; ui_context.colours.background = Vector4.{0.07, 0.09, 0.16, 1};
@ -106,9 +148,12 @@ main :: () {
{ {
ui_context.layout = .LTR; ui_context.layout = .LTR;
ui_context.colours.background = .{0.07, 0.09, 0.16, 1}; ui_context.colours.background = .{0.07, 0.09, 0.16, 1};
ui_context.colours.background = .{0.11, 0.25, 0.26, 1};
ui_context.sizing_x = .FIT; ui_context.sizing_x = .FIT;
ui_context.sizing_y = .FIT; ui_context.sizing_y = .FIT;
ui_label("Hello, World"); //ui_label("Hello, World! How's it going?");
ui_label("Hello, World!");
ui_text_input("Name");
// ui_begin_container("Picture-Name-Settings"); // ui_begin_container("Picture-Name-Settings");
// { // {
// ui_icon("Icon", *dog, v2(128)); // ui_icon("Icon", *dog, v2(128));

View File

@ -13,7 +13,7 @@ InputState :: struct {
left_mouse : bool; left_mouse : bool;
right_mouse : bool; right_mouse : bool;
last_char : u8; last_char : s32;
} }
input_state : InputState; input_state : InputState;

View File

@ -306,16 +306,16 @@ STB_TEXTEDIT_INSERTCHARS :: (obj: *STB_TEXTEDIT_STRING, i: s32, c: *STB_TEXTEDIT
len := obj.text.count; len := obj.text.count;
if n + len > obj.text.allocated { if n + len > obj.text.allocated {
array_reserve(*obj.text, n + len); array_resize(*obj.text, n + len);
} }
// Shift the tail of the string right by n characters // Shift the tail of the string right by n characters
memcpy(obj.text.data + i + n, obj.text.data + i, obj.text.count - i); if i != len
memcpy(obj.text.data + ((i + n) * size_of(STB_TEXTEDIT_CHARTYPE)), obj.text.data + (i * size_of(STB_TEXTEDIT_CHARTYPE)), (len - i) * size_of(STB_TEXTEDIT_CHARTYPE));
memcpy(obj.text.data + i, xx c, n); //memcpy(obj.text.data + (i * size_of(STB_TEXTEDIT_CHARTYPE)), c, n * size_of(STB_TEXTEDIT_CHARTYPE));
memcpy(obj.text.data + (i), c, n * size_of(STB_TEXTEDIT_CHARTYPE));
obj.text.count += n;
return true; return true;
} }
@ -339,8 +339,8 @@ STB_TEXTEDIT_LAYOUTROW :: (row: *StbTexteditRow, obj: *STB_TEXTEDIT_STRING, n: s
//size, max_descent, read := SegmentText(obj.font, text_utf32.data, xx text_utf32.count); //size, max_descent, read := SegmentText(obj.font, text_utf32.data, xx text_utf32.count);
idx : s32; idx : s32;
while row.x1 < obj.max_size.x { while idx < obj.text.count && row.x1 < obj.max_size.x {
size, max_descent, read := next_word_size(obj.font, string.{obj.text.count, obj.text.data}, n + idx, obj.max_size.x); size, max_descent, read := next_word_size(obj.font, .{obj.text.count, obj.text.data}, n + idx, obj.max_size.x);
if row.x1 + size.x > obj.max_size.x { if row.x1 + size.x > obj.max_size.x {
break; break;

View File

@ -213,7 +213,7 @@ init_font :: (using font: *Font, filename: string, size: s32) {
} }
} }
render_text :: (font: *Font, text: string, pos: Vector2, size: Vector2, window_space: bool = true, colour: Vector4 = .{1.0, 1.0, 1.0, 1.0}, render_text :: (font: *Font, text: []u32, pos: Vector2, size: Vector2, window_space: bool = true, colour: Vector4 = .{1.0, 1.0, 1.0, 1.0},
background: Vector4 = .{0.0, 0.0, 0.0, 0.0}, nice_background := false, count_descent: bool = false) { background: Vector4 = .{0.0, 0.0, 0.0, 0.0}, nice_background := false, count_descent: bool = false) {
if !text if !text
@ -235,27 +235,15 @@ render_text :: (font: *Font, text: string, pos: Vector2, size: Vector2, window_s
render_pos := pos; render_pos := pos;
text_utf32 : [..]u32;
defer array_free(text_utf32);
StringAt : u64;
while StringAt < xx text.count {
Decode : kbts_decode = kbts_DecodeUtf8(text.data + StringAt, xx text.count - StringAt);
StringAt += Decode.SourceCharactersConsumed;
if Decode.Valid {
array_add(*text_utf32, Decode.Codepoint);
}
}
Cursor : kbts_cursor; Cursor : kbts_cursor;
Direction : kbts_direction = .KBTS_DIRECTION_NONE; Direction : kbts_direction = .KBTS_DIRECTION_NONE;
Script : kbts_script = .KBTS_SCRIPT_DONT_KNOW; Script : kbts_script = .KBTS_SCRIPT_DONT_KNOW;
Glyphs : *kbts_glyph = cast(*kbts_glyph, alloc(size_of(kbts_glyph) * text_utf32.count)); Glyphs : *kbts_glyph = cast(*kbts_glyph, alloc(size_of(kbts_glyph) * text.count));
CodepointIndex : s32; CodepointIndex : s32;
while CodepointIndex < xx text.count { while CodepointIndex < xx text.count {
Glyphs[CodepointIndex] = kbts_CodepointToGlyph(*font.kb, text_utf32.data[CodepointIndex]); Glyphs[CodepointIndex] = kbts_CodepointToGlyph(*font.kb, text.data[CodepointIndex]);
CodepointIndex += 1; CodepointIndex += 1;
} }
@ -263,7 +251,7 @@ render_text :: (font: *Font, text: string, pos: Vector2, size: Vector2, window_s
State : *kbts_shape_state = kbts_CreateShapeState(*font.kb); State : *kbts_shape_state = kbts_CreateShapeState(*font.kb);
Config : kbts_shape_config = kbts_ShapeConfig(*font.kb, Script, .DONT_KNOW); Config : kbts_shape_config = kbts_ShapeConfig(*font.kb, Script, .DONT_KNOW);
GlyphCount : u32 = xx text_utf32.count; GlyphCount : u32 = xx text.count;
GlyphCapacity : u32 = GlyphCount; GlyphCapacity : u32 = GlyphCount;
while kbts_Shape(State, *Config, Direction, Direction, Glyphs, *GlyphCount, GlyphCapacity) { while kbts_Shape(State, *Config, Direction, Direction, Glyphs, *GlyphCount, GlyphCapacity) {
Glyphs = cast(*kbts_glyph, realloc(Glyphs, size_of(kbts_glyph) * State.RequiredGlyphCapacity, size_of(kbts_glyph) * GlyphCapacity)); Glyphs = cast(*kbts_glyph, realloc(Glyphs, size_of(kbts_glyph) * State.RequiredGlyphCapacity, size_of(kbts_glyph) * GlyphCapacity));
@ -282,8 +270,8 @@ render_text :: (font: *Font, text: string, pos: Vector2, size: Vector2, window_s
// x_advance : hb_position_t = glyph_pos[i].x_advance; // x_advance : hb_position_t = glyph_pos[i].x_advance;
// y_advance : hb_position_t = glyph_pos[i].y_advance; // y_advance : hb_position_t = glyph_pos[i].y_advance;
x_offset : float = xx FT_MulFix(Cursor.X, font.face.size.metrics.x_scale) >> 6; x_offset : float = xx FT_MulFix(X, font.face.size.metrics.x_scale) >> 6;
y_offset : float = xx FT_MulFix(Cursor.Y, font.face.size.metrics.y_scale) >> 6; y_offset : float = xx FT_MulFix(Y, font.face.size.metrics.y_scale) >> 6;
glyph : *Glyph = table_find_pointer(*font.glyphs, kglyph.Id); glyph : *Glyph = table_find_pointer(*font.glyphs, kglyph.Id);
@ -487,7 +475,7 @@ ShapeText :: (font: *Font, Cursor: *kbts_cursor, Codepoints: *u32, CodepointCoun
glyph : *Glyph = table_find_pointer(*font.glyphs, kglyph.Id); glyph : *Glyph = table_find_pointer(*font.glyphs, kglyph.Id);
if glyph { if glyph {
size.y = max(size.y, xx glyph.height); size.y = max(size.y, xx glyph.height);
size.x += xx FT_MulFix(Cursor.X, font.face.size.metrics.x_scale) >> 6; size.x += xx FT_MulFix(Cursor.X - X, font.face.size.metrics.x_scale) >> 6;
max_descent = max(max_descent, xx glyph.descent); max_descent = max(max_descent, xx glyph.descent);
//line.max_descent = max(line.max_descent, cast(float) glyph.descent); //line.max_descent = max(line.max_descent, cast(float) glyph.descent);
//line.max_ascent = max(line.max_ascent, cast(float) glyph.ascent); //line.max_ascent = max(line.max_ascent, cast(float) glyph.ascent);
@ -645,25 +633,25 @@ SegmentText :: (font: *Font, Codepoints: *u32, CodepointCount: u64) -> Vector2,
// return 0; // return 0;
// } // }
next_word_size :: (font: *Font, text: string, n: s32, max_width: float = 0.0) -> Vector2, float, s32 { next_word_size :: (font: *Font, text: []u32, n: s32, max_width: float = 0.0) -> Vector2, float, s32 {
textp : *u8 = text.data; textp : *u32 = text.data;
line_start : *u8 = textp + n; line_start : *u32 = textp + n;
len := text.count - (line_start - textp); len : u64 = xx (text.count - (line_start - textp));
text_utf32 : [..]u32; // text_utf32 : [..]u32;
defer array_free(text_utf32); // defer array_free(text_utf32);
StringAt : u64; // StringAt : u64;
while StringAt < xx len { // while StringAt < xx len {
Decode : kbts_decode = kbts_DecodeUtf8(line_start + StringAt, xx len - StringAt); // Decode : kbts_decode = kbts_DecodeUtf8(line_start + StringAt, xx len - StringAt);
StringAt += Decode.SourceCharactersConsumed; // StringAt += Decode.SourceCharactersConsumed;
if Decode.Valid { // if Decode.Valid {
array_add(*text_utf32, Decode.Codepoint); // array_add(*text_utf32, Decode.Codepoint);
} // }
} // }
size, max_descent, read := SegmentText(font, text_utf32.data, xx text_utf32.count); size, max_descent, read := SegmentText(font, line_start, len);
return size, max_descent, read; return size, max_descent, read;
@ -677,7 +665,7 @@ next_word_size :: (font: *Font, text: string, n: s32, max_width: float = 0.0) ->
// } // }
// } // }
total_size : Vector2; //total_size : Vector2;
// lines : [..]Line; // lines : [..]Line;
// if !text { // if !text {
@ -820,7 +808,7 @@ next_word_size :: (font: *Font, text: string, n: s32, max_width: float = 0.0) ->
// } // }
return total_size, 0, 0; //return total_size, 0, 0;
} }
make_texture_from_data :: (data: *u8, width: s32, height: s32) -> Texture { make_texture_from_data :: (data: *u8, width: s32, height: s32) -> Texture {

View File

@ -158,6 +158,7 @@ Label :: struct {
font_colour : Vector4; font_colour : Vector4;
text : string; text : string;
text_size : Vector2; text_size : Vector2;
max_descent : float;
//lines : [..]Line; //lines : [..]Line;
} }
@ -198,8 +199,9 @@ TextInput :: struct {
frame : *Texture; frame : *Texture;
font : *Font; font : *Font;
font_colour : Vector4; font_colour : Vector4;
text : [..]u8; text : [..]u32;
max_width : float; max_width : float;
max_descent : float;
textedit_state : STB_TexteditState; textedit_state : STB_TexteditState;
} }
@ -410,10 +412,23 @@ ui_label :: (s: string = "", colour := Vector4.{1.0, 1.0, 1.0, 1.0}) {
} }
ui_size_label :: (label: *Label, max_width: float) { ui_size_label :: (label: *Label, max_width: float) {
text_utf32 : [..]u32;
defer array_free(text_utf32);
StringAt : u64;
while StringAt < xx label.text.count {
Decode : kbts_decode = kbts_DecodeUtf8(label.text.data + StringAt, xx label.text.count - StringAt);
StringAt += Decode.SourceCharactersConsumed;
if Decode.Valid {
array_add(*text_utf32, Decode.Codepoint);
}
}
label_size : Vector2; label_size : Vector2;
max_descent : float;
idx : s32; idx : s32;
while idx < label.text.count { while idx < label.text.count {
word_size, word_ascent, read := next_word_size(label.font, label.text, idx, max_width); word_size, word_descent, read := next_word_size(label.font, text_utf32, idx, max_width);
if max_width > 0.0 && label_size.x + word_size.x > max_width { if max_width > 0.0 && label_size.x + word_size.x > max_width {
break; break;
@ -421,14 +436,16 @@ ui_size_label :: (label: *Label, max_width: float) {
label_size.x += word_size.x; label_size.x += word_size.x;
label_size.y = max(label_size.y, word_size.y); label_size.y = max(label_size.y, word_size.y);
max_descent = max(max_descent, word_descent);
idx += read; idx += read;
} }
//label_size := Vector2.{xx Simp.prepare_text(label.font, label.text), xx label.font.character_height}; //label_size := Vector2.{xx Simp.prepare_text(label.font, label.text), xx label.font.character_height};
label.min_size = v2(2 * label.margin + 2 * label.padding) + label_size; label.min_size = v2(2 * label.margin + 2 * label.padding) + Vector2.{label_size.x, label_size.y + max_descent};
label.size = label.min_size; label.size = label.min_size;
label.max_size = label.size; label.max_size = label.size;
label.max_descent = max_descent;
//label.lines = lines; //label.lines = lines;
label.text_size = label_size; label.text_size = label_size;
} }
@ -458,18 +475,32 @@ ui_draw_label :: (using label: *Label) {
// restore_opengl_state(*opengl_state); // restore_opengl_state(*opengl_state);
//n : s32 = xx label.text.count; //n : s32 = xx label.text.count;
line_height := font.face.size.metrics.height >> 6;
midline : Vector2 = pos + Vector2.{cast(float, margin + padding), xx (size.y / 2.0)}; midline : Vector2 = pos + Vector2.{cast(float, margin + padding), cast(float, margin + padding) + max_descent};
//0.0/*xx -(font.face.size.metrics.height >> 6 / 2.0)*/};
text_utf32 : [..]u32;
defer array_free(text_utf32);
StringAt : u64;
while StringAt < xx text.count {
Decode : kbts_decode = kbts_DecodeUtf8(text.data + StringAt, xx text.count - StringAt);
StringAt += Decode.SourceCharactersConsumed;
if Decode.Valid {
array_add(*text_utf32, Decode.Codepoint);
}
}
this_size : Vector2; this_size : Vector2;
idx : s32; idx : s32;
row_start : s32; row_start : s32;
row_end : s32; row_end : s32;
while idx < label.text.count { while idx < label.text.count {
word_size, word_max_descent, read := next_word_size(label.font, string.{label.text.count, label.text.data}, idx, label.max_size.x); word_size, word_max_descent, read := next_word_size(label.font, text_utf32, idx, label.max_size.x);
if this_size.x + word_size.x > label.max_size.x { if this_size.x + word_size.x > label.max_size.x {
render_text(font, .{row_end - row_start, label.text.data + row_start}, this_size, render_text(font, .{row_end - row_start, text_utf32.data + row_start}, this_size,
midline, colour = font_colour); midline, colour = font_colour);
row_start = row_end; row_start = row_end;
midline.y += label.font.face.size.metrics.height >> 6; midline.y += label.font.face.size.metrics.height >> 6;
@ -482,7 +513,7 @@ ui_draw_label :: (using label: *Label) {
} }
if row_start < row_end { if row_start < row_end {
render_text(font, .{row_end - row_start, label.text.data + row_start}, render_text(font, .{row_end - row_start, text_utf32.data + row_start},
midline, this_size, colour = font_colour); midline, this_size, colour = font_colour);
} }
@ -633,10 +664,21 @@ ui_button :: (s: string = "", icon_texture: *Texture = null, font_colour := Vect
button.min_size = v2(2 * button.margin + 2 * button.border_size + 2 * button.padding); button.min_size = v2(2 * button.margin + 2 * button.border_size + 2 * button.padding);
idx : s32; text_utf32 : [..]u32;
defer array_free(text_utf32);
StringAt : u64;
while StringAt < xx text.count {
Decode : kbts_decode = kbts_DecodeUtf8(text.data + StringAt, xx text.count - StringAt);
StringAt += Decode.SourceCharactersConsumed;
if Decode.Valid {
array_add(*text_utf32, Decode.Codepoint);
}
}
idx : s32;
while idx < text.count { while idx < text.count {
label_size, max_descent, read := next_word_size(button.font, button.text, idx, button.max_size.x); label_size, max_descent, read := next_word_size(button.font, text_utf32, idx, button.max_size.x);
idx += read; idx += read;
} }
@ -862,23 +904,29 @@ ui_text_input :: (s: string, font_colour := Vector4.{1, 1, 1, 1}) {
ui_append_to_parent(text_input); ui_append_to_parent(text_input);
if text_input.active && input_state.last_char > 0 {
stb_textedit_key(text_input, *text_input.textedit_state, input_state.last_char);
// log("Adding % to builder.", to_string(*input_state.last_char, 1));
// append(*text_input.input_buffer, input_state.last_char);
}
text_size : Vector2; text_size : Vector2;
text_size.y = xx text_input.font.face.size.metrics.height >> 6;
//str := builder_to_string(*text_input.input_buffer, 0, false); //str := builder_to_string(*text_input.input_buffer, 0, false);
// if str.count > 0 { // if str.count > 0 {
// defer free(str); // defer free(str);
// textsize = Vector2.{xx Simp.prepare_text(text_input.font, str), xx text_input.font.character_height}; // textsize = Vector2.{xx Simp.prepare_text(text_input.font, str), xx text_input.font.character_height};
// } // }
max_descent : float;
idx : s32;
while idx < text_input.text.count {
word_size, word_descent, read := next_word_size(text_input.font, text_input.text, idx, 0.0);
row : StbTexteditRow; text_size.x += word_size.x;
i : s32; text_size.y = max(text_size.y, word_size.y);
max_descent = max(max_descent, word_descent);
while i < text_input.text.count { idx += read;
STB_TEXTEDIT_LAYOUTROW(*row, text_input, i);
text_size.x += row.x1;
text_size.y = max(text_size.y, row.baseline_y_delta);
i += row.num_chars;
} }
text_input.min_size = v2(2 * text_input.margin + 2 * text_input.border_size + 2 * text_input.padding) + text_size; text_input.min_size = v2(2 * text_input.margin + 2 * text_input.border_size + 2 * text_input.padding) + text_size;
@ -909,12 +957,6 @@ ui_text_input :: (s: string, font_colour := Vector4.{1, 1, 1, 1}) {
} else { } else {
text_input.hot = false; text_input.hot = false;
} }
if text_input.active && input_state.last_char > 0 {
stb_textedit_key(text_input, *text_input.textedit_state, input_state.last_char);
// log("Adding % to builder.", to_string(*input_state.last_char, 1));
// append(*text_input.input_buffer, input_state.last_char);
}
} }
ui_draw_text_input :: (using text_input: *TextInput) { ui_draw_text_input :: (using text_input: *TextInput) {
@ -1277,7 +1319,7 @@ ui_content_size :: (rect: *Rect) -> Vector2 {
while next { while next {
if next.type != .SCROLLBAR { if next.type != .SCROLLBAR {
size_to_add := ifx next.type == .LABEL then next.last_frame_size else next.size; size_to_add := /*ifx next.type == .LABEL then next.last_frame_size else */next.size;
if rect.layout == { if rect.layout == {
case .TTB; case .TTB;
size.x = max(size.x, /*rect.min_size.x + */ size_to_add.x); size.x = max(size.x, /*rect.min_size.x + */ size_to_add.x);
@ -1314,7 +1356,7 @@ ui_grow_roots :: () {
bottom_left = it; bottom_left = it;
} }
if bottom_left && top_left { if bottom_left {
bottom_left.max_size = bottom_left.size; bottom_left.max_size = bottom_left.size;
top_left.max_size = Vector2.{xx window_width, xx window_height - bottom_left.max_size.y}; top_left.max_size = Vector2.{xx window_width, xx window_height - bottom_left.max_size.y};
@ -1322,12 +1364,15 @@ ui_grow_roots :: () {
if bottom_left.sizing_x == .GROW { if bottom_left.sizing_x == .GROW {
bottom_left.size.x = xx window_width; bottom_left.size.x = xx window_width;
} }
}
if top_left.sizing_y == .GROW { if top_left {
if bottom_left.sizing_y != .GROW {
//top_left.size.y = window_height - bottom_left.size.y; // if top_left.sizing_y == .GROW {
} // if bottom_left.sizing_y != .GROW {
} // //top_left.size.y = window_height - bottom_left.size.y;
// }
// }
if top_left.sizing_x == .GROW { if top_left.sizing_x == .GROW {
top_left.size.x = xx window_width; top_left.size.x = xx window_width;

11
ui.rad
View File

@ -1,12 +1,14 @@
// raddbg 0.9.20 project file // raddbg 0.9.20 project file
recent_file: path: "src/text.jai"
recent_file: path: "src/ui.jai"
recent_file: path: "src/main.jai" recent_file: path: "src/main.jai"
recent_file: path: "src/ui.jai"
recent_file: path: "../../../../jai/modules/math/module.jai"
recent_file: path: "../../../../jai/modules/basic/array.jai" recent_file: path: "../../../../jai/modules/basic/array.jai"
recent_file: path: "src/stb_textedit.jai"
recent_file: path: "src/text.jai"
recent_file: path: "modules/kb_text_shape/kb_text_shape.h"
recent_file: path: "../../../../jai/modules/basic/module.jai" recent_file: path: "../../../../jai/modules/basic/module.jai"
recent_file: path: "../../../../jai/modules/default_allocator/module.jai" recent_file: path: "../../../../jai/modules/default_allocator/module.jai"
recent_file: path: "modules/kb_text_shape/kb_text_shape.h"
recent_file: path: "../../../../jai/modules/runtime_support.jai" recent_file: path: "../../../../jai/modules/runtime_support.jai"
target: target:
{ {
@ -16,6 +18,7 @@ target:
} }
breakpoint: breakpoint:
{ {
source_location: "src/main.jai:72:1" source_location: "src/stb_textedit.jai:990:1"
hit_count: 0 hit_count: 0
enabled: 0
} }