From b5e7bbc5ad898ee833636ff9e1d4a0e7bd6b595a Mon Sep 17 00:00:00 2001 From: wangqr Date: Wed, 25 Dec 2019 18:38:42 -0500 Subject: [PATCH] Submit "align to video" on double click Fix wangqr/Aegisub#34 --- src/dialog_align.cpp | 8 +++----- src/image_position_picker.cpp | 5 +++++ 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/dialog_align.cpp b/src/dialog_align.cpp index 5243d2197..2de54b2c0 100644 --- a/src/dialog_align.cpp +++ b/src/dialog_align.cpp @@ -76,7 +76,7 @@ namespace { void update_from_textbox(wxCommandEvent&); bool check_exists(int pos, int x, int y, int* lrud, double* orig, unsigned char tolerance); - void process(wxCommandEvent&); + void process(wxEvent&); public: DialogAlignToVideo(agi::Context* context); ~DialogAlignToVideo(); @@ -137,6 +137,7 @@ namespace { CenterOnParent(); Bind(wxEVT_BUTTON, &DialogAlignToVideo::process, this, wxID_OK); + Bind(wxEVT_LEFT_DCLICK, &DialogAlignToVideo::process, this, preview_frame->GetId()); SetIcon(GETICON(button_align_16)); if (maximized) wxDialog::Maximize(true); @@ -255,7 +256,7 @@ namespace { return true; } - void DialogAlignToVideo::process(wxCommandEvent & evt) + void DialogAlignToVideo::process(wxEvent &) { auto n_frames = provider->GetFrameCount(); auto w = provider->GetWidth(); @@ -265,19 +266,16 @@ namespace { if (!selected_x->GetValue().ToLong(&lx) || !selected_y->GetValue().ToLong(&ly) || !selected_tolerance->GetValue().ToLong(<)) { wxMessageBox(_("Bad x or y position or tolerance value!")); - evt.Skip(); return; } if (lx < 0 || ly < 0 || lx >= w || ly >= h) { wxMessageBox(wxString::Format(_("Bad x or y position! Require: 0 <= x < %i, 0 <= y < %i"), w, h)); - evt.Skip(); return; } if (lt < 0 || lt > 255) { wxMessageBox(_("Bad tolerance value! Require: 0 <= torlerance <= 255")); - evt.Skip(); return; } int x = int(lx), y = int(ly); diff --git a/src/image_position_picker.cpp b/src/image_position_picker.cpp index 2bc9c6f89..5912b4fc3 100644 --- a/src/image_position_picker.cpp +++ b/src/image_position_picker.cpp @@ -124,4 +124,9 @@ void ImagePositionPicker::OnMouseEvent(wxMouseEvent& evt) if (x >= 0 && x < w && y >= 0 && y < h) update(x, y, image.GetRed(x, y), image.GetGreen(x, y), image.GetBlue(x, y)); } + else if (evt.LeftDClick()) { + // Propagate the double click event to submit + evt.ResumePropagation(wxEVENT_PROPAGATE_MAX); + evt.Skip(); + } }