mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-10 04:57:00 -04:00
feat: initial arbitrary constrain of slice window images to 500x500
This commit is contained in:
@@ -13,7 +13,7 @@
|
||||
#include <util/rotation.hpp>
|
||||
#include <gfx/gfx.hpp>
|
||||
#include <wx/spinctrl.h>
|
||||
#include <wx/dcbuffer.h>
|
||||
#include <wx/dcbuffer.h>
|
||||
|
||||
// ----------------------------------------------------------------------------- : ImageSlice
|
||||
|
||||
@@ -133,11 +133,11 @@ ImageSliceWindow::ImageSliceWindow(Window* parent, const Image& source, const wx
|
||||
// top row: image editors
|
||||
wxSizer* s2 = new wxBoxSizer(wxHORIZONTAL);
|
||||
wxSizer* s3 = new wxBoxSizer(wxVERTICAL);
|
||||
s3->Add(new wxStaticText(this, wxID_ANY, _LABEL_("original")));
|
||||
s3->Add(new wxStaticText(this, wxID_ANY, _LABEL_2_("original", to_string(slice.source.GetWidth()), to_string(slice.source.GetHeight()))));
|
||||
s3->Add(selector, 1, wxEXPAND | wxTOP, 4);
|
||||
s2->Add(s3, 1, wxEXPAND | wxALL, 4);
|
||||
wxSizer* s4 = new wxBoxSizer(wxVERTICAL);
|
||||
s4->Add(new wxStaticText(this, wxID_ANY, _LABEL_("result")));
|
||||
s4->Add(new wxStaticText(this, wxID_ANY, _LABEL_2_("result", to_string(slice.target_size.GetWidth()), to_string(slice.target_size.GetHeight()))));
|
||||
s4->Add(preview, 0, wxTOP, 4);
|
||||
s2->Add(s4, 0, wxALL, 4);
|
||||
s->Add(s2, 1, wxEXPAND);
|
||||
@@ -390,9 +390,12 @@ wxSize ImageSlicePreview::DoGetBestSize() const {
|
||||
// We know the client size we want, calculate the size that goes with that
|
||||
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;
|
||||
float target_ratio = ((float)slice.target_size.GetWidth()) / ((float)slice.target_size.GetHeight());
|
||||
if (target_ratio > 1.0) {
|
||||
return wxSize(500, 500 / target_ratio);
|
||||
} else {
|
||||
return wxSize(500 * target_ratio, 500);
|
||||
}
|
||||
}
|
||||
|
||||
void ImageSlicePreview::onPaint(wxPaintEvent&) {
|
||||
@@ -474,8 +477,14 @@ ImageSliceSelector::ImageSliceSelector(Window* parent, int id, ImageSlice& slice
|
||||
: wxControl(parent, id, wxDefaultPosition, wxDefaultSize, wxBORDER_THEME)
|
||||
, slice(slice)
|
||||
, mouse_down(false)
|
||||
{
|
||||
SetMinSize(wxSize(400, 300));
|
||||
{
|
||||
|
||||
float target_ratio = ((float) slice.source.GetWidth()) / ((float) slice.source.GetHeight());
|
||||
if (target_ratio > 1.0) {
|
||||
SetMinSize(wxSize(500, 500 / target_ratio));
|
||||
} else {
|
||||
SetMinSize(wxSize(500 * target_ratio, 500));
|
||||
}
|
||||
SetBackgroundStyle(wxBG_STYLE_PAINT);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user