2006-01-16 22:02:54 +01:00
|
|
|
// Copyright (c) 2005, 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.
|
|
|
|
//
|
2009-07-29 07:43:02 +02:00
|
|
|
// Aegisub Project http://www.aegisub.org/
|
|
|
|
|
|
|
|
/// @file video_box.cpp
|
|
|
|
/// @brief The video area in the main window, including surrounding tool bars
|
|
|
|
/// @ingroup main_ui video
|
|
|
|
///
|
2006-01-16 22:02:54 +01:00
|
|
|
|
2009-01-04 07:31:48 +01:00
|
|
|
#include "config.h"
|
|
|
|
|
2012-01-22 06:59:23 +01:00
|
|
|
#include <wx/combobox.h>
|
|
|
|
#include <wx/sizer.h>
|
2009-09-10 15:06:40 +02:00
|
|
|
#include <wx/statline.h>
|
2012-01-22 06:59:23 +01:00
|
|
|
#include <wx/textctrl.h>
|
|
|
|
#include <wx/toolbar.h>
|
2009-09-10 15:06:40 +02:00
|
|
|
|
2012-01-22 06:59:23 +01:00
|
|
|
#include "video_box.h"
|
|
|
|
|
2011-01-16 08:17:08 +01:00
|
|
|
#include "include/aegisub/context.h"
|
2011-11-06 18:18:20 +01:00
|
|
|
#include "include/aegisub/toolbar.h"
|
2011-01-16 08:17:08 +01:00
|
|
|
|
2011-01-23 08:48:07 +01:00
|
|
|
#include "ass_dialogue.h"
|
|
|
|
#include "ass_file.h"
|
2011-01-20 06:58:01 +01:00
|
|
|
#include "command/command.h"
|
2011-01-23 08:48:07 +01:00
|
|
|
#include "compat.h"
|
2009-09-10 15:06:40 +02:00
|
|
|
#include "libresrc/libresrc.h"
|
2013-01-07 02:50:09 +01:00
|
|
|
#include "options.h"
|
2010-12-08 04:36:10 +01:00
|
|
|
#include "selection_controller.h"
|
2009-09-10 15:06:40 +02:00
|
|
|
#include "video_context.h"
|
|
|
|
#include "video_display.h"
|
|
|
|
#include "video_slider.h"
|
2006-01-16 22:02:54 +01:00
|
|
|
|
2011-07-15 06:06:16 +02:00
|
|
|
VideoBox::VideoBox(wxWindow *parent, bool isDetached, agi::Context *context)
|
2012-01-31 01:44:26 +01:00
|
|
|
: wxPanel(parent,-1)
|
2011-01-20 06:58:01 +01:00
|
|
|
, context(context)
|
2007-01-11 04:53:20 +01:00
|
|
|
{
|
2012-06-12 04:59:41 +02:00
|
|
|
// Seek
|
2013-11-21 18:13:36 +01:00
|
|
|
auto videoSlider = new VideoSlider(this, context);
|
2012-06-12 04:59:41 +02:00
|
|
|
videoSlider->SetToolTip(_("Seek video"));
|
|
|
|
|
2007-01-11 06:33:36 +01:00
|
|
|
// Buttons
|
2012-12-10 17:58:30 +01:00
|
|
|
wxToolBar *mainToolbar = toolbar::GetToolbar(this, "video", context, "Video", false);
|
2006-01-29 16:08:51 +01:00
|
|
|
|
2006-01-16 22:02:54 +01:00
|
|
|
// Position
|
2011-01-20 06:58:01 +01:00
|
|
|
VideoPosition = new wxTextCtrl(this,-1,"",wxDefaultPosition,wxSize(110,20),wxTE_READONLY);
|
2012-02-07 02:22:32 +01:00
|
|
|
VideoPosition->SetToolTip(_("Current frame time and number"));
|
2006-01-16 22:02:54 +01:00
|
|
|
|
|
|
|
// Times of sub relative to video
|
2011-01-20 06:58:01 +01:00
|
|
|
VideoSubsPos = new wxTextCtrl(this,-1,"",wxDefaultPosition,wxSize(110,20),wxTE_READONLY);
|
2012-02-07 02:22:32 +01:00
|
|
|
VideoSubsPos->SetToolTip(_("Time of this frame relative to start and end of current subs"));
|
2006-01-16 22:02:54 +01:00
|
|
|
|
2011-07-15 06:06:16 +02:00
|
|
|
// Zoom box
|
|
|
|
wxArrayString choices;
|
2012-12-10 17:58:30 +01:00
|
|
|
for (int i = 1 ; i <= 24; ++i)
|
2011-07-15 06:06:16 +02:00
|
|
|
choices.Add(wxString::Format("%g%%", i * 12.5));
|
2012-01-27 20:23:16 +01:00
|
|
|
wxComboBox *zoomBox = new wxComboBox(this, -1, "75%", wxDefaultPosition, wxDefaultSize, choices, wxCB_DROPDOWN | wxTE_PROCESS_ENTER);
|
2011-07-15 06:06:16 +02:00
|
|
|
|
2007-01-11 04:53:20 +01:00
|
|
|
// Typesetting buttons
|
2012-01-22 06:59:23 +01:00
|
|
|
wxToolBar *visualToolBar = toolbar::GetToolbar(this, "visual_tools", context, "Video", true);
|
2007-01-11 04:53:20 +01:00
|
|
|
|
2012-01-22 06:59:36 +01:00
|
|
|
// Visual controls sub-toolbar
|
|
|
|
wxToolBar *visualSubToolBar = new wxToolBar(this, -1, wxDefaultPosition, wxDefaultSize, wxTB_VERTICAL | wxTB_BOTTOM | wxTB_FLAT);
|
|
|
|
|
2013-11-21 18:13:36 +01:00
|
|
|
auto videoDisplay = new VideoDisplay(visualSubToolBar, isDetached, zoomBox, this, context);
|
2012-06-12 04:59:41 +02:00
|
|
|
videoDisplay->MoveBeforeInTabOrder(videoSlider);
|
2009-09-10 03:41:34 +02:00
|
|
|
|
2012-01-22 06:59:36 +01:00
|
|
|
wxSizer *toolbarSizer = new wxBoxSizer(wxVERTICAL);
|
2012-05-26 22:16:12 +02:00
|
|
|
toolbarSizer->Add(visualToolBar, wxSizerFlags(1));
|
2012-01-22 06:59:36 +01:00
|
|
|
toolbarSizer->Add(visualSubToolBar, wxSizerFlags());
|
|
|
|
|
2007-01-11 04:53:20 +01:00
|
|
|
// Top sizer
|
2012-07-04 17:30:16 +02:00
|
|
|
wxSizer *topSizer = new wxBoxSizer(wxHORIZONTAL);
|
|
|
|
topSizer->Add(toolbarSizer, 0, wxEXPAND);
|
|
|
|
topSizer->Add(videoDisplay, isDetached, isDetached ? wxEXPAND : 0);
|
2006-01-16 22:02:54 +01:00
|
|
|
|
|
|
|
// Sizers
|
2011-01-23 08:48:07 +01:00
|
|
|
wxSizer *videoSliderSizer = new wxBoxSizer(wxHORIZONTAL);
|
2012-07-04 17:30:16 +02:00
|
|
|
videoSliderSizer->Add(videoSlider, wxSizerFlags(1).Expand());
|
2012-12-10 17:58:30 +01:00
|
|
|
|
|
|
|
wxSizer *videoBottomSizer = new wxBoxSizer(wxHORIZONTAL);
|
|
|
|
videoBottomSizer->Add(mainToolbar, wxSizerFlags(0).Center());
|
2012-07-04 17:30:16 +02:00
|
|
|
videoBottomSizer->Add(VideoPosition, wxSizerFlags(1).Center().Border(wxLEFT));
|
2013-01-10 04:38:41 +01:00
|
|
|
videoBottomSizer->Add(VideoSubsPos, wxSizerFlags(1).Center().Border(wxLEFT));
|
|
|
|
videoBottomSizer->Add(zoomBox, wxSizerFlags(0).Center().Border(wxLEFT | wxRIGHT));
|
2009-06-04 01:08:40 +02:00
|
|
|
|
2011-01-23 08:48:07 +01:00
|
|
|
wxSizer *VideoSizer = new wxBoxSizer(wxVERTICAL);
|
2012-07-04 17:30:16 +02:00
|
|
|
VideoSizer->Add(topSizer, 1, wxEXPAND, 0);
|
|
|
|
VideoSizer->Add(new wxStaticLine(this), 0, wxEXPAND, 0);
|
2006-01-16 22:02:54 +01:00
|
|
|
VideoSizer->Add(videoSliderSizer,0,wxEXPAND,0);
|
2012-12-10 17:58:30 +01:00
|
|
|
VideoSizer->Add(videoBottomSizer,0,wxEXPAND | wxBOTTOM,5);
|
2007-01-11 04:53:20 +01:00
|
|
|
SetSizer(VideoSizer);
|
2007-01-11 06:33:36 +01:00
|
|
|
|
2011-08-17 07:32:21 +02:00
|
|
|
UpdateTimeBoxes();
|
|
|
|
|
2011-01-23 08:48:07 +01:00
|
|
|
slots.push_back(context->videoController->AddSeekListener(&VideoBox::UpdateTimeBoxes, this));
|
|
|
|
slots.push_back(context->videoController->AddKeyframesListener(&VideoBox::UpdateTimeBoxes, this));
|
|
|
|
slots.push_back(context->videoController->AddTimecodesListener(&VideoBox::UpdateTimeBoxes, this));
|
|
|
|
slots.push_back(context->videoController->AddVideoOpenListener(&VideoBox::UpdateTimeBoxes, this));
|
|
|
|
slots.push_back(context->ass->AddCommitListener(&VideoBox::UpdateTimeBoxes, this));
|
2012-10-05 05:22:54 +02:00
|
|
|
slots.push_back(context->selectionController->AddSelectionListener(&VideoBox::UpdateTimeBoxes, this));
|
2007-01-11 06:33:36 +01:00
|
|
|
}
|
|
|
|
|
2011-01-23 08:48:07 +01:00
|
|
|
void VideoBox::UpdateTimeBoxes() {
|
|
|
|
if (!context->videoController->IsLoaded()) return;
|
|
|
|
|
|
|
|
int frame = context->videoController->GetFrameN();
|
|
|
|
int time = context->videoController->TimeAtFrame(frame, agi::vfr::EXACT);
|
|
|
|
|
|
|
|
// Set the text box for frame number and time
|
2012-10-12 03:52:36 +02:00
|
|
|
VideoPosition->SetValue(wxString::Format("%s - %d", AssTime(time).GetAssFormated(true), frame));
|
2011-01-23 08:48:07 +01:00
|
|
|
if (binary_search(context->videoController->GetKeyFrames().begin(), context->videoController->GetKeyFrames().end(), frame)) {
|
|
|
|
// Set the background color to indicate this is a keyframe
|
2012-10-26 16:09:14 +02:00
|
|
|
VideoPosition->SetBackgroundColour(to_wx(OPT_GET("Colour/Subtitle Grid/Background/Selection")->GetColor()));
|
|
|
|
VideoPosition->SetForegroundColour(to_wx(OPT_GET("Colour/Subtitle Grid/Selection")->GetColor()));
|
2011-01-23 08:48:07 +01:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
VideoPosition->SetBackgroundColour(wxNullColour);
|
|
|
|
VideoPosition->SetForegroundColour(wxNullColour);
|
|
|
|
}
|
|
|
|
|
|
|
|
AssDialogue *active_line = context->selectionController->GetActiveLine();
|
2013-06-13 01:23:22 +02:00
|
|
|
if (!active_line)
|
2011-01-23 08:48:07 +01:00
|
|
|
VideoSubsPos->SetValue("");
|
|
|
|
else {
|
|
|
|
VideoSubsPos->SetValue(wxString::Format(
|
|
|
|
"%+dms; %+dms",
|
2011-12-22 22:28:51 +01:00
|
|
|
time - active_line->Start,
|
|
|
|
time - active_line->End));
|
2011-01-23 08:48:07 +01:00
|
|
|
}
|
|
|
|
}
|