From 3a4477413a62ef928c26c4137dfc6668d22df297 Mon Sep 17 00:00:00 2001 From: Michael Drake Date: Sat, 3 Aug 2019 11:00:09 +0100 Subject: [PATCH] Framebuffer: Add keyboard controls for scaling. --- frontends/framebuffer/gui.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/frontends/framebuffer/gui.c b/frontends/framebuffer/gui.c index 74f6100a5..6cbcca85d 100644 --- a/frontends/framebuffer/gui.c +++ b/frontends/framebuffer/gui.c @@ -910,6 +910,40 @@ fb_browser_window_input(fbtk_widget_t *widget, fbtk_callback_info *cbi) widget_scroll_y(gw, 100, false); break; + case NSFB_KEY_MINUS: + if (modifier & FBTK_MOD_RCTRL || + modifier & FBTK_MOD_LCTRL) { + float scale = browser_window_get_scale(gw->bw); + scale -= 0.1; + if (scale < 0.1) { + scale = 0.1; + } + if (scale > 0.95 && scale < 1.05) { + scale = 1; + } + browser_window_set_scale(gw->bw, scale, true); + } + break; + + case NSFB_KEY_EQUALS: /* PLUS */ + if (modifier & FBTK_MOD_RCTRL || + modifier & FBTK_MOD_LCTRL) { + float scale = browser_window_get_scale(gw->bw); + scale += 0.1; + if (scale > 0.95 && scale < 1.05) { + scale = 1; + } + browser_window_set_scale(gw->bw, scale, true); + } + break; + + case NSFB_KEY_0: /* PLUS */ + if (modifier & FBTK_MOD_RCTRL || + modifier & FBTK_MOD_LCTRL) { + browser_window_set_scale(gw->bw, 1, true); + } + break; + case NSFB_KEY_RSHIFT: modifier |= FBTK_MOD_RSHIFT; break;