]> git.vomp.tv Git - vompclient.git/blob - vmediaview.h
Windows fixes
[vompclient.git] / vmediaview.h
1 /*
2     Copyright 2004-2005 Chris Tallon, Andreas Vogel
3
4     This file is part of VOMP.
5
6     VOMP is free software; you can redistribute it and/or modify
7     it under the terms of the GNU General Public License as published by
8     the Free Software Foundation; either version 2 of the License, or
9     (at your option) any later version.
10
11     VOMP is distributed in the hope that it will be useful,
12     but WITHOUT ANY WARRANTY; without even the implied warranty of
13     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14     GNU General Public License for more details.
15
16     You should have received a copy of the GNU General Public License
17     along with VOMP.  If not, see <https://www.gnu.org/licenses/>.
18 */
19
20 #ifndef VMEDIAVIEW_H
21 #define VMEDIAVIEW_H
22
23 #include "boxx.h"
24 #include "timers.h"
25 #include "vmedialist.h"
26 #include "colour.h"
27 #include "wjpeg.h"
28 #include "wjpegcomplex.h"
29 #include "imagereader.h"
30
31 #define TESTCOLOURS
32 class Message;
33 class VInfo;
34 class AudioPlayer;
35 class DrawingThread;
36
37 /**
38   * the picture viewer
39   * will ineract with the parent List for ff,back, slide show...
40   *
41 */
42 class VPictureBanner;
43 class MediaOptions;
44 class VPreader;
45
46 class VMediaView : public Boxx, public TimerReceiver
47 {
48   friend class VPReader;
49   public:
50     virtual ~VMediaView();
51
52     void processMessage(Message* m);
53     int handleCommand(int command);
54     void draw();
55     void timercall(int clientReference);
56     //factory method, create an instance (setting it disabled)
57     //return NULL on error
58     static VMediaView *createViewer(VMediaList * parent);
59     //show the picture currently selected in the parent
60     //potentially moving to next/previous one
61     void showPicture(ULONG move,bool bslideshow,bool forceBanner);
62
63     void enableBanner(bool enable);
64
65     //play audio
66     //if activate is false no info will be shown
67     int play(bool all,bool activate,ULONG move=VMediaList::MV_NONE,bool showInfo=false);
68
69     //check if the audio player is still running
70     //to decide wether to shutdown or not
71     bool isAudioPlaying();
72
73     //player event parameters - no interference with audioplayer! - so we start at 100
74     const static int EVENT_SLIDESHOW;
75     const static int EVENT_DRAWINGDONE;
76     const static int EVENT_DRAWINGERROR;
77     const static int EVENT_DIRECTORYDONE;
78
79   private:
80
81     /**
82       * Common functions
83       * *************************************************************
84       */
85     void setPictureMode(bool enabled);
86     void setAudioMode(bool enabled,bool doHiding=true);
87     //destroy a view (banner, info) - from timer calls
88                 void sendViewMsg(Boxx *v);
89                 //send command in main thread - especially if this view is not on top
90                 void sendCommandMsg(int command);
91     VMediaList   *parent;
92     VMediaView(VMediaList * plist);
93     bool audioEnabled;
94     bool pictureEnabled;
95
96
97
98     /**
99       * Picture viewer
100       * *************************************************************
101       */
102     const static int PICTUREBANNER_TIME=8;
103     //start a slideshow
104     void startSlideshow();
105     //stop the sliedshow
106     void stopSlideshow(bool hard=true);
107     //showXXX functions enable the corresponding banner and restart the timer
108     //updateXXX functions update the content but do not retrigger the timer
109     void showPictureBanner(bool loading=false);
110     void destroyPictureBanner(bool fromTimer=false);
111     void updatePictureBanner(bool loading=false);
112     void showPictureInfo();
113     void updatePictureInfo();
114     void destroyInfo(bool fromTimer=false);
115     int  loadPicture(Media *m,bool forceBanner);
116     void getDrawingParam(Surface *&sfc,WJpegComplex::JpegControl *&ctl);
117     void switchSurface(); //will switch surface and currentControl
118     void drawingDone(bool hasError);
119
120     // Picture member variables
121     VPreader   *reader; //the reader for the drawing part
122     ImageReader *ireader;//the buffered media reader
123     VPictureBanner *pictureBanner;
124     bool havePictureBanner; //dow we have a normal banner (except during loading)
125     bool pictureLoading;
126     bool pictureShowing; //set to false if loading next is impossible
127     bool slideshow;
128     int showtime;
129     const char * pictureError;
130     Media * currentPicture;
131     const static int INITIAL_SHOWTIME=5;
132     WJpegComplex::Rotation rotate;
133     WJpegComplex::ScaleMode cropmode;
134     VInfo * info;
135     static DrawStyle pictureBack;
136     static DrawStyle infoBack;
137     static DrawStyle audioBannerBack;
138     int currentScale;
139     MediaOptions *options;
140     WJpegComplex::JpegControl ctl;
141     WJpegComplex::JpegControl ctl2;
142     WJpegComplex::JpegControl *currentControl;
143     Surface *sfc1;
144     Surface *sfc2;
145     //which is the active surface
146     bool secondSurface(){
147       return surface == sfc2;
148     }
149     UINT originalw;
150     UINT originalh;
151     bool bannerEnabled;
152
153     DrawingThread *drawingThread;
154     /**
155       * Audio player
156       * *************************************************************
157       */
158                 const static int AUDIOBANNER_TIME=30;
159                 const static int AUDIOERROR_TIME=5;
160
161
162                 //margin on SCREEN on each side
163                 const static int AUDIOBANNER_X_MARGIN=50;
164                 //margin on bottom of screen
165                 const static int AUDIOBANNER_BOTTOM_MARGIN=30;
166                 //length of the progress bar
167                 const static int AUDIOBARLEN=250;
168
169     //the  AudioInfo uses the same member as the PictureInfo
170     //so only one of them can be active at the same time
171                 void updateAudioInfo();
172     void showAudioInfo();
173                 void drawAudioInfo();
174                 void drawAudioClocks();
175     void showAudioBanner();
176     void destroyAudioBanner(); //currently not called from timer!
177                 //get the player - create it if necessary
178                 AudioPlayer* getPlayer(bool create=true);
179     bool playall;
180     const char * audioError;
181     Media * currentAudio;
182                 bool justPlaying;
183                 Region barRegion;
184                 Region clocksRegion;
185           DrawStyle barBlue;
186     //retrigger info on events?
187     bool retriggerAudioInfo;
188     VInfo *audioBanner;
189
190
191  };
192
193
194
195 #endif