feat: use icons in spreadsheet app toolbar

This commit is contained in:
2026-04-08 20:13:57 +02:00
parent c3a5a1c739
commit 27fcdd425f
3 changed files with 63 additions and 6 deletions
+17 -6
View File
@@ -5,6 +5,8 @@
*/
#include "spreadsheet.h"
#include <gui/canvas.hpp>
#include <gui/svg.hpp>
void render(uint32_t* pixels) {
px_fill(pixels, g_win_w, g_win_h, 0, 0, g_win_w, g_win_h, BG_COLOR);
@@ -15,6 +17,9 @@ void render(uint32_t* pixels) {
Cell* cur_cell = &g_cells[g_sel_row][g_sel_col];
// Canvas for icons
gui::Canvas c(pixels, g_win_w, g_win_h);
int bx = 4;
auto tb_btn = [&](int w, bool active, const char* label) {
Color bg = active ? TB_BTN_ACTIVE : TB_BTN_BG;
@@ -28,20 +33,26 @@ void render(uint32_t* pixels) {
}
bx += w + 4;
};
auto tb_icon_btn = [&](const SvgIcon& icon) {
px_fill_rounded(pixels, g_win_w, g_win_h, bx, TB_BTN_Y, TB_BTN_SIZE, TB_BTN_SIZE, TB_BTN_RAD, TB_BTN_BG);
if (icon.pixels)
c.icon(bx + 4, TB_BTN_Y + 4, icon);
bx += TB_BTN_SIZE + 4;
};
auto tb_sep = [&]() {
px_vline(pixels, g_win_w, g_win_h, bx, 6, TOOLBAR_H - 12, TB_SEP_COLOR);
bx += 8;
};
// Open / Save
tb_btn(36, false, "Open");
tb_btn(36, false, "Save");
// Open / Save (icon buttons)
tb_icon_btn(g_icon_folder);
tb_icon_btn(g_icon_save);
tb_sep();
// Cut/Copy/Paste
tb_btn(28, false, "Cut");
tb_btn(36, false, "Copy");
tb_btn(36, false, "Paste");
tb_icon_btn(g_icon_cut);
tb_icon_btn(g_icon_copy);
tb_icon_btn(g_icon_paste);
tb_sep();
// Bold