mirror of https://github.com/odrling/Aegisub
Eliminate a bunch of explicit constructors/destructors
Use explicitly defaulted destructors for base cases when possible, eliminate aggregate initialization constructors where possible, and push some more stuff to NSDMIs.
This commit is contained in:
parent
a5fdc6795c
commit
15ae2b0ccc
|
@ -38,7 +38,7 @@ class SyntaxHighlighter {
|
|||
if (ranges.size() && ranges.back().type == type)
|
||||
ranges.back().length += len;
|
||||
else
|
||||
ranges.push_back(DialogueToken(type, len));
|
||||
ranges.push_back(DialogueToken{type, len});
|
||||
}
|
||||
|
||||
public:
|
||||
|
@ -101,7 +101,7 @@ class WordSplitter {
|
|||
tokens[i].length = len;
|
||||
|
||||
if (old.length != (size_t)len) {
|
||||
tokens.insert(tokens.begin() + i + 1, DialogueToken(old.type, old.length - len));
|
||||
tokens.insert(tokens.begin() + i + 1, DialogueToken{old.type, old.length - len});
|
||||
++i;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,14 +31,12 @@ namespace {
|
|||
void Visit(Boolean const&) { }
|
||||
void Visit(Null const&) { is_null = true; }
|
||||
public:
|
||||
bool is_null;
|
||||
CastVisitorBase() : is_null(false) { }
|
||||
bool is_null = false;
|
||||
};
|
||||
|
||||
template<class T>
|
||||
struct CastVisitor final : public CastVisitorBase {
|
||||
T *element;
|
||||
CastVisitor() : element(0) { }
|
||||
T *element = nullptr;
|
||||
void Visit(T& ele) { element = &ele; }
|
||||
};
|
||||
}
|
||||
|
|
|
@ -218,7 +218,7 @@ namespace ass {
|
|||
ptrdiff_t len = it->value().end() - it->value().begin();
|
||||
assert(len > 0);
|
||||
if (data.empty() || data.back().type != id)
|
||||
data.push_back(DialogueToken(id, len));
|
||||
data.push_back(DialogueToken{id, len});
|
||||
else
|
||||
data.back().length += len;
|
||||
}
|
||||
|
|
|
@ -60,8 +60,6 @@ struct TimecodeRange {
|
|||
int end;
|
||||
double fps;
|
||||
bool operator<(TimecodeRange const& cmp) const { return start < cmp.start; }
|
||||
TimecodeRange(int start=0, int end=0, double fps=0.)
|
||||
: start(start), end(end), fps(fps) { }
|
||||
};
|
||||
|
||||
/// @brief Parse a single line of a v1 timecode file
|
||||
|
@ -95,7 +93,7 @@ TimecodeRange v1_parse_line(std::string const& str) {
|
|||
void v1_fill_range_gaps(std::list<TimecodeRange> &ranges, double fps) {
|
||||
// Range for frames between start and first override
|
||||
if (ranges.empty() || ranges.front().start > 0)
|
||||
ranges.emplace_front(0, ranges.empty() ? 0 : ranges.front().start - 1, fps);
|
||||
ranges.push_front(TimecodeRange{0, ranges.empty() ? 0 : ranges.front().start - 1, fps});
|
||||
|
||||
for (auto cur = ++begin(ranges), prev = begin(ranges); cur != end(ranges); ++cur, ++prev) {
|
||||
if (prev->end >= cur->start)
|
||||
|
@ -103,7 +101,7 @@ void v1_fill_range_gaps(std::list<TimecodeRange> &ranges, double fps) {
|
|||
// broken things with them
|
||||
throw UnorderedTimecodes("Override ranges must not overlap");
|
||||
if (prev->end + 1 < cur->start) {
|
||||
ranges.emplace(cur, prev->end + 1, cur->start -1, fps);
|
||||
ranges.insert(cur, TimecodeRange{prev->end + 1, cur->start - 1, fps});
|
||||
++prev;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -66,7 +66,6 @@ namespace agi {
|
|||
struct DialogueToken {
|
||||
int type;
|
||||
size_t length;
|
||||
DialogueToken(int type, size_t length) : type(type), length(length) { }
|
||||
};
|
||||
|
||||
/// Tokenize the passed string as the body of a dialogue line
|
||||
|
|
|
@ -19,11 +19,9 @@ class Reader {
|
|||
public:
|
||||
// this structure will be reported in one of the exceptions defined below
|
||||
struct Location {
|
||||
Location() : m_nLine(0), m_nLineOffset(0), m_nDocOffset(0) { }
|
||||
|
||||
unsigned int m_nLine; // document line, zero-indexed
|
||||
unsigned int m_nLineOffset; // character offset from beginning of line, zero indexed
|
||||
unsigned int m_nDocOffset; // character offset from entire document, zero indexed
|
||||
unsigned int m_nLine = 0; // document line, zero-indexed
|
||||
unsigned int m_nLineOffset = 0; // character offset from beginning of line, zero indexed
|
||||
unsigned int m_nDocOffset = 0; // character offset from entire document, zero indexed
|
||||
};
|
||||
|
||||
// thrown during the first phase of reading. generally catches low-level
|
||||
|
|
|
@ -14,7 +14,7 @@ namespace json
|
|||
{
|
||||
|
||||
struct Visitor {
|
||||
virtual ~Visitor() { }
|
||||
virtual ~Visitor() = default;
|
||||
|
||||
virtual void Visit(Array& array) = 0;
|
||||
virtual void Visit(Object& object) = 0;
|
||||
|
@ -26,7 +26,7 @@ struct Visitor {
|
|||
};
|
||||
|
||||
struct ConstVisitor {
|
||||
virtual ~ConstVisitor() { }
|
||||
virtual ~ConstVisitor() = default;
|
||||
|
||||
virtual void Visit(const Array& array) = 0;
|
||||
virtual void Visit(const Object& object) = 0;
|
||||
|
|
|
@ -40,7 +40,7 @@ typedef void* iconv_t;
|
|||
/// Helper class that abstracts away the differences between libiconv and
|
||||
/// POSIX iconv implementations
|
||||
struct Converter {
|
||||
virtual ~Converter() { }
|
||||
virtual ~Converter() = default;
|
||||
virtual size_t Convert(const char** inbuf, size_t* inbytesleft, char** outbuf, size_t* outbytesleft) = 0;
|
||||
};
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ namespace agi {
|
|||
unsigned char b = 0; ///< Blue component
|
||||
unsigned char a = 0; ///< Alpha component
|
||||
|
||||
Color() { }
|
||||
Color() = default;
|
||||
Color(unsigned char r, unsigned char g, unsigned char b, unsigned char a = 0);
|
||||
Color(std::string const& str);
|
||||
|
||||
|
|
|
@ -84,8 +84,7 @@ void Copy(fs::path const& from, fs::path const& to) {
|
|||
}
|
||||
|
||||
struct DirectoryIterator::PrivData {
|
||||
scoped_holder<HANDLE, BOOL (__stdcall *)(HANDLE)> h;
|
||||
PrivData() : h(INVALID_HANDLE_VALUE, FindClose) { }
|
||||
scoped_holder<HANDLE, BOOL (__stdcall *)(HANDLE)> h{INVALID_HANDLE_VALUE, FindClose};
|
||||
};
|
||||
|
||||
DirectoryIterator::DirectoryIterator() { }
|
||||
|
|
|
@ -75,7 +75,7 @@ protected:
|
|||
std::string text;
|
||||
public:
|
||||
AssDialogueBlock(std::string text) : text(std::move(text)) { }
|
||||
virtual ~AssDialogueBlock() { }
|
||||
virtual ~AssDialogueBlock() = default;
|
||||
|
||||
virtual AssBlockType GetType() const = 0;
|
||||
virtual std::string GetText() { return text; }
|
||||
|
|
|
@ -51,7 +51,7 @@ using AssEntryListHook = boost::intrusive::make_list_base_hook<boost::intrusive:
|
|||
|
||||
class AssEntry {
|
||||
public:
|
||||
virtual ~AssEntry() { }
|
||||
virtual ~AssEntry() = default;
|
||||
|
||||
/// Section of the file this entry belongs to
|
||||
virtual AssEntryGroup Group() const=0;
|
||||
|
|
|
@ -60,7 +60,7 @@ class AssExportFilter : public boost::intrusive::make_list_base_hook<boost::intr
|
|||
|
||||
public:
|
||||
AssExportFilter(std::string name, std::string description, int priority = 0);
|
||||
virtual ~AssExportFilter() { };
|
||||
virtual ~AssExportFilter() = default;
|
||||
|
||||
std::string const& GetName() const { return name; }
|
||||
std::string const& GetDescription() const { return description; }
|
||||
|
|
|
@ -167,13 +167,6 @@ struct AssOverrideParamProto {
|
|||
|
||||
/// Semantic type of this parameter
|
||||
AssParameterClass classification;
|
||||
|
||||
AssOverrideParamProto(VariableDataType type, int opt, AssParameterClass classi)
|
||||
: optional(opt)
|
||||
, type(type)
|
||||
, classification(classi)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
struct AssOverrideTagProto {
|
||||
|
@ -190,7 +183,7 @@ struct AssOverrideTagProto {
|
|||
/// @param classi Semantic type of the parameter
|
||||
/// @param opt Situations in which this parameter is present
|
||||
void AddParam(VariableDataType type, AssParameterClass classi = AssParameterClass::NORMAL, int opt = NOT_OPTIONAL) {
|
||||
params.emplace_back(type, opt, classi);
|
||||
params.push_back(AssOverrideParamProto{opt, type, classi});
|
||||
}
|
||||
|
||||
/// @brief Convenience function for single-argument tags
|
||||
|
@ -200,7 +193,7 @@ struct AssOverrideTagProto {
|
|||
/// @param opt Situations in which this parameter is present
|
||||
void Set(const char *name, VariableDataType type, AssParameterClass classi = AssParameterClass::NORMAL, int opt = NOT_OPTIONAL) {
|
||||
this->name = name;
|
||||
params.emplace_back(type, opt, classi);
|
||||
params.push_back(AssOverrideParamProto{opt, type, classi});
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -91,7 +91,7 @@ public:
|
|||
/// @brief Destructor
|
||||
///
|
||||
/// Empty virtual destructor for the cases that need it.
|
||||
virtual ~AudioDisplayInteractionObject() { }
|
||||
virtual ~AudioDisplayInteractionObject() = default;
|
||||
};
|
||||
|
||||
/// @class AudioDisplay
|
||||
|
|
|
@ -85,7 +85,7 @@ protected:
|
|||
agi::signal::Signal<> AnnounceMarkerMoved;
|
||||
public:
|
||||
/// Virtual destructor, does nothing
|
||||
virtual ~AudioMarkerProvider() { }
|
||||
virtual ~AudioMarkerProvider() = default;
|
||||
|
||||
/// @brief Return markers in a time range
|
||||
virtual void GetMarkers(const TimeRange &range, AudioMarkerVector &out) const = 0;
|
||||
|
@ -106,11 +106,10 @@ public:
|
|||
wxString text;
|
||||
/// Range which this label applies to
|
||||
TimeRange range;
|
||||
AudioLabel(wxString const& text, TimeRange const& range) : text(text), range(range) { }
|
||||
};
|
||||
|
||||
/// Virtual destructor, does nothing
|
||||
virtual ~AudioLabelProvider() { }
|
||||
virtual ~AudioLabelProvider() = default;
|
||||
|
||||
/// @brief Get labels in a time range
|
||||
/// @param range Range of times to get labels for
|
||||
|
@ -177,9 +176,9 @@ public:
|
|||
class SecondsMarkerProvider final : public AudioMarkerProvider {
|
||||
struct Marker final : public AudioMarker {
|
||||
Pen *style;
|
||||
int position;
|
||||
int position = 0;
|
||||
|
||||
Marker(Pen *style) : style(style), position(0) { }
|
||||
Marker(Pen *style) : style(style) { }
|
||||
int GetPosition() const override { return position; }
|
||||
FeetStyle GetFeet() const override { return Feet_None; }
|
||||
bool CanSnap() const override { return false; }
|
||||
|
|
|
@ -115,13 +115,7 @@ public:
|
|||
struct COMInitialization {
|
||||
|
||||
/// Flag set if an inited COM library is managed
|
||||
bool inited;
|
||||
|
||||
/// @brief Constructor, sets inited false
|
||||
COMInitialization()
|
||||
{
|
||||
inited = false;
|
||||
}
|
||||
bool inited = false;
|
||||
|
||||
/// @brief Destructor, de-inits COM if it is inited
|
||||
~COMInitialization()
|
||||
|
|
|
@ -258,7 +258,7 @@ public:
|
|||
AudioRendererBitmapProvider() : provider(nullptr), pixel_ms(0), amplitude_scale(0) { };
|
||||
|
||||
/// @brief Destructor
|
||||
virtual ~AudioRendererBitmapProvider() { }
|
||||
virtual ~AudioRendererBitmapProvider() = default;
|
||||
|
||||
/// @brief Rendering function
|
||||
/// @param bmp Bitmap to render to
|
||||
|
|
|
@ -173,7 +173,7 @@ public:
|
|||
virtual void OnMarkerDrag(std::vector<AudioMarker*> const& marker, int new_position, int snap_range) = 0;
|
||||
|
||||
/// @brief Destructor
|
||||
virtual ~AudioTimingController() { }
|
||||
virtual ~AudioTimingController() = default;
|
||||
|
||||
DEFINE_SIGNAL_ADDERS(AnnounceUpdatedPrimaryRange, AddUpdatedPrimaryRangeListener)
|
||||
DEFINE_SIGNAL_ADDERS(AnnounceUpdatedStyleRanges, AddUpdatedStyleRangesListener)
|
||||
|
|
|
@ -286,7 +286,7 @@ void AudioTimingControllerKaraoke::Revert() {
|
|||
for (auto it = kara->begin(); it != kara->end(); ++it) {
|
||||
if (it != kara->begin())
|
||||
markers.emplace_back(it->start_time, &separator_pen, AudioMarker::Feet_None);
|
||||
labels.emplace_back(to_wx(it->text), TimeRange(it->start_time, it->start_time + it->duration));
|
||||
labels.push_back(AudioLabel{to_wx(it->text), TimeRange(it->start_time, it->start_time + it->duration)});
|
||||
}
|
||||
|
||||
AnnounceUpdatedPrimaryRange();
|
||||
|
|
|
@ -90,7 +90,7 @@ namespace Automation4 {
|
|||
/// panel
|
||||
class ScriptDialog {
|
||||
public:
|
||||
virtual ~ScriptDialog() { }
|
||||
virtual ~ScriptDialog() = default;
|
||||
|
||||
/// Create a window with the given parent
|
||||
virtual wxWindow *CreateWindow(wxWindow *parent) = 0;
|
||||
|
@ -155,7 +155,7 @@ namespace Automation4 {
|
|||
Script(agi::fs::path const& filename);
|
||||
|
||||
public:
|
||||
virtual ~Script() { }
|
||||
virtual ~Script() = default;
|
||||
|
||||
/// Reload this script
|
||||
virtual void Reload() = 0;
|
||||
|
@ -253,7 +253,7 @@ namespace Automation4 {
|
|||
ScriptFactory(std::string engine_name, std::string filename_pattern);
|
||||
|
||||
public:
|
||||
virtual ~ScriptFactory() { }
|
||||
virtual ~ScriptFactory() = default;
|
||||
|
||||
/// Name of this automation engine
|
||||
const std::string& GetEngineName() const { return engine_name; }
|
||||
|
|
|
@ -196,7 +196,7 @@ namespace Automation4 {
|
|||
LuaDialogControl(lua_State *L);
|
||||
|
||||
/// Virtual destructor so this can safely be inherited from
|
||||
virtual ~LuaDialogControl() { }
|
||||
virtual ~LuaDialogControl() = default;
|
||||
};
|
||||
|
||||
/// A lua-generated dialog or panel in the export options dialog
|
||||
|
|
|
@ -136,7 +136,7 @@ DEFINE_SIMPLE_EXCEPTION_NOINNER(CommandNotFound, CommandError, "command/notfound
|
|||
virtual bool IsActive(const agi::Context *c) { return false; }
|
||||
|
||||
/// Destructor
|
||||
virtual ~Command() { };
|
||||
virtual ~Command() = default;
|
||||
};
|
||||
|
||||
/// Init all builtin commands.
|
||||
|
|
|
@ -114,8 +114,8 @@ void DialogAutosave::Populate(std::map<wxString, AutosaveFile> &files_map, std::
|
|||
|
||||
auto it = files_map.find(name);
|
||||
if (it == files_map.end())
|
||||
it = files_map.insert(std::make_pair(name, name)).first;
|
||||
it->second.versions.emplace_back(wxFileName(directory, fn).GetFullPath(), date, wxString::Format(name_fmt, date.Format()));
|
||||
it = files_map.insert(std::make_pair(name, AutosaveFile{name})).first;
|
||||
it->second.versions.push_back(Version{wxFileName(directory, fn).GetFullPath(), date, wxString::Format(name_fmt, date.Format())});
|
||||
} while (dir.GetNext(&fn));
|
||||
}
|
||||
|
||||
|
|
|
@ -29,14 +29,11 @@ class DialogAutosave final : public wxDialog {
|
|||
wxString filename;
|
||||
wxDateTime date;
|
||||
wxString display;
|
||||
Version(wxString const& filename, wxDateTime date, wxString const& display)
|
||||
: filename(filename), date(std::move(date)), display(display) { }
|
||||
};
|
||||
|
||||
struct AutosaveFile {
|
||||
wxString name;
|
||||
std::vector<Version> versions;
|
||||
AutosaveFile(wxString const& name) : name(name) { }
|
||||
};
|
||||
|
||||
std::vector<AutosaveFile> files;
|
||||
|
|
|
@ -73,8 +73,7 @@ class KaraokeLineMatchDisplay final : public wxControl {
|
|||
struct MatchGroup {
|
||||
std::vector<MatchSyllable> src;
|
||||
std::string dst;
|
||||
int last_render_width;
|
||||
MatchGroup() : last_render_width(0) { }
|
||||
int last_render_width = 0;
|
||||
};
|
||||
|
||||
std::vector<MatchGroup> matched_groups;
|
||||
|
|
|
@ -86,9 +86,6 @@ struct AegisubUpdateDescription {
|
|||
std::string url;
|
||||
std::string friendly_name;
|
||||
std::string description;
|
||||
|
||||
AegisubUpdateDescription(std::string url, std::string friendly_name, std::string description)
|
||||
: url(std::move(url)), friendly_name(std::move(friendly_name)), description(std::move(description)) { }
|
||||
};
|
||||
|
||||
class VersionCheckerResultDialog final : public wxDialog {
|
||||
|
@ -340,16 +337,15 @@ void DoCheck(bool interactive) {
|
|||
boost::split(parsed, line, boost::is_any_of("|"));
|
||||
if (parsed.size() != 6) continue;
|
||||
|
||||
// 0 and 2 being things that never got used
|
||||
std::string revision = parsed[1];
|
||||
std::string url = inline_string_decode(parsed[3]);
|
||||
std::string friendlyname = inline_string_decode(parsed[4]);
|
||||
std::string description = inline_string_decode(parsed[5]);
|
||||
|
||||
if (atoi(revision.c_str()) <= GetSVNRevision())
|
||||
if (atoi(parsed[1].c_str()) <= GetSVNRevision())
|
||||
continue;
|
||||
|
||||
results.emplace_back(url, friendlyname, description);
|
||||
// 0 and 2 being things that never got used
|
||||
results.push_back(AegisubUpdateDescription{
|
||||
inline_string_decode(parsed[3]),
|
||||
inline_string_decode(parsed[4]),
|
||||
inline_string_decode(parsed[5])
|
||||
});
|
||||
}
|
||||
|
||||
if (!results.empty() || interactive) {
|
||||
|
|
|
@ -56,22 +56,17 @@ namespace {
|
|||
/// @brief Struct storing the information needed to draw a glyph
|
||||
struct OpenGLTextGlyph {
|
||||
wxString str; ///< String containing the glyph(s) this is for
|
||||
int tex; ///< OpenGL texture to draw for this glyph
|
||||
float x1; ///< Left x coordinate of this glyph in the containing texture
|
||||
float x2; ///< Right x coordinate of this glyph in the containing texture
|
||||
float y1; ///< Left y coordinate of this glyph in the containing texture
|
||||
float y2; ///< Right y coordinate of this glyph in the containing texture
|
||||
int w; ///< Width of the glyph in pixels
|
||||
int h; ///< Height of the glyph in pixels
|
||||
int tex = 0; ///< OpenGL texture to draw for this glyph
|
||||
float x1 = 0; ///< Left x coordinate of this glyph in the containing texture
|
||||
float x2 = 0; ///< Right x coordinate of this glyph in the containing texture
|
||||
float y1 = 0; ///< Left y coordinate of this glyph in the containing texture
|
||||
float y2 = 0; ///< Right y coordinate of this glyph in the containing texture
|
||||
int w = 0; ///< Width of the glyph in pixels
|
||||
int h = 0; ///< Height of the glyph in pixels
|
||||
wxFont font; ///< Font used for this glyph
|
||||
|
||||
OpenGLTextGlyph(int value, wxFont const& font)
|
||||
: str(wxChar(value))
|
||||
, tex(0)
|
||||
, x1(0)
|
||||
, x2(0)
|
||||
, y1(0)
|
||||
, y2(0)
|
||||
, font(font)
|
||||
{
|
||||
wxCoord desc,lead;
|
||||
|
@ -113,13 +108,13 @@ struct OpenGLTextGlyph {
|
|||
/// @class OpenGLTextTexture
|
||||
/// @brief OpenGL texture which stores one or more glyphs as sprites
|
||||
class OpenGLTextTexture final : boost::noncopyable {
|
||||
int x; ///< Next x coordinate at which a glyph can be inserted
|
||||
int y; ///< Next y coordinate at which a glyph can be inserted
|
||||
int nextY; ///< Y coordinate of the next line; tracked due to that lines
|
||||
///< are only as tall as needed to fit the glyphs in them
|
||||
int width; ///< Width of the texture
|
||||
int height; ///< Height of the texture
|
||||
GLuint tex; ///< The texture
|
||||
int x = 0; ///< Next x coordinate at which a glyph can be inserted
|
||||
int y = 0; ///< Next y coordinate at which a glyph can be inserted
|
||||
int nextY = 0; ///< Y coordinate of the next line; tracked due to that lines
|
||||
///< are only as tall as needed to fit the glyphs in them
|
||||
int width; ///< Width of the texture
|
||||
int height; ///< Height of the texture
|
||||
GLuint tex = 0; ///< The texture
|
||||
|
||||
/// Insert the glyph into this texture at the current coordinates
|
||||
void Insert(OpenGLTextGlyph &glyph) {
|
||||
|
@ -161,12 +156,8 @@ class OpenGLTextTexture final : boost::noncopyable {
|
|||
|
||||
public:
|
||||
OpenGLTextTexture(OpenGLTextGlyph &glyph)
|
||||
: x(0)
|
||||
, y(0)
|
||||
, nextY(0)
|
||||
, width(std::max(SmallestPowerOf2(glyph.w), 64))
|
||||
: width(std::max(SmallestPowerOf2(glyph.w), 64))
|
||||
, height(std::max(SmallestPowerOf2(glyph.h), 64))
|
||||
, tex(0)
|
||||
{
|
||||
width = height = std::max(width, height);
|
||||
|
||||
|
|
|
@ -41,8 +41,8 @@ using namespace agi::hotkey;
|
|||
/// @class HotkeyModelItem
|
||||
/// @brief A base class for things exposed by HotkeyDataViewModel
|
||||
class HotkeyModelItem {
|
||||
protected:
|
||||
~HotkeyModelItem() { }
|
||||
protected:
|
||||
~HotkeyModelItem() = default;
|
||||
public:
|
||||
virtual unsigned int GetChildren(wxDataViewItemArray &children) const=0;
|
||||
virtual wxDataViewItem GetParent() const=0;
|
||||
|
|
|
@ -48,7 +48,7 @@ protected:
|
|||
|
||||
public:
|
||||
AudioPlayer(AudioProvider *provider);
|
||||
virtual ~AudioPlayer() { }
|
||||
virtual ~AudioPlayer() = default;
|
||||
|
||||
virtual void Play(int64_t start,int64_t count)=0; // Play sample range
|
||||
virtual void Stop()=0; // Stop playing
|
||||
|
|
|
@ -57,7 +57,7 @@ protected:
|
|||
void ZeroFill(void *buf, int64_t count) const;
|
||||
|
||||
public:
|
||||
virtual ~AudioProvider() { }
|
||||
virtual ~AudioProvider() = default;
|
||||
|
||||
void GetAudio(void *buf, int64_t start, int64_t count) const;
|
||||
void GetAudioWithVolume(void *buf, int64_t start, int64_t count, double volume) const;
|
||||
|
|
|
@ -43,7 +43,7 @@ struct VideoFrame;
|
|||
|
||||
class SubtitlesProvider {
|
||||
public:
|
||||
virtual ~SubtitlesProvider() { }
|
||||
virtual ~SubtitlesProvider() = default;
|
||||
virtual void LoadSubtitles(AssFile *subs)=0;
|
||||
virtual void DrawSubtitles(VideoFrame &dst, double time)=0;
|
||||
};
|
||||
|
|
|
@ -331,12 +331,11 @@ public:
|
|||
|
||||
class HotkeyRenderer final : public wxDataViewCustomRenderer {
|
||||
wxString value;
|
||||
wxTextCtrl *ctrl;
|
||||
wxTextCtrl *ctrl = nullptr;
|
||||
|
||||
public:
|
||||
HotkeyRenderer()
|
||||
: wxDataViewCustomRenderer("string", wxDATAVIEW_CELL_EDITABLE)
|
||||
, ctrl(nullptr)
|
||||
{ }
|
||||
|
||||
wxWindow *CreateEditorCtrl(wxWindow *parent, wxRect label_rect, wxVariant const& var) override {
|
||||
|
|
|
@ -260,7 +260,6 @@ struct disabler {
|
|||
wxControl *ctrl;
|
||||
bool enable;
|
||||
|
||||
disabler(wxControl *ctrl, bool enable) : ctrl(ctrl), enable(enable) { }
|
||||
void operator()(wxCommandEvent &evt) {
|
||||
ctrl->Enable(!!evt.GetInt() == enable);
|
||||
evt.Skip();
|
||||
|
@ -272,7 +271,7 @@ void OptionPage::EnableIfChecked(wxControl *cbx, wxControl *ctrl) {
|
|||
if (!cb) return;
|
||||
|
||||
ctrl->Enable(cb->IsChecked());
|
||||
cb->Bind(wxEVT_CHECKBOX, disabler(ctrl, true));
|
||||
cb->Bind(wxEVT_CHECKBOX, disabler{ctrl, true});
|
||||
}
|
||||
|
||||
void OptionPage::DisableIfChecked(wxControl *cbx, wxControl *ctrl) {
|
||||
|
@ -280,5 +279,5 @@ void OptionPage::DisableIfChecked(wxControl *cbx, wxControl *ctrl) {
|
|||
if (!cb) return;
|
||||
|
||||
ctrl->Enable(!cb->IsChecked());
|
||||
cb->Bind(wxEVT_CHECKBOX, disabler(ctrl, false));
|
||||
cb->Bind(wxEVT_CHECKBOX, disabler{ctrl, false});
|
||||
}
|
||||
|
|
|
@ -53,10 +53,10 @@ typedef std::function<MatchState (const AssDialogue*, size_t)> matcher;
|
|||
|
||||
class noop_accessor {
|
||||
boost::flyweight<std::string> AssDialogueBase::*field;
|
||||
size_t start;
|
||||
size_t start = 0;
|
||||
|
||||
public:
|
||||
noop_accessor(SearchReplaceSettings::Field f) : field(get_dialogue_field(f)), start(0) { }
|
||||
noop_accessor(SearchReplaceSettings::Field f) : field(get_dialogue_field(f)) { }
|
||||
|
||||
std::string get(const AssDialogue *d, size_t s) {
|
||||
start = s;
|
||||
|
@ -64,14 +64,14 @@ public:
|
|||
}
|
||||
|
||||
MatchState make_match_state(size_t s, size_t e, boost::u32regex *r = nullptr) {
|
||||
return MatchState(s + start, e + start, r);
|
||||
return {r, s + start, e + start};
|
||||
}
|
||||
};
|
||||
|
||||
class skip_tags_accessor {
|
||||
boost::flyweight<std::string> AssDialogueBase::*field;
|
||||
std::vector<std::pair<size_t, size_t>> blocks;
|
||||
size_t start;
|
||||
size_t start = 0;
|
||||
|
||||
void parse_str(std::string const& str) {
|
||||
blocks.clear();
|
||||
|
@ -90,7 +90,7 @@ class skip_tags_accessor {
|
|||
}
|
||||
|
||||
public:
|
||||
skip_tags_accessor(SearchReplaceSettings::Field f) : field(get_dialogue_field(f)), start(0) { }
|
||||
skip_tags_accessor(SearchReplaceSettings::Field f) : field(get_dialogue_field(f)) { }
|
||||
|
||||
std::string get(const AssDialogue *d, size_t s) {
|
||||
auto const& str = get_normalized(d, field);
|
||||
|
@ -140,7 +140,7 @@ public:
|
|||
// Note that blocks cannot be partially within the match
|
||||
e += block.second - block.first + 1;
|
||||
}
|
||||
return MatchState(s, e, r);
|
||||
return {r, s, e};
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -157,7 +157,7 @@ matcher get_matcher(SearchReplaceSettings const& settings, Accessor&& a) {
|
|||
boost::smatch result;
|
||||
auto const& str = a.get(diag, start);
|
||||
if (!u32regex_search(str, result, regex, start > 0 ? boost::match_not_bol : boost::match_default))
|
||||
return MatchState();
|
||||
return {nullptr, 0, -1};
|
||||
return a.make_match_state(result.position(), result.position() + result.length(), ®ex);
|
||||
};
|
||||
}
|
||||
|
@ -169,18 +169,19 @@ matcher get_matcher(SearchReplaceSettings const& settings, Accessor&& a) {
|
|||
if (!settings.match_case)
|
||||
look_for = boost::locale::fold_case(look_for);
|
||||
|
||||
MatchState invalid{nullptr, 0, -1};
|
||||
return [=](const AssDialogue *diag, size_t start) mutable -> MatchState {
|
||||
const auto str = a.get(diag, start);
|
||||
if (full_match_only && str.size() != look_for.size())
|
||||
return MatchState();
|
||||
return invalid;
|
||||
|
||||
if (match_case) {
|
||||
const auto pos = str.find(look_for);
|
||||
return pos == std::string::npos ? MatchState() : a.make_match_state(pos, pos + look_for.size());
|
||||
return pos == std::string::npos ? invalid : a.make_match_state(pos, pos + look_for.size());
|
||||
}
|
||||
|
||||
const auto pos = agi::util::ifind(str, look_for);
|
||||
return pos.first == bad_pos ? MatchState() : a.make_match_state(pos.first, pos.second);
|
||||
return pos.first == bad_pos ? invalid : a.make_match_state(pos.first, pos.second);
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -25,8 +25,6 @@ struct MatchState {
|
|||
boost::u32regex *re;
|
||||
size_t start, end;
|
||||
|
||||
MatchState() : re(nullptr), start(0), end(-1) { }
|
||||
MatchState(size_t s, size_t e, boost::u32regex *re) : re(re), start(s), end(e) { }
|
||||
operator bool() const { return end != (size_t)-1; }
|
||||
};
|
||||
|
||||
|
|
|
@ -70,8 +70,6 @@ SubtitleFormat::SubtitleFormat(std::string name)
|
|||
{
|
||||
}
|
||||
|
||||
SubtitleFormat::~SubtitleFormat() { }
|
||||
|
||||
bool SubtitleFormat::CanReadFile(agi::fs::path const& filename, std::string const&) const {
|
||||
auto wildcards = GetReadWildcards();
|
||||
return any_of(begin(wildcards), end(wildcards),
|
||||
|
|
|
@ -71,7 +71,7 @@ public:
|
|||
/// @param Subtitle format name
|
||||
SubtitleFormat(std::string name);
|
||||
/// Destructor
|
||||
virtual ~SubtitleFormat();
|
||||
virtual ~SubtitleFormat() = default;
|
||||
|
||||
/// Get this format's name
|
||||
std::string const& GetName() const { return name; }
|
||||
|
|
|
@ -39,6 +39,7 @@
|
|||
|
||||
#include <libaegisub/hotkey.h>
|
||||
|
||||
#include <list>
|
||||
#include <wx/weakref.h>
|
||||
#include <wx/window.h>
|
||||
|
||||
|
@ -48,36 +49,15 @@ struct ToolTipBinding {
|
|||
const char *command;
|
||||
const char *context;
|
||||
void Update();
|
||||
|
||||
ToolTipBinding(wxWindow *window, wxString toolTip, const char *command, const char *context)
|
||||
: window(window)
|
||||
, toolTip(toolTip)
|
||||
, command(command)
|
||||
, context(context)
|
||||
{
|
||||
}
|
||||
|
||||
// clang doesn't like wxWeakRef's copy constructor, so use the assignment
|
||||
// operator instead
|
||||
ToolTipBinding(ToolTipBinding const& other)
|
||||
: toolTip(other.toolTip)
|
||||
, command(other.command)
|
||||
, context(other.context)
|
||||
{
|
||||
window = other.window;
|
||||
}
|
||||
};
|
||||
|
||||
ToolTipManager::ToolTipManager() { }
|
||||
ToolTipManager::~ToolTipManager() { }
|
||||
|
||||
void ToolTipManager::Bind(wxWindow *window, wxString tooltip, const char *context, const char *command) {
|
||||
ToolTipBinding tip(window, tooltip, command, context);
|
||||
ToolTipBinding tip{window, tooltip, command, context};
|
||||
tip.Update();
|
||||
|
||||
static ToolTipManager instance;
|
||||
instance.tips.push_back(tip);
|
||||
hotkey::inst->AddHotkeyChangeListener(&ToolTipBinding::Update, &instance.tips.back());
|
||||
static std::list<ToolTipBinding> tips;
|
||||
tips.push_back(tip);
|
||||
hotkey::inst->AddHotkeyChangeListener(&ToolTipBinding::Update, &tips.back());
|
||||
}
|
||||
|
||||
void ToolTipBinding::Update() {
|
||||
|
|
|
@ -27,26 +27,10 @@
|
|||
//
|
||||
// Aegisub Project http://www.aegisub.org/
|
||||
|
||||
/// @file tooltip_manager.h
|
||||
/// @see tooltip_manager.cpp
|
||||
/// @ingroup custom_control
|
||||
///
|
||||
|
||||
#include <boost/container/list.hpp>
|
||||
|
||||
struct ToolTipBinding;
|
||||
|
||||
class wxString;
|
||||
class wxWindow;
|
||||
|
||||
class ToolTipManager {
|
||||
ToolTipManager();
|
||||
~ToolTipManager();
|
||||
ToolTipManager(ToolTipManager const&);
|
||||
ToolTipManager& operator=(ToolTipManager const&);
|
||||
|
||||
boost::container::list<ToolTipBinding> tips;
|
||||
|
||||
public:
|
||||
static void Bind(wxWindow *window, wxString tooltip, const char *context, const char *command);
|
||||
};
|
||||
|
|
|
@ -142,7 +142,7 @@ public:
|
|||
virtual void Draw()=0;
|
||||
virtual void SetDisplayArea(int x, int y, int w, int h);
|
||||
virtual void SetToolbar(wxToolBar *) { }
|
||||
virtual ~VisualToolBase() { }
|
||||
virtual ~VisualToolBase() = default;
|
||||
};
|
||||
|
||||
/// Visual tool base class containing all common feature-related functionality
|
||||
|
|
|
@ -24,9 +24,9 @@
|
|||
|
||||
/// VisualDraggableFeature with siblings
|
||||
struct ClipCorner final : public VisualDraggableFeature {
|
||||
ClipCorner *horiz; ///< Other corner on this corner's horizontal line
|
||||
ClipCorner *vert; ///< Other corner on this corner's vertical line
|
||||
ClipCorner() : VisualDraggableFeature() , horiz(nullptr) , vert(nullptr) { type = DRAG_SMALL_CIRCLE; }
|
||||
ClipCorner *horiz = nullptr; ///< Other corner on this corner's horizontal line
|
||||
ClipCorner *vert = nullptr; ///< Other corner on this corner's vertical line
|
||||
ClipCorner() { type = DRAG_SMALL_CIRCLE; }
|
||||
};
|
||||
|
||||
class VisualToolClip final : public VisualTool<ClipCorner> {
|
||||
|
|
|
@ -26,9 +26,8 @@
|
|||
/// @brief VisualDraggableFeature with a time value
|
||||
class VisualToolDragDraggableFeature final : public VisualDraggableFeature {
|
||||
public:
|
||||
int time;
|
||||
VisualToolDragDraggableFeature *parent;
|
||||
VisualToolDragDraggableFeature() : VisualDraggableFeature(), time(0), parent(nullptr) { }
|
||||
int time = 0;
|
||||
VisualToolDragDraggableFeature *parent = nullptr;
|
||||
};
|
||||
|
||||
class wxBitmapButton;
|
||||
|
|
|
@ -32,12 +32,7 @@ struct VisualToolVectorClipDraggableFeature final : public VisualDraggableFeatur
|
|||
/// Which curve in the spline this feature is a point on
|
||||
Spline::iterator curve;
|
||||
/// 0-3; indicates which part of the curve this point is
|
||||
int point;
|
||||
/// @brief Constructor
|
||||
VisualToolVectorClipDraggableFeature()
|
||||
: VisualDraggableFeature()
|
||||
, point(0)
|
||||
{ }
|
||||
int point = 0;
|
||||
};
|
||||
|
||||
class VisualToolVectorClip final : public VisualTool<VisualToolVectorClipDraggableFeature> {
|
||||
|
|
Loading…
Reference in New Issue