Make VideoDisplay set its initial zoom itself rather than FrameMain

Originally committed to SVN as r4739.
This commit is contained in:
Thomas Goyne 2010-08-13 05:51:17 +00:00
parent 6bb5dd0bfd
commit 768f74ae3c
6 changed files with 40 additions and 20 deletions

View file

@ -75,7 +75,7 @@ DialogDetachedVideo::DialogDetachedVideo(FrameMain *par, const wxSize &initialDi
wxPanel *panel = new wxPanel(this,-1,wxDefaultPosition,wxDefaultSize,wxTAB_TRAVERSAL | wxCLIP_CHILDREN); wxPanel *panel = new wxPanel(this,-1,wxDefaultPosition,wxDefaultSize,wxTAB_TRAVERSAL | wxCLIP_CHILDREN);
// Video area; // Video area;
videoBox = new VideoBox(panel, true); videoBox = new VideoBox(panel, true, NULL);
videoBox->videoDisplay->freeSize = true; videoBox->videoDisplay->freeSize = true;
videoBox->videoDisplay->SetClientSize(initialDisplaySize); videoBox->videoDisplay->SetClientSize(initialDisplaySize);
videoBox->videoSlider->grid = par->SubsGrid; videoBox->videoSlider->grid = par->SubsGrid;

View file

@ -579,9 +579,8 @@ void FrameMain::InitContents() {
// Video area; // Video area;
StartupLog(_T("Create video box")); StartupLog(_T("Create video box"));
videoBox = new VideoBox(Panel, false); videoBox = new VideoBox(Panel, false, ZoomBox);
TopSizer->Add(videoBox,0,wxEXPAND,0); TopSizer->Add(videoBox,0,wxEXPAND,0);
videoBox->videoDisplay->zoomBox = ZoomBox;
// Subtitles area // Subtitles area
StartupLog(_T("Create subtitles grid")); StartupLog(_T("Create subtitles grid"));
@ -589,8 +588,6 @@ void FrameMain::InitContents() {
BottomSizer->Add(SubsGrid,1,wxEXPAND | wxLEFT | wxRIGHT | wxBOTTOM,0); BottomSizer->Add(SubsGrid,1,wxEXPAND | wxLEFT | wxRIGHT | wxBOTTOM,0);
videoBox->videoSlider->grid = SubsGrid; videoBox->videoSlider->grid = SubsGrid;
VideoContext::Get()->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; Search.grid = SubsGrid;
// Audio area // Audio area

View file

@ -63,7 +63,7 @@
/// @param parent /// @param parent
/// @param isDetached /// @param isDetached
/// ///
VideoBox::VideoBox(wxWindow *parent, bool isDetached) VideoBox::VideoBox(wxWindow *parent, bool isDetached, wxComboBox *zoomBox)
: wxPanel (parent,-1) : wxPanel (parent,-1)
{ {
// Parent // Parent
@ -114,9 +114,8 @@ VideoBox::VideoBox(wxWindow *parent, bool isDetached)
visualToolBar->SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE)); visualToolBar->SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE));
// Display // 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); VideoContext::Get()->AddDisplay(videoDisplay);
videoDisplay->Reset();
// Set display // Set display
videoSlider->Display = videoDisplay; videoSlider->Display = videoDisplay;

View file

@ -54,6 +54,7 @@ class VideoDisplay;
class VideoSlider; class VideoSlider;
class ToggleBitmap; class ToggleBitmap;
class FrameMain; class FrameMain;
class wxComboBox;
@ -104,7 +105,7 @@ public:
/// DOCME /// DOCME
VideoSlider *videoSlider; VideoSlider *videoSlider;
VideoBox (wxWindow *parent, bool isDetached); VideoBox (wxWindow *parent, bool isDetached, wxComboBox *zoomBox);
DECLARE_EVENT_TABLE() DECLARE_EVENT_TABLE()
}; };

View file

@ -122,16 +122,25 @@ public:
#define E(cmd) cmd; if (GLenum err = glGetError()) throw OpenGlException(L###cmd, err) #define E(cmd) cmd; if (GLenum err = glGetError()) throw OpenGlException(L###cmd, err)
using std::min; VideoDisplay::VideoDisplay(
VideoBox *box,
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) 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) : wxGLCanvas (parent, id, attribList, pos, size, style, name)
, alwaysShowTools(OPT_GET("Tool/Visual/Always Show")) , alwaysShowTools(OPT_GET("Tool/Visual/Always Show"))
, origSize(size) , origSize(size)
, currentFrame(-1) , currentFrame(-1)
, w(8), h(8), viewport_x(0), viewport_width(0), viewport_bottom(0), viewport_top(0), viewport_height(0) , w(8), h(8), viewport_x(0), viewport_width(0), viewport_bottom(0), viewport_top(0), viewport_height(0)
, locked(false) , locked(false)
, zoomValue(1.0) , zoomValue(OPT_GET("Video/Default Zoom")->GetInt() * .125 + .125)
, ControlSlider(ControlSlider) , ControlSlider(ControlSlider)
, SubsPosition(SubsPosition) , SubsPosition(SubsPosition)
, PositionDisplay(PositionDisplay) , PositionDisplay(PositionDisplay)
@ -140,9 +149,11 @@ VideoDisplay::VideoDisplay(VideoBox *box, VideoSlider *ControlSlider, wxTextCtrl
, toolBar(box->visualSubToolBar) , toolBar(box->visualSubToolBar)
, scriptW(INT_MIN) , scriptW(INT_MIN)
, scriptH(INT_MIN) , scriptH(INT_MIN)
, zoomBox(zoomBox)
, box(box) , box(box)
, freeSize(false) , 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); 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); VideoContext::Get()->Bind(EVT_FRAME_READY, &VideoDisplay::UploadFrameData, this);
SetCursor(wxNullCursor); SetCursor(wxNullCursor);
@ -265,7 +276,7 @@ void VideoDisplay::Render() try {
assert(w > 0); assert(w > 0);
videoOut->Render(viewport_x, viewport_bottom, viewport_width, viewport_height); 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(glMatrixMode(GL_PROJECTION));
E(glLoadIdentity()); E(glLoadIdentity());
@ -394,7 +405,7 @@ void VideoDisplay::UpdateSize() {
w = con->GetAspectRatioType() == 0 ? vidW * zoomValue : vidH * zoomValue * con->GetAspectRatioValue(); w = con->GetAspectRatioType() == 0 ? vidW * zoomValue : vidH * zoomValue * con->GetAspectRatioValue();
// Cap the canvas size to the window size // 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_x = 0;
viewport_bottom = ch - h; viewport_bottom = ch - h;
@ -513,10 +524,11 @@ void VideoDisplay::OnKey(wxKeyEvent &event) {
void VideoDisplay::SetZoom(double value) { void VideoDisplay::SetZoom(double value) {
zoomValue = std::max(value, .125); zoomValue = std::max(value, .125);
zoomBox->SetValue(wxString::Format("%g%%", zoomValue * 100.)); if (zoomBox) zoomBox->SetValue(wxString::Format("%g%%", zoomValue * 100.));
UpdateSize(); UpdateSize();
} }
void VideoDisplay::SetZoomFromBox() { void VideoDisplay::SetZoomFromBox() {
if (!zoomBox) return;
wxString strValue = zoomBox->GetValue(); wxString strValue = zoomBox->GetValue();
strValue.EndsWith(L"%", &strValue); strValue.EndsWith(L"%", &strValue);
double value; double value;

View file

@ -169,13 +169,13 @@ class VideoDisplay : public wxGLCanvas {
VideoState video; VideoState video;
/// The dropdown box for selecting zoom levels
wxComboBox *zoomBox;
public: public:
/// The VideoBox this display is contained in /// The VideoBox this display is contained in
VideoBox *box; VideoBox *box;
/// The dropdown box for selecting zoom levels
wxComboBox *zoomBox;
/// Whether the display can be freely resized by the user /// Whether the display can be freely resized by the user
bool freeSize; 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 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 style Window style.
/// @param name Window name. /// @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(); ~VideoDisplay();
/// @brief Reset the size of the display to the video size /// @brief Reset the size of the display to the video size
void Reset(); void Reset();