]> git.vomp.tv Git - vompclient.git/blob - vepgsummary.cc
Fix text corruption on channel list when returning from live TV
[vompclient.git] / vepgsummary.cc
1 /*
2     Copyright 2004-2008 Chris Tallon
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, write to the Free Software
18     Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
19 */
20
21 #include "vepgsummary.h"
22
23 #include "remote.h"
24 #include "vquestion.h"
25 #include "vepgsettimer.h"
26 #include "vinfo.h"
27 #include "vdr.h"
28 #include "colour.h"
29 #include "video.h"
30 #include "i18n.h"
31 #include "command.h"
32 #include "boxstack.h"
33 #include "event.h"
34 #include "channel.h"
35 #include "message.h"
36 #include "log.h"
37 #include "wmovieview.h"
38 #include "wseriesview.h"
39 #include "wpictureview.h"
40
41 #include <string>
42
43 VEpgSummary::VEpgSummary(Event *tevent, Channel* tchannel)
44 {
45   event = tevent;
46   channel = tchannel;
47   
48
49   if (Video::getInstance()->getFormat() == Video::PAL)
50   {
51     setSize(640+40, 500+40);
52         createBuffer();
53   }
54   else
55   {
56         setSize(560, 400);
57         createBuffer();
58   }
59   setPosition(20, 20);
60
61   setTitleBarOn(1);
62   setBorderOn(1);
63   setTitleText(event->title);
64
65   setTitleBarColour(DrawStyle::TITLEBARBACKGROUND);
66
67   tabbar.setPosition(10+10, 30 + 5);
68   tabbar.setSize(area.w - 20-10, area.h - 30 - 10-30);
69   add(&tabbar);
70
71   boxRed.setBackgroundColour(DrawStyle::RED);
72   boxRed.setPosition(20 /*54*/, tabbar.getY2()+8);
73   boxRed.setSize(18, 16);
74   add(&boxRed);
75
76   textRed.setPosition(boxRed.getX2(), tabbar.getY2()+4);
77   textRed.setSize(166, 30);
78   textRed.setText(tr("Record"));
79   add(&textRed);
80
81
82   WTextbox * summary=new WTextbox();
83   summary->setParaMode(true);
84
85   std::string summary_text = std::string(event->subtitle)+ "\n" +std::string(event->description);
86
87   summary->setText(summary_text.c_str());
88   OsdVector *osdv=dynamic_cast<OsdVector*>(Osd::getInstance());
89   summary->setBackgroundColour(DrawStyle::VIEWTRANSPARENTBACKGROUND);
90
91   tabbar.addTab(tr("EPG"), summary);
92   summary->setVideoBackground();
93   WMovieView *movieview=NULL;
94   WSeriesView *seriesview=NULL;
95   if (event->movieInfo) {
96           movieview = new WMovieView(event->movieInfo);
97           movieview->setParaMode(true);
98           movieview->setBackgroundColour(DrawStyle::VIEWTRANSPARENTBACKGROUND);
99           tabbar.addTab(tr("TheTVDB Info"), movieview);
100           if (osdv) {
101                   if (event->movieInfo->actors.size() > 0 && osdv)
102                   {
103                           WActorGallery *gallery= new WActorGallery(event->movieInfo->actors);
104                           gallery->setBackgroundColour(DrawStyle::VIEWTRANSPARENTBACKGROUND);
105                           tabbar.addTab(tr("Cast"),gallery);
106                   }
107                   WArtworkGallery *artgallery= new WArtworkGallery(*event->movieInfo);
108                   artgallery->setBackgroundColour(DrawStyle::VIEWTRANSPARENTBACKGROUND);
109                   tabbar.addTab(tr("Gallery"),artgallery);
110           }
111   } else if (event->seriesInfo) {
112           seriesview = new WSeriesView(event->seriesInfo);
113           seriesview->setParaMode(true);
114           seriesview->setBackgroundColour(DrawStyle::VIEWTRANSPARENTBACKGROUND);
115           tabbar.addTab(tr("TheTVDB Info"), seriesview);
116           if (osdv) {
117                   if (event->seriesInfo->actors.size() > 0 && osdv)
118                   {
119                           WActorGallery *gallery= new WActorGallery(event->seriesInfo->actors);
120                           gallery->setBackgroundColour(DrawStyle::VIEWTRANSPARENTBACKGROUND);
121                           tabbar.addTab(tr("Cast"),gallery);
122                   }
123                   WArtworkGallery *artgallery= new WArtworkGallery(*event->seriesInfo);
124                   artgallery->setBackgroundColour(DrawStyle::VIEWTRANSPARENTBACKGROUND);
125                   tabbar.addTab(tr("Gallery"),artgallery);
126           }
127
128   }
129
130   epgTVmedia.setPosition(summary->getRegionR().w-130-10,0);
131   epgTVmedia.setSize(130,(UINT)(195/Osd::getInstance()->getPixelAspect()));
132   summary->add(&epgTVmedia);
133   if (movieview) movieview->add(&epgTVmedia);
134   if (seriesview) seriesview->add(&epgTVmedia);
135   TVMedia poster;
136   poster.height=0;
137   if (event->movieInfo) {
138           poster=event->movieInfo->poster;
139   }
140   if (event->seriesInfo) {
141           if (event->seriesInfo->seasonposter.height) {
142                   poster=event->seriesInfo->seasonposter;
143           }
144           else
145                   if (event->seriesInfo->posters.size()) {
146                           poster=event->seriesInfo->posters[0];
147                   }
148   }
149   if (poster.height) {
150           epgTVmedia.setTVMedia(poster.info, WTVMedia::ZoomHorizontal);
151           epgTVmedia.setVisible(true);
152   } else {
153           epgTVmedia.setVisible(false);
154   }
155
156
157
158   tabbar.activateFocus(true);
159 }
160
161 VEpgSummary::~VEpgSummary()
162 {
163 }
164
165
166
167
168 int VEpgSummary::handleCommand(int command)
169 {
170         if (command==Remote::BACK) {
171                 return 4;
172         }
173         if (command==Remote::RED)
174     {
175       if (!channel) return 2;
176       Log::getInstance()->log("VEpgSummary", Log::DEBUG, "ID %lu TIME %lu DURATION %lu TITLE %s", event->id, event->time, event->duration, event->title);
177       VEpgSetTimer* vs = new VEpgSetTimer(event, channel);
178       vs->draw();
179       BoxStack *boxstack=BoxStack::getInstance();
180       boxstack->add(vs);
181       boxstack->update(vs);
182       return 2;
183     }
184
185         // Pass to tabbar
186         int retval = tabbar.handleCommand(command);
187         if (retval == 1)
188         {
189                 BoxStack::getInstance()->update(this);
190                 return 2;
191         }
192         else if (retval == 2)
193         {
194
195                 return 2;
196         }
197
198
199
200         // stop command getting to any more views
201         return 1;
202 }
203
204
205
206 void VEpgSummary::processMessage(Message* m)
207 {
208         if (m->message == Message::MOUSE_MOVE)
209         {
210                 if (tabbar.mouseMove((m->parameter.num >> 16) - getScreenX(), (m->parameter.num & 0xFFFF) - getScreenY()))
211                 {
212                         BoxStack::getInstance()->update(this);
213                 }
214         }
215         else if (m->message == Message::MOUSE_LBDOWN)
216         {
217                 int cancel = true;
218                 int x = (m->parameter.num >> 16) - getScreenX();
219                 int y = (m->parameter.num & 0xFFFF) - getScreenY();
220
221                 if ((boxRed.getX() <= x) && (boxRed.getX() + (int)boxRed.getWidth() >= x) &&
222                                 (boxRed.getY() <= y) && (boxRed.getY() + (int)boxRed.getHeight() >= y)) {
223                         BoxStack::getInstance()->handleCommand(Remote::RED);
224                         cancel = false;
225                 }
226
227
228                 if (cancel && tabbar.mouseLBDOWN((m->parameter.num >> 16) - getScreenX(), (m->parameter.num & 0xFFFF) - getScreenY()))
229                 {
230                         BoxStack::getInstance()->update(this);
231                         cancel = false;
232                 }
233                 if (cancel)
234                 {
235                         //check if press is outside this view! then simulate cancel
236                         int checkX=(m->parameter.num>>16)-getScreenX();
237                         int checkY=(m->parameter.num&0xFFFF)-getScreenY();
238                         if (checkX<0 || checkY <0 || checkX>(int)getWidth() || checkY>(int)getHeight())
239                         {
240                                 BoxStack::getInstance()->handleCommand(Remote::BACK); //simulate cancel press
241                         }
242                 }
243         } else if (m->message == Message::MOUSE_SCROLL)
244         {
245                 if (tabbar.mouseAndroidScroll((m->tag >> 16) - getScreenX(), (m->tag & 0xFFFF) - getScreenY(),
246                                 (short)(m->parameter.num >> 16), (short)(m->parameter.num & 0xFFFF)))
247                 {
248                         BoxStack::getInstance()->update(this);
249                         return;
250                 }
251         }
252 }
253
254