1 /* This file is part of the KDE project 2 * 3 * Copyright (C) 2006-2007 Koos Vriezen <koos.vriezen@gmail.com> 4 * 5 * This library is free software; you can redistribute it and/or 6 * modify it under the terms of the GNU Library General Public 7 * License as published by the Free Software Foundation; either 8 * version 2 of the License, or (at your option) any later version. 9 * 10 * This library is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 * Library General Public License for more details. 14 * 15 * You should have received a copy of the GNU Library General Public License 16 * along with this library; see the file COPYING.LIB. If not, write to 17 * the Free Software Foundation, Inc., 51 Franklin Steet, Fifth Floor, 18 * Boston, MA 02110-1301, USA. 19 */ 20 21 #ifndef _KMPLAYER_RP_H_ 22 #define _KMPLAYER_RP_H_ 23 24 #include <qobject.h> 25 #include <qstring.h> 26 27 #include "kmplayerplaylist.h" 28 #include "surface.h" 29 30 namespace KMPlayer { 31 32 /** 33 * RealPix support classes 34 */ 35 namespace RP { 36 37 const short id_node_imfl = 150; 38 const short id_node_head = 151; 39 const short id_node_image = 152; 40 const short id_node_crossfade = 153; 41 const short id_node_fill = 154; 42 const short id_node_wipe = 155; 43 const short id_node_fadein = 156; 44 const short id_node_fadeout = 157; 45 const short id_node_viewchange = 158; 46 const short id_node_animate = 159; 47 const short id_node_first = id_node_imfl; 48 const short id_node_last = 160; 49 50 class KMPLAYER_NO_EXPORT Imfl : public Mrl { 51 public: 52 Imfl (NodePtr & d); 53 ~Imfl (); nodeName()54 KDE_NO_EXPORT virtual const char * nodeName () const { return "imfl"; } 55 virtual Node *childFromTag (const QString & tag); 56 virtual void closed (); 57 virtual void defer (); // start loading the images if not yet done 58 virtual void activate (); // start timings, handle paint events 59 virtual void finish (); // end the timings 60 virtual void deactivate (); // stop handling paint events playType()61 KDE_NO_EXPORT virtual PlayType playType () { return play_type_image; } 62 virtual void message (MessageType msg, void *content=NULL); 63 virtual void accept (Visitor *); 64 Surface *surface (); 65 void repaint (); // called whenever something changes on image 66 Fit fit; // how to layout images 67 unsigned int duration; // cached attributes of head 68 Posting *duration_timer; 69 SurfacePtrW rp_surface; 70 int needs_scene_img; 71 }; 72 73 class KMPLAYER_NO_EXPORT TimingsBase : public Element { 74 public: 75 TimingsBase (NodePtr & d, const short id); ~TimingsBase()76 KDE_NO_CDTOR_EXPORT ~TimingsBase () {} 77 virtual void activate (); // start the 'start_timer' 78 virtual void begin (); // start_timer has expired 79 virtual void finish (); // ?duration_timer has expired? 80 virtual void deactivate (); // disabled 81 virtual void message (MessageType msg, void *content=NULL); 82 int progress; 83 Single x, y, w, h; 84 Single srcx, srcy, srcw, srch; 85 NodePtrW target; 86 protected: 87 void update (int percentage); 88 void cancelTimers (); 89 unsigned int start, duration; 90 int steps, curr_step; 91 Posting *start_timer; 92 Posting *duration_timer; 93 Posting *update_timer; 94 ConnectionLink document_postponed; 95 }; 96 97 class KMPLAYER_NO_EXPORT Crossfade : public TimingsBase { 98 public: Crossfade(NodePtr & d)99 KDE_NO_CDTOR_EXPORT Crossfade (NodePtr & d) 100 : TimingsBase (d, id_node_crossfade) {} ~Crossfade()101 KDE_NO_CDTOR_EXPORT ~Crossfade () {} nodeName()102 KDE_NO_EXPORT virtual const char * nodeName () const { return "crossfade"; } 103 virtual void activate (); 104 virtual void begin (); 105 virtual void accept (Visitor *); 106 }; 107 108 class KMPLAYER_NO_EXPORT Fadein : public TimingsBase { 109 public: Fadein(NodePtr & d)110 KDE_NO_CDTOR_EXPORT Fadein (NodePtr & d) : TimingsBase(d, id_node_fadein) {} ~Fadein()111 KDE_NO_CDTOR_EXPORT ~Fadein () {} nodeName()112 KDE_NO_EXPORT virtual const char * nodeName () const { return "fadein"; } 113 virtual void activate (); 114 virtual void begin (); 115 virtual void accept (Visitor *); 116 unsigned int from_color; 117 }; 118 119 class KMPLAYER_NO_EXPORT Fadeout : public TimingsBase { 120 public: Fadeout(NodePtr & d)121 KDE_NO_CDTOR_EXPORT Fadeout(NodePtr &d) : TimingsBase(d, id_node_fadeout) {} ~Fadeout()122 KDE_NO_CDTOR_EXPORT ~Fadeout () {} nodeName()123 KDE_NO_EXPORT virtual const char * nodeName () const { return "fadeout"; } 124 virtual void activate (); 125 virtual void begin (); 126 virtual void accept (Visitor *); 127 unsigned int to_color; 128 }; 129 130 class KMPLAYER_NO_EXPORT Fill : public TimingsBase { 131 public: Fill(NodePtr & d)132 KDE_NO_CDTOR_EXPORT Fill (NodePtr & d) : TimingsBase (d, id_node_fill) {} ~Fill()133 KDE_NO_CDTOR_EXPORT ~Fill () {} nodeName()134 KDE_NO_EXPORT virtual const char * nodeName () const { return "fill"; } 135 virtual void activate (); 136 virtual void begin (); fillColor()137 unsigned int fillColor () const { return color; } 138 virtual void accept (Visitor *); 139 unsigned int color; 140 }; 141 142 class KMPLAYER_NO_EXPORT Wipe : public TimingsBase { 143 public: Wipe(NodePtr & d)144 KDE_NO_CDTOR_EXPORT Wipe (NodePtr & d) : TimingsBase (d, id_node_wipe) {} ~Wipe()145 KDE_NO_CDTOR_EXPORT ~Wipe () {} nodeName()146 KDE_NO_EXPORT virtual const char * nodeName () const { return "wipe"; } 147 virtual void activate (); 148 virtual void begin (); 149 virtual void accept (Visitor *); 150 enum { dir_right, dir_left, dir_up, dir_down } direction; 151 }; 152 153 class KMPLAYER_NO_EXPORT ViewChange : public TimingsBase { 154 public: ViewChange(NodePtr & d)155 KDE_NO_CDTOR_EXPORT ViewChange (NodePtr & d) 156 : TimingsBase (d, id_node_viewchange) {} ~ViewChange()157 KDE_NO_CDTOR_EXPORT ~ViewChange () {} nodeName()158 KDE_NO_EXPORT virtual const char * nodeName() const { return "viewchange"; } 159 virtual void activate (); 160 virtual void begin (); 161 virtual void finish (); 162 virtual void accept (Visitor *); 163 }; 164 165 class KMPLAYER_NO_EXPORT Image : public Mrl { 166 PostponePtr postpone_lock; 167 public: 168 Image (NodePtr & d); 169 ~Image (); nodeName()170 KDE_NO_EXPORT virtual const char * nodeName () const { return "image"; } 171 virtual void activate (); 172 virtual void begin (); 173 virtual void deactivate (); 174 virtual void closed (); 175 virtual void message (MessageType msg, void *content=NULL); 176 bool isReady (bool postpone_if_not = false); // is downloading ready 177 Surface *surface (); 178 SurfacePtrW img_surface; 179 protected: 180 void dataArrived (); 181 }; 182 183 } // RP namespace 184 185 } // KMPlayer namespace 186 187 #endif //_KMPLAYER_RP_H_ 188 189