forked from mia/Aegisub
Use std::tr1::array for AssStyle::Margin
This eliminates the need for an explicit operator= on AssStyle.
This commit is contained in:
parent
e0705f1c84
commit
ce05857bfa
5 changed files with 12 additions and 64 deletions
|
@ -50,11 +50,15 @@
|
||||||
|
|
||||||
#include "../libaegisub/lagi_pre.h"
|
#include "../libaegisub/lagi_pre.h"
|
||||||
|
|
||||||
/////////
|
|
||||||
// Setup
|
|
||||||
#define AGI_PRE
|
#define AGI_PRE
|
||||||
|
|
||||||
// General headers
|
// General headers
|
||||||
|
#ifdef _WIN32
|
||||||
|
#include <array>
|
||||||
|
#else
|
||||||
|
#include <tr1/array>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <clocale>
|
#include <clocale>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <cctype>
|
#include <cctype>
|
||||||
|
|
|
@ -78,7 +78,7 @@ class AssEntry {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/// Group it belongs to, e.g. "[Events]"
|
/// Group it belongs to, e.g. "[Events]"
|
||||||
const wxString group;
|
wxString group;
|
||||||
|
|
||||||
AssEntry(wxString const& data, wxString const& group) : data(data), group(group) { }
|
AssEntry(wxString const& data, wxString const& group) : data(data), group(group) { }
|
||||||
virtual ~AssEntry() { }
|
virtual ~AssEntry() { }
|
||||||
|
|
|
@ -62,8 +62,6 @@ AssColor::AssColor(const wxColour &color)
|
||||||
SetWXColor(color);
|
SetWXColor(color);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @brief Parse from SSA/ASS
|
|
||||||
/// @param value
|
|
||||||
void AssColor::Parse(wxString const& value) {
|
void AssColor::Parse(wxString const& value) {
|
||||||
if (value.size() > 0 && value[0] == '#') {
|
if (value.size() > 0 && value[0] == '#') {
|
||||||
// HTML colour
|
// HTML colour
|
||||||
|
@ -96,26 +94,16 @@ void AssColor::Parse(wxString const& value) {
|
||||||
a = (outval>>24) & 0xFF;
|
a = (outval>>24) & 0xFF;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @brief Gets a wxColour
|
|
||||||
/// @return
|
|
||||||
wxColour AssColor::GetWXColor() const {
|
wxColour AssColor::GetWXColor() const {
|
||||||
return wxColour(r,g,b,255-a);
|
return wxColour(r,g,b,255-a);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @brief Sets color from wx
|
|
||||||
/// @param color
|
|
||||||
void AssColor::SetWXColor(const wxColor &color) {
|
void AssColor::SetWXColor(const wxColor &color) {
|
||||||
r = color.Red();
|
r = color.Red();
|
||||||
g = color.Green();
|
g = color.Green();
|
||||||
b = color.Blue();
|
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 AssColor::GetAssFormatted(bool alpha,bool stripped,bool isStyle) const {
|
||||||
wxString work;
|
wxString work;
|
||||||
if (!stripped) work += "&H";
|
if (!stripped) work += "&H";
|
||||||
|
@ -125,8 +113,6 @@ wxString AssColor::GetAssFormatted(bool alpha,bool stripped,bool isStyle) const
|
||||||
return work;
|
return work;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @brief Get decimal formatted
|
|
||||||
/// @return
|
|
||||||
wxString AssColor::GetSSAFormatted() const {
|
wxString AssColor::GetSSAFormatted() const {
|
||||||
long color = (a<<24)+(b<<16)+(g<<8)+r;
|
long color = (a<<24)+(b<<16)+(g<<8)+r;
|
||||||
wxString output=wxString::Format("%li",(long)color);
|
wxString output=wxString::Format("%li",(long)color);
|
||||||
|
@ -164,8 +150,7 @@ AssStyle::AssStyle()
|
||||||
, alignment(2)
|
, alignment(2)
|
||||||
, encoding(1)
|
, encoding(1)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < 3; i++)
|
std::fill(Margin.begin(), Margin.end(), 10);
|
||||||
Margin[i] = 10;
|
|
||||||
|
|
||||||
UpdateData();
|
UpdateData();
|
||||||
}
|
}
|
||||||
|
@ -269,38 +254,6 @@ AssStyle::AssStyle(wxString rawData, int version)
|
||||||
UpdateData();
|
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() {
|
void AssStyle::UpdateData() {
|
||||||
wxString final;
|
wxString final;
|
||||||
|
|
||||||
|
|
|
@ -33,16 +33,13 @@
|
||||||
///
|
///
|
||||||
|
|
||||||
#ifndef AGI_PRE
|
#ifndef AGI_PRE
|
||||||
|
#include <tr1/array>
|
||||||
|
|
||||||
#include <wx/colour.h>
|
#include <wx/colour.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "ass_entry.h"
|
#include "ass_entry.h"
|
||||||
|
|
||||||
/// DOCME
|
|
||||||
/// @class AssColor
|
|
||||||
/// @brief DOCME
|
|
||||||
///
|
|
||||||
/// DOCME
|
|
||||||
struct AssColor {
|
struct AssColor {
|
||||||
int r; ///< Red component
|
int r; ///< Red component
|
||||||
int g; ///< Green component
|
int g; ///< Green component
|
||||||
|
@ -63,11 +60,6 @@ struct AssColor {
|
||||||
wxString GetSSAFormatted() const;
|
wxString GetSSAFormatted() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
/// DOCME
|
|
||||||
/// @class AssStyle
|
|
||||||
/// @brief DOCME
|
|
||||||
///
|
|
||||||
/// DOCME
|
|
||||||
class AssStyle : public AssEntry {
|
class AssStyle : public AssEntry {
|
||||||
public:
|
public:
|
||||||
wxString name; ///< Name of the style; must be case-insensitively unique within a file despite being case-sensitive
|
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 outline_w; ///< Outline width in pixels
|
||||||
double shadow_w; ///< Shadow distance in pixels
|
double shadow_w; ///< Shadow distance in pixels
|
||||||
int alignment; ///< \an-style line alignment
|
int alignment; ///< \an-style line alignment
|
||||||
int Margin[3]; ///< Left/Right/Vertical
|
std::tr1::array<int, 3> Margin; ///< Left/Right/Vertical
|
||||||
int encoding; ///< ASS font encoding needed for some non-unicode fonts
|
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
|
/// Update the raw line data after one or more of the public members have been changed
|
||||||
|
@ -103,7 +95,6 @@ public:
|
||||||
|
|
||||||
AssStyle();
|
AssStyle();
|
||||||
AssStyle(wxString data, int version=1);
|
AssStyle(wxString data, int version=1);
|
||||||
AssStyle& operator=(AssStyle const&);
|
|
||||||
|
|
||||||
wxString GetSSAText() const;
|
wxString GetSSAText() const;
|
||||||
AssEntryType GetType() const { return ENTRY_STYLE; }
|
AssEntryType GetType() const { return ENTRY_STYLE; }
|
||||||
|
|
|
@ -79,7 +79,7 @@ void SubtitlesPreview::SetStyle(AssStyle const& newStyle) {
|
||||||
*style = newStyle;
|
*style = newStyle;
|
||||||
style->name = "Default";
|
style->name = "Default";
|
||||||
style->alignment = 5;
|
style->alignment = 5;
|
||||||
memset(style->Margin, 0, sizeof style->Margin);
|
std::fill(style->Margin.begin(), style->Margin.end(), 0);
|
||||||
style->UpdateData();
|
style->UpdateData();
|
||||||
UpdateBitmap();
|
UpdateBitmap();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue