fix: make charmap scrollbar hug the panel edge
The scrollbar was placed inside the padded tile grid, leaving a gap above it (below the tabs) and beside it (before the window edge). Give the scrollbar its own viewport spanning the full panel between the tabs and footer, flush to the right window edge, like the Devices/Music apps. The tile grid keeps its margins and simply reserves the scrollbar width plus a gap on its right. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -204,9 +204,6 @@ static constexpr int FOOTER_H = 84;
|
||||
static constexpr int GRID_PAD = 12;
|
||||
static constexpr int CELL_GAP = 6;
|
||||
static constexpr int CELL_TARGET = 54; // desired tile edge in px
|
||||
// Gutter reserved on the right of the tile area for the shared MTK scrollbar
|
||||
// (its 12px track plus a little breathing room from the last tile column).
|
||||
static constexpr int SB_GUTTER = mtk::SCROLLBAR_W + 6;
|
||||
|
||||
static constexpr int TAB_SIZE = 16;
|
||||
static constexpr int CELL_SIZE = 26; // glyph font size inside a tile
|
||||
@@ -238,7 +235,8 @@ static const char* g_tab_labels[SET_COUNT] = {}; // populated from SETS in _sta
|
||||
|
||||
struct Layout {
|
||||
Rect tabs;
|
||||
Rect grid; // interior area available for the tile grid
|
||||
Rect grid; // interior area available for the tile grid (with margins)
|
||||
Rect panel; // full content region between tabs and footer (scrollbar viewport)
|
||||
Rect footer;
|
||||
Rect copy_btn;
|
||||
int cols;
|
||||
@@ -255,13 +253,21 @@ static Layout compute_layout(int w, int h) {
|
||||
L.tabs = { 0, 0, w, TAB_H };
|
||||
int grid_top = TAB_H;
|
||||
L.footer = { 0, h - FOOTER_H, w, FOOTER_H };
|
||||
|
||||
// Scrollbar viewport: the whole panel between tabs and footer, so the
|
||||
// shared MTK scrollbar hugs the window's right edge and spans full height
|
||||
// (matching Devices/Music) — no inset above or beside it.
|
||||
L.panel = { 0, grid_top, w, (h - FOOTER_H) - grid_top };
|
||||
|
||||
// Tile grid keeps left/top/bottom margins; its right edge leaves the
|
||||
// scrollbar's width plus a GRID_PAD gap.
|
||||
L.grid = { GRID_PAD, grid_top + GRID_PAD,
|
||||
w - GRID_PAD * 2, (h - FOOTER_H) - grid_top - GRID_PAD * 2 };
|
||||
w - mtk::SCROLLBAR_W - GRID_PAD * 2,
|
||||
(h - FOOTER_H) - grid_top - GRID_PAD * 2 };
|
||||
if (L.grid.w < CELL_TARGET) L.grid.w = CELL_TARGET;
|
||||
if (L.grid.h < 1) L.grid.h = 1;
|
||||
|
||||
int avail = L.grid.w - SB_GUTTER;
|
||||
if (avail < CELL_TARGET) avail = CELL_TARGET;
|
||||
int avail = L.grid.w;
|
||||
L.cols = (avail + CELL_GAP) / (CELL_TARGET + CELL_GAP);
|
||||
if (L.cols < 1) L.cols = 1;
|
||||
L.cell_w = (avail - CELL_GAP * (L.cols - 1)) / L.cols;
|
||||
@@ -291,7 +297,7 @@ static Rect tile_rect(const Layout& L, int i) {
|
||||
|
||||
static int hit_tile(const Layout& L, int mx, int my) {
|
||||
if (my < L.grid.y || my >= L.grid.y + L.grid.h) return -1;
|
||||
if (mx < L.grid.x || mx >= L.grid.x + L.grid.w - SB_GUTTER) return -1;
|
||||
if (mx < L.grid.x || mx >= L.grid.x + L.grid.w) return -1;
|
||||
for (int i = 0; i < cur_set().count; i++) {
|
||||
Rect r = tile_rect(L, i);
|
||||
if (r.contains(mx, my)) return i;
|
||||
@@ -386,7 +392,7 @@ static void render(Canvas& c) {
|
||||
}
|
||||
|
||||
// ---- Scrollbar (shared MTK widget; no-ops when the set fits) ----
|
||||
Rect sb_track = mtk::scrollbar_track_rect(L.grid);
|
||||
Rect sb_track = mtk::scrollbar_track_rect(L.panel);
|
||||
Rect sb_thumb = mtk::scrollbar_thumb_rect(sb_track, L.content_h, L.grid.h, g_scroll);
|
||||
mtk::draw_scrollbar(c, sb_track, sb_thumb, g_sb_hover, g_sb_dragging, g_theme);
|
||||
|
||||
@@ -461,7 +467,7 @@ static bool handle_mouse(const montauk::abi::WinEvent& ev, int w, int h) {
|
||||
bool released = !(ev.mouse.buttons & 1) && (ev.mouse.prev_buttons & 1);
|
||||
|
||||
// Scrollbar geometry (shared MTK widget).
|
||||
Rect sb_track = mtk::scrollbar_track_rect(L.grid);
|
||||
Rect sb_track = mtk::scrollbar_track_rect(L.panel);
|
||||
Rect sb_thumb = mtk::scrollbar_thumb_rect(sb_track, L.content_h, L.grid.h, g_scroll);
|
||||
bool scrollable = !sb_track.empty() && !sb_thumb.empty();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user