diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/mo_edit.c | 36 | ||||
| -rw-r--r-- | src/ui.c | 7 | ||||
| -rw-r--r-- | src/ui.h | 11 |
3 files changed, 37 insertions, 17 deletions
diff --git a/src/mo_edit.c b/src/mo_edit.c index 134da15..bbd12ee 100644 --- a/src/mo_edit.c +++ b/src/mo_edit.c @@ -9,16 +9,12 @@ // TODO(Aldrik): option to disable menu item // TODO(Aldrik): move the delete button for term to edit panel on the topright and put a exclamation mark at the old spot to indicate a missing translation -// TODO(Aldrik): language name validation // TODO(Aldrik): language mo file name preview when entering name // TODO(Aldrik): option to mark languages with colors // TODO(Aldrik): change save icon -// TODO(Aldrik): press tab to go to next translation textbox // TODO(Aldrik): scissor on textbox in scroll // TODO(Aldrik): delete file of language when deleting language -// TODO(Aldrik): confirmation on deletion of term and language -// TODO(Aldrik): creating a new term when term name textbox is selected doesnt overwrite new name -// TODO(Aldrik): deleting the term selected doesnt select a valid term +// TODO(Aldrik): confirmation on deletion of term and language (replace delete button with "Confirm" button to confirm deletion) // TODO(Aldrik): reset textbox vertical scroll when new term is selected // TODO(Aldrik): ctrl+x to select+delete selection // TODO(Aldrik): ctrl+del to delete up to space char @@ -179,6 +175,16 @@ s32 add_language_to_project(char *buffer) return -1; } + for (s32 i = 0; i < current_project->languages.length; i++) + { + language *lang = array_at(¤t_project->languages, i); + if (string_equals(lang->name, buffer)) + { + platform_show_message(main_window, "Language already added", "Invalid info"); + return -1; + } + } + char *val = mem_alloc(MAX_INPUT_LENGTH); string_copyn(val, buffer, MAX_INPUT_LENGTH); @@ -314,6 +320,8 @@ s32 add_term_to_project() array_push(&t.translations, &tr); } + ui_set_textbox_active(&tb_new_term); + return array_push(¤t_project->terms, &t); } @@ -579,6 +587,7 @@ int main(int argc, char **argv) { remove_term_from_project(i); --i; + if (i >= 0) select_term(i); if (current_project->selected_term_index >= 0) current_project->selected_term_index--; @@ -641,7 +650,7 @@ int main(int argc, char **argv) ui_push_text(localize("no_languages_added")); } else - { + { for (s32 i = 0; i < t->translations.length; i++) { translation *tr = array_at(&t->translations, i); @@ -669,6 +678,21 @@ int main(int argc, char **argv) global_ui_context.layout.offset_y += TEXTBOX_HEIGHT + WIDGET_PADDING; global_ui_context.layout.offset_x = 310; + + if (keyboard_is_key_pressed(&keyboard, KEY_TAB) && tb_translation_list[i].state) + { + keyboard.input_keys[KEY_TAB] = false; + tb_translation_list[i].state = false; + + if (i+1 < t->translations.length) + { + ui_set_textbox_active(&tb_translation_list[i+1]); + } + else + { + ui_set_textbox_active(&tb_translation_list[0]); + } + } } } } @@ -88,6 +88,11 @@ inline scroll_state ui_create_scroll(s32 scroll) void ui_set_textbox_text(textbox_state *textbox, char *text) { + if (global_ui_context.current_active_textbox == textbox) + { + keyboard_set_input_text(global_ui_context.keyboard, text); + } + string_copyn(textbox->buffer, text, textbox->max_len); } @@ -522,7 +527,7 @@ static void ui_set_active_textbox(textbox_state *state) global_ui_context.current_active_textbox = state; } -void set_active_textbox(textbox_state *textbox) +void ui_set_textbox_active(textbox_state *textbox) { ui_set_active_textbox(textbox); keyboard_set_input_text(global_ui_context.keyboard, textbox->buffer); @@ -145,16 +145,6 @@ typedef struct t_ui_context bool item_hovered; } ui_context; -///// our global ui states //// -checkbox_state checkbox_recursive; -textbox_state textbox_search_text; -textbox_state textbox_path; -textbox_state textbox_file_filter; -button_state button_select_directory; -button_state button_find_text; -button_state button_cancel; -/////////////////////////////// - ui_context global_ui_context; u32 ui_get_id(); @@ -169,6 +159,7 @@ char* name_of_month(s32 month); void ui_set_style(u16 style); void set_active_textbox(textbox_state *textbox); void ui_set_textbox_text(textbox_state *textbox, char *text); +void ui_set_textbox_active(textbox_state *textbox); // widget initialization checkbox_state ui_create_checkbox(bool selected); |
