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/
|
|
|
|
|
2014-05-22 21:07:15 +02:00
|
|
|
#include "colour_button.h"
|
2014-05-29 17:28:37 +02:00
|
|
|
#include "format.h"
|
2014-05-22 21:07:15 +02:00
|
|
|
#include "help_button.h"
|
|
|
|
#include "libresrc/libresrc.h"
|
|
|
|
#include "options.h"
|
|
|
|
#include "validators.h"
|
|
|
|
#include "video_provider_dummy.h"
|
2007-04-02 20:28:09 +02:00
|
|
|
|
2014-07-06 16:28:58 +02:00
|
|
|
#include <libaegisub/ass/time.h>
|
2014-05-22 21:07:15 +02:00
|
|
|
#include <libaegisub/color.h>
|
2012-01-18 21:08:42 +01:00
|
|
|
|
|
|
|
#include <wx/checkbox.h>
|
|
|
|
#include <wx/combobox.h>
|
2014-05-22 21:07:15 +02:00
|
|
|
#include <wx/dialog.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>
|
2007-04-02 20:28:09 +02:00
|
|
|
|
2012-12-17 21:17:11 +01:00
|
|
|
namespace {
|
2014-05-31 02:05:25 +02:00
|
|
|
struct DialogDummyVideo {
|
|
|
|
wxDialog d;
|
|
|
|
|
2014-05-22 21:07:15 +02:00
|
|
|
double fps = OPT_GET("Video/Dummy/FPS")->GetDouble();
|
|
|
|
int width = OPT_GET("Video/Dummy/Last/Width")->GetInt();
|
|
|
|
int height = OPT_GET("Video/Dummy/Last/Height")->GetInt();
|
|
|
|
int length = OPT_GET("Video/Dummy/Last/Length")->GetInt();
|
|
|
|
agi::Color color = OPT_GET("Colour/Video Dummy/Last Colour")->GetColor();
|
|
|
|
bool pattern = OPT_GET("Video/Dummy/Pattern")->GetBool();
|
|
|
|
|
|
|
|
wxStaticText *length_display;
|
|
|
|
wxFlexGridSizer *sizer;
|
|
|
|
|
|
|
|
template<typename T>
|
|
|
|
void AddCtrl(wxString const& label, T *ctrl);
|
|
|
|
|
|
|
|
void OnResolutionShortcut(wxCommandEvent &evt);
|
|
|
|
void UpdateLengthDisplay();
|
|
|
|
|
|
|
|
DialogDummyVideo(wxWindow *parent);
|
|
|
|
};
|
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) {
|
2013-10-14 21:11:50 +02:00
|
|
|
return new wxTextCtrl(parent, -1, "", wxDefaultPosition, wxSize(50, -1), 0, DoubleValidator(value, min, max));
|
2012-12-17 21:17:11 +01:00
|
|
|
}
|
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) {
|
2013-11-21 18:13:36 +01:00
|
|
|
wxComboBox *ctrl = new wxComboBox(parent, -1, "", wxDefaultPosition, wxDefaultSize, 0, nullptr, 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)
|
2014-05-31 02:05:25 +02:00
|
|
|
: d(parent, -1, _("Dummy video options"))
|
2007-04-02 20:28:09 +02:00
|
|
|
{
|
2014-05-31 02:05:25 +02:00
|
|
|
d.SetIcon(GETICON(use_dummy_video_menu_16));
|
2012-04-03 22:40:33 +02:00
|
|
|
|
2013-11-21 18:13:36 +01:00
|
|
|
auto res_sizer = new wxBoxSizer(wxHORIZONTAL);
|
2014-05-31 02:05:25 +02:00
|
|
|
res_sizer->Add(spin_ctrl(&d, 1, 10000, &width), wxSizerFlags(1).Expand());
|
|
|
|
res_sizer->Add(new wxStaticText(&d, -1, " x "), wxSizerFlags().Center());
|
|
|
|
res_sizer->Add(spin_ctrl(&d, 1, 10000, &height), wxSizerFlags(1).Expand());
|
2012-12-17 21:17:11 +01:00
|
|
|
|
2013-11-21 18:13:36 +01:00
|
|
|
auto color_sizer = new wxBoxSizer(wxHORIZONTAL);
|
2014-05-31 02:05:25 +02:00
|
|
|
auto color_btn = new ColourButton(&d, wxSize(30, 17), false, color);
|
2012-12-17 21:17:11 +01:00
|
|
|
color_sizer->Add(color_btn, wxSizerFlags().DoubleBorder(wxRIGHT));
|
2014-05-31 02:05:25 +02:00
|
|
|
color_sizer->Add(new wxCheckBox(&d, -1, _("Checkerboard &pattern"), wxDefaultPosition, wxDefaultSize, 0, wxGenericValidator(&pattern)), wxSizerFlags(1).Center());
|
2012-12-17 21:17:11 +01:00
|
|
|
|
|
|
|
sizer = new wxFlexGridSizer(2, 5, 5);
|
2014-05-31 02:05:25 +02:00
|
|
|
AddCtrl(_("Video resolution:"), resolution_shortcuts(&d, width, height));
|
2012-12-17 21:17:11 +01:00
|
|
|
AddCtrl("", res_sizer);
|
|
|
|
AddCtrl(_("Color:"), color_sizer);
|
2014-05-31 02:05:25 +02:00
|
|
|
AddCtrl(_("Frame rate (fps):"), spin_ctrl(&d, .1, 1000.0, &fps));
|
|
|
|
AddCtrl(_("Duration (frames):"), spin_ctrl(&d, 2, 36000000, &length)); // Ten hours of 1k FPS
|
|
|
|
AddCtrl("", length_display = new wxStaticText(&d, -1, ""));
|
2012-12-17 21:17:11 +01:00
|
|
|
|
2014-05-31 02:05:25 +02:00
|
|
|
auto btn_sizer = d.CreateStdDialogButtonSizer(wxOK | wxCANCEL | wxHELP);
|
2013-12-12 03:25:13 +01:00
|
|
|
btn_sizer->GetHelpButton()->Bind(wxEVT_BUTTON, std::bind(&HelpButton::OpenPage, "Dummy Video"));
|
2012-05-15 16:07:00 +02:00
|
|
|
|
2013-11-21 18:13:36 +01:00
|
|
|
auto main_sizer = new wxBoxSizer(wxVERTICAL);
|
2012-12-17 21:17:11 +01:00
|
|
|
main_sizer->Add(sizer, wxSizerFlags(1).Border().Expand());
|
2014-05-31 02:05:25 +02:00
|
|
|
main_sizer->Add(new wxStaticLine(&d, wxHORIZONTAL), wxSizerFlags().HorzBorder().Expand());
|
2012-12-17 21:17:11 +01:00
|
|
|
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
|
|
|
|
2014-05-31 02:05:25 +02:00
|
|
|
d.SetSizerAndFit(main_sizer);
|
|
|
|
d.CenterOnParent();
|
2007-04-02 20:28:09 +02:00
|
|
|
|
2014-05-31 02:05:25 +02:00
|
|
|
d.Bind(wxEVT_COMBOBOX, &DialogDummyVideo::OnResolutionShortcut, this);
|
2013-01-13 19:32:13 +01:00
|
|
|
color_btn->Bind(EVT_COLOR, [=](wxThreadEvent& e) { color = color_btn->GetColor(); });
|
2014-05-31 02:05:25 +02:00
|
|
|
d.Bind(wxEVT_SPINCTRL, [&](wxCommandEvent&) {
|
|
|
|
d.TransferDataFromWindow();
|
2012-12-17 21:17:11 +01:00
|
|
|
UpdateLengthDisplay();
|
|
|
|
});
|
2007-04-02 20:28:09 +02:00
|
|
|
}
|
|
|
|
|
2014-12-28 21:45:55 +01:00
|
|
|
static void add_label(wxWindow *parent, wxSizer *sizer, wxString const& label) {
|
2012-12-17 21:17:11 +01:00
|
|
|
if (!label)
|
|
|
|
sizer->AddStretchSpacer();
|
|
|
|
else
|
2014-12-28 21:45:55 +01:00
|
|
|
sizer->Add(new wxStaticText(parent, -1, label), wxSizerFlags().Center().Left());
|
|
|
|
}
|
|
|
|
|
|
|
|
template<typename T>
|
|
|
|
void DialogDummyVideo::AddCtrl(wxString const& label, T *ctrl) {
|
|
|
|
add_label(&d, sizer, label);
|
2012-12-17 21:17:11 +01:00
|
|
|
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) {
|
2014-05-31 02:05:25 +02:00
|
|
|
d.TransferDataFromWindow();
|
2012-12-17 21:17:11 +01:00
|
|
|
int rs = e.GetSelection();
|
|
|
|
width = resolutions[rs].width;
|
|
|
|
height = resolutions[rs].height;
|
2014-05-31 02:05:25 +02:00
|
|
|
d.TransferDataToWindow();
|
2007-04-02 20:28:09 +02:00
|
|
|
}
|
|
|
|
|
2012-12-17 21:17:11 +01:00
|
|
|
void DialogDummyVideo::UpdateLengthDisplay() {
|
2014-07-06 16:28:58 +02:00
|
|
|
length_display->SetLabel(fmt_tl("Resulting duration: %s", agi::Time(length / fps * 1000).GetAssFormatted(true)));
|
2007-04-02 20:28:09 +02:00
|
|
|
}
|
2014-05-22 21:07:15 +02:00
|
|
|
}
|
2007-04-02 20:28:09 +02:00
|
|
|
|
2014-05-22 21:07:15 +02:00
|
|
|
std::string CreateDummyVideo(wxWindow *parent) {
|
2012-12-17 21:17:11 +01:00
|
|
|
DialogDummyVideo dlg(parent);
|
2014-05-31 02:05:25 +02:00
|
|
|
if (dlg.d.ShowModal() != wxID_OK)
|
2012-12-17 21:17:11 +01:00
|
|
|
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
|
|
|
}
|