intermediate
This commit is contained in:
parent
e4df2e1551
commit
4744f67e2e
@ -6,7 +6,7 @@
|
|||||||
NAME :: "mexplore";
|
NAME :: "mexplore";
|
||||||
VERSION :: "0.1";
|
VERSION :: "0.1";
|
||||||
JAI_VERSION :: "beta 0.2.016, built on 19 July 2025";
|
JAI_VERSION :: "beta 0.2.016, built on 19 July 2025";
|
||||||
RELEASE_DATE :: "26 July 2025, 17:47:40";
|
RELEASE_DATE :: "3 August 2025, 09:51:04";
|
||||||
GIT_BRANCH :: "main";
|
GIT_BRANCH :: "main";
|
||||||
GIT_REVISION :: "89727b9bc176c098f703cbc731593120989767ed";
|
GIT_REVISION :: "e4df2e155175ce56f09148738c333da44455ce7a";
|
||||||
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.
@ -75,9 +75,6 @@ main :: () {
|
|||||||
new_counter : u64 = SDL_GetPerformanceCounter();
|
new_counter : u64 = SDL_GetPerformanceCounter();
|
||||||
dt = cast(float, new_counter - last_counter) / cast(float, counter_frequency);
|
dt = cast(float, new_counter - last_counter) / cast(float, counter_frequency);
|
||||||
last_counter = new_counter;
|
last_counter = new_counter;
|
||||||
log("%", dt);
|
|
||||||
|
|
||||||
input_state.last_char = 0;
|
|
||||||
|
|
||||||
event : SDL_Event;
|
event : SDL_Event;
|
||||||
|
|
||||||
@ -89,13 +86,13 @@ main :: () {
|
|||||||
running = false;
|
running = false;
|
||||||
|
|
||||||
case SDL_EVENT_KEY_DOWN;
|
case SDL_EVENT_KEY_DOWN;
|
||||||
|
log("%", event.key);
|
||||||
if event.key.key == {
|
if event.key.key == {
|
||||||
case SDLK_ESCAPE;
|
case SDLK_ESCAPE;
|
||||||
running = false;
|
running = false;
|
||||||
|
|
||||||
case SDLK_RETURN;
|
case SDLK_RETURN;
|
||||||
log("pressing enter");
|
transition.char = STB_TEXTEDIT_NEWLINE;
|
||||||
input_state.last_char = STB_TEXTEDIT_NEWLINE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
case SDL_EVENT_MOUSE_MOTION;
|
case SDL_EVENT_MOUSE_MOTION;
|
||||||
@ -136,7 +133,7 @@ main :: () {
|
|||||||
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 {
|
||||||
input_state.last_char = xx Decode.Codepoint;
|
transition.char = xx Decode.Codepoint;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -7,13 +7,19 @@ InputTransition :: struct {
|
|||||||
|
|
||||||
mouse_wheel : s64;
|
mouse_wheel : s64;
|
||||||
motion_delta : Vector2;
|
motion_delta : Vector2;
|
||||||
|
|
||||||
|
control_down : bool;
|
||||||
|
control_up : bool;
|
||||||
|
|
||||||
|
shift_down : bool;
|
||||||
|
shift_up : bool;
|
||||||
|
|
||||||
|
char : s32;
|
||||||
}
|
}
|
||||||
|
|
||||||
InputState :: struct {
|
InputState :: struct {
|
||||||
left_mouse : bool;
|
left_mouse : bool;
|
||||||
right_mouse : bool;
|
right_mouse : bool;
|
||||||
|
|
||||||
last_char : s32;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
input_state : InputState;
|
input_state : InputState;
|
||||||
|
|||||||
@ -308,8 +308,6 @@ render_text :: (font: *Font, text: []u32, pos: Vector2, size: Vector2, window_sp
|
|||||||
// t1 := t0 + .{cast(float, glyph.width / ATLAS_SIZE), cast(float, glyph.height / ATLAS_SIZE)};
|
// t1 := t0 + .{cast(float, glyph.width / ATLAS_SIZE), cast(float, glyph.height / ATLAS_SIZE)};
|
||||||
// }
|
// }
|
||||||
|
|
||||||
log("adding vertex %, %, with size %", v0, v1, v1 - v0);
|
|
||||||
|
|
||||||
array_add(*vertices, .{v0, t0, colour});
|
array_add(*vertices, .{v0, t0, colour});
|
||||||
array_add(*vertices, .{.{v0.x, v1.y}, .{t0.x, t1.y}, colour});
|
array_add(*vertices, .{.{v0.x, v1.y}, .{t0.x, t1.y}, colour});
|
||||||
array_add(*vertices, .{.{v1.x, v0.y}, .{t1.x, t0.y}, colour});
|
array_add(*vertices, .{.{v1.x, v0.y}, .{t1.x, t0.y}, colour});
|
||||||
|
|||||||
30
src/ui.jai
30
src/ui.jai
@ -905,15 +905,6 @@ ui_text_input :: (s: string, font_colour := Vector4.{1, 1, 1, 1}) {
|
|||||||
|
|
||||||
ui_append_to_parent(text_input);
|
ui_append_to_parent(text_input);
|
||||||
|
|
||||||
log("%", text_input.textedit_state.cursor);
|
|
||||||
|
|
||||||
if text_input.active && input_state.last_char > 0 {
|
|
||||||
stb_textedit_key(text_input, *text_input.textedit_state, input_state.last_char);
|
|
||||||
log("adding char %", 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;
|
//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);
|
||||||
@ -964,7 +955,6 @@ ui_text_input :: (s: string, font_colour := Vector4.{1, 1, 1, 1}) {
|
|||||||
|
|
||||||
if action.left_pressed {
|
if action.left_pressed {
|
||||||
text_input.active = true;
|
text_input.active = true;
|
||||||
log("Text input active");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
text_input.interacted = true;
|
text_input.interacted = true;
|
||||||
@ -1041,7 +1031,6 @@ ui_draw_text_input :: (using text_input: *TextInput) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if cursor_time < 0.5 {
|
if cursor_time < 0.5 {
|
||||||
log("rendering cursor at %", cursor_pos);
|
|
||||||
render_filled_rectangle(cursor_pos + v2(margin) + v2(border_size) + v2(padding), .{5.0, xx font.face.size.metrics.height >> 6});
|
render_filled_rectangle(cursor_pos + v2(margin) + v2(border_size) + v2(padding), .{5.0, xx font.face.size.metrics.height >> 6});
|
||||||
} else if cursor_time > 1.0 {
|
} else if cursor_time > 1.0 {
|
||||||
cursor_time = 0.0;
|
cursor_time = 0.0;
|
||||||
@ -1268,11 +1257,6 @@ ui_action :: (rect: *Rect) -> UIAction {
|
|||||||
x, y : float;
|
x, y : float;
|
||||||
SDL_GetMouseState(*x, *y);
|
SDL_GetMouseState(*x, *y);
|
||||||
|
|
||||||
if rect.key == "Strain-Today-Strain-HR&Strain-Scroll-Dashboard" {
|
|
||||||
if input_transitions.count > 0
|
|
||||||
print("%\n", input_transitions);
|
|
||||||
}
|
|
||||||
|
|
||||||
mouse := Vector2.{xx x, xx (window_height - y)};
|
mouse := Vector2.{xx x, xx (window_height - y)};
|
||||||
|
|
||||||
isinrect := is_in_rect(rect, mouse);
|
isinrect := is_in_rect(rect, mouse);
|
||||||
@ -1336,16 +1320,24 @@ ui_action :: (rect: *Rect) -> UIAction {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for transition : input_transitions {
|
for transition : input_transitions {
|
||||||
if rect.type == .SCROLLBAR {
|
if rect.type == {
|
||||||
|
case .SCROLLBAR;
|
||||||
if abs(transition.motion_delta.y) > 0 {
|
if abs(transition.motion_delta.y) > 0 {
|
||||||
action.scroll -= transition.motion_delta.y;
|
action.scroll -= transition.motion_delta.y;
|
||||||
|
|
||||||
should_consume = true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for transition : input_transitions {
|
||||||
|
if rect.type == {
|
||||||
|
case .TEXTINPUT;
|
||||||
|
text_input := cast(*TextInput, rect);
|
||||||
|
if text_input.active && transition.char > 0 {
|
||||||
|
stb_textedit_key(text_input, *text_input.textedit_state, transition.char);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if should_consume
|
if should_consume
|
||||||
array_reset(*input_transitions);
|
array_reset(*input_transitions);
|
||||||
|
|||||||
20
ui.rad
20
ui.rad
@ -1,14 +1,14 @@
|
|||||||
// raddbg 0.9.20 project file
|
// raddbg 0.9.20 project file
|
||||||
|
|
||||||
recent_file: path: "src/text.jai"
|
recent_file: path: "src/main.jai"
|
||||||
recent_file: path: "src/ui.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: "src/text.jai"
|
||||||
recent_file: path: "src/stb_textedit.jai"
|
recent_file: path: "src/stb_textedit.jai"
|
||||||
recent_file: path: "modules/kb_text_shape/kb_text_shape.h"
|
recent_file: path: "modules/kb_text_shape/kb_text_shape.h"
|
||||||
recent_file: path: "modules/SDL3/src/SDL-release-3.2.16/src/events/sdl_keyboard.c"
|
recent_file: path: "modules/SDL3/src/SDL-release-3.2.16/src/events/sdl_keyboard.c"
|
||||||
recent_file: path: "modules/SDL3/src/SDL-release-3.2.16/src/video/windows/SDL_windowsevents.c"
|
recent_file: path: "modules/SDL3/src/SDL-release-3.2.16/src/video/windows/SDL_windowsevents.c"
|
||||||
recent_file: path: "src/main.jai"
|
|
||||||
recent_file: path: "../../../../jai/modules/basic/array.jai"
|
|
||||||
recent_file: path: "../../../../jai/modules/math/module.jai"
|
|
||||||
recent_file: path: "src/math/math.jai"
|
recent_file: path: "src/math/math.jai"
|
||||||
recent_file: path: "../../../../jai/modules/runtime_support.jai"
|
recent_file: path: "../../../../jai/modules/runtime_support.jai"
|
||||||
recent_file: path: "../../../../jai/modules/basic/module.jai"
|
recent_file: path: "../../../../jai/modules/basic/module.jai"
|
||||||
@ -19,15 +19,3 @@ target:
|
|||||||
working_directory: bin
|
working_directory: bin
|
||||||
enabled: 1
|
enabled: 1
|
||||||
}
|
}
|
||||||
breakpoint:
|
|
||||||
{
|
|
||||||
source_location: "src/ui.jai:1014:1"
|
|
||||||
hit_count: 0
|
|
||||||
enabled: 0
|
|
||||||
}
|
|
||||||
breakpoint:
|
|
||||||
{
|
|
||||||
source_location: "src/text.jai:281:1"
|
|
||||||
hit_count: 0
|
|
||||||
enabled: 0
|
|
||||||
}
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user