right alt

master
Allen Webster 2016-01-16 20:34:48 -05:00
parent 0aa1df3da0
commit 7009115967
21 changed files with 4490 additions and 4215 deletions

View File

@ -17,7 +17,9 @@
clear_parameters(cmd_context)
#define push_memory(cmd_context, len) app->push_memory(cmd_context, len)
#ifndef literal
#define literal(s) s, (sizeof(s)-1)
#endif
// NOTE(allen|a3.1): All of your custom ids should be >= mapid_user_custom.
// I recommend enumerating your own map ids as shown here.

View File

@ -132,6 +132,7 @@ enum Param_ID{
par_cli_path,
par_cli_command,
par_cli_overlap_with_conflict,
par_cli_always_bind_to_view,
// never below this
par_type_count
};
@ -284,7 +285,7 @@ struct Application_Links{
Directory_CD *directory_cd;
};
struct Config_API{
struct Custom_API{
Get_Binding_Data_Function *get_bindings;
Set_Extra_Font_Function *set_extra_font;
};

View File

@ -1537,41 +1537,47 @@ cpp_get_token(Cpp_Token_Stack *token_stack, int pos){
last = token_stack->count;
Cpp_Get_Token_Result result = {};
while (1){
result.token_index = (first + last)/2;
if (token_stack->count > 0){
for (;;){
result.token_index = (first + last)/2;
int this_start = token_stack->tokens[result.token_index].start;
int next_start;
if (result.token_index + 1 < token_stack->count){
next_start = token_stack->tokens[result.token_index+1].start;
int this_start = token_stack->tokens[result.token_index].start;
int next_start;
if (result.token_index + 1 < token_stack->count){
next_start = token_stack->tokens[result.token_index+1].start;
}
else{
next_start = this_start + token_stack->tokens[result.token_index].size;
}
if (this_start <= pos && pos < next_start){
break;
}
else if (pos < this_start){
last = result.token_index;
}
else{
first = result.token_index + 1;
}
if (first == last){
result.token_index = first;
break;
}
}
else{
next_start = this_start + token_stack->tokens[result.token_index].size;
}
if (this_start <= pos && pos < next_start){
break;
}
else if (pos < this_start){
last = result.token_index;
}
else{
first = result.token_index + 1;
}
if (first == last){
result.token_index = first;
break;
}
}
if (result.token_index == token_stack->count){
--result.token_index;
result.in_whitespace = 1;
}
else{
Cpp_Token *token = token_stack->tokens + result.token_index;
if (token->start + token->size <= pos){
if (result.token_index == token_stack->count){
--result.token_index;
result.in_whitespace = 1;
}
else{
Cpp_Token *token = token_stack->tokens + result.token_index;
if (token->start + token->size <= pos){
result.in_whitespace = 1;
}
}
}
else{
result.token_index = -1;
result.in_whitespace = 1;
}
return result;
@ -1612,7 +1618,7 @@ cpp_relex_nonalloc_start(Cpp_File file, Cpp_Token_Stack *stack,
else{
state.start_token_i = result.token_index-1;
}
result = cpp_get_token(stack, end);
if (result.token_index < 0) result.token_index = 0;
else if (end > stack->tokens[result.token_index].start) ++result.token_index;

7377
4ed.cpp

File diff suppressed because it is too large Load Diff

29
4ed.h
View File

@ -26,15 +26,17 @@ enum Key_Control{
CONTROL_KEY_SHIFT,
CONTROL_KEY_CONTROL,
CONTROL_KEY_ALT,
CONTROL_KEY_CAPS,
// always last
CONTROL_KEY_COUNT
};
struct Key_Event_Data{
u8 keycode;
//u8 apply_shift;
u8 character;
u8 character_no_caps_lock;
b8 modifiers[CONTROL_KEY_COUNT];
};
struct Key_Input_Data{
@ -42,37 +44,28 @@ struct Key_Input_Data{
Key_Event_Data hold[KEY_INPUT_BUFFER_SIZE];
i32 press_count;
i32 hold_count;
b8 control_keys[CONTROL_KEY_COUNT];
b8 caps_lock;
};
struct Key_Summary{
i32 count;
Key_Event_Data keys[KEY_INPUT_BUFFER_DSIZE];
bool8 modifiers[CONTROL_KEY_COUNT];
};
struct Key_Single{
Key_Event_Data key;
b8 *modifiers;
};
inline Key_Single
inline Key_Event_Data
get_single_key(Key_Summary *summary, i32 index){
Assert(index >= 0 && index < summary->count);
Key_Single key;
key.key = summary->keys[index];
key.modifiers = summary->modifiers;
Key_Event_Data key;
key = summary->keys[index];
return key;
}
struct Mouse_State{
b32 out_of_window;
b32 left_button, right_button;
b32 left_button_prev, right_button_prev;
i32 x, y;
b8 left_button, right_button;
b8 left_button_pressed, right_button_pressed;
b8 left_button_released, right_button_released;
i16 wheel;
i32 x, y;
};
struct Mouse_Summary{
@ -135,7 +128,7 @@ struct Exchange{
Key_Codes *loose_codes, \
Clipboard_Contents clipboard, \
String current_directory, \
Config_API api)
Custom_API api)
typedef App_Init_Sig(App_Init);

View File

@ -190,7 +190,7 @@ draw_rgb_slider(Render_Target *target, Vec4 base, i32 channel,
}
internal void
do_label(UI_State *state, UI_Layout *layout, char *text, f32 height = 2.f){
do_label(UI_State *state, UI_Layout *layout, char *text, int text_size, f32 height = 2.f){
Style *style = state->style;
i16 font_id = style->font_id;
i32 line_height = get_font_info(state->font_set, font_id)->height;
@ -202,11 +202,18 @@ do_label(UI_State *state, UI_Layout *layout, char *text, f32 height = 2.f){
u32 fore = style->main.default_color;
draw_rectangle(target, label, back);
i32 height = label.y1 - label.y0;
draw_string(target, font_id, text, label.x0,
String textstr = make_string(text, text_size);
draw_string(target, font_id, textstr, label.x0,
label.y0 + (height - line_height)/2, fore);
}
}
inline void
do_label(UI_State *state, UI_Layout *layout, String text, f32 height = 2.f){
do_label(state, layout, text.str, text.size, height);
}
internal void
do_scroll_bar(UI_State *state, i32_Rect rect){
i32 id = 1;
@ -447,19 +454,19 @@ do_channel_field(i32 sub_id, Color_UI *ui, u8 *channel, Channel_Field_Type ftype
Key_Summary *keys = ui->state.keys;
Key_Codes *codes = ui->state.codes;
for (i32 key_i = 0; key_i < keys->count; ++key_i){
Key_Single key = get_single_key(keys, key_i);
Key_Event_Data key = get_single_key(keys, key_i);
if (key.key.keycode == codes->right){
if (key.keycode == codes->right){
++indx;
if (indx > digit_count-1) indx = 0;
}
if (key.key.keycode == codes->left){
if (key.keycode == codes->left){
--indx;
if (indx < 0) indx = digit_count-1;
}
i32 new_value = *channel;
if (key.key.keycode == codes->up || key.key.keycode == codes->down){
if (key.keycode == codes->up || key.keycode == codes->down){
i32 place = digit_count-1-indx;
i32 base = (ftype == CF_DEC)?10:0x10;
i32 step_amount = 1;
@ -467,13 +474,13 @@ do_channel_field(i32 sub_id, Color_UI *ui, u8 *channel, Channel_Field_Type ftype
step_amount *= base;
--place;
}
if (key.key.keycode == codes->down){
if (key.keycode == codes->down){
step_amount = 0 - step_amount;
}
new_value += step_amount;
}
u8 c = (u8)key.key.character;
u8 c = (u8)key.character;
bool32 is_good = (ftype == CF_DEC)?char_is_numeric(c):char_is_hex(c);
if (is_good){
string_buffer[indx] = c;
@ -1563,7 +1570,7 @@ step_draw_library(System_Functions *system, Exchange *exchange, Mem_Options *mem
switch (mode){
case CV_MODE_LIBRARY:
{
do_label(&ui.state, &ui.layout, "Current Theme - Click to Edit");
do_label(&ui.state, &ui.layout, literal("Current Theme - Click to Edit"));
if (do_style_preview(&ui, color_view->main_style)){
color_view->mode = CV_MODE_ADJUSTING;
color_view->state.selected = {};
@ -1592,7 +1599,7 @@ step_draw_library(System_Functions *system, Exchange *exchange, Mem_Options *mem
memset(color_view->import_export_check, 0, sizeof(color_view->import_export_check));
}
do_label(&ui.state, &ui.layout, "Theme Library - Click to Select");
do_label(&ui.state, &ui.layout, literal("Theme Library - Click to Select"));
i32 style_count = color_view->styles->count;
Style *style = color_view->styles->styles;
@ -1606,12 +1613,12 @@ step_draw_library(System_Functions *system, Exchange *exchange, Mem_Options *mem
case CV_MODE_IMPORT_FILE:
{
do_label(&ui.state, &ui.layout, "Current Theme");
do_label(&ui.state, &ui.layout, literal("Current Theme"));
do_style_preview(&ui, color_view->main_style);
b32 file_selected = 0;
do_label(&ui.state, &ui.layout, "Import Which File?");
do_label(&ui.state, &ui.layout, literal("Import Which File?"));
begin_row(&ui.layout, 2);
if (do_button(-2, &ui.state, &ui.layout, "*.p4c only", 2, 1, color_view->p4c_only)){
color_view->p4c_only = !color_view->p4c_only;
@ -1671,12 +1678,12 @@ step_draw_library(System_Functions *system, Exchange *exchange, Mem_Options *mem
case CV_MODE_EXPORT_FILE:
{
do_label(&ui.state, &ui.layout, "Current Theme");
do_label(&ui.state, &ui.layout, literal("Current Theme"));
do_style_preview(&ui, color_view->main_style);
b32 file_selected = 0;
do_label(&ui.state, &ui.layout, "Export File Name?");
do_label(&ui.state, &ui.layout, literal("Export File Name?"));
begin_row(&ui.layout, 2);
if (do_button(-2, &ui.state, &ui.layout, "Finish Export", 2)){
file_selected = 1;
@ -1722,14 +1729,14 @@ step_draw_library(System_Functions *system, Exchange *exchange, Mem_Options *mem
case CV_MODE_IMPORT:
{
do_label(&ui.state, &ui.layout, "Current Theme");
do_label(&ui.state, &ui.layout, literal("Current Theme"));
do_style_preview(&ui, color_view->main_style);
i32 style_count = color_view->inspecting_styles.count;
Style *styles = color_view->inspecting_styles.styles;
bool8 *import_check = color_view->import_export_check;
do_label(&ui.state, &ui.layout, "Pack");
do_label(&ui.state, &ui.layout, literal("Pack"));
begin_row(&ui.layout, 2);
if (do_button(-2, &ui.state, &ui.layout, "Finish Import", 2)){
Style *style = styles;
@ -1753,10 +1760,10 @@ step_draw_library(System_Functions *system, Exchange *exchange, Mem_Options *mem
case CV_MODE_EXPORT:
{
do_label(&ui.state, &ui.layout, "Current Theme");
do_label(&ui.state, &ui.layout, literal("Current Theme"));
do_style_preview(&ui, color_view->main_style);
do_label(&ui.state, &ui.layout, "Export Which Themes?");
do_label(&ui.state, &ui.layout, literal("Export Which Themes?"));
begin_row(&ui.layout, 2);
if (do_button(-2, &ui.state, &ui.layout, "Export", 2)){
color_view->mode = CV_MODE_EXPORT_FILE;

View File

@ -126,7 +126,7 @@ apply_shift_to_code(u8 keycode){
}
internal Command_Binding
map_extract(Command_Map *map, Key_Single key){
map_extract(Command_Map *map, Key_Event_Data key){
Command_Binding bind = {};
b32 ctrl = key.modifiers[CONTROL_KEY_CONTROL];
@ -135,16 +135,16 @@ map_extract(Command_Map *map, Key_Single key){
u16 code;
u8 command = MDFR_NONE;
if (key.key.character_no_caps_lock != 0 &&
key.key.character_no_caps_lock != ' ') shift = 0;
if (key.character_no_caps_lock != 0 &&
key.character_no_caps_lock != ' ') shift = 0;
if (shift) command |= MDFR_SHIFT;
if (ctrl) command |= MDFR_CTRL;
if (alt) command |= MDFR_ALT;
code = key.key.character_no_caps_lock;
code = key.character_no_caps_lock;
if (code == 0){
code = key.key.keycode;
code = key.keycode;
map_find(map, code, command, &bind);
}
else{

View File

@ -218,9 +218,12 @@ draw_os_events(Debug_View *view, i32_Rect rect, Render_Target *target,
i16 font_id = view->font_id;
i32 line_height = get_font_info(&target->font_set, font_id)->height;
#if 0
draw_modifiers(view, target, active_input->keys.modifiers,
0xFFFFFFFF, 0xFF444444, &x, y);
#endif
max_x = x;
x = rect.x0;
y += line_height;
@ -325,7 +328,8 @@ step_debug_view(Debug_View *view, i32_Rect rect, Render_Target *target,
Input_Summary *active_input){
persist i32 max_past = ArrayCount(view->past_keys);
bool8 *modifiers = active_input->keys.modifiers;
#if 0
b8 *modifiers = active_input->keys.modifiers;
for (i32 i = 0; i < active_input->keys.count; ++i){
Dbg_Past_Key *past_key = view->past_keys + view->past_key_pos;
++view->past_key_pos;
@ -350,6 +354,7 @@ step_debug_view(Debug_View *view, i32_Rect rect, Render_Target *target,
if (active_input->mouse.wheel_used)
view->prev_mouse_wheel = active_input->mouse.wheel_amount;
#endif
}
internal

View File

@ -95,6 +95,7 @@ struct Editing_File_Settings{
i32 dos_write_mode;
b32 tokens_exist;
b32 super_locked;
b32 is_initialized;
};
// NOTE(allen): This part of the Editing_File is cleared whenever
@ -425,10 +426,10 @@ struct Single_Line_Mode{
internal Single_Line_Input_Step
app_single_line_input_core(System_Functions *system,
Key_Codes *codes, Working_Set *working_set,
Key_Single key, Single_Line_Mode mode){
Key_Event_Data key, Single_Line_Mode mode){
Single_Line_Input_Step result = {};
if (key.key.keycode == codes->back){
if (key.keycode == codes->back){
result.hit_backspace = 1;
if (mode.string->size > 0){
result.made_a_change = 1;
@ -453,7 +454,7 @@ app_single_line_input_core(System_Functions *system,
}
}
else if (key.key.character == '\n' || key.key.character == '\t'){
else if (key.character == '\n' || key.character == '\t'){
result.made_a_change = 1;
if (key.modifiers[CONTROL_KEY_CONTROL] ||
key.modifiers[CONTROL_KEY_ALT]){
@ -490,17 +491,17 @@ app_single_line_input_core(System_Functions *system,
}
}
else if (key.key.keycode == codes->esc){
else if (key.keycode == codes->esc){
result.hit_esc = 1;
result.made_a_change = 1;
}
else if (key.key.character){
else if (key.character){
result.hit_a_character = 1;
if (!key.modifiers[CONTROL_KEY_CONTROL] &&
!key.modifiers[CONTROL_KEY_ALT]){
if (mode.string->size+1 < mode.string->memory_size){
u8 new_character = (u8)key.key.character;
u8 new_character = (u8)key.character;
mode.string->str[mode.string->size] = new_character;
mode.string->size++;
mode.string->str[mode.string->size] = 0;
@ -521,7 +522,7 @@ app_single_line_input_core(System_Functions *system,
inline Single_Line_Input_Step
app_single_line_input_step(System_Functions *system,
Key_Codes *codes, Key_Single key, String *string){
Key_Codes *codes, Key_Event_Data key, String *string){
Single_Line_Mode mode = {};
mode.type = SINGLE_LINE_STRING;
mode.string = string;
@ -530,7 +531,7 @@ app_single_line_input_step(System_Functions *system,
inline Single_Line_Input_Step
app_single_file_input_step(System_Functions *system,
Key_Codes *codes, Working_Set *working_set, Key_Single key,
Key_Codes *codes, Working_Set *working_set, Key_Event_Data key,
String *string, Hot_Directory *hot_directory,
bool32 fast_folder_select){
Single_Line_Mode mode = {};
@ -543,13 +544,13 @@ app_single_file_input_step(System_Functions *system,
inline Single_Line_Input_Step
app_single_number_input_step(System_Functions *system,
Key_Codes *codes, Key_Single key, String *string){
Key_Codes *codes, Key_Event_Data key, String *string){
Single_Line_Input_Step result = {};
Single_Line_Mode mode = {};
mode.type = SINGLE_LINE_STRING;
mode.string = string;
char c = (char)key.key.character;
char c = (char)key.character;
if (c == 0 || c == '\n' || char_is_numeric(c))
result = app_single_line_input_core(system, codes, 0, key, mode);
return result;
@ -936,8 +937,8 @@ ui_do_text_field_input(UI_State *state, String *str){
bool32 result = 0;
Key_Summary *keys = state->keys;
for (i32 key_i = 0; key_i < keys->count; ++key_i){
Key_Single key = get_single_key(keys, key_i);
char c = (char)key.key.character;
Key_Event_Data key = get_single_key(keys, key_i);
char c = (char)key.character;
if (char_is_basic(c) && str->size < str->memory_size-1){
str->str[str->size++] = c;
str->str[str->size] = 0;
@ -945,7 +946,7 @@ ui_do_text_field_input(UI_State *state, String *str){
else if (c == '\n'){
result = 1;
}
else if (key.key.keycode == state->codes->back && str->size > 0){
else if (key.keycode == state->codes->back && str->size > 0){
str->str[--str->size] = 0;
}
}
@ -958,7 +959,7 @@ ui_do_file_field_input(System_Functions *system,
bool32 result = 0;
Key_Summary *keys = state->keys;
for (i32 key_i = 0; key_i < keys->count; ++key_i){
Key_Single key = get_single_key(keys, key_i);
Key_Event_Data key = get_single_key(keys, key_i);
String *str = &hot_dir->string;
terminate_with_null(str);
Single_Line_Input_Step step =
@ -974,7 +975,7 @@ ui_do_line_field_input(System_Functions *system,
bool32 result = 0;
Key_Summary *keys = state->keys;
for (i32 key_i = 0; key_i < keys->count; ++key_i){
Key_Single key = get_single_key(keys, key_i);
Key_Event_Data key = get_single_key(keys, key_i);
terminate_with_null(string);
Single_Line_Input_Step step =
app_single_line_input_step(system, state->codes, key, string);
@ -1552,10 +1553,8 @@ working_set_get_available_file(Working_Set *working_set){
break;
}
}
if (result.file){
*result.file = {};
}
if (result.file) *result.file = {};
return result;
}
@ -1639,7 +1638,7 @@ Job_Callback_Sig(job_full_lex){
status = cpp_lex_file_nonalloc(cpp_file, &tokens, status);
}
i32 new_max = LargeRoundUp(tokens.count, Kbytes(1));
i32 new_max = LargeRoundUp(tokens.count+1, Kbytes(1));
system->acquire_lock(FRAME_LOCK);
{
@ -2247,9 +2246,9 @@ view_file_loaded_init(System_Functions *system, File_View *view, i32 cursor_pos)
}
internal void
view_set_file(System_Functions *system, File_View *view, Editing_File *file,
Font_Set *set, Style *style, Custom_Command_Function *open_hook,
void *cmd_context, Application_Links *app){
view_set_file(System_Functions *system, File_View *view,
Editing_File *file, Font_Set *set, Style *style,
Hook_Function *open_hook, void *cmd_context, Application_Links *app){
Panel *panel = view->view_base.panel;
view->file = file;
view->locked = file->settings.super_locked;
@ -2295,8 +2294,11 @@ view_set_file(System_Functions *system, File_View *view, Editing_File *file,
view->vel_y = 1.f;
view->vel_x = 1.f;
if (open_hook) open_hook(cmd_context, app);
if (open_hook && file->settings.is_initialized == 0){
open_hook(cmd_context, app);
file->settings.is_initialized = 1;
}
}
struct Relative_Scrolling{
@ -2723,8 +2725,7 @@ file_do_single_edit(System_Functions *system,
}
internal void
view_do_white_batch_edit(System_Functions *system,
Mem_Options *mem, File_View *view, Editing_File *file,
view_do_white_batch_edit(System_Functions *system, Mem_Options *mem, File_View *view, Editing_File *file,
Editing_Layout *layout, Edit_Spec spec, History_Mode history_mode){
if (view->locked) return;
#if BUFFER_EXPERIMENT_SCALPEL <= 3
@ -2871,7 +2872,7 @@ view_undo_redo(System_Functions *system,
Assert(step.type == expected_type);
Edit_Spec spec;
Edit_Spec spec = {};
spec.step = step;
if (step.child_count == 0){
@ -4341,7 +4342,7 @@ HANDLE_COMMAND_SIG(handle_command_file_view){
if (binding.function) binding.function(system, command, binding);
file_view->mode = file_view->next_mode;
if (key.key.keycode == codes->esc)
if (key.keycode == codes->esc)
view_set_widget(file_view, FWIDG_NONE);
}break;

View File

@ -115,7 +115,7 @@ font_set_load(Partition *partition, Font_Set *set, i16 font_id){
font__insert(&set->used_slots, slot);
Render_Font *font = (Render_Font*)(slot + 1);
set->font_load(partition, font, info->filename.str, info->pt_size, 4);
set->font_load(font, info->filename.str, info->pt_size, 4);
info->font = font;
slot->font_id = font_id;
}

View File

@ -113,8 +113,7 @@ step_draw_int_view(System_Functions *system, Interactive_View *view,
b32 new_dir = 0;
b32 complete = 0;
terminate_with_null(&view->query);
do_label(&state, &layout, view->query.str, 1.f);
do_label(&state, &layout, view->query, 1.f);
switch (view->interaction){
case INTV_SYS_FILE_LIST:
@ -142,7 +141,7 @@ step_draw_int_view(System_Functions *system, Interactive_View *view,
String s = make_fixed_width_string(s_);
append(&s, view->dest);
append(&s, " has unsaved changes, kill it?");
do_label(&state, &layout, s.str, 1.f);
do_label(&state, &layout, s, 1.f);
i32 id = 0;
if (do_list_option(++id, &state, &layout, make_lit_string("(Y)es"))){

View File

@ -49,7 +49,7 @@ typedef Do_View_Sig(Do_View_Function);
#define HANDLE_COMMAND_SIG(name) \
void (name)(System_Functions *system, View *view, \
Command_Data *command, Command_Binding binding, \
Key_Single key, Key_Codes *codes)
Key_Event_Data key, Key_Codes *codes)
typedef HANDLE_COMMAND_SIG(Handle_Command_Function);

View File

@ -47,7 +47,7 @@ struct Mem_Options{
inline Partition
partition_open(void *memory, i32 size){
Partition partition;
partition.base = (u8*)memory;;
partition.base = (u8*)memory;
partition.pos = 0;
partition.max = size;
return partition;

View File

@ -14,6 +14,7 @@ struct Menu_View{
Style *style;
Working_Set *working_set;
Delay *delay;
Font_Set *font_set;
UI_State state;
};
@ -33,14 +34,14 @@ step_draw_menu_view(Menu_View *view, Render_Target *target, i32_Rect rect,
UI_State state =
ui_state_init(&view->state, target, user_input,
view->style, &target->font_set, view->working_set, input_stage);
view->style, view->font_set, view->working_set, input_stage);
UI_Layout layout;
begin_layout(&layout, rect);
i32 id = 0;
do_label(&state, &layout, "Menu", 2.f);
do_label(&state, &layout, literal("Menu"), 2.f);
if (do_list_option_lit(++id, &state, &layout, "Theme Options")){
delayed_action(view->delay, DACT_THEME_OPTIONS, {}, view->view_base.panel);
@ -67,7 +68,8 @@ Do_View_Sig(do_menu_view){
}
internal Menu_View*
menu_view_init(View *view, Style *style, Working_Set *working_set, Delay *delay){
menu_view_init(View *view, Style *style, Working_Set *working_set,
Delay *delay, Font_Set *font_set){
view->type = VIEW_TYPE_INTERACTIVE;
view->do_view = do_menu_view;
@ -76,6 +78,7 @@ menu_view_init(View *view, Style *style, Working_Set *working_set, Delay *delay)
result->style = style;
result->working_set = working_set;
result->delay = delay;
result->font_set = font_set;
return result;
}

View File

@ -101,6 +101,10 @@ _OutDbgStr(u8*);
#define Swap(a,b) {auto t = a; a = b; b = t;}
#ifndef literal
#define literal(s) s, (sizeof(s)-1)
#endif
#define Min(a,b) (((a)<(b))?(a):(b))
#define Max(a,b) (((a)>(b))?(a):(b))

View File

@ -269,11 +269,16 @@ launch_rendering(Render_Target *target){
#undef ExtractStruct
internal
Font_Info_Load_Sig(draw_font_info_load){
internal i32
draw_font_info_load(Partition *partition,
char *filename,
i32 pt_size,
i32 *height,
i32 *advance){
i32 result = 1;
Data file;
file = system_load_file(filename);
Temp_Memory temp = begin_temp_memory(partition);
stbtt_packedchar *chardata = push_array(partition, stbtt_packedchar, 256);
@ -283,7 +288,7 @@ Font_Info_Load_Sig(draw_font_info_load){
tex_width = pt_size*128*oversample;
tex_height = pt_size*2*oversample;
void *block = push_block(partition, tex_width * tex_height);
if (!file.data){
result = 0;
}
@ -342,18 +347,25 @@ Font_Info_Load_Sig(draw_font_info_load){
system_free_memory(file.data);
}
end_temp_memory(temp);
return(result);
}
internal
Font_Load_Sig(draw_font_load){
internal i32
draw_font_load(void *base_block, i32 size,
Render_Font *font_out,
char *filename,
i32 pt_size,
i32 tab_width){
i32 result = 1;
Data file;
file = system_load_file(filename);
Temp_Memory temp = begin_temp_memory(partition);
Partition partition_ = partition_open(base_block, size);
Partition *partition = &partition_;
stbtt_packedchar *chardata = font_out->chardata;
i32 oversample = 2;
@ -395,14 +407,6 @@ Font_Load_Sig(draw_font_load){
stbtt_pack_context spc;
#if 0
if (stbtt_BakeFontBitmap((u8*)file.data, 0, (f32)pt_size,
memory_cursor, tex_width, tex_height, 0, 128,
font_out->chardata, partition) <= 0){
result = 0;
}
#endif
if (stbtt_PackBegin(&spc, (u8*)block, tex_width, tex_height, tex_width, 1, partition)){
stbtt_PackSetOversampling(&spc, oversample, oversample);
if (stbtt_PackFontRange(&spc, (u8*)file.data, 0,
@ -456,8 +460,6 @@ Font_Load_Sig(draw_font_load){
}
system_free_memory(file.data);
}
end_temp_memory(temp);
return result;
}

View File

@ -107,7 +107,6 @@ struct Render_Piece_Combined{
typedef Draw_Push_Piece_Sig(Draw_Push_Piece);
#define Font_Load_Sig(name) i32 name( \
Partition *partition, \
Render_Font *font_out, \
char *filename, \
i32 pt_size, \

View File

@ -20,15 +20,18 @@ draw_pop_clip(Render_Target *target){
}
internal void
begin_render_section(Render_Target *target){
begin_render_section(Render_Target *target, System_Functions *system){
Font_Set *font_set = &target->font_set;
font_set->used_this_frame = 0;
memset(font_set->font_used_flags, 0, font_set->max);
target->size = 0;
system->acquire_lock(RENDER_LOCK);
}
internal void
end_render_section(Render_Target *target){
end_render_section(Render_Target *target, System_Functions *system){
//Font_Set *font_set = &target->font_set;
system->release_lock(RENDER_LOCK);
}
internal void

View File

@ -61,6 +61,9 @@ struct Thread_Context;
enum Lock_ID{
FRAME_LOCK,
INPUT_LOCK,
FONT_LOCK,
RENDER_LOCK,
CANCEL_LOCK0,
CANCEL_LOCK1,
CANCEL_LOCK2,

BIN
vc120.pdb

Binary file not shown.

File diff suppressed because it is too large Load Diff