Submit "align to video" on double click

Fix wangqr/Aegisub#34
This commit is contained in:
wangqr 2019-12-25 18:38:42 -05:00 committed by arch1t3cht
parent 42248eabad
commit b5e7bbc5ad
2 changed files with 8 additions and 5 deletions

View File

@ -76,7 +76,7 @@ namespace {
void update_from_textbox(wxCommandEvent&); void update_from_textbox(wxCommandEvent&);
bool check_exists(int pos, int x, int y, int* lrud, double* orig, unsigned char tolerance); bool check_exists(int pos, int x, int y, int* lrud, double* orig, unsigned char tolerance);
void process(wxCommandEvent&); void process(wxEvent&);
public: public:
DialogAlignToVideo(agi::Context* context); DialogAlignToVideo(agi::Context* context);
~DialogAlignToVideo(); ~DialogAlignToVideo();
@ -137,6 +137,7 @@ namespace {
CenterOnParent(); CenterOnParent();
Bind(wxEVT_BUTTON, &DialogAlignToVideo::process, this, wxID_OK); Bind(wxEVT_BUTTON, &DialogAlignToVideo::process, this, wxID_OK);
Bind(wxEVT_LEFT_DCLICK, &DialogAlignToVideo::process, this, preview_frame->GetId());
SetIcon(GETICON(button_align_16)); SetIcon(GETICON(button_align_16));
if (maximized) if (maximized)
wxDialog::Maximize(true); wxDialog::Maximize(true);
@ -255,7 +256,7 @@ namespace {
return true; return true;
} }
void DialogAlignToVideo::process(wxCommandEvent & evt) void DialogAlignToVideo::process(wxEvent &)
{ {
auto n_frames = provider->GetFrameCount(); auto n_frames = provider->GetFrameCount();
auto w = provider->GetWidth(); auto w = provider->GetWidth();
@ -265,19 +266,16 @@ namespace {
if (!selected_x->GetValue().ToLong(&lx) || !selected_y->GetValue().ToLong(&ly) || !selected_tolerance->GetValue().ToLong(&lt)) if (!selected_x->GetValue().ToLong(&lx) || !selected_y->GetValue().ToLong(&ly) || !selected_tolerance->GetValue().ToLong(&lt))
{ {
wxMessageBox(_("Bad x or y position or tolerance value!")); wxMessageBox(_("Bad x or y position or tolerance value!"));
evt.Skip();
return; return;
} }
if (lx < 0 || ly < 0 || lx >= w || ly >= h) 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)); wxMessageBox(wxString::Format(_("Bad x or y position! Require: 0 <= x < %i, 0 <= y < %i"), w, h));
evt.Skip();
return; return;
} }
if (lt < 0 || lt > 255) if (lt < 0 || lt > 255)
{ {
wxMessageBox(_("Bad tolerance value! Require: 0 <= torlerance <= 255")); wxMessageBox(_("Bad tolerance value! Require: 0 <= torlerance <= 255"));
evt.Skip();
return; return;
} }
int x = int(lx), y = int(ly); int x = int(lx), y = int(ly);

View File

@ -124,4 +124,9 @@ void ImagePositionPicker::OnMouseEvent(wxMouseEvent& evt)
if (x >= 0 && x < w && y >= 0 && y < h) if (x >= 0 && x < w && y >= 0 && y < h)
update(x, y, image.GetRed(x, y), image.GetGreen(x, y), image.GetBlue(x, y)); 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();
}
} }