Ticket #10256: animation.patch
File animation.patch, 26.8 KB (added by , 12 years ago) |
---|
-
mythtv/libs/libmythui/libmythui.pro
diff --git a/mythtv/libs/libmythui/libmythui.pro b/mythtv/libs/libmythui/libmythui.pro index 0f0a49b..64c68bb 100644
a b HEADERS += mythvirtualkeyboard.h mythuishape.h mythuiguidegrid.h 31 31 HEADERS += mythrender_base.h mythfontmanager.h mythuieditbar.h 32 32 HEADERS += mythdisplay.h mythuivideo.h mythudplistener.h 33 33 HEADERS += mythuiexp.h mythuisimpletext.h mythuistatetracker.h 34 HEADERS += mythanimation.h 34 35 35 36 SOURCES = mythmainwindow.cpp mythpainter.cpp mythimage.cpp mythrect.cpp 36 37 SOURCES += myththemebase.cpp mythpainter_qimage.cpp mythpainter_yuva.cpp … … SOURCES += mythvirtualkeyboard.cpp mythuishape.cpp mythuiguidegrid.cpp 49 50 SOURCES += mythfontmanager.cpp mythuieditbar.cpp 50 51 SOURCES += mythdisplay.cpp mythuivideo.cpp mythudplistener.cpp 51 52 SOURCES += mythuisimpletext.cpp mythuistatetracker.cpp 53 SOURCES += mythanimation.cpp 52 54 53 55 54 56 inc.path = $${PREFIX}/include/mythtv/libmythui/ … … inc.files += mythvirtualkeyboard.h mythuishape.h mythuiguidegrid.h 67 69 inc.files += mythuieditbar.h mythuifilebrowser.h mythuivideo.h 68 70 inc.files += mythuiexp.h mythuisimpletext.h mythuiactions.h 69 71 inc.files += mythuistatetracker.h 72 inc.files += mythanimation.h 70 73 71 74 INSTALLS += inc 72 75 -
new file mythtv/libs/libmythui/mythanimation.cpp
diff --git a/mythtv/libs/libmythui/mythanimation.cpp b/mythtv/libs/libmythui/mythanimation.cpp new file mode 100644 index 0000000..6e56050
- + 1 #include "mythanimation.h" 2 #include "mythuitype.h" 3 #include "mythmainwindow.h" 4 5 #include <QDomDocument> 6 7 MythAnimation::MythAnimation(MythUIType* parent, Type type) 8 : m_parent(parent), m_type(type), m_when(AboutToShow), 9 m_active(false), m_looped(false), m_reversible(false) 10 { 11 } 12 13 void MythAnimation::Activate(void) 14 { 15 m_active = true; 16 setCurrentTime(0); 17 } 18 19 MythAnimation::When MythAnimation::GetWhen(void) const 20 { 21 return m_when; 22 } 23 24 void MythAnimation::updateCurrentValue(const QVariant& value) 25 { 26 if (!m_active) 27 return; 28 29 m_value = value; 30 if (m_parent) 31 { 32 if (Position == m_type) 33 m_parent->SetPosition(m_value.toPoint()); 34 else if (Alpha == m_type) 35 m_parent->SetAlpha(m_value.toInt()); 36 else if (Size == m_type) 37 m_parent->SetSize(m_value.toSize()); 38 else if (Zoom == m_type) 39 m_parent->SetZoom(m_value.toFloat()); 40 else if (Angle == m_type) 41 m_parent->SetAngle(m_value.toFloat()); 42 } 43 } 44 45 void MythAnimation::CopyFrom(const MythAnimation* animation) 46 { 47 m_type = animation->m_type; 48 m_value = animation->m_value; 49 m_when = animation->m_when; 50 m_looped = animation->m_looped; 51 m_reversible = animation->m_reversible; 52 53 setStartValue(animation->startValue()); 54 setEndValue(animation->endValue()); 55 setEasingCurve(animation->easingCurve()); 56 setDuration(animation->duration()); 57 if (m_looped) 58 setLoopCount(-1); 59 } 60 61 void MythAnimation::incrementCurrentTime(void) 62 { 63 if (!m_active) 64 return; 65 66 int time = currentTime(); 67 if (direction() == Forward) 68 time += GetMythMainWindow()->GetDrawInterval(); 69 else 70 time -= GetMythMainWindow()->GetDrawInterval(); 71 72 setCurrentTime(time); 73 74 if (endValue() == currentValue()) 75 { 76 if (direction() == Forward) 77 { 78 if (m_reversible) 79 setDirection(Backward); 80 else if (!m_looped) 81 m_active = false; 82 } 83 } 84 else if (startValue() == currentValue()) 85 { 86 if (direction() == Backward) 87 { 88 if (m_reversible) 89 setDirection(Forward); 90 else if (!m_looped) 91 m_active = false; 92 } 93 } 94 } 95 96 void MythAnimation::setEasingCurve(const QString& curve) 97 { 98 if (curve == "Linear") setEasingCurve(QEasingCurve::Linear); 99 else if (curve == "InQuad") setEasingCurve(QEasingCurve::InQuad); 100 else if (curve == "OutQuad") setEasingCurve(QEasingCurve::OutQuad); 101 else if (curve == "InOutQuad") setEasingCurve(QEasingCurve::InOutQuad); 102 else if (curve == "OutInQuad") setEasingCurve(QEasingCurve::OutInQuad); 103 else if (curve == "InCubic") setEasingCurve(QEasingCurve::InCubic); 104 else if (curve == "OutCubic") setEasingCurve(QEasingCurve::OutCubic); 105 else if (curve == "InOutCubic") setEasingCurve(QEasingCurve::InOutCubic); 106 else if (curve == "OutInCubic") setEasingCurve(QEasingCurve::OutInCubic); 107 else if (curve == "InQuart") setEasingCurve(QEasingCurve::InQuart); 108 else if (curve == "OutQuart") setEasingCurve(QEasingCurve::OutQuart); 109 else if (curve == "InOutQuart") setEasingCurve(QEasingCurve::InOutQuart); 110 else if (curve == "OutInQuart") setEasingCurve(QEasingCurve::OutInQuart); 111 else if (curve == "InQuint") setEasingCurve(QEasingCurve::InQuint); 112 else if (curve == "OutQuint") setEasingCurve(QEasingCurve::OutQuint); 113 else if (curve == "InOutQuint") setEasingCurve(QEasingCurve::InOutQuint); 114 else if (curve == "OutInQuint") setEasingCurve(QEasingCurve::OutInQuint); 115 else if (curve == "InSine") setEasingCurve(QEasingCurve::InSine); 116 else if (curve == "OutSine") setEasingCurve(QEasingCurve::OutSine); 117 else if (curve == "InOutSine") setEasingCurve(QEasingCurve::InOutSine); 118 else if (curve == "OutInSine") setEasingCurve(QEasingCurve::OutInSine); 119 else if (curve == "InExpo") setEasingCurve(QEasingCurve::InExpo); 120 else if (curve == "OutExpo") setEasingCurve(QEasingCurve::OutExpo); 121 else if (curve == "InOutExpo") setEasingCurve(QEasingCurve::InOutExpo); 122 else if (curve == "OutInExpo") setEasingCurve(QEasingCurve::OutInExpo); 123 else if (curve == "InCirc") setEasingCurve(QEasingCurve::InCirc); 124 else if (curve == "OutCirc") setEasingCurve(QEasingCurve::OutCirc); 125 else if (curve == "InOutCirc") setEasingCurve(QEasingCurve::InOutCirc); 126 else if (curve == "OutInCirc") setEasingCurve(QEasingCurve::OutInCirc); 127 else if (curve == "InElastic") setEasingCurve(QEasingCurve::InElastic); 128 else if (curve == "OutElastic") setEasingCurve(QEasingCurve::OutElastic); 129 else if (curve == "InOutElastic") setEasingCurve(QEasingCurve::InOutElastic); 130 else if (curve == "OutInElastic") setEasingCurve(QEasingCurve::OutInElastic); 131 else if (curve == "InOutBack") setEasingCurve(QEasingCurve::InOutBack); 132 else if (curve == "OutInBack") setEasingCurve(QEasingCurve::OutInBack); 133 else if (curve == "InBounce") setEasingCurve(QEasingCurve::InBounce); 134 else if (curve == "OutBounce") setEasingCurve(QEasingCurve::OutBounce); 135 else if (curve == "InOutBounce") setEasingCurve(QEasingCurve::InOutBounce); 136 else if (curve == "OutInBounce") setEasingCurve(QEasingCurve::OutInBounce); 137 else if (curve == "InCurve") setEasingCurve(QEasingCurve::InCurve); 138 else if (curve == "OutCurve") setEasingCurve(QEasingCurve::OutCurve); 139 else if (curve == "SineCurve") setEasingCurve(QEasingCurve::SineCurve); 140 else if (curve == "CosineCurve") setEasingCurve(QEasingCurve::CosineCurve); 141 } 142 143 void MythAnimation::setEasingCurve(QEasingCurve curve) 144 { 145 QVariantAnimation::setEasingCurve(curve); 146 } 147 148 bool MythAnimation::ParseElement(const QDomElement& element) 149 { 150 bool result = true; 151 QVariant startValue; 152 QVariant endValue; 153 154 QString when = element.attribute("when", "AboutToShow"); 155 if (when == "AboutToShow") 156 m_when = AboutToShow; 157 else if (when == "AboutToHide") 158 m_when = AboutToHide; 159 160 m_looped = parseBool(element.attribute("looped", "false")); 161 m_reversible = parseBool(element.attribute("reversible", "false")); 162 163 if (element.attribute("type", "") == "alpha") 164 { 165 parseAlpha(element, startValue, endValue); 166 } 167 else if (element.attribute("type", "") == "position") 168 { 169 parsePosition(element, startValue, endValue); 170 } 171 else if (element.attribute("type", "") == "size") 172 { 173 parseSize(element, startValue, endValue); 174 } 175 else if (element.attribute("type", "") == "zoom") 176 { 177 parseZoom(element, startValue, endValue); 178 } 179 else if (element.attribute("type", "") == "angle") 180 { 181 parseAngle(element, startValue, endValue); 182 } 183 else 184 result = false; 185 186 if (result) 187 { 188 setStartValue(startValue); 189 setEndValue(endValue); 190 setDuration(element.attribute("duration", "500").toInt()); 191 setEasingCurve(element.attribute("easingcurve")); 192 if (m_looped) 193 setLoopCount(-1); 194 } 195 196 return result; 197 } 198 199 void MythAnimation::parseAlpha(const QDomElement& element, QVariant& startValue, QVariant& endValue) 200 { 201 m_type = Alpha; 202 startValue = element.attribute("start", "0").toInt(); 203 endValue = element.attribute("end", "0").toInt(); 204 } 205 206 void MythAnimation::parsePosition(const QDomElement& element, QVariant& startValue, QVariant& endValue) 207 { 208 m_type = Position; 209 210 MythPoint start = parsePoint(element.attribute("start", "0,0"), false); 211 MythPoint startN = parsePoint(element.attribute("start", "0,0")); 212 MythPoint end = parsePoint(element.attribute("end", "0,0"), false); 213 MythPoint endN = parsePoint(element.attribute("end", "0,0")); 214 215 if (start.x() == -1) 216 startN.setX(m_parent->GetArea().x()); 217 218 if (start.y() == -1) 219 startN.setY(m_parent->GetArea().y()); 220 221 if (end.x() == -1) 222 endN.setX(m_parent->GetArea().x()); 223 224 if (end.y() == -1) 225 endN.setY(m_parent->GetArea().y()); 226 227 startN.CalculatePoint(m_parent->GetArea()); 228 endN.CalculatePoint(m_parent->GetArea()); 229 230 startValue = startN.toQPoint(); 231 endValue = endN.toQPoint(); 232 } 233 234 void MythAnimation::parseSize(const QDomElement& element, QVariant& startValue, QVariant& endValue) 235 { 236 m_type = Size; 237 startValue = XMLParseBase::parseSize(element.attribute("start", "0,0")); 238 endValue = XMLParseBase::parseSize(element.attribute("end", "0,0")); 239 } 240 241 void MythAnimation::parseZoom(const QDomElement& element, QVariant& startValue, QVariant& endValue) 242 { 243 m_type = Zoom; 244 startValue = element.attribute("start", "0").toFloat(); 245 endValue = element.attribute("end", "0").toFloat(); 246 } 247 248 void MythAnimation::parseAngle(const QDomElement& element, QVariant& startValue, QVariant& endValue) 249 { 250 m_type = Angle; 251 startValue = element.attribute("start", "0").toFloat(); 252 endValue = element.attribute("end", "0").toFloat(); 253 } -
new file mythtv/libs/libmythui/mythanimation.h
diff --git a/mythtv/libs/libmythui/mythanimation.h b/mythtv/libs/libmythui/mythanimation.h new file mode 100644 index 0000000..a6040cb
- + 1 #ifndef MYTHANIMATION_H_ 2 #define MYTHANIMATION_H_ 3 4 #include "xmlparsebase.h" 5 #include <QVariantAnimation> 6 7 class MythUIType; 8 9 struct Effects 10 { 11 int alpha; 12 float zoom; 13 float angle; 14 Effects(int alpha_ = 255, float zoom_ = 1.0, float angle_ = 0.0) : alpha(alpha_), zoom(zoom_), angle(angle_) {} 15 }; 16 17 class MythAnimation : public QVariantAnimation, XMLParseBase 18 { 19 public: 20 enum Type {Alpha, Position, Size, Zoom, Angle}; 21 enum When {AboutToHide, AboutToShow}; 22 23 MythAnimation(MythUIType* parent = NULL, Type type = Position); 24 25 void Activate(void); 26 void CopyFrom(const MythAnimation* animation); 27 bool ParseElement(const QDomElement& element); 28 When GetWhen(void) const; 29 30 QVariant value() const { return m_value; } 31 32 void updateCurrentValue(const QVariant& value); 33 34 void incrementCurrentTime(void); 35 36 void setEasingCurve(const QString& curve); 37 void setEasingCurve(QEasingCurve curve); 38 39 private: 40 void parseAlpha(const QDomElement& element, QVariant& startValue, QVariant& endValue); 41 void parsePosition(const QDomElement& element, QVariant& startValue, QVariant& endValue); 42 void parseSize(const QDomElement& element, QVariant& startValue, QVariant& endValue); 43 void parseZoom(const QDomElement& element, QVariant& startValue, QVariant& endValue); 44 void parseAngle(const QDomElement& element, QVariant& startValue, QVariant& endValue); 45 46 MythUIType* m_parent; 47 Type m_type; 48 When m_when; 49 QVariant m_value; 50 bool m_active; 51 bool m_looped; 52 bool m_reversible; 53 }; 54 55 #endif -
mythtv/libs/libmythui/mythmainwindow.cpp
diff --git a/mythtv/libs/libmythui/mythmainwindow.cpp b/mythtv/libs/libmythui/mythmainwindow.cpp index a01931f..884f892 100644
a b class MythMainWindowPrivate 158 158 159 159 sysEventHandler(NULL), 160 160 161 drawInterval(1000 / 70), 161 162 drawTimer(NULL), 162 163 mainStack(NULL), 163 164 … … class MythMainWindowPrivate 235 236 236 237 QObject *sysEventHandler; 237 238 239 int drawInterval; 238 240 MythSignalingTimer *drawTimer; 239 241 QVector<MythScreenStack *> stackList; 240 242 MythScreenStack *mainStack; … … MythMainWindow::MythMainWindow(const bool useDB) 479 481 connect(d->hideMouseTimer, SIGNAL(timeout()), SLOT(HideMouseTimeout())); 480 482 481 483 d->drawTimer = new MythSignalingTimer(this, SLOT(animate())); 482 d->drawTimer->start( 1000 / 70);484 d->drawTimer->start(d->drawInterval); 483 485 484 486 d->AllowInput = true; 485 487 … … void MythMainWindow::SetUIScreenRect(QRect &rect) 2456 2458 d->uiScreenRect = rect; 2457 2459 } 2458 2460 2461 int MythMainWindow::GetDrawInterval() const 2462 { 2463 return d->drawInterval; 2464 } 2465 2459 2466 void MythMainWindow::StartLIRC(void) 2460 2467 { 2461 2468 #ifdef USE_LIRC -
mythtv/libs/libmythui/mythmainwindow.h
diff --git a/mythtv/libs/libmythui/mythmainwindow.h b/mythtv/libs/libmythui/mythmainwindow.h index 388ca3f..c1702b6 100644
a b class MUI_PUBLIC MythMainWindow : public QWidget 105 105 QRect GetUIScreenRect(); 106 106 void SetUIScreenRect(QRect &rect); 107 107 108 int GetDrawInterval() const; 108 109 int NormalizeFontSize(int pointSize); 109 110 MythRect NormRect(const MythRect &rect); 110 111 QPoint NormPoint(const QPoint &point); -
mythtv/libs/libmythui/mythpainter.h
diff --git a/mythtv/libs/libmythui/mythpainter.h b/mythtv/libs/libmythui/mythpainter.h index 1625aa2..70bcc48 100644
a b class QColor; 21 21 22 22 class MythFontProperties; 23 23 class MythImage; 24 struct Effects; 24 25 25 26 typedef QVector<QTextLayout *> LayoutVector; 26 27 typedef QVector<QTextLayout::FormatRange> FormatVector; … … class MUI_PUBLIC MythPainter 67 68 virtual void DrawEllipse(const QRect &area, const QBrush &fillBrush, 68 69 const QPen &linePen, int alpha); 69 70 71 virtual void SetTransform(const Effects &zoom, QPointF center = QPointF()) { } 72 virtual void RestoreTransform(void) { } 73 70 74 MythImage *GetFormatImage(); 71 75 void DeleteFormatImage(MythImage *im); 72 76 -
mythtv/libs/libmythui/mythpainter_ogl.cpp
diff --git a/mythtv/libs/libmythui/mythpainter_ogl.cpp b/mythtv/libs/libmythui/mythpainter_ogl.cpp index 2dd047c..85e17fa 100644
a b void MythOpenGLPainter::DeleteFormatImagePriv(MythImage *im) 227 227 m_ImageExpireList.remove(im); 228 228 } 229 229 } 230 231 void MythOpenGLPainter::SetTransform(const Effects &fx, QPointF center) 232 { 233 if (realRender) 234 realRender->SetTransform(fx, center); 235 } 236 237 void MythOpenGLPainter::RestoreTransform(void) 238 { 239 if (realRender) 240 realRender->RestoreTransform(); 241 } -
mythtv/libs/libmythui/mythpainter_ogl.h
diff --git a/mythtv/libs/libmythui/mythpainter_ogl.h b/mythtv/libs/libmythui/mythpainter_ogl.h index 34fffb0..600c930 100644
a b class MUI_PUBLIC MythOpenGLPainter : public MythPainter 34 34 const QBrush &fillBrush, const QPen &linePen, 35 35 int alpha); 36 36 37 virtual void SetTransform(const Effects &fx, QPointF center = QPointF()); 38 virtual void RestoreTransform(void); 39 37 40 protected: 38 41 virtual MythImage* GetFormatImagePriv(void) { return new MythImage(this); } 39 42 virtual void DeleteFormatImagePriv(MythImage *im); -
mythtv/libs/libmythui/mythrender_opengl.cpp
diff --git a/mythtv/libs/libmythui/mythrender_opengl.cpp b/mythtv/libs/libmythui/mythrender_opengl.cpp index b7bf454..1d463a3 100644
a b 1 1 #include <algorithm> 2 2 using namespace std; 3 3 4 #include "mythanimation.h" 4 5 #include "mythlogging.h" 5 6 #include "mythrender_opengl.h" 6 7 #include "mythxdisplay.h" … … void MythRenderOpenGL::SetFence(void) 258 259 doneCurrent(); 259 260 } 260 261 262 void MythRenderOpenGL::SetTransform(const Effects &fx, QPointF center) 263 { 264 makeCurrent(); 265 glPushMatrix(); 266 glTranslatef(center.x(), center.y(), 0.0); 267 glScalef(fx.zoom, fx.zoom, 1.0); 268 glRotatef(fx.angle, 0, 0, 1); 269 glTranslatef(-center.x(), -center.y(), 0.0); 270 doneCurrent(); 271 } 272 273 void MythRenderOpenGL::RestoreTransform(void) 274 { 275 makeCurrent(); 276 glPopMatrix(); 277 doneCurrent(); 278 } 279 261 280 void* MythRenderOpenGL::GetTextureBuffer(uint tex, bool create_buffer) 262 281 { 263 282 if (!m_textures.contains(tex)) -
mythtv/libs/libmythui/mythrender_opengl.h
diff --git a/mythtv/libs/libmythui/mythrender_opengl.h b/mythtv/libs/libmythui/mythrender_opengl.h index 05f9384..adc0f8e 100644
a b 33 33 #include "mythrender_base.h" 34 34 #include "mythrender_opengl_defs.h" 35 35 36 struct Effects; 37 36 38 typedef enum 37 39 { 38 40 kGLFeatNone = 0x0000, … … class MUI_PUBLIC MythRenderOpenGL : public QGLContext, public MythRender 127 129 virtual void SetColor(int r, int g, int b, int a) { } 128 130 void SetBackground(int r, int g, int b, int a); 129 131 void SetFence(void); 132 void SetTransform(const Effects &fx, QPointF center = QPointF()); 133 void RestoreTransform(void); 130 134 131 135 void* GetTextureBuffer(uint tex, bool create_buffer = true); 132 136 void UpdateTexture(uint tex, void *buf); -
mythtv/libs/libmythui/mythscreentype.cpp
diff --git a/mythtv/libs/libmythui/mythscreentype.cpp b/mythtv/libs/libmythui/mythscreentype.cpp index 0c495a1..ca05ecf 100644
a b 15 15 #include "mythprogressdialog.h" 16 16 #include "mythuigroup.h" 17 17 #include "mythlogging.h" 18 #include "mythanimation.h" 18 19 19 20 QEvent::Type ScreenLoadCompletionEvent::kEventType = 20 21 (QEvent::Type) QEvent::registerEventType(); … … void MythScreenType::aboutToHide(void) 237 238 GetMythMainWindow()->GetPaintWindow()->setMask(m_SavedMask); 238 239 } 239 240 } 241 242 ActivateAnimations(MythAnimation::AboutToHide); 240 243 } 241 244 242 245 void MythScreenType::aboutToShow(void) … … void MythScreenType::aboutToShow(void) 253 256 GetMythMainWindow()->GetPaintWindow()->setMask(region); 254 257 } 255 258 } 259 260 ActivateAnimations(MythAnimation::AboutToShow); 256 261 } 257 262 258 263 bool MythScreenType::IsDeleting(void) const … … bool MythScreenType::ParseElement( 546 551 } 547 552 else 548 553 { 549 return false;554 return MythUIType::ParseElement(filename, element, showWarnings); 550 555 } 551 556 552 557 return true; -
mythtv/libs/libmythui/mythuitype.cpp
diff --git a/mythtv/libs/libmythui/mythuitype.cpp b/mythtv/libs/libmythui/mythuitype.cpp index c6ce242..45ca7d6 100644
a b 11 11 #include "mythlogging.h" 12 12 13 13 // MythUI headers 14 #include "mythanimation.h" 14 15 #include "mythgesture.h" 15 16 #include "mythimage.h" 16 17 #include "mythpainter.h" … … MythUIType::MythUIType(QObject *parent, const QString &name) 41 42 m_Area = MythRect(0, 0, 0, 0); 42 43 m_MinArea = MythRect(0, 0, 0, 0); 43 44 m_NeedsRedraw = false; 44 m_Alpha = 255;45 45 m_AlphaChangeMode = m_AlphaChange = m_AlphaMin = 0; 46 46 m_AlphaMax = 255; 47 47 m_Moving = false; … … MythUIType::MythUIType(QObject *parent, const QString &name) 71 71 MythUIType::~MythUIType() 72 72 { 73 73 delete m_Fonts; 74 qDeleteAll(m_animations); 74 75 } 75 76 76 77 /** … … MythUIType *MythUIType::GetChildAt(const QPoint &p, bool recursive, 272 273 return NULL; 273 274 } 274 275 276 void MythUIType::ActivateAnimations(MythAnimation::When when) 277 { 278 foreach (MythAnimation* animation, m_animations) 279 if (animation->GetWhen() == when) 280 animation->Activate(); 281 282 foreach (MythUIType* uiType, m_ChildrenList) 283 uiType->ActivateAnimations(when); 284 } 285 275 286 bool MythUIType::NeedsRedraw(void) const 276 287 { 277 288 return m_NeedsRedraw; … … void MythUIType::HandleAlphaPulse(void) 402 413 if (m_AlphaChangeMode == 0) 403 414 return; 404 415 405 m_ Alpha += m_AlphaChange;416 m_Effects.alpha += m_AlphaChange; 406 417 407 if (m_ Alpha > m_AlphaMax)408 m_ Alpha = m_AlphaMax;418 if (m_Effects.alpha > m_AlphaMax) 419 m_Effects.alpha = m_AlphaMax; 409 420 410 if (m_ Alpha < m_AlphaMin)411 m_ Alpha = m_AlphaMin;421 if (m_Effects.alpha < m_AlphaMin) 422 m_Effects.alpha = m_AlphaMin; 412 423 413 424 // Reached limits so change direction 414 if (m_ Alpha == m_AlphaMax || m_Alpha == m_AlphaMin)425 if (m_Effects.alpha == m_AlphaMax || m_Effects.alpha == m_AlphaMin) 415 426 { 416 427 if (m_AlphaChangeMode == 2) 417 428 { … … void MythUIType::Pulse(void) 441 452 HandleMovementPulse(); 442 453 HandleAlphaPulse(); 443 454 455 QList<MythAnimation*>::Iterator i; 456 for (i = m_animations.begin(); i != m_animations.end(); ++i) 457 (*i)->incrementCurrentTime(); 458 444 459 QList<MythUIType *>::Iterator it; 445 460 446 461 for (it = m_ChildrenList.begin(); it != m_ChildrenList.end(); ++it) … … void MythUIType::Pulse(void) 449 464 450 465 int MythUIType::CalcAlpha(int alphamod) 451 466 { 452 return (int)(m_ Alpha * (alphamod / 255.0));467 return (int)(m_Effects.alpha * (alphamod / 255.0)); 453 468 } 454 469 455 470 void MythUIType::DrawSelf(MythPainter *, int, int, int, QRect) … … void MythUIType::Draw(MythPainter *p, int xoffset, int yoffset, int alphaMod, 470 485 if (!realArea.intersects(clipRect)) 471 486 return; 472 487 488 QPointF center(xoffset + m_Area.x() + m_Area.width() / 2.0, 489 yoffset + m_Area.y() + m_Area.height() / 2.0); 490 p->SetTransform(m_Effects, center); 491 473 492 DrawSelf(p, xoffset, yoffset, alphaMod, clipRect); 474 493 475 494 QList<MythUIType *>::Iterator it; … … void MythUIType::Draw(MythPainter *p, int xoffset, int yoffset, int alphaMod, 494 513 p->DrawText(realArea, objectName(), 0, font, 255, realArea); 495 514 } 496 515 } 516 517 p->RestoreTransform(); 497 518 } 498 519 499 520 void MythUIType::SetPosition(int x, int y) … … void MythUIType::AdjustAlpha(int mode, int alphachange, int minalpha, 894 915 m_AlphaMin = minalpha; 895 916 m_AlphaMax = maxalpha; 896 917 897 if (m_ Alpha > m_AlphaMax)898 m_ Alpha = m_AlphaMax;918 if (m_Effects.alpha > m_AlphaMax) 919 m_Effects.alpha = m_AlphaMax; 899 920 900 if (m_ Alpha < m_AlphaMin)901 m_ Alpha = m_AlphaMin;921 if (m_Effects.alpha < m_AlphaMin) 922 m_Effects.alpha = m_AlphaMin; 902 923 } 903 924 904 925 void MythUIType::SetAlpha(int newalpha) 905 926 { 906 if (m_ Alpha == newalpha)927 if (m_Effects.alpha == newalpha) 907 928 return; 908 929 909 m_ Alpha = newalpha;930 m_Effects.alpha = newalpha; 910 931 SetRedraw(); 911 932 } 912 933 913 934 int MythUIType::GetAlpha(void) const 914 935 { 915 return m_Alpha; 936 return m_Effects.alpha; 937 } 938 939 void MythUIType::SetZoom(float newzoom) 940 { 941 m_Effects.zoom = newzoom; 942 SetRedraw(); 943 } 944 945 float MythUIType::GetZoom(void) const 946 { 947 return m_Effects.zoom; 948 } 949 950 void MythUIType::SetAngle(float newangle) 951 { 952 m_Effects.angle = newangle; 953 SetRedraw(); 954 } 955 956 float MythUIType::GetAngle(void) const 957 { 958 return m_Effects.angle; 916 959 } 917 960 918 961 /** \brief Key event handler … … void MythUIType::CopyFrom(MythUIType *base) 1052 1095 m_MinSize = base->m_MinSize; 1053 1096 m_Vanish = base->m_Vanish; 1054 1097 m_Vanished = false; 1055 m_ Alpha = base->m_Alpha;1098 m_Effects = base->m_Effects; 1056 1099 m_AlphaChangeMode = base->m_AlphaChangeMode; 1057 1100 m_AlphaChange = base->m_AlphaChange; 1058 1101 m_AlphaMin = base->m_AlphaMin; … … void MythUIType::CopyFrom(MythUIType *base) 1063 1106 m_XYSpeed = base->m_XYSpeed; 1064 1107 m_deferload = base->m_deferload; 1065 1108 1109 QList<MythAnimation*>::Iterator i; 1110 for (i = base->m_animations.begin(); i != base->m_animations.end(); ++i) 1111 { 1112 MythAnimation* animation = new MythAnimation(this); 1113 animation->CopyFrom(*i); 1114 m_animations.push_back(animation); 1115 } 1116 1066 1117 QList<MythUIType *>::Iterator it; 1067 1118 1068 1119 for (it = base->m_ChildrenList.begin(); it != base->m_ChildrenList.end(); … … bool MythUIType::ParseElement( 1116 1167 } 1117 1168 else if (element.tagName() == "alpha") 1118 1169 { 1119 m_ Alpha = getFirstText(element).toInt();1170 m_Effects.alpha = getFirstText(element).toInt(); 1120 1171 m_AlphaChangeMode = 0; 1121 1172 } 1122 1173 else if (element.tagName() == "alphapulse") 1123 1174 { 1124 1175 m_AlphaChangeMode = 2; 1125 1176 m_AlphaMin = element.attribute("min", "0").toInt(); 1126 m_ Alpha = m_AlphaMax = element.attribute("max", "255").toInt();1177 m_Effects.alpha = m_AlphaMax = element.attribute("max", "255").toInt(); 1127 1178 1128 1179 if (m_AlphaMax > 255) 1129 m_ Alpha = m_AlphaMax = 255;1180 m_Effects.alpha = m_AlphaMax = 255; 1130 1181 1131 1182 if (m_AlphaMin < 0) 1132 1183 m_AlphaMin = 0; … … bool MythUIType::ParseElement( 1146 1197 { 1147 1198 m_helptext = getFirstText(element); 1148 1199 } 1200 else if (element.tagName() == "animation") 1201 { 1202 MythAnimation* animation = new MythAnimation(this); 1203 if (animation->ParseElement(element)) 1204 m_animations.push_back(animation); 1205 else 1206 delete animation; 1207 } 1149 1208 else 1150 1209 return false; 1151 1210 -
mythtv/libs/libmythui/mythuitype.h
diff --git a/mythtv/libs/libmythui/mythuitype.h b/mythtv/libs/libmythui/mythuitype.h index 99ce423..f24a982 100644
a b 9 9 #include <QColor> 10 10 11 11 #include "xmlparsebase.h" 12 #include "mythanimation.h" 12 13 #include "mythrect.h" 13 14 #include "mythgesture.h" 14 15 #include "mythmedia.h" … … class MUI_PUBLIC MythUIType : public QObject, public XMLParseBase 98 99 bool MoveToTop(void); 99 100 bool MoveChildToTop(MythUIType *child); 100 101 102 void ActivateAnimations(MythAnimation::When when); 103 101 104 // Called each draw pulse. Will redraw automatically if dirty afterwards 102 105 virtual void Pulse(void); 103 106 … … class MUI_PUBLIC MythUIType : public QObject, public XMLParseBase 153 156 virtual MythPainter *GetPainter(void); 154 157 void SetPainter(MythPainter *painter) { m_Painter = painter; } 155 158 159 void SetZoom(float zoom); 160 float GetZoom(void) const; 161 162 void SetAngle(float angle); 163 float GetAngle(void) const; 164 156 165 protected: 157 166 virtual void customEvent(QEvent *); 158 167 … … class MUI_PUBLIC MythUIType : public QObject, public XMLParseBase 217 226 QRegion m_DirtyRegion; 218 227 bool m_NeedsRedraw; 219 228 220 int m_Alpha; 229 Effects m_Effects; 230 221 231 int m_AlphaChangeMode; // 0 - none, 1 - once, 2 - cycle 222 232 int m_AlphaChange; 223 233 int m_AlphaMin; … … class MUI_PUBLIC MythUIType : public QObject, public XMLParseBase 232 242 MythUIType *m_Parent; 233 243 MythPainter *m_Painter; 234 244 245 QList<MythAnimation*> m_animations; 235 246 QString m_helptext; 236 247 237 248 bool m_deferload;