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, write to the Free Software
19 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
22 #include "wpictureview.h"
27 #include "movieinfo.h"
28 #include "seriesinfo.h"
31 WPictureView::WPictureView():
32 foreColour(DrawStyle::LIGHTTEXT)
39 WPictureView::~WPictureView()
45 void WPictureView::setForegroundColour(const DrawStyle& fcolour)
50 void WPictureView::draw()
53 int fontHeight = getFontHeight();
54 float ypos = cur_scroll_line * (fontHeight*8.f);
58 drawClippingRectangle(1,1,area.w-1,area.h-1);
60 list<Picture>::iterator itty=pictures.begin();
61 while (itty!=pictures.end())
63 // We now calculate the pictures in one row
64 list<Picture*> cur_pict;
66 float max_height=const_height;
69 while (itty != pictures.end())
71 if ((((*itty).w + cur_width+ 10.f) > area.w || const_height) && cur_pict.size() > 0) break;
72 cur_width += 10 + (*itty).w;
73 if (!const_height) max_height = max(max_height,(*itty).h);
74 cur_pict.push_back(&(*itty));
77 // ok now we have a list of pictures, let's draw them
78 list<Picture*>::iterator citty=cur_pict.begin();
79 float xpos= (area.w - cur_width)*0.5f;
81 while (citty!=cur_pict.end())
84 drawTVMedia((*citty)->media,
85 xpos, ypos + max_height /*- (*citty)->h*/,
87 /*(*citty)->h*/0.f,BottomLeft);
89 if (!(*citty)->banner) {
90 drawTVMedia((*citty)->media,
91 xpos+area.w*0.5f, ypos,
93 const_height,TopMiddle);
95 drawTVMedia((*citty)->media,
96 xpos+area.w*0.5f, ypos,
101 xpos += (*citty)->w + 10.f;
105 height += max_height;
109 citty=cur_pict.begin();
110 xpos= (area.w - cur_width)*0.5f;
111 if (xpos < 0) xpos=0;
112 while (citty!=cur_pict.end())
114 if (!(*citty)->caption.empty())
116 drawTextCentre((*citty)->caption.c_str(), xpos + (*citty)->w*0.5f, ypos, foreColour);
119 if (!(*citty)->caption2.empty())
121 drawTextCentre((*citty)->caption2.c_str(), xpos + (*citty)->w*0.5f, ypos + fontHeight*1.f, foreColour);
124 xpos += (*citty)->w + 10.f;
128 ypos +=fontHeight*1.f;
129 height += fontHeight*1.f;
132 ypos +=fontHeight*1.f;
133 height += fontHeight*1.f;
135 ypos +=fontHeight*1.f;
136 height += fontHeight*1.f;
139 rem_scroll_line = ceil((height - area.h -cur_scroll_line * fontHeight*8.f)/fontHeight/8.f);
140 // Log::getInstance()->log("WActorGallery", Log::DEBUG, "TVMedia rml %d",rem_scroll_line);
141 drawClippingRectangle(0,0,0,0);
145 void WPictureView::addPicture(TVMediaInfo& pict, float pwidth, float pheight , bool banner, std::string caption, std::string caption2)
147 pictures.push_back(Picture(pict,pwidth,pheight, banner, caption,caption2));
150 int WPictureView::handleCommand(int command)
157 if (cur_scroll_line > 0)
165 return 4; // Signal return control to parent
168 case Remote::DF_DOWN:
171 if (rem_scroll_line > 0)
182 case Remote::DF_LEFT:
183 case Remote::DF_RIGHT:
193 WActorGallery::WActorGallery(Actors& actors)
195 Actors::iterator itty=actors.begin();
196 float pixelaspect=Osd::getInstance()->getPixelAspect();
197 while (itty!= actors.end())
199 float aspect=((float)(*itty).thumb.height)/((float)(*itty).thumb.width)/pixelaspect;
201 float height= aspect*width;
203 //Log::getInstance()->log("WActorGallery", Log::DEBUG, "TVMedia %d %d %g", (*itty).thumb.width,(*itty).thumb.height,aspect);
204 addPicture((*itty).thumb.info, width, height, false,(*itty).name,"\""+(*itty).role+"\"");
209 WArtworkGallery::WArtworkGallery(MovieInfo& movie)
211 float pixelaspect=Osd::getInstance()->getPixelAspect();
212 addTVMedia(movie.fanart);
213 addTVMedia(movie.collectionFanart);
214 addTVMedia(movie.collectionPoster);
215 addTVMedia(movie.poster);
219 WArtworkGallery::WArtworkGallery(SeriesInfo& series)
221 addTVMedia(series.seasonposter);
222 addTVMedia(series.episode.image);
224 addTVMedias(series.banners, true);
225 addTVMedias(series.fanart);
226 addTVMedias(series.posters);
230 void WArtworkGallery::addTVMedias(TVMedias& medias, bool banner)
233 TVMedias::iterator titty=medias.begin();
234 while (titty!=medias.end())
236 addTVMedia(*titty, banner);
243 void WArtworkGallery::addTVMedia(TVMedia& media, bool banner)
246 addPicture(media.info, media.width, media.height, banner);