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 top: &Top
|
||||||
selection width: &Width
|
selection width: &Width
|
||||||
selection height: &Height
|
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
|
#zoom: Zoom
|
||||||
fix aspect ratio: Fix aspect ratio (width/height)
|
fix aspect ratio: Fix aspect ratio (width/height)
|
||||||
zoom amount: Zoom
|
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_warning IMAGE "message_warning.png"
|
||||||
message_error IMAGE "message_error.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
|
// -------------------------------------------------------- : WX
|
||||||
|
|
||||||
//wxBITMAP_STD_COLOURS BITMAP "wx/msw/colours.bmp"
|
//wxBITMAP_STD_COLOURS BITMAP "wx/msw/colours.bmp"
|
||||||
|
|||||||
@@ -52,13 +52,20 @@ void ImageSlice::constrain(PreferedProperty prefer) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ImageSlice::centerSelection() {
|
void ImageSlice::centerSelection() {
|
||||||
if (selection.GetWidth() < source.GetWidth()) {
|
centerSelectionHorizontally();
|
||||||
selection.x = ((source.GetWidth() - selection.GetWidth()) / 2);
|
centerSelectionVertically();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (selection.GetHeight() < source.GetHeight()) {
|
void ImageSlice::centerSelectionHorizontally() {
|
||||||
selection.y = ((source.GetHeight() - selection.GetHeight()) / 2);
|
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 {
|
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(width, 0, wxEXPAND);
|
||||||
s7->Add(new wxStaticText(this, wxID_ANY, _LABEL_("selection height")), 0, wxALIGN_CENTER_VERTICAL);
|
s7->Add(new wxStaticText(this, wxID_ANY, _LABEL_("selection height")), 0, wxALIGN_CENTER_VERTICAL);
|
||||||
s7->Add(height, 0, wxEXPAND);
|
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);
|
s6->Add(s7, 1, wxEXPAND | wxALL, 4);
|
||||||
s5->Add(s6, 0, wxEXPAND | wxALL, 4);
|
s5->Add(s6, 0, wxEXPAND | wxALL, 4);
|
||||||
s5->AddStretchSpacer(1);
|
s5->AddStretchSpacer(1);
|
||||||
@@ -299,11 +322,22 @@ void ImageSliceWindow::onUpdateFromControl(PreferedProperty prefer) {
|
|||||||
updateControls();
|
updateControls();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImageSliceWindow::onSelectionCenter(wxCommandEvent&) {
|
void ImageSliceWindow::onSelectionCenter(wxCommandEvent& ev) {
|
||||||
slice.centerSelection();
|
switch (ev.GetId()) {
|
||||||
preview->update();
|
case ID_SELECTION_CENTER:
|
||||||
selector->update();
|
slice.centerSelection();
|
||||||
updateControls();
|
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() {
|
void ImageSliceWindow::updateControls() {
|
||||||
@@ -357,6 +391,8 @@ BEGIN_EVENT_TABLE(ImageSliceWindow, wxDialog)
|
|||||||
EVT_TEXT (ID_WIDTH, ImageSliceWindow::onChangeWidth)
|
EVT_TEXT (ID_WIDTH, ImageSliceWindow::onChangeWidth)
|
||||||
EVT_TEXT (ID_HEIGHT, ImageSliceWindow::onChangeHeight)
|
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_CHECKBOX (ID_FIX_ASPECT, ImageSliceWindow::onChangeFixAspect)
|
||||||
EVT_SPINCTRL (ID_ZOOM, ImageSliceWindow::onChangeZoom)
|
EVT_SPINCTRL (ID_ZOOM, ImageSliceWindow::onChangeZoom)
|
||||||
EVT_SPINCTRL (ID_ZOOM_X, ImageSliceWindow::onChangeZoomX)
|
EVT_SPINCTRL (ID_ZOOM_X, ImageSliceWindow::onChangeZoomX)
|
||||||
|
|||||||
@@ -44,6 +44,8 @@ public:
|
|||||||
void constrain(PreferedProperty prefer = PREFER_NONE);
|
void constrain(PreferedProperty prefer = PREFER_NONE);
|
||||||
/// Attempt to center the current constraints
|
/// Attempt to center the current constraints
|
||||||
void centerSelection();
|
void centerSelection();
|
||||||
|
void centerSelectionHorizontally();
|
||||||
|
void centerSelectionVertically();
|
||||||
/// Get the sliced image
|
/// Get the sliced image
|
||||||
Image getSlice(double scale = 1.0) const;
|
Image getSlice(double scale = 1.0) const;
|
||||||
|
|
||||||
|
|||||||
@@ -273,6 +273,8 @@ enum ControlID {
|
|||||||
ID_WIDTH,
|
ID_WIDTH,
|
||||||
ID_HEIGHT,
|
ID_HEIGHT,
|
||||||
ID_SELECTION_CENTER,
|
ID_SELECTION_CENTER,
|
||||||
|
ID_SELECTION_CENTER_HORIZONTALLY,
|
||||||
|
ID_SELECTION_CENTER_VERTICALLY,
|
||||||
ID_FIX_ASPECT,
|
ID_FIX_ASPECT,
|
||||||
ID_ZOOM,
|
ID_ZOOM,
|
||||||
ID_ZOOM_X,
|
ID_ZOOM_X,
|
||||||
|
|||||||
Reference in New Issue
Block a user