Make VideoDisplay set its initial zoom itself rather than FrameMain
Originally committed to SVN as r4739.
This commit is contained in:
parent
6bb5dd0bfd
commit
768f74ae3c
6 changed files with 40 additions and 20 deletions
|
@ -75,7 +75,7 @@ DialogDetachedVideo::DialogDetachedVideo(FrameMain *par, const wxSize &initialDi
|
|||
wxPanel *panel = new wxPanel(this,-1,wxDefaultPosition,wxDefaultSize,wxTAB_TRAVERSAL | wxCLIP_CHILDREN);
|
||||
|
||||
// Video area;
|
||||
videoBox = new VideoBox(panel, true);
|
||||
videoBox = new VideoBox(panel, true, NULL);
|
||||
videoBox->videoDisplay->freeSize = true;
|
||||
videoBox->videoDisplay->SetClientSize(initialDisplaySize);
|
||||
videoBox->videoSlider->grid = par->SubsGrid;
|
||||
|
|
|
@ -579,9 +579,8 @@ void FrameMain::InitContents() {
|
|||
|
||||
// Video area;
|
||||
StartupLog(_T("Create video box"));
|
||||
videoBox = new VideoBox(Panel, false);
|
||||
videoBox = new VideoBox(Panel, false, ZoomBox);
|
||||
TopSizer->Add(videoBox,0,wxEXPAND,0);
|
||||
videoBox->videoDisplay->zoomBox = ZoomBox;
|
||||
|
||||
// Subtitles area
|
||||
StartupLog(_T("Create subtitles grid"));
|
||||
|
@ -589,8 +588,6 @@ void FrameMain::InitContents() {
|
|||
BottomSizer->Add(SubsGrid,1,wxEXPAND | wxLEFT | wxRIGHT | wxBOTTOM,0);
|
||||
videoBox->videoSlider->grid = SubsGrid;
|
||||
VideoContext::Get()->grid = SubsGrid;
|
||||
StartupLog(_T("Reset video zoom"));
|
||||
videoBox->videoDisplay->SetZoom(OPT_GET("Video/Default Zoom")->GetInt() * .125 + .125);
|
||||
Search.grid = SubsGrid;
|
||||
|
||||
// Audio area
|
||||
|
|
|
@ -63,7 +63,7 @@
|
|||
/// @param parent
|
||||
/// @param isDetached
|
||||
///
|
||||
VideoBox::VideoBox(wxWindow *parent, bool isDetached)
|
||||
VideoBox::VideoBox(wxWindow *parent, bool isDetached, wxComboBox *zoomBox)
|
||||
: wxPanel (parent,-1)
|
||||
{
|
||||
// Parent
|
||||
|
@ -114,9 +114,8 @@ VideoBox::VideoBox(wxWindow *parent, bool isDetached)
|
|||
visualToolBar->SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE));
|
||||
|
||||
// Display
|
||||
videoDisplay = new VideoDisplay(this,videoSlider,VideoPosition,VideoSubsPos,videoPage,-1,wxDefaultPosition,wxDefaultSize,wxSUNKEN_BORDER);
|
||||
videoDisplay = new VideoDisplay(this,videoSlider,VideoPosition,VideoSubsPos,zoomBox,videoPage,-1,wxDefaultPosition,wxDefaultSize,wxSUNKEN_BORDER);
|
||||
VideoContext::Get()->AddDisplay(videoDisplay);
|
||||
videoDisplay->Reset();
|
||||
|
||||
// Set display
|
||||
videoSlider->Display = videoDisplay;
|
||||
|
|
|
@ -54,6 +54,7 @@ class VideoDisplay;
|
|||
class VideoSlider;
|
||||
class ToggleBitmap;
|
||||
class FrameMain;
|
||||
class wxComboBox;
|
||||
|
||||
|
||||
|
||||
|
@ -104,7 +105,7 @@ public:
|
|||
/// DOCME
|
||||
VideoSlider *videoSlider;
|
||||
|
||||
VideoBox (wxWindow *parent, bool isDetached);
|
||||
VideoBox (wxWindow *parent, bool isDetached, wxComboBox *zoomBox);
|
||||
|
||||
DECLARE_EVENT_TABLE()
|
||||
};
|
||||
|
|
|
@ -122,16 +122,25 @@ public:
|
|||
|
||||
#define E(cmd) cmd; if (GLenum err = glGetError()) throw OpenGlException(L###cmd, err)
|
||||
|
||||
using std::min;
|
||||
|
||||
VideoDisplay::VideoDisplay(VideoBox *box, VideoSlider *ControlSlider, wxTextCtrl *PositionDisplay, wxTextCtrl *SubsPosition, wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style, const wxString& name)
|
||||
VideoDisplay::VideoDisplay(
|
||||
VideoBox *box,
|
||||
VideoSlider *ControlSlider,
|
||||
wxTextCtrl *PositionDisplay,
|
||||
wxTextCtrl *SubsPosition,
|
||||
wxComboBox *zoomBox,
|
||||
wxWindow* parent,
|
||||
wxWindowID id,
|
||||
const wxPoint& pos,
|
||||
const wxSize& size,
|
||||
long style,
|
||||
const wxString& name)
|
||||
: wxGLCanvas (parent, id, attribList, pos, size, style, name)
|
||||
, alwaysShowTools(OPT_GET("Tool/Visual/Always Show"))
|
||||
, origSize(size)
|
||||
, currentFrame(-1)
|
||||
, w(8), h(8), viewport_x(0), viewport_width(0), viewport_bottom(0), viewport_top(0), viewport_height(0)
|
||||
, locked(false)
|
||||
, zoomValue(1.0)
|
||||
, zoomValue(OPT_GET("Video/Default Zoom")->GetInt() * .125 + .125)
|
||||
, ControlSlider(ControlSlider)
|
||||
, SubsPosition(SubsPosition)
|
||||
, PositionDisplay(PositionDisplay)
|
||||
|
@ -140,9 +149,11 @@ VideoDisplay::VideoDisplay(VideoBox *box, VideoSlider *ControlSlider, wxTextCtrl
|
|||
, toolBar(box->visualSubToolBar)
|
||||
, scriptW(INT_MIN)
|
||||
, scriptH(INT_MIN)
|
||||
, zoomBox(zoomBox)
|
||||
, box(box)
|
||||
, freeSize(false)
|
||||
{
|
||||
if (zoomBox) zoomBox->SetValue(wxString::Format("%g%%", zoomValue * 100.));
|
||||
box->Bind(wxEVT_COMMAND_TOOL_CLICKED, &VideoDisplay::OnMode, this, Video_Mode_Standard, Video_Mode_Vector_Clip);
|
||||
VideoContext::Get()->Bind(EVT_FRAME_READY, &VideoDisplay::UploadFrameData, this);
|
||||
SetCursor(wxNullCursor);
|
||||
|
@ -265,7 +276,7 @@ void VideoDisplay::Render() try {
|
|||
assert(w > 0);
|
||||
|
||||
videoOut->Render(viewport_x, viewport_bottom, viewport_width, viewport_height);
|
||||
E(glViewport(0, min(viewport_bottom, 0), w, h));
|
||||
E(glViewport(0, std::min(viewport_bottom, 0), w, h));
|
||||
|
||||
E(glMatrixMode(GL_PROJECTION));
|
||||
E(glLoadIdentity());
|
||||
|
@ -394,7 +405,7 @@ void VideoDisplay::UpdateSize() {
|
|||
w = con->GetAspectRatioType() == 0 ? vidW * zoomValue : vidH * zoomValue * con->GetAspectRatioValue();
|
||||
|
||||
// Cap the canvas size to the window size
|
||||
int cw = min(w, maxW), ch = min(h, maxH);
|
||||
int cw = std::min(w, maxW), ch = std::min(h, maxH);
|
||||
|
||||
viewport_x = 0;
|
||||
viewport_bottom = ch - h;
|
||||
|
@ -513,10 +524,11 @@ void VideoDisplay::OnKey(wxKeyEvent &event) {
|
|||
|
||||
void VideoDisplay::SetZoom(double value) {
|
||||
zoomValue = std::max(value, .125);
|
||||
zoomBox->SetValue(wxString::Format("%g%%", zoomValue * 100.));
|
||||
if (zoomBox) zoomBox->SetValue(wxString::Format("%g%%", zoomValue * 100.));
|
||||
UpdateSize();
|
||||
}
|
||||
void VideoDisplay::SetZoomFromBox() {
|
||||
if (!zoomBox) return;
|
||||
wxString strValue = zoomBox->GetValue();
|
||||
strValue.EndsWith(L"%", &strValue);
|
||||
double value;
|
||||
|
|
|
@ -169,13 +169,13 @@ class VideoDisplay : public wxGLCanvas {
|
|||
|
||||
VideoState video;
|
||||
|
||||
/// The dropdown box for selecting zoom levels
|
||||
wxComboBox *zoomBox;
|
||||
|
||||
public:
|
||||
/// The VideoBox this display is contained in
|
||||
VideoBox *box;
|
||||
|
||||
/// The dropdown box for selecting zoom levels
|
||||
wxComboBox *zoomBox;
|
||||
|
||||
/// Whether the display can be freely resized by the user
|
||||
bool freeSize;
|
||||
|
||||
|
@ -186,7 +186,18 @@ public:
|
|||
/// @param size Window size. wxDefaultSize is (-1, -1) which indicates that wxWidgets should generate a default size for the window. If no suitable size can be found, the window will be sized to 20x20 pixels so that the window is visible but obviously not correctly sized.
|
||||
/// @param style Window style.
|
||||
/// @param name Window name.
|
||||
VideoDisplay(VideoBox *box, VideoSlider *ControlSlider, wxTextCtrl *PositionDisplay, wxTextCtrl *SubsPosition, wxWindow* parent, wxWindowID id, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = 0, const wxString& name = wxPanelNameStr);
|
||||
VideoDisplay(
|
||||
VideoBox *box,
|
||||
VideoSlider *ControlSlider,
|
||||
wxTextCtrl *PositionDisplay,
|
||||
wxTextCtrl *SubsPosition,
|
||||
wxComboBox *zoomBox,
|
||||
wxWindow* parent,
|
||||
wxWindowID id,
|
||||
const wxPoint& pos = wxDefaultPosition,
|
||||
const wxSize& size = wxDefaultSize,
|
||||
long style = 0,
|
||||
const wxString& name = wxPanelNameStr);
|
||||
~VideoDisplay();
|
||||
/// @brief Reset the size of the display to the video size
|
||||
void Reset();
|
||||
|
|
Loading…
Reference in a new issue