2012-12-17 21:17:11 +01:00
|
|
|
// Copyright (c) 2012, Thomas Goyne <plorkyeran@aegisub.org>
|
2007-04-02 20:28:09 +02:00
|
|
|
//
|
2012-12-17 21:17:11 +01:00
|
|
|
// Permission to use, copy, modify, and distribute this software for any
|
|
|
|
// purpose with or without fee is hereby granted, provided that the above
|
|
|
|
// copyright notice and this permission notice appear in all copies.
|
2007-04-02 20:28:09 +02:00
|
|
|
//
|
2012-12-17 21:17:11 +01:00
|
|
|
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
|
|
// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
|
|
// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
|
|
// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
|
|
// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
|
|
// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
|
|
// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
2007-04-02 20:28:09 +02:00
|
|
|
//
|
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"
|
|
|
|
|
|
|
|
#include <wx/checkbox.h>
|
|
|
|
#include <wx/combobox.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>
|
2012-12-17 21:17:11 +01:00
|
|
|
#include <wx/valgen.h>
|
|
|
|
#include <wx/valnum.h>
|
2007-04-02 20:28:09 +02:00
|
|
|
|
2012-12-17 21:17:11 +01:00
|
|
|
#include "ass_time.h"
|
2012-01-18 21:08:42 +01:00
|
|
|
#include "colour_button.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"
|
2012-01-18 21:08:42 +01:00
|
|
|
#include "video_provider_dummy.h"
|
|
|
|
|
2012-12-17 21:17:11 +01:00
|
|
|
namespace {
|
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
|
|
|
|
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
|
|
|
|
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},
|
2012-12-17 21:17:11 +01:00
|
|
|
{"1024x576 (SuperPAL widescreen)", 1024, 576}
|
2007-04-02 20:28:09 +02:00
|
|
|
};
|
|
|
|
|
2012-12-17 21:17:11 +01:00
|
|
|
wxSpinCtrl *spin_ctrl(wxWindow *parent, int min, int max, int *value) {
|
|
|
|
auto ctrl = new wxSpinCtrl(parent, -1, "", wxDefaultPosition, wxSize(50, -1), wxSP_ARROW_KEYS, min, max, *value);
|
|
|
|
ctrl->SetValidator(wxGenericValidator(value));
|
|
|
|
return ctrl;
|
|
|
|
}
|
|
|
|
|
|
|
|
wxControl *spin_ctrl(wxWindow *parent, double min, double max, double *value) {
|
|
|
|
wxFloatingPointValidator<double> val(4, value);
|
|
|
|
val.SetRange(min, max);
|
|
|
|
return new wxTextCtrl(parent, -1, "", wxDefaultPosition, wxSize(50, -1), 0, val);
|
|
|
|
}
|
2012-10-26 16:09:14 +02:00
|
|
|
|
2012-12-17 21:17:11 +01:00
|
|
|
wxComboBox *resolution_shortcuts(wxWindow *parent, int width, int height) {
|
|
|
|
wxComboBox *ctrl = new wxComboBox(parent, -1, "", wxDefaultPosition, wxDefaultSize, 0, 0, wxCB_READONLY);
|
2012-10-26 16:09:14 +02:00
|
|
|
|
2012-12-17 21:17:11 +01:00
|
|
|
for (auto const& res : resolutions) {
|
|
|
|
ctrl->Append(res.name);
|
|
|
|
if (res.width == width && res.height == height)
|
|
|
|
ctrl->SetSelection(ctrl->GetCount() - 1);
|
2012-10-26 16:09:14 +02:00
|
|
|
}
|
|
|
|
|
2012-12-17 21:17:11 +01:00
|
|
|
return ctrl;
|
|
|
|
}
|
2012-10-26 16:09:14 +02:00
|
|
|
|
2007-04-02 20:28:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
DialogDummyVideo::DialogDummyVideo(wxWindow *parent)
|
2012-12-17 21:17:11 +01:00
|
|
|
: wxDialog(parent, -1, _("Dummy video options"))
|
|
|
|
, fps(OPT_GET("Video/Dummy/FPS")->GetDouble())
|
|
|
|
, width(OPT_GET("Video/Dummy/Last/Width")->GetInt())
|
|
|
|
, height(OPT_GET("Video/Dummy/Last/Height")->GetInt())
|
|
|
|
, length(OPT_GET("Video/Dummy/Last/Length")->GetInt())
|
|
|
|
, color(OPT_GET("Colour/Video Dummy/Last Colour")->GetColor())
|
|
|
|
, pattern(OPT_GET("Video/Dummy/Pattern")->GetBool())
|
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
|
|
|
wxBoxSizer *res_sizer = new wxBoxSizer(wxHORIZONTAL);
|
2012-12-17 21:17:11 +01:00
|
|
|
res_sizer->Add(spin_ctrl(this, 1, 10000, &width), wxSizerFlags(1).Expand());
|
|
|
|
res_sizer->Add(new wxStaticText(this, -1, " x "), wxSizerFlags().Center());
|
|
|
|
res_sizer->Add(spin_ctrl(this, 1, 10000, &height), wxSizerFlags(1).Expand());
|
|
|
|
|
|
|
|
wxBoxSizer *color_sizer = new wxBoxSizer(wxHORIZONTAL);
|
|
|
|
ColourButton *color_btn = new ColourButton(this, -1, wxSize(30, 17), color);
|
|
|
|
color_sizer->Add(color_btn, wxSizerFlags().DoubleBorder(wxRIGHT));
|
|
|
|
color_sizer->Add(new wxCheckBox(this, -1, _("Checkerboard &pattern"), wxDefaultPosition, wxDefaultSize, 0, wxGenericValidator(&pattern)), wxSizerFlags(1).Center());
|
|
|
|
|
|
|
|
sizer = new wxFlexGridSizer(2, 5, 5);
|
|
|
|
AddCtrl(_("Video resolution:"), resolution_shortcuts(this, width, height));
|
|
|
|
AddCtrl("", res_sizer);
|
|
|
|
AddCtrl(_("Color:"), color_sizer);
|
|
|
|
AddCtrl(_("Frame rate (fps):"), spin_ctrl(this, .1, 1000.0, &fps));
|
|
|
|
AddCtrl(_("Duration (frames):"), spin_ctrl(this, 2, 36000000, &length)); // Ten hours of 1k FPS
|
|
|
|
AddCtrl("", length_display = new wxStaticText(this, -1, ""));
|
|
|
|
|
|
|
|
wxStdDialogButtonSizer *btn_sizer = CreateStdDialogButtonSizer(wxOK | wxCANCEL | wxHELP);
|
|
|
|
btn_sizer->GetHelpButton()->Bind(wxEVT_COMMAND_BUTTON_CLICKED, std::bind(&HelpButton::OpenPage, "Dummy Video"));
|
2012-05-15 16:07:00 +02:00
|
|
|
|
2012-12-17 21:17:11 +01:00
|
|
|
wxBoxSizer *main_sizer = new wxBoxSizer(wxVERTICAL);
|
|
|
|
main_sizer->Add(sizer, wxSizerFlags(1).Border().Expand());
|
|
|
|
main_sizer->Add(new wxStaticLine(this, wxHORIZONTAL), wxSizerFlags().HorzBorder().Expand());
|
|
|
|
main_sizer->Add(btn_sizer, wxSizerFlags().Expand().Border());
|
2007-04-02 20:28:09 +02:00
|
|
|
|
|
|
|
UpdateLengthDisplay();
|
2007-04-25 06:09:42 +02:00
|
|
|
|
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
|
|
|
|
2012-12-17 21:17:11 +01:00
|
|
|
Bind(wxEVT_COMMAND_COMBOBOX_SELECTED, &DialogDummyVideo::OnResolutionShortcut, this);
|
|
|
|
color_btn->Bind(wxEVT_COMMAND_BUTTON_CLICKED, [=](wxCommandEvent& e) {
|
|
|
|
color = color_btn->GetColor();
|
|
|
|
e.Skip();
|
|
|
|
});
|
|
|
|
Bind(wxEVT_COMMAND_SPINCTRL_UPDATED, [=](wxCommandEvent&) {
|
|
|
|
TransferDataFromWindow();
|
|
|
|
UpdateLengthDisplay();
|
|
|
|
});
|
2007-04-02 20:28:09 +02:00
|
|
|
}
|
|
|
|
|
2012-12-17 21:17:11 +01:00
|
|
|
template<typename T>
|
|
|
|
void DialogDummyVideo::AddCtrl(wxString const& label, T *ctrl) {
|
|
|
|
if (!label)
|
|
|
|
sizer->AddStretchSpacer();
|
|
|
|
else
|
|
|
|
sizer->Add(new wxStaticText(this, -1, label), wxSizerFlags().Center().Left());
|
|
|
|
sizer->Add(ctrl, wxSizerFlags().Expand().Center().Left());
|
2007-04-02 20:28:09 +02:00
|
|
|
}
|
|
|
|
|
2012-12-17 21:17:11 +01:00
|
|
|
void DialogDummyVideo::OnResolutionShortcut(wxCommandEvent &e) {
|
|
|
|
TransferDataFromWindow();
|
|
|
|
int rs = e.GetSelection();
|
|
|
|
width = resolutions[rs].width;
|
|
|
|
height = resolutions[rs].height;
|
|
|
|
TransferDataToWindow();
|
2007-04-02 20:28:09 +02:00
|
|
|
}
|
|
|
|
|
2012-12-17 21:17:11 +01:00
|
|
|
void DialogDummyVideo::UpdateLengthDisplay() {
|
|
|
|
length_display->SetLabel(wxString::Format(_("Resulting duration: %s"), AssTime(length / fps * 1000).GetAssFormated(true)));
|
2007-04-02 20:28:09 +02:00
|
|
|
}
|
|
|
|
|
2012-12-17 21:17:11 +01:00
|
|
|
wxString DialogDummyVideo::CreateDummyVideo(wxWindow *parent) {
|
|
|
|
DialogDummyVideo dlg(parent);
|
|
|
|
if (dlg.ShowModal() != wxID_OK)
|
|
|
|
return "";
|
2007-04-02 20:28:09 +02:00
|
|
|
|
2012-12-17 21:17:11 +01:00
|
|
|
OPT_SET("Video/Dummy/FPS")->SetDouble(dlg.fps);
|
|
|
|
OPT_SET("Video/Dummy/Last/Width")->SetInt(dlg.width);
|
|
|
|
OPT_SET("Video/Dummy/Last/Height")->SetInt(dlg.height);
|
|
|
|
OPT_SET("Video/Dummy/Last/Length")->SetInt(dlg.length);
|
|
|
|
OPT_SET("Colour/Video Dummy/Last Colour")->SetColor(dlg.color);
|
|
|
|
OPT_SET("Video/Dummy/Pattern")->SetBool(dlg.pattern);
|
2012-03-25 06:05:06 +02:00
|
|
|
|
2012-12-17 21:17:11 +01:00
|
|
|
return DummyVideoProvider::MakeFilename(dlg.fps, dlg.length, dlg.width, dlg.height, dlg.color, dlg.pattern);
|
2007-04-02 20:28:09 +02:00
|
|
|
}
|