2010-05-13 20:37:41 +02:00
|
|
|
// Copyright (c) 2005-2010, Rodrigo Braz Monteiro
|
2006-01-16 22:02:54 +01:00
|
|
|
// All rights reserved.
|
|
|
|
//
|
|
|
|
// Redistribution and use in source and binary forms, with or without
|
|
|
|
// modification, are permitted provided that the following conditions are met:
|
|
|
|
//
|
|
|
|
// * Redistributions of source code must retain the above copyright notice,
|
|
|
|
// this list of conditions and the following disclaimer.
|
|
|
|
// * Redistributions in binary form must reproduce the above copyright notice,
|
|
|
|
// this list of conditions and the following disclaimer in the documentation
|
|
|
|
// and/or other materials provided with the distribution.
|
|
|
|
// * Neither the name of the Aegisub Group nor the names of its contributors
|
|
|
|
// may be used to endorse or promote products derived from this software
|
|
|
|
// without specific prior written permission.
|
|
|
|
//
|
|
|
|
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
|
|
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
|
|
|
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
|
|
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
|
|
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
|
|
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
|
|
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
|
|
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
|
|
// POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
//
|
2009-07-29 07:43:02 +02:00
|
|
|
// Aegisub Project http://www.aegisub.org/
|
2006-01-16 22:02:54 +01:00
|
|
|
//
|
2009-07-29 07:43:02 +02:00
|
|
|
// $Id$
|
|
|
|
|
|
|
|
/// @file video_display.cpp
|
|
|
|
/// @brief Control displaying a video frame obtained from the video context
|
|
|
|
/// @ingroup video main_ui
|
|
|
|
///
|
2006-01-16 22:02:54 +01:00
|
|
|
|
|
|
|
// Includes
|
2009-01-04 07:31:48 +01:00
|
|
|
#include "config.h"
|
|
|
|
|
2009-09-10 15:06:40 +02:00
|
|
|
#ifndef AGI_PRE
|
2010-08-03 00:14:11 +02:00
|
|
|
#include <algorithm>
|
|
|
|
|
2009-09-10 15:06:40 +02:00
|
|
|
#include <wx/clipbrd.h>
|
|
|
|
#include <wx/dataobj.h>
|
|
|
|
#include <wx/dcclient.h>
|
2007-01-23 21:50:41 +01:00
|
|
|
#include <wx/glcanvas.h>
|
2009-09-10 15:06:40 +02:00
|
|
|
#include <wx/menu.h>
|
2010-06-14 21:26:27 +02:00
|
|
|
#include <wx/toolbar.h>
|
2009-09-10 15:06:40 +02:00
|
|
|
#endif
|
|
|
|
|
2007-09-12 01:22:26 +02:00
|
|
|
#ifdef __APPLE__
|
2011-01-11 18:52:17 +01:00
|
|
|
#include <OpenGL/gl.h>
|
2007-04-22 04:24:27 +02:00
|
|
|
#include <OpenGL/glu.h>
|
|
|
|
#else
|
2007-01-22 23:57:45 +01:00
|
|
|
#include <GL/gl.h>
|
|
|
|
#include <GL/glu.h>
|
2007-04-22 04:24:27 +02:00
|
|
|
#endif
|
2009-09-10 15:06:40 +02:00
|
|
|
|
2011-01-16 08:17:08 +01:00
|
|
|
#include "include/aegisub/context.h"
|
2011-01-05 19:40:37 +01:00
|
|
|
#include "include/aegisub/hotkey.h"
|
Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
|
|
|
|
2010-05-16 08:39:11 +02:00
|
|
|
#include "video_display.h"
|
2010-12-08 04:36:10 +01:00
|
|
|
#include "selection_controller.h"
|
2010-05-16 08:39:11 +02:00
|
|
|
|
2006-01-16 22:02:54 +01:00
|
|
|
#include "ass_dialogue.h"
|
2010-12-07 20:09:28 +01:00
|
|
|
#include "ass_file.h"
|
2010-05-21 03:13:36 +02:00
|
|
|
#include "main.h"
|
2010-07-08 06:29:04 +02:00
|
|
|
#include "subs_grid.h"
|
2010-07-23 07:58:39 +02:00
|
|
|
#include "threaded_frame_source.h"
|
2009-10-05 06:22:28 +02:00
|
|
|
#include "video_out_gl.h"
|
2007-01-11 04:53:20 +01:00
|
|
|
#include "video_box.h"
|
2009-09-10 03:41:34 +02:00
|
|
|
#include "video_context.h"
|
2007-07-01 02:19:55 +02:00
|
|
|
#include "visual_tool.h"
|
2009-09-10 15:06:40 +02:00
|
|
|
#include "visual_tool_clip.h"
|
2007-07-01 02:19:55 +02:00
|
|
|
#include "visual_tool_cross.h"
|
2009-09-10 15:06:40 +02:00
|
|
|
#include "visual_tool_drag.h"
|
2007-07-01 04:46:12 +02:00
|
|
|
#include "visual_tool_rotatexy.h"
|
2009-09-10 15:06:40 +02:00
|
|
|
#include "visual_tool_rotatez.h"
|
2007-07-01 05:17:56 +02:00
|
|
|
#include "visual_tool_scale.h"
|
2007-07-05 06:32:46 +02:00
|
|
|
#include "visual_tool_vector_clip.h"
|
2009-09-10 15:06:40 +02:00
|
|
|
|
2006-01-16 22:02:54 +01:00
|
|
|
|
2009-09-10 03:41:34 +02:00
|
|
|
// Menu item IDs
|
2006-01-16 22:02:54 +01:00
|
|
|
enum {
|
2009-09-10 03:41:34 +02:00
|
|
|
/// Copy mouse coordinates to clipboard
|
2007-04-08 00:03:06 +02:00
|
|
|
VIDEO_MENU_COPY_COORDS = 1230,
|
2009-09-10 03:41:34 +02:00
|
|
|
/// Copy frame to clipboard with subtitles
|
2007-04-08 00:03:06 +02:00
|
|
|
VIDEO_MENU_COPY_TO_CLIPBOARD,
|
2009-09-10 03:41:34 +02:00
|
|
|
/// Copy frame to clipboard without subtitles
|
2007-04-08 00:03:06 +02:00
|
|
|
VIDEO_MENU_COPY_TO_CLIPBOARD_RAW,
|
2009-09-10 03:41:34 +02:00
|
|
|
/// Save frame with subtitles
|
2006-01-16 22:02:54 +01:00
|
|
|
VIDEO_MENU_SAVE_SNAPSHOT,
|
2009-09-10 03:41:34 +02:00
|
|
|
/// Save frame without subtitles
|
2007-04-08 00:03:06 +02:00
|
|
|
VIDEO_MENU_SAVE_SNAPSHOT_RAW
|
2006-01-16 22:02:54 +01:00
|
|
|
};
|
|
|
|
|
2007-01-21 07:30:19 +01:00
|
|
|
BEGIN_EVENT_TABLE(VideoDisplay, wxGLCanvas)
|
|
|
|
EVT_MOUSE_EVENTS(VideoDisplay::OnMouseEvent)
|
Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
|
|
|
EVT_KEY_DOWN(VideoDisplay::OnKeyDown)
|
2007-01-21 07:30:19 +01:00
|
|
|
EVT_PAINT(VideoDisplay::OnPaint)
|
2007-01-23 05:42:08 +01:00
|
|
|
EVT_SIZE(VideoDisplay::OnSizeEvent)
|
2007-01-21 07:30:19 +01:00
|
|
|
EVT_ERASE_BACKGROUND(VideoDisplay::OnEraseBackground)
|
2006-01-16 22:02:54 +01:00
|
|
|
|
2007-04-08 00:03:06 +02:00
|
|
|
EVT_MENU(VIDEO_MENU_COPY_COORDS,VideoDisplay::OnCopyCoords)
|
2006-01-16 22:02:54 +01:00
|
|
|
EVT_MENU(VIDEO_MENU_COPY_TO_CLIPBOARD,VideoDisplay::OnCopyToClipboard)
|
|
|
|
EVT_MENU(VIDEO_MENU_SAVE_SNAPSHOT,VideoDisplay::OnSaveSnapshot)
|
2007-04-08 00:03:06 +02:00
|
|
|
EVT_MENU(VIDEO_MENU_COPY_TO_CLIPBOARD_RAW,VideoDisplay::OnCopyToClipboardRaw)
|
|
|
|
EVT_MENU(VIDEO_MENU_SAVE_SNAPSHOT_RAW,VideoDisplay::OnSaveSnapshotRaw)
|
2006-01-16 22:02:54 +01:00
|
|
|
END_EVENT_TABLE()
|
|
|
|
|
2009-09-10 03:41:34 +02:00
|
|
|
/// Attribute list for gl canvases; set the canvases to doublebuffered rgba with an 8 bit stencil buffer
|
2007-07-05 06:32:46 +02:00
|
|
|
int attribList[] = { WX_GL_RGBA , WX_GL_DOUBLEBUFFER, WX_GL_STENCIL_SIZE, 8, 0 };
|
2007-01-22 23:57:45 +01:00
|
|
|
|
2010-05-16 08:39:11 +02:00
|
|
|
/// @class VideoOutRenderException
|
|
|
|
/// @extends VideoOutException
|
2010-12-07 20:09:21 +01:00
|
|
|
/// @brief An OpenGL error occurred while uploading or displaying a frame
|
2010-05-21 03:13:36 +02:00
|
|
|
class OpenGlException : public agi::Exception {
|
2010-05-16 08:39:11 +02:00
|
|
|
public:
|
|
|
|
OpenGlException(const wxChar *func, int err)
|
2010-05-21 03:13:36 +02:00
|
|
|
: agi::Exception(STD_STR(wxString::Format("%s failed with error code %d", func, err)))
|
2010-05-16 08:39:11 +02:00
|
|
|
{ }
|
2010-05-21 03:13:36 +02:00
|
|
|
const char * GetName() const { return "video/opengl"; }
|
2010-05-16 08:39:11 +02:00
|
|
|
Exception * Copy() const { return new OpenGlException(*this); }
|
|
|
|
};
|
|
|
|
|
|
|
|
#define E(cmd) cmd; if (GLenum err = glGetError()) throw OpenGlException(L###cmd, err)
|
|
|
|
|
2010-08-13 07:51:17 +02:00
|
|
|
VideoDisplay::VideoDisplay(
|
|
|
|
VideoBox *box,
|
|
|
|
wxTextCtrl *PositionDisplay,
|
|
|
|
wxTextCtrl *SubsPosition,
|
|
|
|
wxComboBox *zoomBox,
|
|
|
|
wxWindow* parent,
|
2011-01-16 08:17:08 +01:00
|
|
|
agi::Context *c)
|
2010-12-30 20:13:53 +01:00
|
|
|
: wxGLCanvas (parent, -1, attribList, wxDefaultPosition, wxDefaultSize, 0, wxPanelNameStr)
|
2010-06-04 05:07:33 +02:00
|
|
|
, alwaysShowTools(OPT_GET("Tool/Visual/Always Show"))
|
2011-01-16 08:17:08 +01:00
|
|
|
, con(c)
|
2009-10-05 06:22:28 +02:00
|
|
|
, currentFrame(-1)
|
2010-05-16 08:39:11 +02:00
|
|
|
, w(8), h(8), viewport_x(0), viewport_width(0), viewport_bottom(0), viewport_top(0), viewport_height(0)
|
2010-08-13 07:51:17 +02:00
|
|
|
, zoomValue(OPT_GET("Video/Default Zoom")->GetInt() * .125 + .125)
|
2009-10-05 06:22:28 +02:00
|
|
|
, SubsPosition(SubsPosition)
|
|
|
|
, PositionDisplay(PositionDisplay)
|
2009-10-13 19:28:39 +02:00
|
|
|
, videoOut(new VideoOutGL())
|
2010-05-16 08:39:11 +02:00
|
|
|
, activeMode(Video_Mode_Standard)
|
|
|
|
, toolBar(box->visualSubToolBar)
|
|
|
|
, scriptW(INT_MIN)
|
|
|
|
, scriptH(INT_MIN)
|
2010-08-13 07:51:17 +02:00
|
|
|
, zoomBox(zoomBox)
|
2010-05-16 09:06:08 +02:00
|
|
|
, box(box)
|
|
|
|
, freeSize(false)
|
2006-01-16 22:02:54 +01:00
|
|
|
{
|
2010-12-07 20:09:28 +01:00
|
|
|
assert(box);
|
|
|
|
|
2010-08-13 07:51:17 +02:00
|
|
|
if (zoomBox) zoomBox->SetValue(wxString::Format("%g%%", zoomValue * 100.));
|
2010-05-16 08:39:11 +02:00
|
|
|
box->Bind(wxEVT_COMMAND_TOOL_CLICKED, &VideoDisplay::OnMode, this, Video_Mode_Standard, Video_Mode_Vector_Clip);
|
2010-12-07 20:09:21 +01:00
|
|
|
|
2011-01-16 08:17:08 +01:00
|
|
|
con->videoController->Bind(EVT_FRAME_READY, &VideoDisplay::UploadFrameData, this);
|
|
|
|
slots.push_back(con->videoController->AddSeekListener(&VideoDisplay::SetFrame, this));
|
|
|
|
slots.push_back(con->videoController->AddVideoOpenListener(&VideoDisplay::OnVideoOpen, this));
|
|
|
|
slots.push_back(con->videoController->AddARChangeListener(&VideoDisplay::UpdateSize, this));
|
2011-01-16 08:17:36 +01:00
|
|
|
slots.push_back(con->ass->AddCommitListener(&VideoDisplay::OnCommit, this));
|
2010-12-07 20:09:21 +01:00
|
|
|
|
2007-01-21 07:30:19 +01:00
|
|
|
SetCursor(wxNullCursor);
|
2006-01-16 22:02:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
VideoDisplay::~VideoDisplay () {
|
2011-01-16 08:17:08 +01:00
|
|
|
con->videoController->Unbind(EVT_FRAME_READY, &VideoDisplay::UploadFrameData, this);
|
2006-01-16 22:02:54 +01:00
|
|
|
}
|
|
|
|
|
2010-07-18 07:45:52 +02:00
|
|
|
bool VideoDisplay::InitContext() {
|
|
|
|
if (!IsShownOnScreen()) return false;
|
|
|
|
if (!glContext.get()) {
|
|
|
|
glContext.reset(new wxGLContext(this));
|
|
|
|
}
|
|
|
|
SetCurrent(*glContext.get());
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2007-04-18 06:51:17 +02:00
|
|
|
void VideoDisplay::ShowCursor(bool show) {
|
2010-05-13 20:41:46 +02:00
|
|
|
if (show) {
|
|
|
|
SetCursor(wxNullCursor);
|
|
|
|
}
|
2007-04-18 06:51:17 +02:00
|
|
|
else {
|
|
|
|
wxCursor cursor(wxCURSOR_BLANK);
|
|
|
|
SetCursor(cursor);
|
|
|
|
}
|
|
|
|
}
|
2010-10-16 22:11:53 +02:00
|
|
|
|
|
|
|
void VideoDisplay::UpdateRelativeTimes(int time) {
|
|
|
|
wxString startSign;
|
|
|
|
wxString endSign;
|
|
|
|
int startOff = 0;
|
|
|
|
int endOff = 0;
|
|
|
|
|
2011-01-16 08:17:08 +01:00
|
|
|
if (AssDialogue *curLine = con->selectionController->GetActiveLine()) {
|
2010-10-16 22:11:53 +02:00
|
|
|
startOff = time - curLine->Start.GetMS();
|
|
|
|
endOff = time - curLine->End.GetMS();
|
|
|
|
}
|
|
|
|
|
|
|
|
// Positive signs
|
|
|
|
if (startOff > 0) startSign = L"+";
|
|
|
|
if (endOff > 0) endSign = L"+";
|
|
|
|
|
|
|
|
// Set the text box for time relative to active subtitle line
|
|
|
|
SubsPosition->SetValue(wxString::Format(L"%s%ims; %s%ims", startSign.c_str(), startOff, endSign.c_str(), endOff));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-10-05 06:22:28 +02:00
|
|
|
void VideoDisplay::SetFrame(int frameNumber) {
|
2010-06-28 09:39:42 +02:00
|
|
|
currentFrame = frameNumber;
|
|
|
|
|
2009-10-05 06:22:28 +02:00
|
|
|
// Get time for frame
|
2010-05-16 08:39:11 +02:00
|
|
|
{
|
2011-01-16 08:17:08 +01:00
|
|
|
int time = con->videoController->TimeAtFrame(frameNumber, agi::vfr::EXACT);
|
2010-05-16 08:39:11 +02:00
|
|
|
int h = time / 3600000;
|
|
|
|
int m = time % 3600000 / 60000;
|
|
|
|
int s = time % 60000 / 1000;
|
|
|
|
int ms = time % 1000;
|
|
|
|
|
|
|
|
// Set the text box for frame number and time
|
|
|
|
PositionDisplay->SetValue(wxString::Format(L"%01i:%02i:%02i.%03i - %i", h, m, s, ms, frameNumber));
|
2011-01-16 08:17:08 +01:00
|
|
|
if (std::binary_search(con->videoController->GetKeyFrames().begin(), con->videoController->GetKeyFrames().end(), frameNumber)) {
|
2010-05-16 08:39:11 +02:00
|
|
|
// Set the background color to indicate this is a keyframe
|
2010-05-21 03:13:36 +02:00
|
|
|
PositionDisplay->SetBackgroundColour(lagi_wxColour(OPT_GET("Colour/Subtitle Grid/Background/Selection")->GetColour()));
|
|
|
|
PositionDisplay->SetForegroundColour(lagi_wxColour(OPT_GET("Colour/Subtitle Grid/Selection")->GetColour()));
|
2010-05-16 08:39:11 +02:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
PositionDisplay->SetBackgroundColour(wxNullColour);
|
|
|
|
PositionDisplay->SetForegroundColour(wxNullColour);
|
|
|
|
}
|
2009-10-05 06:22:28 +02:00
|
|
|
|
2010-10-16 22:11:53 +02:00
|
|
|
UpdateRelativeTimes(time);
|
2010-05-16 08:39:11 +02:00
|
|
|
}
|
2009-10-05 06:22:28 +02:00
|
|
|
|
2009-10-13 19:28:39 +02:00
|
|
|
// Render the new frame
|
2011-01-16 08:17:08 +01:00
|
|
|
if (con->videoController->IsLoaded()) {
|
2010-06-28 09:13:15 +02:00
|
|
|
tool->SetFrame(frameNumber);
|
2011-01-16 08:17:08 +01:00
|
|
|
con->videoController->GetFrameAsync(currentFrame);
|
2009-10-27 15:27:39 +01:00
|
|
|
}
|
2010-06-28 09:39:42 +02:00
|
|
|
}
|
2009-10-05 06:22:28 +02:00
|
|
|
|
2010-07-23 07:58:39 +02:00
|
|
|
void VideoDisplay::UploadFrameData(FrameReadyEvent &evt) {
|
2010-07-18 07:45:52 +02:00
|
|
|
if (!InitContext()) return;
|
2010-07-23 07:58:39 +02:00
|
|
|
|
2010-06-28 09:39:42 +02:00
|
|
|
try {
|
2010-07-23 07:58:39 +02:00
|
|
|
videoOut->UploadFrameData(*evt.frame);
|
2010-06-28 09:39:42 +02:00
|
|
|
}
|
|
|
|
catch (const VideoOutInitException& err) {
|
|
|
|
wxLogError(
|
2010-07-23 07:58:39 +02:00
|
|
|
L"Failed to initialize video display. Closing other running "
|
|
|
|
L"programs and updating your video card drivers may fix this.\n"
|
2010-06-28 09:39:42 +02:00
|
|
|
L"Error message reported: %s",
|
|
|
|
err.GetMessage().c_str());
|
2011-01-16 08:17:08 +01:00
|
|
|
con->videoController->Reset();
|
2010-06-28 09:39:42 +02:00
|
|
|
}
|
|
|
|
catch (const VideoOutRenderException& err) {
|
|
|
|
wxLogError(
|
|
|
|
L"Could not upload video frame to graphics card.\n"
|
|
|
|
L"Error message reported: %s",
|
|
|
|
err.GetMessage().c_str());
|
|
|
|
}
|
2010-07-23 07:58:39 +02:00
|
|
|
Render();
|
2009-10-05 06:22:28 +02:00
|
|
|
}
|
|
|
|
|
2010-12-07 20:09:28 +01:00
|
|
|
void VideoDisplay::OnVideoOpen() {
|
2011-01-16 08:17:08 +01:00
|
|
|
if (!con->videoController->IsLoaded()) return;
|
2010-12-07 20:09:28 +01:00
|
|
|
UpdateSize();
|
|
|
|
currentFrame = 0;
|
2011-01-16 08:17:08 +01:00
|
|
|
con->videoController->GetFrameAsync(0);
|
2010-12-07 20:09:28 +01:00
|
|
|
UpdateRelativeTimes(0);
|
2011-01-16 08:17:08 +01:00
|
|
|
if (!tool.get()) tool.reset(new VisualToolCross(this, con, video, toolBar));
|
2010-06-28 09:13:15 +02:00
|
|
|
tool->Refresh();
|
|
|
|
}
|
2010-12-07 20:09:28 +01:00
|
|
|
void VideoDisplay::OnCommit(int type) {
|
|
|
|
if (type == AssFile::COMMIT_FULL || type == AssFile::COMMIT_UNDO)
|
2011-01-16 08:17:08 +01:00
|
|
|
con->videoController->GetScriptSize(scriptW, scriptH);
|
2010-12-07 20:09:28 +01:00
|
|
|
if (tool.get()) tool->Refresh();
|
2011-01-16 08:17:08 +01:00
|
|
|
UpdateRelativeTimes(con->videoController->TimeAtFrame(currentFrame, agi::vfr::EXACT));
|
2009-10-05 06:22:28 +02:00
|
|
|
}
|
|
|
|
|
2009-10-27 15:27:39 +01:00
|
|
|
void VideoDisplay::Render() try {
|
2010-07-18 07:45:52 +02:00
|
|
|
if (!InitContext()) return;
|
2011-01-16 08:17:08 +01:00
|
|
|
if (!con->videoController->IsLoaded()) return;
|
2010-05-16 08:39:11 +02:00
|
|
|
assert(wxIsMainThread());
|
2010-08-13 07:51:31 +02:00
|
|
|
if (!viewport_height || !viewport_width) UpdateSize();
|
2007-04-02 01:07:29 +02:00
|
|
|
|
2010-05-16 08:39:11 +02:00
|
|
|
videoOut->Render(viewport_x, viewport_bottom, viewport_width, viewport_height);
|
2010-08-13 07:51:17 +02:00
|
|
|
E(glViewport(0, std::min(viewport_bottom, 0), w, h));
|
2010-05-16 08:39:11 +02:00
|
|
|
|
|
|
|
E(glMatrixMode(GL_PROJECTION));
|
|
|
|
E(glLoadIdentity());
|
|
|
|
E(glOrtho(0.0f, w, h, 0.0f, -1000.0f, 1000.0f));
|
|
|
|
|
2010-05-21 03:13:36 +02:00
|
|
|
if (OPT_GET("Video/Overscan Mask")->GetBool()) {
|
2011-01-16 08:17:08 +01:00
|
|
|
double ar = con->videoController->GetAspectRatioValue();
|
2010-05-16 08:39:11 +02:00
|
|
|
|
|
|
|
// Based on BBC's guidelines: http://www.bbc.co.uk/guidelines/dq/pdf/tv/tv_standards_london.pdf
|
|
|
|
// 16:9 or wider
|
|
|
|
if (ar > 1.75) {
|
|
|
|
DrawOverscanMask(w * 0.1, h * 0.05, wxColor(30,70,200),0.5);
|
|
|
|
DrawOverscanMask(w * 0.035, h * 0.035, wxColor(30,70,200),0.5);
|
|
|
|
}
|
2009-10-05 06:22:28 +02:00
|
|
|
|
2010-05-16 08:39:11 +02:00
|
|
|
// Less wide than 16:9 (use 4:3 standard)
|
|
|
|
else {
|
|
|
|
DrawOverscanMask(w * 0.067, h * 0.05, wxColor(30,70,200),0.5);
|
|
|
|
DrawOverscanMask(w * 0.033, h * 0.035, wxColor(30,70,200),0.5);
|
|
|
|
}
|
|
|
|
}
|
2007-01-02 21:07:52 +01:00
|
|
|
|
2010-06-04 05:07:33 +02:00
|
|
|
if (video.x > INT_MIN || video.y > INT_MIN || alwaysShowTools->GetBool()) {
|
2010-05-16 08:39:11 +02:00
|
|
|
tool->Draw();
|
2010-05-01 03:45:10 +02:00
|
|
|
}
|
2007-01-02 21:07:52 +01:00
|
|
|
|
2007-01-21 07:30:19 +01:00
|
|
|
SwapBuffers();
|
2007-01-02 21:07:52 +01:00
|
|
|
}
|
2009-10-05 06:22:28 +02:00
|
|
|
catch (const VideoOutException &err) {
|
2009-12-01 01:32:43 +01:00
|
|
|
wxLogError(
|
2010-05-16 08:39:11 +02:00
|
|
|
L"An error occurred trying to render the video frame on the screen.\n"
|
|
|
|
L"Error message reported: %s",
|
|
|
|
err.GetMessage().c_str());
|
2011-01-16 08:17:08 +01:00
|
|
|
con->videoController->Reset();
|
2010-05-16 08:39:11 +02:00
|
|
|
}
|
|
|
|
catch (const OpenGlException &err) {
|
|
|
|
wxLogError(
|
|
|
|
L"An error occurred trying to render visual overlays on the screen.\n"
|
|
|
|
L"Error message reported: %s",
|
2009-12-13 20:27:45 +01:00
|
|
|
err.GetMessage().c_str());
|
2011-01-16 08:17:08 +01:00
|
|
|
con->videoController->Reset();
|
2009-10-05 06:22:28 +02:00
|
|
|
}
|
2010-04-30 05:00:15 +02:00
|
|
|
catch (const wchar_t *err) {
|
|
|
|
wxLogError(
|
|
|
|
L"An error occurred trying to render the video frame on the screen.\n"
|
|
|
|
L"Error message reported: %s",
|
|
|
|
err);
|
2011-01-16 08:17:08 +01:00
|
|
|
con->videoController->Reset();
|
2010-04-30 05:00:15 +02:00
|
|
|
}
|
2009-06-01 17:26:26 +02:00
|
|
|
catch (...) {
|
|
|
|
wxLogError(
|
2010-05-16 08:39:11 +02:00
|
|
|
L"An error occurred trying to render the video frame to screen.\n"
|
|
|
|
L"No further error message given.");
|
2011-01-16 08:17:08 +01:00
|
|
|
con->videoController->Reset();
|
2009-06-01 17:26:26 +02:00
|
|
|
}
|
2007-01-02 21:07:52 +01:00
|
|
|
|
2010-05-16 08:39:11 +02:00
|
|
|
void VideoDisplay::DrawOverscanMask(int sizeH, int sizeV, wxColor color, double alpha) const {
|
|
|
|
int rad1 = h * 0.05;
|
2007-06-28 22:29:56 +02:00
|
|
|
int gapH = sizeH+rad1;
|
|
|
|
int gapV = sizeV+rad1;
|
2010-05-16 08:39:11 +02:00
|
|
|
int rad2 = sqrt(double(gapH*gapH + gapV*gapV)) + 1;
|
2007-06-28 22:29:56 +02:00
|
|
|
|
|
|
|
OpenGLWrapper gl;
|
2010-05-16 08:39:11 +02:00
|
|
|
E(gl.SetFillColour(color, alpha));
|
|
|
|
gl.SetLineColour(wxColor(0, 0, 0), 0.0, 1);
|
2007-06-28 22:29:56 +02:00
|
|
|
|
2010-05-13 20:37:46 +02:00
|
|
|
// Draw sides
|
2010-06-28 09:13:08 +02:00
|
|
|
E(gl.DrawRectangle(gapH, 0, w-gapH, sizeV)); // Top
|
2010-05-16 08:39:11 +02:00
|
|
|
E(gl.DrawRectangle(w-sizeH, gapV, w, h-gapV)); // Right
|
|
|
|
E(gl.DrawRectangle(gapH, h-sizeV, w-gapH, h)); // Bottom
|
2010-06-28 09:13:08 +02:00
|
|
|
E(gl.DrawRectangle(0, gapV, sizeH, h-gapV)); // Left
|
2007-06-28 22:29:56 +02:00
|
|
|
|
2010-05-13 20:37:46 +02:00
|
|
|
// Draw rounded corners
|
2010-06-28 09:13:08 +02:00
|
|
|
E(gl.DrawRing(gapH, gapV, rad1, rad2, 1.0, 180.0, 270.0)); // Top-left
|
|
|
|
E(gl.DrawRing(w-gapH, gapV, rad1, rad2, 1.0, 90.0, 180.0)); // Top-right
|
2010-05-16 08:39:11 +02:00
|
|
|
E(gl.DrawRing(w-gapH, h-gapV, rad1, rad2, 1.0, 0.0, 90.0)); // Bottom-right
|
2010-06-28 09:13:08 +02:00
|
|
|
E(gl.DrawRing(gapH, h-gapV, rad1, rad2, 1.0,270.0,360.0)); // Bottom-left
|
2007-06-28 22:29:56 +02:00
|
|
|
|
2010-05-16 08:39:11 +02:00
|
|
|
E(glDisable(GL_BLEND));
|
2007-06-28 22:29:56 +02:00
|
|
|
}
|
|
|
|
|
2010-12-07 20:09:28 +01:00
|
|
|
void VideoDisplay::UpdateSize(int arType, double arValue) {
|
2011-01-16 08:17:08 +01:00
|
|
|
if (!con->videoController->IsLoaded()) return;
|
2007-01-23 21:50:41 +01:00
|
|
|
if (!IsShownOnScreen()) return;
|
2007-01-22 00:16:03 +01:00
|
|
|
|
2011-01-16 08:17:08 +01:00
|
|
|
int vidW = con->videoController->GetWidth();
|
|
|
|
int vidH = con->videoController->GetHeight();
|
2010-12-07 20:09:28 +01:00
|
|
|
|
|
|
|
if (arType == -1) {
|
2011-01-16 08:17:08 +01:00
|
|
|
arType = con->videoController->GetAspectRatioType();
|
|
|
|
arValue = con->videoController->GetAspectRatioValue();
|
2010-12-07 20:09:28 +01:00
|
|
|
}
|
2010-01-31 19:49:37 +01:00
|
|
|
|
2010-05-16 08:38:59 +02:00
|
|
|
if (freeSize) {
|
2010-05-16 08:39:06 +02:00
|
|
|
GetClientSize(&w,&h);
|
2010-05-16 08:39:11 +02:00
|
|
|
viewport_x = 0;
|
|
|
|
viewport_bottom = 0;
|
|
|
|
viewport_top = 0;
|
|
|
|
viewport_width = w;
|
|
|
|
viewport_height = h;
|
2010-05-16 08:39:06 +02:00
|
|
|
|
2010-05-16 08:38:59 +02:00
|
|
|
// Set aspect ratio
|
2010-12-07 20:09:28 +01:00
|
|
|
double displayAr = double(w) / h;
|
|
|
|
double videoAr = arType == 0 ? double(vidW)/vidH : arValue;
|
2010-05-16 08:38:59 +02:00
|
|
|
|
|
|
|
// Window is wider than video, blackbox left/right
|
|
|
|
if (displayAr - videoAr > 0.01f) {
|
|
|
|
int delta = w - videoAr * h;
|
2010-05-16 08:39:11 +02:00
|
|
|
viewport_x = delta / 2;
|
|
|
|
viewport_width = w - delta;
|
2010-05-16 08:38:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// Video is wider than window, blackbox top/bottom
|
|
|
|
else if (videoAr - displayAr > 0.01f) {
|
|
|
|
int delta = h - w / videoAr;
|
2010-05-16 08:39:11 +02:00
|
|
|
viewport_top = viewport_bottom = delta / 2;
|
|
|
|
viewport_height = h - delta;
|
2010-05-16 08:38:59 +02:00
|
|
|
}
|
|
|
|
}
|
2010-05-16 08:39:06 +02:00
|
|
|
else {
|
|
|
|
wxWindow* parent = GetParent();
|
|
|
|
while (!parent->IsTopLevel()) parent = parent->GetParent();
|
|
|
|
int maxH, maxW;
|
|
|
|
parent->GetClientSize(&maxW, &maxH);
|
|
|
|
|
|
|
|
h = vidH * zoomValue;
|
2010-12-07 20:09:28 +01:00
|
|
|
w = arType == 0 ? vidW * zoomValue : vidH * zoomValue * arValue;
|
2010-05-16 08:39:06 +02:00
|
|
|
|
|
|
|
// Cap the canvas size to the window size
|
2010-08-13 07:51:17 +02:00
|
|
|
int cw = std::min(w, maxW), ch = std::min(h, maxH);
|
2010-05-16 08:39:06 +02:00
|
|
|
|
2010-05-16 08:39:11 +02:00
|
|
|
viewport_x = 0;
|
|
|
|
viewport_bottom = ch - h;
|
|
|
|
viewport_top = 0;
|
|
|
|
viewport_width = w;
|
|
|
|
viewport_height = h;
|
|
|
|
|
|
|
|
wxSize size(cw, ch);
|
2010-08-03 22:21:19 +02:00
|
|
|
SetMinClientSize(size);
|
|
|
|
SetMaxClientSize(size);
|
2010-05-16 08:39:06 +02:00
|
|
|
|
2010-12-07 20:09:28 +01:00
|
|
|
SetEvtHandlerEnabled(false);
|
2010-05-16 08:39:06 +02:00
|
|
|
box->GetParent()->Layout();
|
|
|
|
|
|
|
|
// The sizer makes us use the full width, which at very low zoom levels
|
|
|
|
// results in stretched video, so after using the sizer to update the
|
|
|
|
// parent window sizes, reset our size to the correct value
|
2010-05-16 08:39:11 +02:00
|
|
|
SetSize(cw, ch);
|
2010-05-16 08:39:06 +02:00
|
|
|
|
2010-12-07 20:09:28 +01:00
|
|
|
SetEvtHandlerEnabled(true);
|
2010-05-16 08:39:06 +02:00
|
|
|
}
|
2010-05-16 08:38:59 +02:00
|
|
|
|
2011-01-16 08:17:08 +01:00
|
|
|
con->videoController->GetScriptSize(scriptW, scriptH);
|
2010-05-16 08:39:11 +02:00
|
|
|
video.w = w;
|
|
|
|
video.h = h;
|
|
|
|
|
2010-07-23 06:15:36 +02:00
|
|
|
if (tool.get()) tool->Refresh();
|
2010-05-16 08:39:11 +02:00
|
|
|
|
2010-06-28 09:13:15 +02:00
|
|
|
wxGLCanvas::Refresh(false);
|
2006-01-22 13:44:53 +01:00
|
|
|
}
|
2006-01-16 22:02:54 +01:00
|
|
|
|
2010-05-13 20:37:46 +02:00
|
|
|
void VideoDisplay::OnPaint(wxPaintEvent&) {
|
2007-01-21 07:30:19 +01:00
|
|
|
Render();
|
2006-01-16 22:02:54 +01:00
|
|
|
}
|
|
|
|
|
2007-01-23 05:42:08 +01:00
|
|
|
void VideoDisplay::OnSizeEvent(wxSizeEvent &event) {
|
2009-09-10 03:41:34 +02:00
|
|
|
if (freeSize) UpdateSize();
|
2007-01-23 21:50:41 +01:00
|
|
|
event.Skip();
|
2007-01-23 05:42:08 +01:00
|
|
|
}
|
|
|
|
|
2006-01-16 22:02:54 +01:00
|
|
|
void VideoDisplay::OnMouseEvent(wxMouseEvent& event) {
|
2010-05-16 08:39:11 +02:00
|
|
|
assert(w > 0);
|
2008-03-07 00:27:54 +01:00
|
|
|
|
2006-01-16 22:02:54 +01:00
|
|
|
// Disable when playing
|
2011-01-16 08:17:08 +01:00
|
|
|
if (con->videoController->IsPlaying()) return;
|
2006-01-16 22:02:54 +01:00
|
|
|
|
|
|
|
if (event.ButtonUp(wxMOUSE_BTN_RIGHT)) {
|
|
|
|
wxMenu menu;
|
|
|
|
menu.Append(VIDEO_MENU_SAVE_SNAPSHOT,_("Save PNG snapshot"));
|
|
|
|
menu.Append(VIDEO_MENU_COPY_TO_CLIPBOARD,_("Copy image to Clipboard"));
|
2007-04-08 00:03:06 +02:00
|
|
|
menu.AppendSeparator();
|
2009-05-15 14:44:36 +02:00
|
|
|
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)"));
|
2007-04-08 00:03:06 +02:00
|
|
|
menu.AppendSeparator();
|
2006-01-16 22:02:54 +01:00
|
|
|
menu.Append(VIDEO_MENU_COPY_COORDS,_("Copy coordinates to Clipboard"));
|
2007-04-18 06:51:17 +02:00
|
|
|
|
|
|
|
// Show cursor and popup
|
|
|
|
ShowCursor(true);
|
2006-01-16 22:02:54 +01:00
|
|
|
PopupMenu(&menu);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2007-01-09 02:52:30 +01:00
|
|
|
if (event.ButtonDown(wxMOUSE_BTN_ANY)) {
|
|
|
|
SetFocus();
|
|
|
|
}
|
2010-05-13 20:37:35 +02:00
|
|
|
int wheel = event.GetWheelRotation();
|
|
|
|
if (wheel) {
|
|
|
|
SetZoom (zoomValue + .125 * (wheel / event.GetWheelDelta()));
|
|
|
|
}
|
2007-01-09 02:52:30 +01:00
|
|
|
|
2010-05-16 08:39:11 +02:00
|
|
|
if (event.Leaving()) {
|
2010-12-31 22:03:03 +01:00
|
|
|
video.x = INT_MIN;
|
|
|
|
video.y = INT_MIN;
|
2010-05-16 08:39:11 +02:00
|
|
|
}
|
|
|
|
else {
|
2010-12-31 22:03:03 +01:00
|
|
|
video.x = event.GetX();
|
|
|
|
video.y = event.GetY();
|
2010-05-16 08:39:11 +02:00
|
|
|
}
|
2006-01-16 22:02:54 +01:00
|
|
|
|
2010-05-16 08:39:11 +02:00
|
|
|
tool->OnMouseEvent(event);
|
|
|
|
ShowCursor(activeMode != Video_Mode_Standard);
|
|
|
|
}
|
Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
|
|
|
void VideoDisplay::OnKeyDown(wxKeyEvent &event) {
|
|
|
|
hotkey::check("Video Display", event.GetKeyCode(), event.GetUnicodeKey(), event.GetModifiers());
|
|
|
|
event.StopPropagation();
|
|
|
|
|
|
|
|
/*
|
2009-08-14 00:07:43 +02:00
|
|
|
int key = event.GetKeyCode();
|
|
|
|
#ifdef __APPLE__
|
2010-05-16 08:39:11 +02:00
|
|
|
Hotkeys.SetPressed(key, event.m_metaDown, event.m_altDown, event.m_shiftDown);
|
2009-08-14 00:07:43 +02:00
|
|
|
#else
|
2010-05-16 08:39:11 +02:00
|
|
|
Hotkeys.SetPressed(key, event.m_controlDown, event.m_altDown, event.m_shiftDown);
|
2009-08-14 00:07:43 +02:00
|
|
|
#endif
|
|
|
|
|
2010-05-16 08:39:11 +02:00
|
|
|
if (Hotkeys.IsPressed(L"Visual Tool Default")) SetMode(Video_Mode_Standard);
|
|
|
|
else if (Hotkeys.IsPressed(L"Visual Tool Drag")) SetMode(Video_Mode_Drag);
|
|
|
|
else if (Hotkeys.IsPressed(L"Visual Tool Rotate Z")) SetMode(Video_Mode_Rotate_Z);
|
|
|
|
else if (Hotkeys.IsPressed(L"Visual Tool Rotate X/Y")) SetMode(Video_Mode_Rotate_XY);
|
|
|
|
else if (Hotkeys.IsPressed(L"Visual Tool Scale")) SetMode(Video_Mode_Scale);
|
|
|
|
else if (Hotkeys.IsPressed(L"Visual Tool Rectangular Clip")) SetMode(Video_Mode_Clip);
|
|
|
|
else if (Hotkeys.IsPressed(L"Visual Tool Vector Clip")) SetMode(Video_Mode_Vector_Clip);
|
2007-07-27 06:05:18 +02:00
|
|
|
event.Skip();
|
Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
|
|
|
*/
|
2007-01-09 02:52:30 +01:00
|
|
|
}
|
|
|
|
|
Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
|
|
|
|
2006-01-16 22:02:54 +01:00
|
|
|
void VideoDisplay::SetZoom(double value) {
|
2010-08-12 08:39:49 +02:00
|
|
|
zoomValue = std::max(value, .125);
|
2010-08-13 07:51:17 +02:00
|
|
|
if (zoomBox) zoomBox->SetValue(wxString::Format("%g%%", zoomValue * 100.));
|
2007-01-21 07:30:19 +01:00
|
|
|
UpdateSize();
|
2006-01-16 22:02:54 +01:00
|
|
|
}
|
2010-05-01 03:07:05 +02:00
|
|
|
void VideoDisplay::SetZoomFromBox() {
|
2010-08-13 07:51:17 +02:00
|
|
|
if (!zoomBox) return;
|
2010-05-01 03:07:05 +02:00
|
|
|
wxString strValue = zoomBox->GetValue();
|
|
|
|
strValue.EndsWith(L"%", &strValue);
|
|
|
|
double value;
|
|
|
|
if (strValue.ToDouble(&value)) {
|
|
|
|
zoomValue = value / 100.;
|
|
|
|
UpdateSize();
|
|
|
|
}
|
|
|
|
}
|
2010-05-16 08:39:11 +02:00
|
|
|
double VideoDisplay::GetZoom() const {
|
2010-05-01 03:07:05 +02:00
|
|
|
return zoomValue;
|
2006-01-16 22:02:54 +01:00
|
|
|
}
|
|
|
|
|
2010-05-16 08:39:11 +02:00
|
|
|
template<class T>
|
|
|
|
void VideoDisplay::SetTool() {
|
2010-05-26 09:17:39 +02:00
|
|
|
tool.reset();
|
2011-01-16 08:17:08 +01:00
|
|
|
tool.reset(new T(this, con, video, toolBar));
|
2010-05-16 08:39:11 +02:00
|
|
|
box->Bind(wxEVT_COMMAND_TOOL_CLICKED, &T::OnSubTool, static_cast<T*>(tool.get()), VISUAL_SUB_TOOL_START, VISUAL_SUB_TOOL_END);
|
|
|
|
}
|
|
|
|
void VideoDisplay::OnMode(const wxCommandEvent &event) {
|
|
|
|
SetMode(event.GetId());
|
|
|
|
}
|
|
|
|
void VideoDisplay::SetMode(int mode) {
|
|
|
|
if (activeMode == mode) return;
|
|
|
|
|
|
|
|
toolBar->ClearTools();
|
|
|
|
toolBar->Realize();
|
|
|
|
toolBar->Show(false);
|
|
|
|
|
|
|
|
if (!box->visualToolBar->GetToolState(mode)) {
|
|
|
|
box->visualToolBar->ToggleTool(mode, true);
|
|
|
|
}
|
|
|
|
|
|
|
|
activeMode = mode;
|
|
|
|
switch (mode) {
|
|
|
|
case Video_Mode_Standard: SetTool<VisualToolCross>(); break;
|
|
|
|
case Video_Mode_Drag: SetTool<VisualToolDrag>(); break;
|
|
|
|
case Video_Mode_Rotate_Z: SetTool<VisualToolRotateZ>(); break;
|
|
|
|
case Video_Mode_Rotate_XY: SetTool<VisualToolRotateXY>(); break;
|
|
|
|
case Video_Mode_Scale: SetTool<VisualToolScale>(); break;
|
|
|
|
case Video_Mode_Clip: SetTool<VisualToolClip>(); break;
|
|
|
|
case Video_Mode_Vector_Clip: SetTool<VisualToolVectorClip>(); break;
|
|
|
|
default: assert(false); break;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Update size as the new typesetting tool may have changed the subtoolbar size
|
|
|
|
UpdateSize();
|
|
|
|
}
|
|
|
|
|
|
|
|
void VideoDisplay::ToScriptCoords(int *x, int *y) const {
|
|
|
|
int sx = *x - viewport_x > 0 ? viewport_width : -viewport_width;
|
|
|
|
int sy = *y - viewport_top > 0 ? viewport_height : -viewport_height;
|
|
|
|
*x = ((*x - viewport_x) * scriptW + sx / 2) / viewport_width;
|
|
|
|
*y = ((*y - viewport_top) * scriptH + sy / 2) / viewport_height;
|
|
|
|
}
|
|
|
|
void VideoDisplay::FromScriptCoords(int *x, int *y) const {
|
|
|
|
int sx = *x > 0 ? scriptW : -scriptW;
|
|
|
|
int sy = *y > 0 ? scriptH : -scriptH;
|
|
|
|
*x = (*x * viewport_width + sx / 2) / scriptW + viewport_x;
|
|
|
|
*y = (*y * viewport_height + sy / 2) / scriptH + viewport_top;
|
|
|
|
}
|
|
|
|
|
2010-05-13 20:37:46 +02:00
|
|
|
void VideoDisplay::OnCopyToClipboard(wxCommandEvent &) {
|
2006-01-16 22:02:54 +01:00
|
|
|
if (wxTheClipboard->Open()) {
|
2011-01-16 08:17:08 +01:00
|
|
|
wxTheClipboard->SetData(new wxBitmapDataObject(wxBitmap(con->videoController->GetFrame(currentFrame)->GetImage(),24)));
|
2006-01-16 22:02:54 +01:00
|
|
|
wxTheClipboard->Close();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-05-13 20:37:46 +02:00
|
|
|
void VideoDisplay::OnCopyToClipboardRaw(wxCommandEvent &) {
|
2007-04-08 00:03:06 +02:00
|
|
|
if (wxTheClipboard->Open()) {
|
2011-01-16 08:17:08 +01:00
|
|
|
wxTheClipboard->SetData(new wxBitmapDataObject(wxBitmap(con->videoController->GetFrame(currentFrame,true)->GetImage(),24)));
|
2007-04-08 00:03:06 +02:00
|
|
|
wxTheClipboard->Close();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-05-13 20:37:46 +02:00
|
|
|
void VideoDisplay::OnSaveSnapshot(wxCommandEvent &) {
|
2011-01-16 08:17:08 +01:00
|
|
|
con->videoController->SaveSnapshot(false);
|
2007-04-08 00:03:06 +02:00
|
|
|
}
|
|
|
|
|
2010-05-13 20:37:46 +02:00
|
|
|
void VideoDisplay::OnSaveSnapshotRaw(wxCommandEvent &) {
|
2011-01-16 08:17:08 +01:00
|
|
|
con->videoController->SaveSnapshot(true);
|
2006-01-16 22:02:54 +01:00
|
|
|
}
|
|
|
|
|
2010-05-13 20:37:46 +02:00
|
|
|
void VideoDisplay::OnCopyCoords(wxCommandEvent &) {
|
2006-01-16 22:02:54 +01:00
|
|
|
if (wxTheClipboard->Open()) {
|
2010-05-16 08:39:11 +02:00
|
|
|
int x = video.x;
|
|
|
|
int y = video.y;
|
|
|
|
ToScriptCoords(&x, &y);
|
|
|
|
wxTheClipboard->SetData(new wxTextDataObject(wxString::Format(L"%i,%i",x,y)));
|
2006-01-16 22:02:54 +01:00
|
|
|
wxTheClipboard->Close();
|
|
|
|
}
|
|
|
|
}
|