Changeset View
Changeset View
Standalone View
Standalone View
src/acbf/AcbfTextarea.h
Show All 22 Lines | |||||
23 | #define ACBFTEXTAREA_H | 23 | #define ACBFTEXTAREA_H | ||
24 | 24 | | |||
25 | #include <memory> | 25 | #include <memory> | ||
26 | 26 | | |||
27 | #include "AcbfTextlayer.h" | 27 | #include "AcbfTextlayer.h" | ||
28 | 28 | | |||
29 | #include <QPoint> | 29 | #include <QPoint> | ||
30 | 30 | | |||
31 | /** | ||||
32 | * \brief Class to handle the text areas in ACBF | ||||
33 | * | ||||
34 | * ACBF text areas are a collection of points, some text | ||||
35 | * and some extra information on how to render that text if necessary. | ||||
36 | */ | ||||
37 | | ||||
31 | namespace AdvancedComicBookFormat | 38 | namespace AdvancedComicBookFormat | ||
32 | { | 39 | { | ||
33 | class ACBF_EXPORT Textarea : public QObject | 40 | class ACBF_EXPORT Textarea : public QObject | ||
34 | { | 41 | { | ||
35 | Q_OBJECT | 42 | Q_OBJECT | ||
36 | public: | 43 | public: | ||
37 | explicit Textarea(Textlayer* parent = nullptr); | 44 | explicit Textarea(Textlayer* parent = nullptr); | ||
38 | ~Textarea() override; | 45 | ~Textarea() override; | ||
39 | 46 | | |||
47 | /** | ||||
48 | * @return the types that a text-area can be, like speech or commentary. | ||||
49 | */ | ||||
40 | static QStringList availableTypes(); | 50 | static QStringList availableTypes(); | ||
41 | 51 | | |||
52 | /** | ||||
53 | * \brief Write the textarea into the xml writer. | ||||
54 | */ | ||||
42 | void toXml(QXmlStreamWriter* writer); | 55 | void toXml(QXmlStreamWriter* writer); | ||
56 | /** | ||||
57 | * \brief load a textarea element into this object. | ||||
58 | * @return True if the xmlReader encountered no errors. | ||||
59 | */ | ||||
43 | bool fromXml(QXmlStreamReader *xmlReader); | 60 | bool fromXml(QXmlStreamReader *xmlReader); | ||
44 | 61 | | |||
62 | /** | ||||
63 | * @return a list of points that encompasses the textarea. | ||||
64 | */ | ||||
45 | QList<QPoint> points() const; | 65 | QList<QPoint> points() const; | ||
66 | /** | ||||
67 | * @param index - the index of the desired point. | ||||
68 | * @return a point for an index. | ||||
69 | */ | ||||
46 | QPoint point(int index) const; | 70 | QPoint point(int index) const; | ||
71 | /** | ||||
72 | * @param point - a point from the points list. | ||||
73 | * @return the index of the given point. | ||||
74 | */ | ||||
47 | int pointIndex(const QPoint& point) const; | 75 | int pointIndex(const QPoint& point) const; | ||
48 | 76 | | |||
49 | // If afterIndex is larger than zero, the insertion will happen at that index | 77 | /** | ||
78 | * \brief add a point to the points list. | ||||
79 | * @param point - the point to add. Coordinates should be in pixels. | ||||
80 | * @param index - the index to add it at. If afterIndex is larger than zero, | ||||
81 | * the insertion will happen at that index | ||||
82 | */ | ||||
50 | void addPoint(const QPoint& point, int index = -1); | 83 | void addPoint(const QPoint& point, int index = -1); | ||
84 | /** | ||||
85 | * \brief remove a point from the list. | ||||
86 | * @param point - point to remove from the list. | ||||
87 | */ | ||||
51 | void removePoint(const QPoint& point); | 88 | void removePoint(const QPoint& point); | ||
89 | /** | ||||
90 | * \brief Swap two points in the list. | ||||
91 | * @param swapThis - the first points to swap. | ||||
92 | * @param withThis - the second points to swap. | ||||
93 | */ | ||||
52 | bool swapPoints(const QPoint& swapThis, const QPoint& withThis); | 94 | bool swapPoints(const QPoint& swapThis, const QPoint& withThis); | ||
53 | 95 | | |||
96 | /** | ||||
97 | * @return the background color as a QString. | ||||
98 | * | ||||
99 | * It should be an 8bit per channel rgb hexcode. | ||||
100 | */ | ||||
54 | QString bgcolor() const; | 101 | QString bgcolor() const; | ||
102 | /** | ||||
103 | * \brief set the background color. | ||||
104 | * | ||||
105 | * @param newColor - a String with an 8bit per channel rgb hexcode (#ff00ff, or the like) | ||||
106 | */ | ||||
55 | void setBgcolor(const QString& newColor = QString()); | 107 | void setBgcolor(const QString& newColor = QString()); | ||
56 | 108 | | |||
109 | /** | ||||
110 | * @return the text rotation in degrees. | ||||
111 | */ | ||||
57 | int textRotation() const; | 112 | int textRotation() const; | ||
113 | /** | ||||
114 | * \brief set the text rotation. | ||||
115 | * @param rotation - the text rotation in degrees. | ||||
116 | */ | ||||
58 | void setTextRotation(int rotation = 0); | 117 | void setTextRotation(int rotation = 0); | ||
59 | 118 | | |||
119 | /** | ||||
120 | * @return the type of the text area. This determines how it is styled. | ||||
121 | */ | ||||
60 | QString type() const; | 122 | QString type() const; | ||
123 | /** | ||||
124 | * \brief set the type of the text area. | ||||
125 | * @param type - this should be an entry from the availableTypes(), | ||||
126 | * it will change the way how the text is styled. The default is "speech". | ||||
127 | */ | ||||
61 | void setType(const QString& type = QStringLiteral("speech")); | 128 | void setType(const QString& type = QStringLiteral("speech")); | ||
62 | 129 | | |||
130 | /** | ||||
131 | * @return whether the text should use the 'inverted' colorscheme. | ||||
132 | */ | ||||
63 | bool inverted() const; | 133 | bool inverted() const; | ||
134 | /** | ||||
135 | * \brief set whether the text should use the inverted colorscheme. | ||||
136 | * @param inverted - whether to do so. | ||||
137 | */ | ||||
64 | void setInverted(bool inverted = false); | 138 | void setInverted(bool inverted = false); | ||
65 | 139 | | |||
140 | /** | ||||
141 | * @return whether to use the background color when overlaying the text. | ||||
142 | */ | ||||
66 | bool transparent() const; | 143 | bool transparent() const; | ||
144 | /** | ||||
145 | * \brief set whether to use the background color when overlaying the text. | ||||
146 | * @param transparent - false means to use the background color, true means | ||||
147 | * to have the textare background transparent. | ||||
148 | */ | ||||
67 | void setTransparent(bool transparent = false); | 149 | void setTransparent(bool transparent = false); | ||
68 | 150 | | |||
151 | /** | ||||
152 | * @returns a list of paragraphs. | ||||
153 | * | ||||
154 | * Contains allowed sub-elements: strong, emphasis, strikethrough | ||||
155 | * sub, sup, a (with mandatory href attribute only) | ||||
156 | * Can also contain deprecated sub-elements (superceded by...): code (type option code), | ||||
157 | * inverted (textarea option inverted) | ||||
158 | */ | ||||
69 | QStringList paragraphs() const; | 159 | QStringList paragraphs() const; | ||
70 | // Allowed sub-elements: strong, emphasis, strikethrough, sub, sup, a (with mandatory href attribute only) | 160 | /** | ||
71 | // Deprecated sub-elements (superceded by...): code (type option code), inverted (textarea option inverted) | 161 | * \brief set the list of paragraphs for this textarea. | ||
162 | * @param paragraphs - a list of paragraphs. Can contain sub-elements: | ||||
163 | * strong, emphasis, strikethrough, sub, sup, a (with mandatory href attribute only) | ||||
164 | */ | ||||
72 | void setParagraphs(const QStringList& paragraphs); | 165 | void setParagraphs(const QStringList& paragraphs); | ||
73 | private: | 166 | private: | ||
74 | class Private; | 167 | class Private; | ||
75 | std::unique_ptr<Private> d; | 168 | std::unique_ptr<Private> d; | ||
76 | }; | 169 | }; | ||
77 | } | 170 | } | ||
78 | 171 | | |||
79 | #endif//ACBFTEXTAREA_H | 172 | #endif//ACBFTEXTAREA_H |