2 Copyright 2005 Brian Walton (WTextBox)
3 Copyright 2014 Marten Richter (WPictureView)
5 This file is part of VOMP.
7 VOMP is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 VOMP is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with VOMP. If not, see <https://www.gnu.org/licenses/>.
27 #include "movieinfo.h"
28 #include "seriesinfo.h"
30 #include "wpictureview.h"
32 WPictureView::WPictureView():
33 foreColour(DrawStyle::LIGHTTEXT)
40 WPictureView::~WPictureView()
44 void WPictureView::setForegroundColour(const DrawStyle& fcolour)
49 void WPictureView::draw()
52 int fontHeight = getFontHeight();
53 float ypos = cur_scroll_line * (fontHeight*8.f);
57 drawClippingRectangle(1,1,area.w-1,area.h-1);
59 std::list<Picture>::iterator itty=pictures.begin();
60 while (itty!=pictures.end())
62 // We now calculate the pictures in one row
63 std::list<Picture*> cur_pict;
65 float max_height=const_height;
68 while (itty != pictures.end())
70 if ((((*itty).w + cur_width+ 10.f) > area.w || const_height) && cur_pict.size() > 0) break;
71 cur_width += 10 + (*itty).w;
72 if (!const_height) max_height = std::max(max_height,(*itty).h);
73 cur_pict.push_back(&(*itty));
76 // ok now we have a list of pictures, let's draw them
77 std::list<Picture*>::iterator citty=cur_pict.begin();
78 float xpos= (area.w - cur_width)*0.5f;
80 while (citty!=cur_pict.end())
83 drawImage((*citty)->media,
84 xpos, ypos + max_height /*- (*citty)->h*/,
86 /*(*citty)->h*/0.f,BottomLeft);
88 if (!(*citty)->banner) {
89 drawImage((*citty)->media,
90 xpos+area.w*0.5f, ypos,
92 const_height,TopMiddle);
94 drawImage((*citty)->media,
95 xpos+area.w*0.5f, ypos,
100 xpos += (*citty)->w + 10.f;
104 height += max_height;
108 citty=cur_pict.begin();
109 xpos= (area.w - cur_width)*0.5f;
110 if (xpos < 0) xpos=0;
111 while (citty!=cur_pict.end())
113 if (!(*citty)->caption.empty())
115 drawTextCentre((*citty)->caption.c_str(), (int)(xpos + (*citty)->w*0.5f), (int)ypos, foreColour);
118 if (!(*citty)->caption2.empty())
120 drawTextCentre((*citty)->caption2.c_str(), (int)(xpos + (*citty)->w*0.5f), (int)(ypos + fontHeight*1.f), foreColour);
123 xpos += (*citty)->w + 10.f;
127 ypos +=fontHeight*1.f;
128 height += fontHeight*1.f;
131 ypos +=fontHeight*1.f;
132 height += fontHeight*1.f;
134 ypos +=fontHeight*1.f;
135 height += fontHeight*1.f;
138 rem_scroll_line = (u4)ceil((height - area.h -cur_scroll_line * fontHeight*8.f)/fontHeight/8.f);
139 // Log::getInstance()->log("WActorGallery", Log::DEBUG, "TVMedia rml %d",rem_scroll_line);
140 drawClippingRectangle(0,0,0,0);
144 void WPictureView::addPicture(Image& pict, float pwidth, float pheight , bool banner, std::string caption, std::string caption2)
146 pictures.push_back(Picture(pict, pwidth, pheight, banner, caption, caption2));
149 int WPictureView::handleCommand(int command)
155 if (cur_scroll_line > 0)
163 return 4; // Signal return control to parent
168 if (rem_scroll_line > 0)
189 bool WPictureView::mouseAndroidScroll(int x, int y, int /* sx */, int sy)
191 if ((x - getRootBoxOffsetX()) >= 0 && (y - getRootBoxOffsetY()) >= 0
192 && (x - getRootBoxOffsetX()) <= (int)area.w && (y - getRootBoxOffsetY()) <= (int)area.h)
194 int change = -sy / 120;
196 int rel_change = std::min(cur_scroll_line, tou4(-change));
197 cur_scroll_line -= rel_change;
198 rem_scroll_line += rel_change;
200 else if (change > 0) {
201 int rel_change = std::min(rem_scroll_line, tou4(change));
202 cur_scroll_line += rel_change;
203 rem_scroll_line -= rel_change;
211 WActorGallery::WActorGallery(Actors& actors)
213 Actors::iterator itty=actors.begin();
214 float pixelaspect=Osd::getInstance()->getPixelAspect();
215 while (itty!= actors.end())
217 float aspect=((float)(*itty).thumb.height)/((float)(*itty).thumb.width)/pixelaspect;
219 float height= aspect*width;
221 //Log::getInstance()->log("WActorGallery", Log::DEBUG, "TVMedia %d %d %g", (*itty).thumb.width,(*itty).thumb.height,aspect);
222 addPicture((*itty).thumb.image, width, height, false,(*itty).name,"\""+(*itty).role+"\"");
227 WArtworkGallery::WArtworkGallery(MovieInfo& movie)
229 // float pixelaspect=Osd::getInstance()->getPixelAspect();
230 addTVMedia(movie.fanart);
231 addTVMedia(movie.collectionFanart);
232 addTVMedia(movie.collectionPoster);
233 addTVMedia(movie.poster);
237 WArtworkGallery::WArtworkGallery(SeriesInfo& series)
239 addTVMedia(series.seasonposter);
240 addTVMedia(series.episode.image);
242 addTVMedias(series.banners, true);
243 addTVMedias(series.fanart);
244 addTVMedias(series.posters);
248 void WArtworkGallery::addTVMedias(TVMedias& medias, bool banner)
251 TVMedias::iterator titty=medias.begin();
252 while (titty!=medias.end())
254 addTVMedia(*titty, banner);
261 void WArtworkGallery::addTVMedia(TVMediaStruct& media, bool banner)
264 addPicture(media.image, static_cast<float>(media.width), static_cast<float>(media.height), banner);