mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-12 21:47: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:
@@ -423,10 +423,7 @@ void ImageSlicePreview::update() {
|
|||||||
Refresh(false);
|
Refresh(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
wxSize ImageSlicePreview::DoGetBestSize() const {
|
wxSize ImageSlicePreview::getBestSliceSize() const {
|
||||||
// We know the client size we want, calculate the size that goes with that
|
|
||||||
wxSize ws = GetSize(), cs = GetClientSize();
|
|
||||||
|
|
||||||
float target_ratio = ((float)slice.target_size.GetWidth()) / ((float)slice.target_size.GetHeight());
|
float target_ratio = ((float)slice.target_size.GetWidth()) / ((float)slice.target_size.GetHeight());
|
||||||
if (target_ratio > 1.0) {
|
if (target_ratio > 1.0) {
|
||||||
return wxSize(500, 500 / target_ratio);
|
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&) {
|
void ImageSlicePreview::onPaint(wxPaintEvent&) {
|
||||||
wxPaintDC dc(this);
|
wxPaintDC dc(this);
|
||||||
draw(dc);
|
draw(dc);
|
||||||
@@ -459,7 +464,7 @@ void ImageSlicePreview::draw(DC& dc) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Rescale the bitmap based on the available size.
|
// 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()));
|
bitmap = wxBitmap(bitmap.ConvertToImage().Scale(available_size.GetWidth(), available_size.GetHeight()));
|
||||||
}
|
}
|
||||||
if (bitmap.Ok()) {
|
if (bitmap.Ok()) {
|
||||||
|
|||||||
@@ -138,6 +138,7 @@ private:
|
|||||||
// --------------------------------------------------- : Events
|
// --------------------------------------------------- : Events
|
||||||
DECLARE_EVENT_TABLE();
|
DECLARE_EVENT_TABLE();
|
||||||
|
|
||||||
|
wxSize getBestSliceSize() const;
|
||||||
wxSize DoGetBestSize() const override;
|
wxSize DoGetBestSize() const override;
|
||||||
|
|
||||||
void onLeftDown(wxMouseEvent&);
|
void onLeftDown(wxMouseEvent&);
|
||||||
|
|||||||
Reference in New Issue
Block a user