From bf9125225437a8ebaf519079b828fc304b4eea34 Mon Sep 17 00:00:00 2001 From: Marten Richter Date: Sun, 31 Aug 2014 17:16:59 +0200 Subject: [PATCH] Extended recordings menu, including artwork from tvscraper --- boxx.cc | 24 +++++- boxx.h | 1 + command.cc | 29 ++++++- command.h | 5 ++ defines.h | 1 + objects.mk | 4 +- osdvector.cc | 10 ++- recording.cc | 2 + region.h | 5 ++ tvmedia.cc | 24 +++++- tvmedia.h | 6 +- vdr.cc | 22 +++++ vdr.h | 1 + vdrcommand.h | 1 + vopts.cc | 24 +++++- vrecordinglist.cc | 199 +++++++--------------------------------------- vrecordinglist.h | 11 +-- vwelcome.cc | 26 +++--- wselectlist.cc | 50 +++++++++--- wselectlist.h | 7 +- wtvmedia.cc | 63 +++++++++++++++ wtvmedia.h | 55 +++++++++++++ 22 files changed, 362 insertions(+), 208 deletions(-) create mode 100644 wtvmedia.cc create mode 100644 wtvmedia.h diff --git a/boxx.cc b/boxx.cc index 2222086..16b8e25 100644 --- a/boxx.cc +++ b/boxx.cc @@ -111,6 +111,18 @@ void Boxx::remove(Boxx* oldChild) Log::getInstance()->log("Boxx", Log::ERR, "Remove child box called, child %p not found", oldChild); } +bool Boxx::overlapsVisibleChilds(Region & r) +{ + for(vector::iterator i = children.begin(); i != children.end(); i++) + { + if ((*i)->getVisible() && r.intersects((*i)->getRegionR())) + { + return true; + } + } + return false; +} + void Boxx::setParent(Boxx* newParent) { parent = newParent; @@ -259,11 +271,17 @@ int Boxx::drawPara(const char* text, int x, int y, const DrawStyle& colour,unsig textPos = 0; ypos = y; + Region tester; + tester.h = lineHeight; + + bool haschildren = true; + if ( children.size() == 0) haschildren = false; while(1) { linePos = 0; lineWidth = 0; + tester.y=ypos; while(1) { printLine = 0; @@ -279,7 +297,11 @@ int Boxx::drawPara(const char* text, int x, int y, const DrawStyle& colour,unsig break; } thisCharWidth = charWidth(cur_char); - if ((lineWidth + thisCharWidth) > (int)(area.w - (2 * paraMargin))) + tester.x = lineWidth; + tester.w = thisCharWidth + 10; + + if ((lineWidth + thisCharWidth) > (int)(area.w - (2 * paraMargin)) + || (haschildren && overlapsVisibleChilds(tester))) { // this character would break the right margin if (cur_char == ' ') diff --git a/boxx.h b/boxx.h index 1b76866..76342e4 100644 --- a/boxx.h +++ b/boxx.h @@ -147,6 +147,7 @@ class Boxx void setParent(Boxx*); void blt(Region& r); + bool overlapsVisibleChilds(Region & r); static const int paraMargin = 10; UINT paraVSpace; diff --git a/command.cc b/command.cc index ef50069..eb7a4ea 100644 --- a/command.cc +++ b/command.cc @@ -965,7 +965,6 @@ void Command::doJustConnected(VConnect* vconnect) - // Get TV aspect ratio config = vdr->configLoad("TV", "Aspect"); @@ -1040,6 +1039,34 @@ void Command::doJustConnected(VConnect* vconnect) } + // Set recording list type + + advmenues=false; +#ifdef ADVANCED_MENUES + config = vdr->configLoad("Advanced", "Menu type"); + + if (config) + { + if (!STRCASECMP(config, "Advanced")) + { + logger->log("Command", Log::INFO, "Switching to Advanced menu"); + advmenues=true; + + } + else + { + logger->log("Command", Log::INFO, "Switching to Classic menu"); + advmenues=false; + } + delete[] config; + } + else + { + logger->log("Command", Log::INFO, "Config General/menu type not found"); + advmenues=true; + } +#endif + config = vdr->configLoad("Advanced", "Disable WOL"); if (config) { diff --git a/command.h b/command.h index 746b011..22f27e7 100644 --- a/command.h +++ b/command.h @@ -65,6 +65,9 @@ class Command : public MessageQueue void sig1(); void connectionLost(); + void setAdvMenues(bool adv) {advmenues=adv;}; + bool advMenues() { return advmenues;}; + private: void handleCommand(int); void doStandby(); @@ -95,6 +98,8 @@ class Command : public MessageQueue VInfo* connLost; bool crashed; char* server; + + bool advmenues; UDP udp; diff --git a/defines.h b/defines.h index 14d0e4c..3d975e5 100644 --- a/defines.h +++ b/defines.h @@ -123,6 +123,7 @@ long long getTimeMS(); #define TV_NORM_SWITCHABLE #define HANDLE_VT_SWITCHING #define GRADIENT_DRAWING + #define ADVANCED_MENUES // This is for special HD versions of our menus #define PICTURE_DECODER_MAGICK #define PICTURE_DECODER_OMX diff --git a/objects.mk b/objects.mk index 992ed97..a6dee51 100644 --- a/objects.mk +++ b/objects.mk @@ -5,7 +5,7 @@ OBJECTS1 = command.o tcp.o dsock.o thread.o timers.o i18n.o \ player.o playerradio.o vfeed.o afeed.o \ demuxer.o demuxervdr.o demuxerts.o stream.o \ region.o colour.o boxstack.o boxx.o tbboxx.o \ - vinfo.o vquestion.o vrecordinglist.o vrecording.o \ + vinfo.o vquestion.o vrecordinglist.o vrecordinglistclassic.o vrecordinglistadvanced.o vrecording.o \ vmute.o vvolume.o vtimerlist.o vtimeredit.o vrecordingmenu.o \ vchannellist.o vwelcome.o vvideorec.o vepgsettimer.o \ vchannelselect.o vserverselect.o vconnect.o vepg.o vrecmove.o \ @@ -24,7 +24,7 @@ OBJECTS1 = command.o tcp.o dsock.o thread.o timers.o i18n.o \ imagereader.o mediaoptions.o mediaplayer.o \ serialize.o localmediafile.o playermedia.o \ demuxermedia.o tfeed.o vteletextview.o teletextdecodervbiebu.o \ - teletxt/txtfont.o mediafile.o movieinfo.o seriesinfo.o wmovieview.o wseriesview.o tvmedia.o \ + teletxt/txtfont.o mediafile.o movieinfo.o seriesinfo.o wmovieview.o wseriesview.o tvmedia.o wtvmedia.o\ wpictureview.o diff --git a/osdvector.cc b/osdvector.cc index bacb245..d315c08 100644 --- a/osdvector.cc +++ b/osdvector.cc @@ -533,7 +533,15 @@ LoadIndex OsdVector::loadTVMedia(TVMediaInfo& tvmedia) LoadIndex index=0; if (tvmedias_load.find(tvmedia)==tvmedias_load.end()) { - index=VDR::getInstance()->loadTVMedia(tvmedia); + switch (tvmedia.getType()) { + case 3: + index=VDR::getInstance()->loadTVMediaRecThumb(tvmedia); + break; + default: + index=VDR::getInstance()->loadTVMedia(tvmedia); + break; + } + tvmedias_load[tvmedia]=index; tvmedias_load_inv[index]=tvmedia; } else { diff --git a/recording.cc b/recording.cc index 5bec001..83e8ee3 100644 --- a/recording.cc +++ b/recording.cc @@ -126,6 +126,8 @@ void Recording::loadRecInfo() movieInfo = NULL; seriesInfo = NULL; + movieID = 0; + seriesID =0; vdr->getScraperEventType(fileName, movieID, seriesID, episodeID); Log::getInstance()->log("Recording", Log::DEBUG, "Got Scraper EventType %d %d %d", diff --git a/region.h b/region.h index 44f172d..ad23113 100644 --- a/region.h +++ b/region.h @@ -11,6 +11,11 @@ class Region bool overlappedBy(Region& doesthisOverlap); // Region subtract(Region& other); Region operator + (Region& other); + inline bool intersects(Region test) { + return !((test.x+test.w) < x || (x + w) < test.x + || (test.y+test.h) < y || (y+h) < test.y); + } + UINT x2(); UINT y2(); diff --git a/tvmedia.cc b/tvmedia.cc index 8460b56..b02ebdd 100644 --- a/tvmedia.cc +++ b/tvmedia.cc @@ -31,10 +31,10 @@ TVMediaInfo::TVMediaInfo() type_pict=-1; // 0 full info, 1 poster, 2 poster banner, 3 poster thumb container=-1; // indices the dataelements with picture in movieinfo or seriesinfo container_member=-1; // index into the container + primary_name=""; } - TVMediaInfo::TVMediaInfo(const TVMediaInfo& info) { type=info.type; // movie or series @@ -43,6 +43,7 @@ TVMediaInfo::TVMediaInfo(const TVMediaInfo& info) type_pict=info.type_pict; // 0 full info, 1 poster, 2 poster banner, 3 poster thumb container=info.container; // indices the dataelements with picture in movieinfo or seriesinfo container_member=info.container_member; // index into the container + primary_name=info.primary_name; } @@ -60,6 +61,12 @@ void TVMediaInfo::setSeriesInfo(const SeriesInfo * si) secondary_id=si->episode.episodeid; //0 or episode id } +void TVMediaInfo::setPosterThumb(const char* recname) +{ + type=3; + primary_name=recname; +} + bool operator<(const TVMediaInfo& rhs, const TVMediaInfo& lhs) { if (rhs.type==lhs.type) { @@ -67,7 +74,11 @@ bool operator<(const TVMediaInfo& rhs, const TVMediaInfo& lhs) if (rhs.secondary_id==lhs.secondary_id) { if (rhs.type_pict==lhs.type_pict) { if (rhs.container==lhs.container) { - return rhs.container_membernoResponse()) { delete vresp; return -1; } + delete vresp; + + return vrp.getSerial(); +} + +ULONG VDR::loadTVMediaRecThumb(TVMediaInfo & media) +{ + + VDR_RequestPacket vrp; + + if (!vrp.init(VDR_LOADTVMEDIARECTHUMB, false, 0)) return -1; + if (!vrp.addString(media.primary_name.c_str())) return NULL; + + VDR_PacketReceiver* vdrpr = new VDR_PacketReceiver(); + vdrpr->receiverChannel = VDR::CHANNEL_TVMEDIA; + vdrpr->streamID = vrp.getSerial(); + vdrpr->streamReceiver = NULL; + edRegister(vdrpr); + + VDR_ResponsePacket* vresp = RequestResponse(&vrp); //if (vresp->noResponse()) { delete vresp; return -1; } delete vresp; diff --git a/vdr.h b/vdr.h index cd46f18..1aec760 100644 --- a/vdr.h +++ b/vdr.h @@ -209,6 +209,7 @@ class VDR : public Thread_TYPE, public EventDispatcher, public MediaProvider, pu MovieInfo *getScraperMovieInfo(int movieID); SeriesInfo *getScraperSeriesInfo(int seriesID, int episodeID); ULONG loadTVMedia(TVMediaInfo& tvmedia); + ULONG loadTVMediaRecThumb(TVMediaInfo& tvmedia); void invalidateTVMedia(ULONG loadindex); diff --git a/vdrcommand.h b/vdrcommand.h index d0a8af8..9991b1d 100644 --- a/vdrcommand.h +++ b/vdrcommand.h @@ -73,6 +73,7 @@ const static ULONG VDR_GETRECSCRAPEREVENTTYPE = 38; const static ULONG VDR_GETSCRAPERMOVIEINFO = 39; const static ULONG VDR_GETSCRAPERSERIESINFO = 40; const static ULONG VDR_LOADTVMEDIA = 41; +const static ULONG VDR_LOADTVMEDIARECTHUMB = 42; const static ULONG VDR_SHUTDOWN = 666; class VDR_Command : public SerializableList { diff --git a/vopts.cc b/vopts.cc index 0893b7b..cfa700e 100644 --- a/vopts.cc +++ b/vopts.cc @@ -72,6 +72,9 @@ VOpts::VOpts() static const char* options13[] = {"Auto","1024", "2048", "4096", "8192", "16384", "32768", "65536"}; static const char* options14[] = {"No", "Yes"}; static const char* options18[] = {"Off", "On"}; +#ifdef ADVANCED_MENUES + static const char* options19[] = { "Advanced","Classic"}; +#endif // Get list of languages from VDR and construct options table LangCode = VDR::getInstance()->getLanguageList(); options2 = new const char*[LangCode.size()]; @@ -99,7 +102,6 @@ VOpts::VOpts() options.push_back(option); wop->addOptionLine(option); - UINT suppconn = Video::getInstance()->getSupportedFormats(); if (suppconn) { int defaultch = 0; @@ -256,6 +258,12 @@ VOpts::VOpts() wop->addOptionLine(option); } +#ifdef ADVANCED_MENUES + option = new Option(19, "Advanced Menu", "General", "Menu type",Option::TYPE_TEXT, 2, 0, 0, options19); + options.push_back(option); + wop->addOptionLine(option); +#endif + Remote::getInstance()->addOptionsToPanes(2,&options,wop); Video::getInstance()->addOptionsToPanes(2,&options,wop); Audio::getInstance()->addOptionsToPanes(2,&options,wop); @@ -464,6 +472,20 @@ void VOpts::doSave() } break; } + case 19: + { + if (options[i]->userSetChoice == 1) + { + Log::getInstance()->log("Options", Log::DEBUG, "Setting classic menu"); + Command::getInstance()->setAdvMenues(false); + } + else + { + Log::getInstance()->log("Options", Log::DEBUG, "Setting advanced menu"); + Command::getInstance()->setAdvMenues(true); + } + break; + } } } else diff --git a/vrecordinglist.cc b/vrecordinglist.cc index 65dd572..71f53a5 100644 --- a/vrecordinglist.cc +++ b/vrecordinglist.cc @@ -44,23 +44,6 @@ VRecordingList::VRecordingList() recman = NULL; loading = true; - setSize(570, 420); - createBuffer(); - if (Video::getInstance()->getFormat() == Video::PAL) - { - setPosition(80, 70); - } - else - { - setPosition(70, 35); - } - - setTitleBarOn(1); - setTitleBarColour(DrawStyle::TITLEBARBACKGROUND); - - sl.setPosition(10, 30 + 5); - sl.setSize(area.w - 20, area.h - 30 - 15 - 30); - add(&sl); } VRecordingList::~VRecordingList() @@ -68,142 +51,6 @@ VRecordingList::~VRecordingList() delete recman; } -void VRecordingList::drawData(bool doIndexPop) -{ - int saveIndex = sl.getCurrentOption(); - int saveTop = sl.getTopOption(); - sl.clear(); - sl.addColumn(0); - sl.addColumn(102); - sl.addColumn(118); - - int first = 1; - - char tempA[300]; // FIXME this is guesswork! - char tempB[300]; // FIXME - struct tm* btime; - - Directory* currentSubDir; - DirectoryList::iterator i; - DirectoryList* dirList = recman->getDirectories(); - for (i = dirList->begin(); i != dirList->end(); i++) - { - currentSubDir = *i; - SNPRINTF(tempA, 299, tr(" %lu/%lu\t \t%s"), currentSubDir->getNumNewRecordings(), currentSubDir->getNumRecordings(), currentSubDir->name); - currentSubDir->index = sl.addOption(tempA, 0, first); - first = 0; - } - // FIXME convert the whole program to time_t's - - Recording* currentRec; - RecordingList::iterator j; - RecordingList* recList = recman->getRecordings(); - for (j = recList->begin(); j != recList->end(); j++) - { - currentRec = *j; - time_t recStartTime = (time_t)currentRec->getStartTime(); - btime = localtime(&recStartTime); -//NMT does not like this too! - //#ifndef _MSC_VER -// strftime(tempA, 299, "%0d/%0m %0H:%0M ", btime); -//#else - strftime(tempA, 299, "%d/%m %H:%M ", btime); -//#endif - sprintf(tempB, "%s\t%c\t%s", tempA, (currentRec->getNew() ? '*': ' '), currentRec->getProgName()); - - currentRec->index = sl.addOption(tempB, 0, first); - first = 0; - } - - if (doIndexPop) - { - sl.hintSetCurrent(slIndexStack.top()); - slIndexStack.pop(); - } - else - { - sl.hintSetCurrent(saveIndex); - sl.hintSetTop(saveTop); - } - sl.draw(); - doShowingBar(); -} - -void VRecordingList::draw(bool doIndexPop) -{ - if (!loading) - { - if (recman->isSubDir()) - { - char title[300]; - SNPRINTF(title, 299, tr("Recordings - %s"), recman->getCurDirName()); - setTitleText(title, 364); - } - else - { - setTitleText(tr("Recordings")); - } - } - - TBBoxx::draw(); - - if (loading) - { - drawText(tr("Loading..."), 240, 180, DrawStyle::LIGHTTEXT); - } - else - { - char freeSpace[50]; - int gigFree = recman->getFreeSpace() / 1024; - SNPRINTF(freeSpace, 49, tr("%lu%% used, %iGB free"), recman->getUsedPercent(), gigFree); - drawTextRJ(freeSpace, 560, 5, DrawStyle::LIGHTTEXT); - // Symbols - - WSymbol w; - TEMPADD(&w); - w.nextSymbol = WSymbol::UP; - w.setPosition(20, 385); - w.draw(); - w.nextSymbol = WSymbol::DOWN; - w.setPosition(50, 385); - w.draw(); - w.nextSymbol = WSymbol::SKIPBACK; - w.setPosition(85, 385); - w.draw(); - w.nextSymbol = WSymbol::SKIPFORWARD; - w.setPosition(115, 385); - w.draw(); - w.nextSymbol = WSymbol::PLAY; - w.setPosition(150, 385); - w.draw(); - drawTextRJ(tr("[ok] = menu"), 560, 385, DrawStyle::LIGHTTEXT); - - // All static stuff done - drawData(doIndexPop); - } -} - -void VRecordingList::doShowingBar() -{ - int topOption = sl.getTopOption() + 1; - if (sl.getNumOptions() == 0) topOption = 0; -#ifndef GRADIENT_DRAWING - rectangle(220, 385, 180, 25, DrawStyle::VIEWBACKGROUND); -#endif - char showing[200]; - sprintf(showing, tr("%i to %i of %i"), topOption, sl.getBottomOption(), sl.getNumOptions()); - drawText(showing, 220, 385, DrawStyle::LIGHTTEXT); -} - -void VRecordingList::quickUpdate() { //only quick for plattform that need it! -#ifdef GRADIENT_DRAWING - draw(); -#else - sl.draw(); - doShowingBar(); -#endif -} - void VRecordingList::processMessage(Message* m) { Log::getInstance()->log("VRecordingList", Log::DEBUG, "Got message value %lu", m->message); @@ -426,6 +273,24 @@ Recording* VRecordingList::getCurrentOptionRecording() return NULL; } +Directory* VRecordingList::getCurrentOptionDirectory() +{ + Directory* currentSubDir; + DirectoryList::iterator i; + DirectoryList* dirList = recman->getDirectories(); + for (i = dirList->begin(); i != dirList->end(); i++) + { + currentSubDir = *i; + if (currentSubDir->index == sl.getCurrentOption()) + { + + return currentSubDir; + } + } + + return NULL; +} + int VRecordingList::handleCommand(int command) { switch(command) @@ -469,25 +334,21 @@ int VRecordingList::handleCommand(int command) if (sl.getNumOptions() == 0) return 2; // Check to see if it is a sub directory - Directory* currentSubDir; - DirectoryList::iterator i; - DirectoryList* dirList = recman->getDirectories(); - for (i = dirList->begin(); i != dirList->end(); i++) + Directory* currentSubDir=getCurrentOptionDirectory(); + + if (currentSubDir) { - currentSubDir = *i; - if (currentSubDir->index == sl.getCurrentOption()) - { - if (recman->down(currentSubDir)) - { - slIndexStack.push(sl.getCurrentOption()); - sl.clear(); - draw(); - boxstack->update(this); - } - return 2; - } + if (recman->down(currentSubDir)) + { + slIndexStack.push(sl.getCurrentOption()); + sl.clear(); + draw(); + boxstack->update(this); + } + return 2; } + // check to see if it's a recording Recording* current = getCurrentOptionRecording(); if (current) diff --git a/vrecordinglist.h b/vrecordinglist.h index d2f11db..8db32bc 100644 --- a/vrecordinglist.h +++ b/vrecordinglist.h @@ -42,13 +42,13 @@ class VRecordingList : public TBBoxx VRecordingList(); virtual ~VRecordingList(); + + virtual void draw(bool doIndexPop = false)=0; int handleCommand(int command); void processMessage(Message* m); - void draw(bool doIndexPop = false); bool load(); - void drawData(bool doIndexPop = false); - private: + protected: BoxStack* boxstack; bool loading; RecMan* recman; @@ -56,14 +56,15 @@ class VRecordingList : public TBBoxx WSelectList sl; - void quickUpdate(); - void doShowingBar(); void doDeleteSelected(); int doPlay(bool resume); void doMoveRecording(Directory* toDir); Recording* getCurrentOptionRecording(); + Directory* getCurrentOptionDirectory(); void reSort(); + virtual void quickUpdate()=0; + stack slIndexStack; }; diff --git a/vwelcome.cc b/vwelcome.cc index ee6e044..144bc28 100644 --- a/vwelcome.cc +++ b/vwelcome.cc @@ -23,7 +23,8 @@ #include "remote.h" #include "vdr.h" #include "vchannellist.h" -#include "vrecordinglist.h" +#include "vrecordinglistclassic.h" +#include "vrecordinglistadvanced.h" #include "vtimerlist.h" #include "command.h" #include "message.h" @@ -290,15 +291,20 @@ void VWelcome::doRadioList() void VWelcome::doRecordingsList() { - VRecordingList* vrec = new VRecordingList(); - vrec->draw(); - boxstack->add(vrec); - boxstack->update(vrec); - - if (!vrec->load()) - { - Command::getInstance()->connectionLost(); - } + VRecordingList* vrec; + if (Command::getInstance()->advMenues()) { + vrec = new VRecordingListAdvanced(); + } else { + vrec = new VRecordingListClassic(); + } + vrec->draw(); + boxstack->add(vrec); + boxstack->update(vrec); + + if (!vrec->load()) + { + Command::getInstance()->connectionLost(); + } } void VWelcome::doMediaList() diff --git a/wselectlist.cc b/wselectlist.cc index 1c5e2d7..2799639 100644 --- a/wselectlist.cc +++ b/wselectlist.cc @@ -23,6 +23,8 @@ #include "colour.h" #include "log.h" +#include + WSelectList::WSelectList(): backgroundColour(DrawStyle::VIEWBACKGROUND) { @@ -34,6 +36,7 @@ backgroundColour(DrawStyle::VIEWBACKGROUND) gap = 1; showseloption = true; darkseloption = false; + linesPerOption = 1; } @@ -48,6 +51,7 @@ void WSelectList::clear() for (int i = 0; i < vsize; i++) { delete[] options[i].text; + if (options[i].pict) delete options[i].pict; } options.clear(); @@ -78,7 +82,7 @@ void WSelectList::hintSetTop(int idx) topOption = idx; } -int WSelectList::addOption(const char* text, ULONG data, int selected) +int WSelectList::addOption(const char* text, ULONG data, int selected, TVMediaInfo * pict) { int thisNewOption = options.size(); @@ -86,6 +90,7 @@ int WSelectList::addOption(const char* text, ULONG data, int selected) wslo.text = new char[strlen(text) + 1]; strcpy(wslo.text, text); wslo.data = data; + wslo.pict = pict; options.push_back(wslo); if (selected) selectedOption = thisNewOption; return thisNewOption; @@ -94,7 +99,7 @@ int WSelectList::addOption(const char* text, ULONG data, int selected) void WSelectList::draw() { int fontHeight = getFontHeight(); - int ySeperation = fontHeight + gap; + int ySeperation = fontHeight * linesPerOption + gap; numOptionsDisplayable = (area.h - 5) / ySeperation; @@ -120,14 +125,14 @@ void WSelectList::draw() if (i == selectedOption && showseloption) { - rectangle(0, ypos, area.w, fontHeight, darkseloption ? DrawStyle::SELECTDARKHIGHLIGHT: DrawStyle::SELECTHIGHLIGHT); + rectangle(0, ypos, area.w, fontHeight * linesPerOption, darkseloption ? DrawStyle::SELECTDARKHIGHLIGHT: DrawStyle::SELECTHIGHLIGHT); - drawOptionLine(options[i].text, 5, ypos, area.w - 5, DrawStyle::DARKTEXT); + drawOptionLine(options[i].text, 5, ypos, area.w - 5, DrawStyle::DARKTEXT, options[i].pict); } else { - drawOptionLine(options[i].text, 5, ypos, area.w - 5, DrawStyle::LIGHTTEXT); + drawOptionLine(options[i].text, 5, ypos, area.w - 5, DrawStyle::LIGHTTEXT, options[i].pict); } ypos += ySeperation; } @@ -140,9 +145,20 @@ void WSelectList::addColumn(int x) columns[numColumns++] = x; } -void WSelectList::drawOptionLine(char* text, int xpos, int ypos, int width, const DrawStyle& colour) +void WSelectList::drawOptionLine(char* text, int xpos, int ypos, int width, const DrawStyle& colour, TVMediaInfo* pict) { - if (!numColumns) + UINT curline = 0; + UINT taboffset = 0; + int fontHeight = getFontHeight(); + float ypos_mod= ypos + (linesPerOption-floor(linesPerOption))*((float)fontHeight)*0.5f; + + if (pict) + { + drawTVMedia(*pict, xpos,ypos,0,fontHeight*linesPerOption,TopLeft); + taboffset++; + } + + if (!numColumns && linesPerOption == 1) { drawText(text, xpos, ypos, width, colour); @@ -151,18 +167,26 @@ void WSelectList::drawOptionLine(char* text, int xpos, int ypos, int width, cons { char buffer[200]; strncpy(buffer, text, 199); - int currentColumn = 0; + int currentColumn = taboffset; char* pointer; - pointer = strtok(buffer, "\t"); + pointer = strtok(buffer, "\t\n"); while(pointer) { + drawText(pointer, xpos + columns[currentColumn], ypos_mod + curline * fontHeight, width - columns[currentColumn], colour); + + pointer = strtok(NULL, "\t\n"); + if (pointer) { + char delimiter = text[pointer - buffer-1]; + if (delimiter == '\t') currentColumn++; + else if (delimiter == '\n' ){ + currentColumn = taboffset; + curline++; + } + } + if (curline >= linesPerOption) return; - drawText(pointer, xpos + columns[currentColumn], ypos, width - columns[currentColumn], colour); - - currentColumn++; if (currentColumn == 10) return; - pointer = strtok(NULL, "\t"); } } } diff --git a/wselectlist.h b/wselectlist.h index bb98131..212f21e 100644 --- a/wselectlist.h +++ b/wselectlist.h @@ -35,6 +35,7 @@ typedef struct { char* text; ULONG data; + TVMediaInfo *pict; } wsloption; class WSelectList : public Boxx @@ -48,9 +49,10 @@ class WSelectList : public Boxx void setNoLoop(); void setShowSelOption(bool set) { showseloption = set; }; void setDarkSelOption(bool set) { darkseloption = set; }; - int addOption(const char* text, ULONG data, int selected); + int addOption(const char* text, ULONG data, int selected, TVMediaInfo * pict=NULL); void draw(); void setBackgroundColour(const DrawStyle& colour); + void setLinesPerOption(float lines) {linesPerOption=lines;}; void down(); void up(); @@ -71,7 +73,7 @@ class WSelectList : public Boxx virtual bool mouseAndroidScroll(int x, int y,int sx, int sy); private: - void drawOptionLine(char* text, int xpos, int ypos, int width, const DrawStyle& colour); + void drawOptionLine(char* text, int xpos, int ypos, int width, const DrawStyle& colour, TVMediaInfo* pict); int getMouseLine(int x, int y); vector options; @@ -82,6 +84,7 @@ class WSelectList : public Boxx int numColumns; int noLoop; bool showseloption, darkseloption; + float linesPerOption; UINT gap; DrawStyle backgroundColour; diff --git a/wtvmedia.cc b/wtvmedia.cc new file mode 100644 index 0000000..4e16e6c --- /dev/null +++ b/wtvmedia.cc @@ -0,0 +1,63 @@ +/* + Copyright 2004-2005 Chris Tallon, 2014 Marten Richter + + This file is part of VOMP. + + VOMP is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + VOMP is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with VOMP; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ +#include "boxx.h" +#include "wtvmedia.h" + + + + + WTVMedia::WTVMedia() + { + media = false; + scale=NoZoom; + } + + WTVMedia::~WTVMedia() + { + + } + + + + void WTVMedia::setTVMedia(TVMediaInfo & ninfo, Scaling nscale) + { + info = ninfo; + scale = nscale; + media =true; + } + + void WTVMedia::draw() + { + if (!media) return; + float w=0; + float h=0; + switch (scale) + { + case ZoomHorizontal: + w = area.w; break; + case ZoomVertical: + h = area.h; break; + case ZoomBoth: + w = area.w; + h = area.h; break; + } + drawTVMedia(info,0.f,0.f,w,h,TopLeft); + + } diff --git a/wtvmedia.h b/wtvmedia.h new file mode 100644 index 0000000..17708be --- /dev/null +++ b/wtvmedia.h @@ -0,0 +1,55 @@ +/* + Copyright 2004-2005 Chris Tallon, 2014 Marten Richter + + This file is part of VOMP. + + VOMP is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + VOMP is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with VOMP; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#ifndef WTVMEDIA_H +#define WTVMEDIA_H + +#include +#include +#include "boxx.h" + + + + +class WTVMedia : public Boxx +{ + public: + WTVMedia(); + virtual ~WTVMedia(); + + enum Scaling { + NoZoom, + ZoomHorizontal, + ZoomVertical, + ZoomBoth + }; + + void setTVMedia(TVMediaInfo & info, Scaling scale); + void draw(); + + protected: + TVMediaInfo info; + Scaling scale; + bool media; +}; + + + +#endif -- 2.39.5