]> git.vomp.tv Git - vompclient.git/blob - src/vepgsummary.cc
Type change: UINT -> u4
[vompclient.git] / src / 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 #include "imageloader.h"
40
41 #include "vepgsummary.h"
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.c_str());
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 = event->subtitle + "\n" + 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, static_cast<u4>(195 / Osd::getInstance()->getPixelAspect()));
132   summary->add(&epgTVmedia);
133   if (movieview) movieview->add(&epgTVmedia);
134   if (seriesview) seriesview->add(&epgTVmedia);
135   TVMediaStruct 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.setImage(poster.image, WTVMedia::ZoomHorizontal);
151           epgTVmedia.setVisible(true);
152   } else {
153           epgTVmedia.setVisible(false);
154   }
155
156   tabbar.activateFocus(true);
157
158   MessageQueue::getInstance()->addReceiver(this);
159 }
160
161 VEpgSummary::~VEpgSummary()
162 {
163   MessageQueue::getInstance()->removeReceiver(this);
164 }
165
166
167
168
169 int VEpgSummary::handleCommand(int command)
170 {
171         if (command==Input::BACK) {
172         return BoxStack::DELETE_ME;
173         }
174         if (command==Input::RED)
175     {
176       if (!channel) return BoxStack::COMMAND_HANDLED;
177       LogNT::getInstance()->debug("VEpgSummary", "ID {} TIME {} DURATION {} TITLE {}", event->id, event->time, event->duration, event->title);
178       VEpgSetTimer* vs = new VEpgSetTimer(event, channel);
179       vs->draw();
180       BoxStack *boxstack=BoxStack::getInstance();
181       boxstack->add(vs);
182       boxstack->update(vs);
183       return BoxStack::COMMAND_HANDLED;
184     }
185
186         // Pass to tabbar
187         int retval = tabbar.handleCommand(command);
188         if (retval == 1)
189         {
190                 BoxStack::getInstance()->update(this);
191         return BoxStack::COMMAND_HANDLED;
192         }
193         else if (retval == 2)
194         {
195         return BoxStack::COMMAND_HANDLED;
196         }
197
198
199
200         // stop command getting to any more views
201     return BoxStack::ABANDON_COMMAND;
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 - getScreenX(), m->tag - 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 - getScreenX();
219                 int y = m->tag - getScreenY();
220
221                 if ((boxRed.getX() <= x) && (boxRed.getX() + toi4(boxRed.getWidth()) >= x) &&
222                                 (boxRed.getY() <= y) && (boxRed.getY() + toi4(boxRed.getHeight()) >= y)) {
223                         BoxStack::getInstance()->handleCommand(Input::RED);
224                         cancel = false;
225                 }
226
227
228                 if (cancel && tabbar.mouseLBDOWN(x, y))
229                 {
230                         BoxStack::getInstance()->update(this);
231                         cancel = false;
232                 }
233                 if (cancel)
234                 {
235           if (coordsOutsideBox(m))
236           {
237             Input::sendInputKey(Input::BACK);
238           }
239                 }
240         }
241         else if (m->message == Message::MOUSE_SCROLL)
242         {
243                 if (tabbar.mouseAndroidScroll(m->parameter - getScreenX(), m->tag - getScreenY(), 0, reinterpret_cast<u4>(m->data)))
244                 {
245                         BoxStack::getInstance()->update(this);
246                         return;
247                 }
248         }
249 }
250
251