1 // Copyright (c) 2007, Alysson Souza e Silva (demi_alucard)
2 // All rights reserved.
3 //
4 // Redistribution and use in source and binary forms, with or without
5 // modification, are permitted provided that the following conditions are met:
6 //
7 // * Redistributions of source code must retain the above copyright notice,
8 // this list of conditions and the following disclaimer.
9 // * Redistributions in binary form must reproduce the above copyright notice,
10 // this list of conditions and the following disclaimer in the documentation
11 // and/or other materials provided with the distribution.
12 // * Neither the name of the Aegisub Group nor the names of its contributors
13 // may be used to endorse or promote products derived from this software
14 // without specific prior written permission.
15 //
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
20 // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21 // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22 // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23 // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24 // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25 // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26 // POSSIBILITY OF SUCH DAMAGE.
27 //
28 // Aegisub Project http://www.aegisub.org/
29
30 #include "async_video_provider.h"
31 #include "compat.h"
32 #include "format.h"
33 #include "include/aegisub/context.h"
34 #include "project.h"
35
36 #include <libaegisub/ass/time.h>
37
38 #include <boost/rational.hpp>
39 #include <wx/dialog.h>
40 #include <wx/sizer.h>
41 #include <wx/stattext.h>
42 #include <wx/textctrl.h>
43
ShowVideoDetailsDialog(agi::Context * c)44 void ShowVideoDetailsDialog(agi::Context *c) {
45 wxDialog d(c->parent, -1, _("Video Details"));
46
47 auto provider = c->project->VideoProvider();
48 auto width = provider->GetWidth();
49 auto height = provider->GetHeight();
50 auto framecount = provider->GetFrameCount();
51 auto fps = provider->GetFPS();
52 boost::rational<int> ar(width, height);
53
54 auto fg = new wxFlexGridSizer(2, 5, 10);
55 auto make_field = [&](wxString const& name, wxString const& value) {
56 fg->Add(new wxStaticText(&d, -1, name), 0, wxALIGN_CENTRE_VERTICAL);
57 fg->Add(new wxTextCtrl(&d, -1, value, wxDefaultPosition, wxSize(300,-1), wxTE_READONLY), 0, wxALIGN_CENTRE_VERTICAL | wxEXPAND);
58 };
59 make_field(_("File name:"), c->project->VideoName().wstring());
60 make_field(_("FPS:"), fmt_wx("%.3f", fps.FPS()));
61 make_field(_("Resolution:"), fmt_wx("%dx%d (%d:%d)", width, height, ar.numerator(), ar.denominator()));
62 make_field(_("Length:"), fmt_plural(framecount, "1 frame", "%d frames (%s)",
63 framecount, agi::Time(fps.TimeAtFrame(framecount - 1)).GetAssFormatted(true)));
64 make_field(_("Decoder:"), to_wx(provider->GetDecoderName()));
65
66 auto video_sizer = new wxStaticBoxSizer(wxVERTICAL, &d, _("Video"));
67 video_sizer->Add(fg);
68
69 auto main_sizer = new wxBoxSizer(wxVERTICAL);
70 main_sizer->Add(video_sizer, 1, wxALL|wxEXPAND, 5);
71 main_sizer->Add(d.CreateSeparatedButtonSizer(wxOK), 0, wxALL|wxEXPAND, 5);
72 d.SetSizerAndFit(main_sizer);
73
74 d.CenterOnParent();
75 d.ShowModal();
76 }
77