fix: fix text overlap bug in file dialogs and remove unnecessary hint in Keyboard applet
This commit is contained in:
@@ -12,4 +12,4 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#define MONTAUK_BUILD_NUMBER 116
|
#define MONTAUK_BUILD_NUMBER 119
|
||||||
|
|||||||
@@ -248,6 +248,33 @@ void fit_text_end(const char* src, char* out, int out_len, int max_px) {
|
|||||||
safe_copy(out, out_len, src);
|
safe_copy(out, out_len, src);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void fit_text_start(const char* src, char* out, int out_len, int max_px) {
|
||||||
|
if (!src || !src[0] || out_len <= 0) {
|
||||||
|
if (out_len > 0) out[0] = '\0';
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (text_width(src) <= max_px) {
|
||||||
|
safe_copy(out, out_len, src);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Grid labels must fit their cell in pixels. Character-count truncation is
|
||||||
|
// insufficient for the proportional system font and lets wide names paint
|
||||||
|
// over the adjacent label.
|
||||||
|
int keep = montauk::slen(src);
|
||||||
|
if (keep > out_len - 3) keep = out_len - 3;
|
||||||
|
while (keep > 0) {
|
||||||
|
for (int i = 0; i < keep; i++) out[i] = src[i];
|
||||||
|
out[keep] = '.';
|
||||||
|
out[keep + 1] = '.';
|
||||||
|
out[keep + 2] = '\0';
|
||||||
|
if (text_width(out) <= max_px) return;
|
||||||
|
keep--;
|
||||||
|
}
|
||||||
|
|
||||||
|
safe_copy(out, out_len, "..");
|
||||||
|
}
|
||||||
|
|
||||||
// Path bar: the original plain white/square input look, but rendering the MTK
|
// Path bar: the original plain white/square input look, but rendering the MTK
|
||||||
// text-input state so selection highlighting (and the right-click menu, drawn
|
// text-input state so selection highlighting (and the right-click menu, drawn
|
||||||
// separately) keep working.
|
// separately) keep working.
|
||||||
@@ -864,18 +891,10 @@ void draw_grid_entries(Canvas& c, FileDialogState* st, const FileDialogLayout& l
|
|||||||
else if (st->is_dir[i] && st->icons.icon_folder_lg.pixels) icon = &st->icons.icon_folder_lg;
|
else if (st->is_dir[i] && st->icons.icon_folder_lg.pixels) icon = &st->icons.icon_folder_lg;
|
||||||
if (icon->pixels) c.icon(icon_x, icon_y, *icon);
|
if (icon->pixels) c.icon(icon_x, icon_y, *icon);
|
||||||
|
|
||||||
char label[16];
|
char label[64];
|
||||||
int nlen = montauk::slen(st->entry_names[i]);
|
fit_text_start(st->entry_names[i], label, sizeof(label), GRID_CELL_W - 4);
|
||||||
if (nlen > 11) {
|
|
||||||
for (int k = 0; k < 9; k++) label[k] = st->entry_names[i][k];
|
|
||||||
label[9] = '.';
|
|
||||||
label[10] = '.';
|
|
||||||
label[11] = '\0';
|
|
||||||
} else {
|
|
||||||
safe_copy(label, sizeof(label), st->entry_names[i]);
|
|
||||||
}
|
|
||||||
int tx = cell_x + (GRID_CELL_W - text_width(label)) / 2;
|
int tx = cell_x + (GRID_CELL_W - text_width(label)) / 2;
|
||||||
if (tx < cell_x) tx = cell_x;
|
if (tx < cell_x + 2) tx = cell_x + 2;
|
||||||
int ty = icon_y + GRID_ICON + 2;
|
int ty = icon_y + GRID_ICON + 2;
|
||||||
if (ty >= lo.content_rect.y && ty + system_font_height() <= lo.content_rect.y + lo.content_rect.h)
|
if (ty >= lo.content_rect.y && ty + system_font_height() <= lo.content_rect.y + lo.content_rect.h)
|
||||||
c.text(tx, ty, label, colors::TEXT_COLOR);
|
c.text(tx, ty, label, colors::TEXT_COLOR);
|
||||||
|
|||||||
@@ -145,9 +145,6 @@ static void draw_layouts_tab(Canvas& c, const mtk::Theme& theme) {
|
|||||||
g_win.width - PAD * 2, theme);
|
g_win.width - PAD * 2, theme);
|
||||||
|
|
||||||
c.text(PAD, list_header_y(), "AVAILABLE LAYOUTS", theme.text_muted);
|
c.text(PAD, list_header_y(), "AVAILABLE LAYOUTS", theme.text_muted);
|
||||||
const char* hint = "Click a layout to make it active";
|
|
||||||
c.text(g_win.width - PAD - text_width(hint), list_header_y(),
|
|
||||||
hint, theme.text_muted);
|
|
||||||
|
|
||||||
for (int i = 0; i < g_state.registry.count; i++) {
|
for (int i = 0; i < g_state.registry.count; i++) {
|
||||||
Rect row = row_rect(i);
|
Rect row = row_rect(i);
|
||||||
|
|||||||
Reference in New Issue
Block a user