mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-10 04:57:00 -04:00
Merge pull request #23 from haganbmj/slice_margins
fix: correct computed sizes on slice window to properly display margins
This commit is contained in:
@@ -421,12 +421,9 @@ ImageSlicePreview::ImageSlicePreview(Window* parent, int id, ImageSlice& slice,
|
||||
void ImageSlicePreview::update() {
|
||||
bitmap = wxNullBitmap;
|
||||
Refresh(false);
|
||||
}
|
||||
|
||||
wxSize ImageSlicePreview::DoGetBestSize() const {
|
||||
// We know the client size we want, calculate the size that goes with that
|
||||
wxSize ws = GetSize(), cs = GetClientSize();
|
||||
}
|
||||
|
||||
wxSize ImageSlicePreview::getBestSliceSize() const {
|
||||
float target_ratio = ((float)slice.target_size.GetWidth()) / ((float)slice.target_size.GetHeight());
|
||||
if (target_ratio > 1.0) {
|
||||
return wxSize(500, 500 / target_ratio);
|
||||
@@ -435,6 +432,14 @@ wxSize ImageSlicePreview::DoGetBestSize() const {
|
||||
}
|
||||
}
|
||||
|
||||
wxSize ImageSlicePreview::DoGetBestSize() const {
|
||||
// We know the client size we want, calculate the size that goes with that
|
||||
// This helps with applying margins and other spacing necessities.
|
||||
wxSize ws = GetSize(), cs = GetClientSize();
|
||||
|
||||
return getBestSliceSize() + ws - cs;
|
||||
}
|
||||
|
||||
void ImageSlicePreview::onPaint(wxPaintEvent&) {
|
||||
wxPaintDC dc(this);
|
||||
draw(dc);
|
||||
@@ -459,7 +464,7 @@ void ImageSlicePreview::draw(DC& dc) {
|
||||
}
|
||||
|
||||
// Rescale the bitmap based on the available size.
|
||||
auto available_size = DoGetBestSize();
|
||||
auto available_size = getBestSliceSize();
|
||||
bitmap = wxBitmap(bitmap.ConvertToImage().Scale(available_size.GetWidth(), available_size.GetHeight()));
|
||||
}
|
||||
if (bitmap.Ok()) {
|
||||
|
||||
@@ -137,7 +137,8 @@ private:
|
||||
|
||||
// --------------------------------------------------- : Events
|
||||
DECLARE_EVENT_TABLE();
|
||||
|
||||
|
||||
wxSize getBestSliceSize() const;
|
||||
wxSize DoGetBestSize() const override;
|
||||
|
||||
void onLeftDown(wxMouseEvent&);
|
||||
|
||||
Reference in New Issue
Block a user