forked from mia/Aegisub
Convert the VideoDisplay context menu over to the new menu system
Originally committed to SVN as r5563.
This commit is contained in:
parent
e2f464c94f
commit
fc0db4fc36
3 changed files with 14 additions and 75 deletions
|
@ -197,5 +197,14 @@
|
||||||
{ "command" : "app/updates" },
|
{ "command" : "app/updates" },
|
||||||
{ "command" : "app/about", "special" : "about" },
|
{ "command" : "app/about", "special" : "about" },
|
||||||
{ "command" : "app/log" }
|
{ "command" : "app/log" }
|
||||||
|
],
|
||||||
|
"video_context" : [
|
||||||
|
{ "command" : "video/frame/save" },
|
||||||
|
{ "command" : "video/frame/copy" },
|
||||||
|
{},
|
||||||
|
{ "command" : "video/frame/save/raw" },
|
||||||
|
{ "command" : "video/frame/copy/raw" },
|
||||||
|
{},
|
||||||
|
{ "command" : "video/copy_coordinates" }
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,7 +41,6 @@
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
#include <wx/combobox.h>
|
#include <wx/combobox.h>
|
||||||
#include <wx/clipbrd.h>
|
|
||||||
#include <wx/dataobj.h>
|
#include <wx/dataobj.h>
|
||||||
#include <wx/dcclient.h>
|
#include <wx/dcclient.h>
|
||||||
#include <wx/menu.h>
|
#include <wx/menu.h>
|
||||||
|
@ -59,12 +58,12 @@
|
||||||
|
|
||||||
#include "include/aegisub/context.h"
|
#include "include/aegisub/context.h"
|
||||||
#include "include/aegisub/hotkey.h"
|
#include "include/aegisub/hotkey.h"
|
||||||
|
#include "include/aegisub/menu.h"
|
||||||
|
|
||||||
#include "video_display.h"
|
#include "video_display.h"
|
||||||
|
|
||||||
#include "ass_file.h"
|
#include "ass_file.h"
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
#include "subs_grid.h"
|
|
||||||
#include "threaded_frame_source.h"
|
#include "threaded_frame_source.h"
|
||||||
#include "video_out_gl.h"
|
#include "video_out_gl.h"
|
||||||
#include "video_box.h"
|
#include "video_box.h"
|
||||||
|
@ -78,30 +77,9 @@
|
||||||
#include "visual_tool_scale.h"
|
#include "visual_tool_scale.h"
|
||||||
#include "visual_tool_vector_clip.h"
|
#include "visual_tool_vector_clip.h"
|
||||||
|
|
||||||
|
|
||||||
// Menu item IDs
|
|
||||||
enum {
|
|
||||||
/// Copy mouse coordinates to clipboard
|
|
||||||
VIDEO_MENU_COPY_COORDS = 1230,
|
|
||||||
/// Copy frame to clipboard with subtitles
|
|
||||||
VIDEO_MENU_COPY_TO_CLIPBOARD,
|
|
||||||
/// Copy frame to clipboard without subtitles
|
|
||||||
VIDEO_MENU_COPY_TO_CLIPBOARD_RAW,
|
|
||||||
/// Save frame with subtitles
|
|
||||||
VIDEO_MENU_SAVE_SNAPSHOT,
|
|
||||||
/// Save frame without subtitles
|
|
||||||
VIDEO_MENU_SAVE_SNAPSHOT_RAW
|
|
||||||
};
|
|
||||||
|
|
||||||
BEGIN_EVENT_TABLE(VideoDisplay, wxGLCanvas)
|
BEGIN_EVENT_TABLE(VideoDisplay, wxGLCanvas)
|
||||||
EVT_MOUSE_EVENTS(VideoDisplay::OnMouseEvent)
|
EVT_MOUSE_EVENTS(VideoDisplay::OnMouseEvent)
|
||||||
EVT_KEY_DOWN(VideoDisplay::OnKeyDown)
|
EVT_KEY_DOWN(VideoDisplay::OnKeyDown)
|
||||||
|
|
||||||
EVT_MENU(VIDEO_MENU_COPY_COORDS,VideoDisplay::OnCopyCoords)
|
|
||||||
EVT_MENU(VIDEO_MENU_COPY_TO_CLIPBOARD,VideoDisplay::OnCopyToClipboard)
|
|
||||||
EVT_MENU(VIDEO_MENU_SAVE_SNAPSHOT,VideoDisplay::OnSaveSnapshot)
|
|
||||||
EVT_MENU(VIDEO_MENU_COPY_TO_CLIPBOARD_RAW,VideoDisplay::OnCopyToClipboardRaw)
|
|
||||||
EVT_MENU(VIDEO_MENU_SAVE_SNAPSHOT_RAW,VideoDisplay::OnSaveSnapshotRaw)
|
|
||||||
END_EVENT_TABLE()
|
END_EVENT_TABLE()
|
||||||
|
|
||||||
/// Attribute list for gl canvases; set the canvases to doublebuffered rgba with an 8 bit stencil buffer
|
/// Attribute list for gl canvases; set the canvases to doublebuffered rgba with an 8 bit stencil buffer
|
||||||
|
@ -418,18 +396,9 @@ void VideoDisplay::OnMouseEvent(wxMouseEvent& event) {
|
||||||
if (con->videoController->IsPlaying()) return;
|
if (con->videoController->IsPlaying()) return;
|
||||||
|
|
||||||
if (event.ButtonUp(wxMOUSE_BTN_RIGHT)) {
|
if (event.ButtonUp(wxMOUSE_BTN_RIGHT)) {
|
||||||
wxMenu menu;
|
if (!context_menu.get()) context_menu.reset(menu::GetMenu("video_context", con));
|
||||||
menu.Append(VIDEO_MENU_SAVE_SNAPSHOT,_("Save PNG snapshot"));
|
|
||||||
menu.Append(VIDEO_MENU_COPY_TO_CLIPBOARD,_("Copy image to Clipboard"));
|
|
||||||
menu.AppendSeparator();
|
|
||||||
menu.Append(VIDEO_MENU_SAVE_SNAPSHOT_RAW,_("Save PNG snapshot (no subtitles)"));
|
|
||||||
menu.Append(VIDEO_MENU_COPY_TO_CLIPBOARD_RAW,_("Copy image to Clipboard (no subtitles)"));
|
|
||||||
menu.AppendSeparator();
|
|
||||||
menu.Append(VIDEO_MENU_COPY_COORDS,_("Copy coordinates to Clipboard"));
|
|
||||||
|
|
||||||
// Show cursor and popup
|
|
||||||
ShowCursor(true);
|
ShowCursor(true);
|
||||||
PopupMenu(&menu);
|
menu::OpenPopupMenu(context_menu.get(), this);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -535,36 +504,6 @@ void VideoDisplay::FromScriptCoords(int *x, int *y) const {
|
||||||
*y = (*y * viewport_height + sy / 2) / scriptH + viewport_top;
|
*y = (*y * viewport_height + sy / 2) / scriptH + viewport_top;
|
||||||
}
|
}
|
||||||
|
|
||||||
void VideoDisplay::OnCopyToClipboard(wxCommandEvent &) {
|
|
||||||
if (wxTheClipboard->Open()) {
|
|
||||||
wxTheClipboard->SetData(new wxBitmapDataObject(wxBitmap(con->videoController->GetFrame(currentFrame)->GetImage(),24)));
|
|
||||||
wxTheClipboard->Close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void VideoDisplay::OnCopyToClipboardRaw(wxCommandEvent &) {
|
|
||||||
if (wxTheClipboard->Open()) {
|
|
||||||
wxTheClipboard->SetData(new wxBitmapDataObject(wxBitmap(con->videoController->GetFrame(currentFrame,true)->GetImage(),24)));
|
|
||||||
wxTheClipboard->Close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void VideoDisplay::OnSaveSnapshot(wxCommandEvent &) {
|
|
||||||
con->videoController->SaveSnapshot(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
void VideoDisplay::OnSaveSnapshotRaw(wxCommandEvent &) {
|
|
||||||
con->videoController->SaveSnapshot(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
void VideoDisplay::OnCopyCoords(wxCommandEvent &) {
|
|
||||||
if (wxTheClipboard->Open()) {
|
|
||||||
int x = video.x;
|
|
||||||
int y = video.y;
|
|
||||||
ToScriptCoords(&x, &y);
|
|
||||||
wxTheClipboard->SetData(new wxTextDataObject(wxString::Format(L"%i,%i",x,y)));
|
|
||||||
wxTheClipboard->Close();
|
|
||||||
}
|
|
||||||
void VideoDisplay::GetMousePosition(int *x, int *y) const {
|
void VideoDisplay::GetMousePosition(int *x, int *y) const {
|
||||||
*x = video.x;
|
*x = video.x;
|
||||||
*y = video.y;
|
*y = video.y;
|
||||||
|
|
|
@ -77,6 +77,8 @@ class VideoDisplay : public wxGLCanvas {
|
||||||
|
|
||||||
agi::Context *con;
|
agi::Context *con;
|
||||||
|
|
||||||
|
agi::scoped_ptr<wxMenu> context_menu;
|
||||||
|
|
||||||
/// The frame number currently being displayed
|
/// The frame number currently being displayed
|
||||||
int currentFrame;
|
int currentFrame;
|
||||||
|
|
||||||
|
@ -170,17 +172,6 @@ class VideoDisplay : public wxGLCanvas {
|
||||||
void OnSizeEvent(wxSizeEvent &event);
|
void OnSizeEvent(wxSizeEvent &event);
|
||||||
void OnMode(const wxCommandEvent &event);
|
void OnMode(const wxCommandEvent &event);
|
||||||
|
|
||||||
/// @brief Copy coordinates of the mouse to the clipboard
|
|
||||||
void OnCopyCoords(wxCommandEvent &);
|
|
||||||
/// @brief Copy the currently display frame to the clipboard, with subtitles
|
|
||||||
void OnCopyToClipboard(wxCommandEvent &);
|
|
||||||
/// @brief Save the currently display frame to a file, with subtitles
|
|
||||||
void OnSaveSnapshot(wxCommandEvent &);
|
|
||||||
/// @brief Copy the currently display frame to the clipboard, without subtitles
|
|
||||||
void OnCopyToClipboardRaw(wxCommandEvent &);
|
|
||||||
/// @brief Save the currently display frame to a file, without subtitles
|
|
||||||
void OnSaveSnapshotRaw(wxCommandEvent &);
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/// @brief Constructor
|
/// @brief Constructor
|
||||||
VideoDisplay(
|
VideoDisplay(
|
||||||
|
|
Loading…
Reference in a new issue