From b6a86e6aea32f32827f2870d22d9ee3b394aaa53 Mon Sep 17 00:00:00 2001 From: David Capello Date: Fri, 24 Apr 2020 12:25:24 -0300 Subject: [PATCH] Fix DitheringSelector widget issues with UI Scaling changes --- src/app/ui/dithering_selector.cpp | 19 +++++++++++++++---- src/app/ui/dithering_selector.h | 3 +++ 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/src/app/ui/dithering_selector.cpp b/src/app/ui/dithering_selector.cpp index 33c3b6f6a..29c3f1f27 100644 --- a/src/app/ui/dithering_selector.cpp +++ b/src/app/ui/dithering_selector.cpp @@ -124,8 +124,8 @@ private: void onSizeHint(SizeHintEvent& ev) override { gfx::Size sz = textSize(); - sz.w = std::max(sz.w, preview()->width()) + 4*guiscale(); - sz.h += 6*guiscale() + preview()->height(); + sz.w = std::max(sz.w, preview()->width()*guiscale()) + 4*guiscale(); + sz.h += 6*guiscale() + preview()->height()*guiscale(); ev.setSizeHint(sz); } @@ -153,8 +153,12 @@ private: rc.y+2*guiscale())); g->drawRgbaSurface( preview(), - rc.x+2*guiscale(), - rc.y+4*guiscale()+textsz.h); + preview()->bounds(), + gfx::Rect( + rc.x+2*guiscale(), + rc.y+4*guiscale()+textsz.h, + preview()->width()*guiscale(), + preview()->height()*guiscale())); } bool m_matrixOnly; @@ -181,6 +185,13 @@ DitheringSelector::DitheringSelector(Type type) regenerate(); } +void DitheringSelector::onInitTheme(ui::InitThemeEvent& ev) +{ + ComboBox::onInitTheme(ev); + if (getItem(0)) + setSizeHint(getItem(0)->sizeHint()); +} + void DitheringSelector::regenerate() { deleteAllItems(); diff --git a/src/app/ui/dithering_selector.h b/src/app/ui/dithering_selector.h index 686502351..ffbd64936 100644 --- a/src/app/ui/dithering_selector.h +++ b/src/app/ui/dithering_selector.h @@ -28,6 +28,9 @@ namespace app { render::DitheringAlgorithm ditheringAlgorithm(); render::DitheringMatrix ditheringMatrix(); + protected: + void onInitTheme(ui::InitThemeEvent& ev) override; + private: void regenerate();