From e623048abe27f0bd2bc8d63bb9e062928000550e Mon Sep 17 00:00:00 2001 From: Andrew Belt Date: Mon, 4 Feb 2019 22:32:41 -0800 Subject: [PATCH] Fix MenuButton width. Round pixel ratio down. --- src/app/Toolbar.cpp | 2 +- src/window.cpp | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/app/Toolbar.cpp b/src/app/Toolbar.cpp index 46c191b6..0dd213eb 100644 --- a/src/app/Toolbar.cpp +++ b/src/app/Toolbar.cpp @@ -24,7 +24,7 @@ namespace app { struct MenuButton : ui::Button { void step() override { - box.size.x = bndLabelWidth(APP->window->vg, -1, text.c_str()); + box.size.x = bndLabelWidth(APP->window->vg, -1, text.c_str()) + 1.0; widget::Widget::step(); } void draw(const widget::DrawContext &ctx) override { diff --git a/src/window.cpp b/src/window.cpp index 61409b52..bc56da20 100644 --- a/src/window.cpp +++ b/src/window.cpp @@ -209,6 +209,10 @@ Window::Window() { exit(1); } + float pixelRatio; + glfwGetWindowContentScale(win, &pixelRatio, NULL); + INFO("Pixel ratio: %f", pixelRatio); + glfwSetWindowSizeLimits(win, 800, 600, GLFW_DONT_CARE, GLFW_DONT_CARE); if (settings.windowSize.isZero()) { glfwMaximizeWindow(win); @@ -349,7 +353,7 @@ void Window::run() { // Get desired scaling float pixelRatio; glfwGetWindowContentScale(win, &pixelRatio, NULL); - pixelRatio = std::round(pixelRatio); + pixelRatio = std::floor(pixelRatio + 0.25); if (pixelRatio != this->pixelRatio) { APP->event->handleZoom(); this->pixelRatio = pixelRatio;