From dd286e9f696ebd631af45bca82ca458aafd21728 Mon Sep 17 00:00:00 2001 From: Aldrik Ramaekers Date: Tue, 11 Feb 2020 15:02:55 +0100 Subject: platform work --- src/linux/platform.c | 6 ++++++ src/platform.h | 1 + src/render.c | 7 ++++++- src/ui.c | 4 ++-- src/windows/platform.c | 5 +++++ 5 files changed, 20 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/linux/platform.c b/src/linux/platform.c index 855564b..2019f79 100644 --- a/src/linux/platform.c +++ b/src/linux/platform.c @@ -184,6 +184,12 @@ bool set_active_directory(char *path) return !chdir(path); } + +void platform_delete_file(char *path) +{ + remove(path); +} + bool platform_write_file_content(char *path, const char *mode, char *buffer, s32 len) { bool result = false; diff --git a/src/platform.h b/src/platform.h index b9f242c..796226b 100644 --- a/src/platform.h +++ b/src/platform.h @@ -204,6 +204,7 @@ void get_name_from_path(char *buffer, char *path); void get_directory_from_path(char *buffer, char *path); vec2 platform_get_window_size(platform_window *window); s32 filter_matches(array *filters, char *string, char **matched_filter); +void platform_delete_file(char *path); u64 platform_get_time(time_type time_type, time_precision precision); s32 platform_get_memory_size(); diff --git a/src/render.c b/src/render.c index 4d5c355..11583b1 100644 --- a/src/render.c +++ b/src/render.c @@ -69,10 +69,14 @@ s32 render_text_ellipsed(font *font, s32 x, s32 y, s32 maxw, char *text, color t char *ellipse = "..."; bool in_ellipse = false; + s32 len = utf8len(text); + s32 x_ = x; utf8_int32_t ch; + s32 count = 0; while((text = utf8codepoint(text, &ch)) && ch) { + count++; if (ch == 9) ch = 32; utf8_int32_t ch_next; utf8codepoint(text, &ch_next); @@ -80,6 +84,7 @@ s32 render_text_ellipsed(font *font, s32 x, s32 y, s32 maxw, char *text, color t { ch = 0x3f; } + if (ch == '\n') ch = 0xB6; glyph g = font->glyphs[ch]; @@ -102,7 +107,7 @@ s32 render_text_ellipsed(font *font, s32 x, s32 y, s32 maxw, char *text, color t //kern = stbtt_GetCodepointKernAdvance(&font->info, ch, ch_next); x_ += (g.advance); - if (!in_ellipse && (x_-x) > maxw-(font->glyphs['.'].width*3)) + if (!in_ellipse && (x_-x) > maxw-(font->glyphs['.'].width*3) && count < len-3) { in_ellipse = true; text = ellipse; diff --git a/src/ui.c b/src/ui.c index d0c1a7c..73fa855 100644 --- a/src/ui.c +++ b/src/ui.c @@ -269,7 +269,7 @@ void ui_push_vertical_dragbar() s32 y = global_ui_context.layout.offset_y + global_ui_context.camera->y - WIDGET_PADDING; s32 h = global_ui_context.layout.height; - render_rectangle(x, y, 5, h, global_ui_context.style.border); + render_rectangle(x, y, 2, h, global_ui_context.style.border); } inline void ui_push_menu_item_separator() @@ -391,7 +391,7 @@ bool ui_push_dropdown_item(image *icon, char *title, s32 index) if (icon) { render_image(icon, x+(BUTTON_HORIZONTAL_TEXT_PADDING/2), - y + (h - (h-10))/2, h-10, h-10); + y + (h - (h-6))/2, h-6, h-6); text_x += h-10; } render_text(global_ui_context.font_small, text_x+(BUTTON_HORIZONTAL_TEXT_PADDING/2)-5, text_y, title, global_ui_context.style.foreground); diff --git a/src/windows/platform.c b/src/windows/platform.c index 4b9ae61..dd7b97f 100644 --- a/src/windows/platform.c +++ b/src/windows/platform.c @@ -842,6 +842,11 @@ file_content platform_read_file_content(char *path, const char *mode) return result; } +void platform_delete_file(char *path) +{ + remove(path); +} + bool platform_write_file_content(char *path, const char *mode, char *buffer, s32 len) { bool result = false; -- cgit v1.2.3-70-g09d2