diff --git a/code/font/VEFontCache/draw.odin b/code/font/VEFontCache/draw.odin index 5679bbf..581e995 100644 --- a/code/font/VEFontCache/draw.odin +++ b/code/font/VEFontCache/draw.odin @@ -490,7 +490,7 @@ draw_text_batch :: proc(ctx: ^Context, entry: ^Entry, shaped: ^ShapedText, slot_position, _ := atlas_bbox( atlas, region_kind, atlas_index ) glyph_scale := bounds_size * entry.size_scale + glyph_padding bounds_0_scaled := ceil( vbounds_0 * entry.size_scale ) - dst := glyph_translate + (bounds_0_scaled - glyph_padding) * scale + dst := glyph_translate + bounds_0_scaled * scale dst_scale := glyph_scale * scale textspace_x_form( & slot_position, & glyph_scale, atlas_size ) diff --git a/code/font/VEFontCache/shaped_text.odin b/code/font/VEFontCache/shaped_text.odin index 1ac55c2..69c527f 100644 --- a/code/font/VEFontCache/shaped_text.odin +++ b/code/font/VEFontCache/shaped_text.odin @@ -122,7 +122,7 @@ shape_text_uncached :: proc( ctx : ^Context, font : FontID, text_utf8 : string, position.y }) - position.x += f32(advance) * entry.size_scale + position.x += ceil(f32(advance) * entry.size_scale) prev_codepoint = codepoint } diff --git a/code/sectr/app/screen.odin b/code/sectr/app/screen.odin index c121311..3e56cfe 100644 --- a/code/sectr/app/screen.odin +++ b/code/sectr/app/screen.odin @@ -48,7 +48,7 @@ ui_screen_menu_bar :: proc( captures : rawptr = nil ) -> (should_raise : b32 = f { @static theme : UI_Theme @static loaded : b32 = false - if ! loaded + if ! loaded || true { app_color := app_color_theme() layout := UI_Layout { @@ -56,7 +56,7 @@ ui_screen_menu_bar :: proc( captures : rawptr = nil ) -> (should_raise : b32 = f anchor = range2({},{}), // alignment = UI_Align_Presets.text_centered, text_alignment = {0.0, 0}, - font_size = 12, + font_size = 10, margins = {0, 0, 0, 0}, padding = {0, 0, 0, 0}, border_width = 1.0, @@ -232,7 +232,7 @@ ui_screen_settings_menu :: proc( captures : rawptr = nil ) -> ( should_raise : b using input_box layout.flags = {.Fixed_Width} layout.margins.left = 5 - layout.padding.right = 10 + layout.padding.right = 5 layout.size.min.x = 80 style.corner_radii[0] = 0.35 @@ -273,11 +273,11 @@ ui_screen_settings_menu :: proc( captures : rawptr = nil ) -> ( should_raise : b scope(theme_text) value_txt = ui_text("settings_menu.engine_refresh.input_box.value", to_str_runes_pair(array_to_slice(value_str))) using value_txt - layout.alignment = {1, 0.0} - layout.text_alignment = {0, 0.5} - layout.anchor.left = 1.0 - layout.flags = {.Fixed_Width} - // layout.size.min = cast(Vec2) measure_text_size( value_txt.text.str, value_txt.style.font, value_txt.layout.font_size, 0 ) + layout.alignment = {0.0, 0.0} + layout.text_alignment = {1.0, 0.5} + layout.anchor.left = 0.0 + // layout.flags = {.Fixed_Width} + layout.size.min = cast(Vec2) measure_text_size( value_txt.text.str, value_txt.style.font, value_txt.layout.font_size, 0 ) } } } diff --git a/code/sectr/app/ui_theme.odin b/code/sectr/app/ui_theme.odin index 1a3e0f3..61bbbf2 100644 --- a/code/sectr/app/ui_theme.odin +++ b/code/sectr/app/ui_theme.odin @@ -22,7 +22,7 @@ theme_button :: proc() -> UI_Theme anchor = range2_zero, alignment = {0, 0}, text_alignment = {0.5, 0.5}, - font_size = 16, + font_size = 12, margins = {0, 0, 0, 0}, padding = {0, 0, 0, 0}, border_width = 1, @@ -113,7 +113,7 @@ theme_table_row :: proc( is_even : bool ) -> UI_Theme { @static theme : UI_Theme @static loaded : b32 = false - if ! loaded + if ! loaded || true { app_color := app_color_theme() table_bg : RGBA8 @@ -127,7 +127,7 @@ theme_table_row :: proc( is_even : bool ) -> UI_Theme flags = {}, anchor = range2({},{}), alignment = {0, 0}, - text_alignment = {0.0, 0.0}, + text_alignment = {0.5, 0.0}, font_size = 16, margins = {0, 0, 0, 0}, padding = {0, 0, 0, 0}, @@ -276,12 +276,12 @@ theme_window_bar_btn :: proc() -> UI_Theme anchor = range2({1, 0},{}), alignment = {0, 0}, text_alignment = {0.5, 0.5}, - font_size = 16, + font_size = 12, margins = {0, 0, 0, 0}, padding = {0, 0, 0, 0}, border_width = 1, pos = {0, 0}, - size = range2({50,0},{}) + size = range2({60,0},{}) } style := UI_Style { bg_color = app_color.btn_bg_default, diff --git a/code/sectr/engine/client_api.odin b/code/sectr/engine/client_api.odin index 83fbaa5..9b96362 100644 --- a/code/sectr/engine/client_api.odin +++ b/code/sectr/engine/client_api.odin @@ -332,10 +332,10 @@ startup :: proc( prof : ^SpallProfiler, persistent_mem, frame_mem, transient_mem ui_startup( & workspace.ui, cache_allocator = persistent_slab_allocator() ) } - // debug.path_lorem = str_fmt("C:/projects/SectrPrototype/examples/Lorem Ipsum (197).txt", allocator = persistent_slab_allocator()) + debug.path_lorem = str_fmt("C:/projects/SectrPrototype/examples/Lorem Ipsum (197).txt", allocator = persistent_slab_allocator()) // debug.path_lorem = str_fmt("C:/projects/SectrPrototype/examples/Lorem Ipsum (1022).txt", allocator = persistent_slab_allocator()) // debug.path_lorem = str_fmt("C:/projects/SectrPrototype/examples/sokol_gp.h", allocator = persistent_slab_allocator()) - debug.path_lorem = str_fmt("C:/projects/SectrPrototype/examples/ve_fontcache.h", allocator = persistent_slab_allocator()) + // debug.path_lorem = str_fmt("C:/projects/SectrPrototype/examples/ve_fontcache.h", allocator = persistent_slab_allocator()) alloc_error : AllocatorError; success : bool debug.lorem_content, success = os.read_entire_file( debug.path_lorem, persistent_slab_allocator() ) diff --git a/code/sectr/engine/update.odin b/code/sectr/engine/update.odin index 87e67ce..b5216e5 100644 --- a/code/sectr/engine/update.odin +++ b/code/sectr/engine/update.odin @@ -339,8 +339,8 @@ update :: proc( delta_time : f64 ) -> b32 // test_hover_n_click() // test_draggable() // test_text_box() - // test_parenting( & default_layout, & frame_style_default ) - test_whitespace_ast( & default_layout, & frame_style_default ) + test_parenting( & default_layout, & frame_style_default ) + // test_whitespace_ast( & default_layout, & frame_style_default ) } //endregion Workspace Imgui Tick diff --git a/code/sectr/grime/mappings.odin b/code/sectr/grime/mappings.odin index cc2ef71..28b2242 100644 --- a/code/sectr/grime/mappings.odin +++ b/code/sectr/grime/mappings.odin @@ -51,10 +51,12 @@ import fmt_io "core:fmt" str_tmp_from_any :: fmt_io.tprint import "core:math" - lerp :: math.lerp + lerp :: math.lerp import "core:math/bits" - u64_max :: bits.U64_MAX + u64_max :: bits.U64_MAX + +import "core:math/linalg" import "core:mem" align_forward_int :: mem.align_forward_int @@ -365,6 +367,20 @@ dot :: proc { // ws_view_draw_text_StrRunesPair, // } +floor :: proc { + math.floor_f16, + math.floor_f16le, + math.floor_f16be, + math.floor_f32, + math.floor_f32le, + math.floor_f32be, + math.floor_f64, + math.floor_f64le, + math.floor_f64be, + + linalg.floor +} + from_bytes :: proc { str_builder_from_bytes, } diff --git a/code/sectr/ui/core/layout_compute.odin b/code/sectr/ui/core/layout_compute.odin index 6715aeb..8a34474 100644 --- a/code/sectr/ui/core/layout_compute.odin +++ b/code/sectr/ui/core/layout_compute.odin @@ -167,6 +167,10 @@ ui_box_compute_layout :: proc( box : ^UI_Box, if len(box.text.str) > 0 { ascent, descent, line_gap := get_font_vertical_metrics(style.font, layout.font_size) + + offset := text_size + offset += { 0, -descent } + content_size := content_bounds.max - content_bounds.min text_pos : Vec2 text_pos = content_bounds.min diff --git a/scripts/build.ps1 b/scripts/build.ps1 index 71b3dbd..b845a53 100644 --- a/scripts/build.ps1 +++ b/scripts/build.ps1 @@ -204,10 +204,10 @@ push-location $path_root # $build_args += $flag_micro_architecture_native $build_args += $flag_use_separate_modules $build_args += $flag_thread_count + $CoreCount_Physical - # $build_args += $flag_optimize_none + $build_args += $flag_optimize_none # $build_args += $flag_optimize_minimal # $build_args += $flag_optimize_speed - $build_args += $falg_optimize_aggressive + # $build_args += $falg_optimize_aggressive $build_args += $flag_debug $build_args += $flag_pdb_name + $pdb $build_args += $flag_subsystem + 'windows'