2010-06-02 09:22:53 +02:00
|
|
|
// Copyright (c) 2005-2010, Rodrigo Braz Monteiro
|
|
|
|
// 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.
|
|
|
|
//
|
|
|
|
// Aegisub Project http://www.aegisub.org/
|
|
|
|
//
|
|
|
|
// $Id$
|
|
|
|
|
|
|
|
/// @file video_display.h
|
|
|
|
/// @see video_display.cpp
|
|
|
|
/// @ingroup video main_ui
|
|
|
|
///
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef AGI_PRE
|
2011-01-02 02:44:54 +01:00
|
|
|
#include <list>
|
2012-07-29 05:23:24 +02:00
|
|
|
#include <tr1/memory>
|
2011-01-02 02:44:54 +01:00
|
|
|
|
2010-06-02 09:22:53 +02:00
|
|
|
#include <wx/glcanvas.h>
|
|
|
|
#endif
|
|
|
|
|
2012-01-13 21:18:40 +01:00
|
|
|
#include <typeinfo>
|
|
|
|
|
2011-08-27 08:30:23 +02:00
|
|
|
#include <libaegisub/scoped_ptr.h>
|
2010-12-31 22:02:42 +01:00
|
|
|
#include <libaegisub/signal.h>
|
2010-12-07 20:09:21 +01:00
|
|
|
|
2011-11-06 18:18:20 +01:00
|
|
|
#include "vector2d.h"
|
|
|
|
|
2010-06-02 09:22:53 +02:00
|
|
|
// Prototypes
|
2012-07-29 05:23:24 +02:00
|
|
|
class AegiVideoFrame;
|
2010-07-23 07:58:39 +02:00
|
|
|
class FrameReadyEvent;
|
2010-12-07 20:09:28 +01:00
|
|
|
class VideoContext;
|
2010-06-02 09:22:53 +02:00
|
|
|
class VideoOutGL;
|
2011-11-06 18:18:20 +01:00
|
|
|
class VisualToolBase;
|
2011-08-27 08:30:23 +02:00
|
|
|
class wxComboBox;
|
|
|
|
class wxTextCtrl;
|
2010-06-14 21:26:27 +02:00
|
|
|
class wxToolBar;
|
2011-01-16 08:17:08 +01:00
|
|
|
|
2010-06-04 05:07:33 +02:00
|
|
|
namespace agi {
|
2011-01-16 08:17:08 +01:00
|
|
|
struct Context;
|
2010-06-04 05:07:33 +02:00
|
|
|
class OptionValue;
|
|
|
|
}
|
2010-06-02 09:22:53 +02:00
|
|
|
|
|
|
|
/// @class VideoDisplay
|
|
|
|
/// @brief DOCME
|
2010-07-18 07:45:52 +02:00
|
|
|
class VideoDisplay : public wxGLCanvas {
|
2010-12-07 20:09:21 +01:00
|
|
|
/// Signals the display is connected to
|
|
|
|
std::list<agi::signal::Connection> slots;
|
|
|
|
|
2012-05-05 04:11:15 +02:00
|
|
|
const agi::OptionValue* autohideTools;
|
2010-12-07 20:09:28 +01:00
|
|
|
|
2011-01-16 08:17:08 +01:00
|
|
|
agi::Context *con;
|
2010-06-02 09:22:53 +02:00
|
|
|
|
2011-08-27 08:30:35 +02:00
|
|
|
agi::scoped_ptr<wxMenu> context_menu;
|
|
|
|
|
2010-06-02 09:22:53 +02:00
|
|
|
/// The frame number currently being displayed
|
|
|
|
int currentFrame;
|
|
|
|
|
2012-07-04 17:30:16 +02:00
|
|
|
/// The size of the video in screen at the current zoom level, which may not
|
|
|
|
/// be the same as the actual client size of the display
|
|
|
|
wxSize videoSize;
|
2010-06-02 09:22:53 +02:00
|
|
|
|
2012-08-26 03:33:44 +02:00
|
|
|
Vector2D last_mouse_pos, mouse_pos;
|
2011-11-06 18:18:20 +01:00
|
|
|
|
2010-06-02 09:22:53 +02:00
|
|
|
/// Screen pixels between the left of the canvas and the left of the video
|
2011-11-06 18:18:20 +01:00
|
|
|
int viewport_left;
|
2010-06-02 09:22:53 +02:00
|
|
|
/// The width of the video in screen pixels
|
|
|
|
int viewport_width;
|
|
|
|
/// Screen pixels between the bottom of the canvas and the bottom of the video; used for glViewport
|
|
|
|
int viewport_bottom;
|
|
|
|
/// Screen pixels between the bottom of the canvas and the top of the video; used for coordinate space conversion
|
|
|
|
int viewport_top;
|
|
|
|
/// The height of the video in screen pixels
|
|
|
|
int viewport_height;
|
|
|
|
|
|
|
|
/// The current zoom level, where 1.0 = 100%
|
|
|
|
double zoomValue;
|
|
|
|
|
|
|
|
/// The video renderer
|
2011-08-27 08:30:23 +02:00
|
|
|
agi::scoped_ptr<VideoOutGL> videoOut;
|
2010-06-02 09:22:53 +02:00
|
|
|
|
|
|
|
/// The active visual typesetting tool
|
2011-11-06 18:18:20 +01:00
|
|
|
agi::scoped_ptr<VisualToolBase> tool;
|
2010-06-02 09:22:53 +02:00
|
|
|
/// The toolbar used by individual typesetting tools
|
|
|
|
wxToolBar* toolBar;
|
|
|
|
|
2010-07-18 07:45:52 +02:00
|
|
|
/// The OpenGL context for this display
|
2011-08-27 08:30:23 +02:00
|
|
|
agi::scoped_ptr<wxGLContext> glContext;
|
2010-06-02 09:22:53 +02:00
|
|
|
|
2010-08-13 07:51:17 +02:00
|
|
|
/// The dropdown box for selecting zoom levels
|
|
|
|
wxComboBox *zoomBox;
|
|
|
|
|
2010-06-02 09:22:53 +02:00
|
|
|
/// Whether the display can be freely resized by the user
|
|
|
|
bool freeSize;
|
|
|
|
|
2012-07-29 05:23:24 +02:00
|
|
|
/// Frame which will replace the currently visible frame on the next render
|
|
|
|
std::tr1::shared_ptr<AegiVideoFrame> pending_frame;
|
|
|
|
|
2011-08-27 08:30:23 +02:00
|
|
|
/// @brief Draw an overscan mask
|
2011-11-06 18:18:20 +01:00
|
|
|
/// @param horizontal_percent The percent of the video reserved horizontally
|
|
|
|
/// @param vertical_percent The percent of the video reserved vertically
|
|
|
|
void DrawOverscanMask(float horizontal_percent, float vertical_percent) const;
|
2011-08-27 08:30:23 +02:00
|
|
|
|
|
|
|
/// Upload the image for the current frame to the video card
|
|
|
|
void UploadFrameData(FrameReadyEvent&);
|
|
|
|
|
|
|
|
/// @brief Initialize the gl context and set the active context to this one
|
|
|
|
/// @return Could the context be set?
|
|
|
|
bool InitContext();
|
|
|
|
|
2011-01-23 08:47:59 +01:00
|
|
|
/// @brief Set the size of the display based on the current zoom and video resolution
|
2012-07-04 17:30:16 +02:00
|
|
|
void UpdateSize();
|
|
|
|
void PositionVideo();
|
2012-01-27 20:23:26 +01:00
|
|
|
/// Set the zoom level to that indicated by the dropdown
|
2011-07-15 06:03:54 +02:00
|
|
|
void SetZoomFromBox(wxCommandEvent&);
|
2012-01-27 20:23:26 +01:00
|
|
|
/// Set the zoom level to that indicated by the text
|
|
|
|
void SetZoomFromBoxText(wxCommandEvent&);
|
2011-08-27 08:30:23 +02:00
|
|
|
|
|
|
|
/// @brief Key event handler
|
|
|
|
void OnKeyDown(wxKeyEvent &event);
|
|
|
|
/// @brief Mouse event handler
|
|
|
|
void OnMouseEvent(wxMouseEvent& event);
|
2011-08-31 06:17:37 +02:00
|
|
|
void OnMouseWheel(wxMouseEvent& event);
|
|
|
|
void OnMouseLeave(wxMouseEvent& event);
|
2011-08-27 08:30:23 +02:00
|
|
|
/// @brief Recalculate video positioning and scaling when the available area or zoom changes
|
|
|
|
void OnSizeEvent(wxSizeEvent &event);
|
2011-08-31 06:17:37 +02:00
|
|
|
void OnContextMenu(wxContextMenuEvent&);
|
2011-08-27 08:30:23 +02:00
|
|
|
|
2012-07-24 04:40:37 +02:00
|
|
|
void OnSubtitlesSave();
|
|
|
|
|
2011-01-23 08:47:59 +01:00
|
|
|
public:
|
2010-06-02 09:22:53 +02:00
|
|
|
/// @brief Constructor
|
2010-08-13 07:51:17 +02:00
|
|
|
VideoDisplay(
|
2011-11-12 02:23:29 +01:00
|
|
|
wxToolBar *visualSubToolBar,
|
2011-01-23 08:47:59 +01:00
|
|
|
bool isDetached,
|
2010-08-13 07:51:17 +02:00
|
|
|
wxComboBox *zoomBox,
|
|
|
|
wxWindow* parent,
|
2011-01-16 08:17:08 +01:00
|
|
|
agi::Context *context);
|
2010-06-02 09:22:53 +02:00
|
|
|
~VideoDisplay();
|
|
|
|
|
|
|
|
/// @brief Render the currently visible frame
|
|
|
|
void Render();
|
|
|
|
|
|
|
|
/// @brief Set the zoom level
|
|
|
|
/// @param value The new zoom level
|
|
|
|
void SetZoom(double value);
|
|
|
|
/// @brief Get the current zoom level
|
2011-01-23 08:48:07 +01:00
|
|
|
double GetZoom() const { return zoomValue; }
|
2010-06-02 09:22:53 +02:00
|
|
|
|
2011-11-06 18:18:20 +01:00
|
|
|
/// Get the last seen position of the mouse in script coordinates
|
|
|
|
Vector2D GetMousePosition() const;
|
|
|
|
|
|
|
|
void SetTool(VisualToolBase *new_tool);
|
2012-01-13 21:18:40 +01:00
|
|
|
|
|
|
|
bool ToolIsType(std::type_info const& type) const;
|
2012-04-03 19:38:38 +02:00
|
|
|
|
|
|
|
/// Discard all OpenGL state
|
2012-07-04 17:30:21 +02:00
|
|
|
void Unload();
|
2010-06-02 09:22:53 +02:00
|
|
|
};
|