Add commands for the video display context menu items

Originally committed to SVN as r5562.
This commit is contained in:
Thomas Goyne 2011-08-27 06:30:29 +00:00
parent ca6d5b1f3e
commit e2f464c94f
3 changed files with 85 additions and 0 deletions

View File

@ -225,6 +225,24 @@ struct video_close : public validator_video_loaded {
} }
}; };
/// Copy the current coordinates of the mouse over the video to the clipboard.
struct video_copy_coordinates : public validator_video_loaded {
CMD_NAME("video/copy_coordinates")
STR_MENU("Copy coordinates to Clipboard")
STR_DISP("Copy coordinates to Clipboard")
STR_HELP("Copy the current coordinates of the mouse over the video to the clipboard.")
void operator()(agi::Context *c) {
if (wxTheClipboard->Open()) {
int x, y;
c->videoBox->videoDisplay->GetMousePosition(&x, &y);
c->videoBox->videoDisplay->ToScriptCoords(&x, &y);
wxTheClipboard->SetData(new wxTextDataObject(wxString::Format("%d,%d", x, y)));
wxTheClipboard->Close();
}
}
};
/// Detach video, displaying it in a separate Window. /// Detach video, displaying it in a separate Window.
struct video_detach : public validator_video_loaded { struct video_detach : public validator_video_loaded {
CMD_NAME("video/detach") CMD_NAME("video/detach")
@ -280,6 +298,36 @@ struct video_focus_seek : public validator_video_loaded {
} }
}; };
/// Copy the current video frame to the clipboard, with subtitles
struct video_frame_copy : public validator_video_loaded {
CMD_NAME("video/frame/copy")
STR_MENU("Copy image to Clipboard")
STR_DISP("Copy image to Clipboard")
STR_HELP("Copy the currently displayed frame to the clipboard.")
void operator()(agi::Context *c) {
if (wxTheClipboard->Open()) {
wxTheClipboard->SetData(new wxBitmapDataObject(wxBitmap(c->videoController->GetFrame(c->videoController->GetFrameN())->GetImage(),24)));
wxTheClipboard->Close();
}
}
};
/// Copy the current video frame to the clipboard, without subtitles
struct video_frame_copy_raw : public validator_video_loaded {
CMD_NAME("video/frame/copy/raw")
STR_MENU("Copy image to Clipboard (no subtitles)")
STR_DISP("Copy image to Clipboard (no subtitles)")
STR_HELP("Copy the currently displayed frame to the clipboard, without the subtitles.")
void operator()(agi::Context *c) {
if (wxTheClipboard->Open()) {
wxTheClipboard->SetData(new wxBitmapDataObject(wxBitmap(c->videoController->GetFrame(c->videoController->GetFrameN(), true)->GetImage(),24)));
wxTheClipboard->Close();
}
}
};
/// Seek to the next frame. /// Seek to the next frame.
struct video_frame_next : public validator_video_loaded { struct video_frame_next : public validator_video_loaded {
CMD_NAME("video/frame/next") CMD_NAME("video/frame/next")
@ -427,6 +475,30 @@ struct video_frame_prev_large : public validator_video_loaded {
} }
}; };
/// Save the current video frame, with subtitles (if any)
struct video_frame_save : public validator_video_loaded {
CMD_NAME("video/frame/save")
STR_MENU("Save PNG snapshot")
STR_DISP("Save PNG snapshot")
STR_HELP("Save the currently displayed frame to a PNG file in the video's directory.")
void operator()(agi::Context *c) {
c->videoController->SaveSnapshot(false);
}
};
/// Save the current video frame, without subtitles
struct video_frame_save_raw : public validator_video_loaded {
CMD_NAME("video/frame/save/raw")
STR_MENU("Save PNG snapshot (no subtitles)")
STR_DISP("Save PNG snapshot (no subtitles)")
STR_HELP("Save the currently displayed frame without the subtitles to a PNG file in the video's directory.")
void operator()(agi::Context *c) {
c->videoController->SaveSnapshot(true);
}
};
/// Jump to frame or time. /// Jump to frame or time.
struct video_jump : public validator_video_loaded { struct video_jump : public validator_video_loaded {
CMD_NAME("video/jump") CMD_NAME("video/jump")
@ -669,9 +741,12 @@ namespace cmd {
reg(new video_aspect_full); reg(new video_aspect_full);
reg(new video_aspect_wide); reg(new video_aspect_wide);
reg(new video_close); reg(new video_close);
reg(new video_copy_coordinates);
reg(new video_detach); reg(new video_detach);
reg(new video_details); reg(new video_details);
reg(new video_focus_seek); reg(new video_focus_seek);
reg(new video_frame_copy);
reg(new video_frame_copy_raw);
reg(new video_frame_next); reg(new video_frame_next);
reg(new video_frame_next_boundary); reg(new video_frame_next_boundary);
reg(new video_frame_next_keyframe); reg(new video_frame_next_keyframe);
@ -680,6 +755,8 @@ namespace cmd {
reg(new video_frame_prev_boundary); reg(new video_frame_prev_boundary);
reg(new video_frame_prev_keyframe); reg(new video_frame_prev_keyframe);
reg(new video_frame_prev_large); reg(new video_frame_prev_large);
reg(new video_frame_save);
reg(new video_frame_save_raw);
reg(new video_jump); reg(new video_jump);
reg(new video_jump_end); reg(new video_jump_end);
reg(new video_jump_start); reg(new video_jump_start);

View File

@ -565,4 +565,7 @@ void VideoDisplay::OnCopyCoords(wxCommandEvent &) {
wxTheClipboard->SetData(new wxTextDataObject(wxString::Format(L"%i,%i",x,y))); wxTheClipboard->SetData(new wxTextDataObject(wxString::Format(L"%i,%i",x,y)));
wxTheClipboard->Close(); wxTheClipboard->Close();
} }
void VideoDisplay::GetMousePosition(int *x, int *y) const {
*x = video.x;
*y = video.y;
} }

View File

@ -209,5 +209,10 @@ public:
/// @param y y coordinate; in/out /// @param y y coordinate; in/out
void FromScriptCoords(int *x, int *y) const; void FromScriptCoords(int *x, int *y) const;
/// Get the last seen position of the mouse in screen coordinates
/// @param[out] x x coordinate
/// @param[out] y y coordinate
void GetMousePosition(int *x, int *y) const;
DECLARE_EVENT_TABLE() DECLARE_EVENT_TABLE()
}; };