From a43920089d9e1cae2048c2ce275275c9536ba3a7 Mon Sep 17 00:00:00 2001 From: Brendan Hagan Date: Tue, 12 Jul 2022 00:17:56 -0400 Subject: [PATCH] feat: more slice window alignment options --- data/en.mse-locale/locale | 5 ++- resource/shape_align_both.png | Bin 0 -> 16233 bytes resource/shape_align_center.png | Bin 0 -> 384 bytes resource/shape_align_middle.png | Bin 0 -> 414 bytes resource/win32_res.rc | 4 ++ src/gui/image_slice_window.cpp | 66 ++++++++++++++++++++++++-------- src/gui/image_slice_window.hpp | 4 +- src/util/window_id.hpp | 4 +- 8 files changed, 65 insertions(+), 18 deletions(-) create mode 100644 resource/shape_align_both.png create mode 100644 resource/shape_align_center.png create mode 100644 resource/shape_align_middle.png diff --git a/data/en.mse-locale/locale b/data/en.mse-locale/locale index dae38dc1..66a4a552 100644 --- a/data/en.mse-locale/locale +++ b/data/en.mse-locale/locale @@ -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 diff --git a/resource/shape_align_both.png b/resource/shape_align_both.png new file mode 100644 index 0000000000000000000000000000000000000000..fe874086e22268c6937b434682da0aa170e3a069 GIT binary patch literal 16233 zcmeI3&u<$=6vxM*MG(}g5=bo^z_>yJmG!QF+bhRa8n+}8E>#-TL_(tL-Ep#t?KR#_ z?c{*?apJ-uQYD1=8@O@ezya|m^umb?Lgmr}610tf@ZPMwUQg^HRV#6sZ8y7b-n{R; z`MjC2FaGMr_4m#!zP3mRIkUD}UWey7ykB@8{=V_o(16E_t<^1;ke6P@J3_ww?gAnD z&-TWqw^?~#H=Rb@u$(H5cN;C}O-S)_w`G{S)QeW>w%uHcJ^1mbSk$(bVz)9CtLAddo)PUf>P=VgF2$Ix4)55k#-gl?x4RTu#sQ<7 zl^f9&r%j`ocvdmBY%ZEB#1olZE}eTfn$!{*RZ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Z6yAF1om>|ST ztKHFR-u%C_TS&rR#$xWUuInG^#ZbZh<7OKK0Sbr!oPg)`=K8c40#>`ki?apTCliRg zlEUj-Ocaa&0ziHzlBp`G6i@TVfL<<@Bqx|guvvfy(7bc&my!0N1m(V4lyq=bRi(Le zNvR9#hi1|)cfp-7Ct3?wOSDEz&|1=(k-c%ksD` e{M&ClW_$rjx>)p&(flj`0000&L4`Lx!Vx>#S23&w$uyhfU-d$K`9~Nd8w!zv$M9@Z1$jp29TFj3j_=8Fw z3{%YI%$@t@b+*~1_I?xG+&ypHkT%yBC*7X`0H;U$*kGH-*D~zj_WsiblwiPy%d>+H zKsFLsCaZ=4DL6hHA;5x{_a@9VN{~#-l-L5WA>DQvR=Nn0X;LB+>N1A`ku;k2zxK4npfSnM_=ZsUd2J2vMpSkH_8s%x1H0<)AI26!ZDKDAdd(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) diff --git a/src/gui/image_slice_window.hpp b/src/gui/image_slice_window.hpp index de86e16d..2a8dcf1b 100644 --- a/src/gui/image_slice_window.hpp +++ b/src/gui/image_slice_window.hpp @@ -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; diff --git a/src/util/window_id.hpp b/src/util/window_id.hpp index 568046be..2506828b 100644 --- a/src/util/window_id.hpp +++ b/src/util/window_id.hpp @@ -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,