Skip to content

Commit 285cff1

Browse files
committed
ui: increase keyboard buttons font size
simply make the keyboard buttons text larger. makes it easier to type.
1 parent e55471e commit 285cff1

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

src/ui/c/ui.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,11 @@ extern lv_style_t *nm_style_title()
102102
return &style_title;
103103
}
104104

105+
extern const lv_font_t *nm_font_large()
106+
{
107+
return font_large;
108+
}
109+
105110
/**
106111
* a hack to prevent tabview from switching to the next tab
107112
* on a scroll event, for example coming from a top layer window.
@@ -361,6 +366,7 @@ extern int nm_ui_init_main_tabview(lv_obj_t *scr)
361366
if (virt_keyboard == NULL) {
362367
return -1;
363368
}
369+
lv_obj_set_style_text_font(virt_keyboard, font_large, LV_PART_ITEMS);
364370
lv_obj_set_style_max_height(virt_keyboard, NM_DISP_HOR * 2 / 3, 0);
365371
lv_obj_add_flag(virt_keyboard, LV_OBJ_FLAG_HIDDEN);
366372

src/ui/lvgl.zig

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,9 @@ pub const LvStyle = opaque {
213213
};
214214
};
215215

216+
/// represents lv_font_t in C.
217+
pub const LvFont = opaque {};
218+
216219
/// a simplified color type compatible with LVGL which defines lv_color_t
217220
/// as a union containing an bit-fields struct unsupported in zig cImport.
218221
pub const Color = u16; // originally c.lv_color_t; TODO: comptime switch for u32
@@ -981,6 +984,8 @@ pub const Keyboard = struct {
981984
pub fn new(parent: anytype, mode: Mode) !Keyboard {
982985
const kb = lv_keyboard_create(parent.lvobj) orelse return error.OutOfMemory;
983986
lv_keyboard_set_mode(kb, @intFromEnum(mode));
987+
const sel = LvStyle.Selector{ .part = .item };
988+
lv_obj_set_style_text_font(kb, nm_font_large(), sel.value());
984989
return .{ .lvobj = kb };
985990
}
986991

@@ -1126,6 +1131,8 @@ pub const PosAlign = enum(c.lv_align_t) {
11261131
pub extern fn nm_style_btn_red() *LvStyle; // TODO: make it private
11271132
/// returns a title style with a larger font.
11281133
pub extern fn nm_style_title() *LvStyle; // TODO: make it private
1134+
/// returns default font of large size.
1135+
pub extern fn nm_font_large() *const LvFont; // TODO: make it private
11291136

11301137
// the "native" lv_obj_set/get user_data are static inline, so make our own funcs.
11311138
extern "c" fn nm_obj_userdata(obj: *LvObj) ?*anyopaque;
@@ -1198,6 +1205,7 @@ extern fn lv_obj_remove_style(obj: *LvObj, style: ?*LvStyle, sel: c.lv_style_sel
11981205
extern fn lv_obj_remove_style_all(obj: *LvObj) void;
11991206
extern fn lv_obj_set_style_bg_color(obj: *LvObj, val: Color, sel: c.lv_style_selector_t) void;
12001207
extern fn lv_obj_set_style_text_color(obj: *LvObj, val: Color, sel: c.lv_style_selector_t) void;
1208+
extern fn lv_obj_set_style_text_font(obj: *LvObj, font: *const LvFont, sel: c.lv_style_selector_t) void;
12011209
extern fn lv_obj_set_style_pad_left(obj: *LvObj, val: c.lv_coord_t, sel: c.lv_style_selector_t) void;
12021210
extern fn lv_obj_set_style_pad_right(obj: *LvObj, val: c.lv_coord_t, sel: c.lv_style_selector_t) void;
12031211
extern fn lv_obj_set_style_pad_top(obj: *LvObj, val: c.lv_coord_t, sel: c.lv_style_selector_t) void;

0 commit comments

Comments
 (0)