1
0
Fork 0

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 60dcc35830
commit b2ba1feb28
2 changed files with 8 additions and 5 deletions

View File

@ -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(&lt))
{
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);

View File

@ -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();
}
}