mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-10 04:57:00 -04:00
feat: more slice window alignment options
This commit is contained in:
@@ -540,7 +540,10 @@ label:
|
||||
selection top: &Top
|
||||
selection width: &Width
|
||||
selection height: &Height
|
||||
selection center: Recenter
|
||||
selection center: Center
|
||||
selection center vertically: Center Vertically
|
||||
selection center horizontally: Center Horizontally
|
||||
selection center both: Center Both
|
||||
#zoom: Zoom
|
||||
fix aspect ratio: Fix aspect ratio (width/height)
|
||||
zoom amount: Zoom
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 16 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 384 B |
Binary file not shown.
|
After Width: | Height: | Size: 414 B |
@@ -187,6 +187,10 @@ message_information IMAGE "message_information.png"
|
||||
message_warning IMAGE "message_warning.png"
|
||||
message_error IMAGE "message_error.png"
|
||||
|
||||
shape_align_middle IMAGE "shape_align_middle.png"
|
||||
shape_align_center IMAGE "shape_align_center.png"
|
||||
shape_align_both IMAGE "shape_align_both.png"
|
||||
|
||||
// -------------------------------------------------------- : WX
|
||||
|
||||
//wxBITMAP_STD_COLOURS BITMAP "wx/msw/colours.bmp"
|
||||
|
||||
@@ -51,14 +51,21 @@ void ImageSlice::constrain(PreferedProperty prefer) {
|
||||
}
|
||||
}
|
||||
|
||||
void ImageSlice::centerSelection() {
|
||||
if (selection.GetWidth() < source.GetWidth()) {
|
||||
selection.x = ((source.GetWidth() - selection.GetWidth()) / 2);
|
||||
}
|
||||
|
||||
if (selection.GetHeight() < source.GetHeight()) {
|
||||
selection.y = ((source.GetHeight() - selection.GetHeight()) / 2);
|
||||
}
|
||||
void ImageSlice::centerSelection() {
|
||||
centerSelectionHorizontally();
|
||||
centerSelectionVertically();
|
||||
}
|
||||
|
||||
void ImageSlice::centerSelectionHorizontally() {
|
||||
if (selection.GetWidth() < source.GetWidth()) {
|
||||
selection.x = ((source.GetWidth() - selection.GetWidth()) / 2);
|
||||
}
|
||||
}
|
||||
|
||||
void ImageSlice::centerSelectionVertically() {
|
||||
if (selection.GetHeight() < source.GetHeight()) {
|
||||
selection.y = ((source.GetHeight() - selection.GetHeight()) / 2);
|
||||
}
|
||||
}
|
||||
|
||||
Image ImageSlice::getSlice(double scale) const {
|
||||
@@ -157,7 +164,23 @@ ImageSliceWindow::ImageSliceWindow(Window* parent, const Image& source, const wx
|
||||
s7->Add(width, 0, wxEXPAND);
|
||||
s7->Add(new wxStaticText(this, wxID_ANY, _LABEL_("selection height")), 0, wxALIGN_CENTER_VERTICAL);
|
||||
s7->Add(height, 0, wxEXPAND);
|
||||
s7->Add(new wxButton(this, ID_SELECTION_CENTER, _LABEL_("selection center")), 0, wxALIGN_CENTER, 2);
|
||||
|
||||
s7->Add(new wxStaticText(this, wxID_ANY, _LABEL_("selection center")), 0, wxALIGN_CENTER_VERTICAL);
|
||||
wxBoxSizer* s7A = new wxBoxSizer(wxHORIZONTAL);
|
||||
wxBitmapButton* center_vertically_button = new wxBitmapButton(this, ID_SELECTION_CENTER_VERTICALLY, wxBitmap(load_resource_image(_("shape_align_middle"))));
|
||||
center_vertically_button->SetToolTip(_LABEL_("selection center vertically"));
|
||||
s7A->Add(center_vertically_button);
|
||||
s7A->AddStretchSpacer();
|
||||
|
||||
wxBitmapButton* center_horizontally_button = new wxBitmapButton(this, ID_SELECTION_CENTER_HORIZONTALLY, wxBitmap(load_resource_image(_("shape_align_center"))));
|
||||
center_horizontally_button->SetToolTip(_LABEL_("selection center horizontally"));
|
||||
s7A->Add(center_horizontally_button);
|
||||
s7A->AddStretchSpacer();
|
||||
|
||||
wxBitmapButton* center_button = new wxBitmapButton(this, ID_SELECTION_CENTER, wxBitmap(load_resource_image(_("shape_align_both"))));
|
||||
center_button->SetToolTip(_LABEL_("selection center both"));
|
||||
s7A->Add(center_button);
|
||||
s7->Add(s7A, 1, wxEXPAND, 0);
|
||||
s6->Add(s7, 1, wxEXPAND | wxALL, 4);
|
||||
s5->Add(s6, 0, wxEXPAND | wxALL, 4);
|
||||
s5->AddStretchSpacer(1);
|
||||
@@ -299,11 +322,22 @@ void ImageSliceWindow::onUpdateFromControl(PreferedProperty prefer) {
|
||||
updateControls();
|
||||
}
|
||||
|
||||
void ImageSliceWindow::onSelectionCenter(wxCommandEvent&) {
|
||||
slice.centerSelection();
|
||||
preview->update();
|
||||
selector->update();
|
||||
updateControls();
|
||||
void ImageSliceWindow::onSelectionCenter(wxCommandEvent& ev) {
|
||||
switch (ev.GetId()) {
|
||||
case ID_SELECTION_CENTER:
|
||||
slice.centerSelection();
|
||||
break;
|
||||
case ID_SELECTION_CENTER_HORIZONTALLY:
|
||||
slice.centerSelectionHorizontally();
|
||||
break;
|
||||
case ID_SELECTION_CENTER_VERTICALLY:
|
||||
slice.centerSelectionVertically();
|
||||
break;
|
||||
}
|
||||
|
||||
preview->update();
|
||||
selector->update();
|
||||
updateControls();
|
||||
}
|
||||
|
||||
void ImageSliceWindow::updateControls() {
|
||||
@@ -356,7 +390,9 @@ BEGIN_EVENT_TABLE(ImageSliceWindow, wxDialog)
|
||||
EVT_TEXT (ID_TOP, ImageSliceWindow::onChangeTop)
|
||||
EVT_TEXT (ID_WIDTH, ImageSliceWindow::onChangeWidth)
|
||||
EVT_TEXT (ID_HEIGHT, ImageSliceWindow::onChangeHeight)
|
||||
EVT_BUTTON (ID_SELECTION_CENTER, ImageSliceWindow::onSelectionCenter)
|
||||
EVT_BUTTON (ID_SELECTION_CENTER, ImageSliceWindow::onSelectionCenter)
|
||||
EVT_BUTTON(ID_SELECTION_CENTER_HORIZONTALLY, ImageSliceWindow::onSelectionCenter)
|
||||
EVT_BUTTON(ID_SELECTION_CENTER_VERTICALLY, ImageSliceWindow::onSelectionCenter)
|
||||
EVT_CHECKBOX (ID_FIX_ASPECT, ImageSliceWindow::onChangeFixAspect)
|
||||
EVT_SPINCTRL (ID_ZOOM, ImageSliceWindow::onChangeZoom)
|
||||
EVT_SPINCTRL (ID_ZOOM_X, ImageSliceWindow::onChangeZoomX)
|
||||
|
||||
@@ -43,7 +43,9 @@ public:
|
||||
/// Enforce relations between values
|
||||
void constrain(PreferedProperty prefer = PREFER_NONE);
|
||||
/// Attempt to center the current constraints
|
||||
void centerSelection();
|
||||
void centerSelection();
|
||||
void centerSelectionHorizontally();
|
||||
void centerSelectionVertically();
|
||||
/// Get the sliced image
|
||||
Image getSlice(double scale = 1.0) const;
|
||||
|
||||
|
||||
@@ -272,7 +272,9 @@ enum ControlID {
|
||||
ID_TOP,
|
||||
ID_WIDTH,
|
||||
ID_HEIGHT,
|
||||
ID_SELECTION_CENTER,
|
||||
ID_SELECTION_CENTER,
|
||||
ID_SELECTION_CENTER_HORIZONTALLY,
|
||||
ID_SELECTION_CENTER_VERTICALLY,
|
||||
ID_FIX_ASPECT,
|
||||
ID_ZOOM,
|
||||
ID_ZOOM_X,
|
||||
|
||||
Reference in New Issue
Block a user