2007-04-02 20:28:09 +02:00
|
|
|
// Copyright (c) 2007, Niels Martin Hansen
|
|
|
|
// 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 dialog_dummy_video.cpp
|
|
|
|
/// @brief Set up dummy video provider
|
|
|
|
/// @ingroup secondary_ui
|
|
|
|
///
|
2007-04-02 20:28:09 +02:00
|
|
|
|
|
|
|
|
2009-01-04 07:31:48 +01:00
|
|
|
#include "config.h"
|
|
|
|
|
2012-01-18 21:08:42 +01:00
|
|
|
#include "dialog_dummy_video.h"
|
|
|
|
|
2009-09-10 15:06:40 +02:00
|
|
|
#ifndef AGI_PRE
|
2012-09-25 01:35:27 +02:00
|
|
|
#include <functional>
|
2012-05-15 16:07:00 +02:00
|
|
|
|
2012-01-18 21:08:42 +01:00
|
|
|
#include <wx/checkbox.h>
|
|
|
|
#include <wx/combobox.h>
|
2007-04-02 20:28:09 +02:00
|
|
|
#include <wx/datetime.h>
|
2007-09-12 01:22:26 +02:00
|
|
|
#include <wx/log.h>
|
2009-09-10 15:06:40 +02:00
|
|
|
#include <wx/sizer.h>
|
2012-01-18 21:08:42 +01:00
|
|
|
#include <wx/spinctrl.h>
|
2009-09-10 07:25:25 +02:00
|
|
|
#include <wx/statline.h>
|
2012-01-18 21:08:42 +01:00
|
|
|
#include <wx/stattext.h>
|
|
|
|
#include <wx/string.h>
|
|
|
|
#include <wx/textctrl.h>
|
2009-09-10 15:06:40 +02:00
|
|
|
#endif
|
2007-04-02 20:28:09 +02:00
|
|
|
|
2012-01-18 21:08:42 +01:00
|
|
|
#include "colour_button.h"
|
2010-05-21 03:13:36 +02:00
|
|
|
#include "compat.h"
|
2009-09-10 15:06:40 +02:00
|
|
|
#include "help_button.h"
|
2012-04-03 22:40:33 +02:00
|
|
|
#include "libresrc/libresrc.h"
|
2010-05-21 03:13:36 +02:00
|
|
|
#include "main.h"
|
|
|
|
#include "utils.h"
|
2012-01-18 21:08:42 +01:00
|
|
|
#include "video_provider_dummy.h"
|
|
|
|
|
|
|
|
enum {
|
|
|
|
Dummy_Video_Resolution_Shortcut = 1700,
|
|
|
|
Dummy_Video_FPS,
|
|
|
|
Dummy_Video_Length
|
|
|
|
};
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
|
|
|
|
/// DOCME
|
2007-04-02 20:28:09 +02:00
|
|
|
struct ResolutionShortcut {
|
2011-09-28 21:43:11 +02:00
|
|
|
const char *name;
|
2007-04-02 20:28:09 +02:00
|
|
|
int width;
|
|
|
|
int height;
|
|
|
|
};
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
|
|
|
|
/// DOCME
|
2007-04-02 20:28:09 +02:00
|
|
|
static ResolutionShortcut resolutions[] = {
|
2011-09-28 21:43:11 +02:00
|
|
|
{"640x480 (SD fullscreen)", 640, 480},
|
|
|
|
{"704x480 (SD anamorphic)", 704, 480},
|
|
|
|
{"640x360 (SD widescreen)", 640, 360},
|
|
|
|
{"704x396 (SD widescreen)", 704, 396},
|
|
|
|
{"640x352 (SD widescreen MOD16)", 640, 352},
|
|
|
|
{"704x400 (SD widescreen MOD16)", 704, 400},
|
|
|
|
{"1280x720 (HD 720p)", 1280, 720},
|
|
|
|
{"1920x1080 (HD 1080p)", 1920, 1080},
|
|
|
|
{"1024x576 (SuperPAL widescreen)", 1024, 576},
|
2007-04-02 20:28:09 +02:00
|
|
|
{0, 0, 0}
|
|
|
|
};
|
|
|
|
|
|
|
|
bool DialogDummyVideo::CreateDummyVideo(wxWindow *parent, wxString &out_filename)
|
|
|
|
{
|
|
|
|
DialogDummyVideo dlg(parent);
|
2012-10-26 16:09:14 +02:00
|
|
|
if (dlg.ShowModal() != wxID_OK)
|
2007-04-02 20:28:09 +02:00
|
|
|
return false;
|
2012-10-26 16:09:14 +02:00
|
|
|
|
|
|
|
double fps;
|
|
|
|
long width, height, length;
|
|
|
|
agi::Color colour;
|
|
|
|
bool pattern;
|
|
|
|
|
|
|
|
// Read back values and check sensibility
|
|
|
|
if (!dlg.fps->GetValue().ToDouble(&fps) || fps <= 0) {
|
|
|
|
wxLogWarning("Invalid framerate specified, assuming 23.976");
|
|
|
|
fps = 24/1.001;
|
|
|
|
}
|
|
|
|
if (!dlg.width->GetValue().ToLong(&width) || width <= 0) {
|
|
|
|
wxLogWarning("Invalid width specified");
|
|
|
|
width = 0;
|
|
|
|
}
|
|
|
|
if (!dlg.height->GetValue().ToLong(&height) || height <= 0) {
|
|
|
|
wxLogWarning("Invalid height specified");
|
|
|
|
height = 0;
|
2007-04-02 20:28:09 +02:00
|
|
|
}
|
2012-10-26 16:09:14 +02:00
|
|
|
if (width == 0 && height == 0) {
|
|
|
|
wxLogWarning("Assuming 640x480");
|
|
|
|
width = 640; height = 480;
|
|
|
|
} else if (width == 0) {
|
|
|
|
width = height * 4 / 3;
|
|
|
|
wxLogWarning("Assuming 4:3 fullscreen, %dx%d", width, height);
|
|
|
|
} else if (height == 0) {
|
|
|
|
height = width * 3 / 4;
|
|
|
|
wxLogWarning("Assuming 4:3 fullscreen, %dx%d", width, height);
|
|
|
|
}
|
|
|
|
if ((length = dlg.length->GetValue()) <= 0) {
|
|
|
|
wxLogWarning("Invalid duration, assuming 2 frames");
|
|
|
|
length = 2;
|
|
|
|
}
|
|
|
|
colour = dlg.colour->GetColor();
|
|
|
|
pattern = dlg.pattern->GetValue();
|
|
|
|
|
|
|
|
// Write to options
|
|
|
|
OPT_SET("Video/Dummy/FPS")->SetDouble(fps);
|
|
|
|
OPT_SET("Video/Dummy/Last/Width")->SetInt(width);
|
|
|
|
OPT_SET("Video/Dummy/Last/Height")->SetInt(height);
|
|
|
|
OPT_SET("Video/Dummy/Last/Length")->SetInt(length);
|
|
|
|
OPT_SET("Colour/Video Dummy/Last Colour")->SetColor(colour);
|
|
|
|
OPT_SET("Video/Dummy/Pattern")->SetBool(pattern);
|
|
|
|
|
|
|
|
out_filename = DummyVideoProvider::MakeFilename(fps, length, width, height, colour, pattern);
|
|
|
|
return true;
|
2007-04-02 20:28:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
DialogDummyVideo::DialogDummyVideo(wxWindow *parent)
|
2007-04-03 02:14:05 +02:00
|
|
|
: wxDialog(parent, -1, _("Dummy video options"),wxDefaultPosition,wxDefaultSize)
|
2007-04-02 20:28:09 +02:00
|
|
|
{
|
2012-04-03 22:40:33 +02:00
|
|
|
SetIcon(GETICON(use_dummy_video_menu_16));
|
|
|
|
|
2007-04-02 20:28:09 +02:00
|
|
|
// Main controls
|
|
|
|
length_display = 0;
|
2011-09-28 21:43:11 +02:00
|
|
|
resolution_shortcuts = new wxComboBox(this, Dummy_Video_Resolution_Shortcut, "", wxDefaultPosition, wxDefaultSize, 0, 0, wxCB_READONLY);
|
2007-04-02 20:28:09 +02:00
|
|
|
width = new wxTextCtrl(this, -1);
|
|
|
|
height = new wxTextCtrl(this, -1);
|
2012-10-26 16:09:14 +02:00
|
|
|
colour = new ColourButton(this, -1, wxSize(30, 17), OPT_GET("Colour/Video Dummy/Last Colour")->GetColor());
|
2012-05-15 16:06:55 +02:00
|
|
|
pattern = new wxCheckBox(this, -1, _("Checkerboard &pattern"));
|
2010-05-21 03:13:36 +02:00
|
|
|
fps = new wxTextCtrl(this, Dummy_Video_FPS, wxString::Format("%f", OPT_GET("Video/Dummy/FPS")->GetDouble()));
|
2010-10-11 22:06:20 +02:00
|
|
|
length = new wxSpinCtrl(this, Dummy_Video_Length, "", wxDefaultPosition, wxDefaultSize, 4096|wxALIGN_LEFT);
|
2011-09-28 21:43:11 +02:00
|
|
|
length_display = new wxStaticText(this, -1, "");
|
2007-04-02 20:28:09 +02:00
|
|
|
|
|
|
|
// Support controls and layout
|
|
|
|
wxFlexGridSizer *fg = new wxFlexGridSizer(2, 5, 5);
|
|
|
|
fg->Add(new wxStaticText(this, -1, _("Video resolution:")), 0, wxALIGN_CENTRE_VERTICAL);
|
2007-04-04 04:24:46 +02:00
|
|
|
fg->Add(resolution_shortcuts, 0, wxEXPAND);
|
2007-04-02 20:28:09 +02:00
|
|
|
fg->AddStretchSpacer();
|
|
|
|
wxBoxSizer *res_sizer = new wxBoxSizer(wxHORIZONTAL);
|
2007-04-04 04:24:46 +02:00
|
|
|
res_sizer->Add(width, 0, wxEXPAND);
|
2011-09-28 21:43:11 +02:00
|
|
|
res_sizer->Add(new wxStaticText(this, -1, " x "), 0, wxALIGN_CENTRE_VERTICAL|wxFIXED_MINSIZE);
|
2007-04-04 04:24:46 +02:00
|
|
|
res_sizer->Add(height, 0, wxEXPAND);
|
|
|
|
fg->Add(res_sizer, 0, wxEXPAND);
|
2012-04-03 19:38:50 +02:00
|
|
|
fg->Add(new wxStaticText(this, -1, _("Color:")), 0, wxALIGN_CENTRE_VERTICAL);
|
2010-10-11 22:06:20 +02:00
|
|
|
fg->Add(colour, 0, wxALIGN_LEFT|wxALIGN_CENTRE_VERTICAL);
|
2007-04-04 03:54:37 +02:00
|
|
|
fg->AddStretchSpacer();
|
2007-04-04 04:24:46 +02:00
|
|
|
fg->Add(pattern, 0, wxALIGN_LEFT|wxALIGN_CENTRE_VERTICAL);
|
2007-04-02 20:28:09 +02:00
|
|
|
fg->Add(new wxStaticText(this, -1, _("Frame rate (fps):")), 0, wxALIGN_CENTRE_VERTICAL);
|
2007-04-04 04:24:46 +02:00
|
|
|
fg->Add(fps, 0, wxEXPAND);
|
2007-04-02 20:28:09 +02:00
|
|
|
fg->Add(new wxStaticText(this, -1, _("Duration (frames):")), 0, wxALIGN_CENTRE_VERTICAL);
|
2007-04-04 04:24:46 +02:00
|
|
|
fg->Add(length, 0, wxEXPAND);
|
2007-04-02 20:28:09 +02:00
|
|
|
fg->AddStretchSpacer();
|
2007-04-04 04:24:46 +02:00
|
|
|
fg->Add(length_display, 0, wxEXPAND|wxALIGN_CENTRE_VERTICAL|wxALIGN_LEFT);
|
2007-04-02 20:28:09 +02:00
|
|
|
wxBoxSizer *main_sizer = new wxBoxSizer(wxVERTICAL);
|
2007-04-25 06:09:42 +02:00
|
|
|
main_sizer->Add(fg, 1, wxALL|wxEXPAND, 5);
|
2008-01-13 23:41:34 +01:00
|
|
|
|
2012-05-15 16:07:00 +02:00
|
|
|
wxStdDialogButtonSizer *btnSizer = CreateStdDialogButtonSizer(wxOK | wxCANCEL | wxHELP);
|
|
|
|
ok_button = btnSizer->GetAffirmativeButton();
|
2012-09-25 01:35:27 +02:00
|
|
|
btnSizer->GetHelpButton()->Bind(wxEVT_COMMAND_BUTTON_CLICKED, std::bind(&HelpButton::OpenPage, "Dummy Video"));
|
2012-05-15 16:07:00 +02:00
|
|
|
|
2008-01-13 23:41:34 +01:00
|
|
|
main_sizer->Add(new wxStaticLine(this,wxHORIZONTAL),0,wxALL|wxEXPAND,5);
|
|
|
|
main_sizer->Add(btnSizer,0,wxLEFT|wxRIGHT|wxBOTTOM|wxEXPAND,5);
|
2007-04-02 20:28:09 +02:00
|
|
|
|
|
|
|
// Initialise controls
|
|
|
|
int lastwidth, lastheight, lastres = 0;
|
2010-05-21 03:13:36 +02:00
|
|
|
lastwidth = OPT_GET("Video/Dummy/Last/Width")->GetInt();
|
|
|
|
lastheight = OPT_GET("Video/Dummy/Last/Height")->GetInt();
|
2007-04-02 20:28:09 +02:00
|
|
|
for (ResolutionShortcut *res = resolutions; res->name; ++res) {
|
|
|
|
resolution_shortcuts->Append(res->name);
|
|
|
|
if (res->width == lastwidth && res->height == lastheight)
|
|
|
|
resolution_shortcuts->SetSelection(lastres);
|
|
|
|
lastres++;
|
|
|
|
}
|
2010-05-21 03:13:36 +02:00
|
|
|
pattern->SetValue(OPT_GET("Video/Dummy/Pattern")->GetBool());
|
|
|
|
width->ChangeValue(AegiIntegerToString(OPT_GET("Video/Dummy/Last/Width")->GetInt()));
|
|
|
|
height->ChangeValue(AegiIntegerToString(OPT_GET("Video/Dummy/Last/Height")->GetInt()));
|
2007-04-02 20:28:09 +02:00
|
|
|
length->SetRange(0, 0x10000000);
|
2010-05-21 03:13:36 +02:00
|
|
|
length->SetValue(OPT_GET("Video/Dummy/Last/Length")->GetInt());
|
2007-04-02 20:28:09 +02:00
|
|
|
UpdateLengthDisplay();
|
2007-04-25 06:09:42 +02:00
|
|
|
|
|
|
|
// Layout
|
2011-12-22 22:09:31 +01:00
|
|
|
SetSizerAndFit(main_sizer);
|
2007-04-25 06:09:42 +02:00
|
|
|
CenterOnParent();
|
2007-04-02 20:28:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
DialogDummyVideo::~DialogDummyVideo()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
BEGIN_EVENT_TABLE(DialogDummyVideo,wxDialog)
|
|
|
|
EVT_COMBOBOX(Dummy_Video_Resolution_Shortcut, DialogDummyVideo::OnResolutionShortcut)
|
|
|
|
EVT_TEXT(Dummy_Video_FPS, DialogDummyVideo::OnFpsChange)
|
|
|
|
EVT_SPINCTRL(Dummy_Video_Length, DialogDummyVideo::OnLengthSpin)
|
|
|
|
EVT_TEXT(Dummy_Video_Length, DialogDummyVideo::OnLengthChange)
|
|
|
|
END_EVENT_TABLE()
|
|
|
|
|
2011-12-22 22:09:31 +01:00
|
|
|
void DialogDummyVideo::OnResolutionShortcut(wxCommandEvent &)
|
2007-04-02 20:28:09 +02:00
|
|
|
{
|
|
|
|
int rs = resolution_shortcuts->GetSelection();
|
2011-09-28 21:43:11 +02:00
|
|
|
width->ChangeValue(wxString::Format("%d", resolutions[rs].width));
|
|
|
|
height->ChangeValue(wxString::Format("%d", resolutions[rs].height));
|
2007-04-02 20:28:09 +02:00
|
|
|
}
|
|
|
|
|
2011-12-22 22:09:31 +01:00
|
|
|
void DialogDummyVideo::OnFpsChange(wxCommandEvent &)
|
2007-04-02 20:28:09 +02:00
|
|
|
{
|
|
|
|
UpdateLengthDisplay();
|
|
|
|
}
|
|
|
|
|
2011-12-22 22:09:31 +01:00
|
|
|
void DialogDummyVideo::OnLengthSpin(wxSpinEvent &)
|
2007-04-02 20:28:09 +02:00
|
|
|
{
|
|
|
|
UpdateLengthDisplay();
|
|
|
|
}
|
|
|
|
|
2011-12-22 22:09:31 +01:00
|
|
|
void DialogDummyVideo::OnLengthChange(wxCommandEvent &)
|
2007-04-02 20:28:09 +02:00
|
|
|
{
|
|
|
|
UpdateLengthDisplay();
|
|
|
|
}
|
|
|
|
|
|
|
|
void DialogDummyVideo::UpdateLengthDisplay()
|
|
|
|
{
|
|
|
|
double fpsval;
|
|
|
|
if (!length_display) return;
|
2008-03-18 06:24:21 +01:00
|
|
|
bool valid = false;
|
|
|
|
if (fps->GetValue().ToDouble(&fpsval)) {
|
2012-03-10 03:16:08 +01:00
|
|
|
int lengthval = length->GetValue();
|
2008-03-18 06:24:21 +01:00
|
|
|
if (lengthval && fpsval > 0 && lengthval > 0) {
|
|
|
|
valid = true;
|
|
|
|
int tt = int(lengthval / fpsval * 1000); // frames / (frames/seconds) * 1000 = milliseconds
|
|
|
|
// 32 bit signed int can hold almost 600 positive hours when counting milliseconds, ASS allows at most just below 10 hours, so we're safe
|
|
|
|
int ms, s, m, h;
|
|
|
|
ms = tt % 1000; tt /= 1000;
|
|
|
|
s = tt % 60; tt /= 60;
|
|
|
|
m = tt % 60; tt /= 60;
|
|
|
|
h = tt;
|
|
|
|
length_display->SetLabel(wxString::Format(_("Resulting duration: %d:%02d:%02d.%03d"), h, m, s, ms));
|
|
|
|
ok_button->Enable();
|
|
|
|
}
|
|
|
|
}
|
2012-03-25 06:05:06 +02:00
|
|
|
|
2008-03-18 06:24:21 +01:00
|
|
|
if (!valid) {
|
2007-04-02 20:28:09 +02:00
|
|
|
length_display->SetLabel(_("Invalid fps or length value"));
|
|
|
|
ok_button->Disable();
|
|
|
|
}
|
|
|
|
}
|