From e25522231673c082ee66f81a59698310993b941a Mon Sep 17 00:00:00 2001 From: Rodrigo Braz Monteiro Date: Mon, 17 Nov 2008 03:09:27 +0000 Subject: [PATCH] Fixed some stuff. Originally committed to SVN as r2464. --- athenasub/athenasub_2008.vcproj | 12 +++++--- athenasub/{src => include/athenasub}/colour.h | 11 +++---- athenasub/include/athenasub/interfaces.h | 29 +++---------------- athenasub/src/colour.cpp | 18 ++++++------ athenasub/src/formats/format_ass_style.h | 4 +-- 5 files changed, 29 insertions(+), 45 deletions(-) rename athenasub/{src => include/athenasub}/colour.h (91%) diff --git a/athenasub/athenasub_2008.vcproj b/athenasub/athenasub_2008.vcproj index 11ef9105b..e23a03936 100644 --- a/athenasub/athenasub_2008.vcproj +++ b/athenasub/athenasub_2008.vcproj @@ -186,6 +186,10 @@ RelativePath=".\include\athenasub\athenawin.h" > + + @@ -194,6 +198,10 @@ RelativePath=".\include\athenasub\interfaces.h" > + + @@ -242,10 +250,6 @@ RelativePath=".\src\colour.cpp" > - - diff --git a/athenasub/src/colour.h b/athenasub/include/athenasub/colour.h similarity index 91% rename from athenasub/src/colour.h rename to athenasub/include/athenasub/colour.h index 9b6d47d8f..6cb35d65e 100644 --- a/athenasub/src/colour.h +++ b/athenasub/include/athenasub/colour.h @@ -34,19 +34,20 @@ // #pragma once -#include "athenasub.h" namespace Athenasub { + class String; + // Colour class - class CColour : public IColour { + class Colour { private: unsigned char r, g, b, a; public: - CColour (); - CColour (unsigned char red,unsigned char green,unsigned char blue,unsigned char alpha=0); - CColour (int red,int green,int blue,int alpha=0); + Colour (); + Colour (unsigned char red,unsigned char green,unsigned char blue,unsigned char alpha=0); + Colour (int red,int green,int blue,int alpha=0); void SetRed(unsigned char red) { r = red; } void SetGreen(unsigned char green) { g = green; } diff --git a/athenasub/include/athenasub/interfaces.h b/athenasub/include/athenasub/interfaces.h index 1c9945075..98c4ab092 100644 --- a/athenasub/include/athenasub/interfaces.h +++ b/athenasub/include/athenasub/interfaces.h @@ -38,6 +38,7 @@ #include "tr1.h" #include "athenatime.h" #include "athenastring.h" +#include "colour.h" #include #include @@ -52,7 +53,6 @@ namespace Athenasub { class IController; class IView; class IFormatHandler; - class IColour; class IEntry; class IDialogue; class IStyle; @@ -72,7 +72,6 @@ namespace Athenasub { typedef shared_ptr Controller; typedef shared_ptr View; typedef shared_ptr FormatHandler; - typedef shared_ptr Colour; typedef shared_ptr Entry; typedef shared_ptr Dialogue; typedef shared_ptr Style; @@ -145,6 +144,8 @@ namespace Athenasub { class IView { public: virtual ~IView() {} + + virtual void OnNotify(Notification notification) = 0; }; @@ -201,26 +202,6 @@ namespace Athenasub { }; - // Color - class IColour { - public: - virtual ~IColour() {} - - virtual void SetRed(int red) = 0; - virtual void SetGreen(int green) = 0; - virtual void SetBlue(int blue) = 0; - virtual void SetAlpha(int alpha) = 0; - - virtual int GetRed() const = 0; - virtual int GetGreen() const = 0; - virtual int GetBlue() const = 0; - virtual int GetAlpha() const = 0; - - virtual void Parse(String str,bool reverse) = 0; - virtual String GetVBHex(bool withAlpha=false,bool withHeader=true,bool withFooter=true) const = 0; - }; - - // Types enum SectionEntryType { SECTION_ENTRY_PLAIN, @@ -304,7 +285,7 @@ namespace Athenasub { virtual String GetName() const = 0; virtual String GetFontName() const = 0; virtual float GetFontSize() const = 0; - virtual const IColour& GetColour(int n) const = 0; + virtual const Colour& GetColour(int n) const = 0; virtual int GetMargin(int n) const = 0; }; @@ -356,8 +337,6 @@ namespace Athenasub { virtual ~IAction() {} virtual Action GetAntiAction() const = 0; virtual void Execute() = 0; - - //virtual Section GetSection(const String &name) const = 0; }; diff --git a/athenasub/src/colour.cpp b/athenasub/src/colour.cpp index be342e61c..267b614b7 100644 --- a/athenasub/src/colour.cpp +++ b/athenasub/src/colour.cpp @@ -42,18 +42,18 @@ using namespace Athenasub; //////////////// // Constructors -CColour::CColour () +Colour::Colour () { r = g = b = a = 0; } -CColour::CColour (unsigned char red,unsigned char green,unsigned char blue,unsigned char alpha) +Colour::Colour (unsigned char red,unsigned char green,unsigned char blue,unsigned char alpha) { r = red; g = green; b = blue; a = alpha; } -CColour::CColour (int red,int green,int blue,int alpha) +Colour::Colour (int red,int green,int blue,int alpha) { SetRed(red); SetGreen(green); @@ -64,15 +64,15 @@ CColour::CColour (int red,int green,int blue,int alpha) //////////////////////// // Set colour component -void CColour::SetRed(int red) { r = (unsigned char) Mid(0,red,255); } -void CColour::SetGreen(int green) { g = (unsigned char) Mid(0,green,255); } -void CColour::SetBlue(int blue) { b = (unsigned char) Mid(0,blue,255); } -void CColour::SetAlpha(int alpha) { a = (unsigned char) Mid(0,alpha,255); } +void Colour::SetRed(int red) { r = (unsigned char) Mid(0,red,255); } +void Colour::SetGreen(int green) { g = (unsigned char) Mid(0,green,255); } +void Colour::SetBlue(int blue) { b = (unsigned char) Mid(0,blue,255); } +void Colour::SetAlpha(int alpha) { a = (unsigned char) Mid(0,alpha,255); } ////////////// // Parse text -void CColour::Parse(String value,bool reverse) +void Colour::Parse(String value,bool reverse) { // Prepare unsigned char c; @@ -112,7 +112,7 @@ void CColour::Parse(String value,bool reverse) ///////////////////////////// // Generate Visual Basic hex -String CColour::GetVBHex(bool withAlpha,bool withHeader,bool withFooter) const +String Colour::GetVBHex(bool withAlpha,bool withHeader,bool withFooter) const { String work; if (withHeader) work += "&H"; diff --git a/athenasub/src/formats/format_ass_style.h b/athenasub/src/formats/format_ass_style.h index 6e81d7871..95270e200 100644 --- a/athenasub/src/formats/format_ass_style.h +++ b/athenasub/src/formats/format_ass_style.h @@ -48,7 +48,7 @@ namespace Athenasub { float fontSize; int formatVersion; - array colour; // 0 = Primary, 1 = Secondary, 2 = Tertiary, 3 = Outline, 4 = Shadow + array colour; // 0 = Primary, 1 = Secondary, 2 = Tertiary, 3 = Outline, 4 = Shadow array margin; bool bold; @@ -90,7 +90,7 @@ namespace Athenasub { String GetName() const { return name; } String GetFontName() const { return font; } float GetFontSize() const { return fontSize; } - const IColour& GetColour(int n) const { return colour.at(n); } + const Colour& GetColour(int n) const { return colour.at(n); } int GetMargin(int n) const { return margin.at(n); } };