diff --git a/code/font/vefontcache/vefontcache.odin b/code/font/vefontcache/vefontcache.odin index 1f8a092..384d6d5 100644 --- a/code/font/vefontcache/vefontcache.odin +++ b/code/font/vefontcache/vefontcache.odin @@ -115,7 +115,7 @@ Init_Glyph_Draw_Params :: struct { } Init_Glyph_Draw_Params_Default :: Init_Glyph_Draw_Params { - over_sample = { 4, 4 }, + over_sample = { 16, 16 }, buffer_batch = 4, draw_padding = Init_Atlas_Params_Default.glyph_padding, } diff --git a/code/sectr/app/screen.odin b/code/sectr/app/screen.odin index abf7b94..b78c886 100644 --- a/code/sectr/app/screen.odin +++ b/code/sectr/app/screen.odin @@ -20,12 +20,17 @@ UI_ScreenState :: struct }, settings_menu : struct { - container : UI_Widget, - engine_refresh_inputbox : UI_TextInputBox, - min_zoom_inputbox : UI_TextInputBox, - max_zoom_inputbox : UI_TextInputBox, - cfg_drop_down : UI_DropDown, - zoom_mode_drop_down : UI_DropDown, + container : UI_Widget, + engine_refresh_inputbox : UI_TextInputBox, + min_zoom_inputbox : UI_TextInputBox, + max_zoom_inputbox : UI_TextInputBox, + zoom_smooth_snappiness_input : UI_TextInputBox, + zoom_smooth_sensitivity_input : UI_TextInputBox, + zoom_digital_sensitivity_input : UI_TextInputBox, + zoom_scroll_delta_scale_input : UI_TextInputBox, + font_size_canvas_scalar_input : UI_TextInputBox, + cfg_drop_down : UI_DropDown, + zoom_mode_drop_down : UI_DropDown, pos, size, min_size : Vec2, is_open : b32, is_maximized : b32, @@ -221,10 +226,42 @@ ui_screen_settings_menu :: proc( captures : rawptr = nil ) -> ( should_raise : b } } + // TODO(Ed): This will eventually be most likely generalized/compressed. For now its the main scope for implementing new widgets. app_config := ui_drop_down( & cfg_drop_down, "settings_menu.config", str_intern("App Config"), vb_compute_layout = true) app_config.title.layout.font_size = 12 if app_config.is_open { + ui_settings_entry_inputbox :: proc( input_box : ^UI_TextInputBox, is_even : bool, label : string, setting_title : StrRunesPair, input_policy : UI_TextInput_Policy ) + { + scope( theme_table_row(is_even)) + hb := ui_hbox(.Left_To_Right, str_intern_fmt("%v.hb", label).str); { + using hb + + layout.size.min = {0, 25} + layout.flags = {.Fixed_Height} + layout.padding = to_ui_layout_side(4) + } + + scope(theme_text) + title := ui_text(str_intern_fmt("%v.title", label).str, setting_title); { + using title + layout.anchor.ratio.x = 1.0 + layout.margins.left = 10 + layout.font_size = 12 + } + + ui_text_input_box( input_box, str_intern_fmt("%v.input_box", label).str, allocator = persistent_slab_allocator(), policy = input_policy ) + { + using input_box + layout.flags = {.Fixed_Width} + layout.margins.left = 5 + layout.padding.right = 5 + layout.size.min.x = 80 + style.corner_radii = { 3, 3, 3, 3 } + } + } + + Engine_Refresh_Hz: { scope(theme_table_row(is_even = false)) @@ -432,6 +469,151 @@ ui_screen_settings_menu :: proc( captures : rawptr = nil ) -> ( should_raise : b } } } + + Cam_Zoom_Smooth_Snappiness: + { + ui_settings_entry_inputbox( & zoom_smooth_snappiness_input, false, "settings_menu.cam_zoom_smooth_snappiness", str_intern("Camera: Zoom Smooth Snappiness"), + UI_TextInput_Policy { + digits_only = true, + disallow_leading_zeros = false, + disallow_decimal = false, + digit_min = 0.01, + digit_max = 9999, + max_length = 5, + } + ) + using zoom_smooth_snappiness_input + + if was_active + { + value, success := parse_f32(to_string(array_to_slice(input_str))) + if success { + value = clamp(value, 0.001, 9999.0) + config.cam_zoom_smooth_snappiness = value + } + } + else + { + clear( input_str ) + append( & input_str, to_runes(str_fmt("%v", config.cam_zoom_smooth_snappiness))) + } + } + + Cam_Zoom_Sensitivity_Smooth: + { + ui_settings_entry_inputbox( & zoom_smooth_sensitivity_input, true, "settings_menu.cam_zoom_sensitivity_smooth", str_intern("Camera: Zoom Smooth Sensitivity"), + UI_TextInput_Policy { + digits_only = true, + disallow_leading_zeros = false, + disallow_decimal = false, + digit_min = 0.01, + digit_max = 9999, + max_length = 5, + } + ) + using zoom_smooth_sensitivity_input + + if was_active + { + value, success := parse_f32(to_string(array_to_slice(input_str))) + if success { + value = clamp(value, 0.001, 9999.0) + config.cam_zoom_sensitivity_smooth = value + } + } + else + { + clear( input_str ) + append( & input_str, to_runes(str_fmt("%v", config.cam_zoom_sensitivity_smooth))) + } + } + + Cam_Zoom_Sensitivity_Digital: + { + ui_settings_entry_inputbox( & zoom_digital_sensitivity_input, false, "settings_menu.cam_zoom_sensitivity_digital", str_intern("Camera: Zoom Digital Sensitivity"), + UI_TextInput_Policy { + digits_only = true, + disallow_leading_zeros = false, + disallow_decimal = false, + digit_min = 0.01, + digit_max = 9999, + max_length = 5, + } + ) + using zoom_digital_sensitivity_input + + if was_active + { + value, success := parse_f32(to_string(array_to_slice(input_str))) + if success { + value = clamp(value, 0.001, 9999.0) + config.cam_zoom_sensitivity_digital = value + } + } + else + { + clear( input_str ) + append( & input_str, to_runes(str_fmt("%v", config.cam_zoom_sensitivity_digital))) + } + } + + Cam_Zoom_Scroll_Delta_Scale: + { + ui_settings_entry_inputbox( & zoom_scroll_delta_scale_input, false, "settings_menu.cam_zoom_scroll_delta_scale", str_intern("Camera: Zoom Scroll Delta Scale"), + UI_TextInput_Policy { + digits_only = true, + disallow_leading_zeros = false, + disallow_decimal = false, + digit_min = 0.01, + digit_max = 9999, + max_length = 5, + } + ) + using zoom_scroll_delta_scale_input + + if was_active + { + value, success := parse_f32(to_string(array_to_slice(input_str))) + if success { + value = clamp(value, 0.001, 9999.0) + config.cam_zoom_scroll_delta_scale = value + } + } + else + { + clear( input_str ) + append( & input_str, to_runes(str_fmt("%v", config.cam_zoom_scroll_delta_scale))) + } + } + + Font_Size_Canvas_Scalar: + { + ui_settings_entry_inputbox( & font_size_canvas_scalar_input, false, "settings_menu.font_size_canvas_scalar", str_intern("Font: Size Canvas Scalar"), + UI_TextInput_Policy { + digits_only = true, + disallow_leading_zeros = false, + disallow_decimal = false, + digit_min = 0.01, + digit_max = 9999, + max_length = 5, + } + ) + using font_size_canvas_scalar_input + + if was_active + { + value, success := parse_f32(to_string(array_to_slice(input_str))) + if success { + value = clamp(value, 0.001, 9999.0) + config.font_size_canvas_scalar = value + } + } + else + { + clear( input_str ) + append( & input_str, to_runes(str_fmt("%v", config.font_size_canvas_scalar))) + } + } } } ui_vbox_end(vbox, compute_layout = false ) diff --git a/code/sectr/engine/client_api.odin b/code/sectr/engine/client_api.odin index f84a4ea..ea7df0f 100644 --- a/code/sectr/engine/client_api.odin +++ b/code/sectr/engine/client_api.odin @@ -300,7 +300,7 @@ startup :: proc( prof : ^SpallProfiler, persistent_mem, frame_mem, transient_mem // menu_bar.pos = Vec2(app_window.extent) * { -1, 1 } menu_bar.size = {140, 40} - settings_menu.min_size = {260, 200} + settings_menu.min_size = {360, 200} } // Demo project setup diff --git a/code/sectr/engine/render.odin b/code/sectr/engine/render.odin index 83f59f7..134264e 100644 --- a/code/sectr/engine/render.odin +++ b/code/sectr/engine/render.odin @@ -261,7 +261,6 @@ render_mode_screenspace :: proc( screen_extent : Extents2, screen_ui : ^UI_State } if true { - state.config.font_size_canvas_scalar = 2.0 zoom_adjust_size := 16 * state.project.workspace.cam.zoom over_sample := f32(state.config.font_size_canvas_scalar) debug_text("font_size_canvas_scalar: %v", config.font_size_canvas_scalar) diff --git a/code/sectr/font/render_sokol.odin b/code/sectr/font/render_sokol.odin index d76269c..77a80ff 100644 --- a/code/sectr/font/render_sokol.odin +++ b/code/sectr/font/render_sokol.odin @@ -169,14 +169,14 @@ font_provider_setup_sokol_gfx_objects :: proc( ctx : ^VE_RenderData, ve_ctx : ve glyph_rt_sampler = sokol_gfx.make_sampler( SamplerDescription { min_filter = Image_Filter, mag_filter = Image_Filter, - mipmap_filter = Filter.NEAREST, + mipmap_filter = Filter.LINEAR, wrap_u = .CLAMP_TO_EDGE, wrap_v = .CLAMP_TO_EDGE, min_lod = -1000.0, max_lod = 1000.0, border_color = BorderColor.OPAQUE_BLACK, compare = .NEVER, - max_anisotropy = 1, + max_anisotropy = 16, }) verify( sokol_gfx.query_sampler_state( glyph_rt_sampler) < ResourceState.FAILED, "Failed to make atlas_rt_sampler" ) @@ -307,14 +307,14 @@ font_provider_setup_sokol_gfx_objects :: proc( ctx : ^VE_RenderData, ve_ctx : ve atlas_rt_sampler = sokol_gfx.make_sampler( SamplerDescription { min_filter = Image_Filter, mag_filter = Image_Filter, - mipmap_filter = Filter.NEAREST, + mipmap_filter = Filter.LINEAR, wrap_u = .CLAMP_TO_EDGE, wrap_v = .CLAMP_TO_EDGE, min_lod = -1000.0, max_lod = 1000.0, border_color = BorderColor.OPAQUE_BLACK, compare = .NEVER, - max_anisotropy = 1, + max_anisotropy = 16, }) verify( sokol_gfx.query_sampler_state( atlas_rt_sampler) < ResourceState.FAILED, "Failed to make atlas_rt_sampler" ) diff --git a/code/sectr/shaders/ve_blit_atlas.odin b/code/sectr/shaders/ve_blit_atlas.odin index 8abcbc9..864ec75 100644 --- a/code/sectr/shaders/ve_blit_atlas.odin +++ b/code/sectr/shaders/ve_blit_atlas.odin @@ -31,8 +31,8 @@ import sg "thirdparty:sokol/gfx" Bind slot: SMP_ve_blit_atlas_src_sampler => 0 */ ATTR_ve_blit_atlas_v_position :: 0 -ATTR_ve_blit_atlas_v_texture :: 1 -UB_ve_blit_atlas_fs_params :: 0 +ATTR_ve_blit_atlas_v_texture :: 1 +UB_ve_blit_atlas_fs_params :: 0 IMG_ve_blit_atlas_src_texture :: 0 SMP_ve_blit_atlas_src_sampler :: 0 Ve_Blit_Atlas_Fs_Params :: struct #align(16) { diff --git a/code/sectr/shaders/ve_draw_text.shdc.glsl b/code/sectr/shaders/ve_draw_text.shdc.glsl index 291face..70b4743 100644 --- a/code/sectr/shaders/ve_draw_text.shdc.glsl +++ b/code/sectr/shaders/ve_draw_text.shdc.glsl @@ -33,12 +33,14 @@ void main() if ( down_sample == 1 ) { // TODO(Ed): The original author made these consts, I want to instead expose as uniforms... - const vec2 texture_size = 1.0f / vec2( 2048.0f, 512.0f ); // VEFontCache.Context.buffer_width/buffer_height + const vec2 texture_size = 1.0f / vec2( 2048.0f, 512.0f ); // VEFontCache.Context.buffer_width/buffer_height + const float down_sample_scale = 1.0f / 4.0f; + alpha = - (texture(sampler2D( ve_draw_text_src_texture, ve_draw_text_src_sampler), uv + vec2( -0.5f, -0.5f) * texture_size ).x * 0.25f) - + (texture(sampler2D( ve_draw_text_src_texture, ve_draw_text_src_sampler), uv + vec2( -0.5f, 0.5f) * texture_size ).x * 0.25f) - + (texture(sampler2D( ve_draw_text_src_texture, ve_draw_text_src_sampler), uv + vec2( 0.5f, -0.5f) * texture_size ).x * 0.25f) - + (texture(sampler2D( ve_draw_text_src_texture, ve_draw_text_src_sampler), uv + vec2( 0.5f, 0.5f) * texture_size ).x * 0.25f); + (texture(sampler2D( ve_draw_text_src_texture, ve_draw_text_src_sampler), uv + vec2( -0.5f, -0.5f) * texture_size ).x * down_sample_scale) + + (texture(sampler2D( ve_draw_text_src_texture, ve_draw_text_src_sampler), uv + vec2( -0.5f, 0.5f) * texture_size ).x * down_sample_scale) + + (texture(sampler2D( ve_draw_text_src_texture, ve_draw_text_src_sampler), uv + vec2( 0.5f, -0.5f) * texture_size ).x * down_sample_scale) + + (texture(sampler2D( ve_draw_text_src_texture, ve_draw_text_src_sampler), uv + vec2( 0.5f, 0.5f) * texture_size ).x * down_sample_scale); } frag_color = vec4( colour.xyz, colour.a * alpha ); } diff --git a/code/sectr/ui/core/base.odin b/code/sectr/ui/core/base.odin index d100f26..7fb9a64 100644 --- a/code/sectr/ui/core/base.odin +++ b/code/sectr/ui/core/base.odin @@ -455,7 +455,7 @@ ui_hash_part_from_key_string :: proc ( content : string ) -> string { ui_key_from_string :: #force_inline proc "contextless" ( value : string ) -> UI_Key { // profile(#procedure) - USE_RAD_DEBUGGERS_METHOD :: false + USE_RAD_DEBUGGERS_METHOD :: true key : UI_Key diff --git a/code/sectr/ui/widgets.odin b/code/sectr/ui/widgets.odin index a443040..b3e5161 100644 --- a/code/sectr/ui/widgets.odin +++ b/code/sectr/ui/widgets.odin @@ -581,7 +581,11 @@ UI_TextInputBox :: struct { using policy : UI_TextInput_Policy, } -ui_text_input_box :: proc( text_input_box : ^UI_TextInputBox, label : string, flags : UI_BoxFlags = {.Mouse_Clickable, .Focusable, .Click_To_Focus}, allocator := context.allocator ) +ui_text_input_box :: proc( text_input_box : ^UI_TextInputBox, label : string, + flags : UI_BoxFlags = {.Mouse_Clickable, .Focusable, .Click_To_Focus}, + allocator := context.allocator, + policy : UI_TextInput_Policy = {} +) { state := get_state() iter_next :: next