From ce05857bfad459f490260c42155891bc51a23cee Mon Sep 17 00:00:00 2001 From: Thomas Goyne Date: Fri, 26 Oct 2012 07:29:52 -0700 Subject: [PATCH] Use std::tr1::array for AssStyle::Margin This eliminates the need for an explicit operator= on AssStyle. --- aegisub/src/agi_pre.h | 8 ++++-- aegisub/src/ass_entry.h | 2 +- aegisub/src/ass_style.cpp | 49 +----------------------------------- aegisub/src/ass_style.h | 15 +++-------- aegisub/src/subs_preview.cpp | 2 +- 5 files changed, 12 insertions(+), 64 deletions(-) diff --git a/aegisub/src/agi_pre.h b/aegisub/src/agi_pre.h index 01281c182..863211256 100644 --- a/aegisub/src/agi_pre.h +++ b/aegisub/src/agi_pre.h @@ -50,11 +50,15 @@ #include "../libaegisub/lagi_pre.h" -///////// -// Setup #define AGI_PRE // General headers +#ifdef _WIN32 +#include +#else +#include +#endif + #include #include #include diff --git a/aegisub/src/ass_entry.h b/aegisub/src/ass_entry.h index b9e63c719..83ef4b166 100644 --- a/aegisub/src/ass_entry.h +++ b/aegisub/src/ass_entry.h @@ -78,7 +78,7 @@ class AssEntry { public: /// Group it belongs to, e.g. "[Events]" - const wxString group; + wxString group; AssEntry(wxString const& data, wxString const& group) : data(data), group(group) { } virtual ~AssEntry() { } diff --git a/aegisub/src/ass_style.cpp b/aegisub/src/ass_style.cpp index 6ec3f873a..6085b326a 100644 --- a/aegisub/src/ass_style.cpp +++ b/aegisub/src/ass_style.cpp @@ -62,8 +62,6 @@ AssColor::AssColor(const wxColour &color) SetWXColor(color); } -/// @brief Parse from SSA/ASS -/// @param value void AssColor::Parse(wxString const& value) { if (value.size() > 0 && value[0] == '#') { // HTML colour @@ -96,26 +94,16 @@ void AssColor::Parse(wxString const& value) { a = (outval>>24) & 0xFF; } -/// @brief Gets a wxColour -/// @return wxColour AssColor::GetWXColor() const { return wxColour(r,g,b,255-a); } -/// @brief Sets color from wx -/// @param color void AssColor::SetWXColor(const wxColor &color) { r = color.Red(); g = color.Green(); b = color.Blue(); - //a = color.Alpha(); } -/// @brief Get formatted in ASS format -/// @param alpha -/// @param stripped -/// @param isStyle -/// @return wxString AssColor::GetAssFormatted(bool alpha,bool stripped,bool isStyle) const { wxString work; if (!stripped) work += "&H"; @@ -125,8 +113,6 @@ wxString AssColor::GetAssFormatted(bool alpha,bool stripped,bool isStyle) const return work; } -/// @brief Get decimal formatted -/// @return wxString AssColor::GetSSAFormatted() const { long color = (a<<24)+(b<<16)+(g<<8)+r; wxString output=wxString::Format("%li",(long)color); @@ -164,8 +150,7 @@ AssStyle::AssStyle() , alignment(2) , encoding(1) { - for (int i = 0; i < 3; i++) - Margin[i] = 10; + std::fill(Margin.begin(), Margin.end(), 10); UpdateData(); } @@ -269,38 +254,6 @@ AssStyle::AssStyle(wxString rawData, int version) UpdateData(); } -AssStyle& AssStyle::operator=(AssStyle const& rgt) { - name = rgt.name; - font = rgt.font; - fontsize = rgt.fontsize; - - primary = rgt.primary; - secondary = rgt.secondary; - outline = rgt.outline; - shadow = rgt.shadow; - - bold = rgt.bold; - italic = rgt.italic; - underline = rgt.underline; - strikeout = rgt.strikeout; - - scalex = rgt.scalex; - scaley = rgt.scaley; - spacing = rgt.spacing; - angle = rgt.angle; - borderstyle = rgt.borderstyle; - outline_w = rgt.outline_w; - shadow_w = rgt.shadow_w; - alignment = rgt.alignment; - encoding = rgt.encoding; - - memcpy(Margin, rgt.Margin, sizeof(Margin)); - - SetEntryData(rgt.GetEntryData()); - - return *this; -} - void AssStyle::UpdateData() { wxString final; diff --git a/aegisub/src/ass_style.h b/aegisub/src/ass_style.h index 430896385..af973e9f2 100644 --- a/aegisub/src/ass_style.h +++ b/aegisub/src/ass_style.h @@ -33,16 +33,13 @@ /// #ifndef AGI_PRE +#include + #include #endif #include "ass_entry.h" -/// DOCME -/// @class AssColor -/// @brief DOCME -/// -/// DOCME struct AssColor { int r; ///< Red component int g; ///< Green component @@ -63,11 +60,6 @@ struct AssColor { wxString GetSSAFormatted() const; }; -/// DOCME -/// @class AssStyle -/// @brief DOCME -/// -/// DOCME class AssStyle : public AssEntry { public: wxString name; ///< Name of the style; must be case-insensitively unique within a file despite being case-sensitive @@ -92,7 +84,7 @@ public: double outline_w; ///< Outline width in pixels double shadow_w; ///< Shadow distance in pixels int alignment; ///< \an-style line alignment - int Margin[3]; ///< Left/Right/Vertical + std::tr1::array Margin; ///< Left/Right/Vertical int encoding; ///< ASS font encoding needed for some non-unicode fonts /// Update the raw line data after one or more of the public members have been changed @@ -103,7 +95,6 @@ public: AssStyle(); AssStyle(wxString data, int version=1); - AssStyle& operator=(AssStyle const&); wxString GetSSAText() const; AssEntryType GetType() const { return ENTRY_STYLE; } diff --git a/aegisub/src/subs_preview.cpp b/aegisub/src/subs_preview.cpp index a0313f8b8..13534a5ab 100644 --- a/aegisub/src/subs_preview.cpp +++ b/aegisub/src/subs_preview.cpp @@ -79,7 +79,7 @@ void SubtitlesPreview::SetStyle(AssStyle const& newStyle) { *style = newStyle; style->name = "Default"; style->alignment = 5; - memset(style->Margin, 0, sizeof style->Margin); + std::fill(style->Margin.begin(), style->Margin.end(), 0); style->UpdateData(); UpdateBitmap(); }