beta ready DPI handling
This commit is contained in:
parent
da9d1235b4
commit
783d4cc147
6
4ed.cpp
6
4ed.cpp
|
@ -684,8 +684,7 @@ init_command_line_settings(App_Settings *settings, Plat_Settings *plat_settings,
|
|||
case CLAct_FontSize:
|
||||
{
|
||||
if (i < argc){
|
||||
plat_settings->font_size = (i32)string_to_integer(SCu8(argv[i]), 10);
|
||||
settings->font_size = plat_settings->font_size;
|
||||
settings->font_size = (i32)string_to_integer(SCu8(argv[i]), 10);
|
||||
}
|
||||
action = CLAct_Nothing;
|
||||
}break;
|
||||
|
@ -821,8 +820,7 @@ App_Read_Command_Line_Sig(app_read_command_line){
|
|||
i32 out_size = 0;
|
||||
Models *models = app_setup_memory(system, memory);
|
||||
App_Settings *settings = &models->settings;
|
||||
memset(settings, 0, sizeof(*settings));
|
||||
plat_settings->font_size = 16;
|
||||
block_zero_struct(settings);
|
||||
if (argc > 1){
|
||||
init_command_line_settings(&models->settings, plat_settings, argc, argv);
|
||||
}
|
||||
|
|
8
4ed.h
8
4ed.h
|
@ -56,14 +56,15 @@ struct Plat_Settings{
|
|||
|
||||
u8 use_log;
|
||||
|
||||
i32 window_w, window_h;
|
||||
i32 window_x, window_y;
|
||||
i32 window_w;
|
||||
i32 window_h;
|
||||
i32 window_x;
|
||||
i32 window_y;
|
||||
b8 set_window_pos;
|
||||
b8 set_window_size;
|
||||
b8 maximize_window;
|
||||
|
||||
b8 use_hinting;
|
||||
i32 font_size;
|
||||
};
|
||||
|
||||
#define App_Read_Command_Line_Sig(name) \
|
||||
|
@ -100,7 +101,6 @@ struct Application_Step_Input{
|
|||
String_Const_u8 clipboard;
|
||||
b32 clipboard_changed;
|
||||
b32 trying_to_kill;
|
||||
u32 debug_number;
|
||||
};
|
||||
|
||||
#define App_Step_Sig(name) Application_Step_Result \
|
||||
|
|
|
@ -76,7 +76,7 @@ struct Face{
|
|||
////////////////////////////////
|
||||
|
||||
// NOTE(allen): Platform layer calls - implemented in a "font provider"
|
||||
typedef Face *Font_Make_Face_Function(Arena *arena, Face_Description *description);
|
||||
typedef Face *Font_Make_Face_Function(Arena *arena, Face_Description *description, f32 scale_factor);
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -161,7 +161,7 @@ ft__glyph_bounds_store_uv_raw(Vec3_i32 p, Vec2_i32 dim, Glyph_Bounds *bounds){
|
|||
}
|
||||
|
||||
internal Face*
|
||||
ft__font_make_face(Arena *arena, Face_Description *description){
|
||||
ft__font_make_face(Arena *arena, Face_Description *description, f32 scale_factor){
|
||||
String_Const_u8 file_name = {};
|
||||
if (description->font.in_4coder_font_folder){
|
||||
String_Const_u8 binary_path = sysfunc.get_4ed_path(arena);
|
||||
|
@ -183,7 +183,7 @@ ft__font_make_face(Arena *arena, Face_Description *description){
|
|||
if (error == 0){
|
||||
face = push_array_zero(arena, Face, 1);
|
||||
|
||||
u32 pt_size = description->parameters.pt_size;
|
||||
u32 pt_size = (u32)(description->parameters.pt_size*scale_factor);
|
||||
b32 hinting = description->parameters.hinting;
|
||||
|
||||
FT_Size_RequestRec_ size = {};
|
||||
|
|
|
@ -73,12 +73,13 @@ font_set_init(System_Functions *system, Font_Set *set){
|
|||
set->arena = make_arena_system(system);
|
||||
set->next_id_counter = 1;
|
||||
set->id_to_slot_table = make_table_u64_u64(set->arena.base_allocator, 40);
|
||||
set->scale_factor = system->get_screen_scale_factor();
|
||||
}
|
||||
|
||||
internal Face*
|
||||
font_set_new_face(Font_Set *set, Face_Description *description){
|
||||
Arena arena = make_arena_system(set->system);
|
||||
Face *face = set->system->font_make_face(&arena, description);
|
||||
Face *face = set->system->font_make_face(&arena, description, set->scale_factor);
|
||||
if (face != 0){
|
||||
Font_Face_Slot *slot = font_set__alloc_face_slot(set);
|
||||
slot->arena = arena;
|
||||
|
@ -150,7 +151,7 @@ font_set_modify_face(Font_Set *set, Face_ID id, Face_Description *description){
|
|||
if (slot != 0){
|
||||
i32 version_number = slot->face->version_number;
|
||||
Arena arena = make_arena_system(set->system);
|
||||
Face *face = set->system->font_make_face(&arena, description);
|
||||
Face *face = set->system->font_make_face(&arena, description, set->scale_factor);
|
||||
if (face != 0){
|
||||
linalloc_clear(&slot->arena);
|
||||
slot->arena = arena;
|
||||
|
|
|
@ -35,6 +35,7 @@ struct Font_Set{
|
|||
Font_Face_ID_Node *free_id_nodes;
|
||||
Font_Face_Slot *free_face_slots;
|
||||
Table_u64_u64 id_to_slot_table;
|
||||
f32 scale_factor;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -99,6 +99,9 @@ typedef Sys_CLI_End_Update_Sig(System_CLI_End_Update);
|
|||
#define Sys_Open_Color_Picker_Sig(name) void name(Color_Picker *picker)
|
||||
typedef Sys_Open_Color_Picker_Sig(System_Open_Color_Picker);
|
||||
|
||||
#define Sys_Get_Screen_Scale_Factor_Sig(name) f32 name(void)
|
||||
typedef Sys_Get_Screen_Scale_Factor_Sig(System_Get_Screen_Scale_Factor);
|
||||
|
||||
// thread
|
||||
typedef Plat_Handle System_Thread;
|
||||
typedef Plat_Handle System_Mutex;
|
||||
|
@ -202,6 +205,7 @@ struct System_Functions{
|
|||
|
||||
// TODO(allen):
|
||||
System_Open_Color_Picker *open_color_picker;
|
||||
System_Get_Screen_Scale_Factor *get_screen_scale_factor;
|
||||
|
||||
// threads
|
||||
System_Thread_Launch *thread_launch;
|
||||
|
|
|
@ -39,6 +39,7 @@ link_system_code(void){
|
|||
SYSLINK(cli_end_update);
|
||||
|
||||
SYSLINK(open_color_picker);
|
||||
SYSLINK(get_screen_scale_factor);
|
||||
|
||||
SYSLINK(thread_launch);
|
||||
SYSLINK(thread_join);
|
||||
|
|
|
@ -180,8 +180,7 @@ struct Win32_Vars{
|
|||
String_Const_u8 clip_post;
|
||||
|
||||
HWND window_handle;
|
||||
i32 dpi_x;
|
||||
i32 dpi_y;
|
||||
f32 screen_scale_factor;
|
||||
|
||||
f64 count_per_usecond;
|
||||
b32 first;
|
||||
|
@ -1583,6 +1582,18 @@ WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdS
|
|||
custom_api.get_bindings = get_bindings;
|
||||
#endif
|
||||
|
||||
SetProcessDPIAware();
|
||||
|
||||
{
|
||||
HDC dc = GetDC(0);
|
||||
i32 x_dpi = GetDeviceCaps(dc, LOGPIXELSX);
|
||||
i32 y_dpi = GetDeviceCaps(dc, LOGPIXELSY);
|
||||
i32 max_dpi = max(x_dpi, y_dpi);
|
||||
win32vars.screen_scale_factor = ((f32)max_dpi)/96.f;
|
||||
ReleaseDC(0, dc);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Window and GL Initialization
|
||||
//
|
||||
|
|
|
@ -494,5 +494,10 @@ Sys_Open_Color_Picker_Sig(system_open_color_picker){
|
|||
CloseHandle(ThreadHandle);
|
||||
}
|
||||
|
||||
internal
|
||||
Sys_Get_Screen_Scale_Factor_Sig(system_get_screen_scale_factor){
|
||||
return(win32vars.screen_scale_factor);
|
||||
}
|
||||
|
||||
// BOTTOM
|
||||
|
||||
|
|
|
@ -1,55 +0,0 @@
|
|||
defined(IS_CL)
|
||||
defined(IS_GCC)
|
||||
defined(IS_WINDOWS)
|
||||
defined(IS_LINUX)
|
||||
defined(IS_MAC)
|
||||
FTECH_32_BIT
|
||||
FTECH_64_BIT
|
||||
Temp_Memory_Arena
|
||||
begin_temp_memory
|
||||
end_temp_memory
|
||||
arena_release_all
|
||||
Lister_Activation_Function_Type
|
||||
|
||||
global_part
|
||||
create_or_switch_to_buffer_by_name
|
||||
|
||||
get_build_directory
|
||||
standard_build_search
|
||||
execute_standard_build
|
||||
|
||||
open_all_files_in_directory_with_extension
|
||||
|
||||
buffer_seek_range_camel_right
|
||||
buffer_seek_range_camel_left
|
||||
|
||||
view_buffer_boundary_seek_set_pos
|
||||
view_boundary_seek_set_pos
|
||||
view_buffer_boundary_range
|
||||
view_buffer_snipe_range
|
||||
|
||||
Hard_Start_Result -> Line_Indent_Info
|
||||
buffer_find_hard_start -> get_line_indent_info
|
||||
|
||||
|
||||
get_active_view -> get_active_view_DEP
|
||||
view_compute_cursor -> view_compute_cursor_DEP
|
||||
|
||||
list__parameters
|
||||
list_query__parameters
|
||||
list_identifier__parameters
|
||||
list_type_definition__parameters
|
||||
|
||||
set_buffer_face_by_name -> set_buffer_face_by_font_load_location
|
||||
get_existing_face_id_matching_name -> face_id_from_font_load_target
|
||||
get_face_id_by_name
|
||||
set_global_face_by_name -> set_buffer_face_by_font_load_location (with id = 0)
|
||||
|
||||
mark_enclosures -> draw_enclosures
|
||||
|
||||
all *marker_visuals* -> immediate mode rendering
|
||||
|
||||
get_file_list
|
||||
free_file_list
|
||||
File_Info
|
||||
File_List
|
Loading…
Reference in New Issue