Fix displaying ModelBmp on small surfaces

Resolves #269
This commit is contained in:
Raphael Coeffic
2021-06-19 11:09:48 -07:00
committed by eshifri
parent 3baa932f47
commit 83375befc1
2 changed files with 26 additions and 2 deletions
+20 -1
View File
@@ -56,7 +56,7 @@ class Layout2x4: public Layout
getOptionValue(OPTION_PANEL1_BACKGROUND)->boolValue = true;
getOptionValue(OPTION_PANEL1_COLOR)->unsignedValue = RGB(77,112,203);
getOptionValue(OPTION_PANEL2_BACKGROUND)->boolValue = true;
getOptionValue(OPTION_PANEL2_COLOR)->unsignedValue = RGB(77,112,203);
getOptionValue(OPTION_PANEL2_COLOR)->unsignedValue = RGB(7,1,2);
}
unsigned int getZonesCount() const override
@@ -79,6 +79,25 @@ class Layout2x4: public Layout
return zone;
}
void paint(BitmapBuffer * dc) override;
};
void Layout2x4::paint(BitmapBuffer* dc)
{
rect_t fullScreen = Layout::getMainZone();
fullScreen.w /=2;
if (getOptionValue(OPTION_PANEL1_BACKGROUND)->boolValue) {
lcdSetColor(getOptionValue(OPTION_PANEL1_COLOR)->unsignedValue);
dc->drawSolidFilledRect(fullScreen.x, fullScreen.y, fullScreen.w, fullScreen.h, CUSTOM_COLOR);
}
if (getOptionValue(OPTION_PANEL2_BACKGROUND)->boolValue) {
fullScreen.x += fullScreen.w;
lcdSetColor(getOptionValue(OPTION_PANEL2_COLOR)->unsignedValue);
dc->drawSolidFilledRect(fullScreen.x, fullScreen.y, fullScreen.w, fullScreen.h, CUSTOM_COLOR);
}
Layout::paint(dc);
}
BaseLayoutFactory<Layout2x4> layout2x4("Layout2x4", "2 x 4", LBM_LAYOUT_2x4, OPTIONS_LAYOUT_2x4);
+6 -1
View File
@@ -97,7 +97,12 @@ class ModelBitmapWidget: public Widget
TRACE("could not load bitmap '%s'", filename.c_str());
return;
}
buffer->drawScaledBitmap(bitmap.get(), 0, 38, width(), height() - 38);
if (rect.h >= 96 && rect.w >= 120) {
buffer->drawScaledBitmap(bitmap.get(), 0, 38, width(), height() - 38);
} else {
buffer->drawScaledBitmap(bitmap.get(), 0, 0, width(), height());
}
}
}
};