WIP basic menu
This commit is contained in:
@@ -89,8 +89,7 @@ uint16_t draw_character(pixel_t *framebuffer, const lv_font_t *font, const uint1
|
||||
const uint8_t current_bit_in_byte = bitmap_pixel_index % 8;
|
||||
const uint16_t bitmap_byte_index = glyph_dsc.bitmap_index + (bitmap_pixel_index / 8);
|
||||
const int32_t fb_pixel_x = x_loc + (bitmap_pixel_index % glyph_width) + glyph_ofs_x;
|
||||
const int32_t line_top = y_loc + font->base_line - glyph_height;
|
||||
const int32_t fb_pixel_y = line_top + (bitmap_pixel_index / glyph_width) - glyph_ofs_y;
|
||||
const int32_t fb_pixel_y = y_loc + font->line_height - glyph_height + (bitmap_pixel_index / glyph_width) - glyph_ofs_y - font->base_line;
|
||||
const uint32_t fb_pixel_index = (fb_pixel_y * DISPLAY_WIDTH) + fb_pixel_x;
|
||||
|
||||
const bool bit_on = font_dsc->glyph_bitmap[bitmap_byte_index] & (0x80 >> current_bit_in_byte);
|
||||
|
||||
7
Core/Src/graphics/fonts/runescape_font.c
Normal file
7
Core/Src/graphics/fonts/runescape_font.c
Normal file
@@ -0,0 +1,7 @@
|
||||
#include "fonts/runescape_font.h"
|
||||
|
||||
// This file exists solely to include the font header in its own translation unit
|
||||
// so that the static font_dsc variable doesn't conflict with other fonts.
|
||||
// The font pointer (roboto_bold_font) is defined in the header and exported
|
||||
// for use in other translation units.
|
||||
|
||||
@@ -10,11 +10,11 @@ void draw_menu(const graphical_menu_t *const menu)
|
||||
const uint16_t entry_height = 40;
|
||||
const uint16_t padding_x = 10;
|
||||
const uint16_t padding_y = 0;
|
||||
const pixel_t enabled_text_color = MAKE_PIXEL(31, 63, 31); // White text
|
||||
const pixel_t disabled_text_color = MAKE_PIXEL(15, 31, 15); // Gray text for disabled
|
||||
const pixel_t entry_bg_color = MAKE_PIXEL(15, 15, 15); // Slightly darker for entry background
|
||||
const pixel_t highlighted_bg_color = MAKE_PIXEL(0, 31, 63); // Blue background for highlighted entry
|
||||
const pixel_t highlighted_text_color = MAKE_PIXEL(31, 63, 31); // White text for highlighted entry
|
||||
const pixel_t enabled_text_color = MAKE_PIXEL(0, 0, 0);
|
||||
const pixel_t disabled_text_color = MAKE_PIXEL(128, 128, 128);
|
||||
const pixel_t entry_bg_color = MAKE_PIXEL(255, 255, 255);
|
||||
const pixel_t highlighted_bg_color = MAKE_PIXEL(0, 0, 0);
|
||||
const pixel_t highlighted_text_color = MAKE_PIXEL(255, 255, 0);
|
||||
|
||||
// Ensure selected_entry_idx is within bounds
|
||||
if (selected_entry_idx >= menu->num_entries)
|
||||
@@ -45,7 +45,7 @@ void draw_menu(const graphical_menu_t *const menu)
|
||||
|
||||
// Calculate baseline from top position: baseline = top + (line_height - base_line)
|
||||
const uint16_t text_baseline_y = y_pos + padding_y + (roboto_bold_font.line_height - roboto_bold_font.base_line);
|
||||
draw_string((pixel_t *)framebuffer, &roboto_bold_font,
|
||||
draw_string((pixel_t *)framebuffer, &runescape_font,
|
||||
padding_x, text_baseline_y,
|
||||
entry->title, text_color);
|
||||
}
|
||||
|
||||
@@ -908,7 +908,7 @@ static void MX_GPIO_Init(void)
|
||||
const graphical_menu_t menu_main = {
|
||||
.num_entries = 3,
|
||||
.entries = (graphical_menu_entry_t[]){
|
||||
{.title = "Home", .enabled = true, .highlighted_callback_function = NULL, .highlighted_callback_function_args = NULL, .selected_callback_function = NULL, .selected_callback_function_args = NULL},
|
||||
{.title = "where varock", .enabled = true, .highlighted_callback_function = NULL, .highlighted_callback_function_args = NULL, .selected_callback_function = NULL, .selected_callback_function_args = NULL},
|
||||
{.title = "Settings", .enabled = true, .highlighted_callback_function = NULL, .highlighted_callback_function_args = NULL, .selected_callback_function = NULL, .selected_callback_function_args = NULL},
|
||||
{.title = "About", .enabled = true, .highlighted_callback_function = NULL, .highlighted_callback_function_args = NULL, .selected_callback_function = NULL, .selected_callback_function_args = NULL},
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user