File indexing completed on 2024-03-24 04:56:53
0001 /* 0002 SPDX-FileCopyrightText: 2006-2007 Koos Vriezen <koos.vriezen@gmail.com> 0003 0004 SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 #ifndef _KMPLAYER_RP_H_ 0008 #define _KMPLAYER_RP_H_ 0009 0010 #include <QObject> 0011 #include <QString> 0012 0013 #include "kmplayerplaylist.h" 0014 #include "surface.h" 0015 0016 namespace KMPlayer { 0017 0018 /** 0019 * RealPix support classes 0020 */ 0021 namespace RP { 0022 0023 const short id_node_imfl = 150; 0024 const short id_node_head = 151; 0025 const short id_node_image = 152; 0026 const short id_node_crossfade = 153; 0027 const short id_node_fill = 154; 0028 const short id_node_wipe = 155; 0029 const short id_node_fadein = 156; 0030 const short id_node_fadeout = 157; 0031 const short id_node_viewchange = 158; 0032 const short id_node_animate = 159; 0033 const short id_node_first = id_node_imfl; 0034 const short id_node_last = 160; 0035 0036 class Imfl : public Mrl 0037 { 0038 public: 0039 Imfl (NodePtr & d); 0040 ~Imfl () override; 0041 const char * nodeName () const override { return "imfl"; } 0042 Node *childFromTag (const QString & tag) override; 0043 void closed () override; 0044 void defer () override; // start loading the images if not yet done 0045 void activate () override; // start timings, handle paint events 0046 void finish () override; // end the timings 0047 void deactivate () override; // stop handling paint events 0048 PlayType playType () override { return play_type_image; } 0049 void message (MessageType msg, void *content=nullptr) override; 0050 void accept (Visitor *) override; 0051 Surface *surface (); 0052 void repaint (); // called whenever something changes on image 0053 Fit fit; // how to layout images 0054 unsigned int duration; // cached attributes of head 0055 Posting *duration_timer; 0056 SurfacePtrW rp_surface; 0057 int needs_scene_img; 0058 }; 0059 0060 class TimingsBase : public Element 0061 { 0062 public: 0063 TimingsBase (NodePtr & d, const short id); 0064 ~TimingsBase () override {} 0065 void activate () override; // start the 'start_timer' 0066 void begin () override; // start_timer has expired 0067 void finish () override; // ?duration_timer has expired? 0068 void deactivate () override; // disabled 0069 void message (MessageType msg, void *content=nullptr) override; 0070 int progress; 0071 Single x, y, w, h; 0072 Single srcx, srcy, srcw, srch; 0073 NodePtrW target; 0074 protected: 0075 void update (int percentage); 0076 void cancelTimers (); 0077 unsigned int start, duration; 0078 int steps, curr_step; 0079 Posting *start_timer; 0080 Posting *duration_timer; 0081 Posting *update_timer; 0082 ConnectionLink document_postponed; 0083 }; 0084 0085 class Crossfade : public TimingsBase 0086 { 0087 public: 0088 Crossfade (NodePtr & d) 0089 : TimingsBase (d, id_node_crossfade) {} 0090 ~Crossfade () override {} 0091 const char * nodeName () const override { return "crossfade"; } 0092 void activate () override; 0093 void begin () override; 0094 void accept (Visitor *) override; 0095 }; 0096 0097 class Fadein : public TimingsBase 0098 { 0099 public: 0100 Fadein (NodePtr & d) : TimingsBase(d, id_node_fadein) {} 0101 ~Fadein () override {} 0102 const char * nodeName () const override { return "fadein"; } 0103 void activate () override; 0104 void begin () override; 0105 void accept (Visitor *) override; 0106 unsigned int from_color; 0107 }; 0108 0109 class Fadeout : public TimingsBase 0110 { 0111 public: 0112 Fadeout(NodePtr &d) : TimingsBase(d, id_node_fadeout) {} 0113 ~Fadeout () override {} 0114 const char * nodeName () const override { return "fadeout"; } 0115 void activate () override; 0116 void begin () override; 0117 void accept (Visitor *) override; 0118 unsigned int to_color; 0119 }; 0120 0121 class Fill : public TimingsBase 0122 { 0123 public: 0124 Fill (NodePtr & d) : TimingsBase (d, id_node_fill) {} 0125 ~Fill () override {} 0126 const char * nodeName () const override { return "fill"; } 0127 void activate () override; 0128 void begin () override; 0129 unsigned int fillColor () const { return color; } 0130 void accept (Visitor *) override; 0131 unsigned int color; 0132 }; 0133 0134 class Wipe : public TimingsBase 0135 { 0136 public: 0137 Wipe (NodePtr & d) : TimingsBase (d, id_node_wipe) {} 0138 ~Wipe () override {} 0139 const char * nodeName () const override { return "wipe"; } 0140 void activate () override; 0141 void begin () override; 0142 void accept (Visitor *) override; 0143 enum { dir_right, dir_left, dir_up, dir_down } direction; 0144 }; 0145 0146 class ViewChange : public TimingsBase 0147 { 0148 public: 0149 ViewChange (NodePtr & d) 0150 : TimingsBase (d, id_node_viewchange) {} 0151 ~ViewChange () override {} 0152 const char * nodeName() const override { return "viewchange"; } 0153 void activate () override; 0154 void begin () override; 0155 void finish () override; 0156 void accept (Visitor *) override; 0157 }; 0158 0159 class Image : public Mrl 0160 { 0161 PostponePtr postpone_lock; 0162 public: 0163 Image (NodePtr & d); 0164 ~Image () override; 0165 const char * nodeName () const override { return "image"; } 0166 void activate () override; 0167 void begin () override; 0168 void deactivate () override; 0169 void closed () override; 0170 void message (MessageType msg, void *content=nullptr) override; 0171 bool isReady (bool postpone_if_not = false); // is downloading ready 0172 Surface *surface (); 0173 SurfacePtrW img_surface; 0174 protected: 0175 void dataArrived (); 0176 }; 0177 0178 } // RP namespace 0179 0180 } // KMPlayer namespace 0181 0182 #endif //_KMPLAYER_RP_H_ 0183