finishex exposing cam zoom settings to the wiget menu and the font size canvas scalaar
This commit is contained in:
parent
dd2f6e9c71
commit
292d1b58b5
@ -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,
|
||||
}
|
||||
|
@ -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 )
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
|
@ -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" )
|
||||
|
||||
|
@ -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) {
|
||||
|
@ -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 );
|
||||
}
|
||||
|
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user