fix: de-scale slice preview window

This is a workaround, not a good solution. The slice doesn't really handle sizing well and doesn't set great maximum sizes on the elements within it. I _think_ that can be worked around by constraining the preview, but none of that is really properly context aware to the user's screen.
This commit is contained in:
Brendan Hagan
2022-07-03 22:06:31 -04:00
parent 8d38ab074b
commit a7014b9ee4
+10 -3
View File
@@ -388,8 +388,11 @@ void ImageSlicePreview::update() {
wxSize ImageSlicePreview::DoGetBestSize() const {
// We know the client size we want, calculate the size that goes with that
wxSize ws = GetSize(), cs = GetClientSize();
return slice.target_size + ws - cs;
wxSize ws = GetSize(), cs = GetClientSize();
// This just gets it back to 100% scale. Doesn't solve the sizing issue of the overall window.
// All the above are doing appears to be finding margins/borders and accounting for them on a fixed scale.
return slice.target_size / 2 + ws - cs;
}
void ImageSlicePreview::onPaint(wxPaintEvent&) {
@@ -413,7 +416,11 @@ void ImageSlicePreview::draw(DC& dc) {
mdc.SelectObject(wxNullBitmap);
} else {
bitmap = Bitmap(image);
}
}
// Rescale the bitmap based on the available size.
auto available_size = DoGetBestSize();
bitmap = wxBitmap(bitmap.ConvertToImage().Scale(available_size.GetWidth(), available_size.GetHeight()));
}
if (bitmap.Ok()) {
dc.DrawBitmap(bitmap, 0, 0);