ui: add button for slice selection centering

This commit is contained in:
Brendan Hagan
2022-06-14 00:29:06 -04:00
parent c2fea6bd96
commit 8b888f8d5a
5 changed files with 14 additions and 2 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
cmake_minimum_required(VERSION 3.13)
project(magicseteditor VERSION 2.1.2)
project(magicseteditor VERSION 2.1.3)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED True)
+1
View File
@@ -517,6 +517,7 @@ label:
selection top: &Top
selection width: &Width
selection height: &Height
selection center: Recenter
#zoom: Zoom
fix aspect ratio: Fix aspect ratio (width/height)
zoom amount: Zoom
+10 -1
View File
@@ -147,7 +147,7 @@ ImageSliceWindow::ImageSliceWindow(Window* parent, const Image& source, const wx
s5->Add(size, 0, wxEXPAND | wxALL, 4);
s5->AddStretchSpacer(1);
wxSizer* s6 = new wxStaticBoxSizer(wxVERTICAL, this, _LABEL_("selection"));
wxSizer* s7 = new wxFlexGridSizer(0, 2, 4, 5);
wxSizer* s7 = new wxFlexGridSizer(0, 2, 5, 5);
s7->Add(new wxStaticText(this, wxID_ANY, _LABEL_("selection left")), 0, wxALIGN_CENTER_VERTICAL);
s7->Add(left, 0, wxEXPAND);
s7->Add(new wxStaticText(this, wxID_ANY, _LABEL_("selection top")), 0, wxALIGN_CENTER_VERTICAL);
@@ -156,6 +156,7 @@ 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);
s6->Add(s7, 1, wxEXPAND | wxALL, 4);
s5->Add(s6, 0, wxEXPAND | wxALL, 4);
s5->AddStretchSpacer(1);
@@ -297,6 +298,13 @@ void ImageSliceWindow::onUpdateFromControl(PreferedProperty prefer) {
updateControls();
}
void ImageSliceWindow::onSelectionCenter(wxCommandEvent&) {
slice.centerSelection();
preview->update();
selector->update();
updateControls();
}
void ImageSliceWindow::updateControls() {
if (slice.selection.width == slice.target_size.GetWidth() && slice.selection.height == slice.target_size.GetHeight()) {
size->SetSelection(0); // original size
@@ -347,6 +355,7 @@ 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_CHECKBOX (ID_FIX_ASPECT, ImageSliceWindow::onChangeFixAspect)
EVT_SPINCTRL (ID_ZOOM, ImageSliceWindow::onChangeZoom)
EVT_SPINCTRL (ID_ZOOM_X, ImageSliceWindow::onChangeZoomX)
+1
View File
@@ -93,6 +93,7 @@ private:
void onChangeTop (wxCommandEvent&);
void onChangeWidth (wxCommandEvent&);
void onChangeHeight (wxCommandEvent&);
void onSelectionCenter(wxCommandEvent&);
void onChangeFixAspect (wxCommandEvent&);
void onChangeZoom (wxSpinEvent&);
void onChangeZoomX (wxSpinEvent&);
+1
View File
@@ -267,6 +267,7 @@ enum ControlID {
ID_TOP,
ID_WIDTH,
ID_HEIGHT,
ID_SELECTION_CENTER,
ID_FIX_ASPECT,
ID_ZOOM,
ID_ZOOM_X,