Fix DitheringSelector widget issues with UI Scaling changes

This commit is contained in:
David Capello 2020-04-24 12:25:24 -03:00
parent 05e351c10d
commit b6a86e6aea
2 changed files with 18 additions and 4 deletions

View File

@ -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();

View File

@ -28,6 +28,9 @@ namespace app {
render::DitheringAlgorithm ditheringAlgorithm();
render::DitheringMatrix ditheringMatrix();
protected:
void onInitTheme(ui::InitThemeEvent& ev) override;
private:
void regenerate();