forked from mia/Aegisub
Replace most remaining uses of std::auto_ptr with agi::scoped_ptr
Originally committed to SVN as r6604.
This commit is contained in:
parent
55f9ccc18d
commit
2840fc0aea
8 changed files with 42 additions and 62 deletions
|
@ -41,6 +41,8 @@
|
|||
#include "ass_file.h"
|
||||
#include "include/aegisub/context.h"
|
||||
|
||||
#include <libaegisub/scoped_ptr.h>
|
||||
|
||||
#ifndef AGI_PRE
|
||||
#include <algorithm>
|
||||
#endif
|
||||
|
@ -115,7 +117,7 @@ AssFile *AssExporter::ExportTransform(wxWindow *export_dialog, bool copy) {
|
|||
}
|
||||
|
||||
void AssExporter::Export(wxString const& filename, wxString const& charset, wxWindow *export_dialog) {
|
||||
std::auto_ptr<AssFile> subs(ExportTransform(export_dialog, true));
|
||||
agi::scoped_ptr<AssFile> subs(ExportTransform(export_dialog, true));
|
||||
subs->Save(filename, false, false, charset);
|
||||
}
|
||||
|
||||
|
|
|
@ -36,8 +36,6 @@
|
|||
|
||||
#include "config.h"
|
||||
|
||||
#include <libaegisub/background_runner.h>
|
||||
|
||||
#include "audio_provider_ram.h"
|
||||
|
||||
#include "audio_controller.h"
|
||||
|
@ -45,12 +43,15 @@
|
|||
#include "main.h"
|
||||
#include "utils.h"
|
||||
|
||||
#include <libaegisub/background_runner.h>
|
||||
#include <libaegisub/scoped_ptr.h>
|
||||
|
||||
#define CacheBits ((22))
|
||||
|
||||
#define CacheBlockSize ((1 << CacheBits))
|
||||
|
||||
RAMAudioProvider::RAMAudioProvider(AudioProvider *src, agi::BackgroundRunner *br) {
|
||||
std::auto_ptr<AudioProvider> source(src);
|
||||
agi::scoped_ptr<AudioProvider> source(src);
|
||||
|
||||
samples_native_endian = source->AreSamplesNativeEndian();
|
||||
|
||||
|
|
|
@ -336,7 +336,7 @@ DialogStyleEditor::DialogStyleEditor(wxWindow *parent, AssStyle *style, agi::Con
|
|||
if (!SubtitlesProviderFactory::GetClasses().empty()) {
|
||||
PreviewText = new wxTextCtrl(this, -1, lagi_wxString(OPT_GET("Tool/Style Editor/Preview Text")->GetString()));
|
||||
previewButton = new ColourButton(this, -1, wxSize(45, 16), lagi_wxColour(OPT_GET("Colour/Style Editor/Background/Preview")->GetColour()));
|
||||
SubsPreview = new SubtitlesPreview(this, -1, wxDefaultPosition, wxSize(100, 60), wxSUNKEN_BORDER, lagi_wxColour(OPT_GET("Colour/Style Editor/Background/Preview")->GetColour()));
|
||||
SubsPreview = new SubtitlesPreview(this, wxSize(100, 60), wxSUNKEN_BORDER, lagi_wxColour(OPT_GET("Colour/Style Editor/Background/Preview")->GetColour()));
|
||||
|
||||
SubsPreview->SetToolTip(_("Preview of current style"));
|
||||
SubsPreview->SetStyle(*style);
|
||||
|
|
|
@ -50,17 +50,8 @@
|
|||
#include "include/aegisub/subtitles_provider.h"
|
||||
#include "video_provider_dummy.h"
|
||||
|
||||
|
||||
/// @brief Constructor
|
||||
/// @param parent
|
||||
/// @param id
|
||||
/// @param pos
|
||||
/// @param size
|
||||
/// @param winStyle
|
||||
/// @param col
|
||||
///
|
||||
SubtitlesPreview::SubtitlesPreview(wxWindow *parent,int id,wxPoint pos,wxSize size,int winStyle,wxColour col)
|
||||
: wxWindow(parent,id,pos,size,winStyle)
|
||||
SubtitlesPreview::SubtitlesPreview(wxWindow *parent, wxSize size, int winStyle, wxColour col)
|
||||
: wxWindow(parent, -1, wxDefaultPosition, size, winStyle)
|
||||
, style(new AssStyle)
|
||||
, backColour(col)
|
||||
, subFile(new AssFile)
|
||||
|
@ -78,6 +69,9 @@ SubtitlesPreview::SubtitlesPreview(wxWindow *parent,int id,wxPoint pos,wxSize si
|
|||
wxSizeEvent evt(size);
|
||||
OnSize(evt);
|
||||
UpdateBitmap();
|
||||
|
||||
Bind(wxEVT_PAINT, &SubtitlesPreview::OnPaint, this);
|
||||
Bind(wxEVT_SIZE, &SubtitlesPreview::OnSize, this);
|
||||
}
|
||||
|
||||
SubtitlesPreview::~SubtitlesPreview() {
|
||||
|
@ -100,13 +94,21 @@ void SubtitlesPreview::SetText(wxString text) {
|
|||
}
|
||||
}
|
||||
|
||||
void SubtitlesPreview::SetColour(wxColour col) {
|
||||
if (col != backColour) {
|
||||
backColour = col;
|
||||
vid.reset(new DummyVideoProvider(0.0, 10, bmp->GetWidth(), bmp->GetHeight(), backColour, true));
|
||||
UpdateBitmap();
|
||||
}
|
||||
}
|
||||
|
||||
void SubtitlesPreview::UpdateBitmap() {
|
||||
if (!vid.get()) return;
|
||||
if (!vid) return;
|
||||
|
||||
AegiVideoFrame frame;
|
||||
frame.CopyFrom(vid->GetFrame(0));
|
||||
|
||||
if (provider.get()) {
|
||||
if (provider) {
|
||||
try {
|
||||
provider->LoadSubtitles(subFile.get());
|
||||
provider->DrawSubtitles(frame, 0.1);
|
||||
|
@ -120,14 +122,8 @@ void SubtitlesPreview::UpdateBitmap() {
|
|||
Refresh();
|
||||
}
|
||||
|
||||
BEGIN_EVENT_TABLE(SubtitlesPreview,wxWindow)
|
||||
EVT_PAINT(SubtitlesPreview::OnPaint)
|
||||
EVT_SIZE(SubtitlesPreview::OnSize)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
void SubtitlesPreview::OnPaint(wxPaintEvent &) {
|
||||
wxPaintDC dc(this);
|
||||
dc.DrawBitmap(*bmp,0,0);
|
||||
wxPaintDC(this).DrawBitmap(*bmp, 0, 0);
|
||||
}
|
||||
|
||||
void SubtitlesPreview::OnSize(wxSizeEvent &evt) {
|
||||
|
@ -148,16 +144,8 @@ void SubtitlesPreview::OnSize(wxSizeEvent &evt) {
|
|||
"No subtitles provider", wxICON_ERROR | wxOK);
|
||||
}
|
||||
|
||||
subFile->SetScriptInfo("PlayResX", wxString::Format("%i", w));
|
||||
subFile->SetScriptInfo("PlayResY", wxString::Format("%i", h));
|
||||
subFile->SetScriptInfo("PlayResX", wxString::Format("%d", w));
|
||||
subFile->SetScriptInfo("PlayResY", wxString::Format("%d", h));
|
||||
|
||||
UpdateBitmap();
|
||||
}
|
||||
|
||||
void SubtitlesPreview::SetColour(wxColour col) {
|
||||
if (col != backColour) {
|
||||
backColour = col;
|
||||
vid.reset(new DummyVideoProvider(0.0, 10, bmp->GetWidth(), bmp->GetHeight(), backColour, true));
|
||||
UpdateBitmap();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,11 +35,12 @@
|
|||
///
|
||||
|
||||
#ifndef AGI_PRE
|
||||
#include <memory>
|
||||
#include <wx/window.h>
|
||||
#include <wx/bitmap.h>
|
||||
#endif
|
||||
|
||||
#include <libaegisub/scoped_ptr.h>
|
||||
|
||||
class AssFile;
|
||||
class AssStyle;
|
||||
class SubtitlesProvider;
|
||||
|
@ -49,19 +50,18 @@ class VideoProvider;
|
|||
/// @class SubtitlesPreview
|
||||
/// @brief Preview window to show a short string with a given ass style
|
||||
class SubtitlesPreview : public wxWindow {
|
||||
private:
|
||||
/// The subtitle provider used to render the string
|
||||
std::auto_ptr<SubtitlesProvider> provider;
|
||||
agi::scoped_ptr<SubtitlesProvider> provider;
|
||||
/// Bitmap to render into
|
||||
std::auto_ptr<wxBitmap> bmp;
|
||||
agi::scoped_ptr<wxBitmap> bmp;
|
||||
/// The currently display style
|
||||
AssStyle* style;
|
||||
/// Video provider to render into
|
||||
std::auto_ptr<VideoProvider> vid;
|
||||
agi::scoped_ptr<VideoProvider> vid;
|
||||
/// Current background color
|
||||
wxColour backColour;
|
||||
/// Subtitle file containing the style and displayed line
|
||||
std::auto_ptr<AssFile> subFile;
|
||||
agi::scoped_ptr<AssFile> subFile;
|
||||
/// Line used to render the specified text
|
||||
AssDialogue* line;
|
||||
|
||||
|
@ -80,10 +80,6 @@ public:
|
|||
/// Set the background color
|
||||
void SetColour(wxColour col);
|
||||
|
||||
void Update() { UpdateBitmap(); }
|
||||
|
||||
SubtitlesPreview(wxWindow *parent,int id,wxPoint pos,wxSize size,int style,wxColour colour);
|
||||
SubtitlesPreview(wxWindow *parent, wxSize size, int style, wxColour colour);
|
||||
~SubtitlesPreview();
|
||||
|
||||
DECLARE_EVENT_TABLE()
|
||||
};
|
||||
|
|
|
@ -54,7 +54,8 @@
|
|||
///
|
||||
TextFileWriter::TextFileWriter(wxString const& filename, wxString encoding)
|
||||
: file(new agi::io::Save(STD_STR(filename), true))
|
||||
, conv() {
|
||||
, conv()
|
||||
{
|
||||
if (encoding.empty()) encoding = lagi_wxString(OPT_GET("App/Save Charset")->GetString());
|
||||
if (encoding.Lower() != wxSTRING_ENCODING)
|
||||
conv.reset(new agi::charset::IconvWrapper(wxSTRING_ENCODING, encoding.utf8_str(), true));
|
||||
|
@ -68,17 +69,10 @@ TextFileWriter::TextFileWriter(wxString const& filename, wxString encoding)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/// @brief DOCME
|
||||
///
|
||||
TextFileWriter::~TextFileWriter() {
|
||||
// Explicit empty destructor required with an auto_ptr to an incomplete class
|
||||
}
|
||||
|
||||
|
||||
/// @brief DOCME
|
||||
/// @param line
|
||||
/// @param addLineBreak
|
||||
void TextFileWriter::WriteLineToFile(wxString line, bool addLineBreak) {
|
||||
#ifdef _WIN32
|
||||
if (addLineBreak) line += "\r\n";
|
||||
|
@ -94,7 +88,7 @@ void TextFileWriter::WriteLineToFile(wxString line, bool addLineBreak) {
|
|||
size_t len = line.length() * sizeof(wxStringCharType);
|
||||
#endif
|
||||
|
||||
if (conv.get()) {
|
||||
if (conv) {
|
||||
std::string buf = conv->Convert(std::string(data, len));
|
||||
file->Get().write(buf.data(), buf.size());
|
||||
}
|
||||
|
|
|
@ -38,7 +38,6 @@
|
|||
|
||||
#ifndef AGI_PRE
|
||||
#include <fstream>
|
||||
#include <memory>
|
||||
|
||||
#include <wx/string.h>
|
||||
#endif
|
||||
|
@ -52,6 +51,8 @@ namespace agi {
|
|||
}
|
||||
}
|
||||
|
||||
#include <libaegisub/scoped_ptr.h>
|
||||
|
||||
|
||||
/// DOCME
|
||||
/// @class TextFileWriter
|
||||
|
@ -60,13 +61,10 @@ namespace agi {
|
|||
/// DOCME
|
||||
class TextFileWriter {
|
||||
/// DOCME
|
||||
std::auto_ptr<agi::io::Save> file;
|
||||
agi::scoped_ptr<agi::io::Save> file;
|
||||
|
||||
/// DOCME
|
||||
std::auto_ptr<agi::charset::IconvWrapper> conv;
|
||||
|
||||
TextFileWriter(const TextFileWriter&);
|
||||
TextFileWriter& operator=(const TextFileWriter&);
|
||||
agi::scoped_ptr<agi::charset::IconvWrapper> conv;
|
||||
|
||||
public:
|
||||
TextFileWriter(wxString const& filename, wxString encoding="");
|
||||
|
|
|
@ -44,6 +44,7 @@
|
|||
#include <wx/stopwatch.h>
|
||||
#endif
|
||||
|
||||
#include <libaegisub/scoped_ptr.h>
|
||||
#include <libaegisub/signal.h>
|
||||
#include <libaegisub/vfr.h>
|
||||
|
||||
|
@ -83,7 +84,7 @@ class VideoContext : public wxEvtHandler {
|
|||
VideoProvider *videoProvider;
|
||||
|
||||
/// Asynchronous provider of video frames
|
||||
std::auto_ptr<ThreadedFrameSource> provider;
|
||||
agi::scoped_ptr<ThreadedFrameSource> provider;
|
||||
|
||||
/// Filename of currently open video
|
||||
wxString videoFile;
|
||||
|
|
Loading…
Reference in a new issue