Use custom font for menu options

This commit is contained in:
RandyTheSilly committed 2026-10-09 03:09:22 -04:00
1 parent 74cbe957ee
commit 317241d294
3 files changed
+37 -8

No files matched your search

+9 -8
View File
@@ -1,4 +1,5 @@
#include "custom_status_bar.h"
#include "sdk_mod.h"
#include <pebble.h>
typedef enum {
@@ -25,17 +26,17 @@ static GFont s_font_chicago;
// constants
#define BAR_HEIGHT 20
#ifdef PBL_RECT
#define MARGIN_H 4
#define MARGIN_V 4
#define MARGIN_X 4
#define MARGIN_Y 4
#else
#define MARGIN_H 0
#define MARGIN_X 0
#if PBL_DISPLAY_WIDTH < 260
#define MARGIN_V 4
#define MARGIN_Y 4
#else
#define MARGIN_V 5
#define MARGIN_Y 5
#endif
#endif
static const GRect s_menu_grect = GRect(MARGIN_H, BAR_HEIGHT + MARGIN_V, PBL_DISPLAY_WIDTH - (MARGIN_H * 2), PBL_DISPLAY_HEIGHT - (MARGIN_V * 2));
static const GRect s_menu_grect = GRect(MARGIN_X, BAR_HEIGHT + MARGIN_Y, PBL_DISPLAY_WIDTH - (MARGIN_X * 2), PBL_DISPLAY_HEIGHT - (MARGIN_Y * 2));
static const char *s_main_menu_options[3] = {"Artists", "Playlists", "Now Playing"};
static uint16_t menu_get_num_rows(MenuLayer *menu_layer, uint16_t section_index, void *context) {
@@ -54,7 +55,7 @@ static uint16_t menu_get_num_rows(MenuLayer *menu_layer, uint16_t section_index,
static void menu_draw_row(GContext *ctx, const Layer *cell_layer, MenuIndex *cell_index, void *context) {
switch (s_current_menu_display) {
case MENU_NAV_DISPLAY_MAIN:
menu_cell_basic_draw(ctx, cell_layer, s_main_menu_options[cell_index->row], NULL, NULL); // TODO draw folder icon for... folders
custom_menu_cell_title_draw(ctx, cell_layer, s_main_menu_options[cell_index->row], NULL, s_font_chicago, MARGIN_X);
break;
case MENU_NAV_DISPLAY_ARTISTS:
case MENU_NAV_DISPLAY_ALBUMS:
@@ -95,7 +96,7 @@ static void main_window_load() {
#endif
layer_add_child(main_window_layer, s_status_bar_layer);
s_divider_layer = layer_create(GRect(MARGIN_H, BAR_HEIGHT + (MARGIN_V / 2), PBL_DISPLAY_WIDTH - (MARGIN_H * 2), 1));
s_divider_layer = layer_create(GRect(MARGIN_X, BAR_HEIGHT + (MARGIN_Y / 2), PBL_DISPLAY_WIDTH - (MARGIN_X * 2), 1));
layer_set_update_proc(s_divider_layer, divider_layer_update_proc);
layer_add_child(main_window_layer, s_divider_layer);
}
+25
View File
@@ -0,0 +1,25 @@
#include <pebble.h>
typedef struct MenuCellLayerConfig {
const char *title;
const char *subtitle;
const char *value;
GFont title_font;
GFont value_font;
GFont subtitle_font;
GTextOverflowMode overflow_mode;
int horizontal_inset;
} MenuCellLayerConfig;
void custom_menu_cell_title_draw(GContext *ctx, const Layer *cell_layer, const char *title, const char *subtitle, GFont font, uint8_t margin_x) {
GRect box = layer_get_bounds(cell_layer);
box.origin.x = margin_x;
box.size.w -= margin_x;
if (subtitle) {
graphics_draw_text(ctx, subtitle, font, GRect(PBL_IF_RECT_ELSE(box.origin.x + margin_x, box.origin.x), box.origin.y + (box.size.h / 2), box.size.w, box.size.h), GTextOverflowModeFill, PBL_IF_RECT_ELSE(GTextAlignmentLeft, GTextAlignmentCenter), NULL);
box.origin.y += box.size.h / 5;
} else {
box.origin.y += box.size.h / 3;
}
graphics_draw_text(ctx, title, font, box, GTextOverflowModeFill, PBL_IF_RECT_ELSE(GTextAlignmentLeft, GTextAlignmentCenter), NULL);
}
+3
View File
@@ -0,0 +1,3 @@
#include "pebble.h"
void custom_menu_cell_title_draw(GContext *ctx, const Layer *cell_layer, const char *title, const char *subtitle, GFont font, uint8_t margin_x);