Document most of AssStyle and remove some unused code

Originally committed to SVN as r6036.
This commit is contained in:
Thomas Goyne 2011-12-22 21:15:10 +00:00
parent dbf3eea732
commit 9eaad5f0b1
2 changed files with 34 additions and 141 deletions

View File

@ -208,11 +208,6 @@ AssStyle::AssStyle(wxString _data,int version) {
UpdateData();
}
/// @brief Parses value from ASS data
/// @param rawData
/// @param version
/// @return
///
bool AssStyle::Parse(wxString rawData,int version) {
// Tokenize
wxString temp;
@ -414,8 +409,6 @@ bool AssStyle::Parse(wxString rawData,int version) {
return true;
}
/// @brief Writes data back to ASS (v4+) format
///
void AssStyle::UpdateData() {
wxString final;
@ -438,10 +431,6 @@ void AssStyle::UpdateData() {
SetEntryData(final);
}
/// @brief Sets margin from a string
/// @param str
/// @param which
///
void AssStyle::SetMarginString(const wxString str,int which) {
if (which < 0 || which >= 4) throw Aegisub::InvalidMarginIdError();
if (!str.IsNumber()) throw "Invalid margin value";
@ -453,19 +442,12 @@ void AssStyle::SetMarginString(const wxString str,int which) {
Margin[which] = value;
}
/// @brief Gets string for margin
/// @param which
/// @return
///
wxString AssStyle::GetMarginString(int which) const {
if (which < 0 || which >= 4) throw Aegisub::InvalidMarginIdError();
wxString result = wxString::Format("%04i",Margin[which]);
return result;
}
/// @brief Convert style to SSA string
/// @return
///
wxString AssStyle::GetSSAText() const {
wxString output;
int align = 0;
@ -497,56 +479,10 @@ wxString AssStyle::GetSSAText() const {
return output;
}
/// @brief Clone
/// @return
///
AssEntry *AssStyle::Clone() const {
return new AssStyle(*this);
}
/// @brief Equal to another style?
/// @param style
/// @return
///
bool AssStyle::IsEqualTo(AssStyle *style) const {
// memcmp won't work because strings won't match
if (style->alignment != alignment ||
style->angle != angle ||
style->bold != bold ||
style->borderstyle != borderstyle ||
style->encoding != encoding ||
style->font != font ||
style->fontsize != fontsize ||
style->italic != italic ||
style->Margin[0] != Margin[0] ||
style->Margin[1] != Margin[1] ||
style->Margin[2] != Margin[2] ||
style->Margin[3] != Margin[3] ||
style->name != name ||
style->outline != outline ||
style->outline_w != outline_w ||
style->primary != primary ||
style->scalex != scalex ||
style->scaley != scaley ||
style->secondary != secondary ||
style->shadow != shadow ||
style->shadow_w != shadow_w ||
style->spacing != spacing ||
style->strikeout != strikeout ||
style->underline != underline ||
style->relativeTo != relativeTo)
return false;
else return true;
}
/// @brief Get a list of valid ASS encodings
/// @param encodingStrings
///
void AssStyle::GetEncodings(wxArrayString &encodingStrings) {
encodingStrings.Clear();
encodingStrings.Add(wxString("0 - ") + _("ANSI"));
@ -569,5 +505,3 @@ void AssStyle::GetEncodings(wxArrayString &encodingStrings) {
encodingStrings.Add(wxString("238 - ") + _("East European"));
encodingStrings.Add(wxString("255 - ") + _("OEM"));
}

View File

@ -71,96 +71,55 @@ struct AssColor {
///
/// DOCME
class AssStyle : public AssEntry {
// Parses raw ASS/SSA data into everything else
bool Parse(wxString data,int version=1);
public:
/// DOCME
wxString name;
wxString name; ///< Name of the style; must be case-insensitively unique within a file despite being case-sensitive
wxString font; ///< Font face name
double fontsize; ///< Font size
/// DOCME
wxString font;
AssColor primary; ///< Default text color
AssColor secondary; ///< Text color for not-yet-reached karaoke syllables
AssColor outline; ///< Outline color
AssColor shadow; ///< Shadow color
/// DOCME
double fontsize;
/// DOCME
AssColor primary;
/// DOCME
AssColor secondary;
/// DOCME
AssColor outline;
/// DOCME
AssColor shadow;
/// DOCME
bool bold;
/// DOCME
bool italic;
/// DOCME
bool underline;
/// DOCME
bool strikeout;
double scalex; ///< Font x scale with 100 = 100%
double scaley; ///< Font y scale with 100 = 100%
double spacing; ///< Additional spacing between characters in pixels
double angle; ///< Counterclockwise z rotation in degrees
int borderstyle; ///< 1: Normal; 3: Opaque box; others are unused in Aegisub
double outline_w; ///< Outline width in pixels
double shadow_w; ///< Shadow distance in pixels
int alignment; ///< \an-style line alignment
int Margin[4]; ///< Left/Right/Vertical/Unused margins in pixels
int encoding; ///< ASS font encoding needed for some non-unicode fonts
int relativeTo; ///< ASS2 extension; do not use
/// DOCME
double scalex;
/// Update the raw line data after one or more of the public members have been changed
void UpdateData();
/// DOCME
double scaley;
/// Returns the margin value as a string
/// @param which 0: left; 1: right; 2: vertical/top; 3: bottom
wxString GetMarginString(int which) const;
/// DOCME
double spacing;
/// Sets margin value from a string
/// @param value New value for the margin; must contain a number
/// @param which 0: left; 1: right; 2: vertical/top; 3: bottom
void SetMarginString(const wxString value, int which);
/// DOCME
double angle;
/// DOCME
int borderstyle;
/// DOCME
double outline_w;
/// DOCME
double shadow_w;
/// DOCME
int alignment;
/// DOCME
int Margin[4];
/// DOCME
int encoding;
/// DOCME
int relativeTo;
/// @brief DOCME
///
ASS_EntryType GetType() const { return ENTRY_STYLE; }
bool Parse(wxString data,int version=1); // Parses raw ASS/SSA data into everything else
void UpdateData(); // Updates raw data
wxString GetSSAText() const; // Retrieves SSA-formatted style
wxString GetMarginString(int which) const; // Returns the margin value as a string (0 = left, 1 = right, 2 = vertical/top, 3 = bottom)
void SetMarginString(const wxString value,int which); // Sets margin value from a string (0 = left, 1 = right, 2 = vertical/top, 3 = bottom)
/// @brief Get a list of valid ASS font encodings
static void GetEncodings(wxArrayString &encodingStrings);
AssEntry *Clone() const;
bool IsEqualTo(AssStyle *style) const;
AssStyle();
AssStyle(AssStyle const&);
AssStyle(wxString data,int version=1);
~AssStyle();
wxString GetSSAText() const;
ASS_EntryType GetType() const { return ENTRY_STYLE; }
AssEntry *Clone() const;
};