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