[skinenigmang] rounds to squares corners & jpeg logos for skinenigmang-0.1.0

Message ID ed9fa2110905020030j6eb2866bq366382a415df7c3f@mail.gmail.com
State New
Headers

Commit Message

jlacvdr May 2, 2009, 7:30 a.m. UTC
  Hi,

attached file: skinenigmang-0.1.0-jlac-corners-090502.diff
- change rounds corners to squares corners.

attached file: skinenigmang-0.1.0-jlac-logos-090502.diff
- replace xpm format by logos in 256colors and jpeg
- simplify the logo filenames on disk: at runtine make it lower case,
without space, without underscore.... so avoid many times the same
logo file (or symbolic link) on the disk
- add a svdr command to check the name logos
- theme added (grey/white/black)

Regards,

JLac
  

Comments

Andreas Mair June 12, 2009, 7:56 a.m. UTC | #1
Hi JLac,

2009/5/2 jlacvdr <jlacvdr@gmail.com>:
> Hi,
>
> attached file: skinenigmang-0.1.0-jlac-corners-090502.diff
> - change rounds corners to squares corners.

Thanks for the idea. I've added (in CVS) a new setup option "General /
Round corners" to disable round corners at runtime.

> attached file: skinenigmang-0.1.0-jlac-logos-090502.diff
> - replace xpm format by logos in 256colors and jpeg

Loading non-XPM channel logos is planed for the (near?) future.

> - simplify the logo filenames on disk: at runtine make it lower case,
> without space, without underscore.... so avoid many times the same
> logo file (or symbolic link) on the disk

I like the idea of lower case filenames. I will change that (soon?).
But I don't know yet if I want to remove character in the channel logo
names.

> - add a svdr command to check the name logos

I like this and will include it soon.

> - theme added (grey/white/black)

It's now in the CVS release. Thanks!

Kind regards,
Andreas

> Regards,
>
> JLac
>
> _______________________________________________
> vdr mailing list
> vdr@linuxtv.org
> http://www.linuxtv.org/cgi-bin/mailman/listinfo/vdr
>
>
  

Patch

diff -bBurN skinenigmang-0.1.0/bitmap.c skinenigmang-0.1.0-logo/bitmap.c
--- skinenigmang-0.1.0/bitmap.c	2009-04-04 08:01:11.000000000 +0200
+++ skinenigmang-0.1.0-logo/bitmap.c	2009-05-02 08:46:25.000000000 +0200
@@ -38,6 +38,15 @@ 
     int w = geo.width();
     int h = geo.height();
     if (height != h || width != w) {
+
+    if( w > h )
+    {
+        height = (h*width)/w;
+    }
+    else
+    {
+        width = (w*height)/h;
+    }
       switch (EnigmaConfig.resizeImages) {
         case 0:
           image.sample(Geometry(width, height));
@@ -65,8 +74,13 @@ 
     }
 
     // center image
-    x += ((width - w) / 2);
-    y += ((height - h) / 2);
+    //x += ((width - w) / 2);
+    //y += ((height - h) / 2);
+    x = 0;
+    y = 0;
+
+    bmp->SetSize(w,h);
+    bmp->DrawRectangle(0,0,w,h,clrTransparent);
 
     const PixelPacket *pix = image.getConstPixels(0, 0, w, h);
     for (int iy = 0; iy < h; ++iy) {
diff -bBurN skinenigmang-0.1.0/common.h skinenigmang-0.1.0-logo/common.h
--- skinenigmang-0.1.0/common.h	2008-03-31 12:43:16.000000000 +0200
+++ skinenigmang-0.1.0-logo/common.h	2009-05-02 08:46:25.000000000 +0200
@@ -21,5 +21,7 @@ 
 #define error(x...) esyslog("EnigmaNG: " x);
 #endif
 
+void simplifyName(const char *orgName,char *name);
+
 #endif // __SKINENIGMA_COMMON_H
 // vim:et:sw=2:ts=2:
diff -bBurN skinenigmang-0.1.0/enigma.c skinenigmang-0.1.0-logo/enigma.c
--- skinenigmang-0.1.0/enigma.c	2009-04-24 14:32:08.000000000 +0200
+++ skinenigmang-0.1.0-logo/enigma.c	2009-05-02 08:46:25.000000000 +0200
@@ -403,7 +403,7 @@ 
 
   // create osd
   osd = cOsdProvider::NewOsd(OsdSize.x, OsdSize.y + (Setup.ChannelInfoPos ? 0 : (OsdSize.h - yBottomBottom)) );
-  tArea SingleArea[] = { {0, 0, xBottomRight - 1, yBottomBottom - 1, fShowLogo || EnigmaConfig.showFlags ? 8 : 4} };
+  tArea SingleArea[] = { {0, 0, xBottomRight - 1, yBottomBottom - 1, 8 } };
   if ((SingleArea[0].bpp < 8 || EnigmaConfig.singleArea8Bpp) && osd->CanHandleAreas(SingleArea, sizeof(SingleArea) / sizeof(tArea)) == oeOk) {
     debug("cSkinEnigmaDisplayChannel: using %dbpp single area", SingleArea[0].bpp);
     osd->SetAreas(SingleArea, sizeof(SingleArea) / sizeof(tArea));
@@ -799,10 +799,11 @@ 
       osd->DrawRectangle(xLogoDecoLeft, yLogoTop, xLogoDecoRight - 1, yLogoBottom - 1, Theme.Color(clrLogoBg));
 
       if (EnigmaLogoCache.LoadChannelLogo(Channel)) {
-        osd->DrawBitmap(xLogoLeft + (xLogoRight - xLogoLeft - ChannelLogoWidth) / 2,
-                        yLogoTop + (yLogoBottom - yLogoTop - ChannelLogoHeight) / 2,
-                        EnigmaLogoCache.Get(), EnigmaLogoCache.Get().Color(1),
-                        Theme.Color(clrLogoBg), true);
+        int lw = EnigmaLogoCache.Get().Width();
+        int lh = EnigmaLogoCache.Get().Height();
+        osd->DrawBitmap(xLogoLeft + (xLogoRight - xLogoLeft - lw) / 2,
+                        yLogoTop + (yLogoBottom - yLogoTop - lh) / 2,
+                        EnigmaLogoCache.Get(), 0, 0, true);
       }
     }
 
@@ -3194,7 +3195,7 @@ 
       // set colors
       bitmap->Reset();
       bitmap->SetColor(0, Theme.Color(clrTransparent));
-      bitmap->SetColor(1, Theme.Color(clrBackground));
+      bitmap->SetColor(1, Theme.Color(clrAltBackground));
       bitmap->SetColor(2, Theme.Color(clrTitleBg));
       bitmap->SetColor(3, Theme.Color(clrBottomBg));
       bitmap->SetColor(4, Theme.Color(clrVolumeBar));
@@ -3214,7 +3215,7 @@ 
   osd->DrawRectangle(xTitleLeft, yTitleDecoTop, xTitleRight - 1, yTitleDecoBottom - 1, Theme.Color(clrTitleBg));
   osd->DrawEllipse(xTitleRight - Roundness, yTitleTop, xTitleRight - 1, yTitleTop + Roundness - 1, clrTransparent, -1);
   // draw body area
-  osd->DrawRectangle(xBodyLeft, yBodyTop, xBodyRight - 1, yBodyBottom - 1, Theme.Color(clrBackground));
+  osd->DrawRectangle(xBodyLeft, yBodyTop, xBodyRight - 1, yBodyBottom - 1, Theme.Color(clrAltBackground));
   // draw bottom area
   osd->DrawRectangle(xBottomLeft, yBottomTop, xBottomRight - 1, yBottomBottom - 1, Theme.Color(clrBottomBg));
   osd->DrawEllipse(xBottomRight - Roundness, yBottomBottom - Roundness, xBottomRight - 1, yBottomBottom - 1, clrTransparent, -4);
@@ -3264,7 +3265,7 @@ 
                 xTitleRight - Roundness - xTitleLeft, pFontOsdTitle->Height(), taCenter);
   // draw volumebar
   osd->DrawRectangle(xBodyLeft + Gap, yBodyTop + Gap, xBodyRight - Gap - 1,
-                     yBodyBottom - Gap - 1, Theme.Color(clrBackground));
+                     yBodyBottom - Gap - 1, Theme.Color(clrAltBackground));
   osd->DrawRectangle(xBodyLeft + Gap, yBodyTop + Gap, vol - 1,
                      yBodyBottom - Gap - 1, ColorBar);
 }
diff -bBurN skinenigmang-0.1.0/logo.c skinenigmang-0.1.0-logo/logo.c
--- skinenigmang-0.1.0/logo.c	2008-11-13 12:51:23.000000000 +0100
+++ skinenigmang-0.1.0-logo/logo.c	2009-05-02 08:46:25.000000000 +0200
@@ -90,42 +90,56 @@ 
 #endif
 }
 
+void simplifyName(const char *orgName,char *name)
+{
+    char ac;
+
+    while( *orgName != 0 )
+    {
+        ac = *orgName;
+        if( isalnum( ac ) )
+        {
+            if( isupper( ac ) )
+                ac = tolower( ac );
+
+            *name = ac;
+            *name++;
+        }
+        *orgName++;
+    }
+    *name = 0;
+}
+
 bool cEnigmaLogoCache::LoadChannelLogo(const cChannel *Channel)
 {
   if (Channel == NULL)
     return false;
 
   bool fFoundLogo = false;
-  const char *logoname = NULL;
-  char *strLogo = NULL;
   char *filename = NULL;
 
   char *strChannelID = EnigmaConfig.useChannelId && !Channel->GroupSep() ? strdup(*Channel->GetChannelID().ToString()) : NULL;
-  logoname = EnigmaConfig.useChannelId && !Channel->GroupSep() ? strChannelID : Channel->Name();
-  if (logoname == NULL) goto leave;
-
-  strLogo = strreplace(strdup(logoname), '/', '~');
-  if (strLogo == NULL) goto leave;
-
-  filename = (char *)malloc(strlen(strLogo) + 20 /* should be enough for folder */);
-  if (filename == NULL) goto leave;
-
+  const char *Chlogoname = EnigmaConfig.useChannelId && !Channel->GroupSep() ? strChannelID : Channel->Name();
+  if (Chlogoname != NULL ) {
+    char logoname[64];
+    simplifyName(Chlogoname,logoname);
+    debug("cPluginSkinEnigma::LoadChannelLogo() '%s' -> '%s'\n",Chlogoname,logoname);
+    char *filename = (char *)malloc(strlen(logoname) + 20 /* should be enough for folder */);
+    if (filename != NULL) {
   strcpy(filename, "hqlogos/");
-  strcat(filename, strLogo);
+      strcat(filename, logoname);
   if (!(fFoundLogo = Load(filename, ChannelLogoWidth, ChannelLogoHeight, false))) {
     strcpy(filename, "logos/");
-    strcat(filename, strLogo);
+        strcat(filename, logoname);
     if (!(fFoundLogo = Load(filename, ChannelLogoWidth, ChannelLogoHeight, false))) {
-      error("cPluginSkinEnigma::LoadChannelLogo: LOGO \"%s.xpm\" NOT FOUND in %s/[hq]logos", strLogo, EnigmaConfig.GetLogoDir());
+          error("cPluginSkinEnigma::LoadChannelLogo: LOGO \"%s.jpg\" NOT FOUND in %s/[hq]logos", logoname, EnigmaConfig.GetLogoDir());
       fFoundLogo = Load("hqlogos/no_logo", ChannelLogoWidth, ChannelLogoHeight); //TODO? different default logo for channel/group?
     }
   }
-
-leave:
   free(filename);
-  free(strLogo);
+    }
+  }
   free(strChannelID);
-
   return fFoundLogo;
 }
 
@@ -145,7 +159,7 @@ 
     return false;
 
   char *strFilename;
-  asprintf(&strFilename, "%s/%s.xpm", EnigmaConfig.GetLogoDir(), fileNameP);
+  asprintf(&strFilename, "%s/%s.jpg", EnigmaConfig.GetLogoDir(), fileNameP);
   if (strFilename == NULL)
     return false;
 
@@ -166,8 +180,10 @@ 
   } else {
     // no - cache miss!
     debug("cPluginSkinEnigma::Load() CACHE MISS!");
-    // try to load xpm logo
-    if (!LoadXpm(strFilename, w, h, fLogNotFound))
+//    // try to load xpm logo
+//    if (!LoadXpm(strFilename, w, h, fLogNotFound))
+//      return false;
+    if (!LoadJpg(strFilename, w, h, fLogNotFound))
       return false;
     // check if cache is active
     if (cacheSizeM) {
@@ -204,6 +220,41 @@ 
   return *bitmapM;
 }
 
+bool cEnigmaLogoCache::LoadJpg(const char *fileNameP, int w, int h, bool fLogNotFound)
+{
+  if (fileNameP == NULL)
+    return false;
+
+  struct stat stbuf;
+  cBitmap *bmp = new cBitmap(1, 1, 8);
+
+  // create absolute filename
+  debug("cPluginSkinEnigma::LoadJpg(%s)", fileNameP);
+  // check validity
+  if(lstat(fileNameP, &stbuf) == 0)
+  {
+      DrawImage(fileNameP,0,0,80,80,230,bmp);
+
+    if ((bmp->Width() <= w) && (bmp->Height() <= h)) {
+      int numColors;
+      bmp->Colors(numColors);
+      error("cPluginSkinEnigma::LoadJpg(%s) : %d colors",fileNameP, numColors );
+      debug("cPluginSkinEnigma::LoadJpg(%s) LOGO FOUND", fileNameP);
+      // assign bitmap
+      bitmapM = bmp;
+      return true;
+    } else {
+      // wrong size
+      error("cPluginSkinEnigma::LoadJpg(%s) LOGO HAS WRONG SIZE %d/%d (%d/%d)", fileNameP, bmp->Width(), bmp->Height(), w, h);
+    }
+  }
+
+  delete bmp;
+  bitmapM = NULL;
+  return false;
+}
+
+
 bool cEnigmaLogoCache::LoadXpm(const char *fileNameP, int w, int h, bool fLogNotFound)
 {
   if (fileNameP == NULL)
diff -bBurN skinenigmang-0.1.0/logo.h skinenigmang-0.1.0-logo/logo.h
--- skinenigmang-0.1.0/logo.h	2008-02-25 09:32:56.000000000 +0100
+++ skinenigmang-0.1.0-logo/logo.h	2009-05-02 08:46:25.000000000 +0200
@@ -42,6 +42,7 @@ 
   std::map<std::string, cBitmap*> cacheMapM;
   bool DrawImage(const char *fileNameP, int x, int y, int w, int h, int c, cBitmap *bmp);
   bool LoadXpm(const char *fileNameP, int w, int h, bool fLogNotFound = true);
+  bool LoadJpg(const char *fileNameP, int w, int h, bool fLogNotFound = true);
   bool Load(const char *fileNameP, int w, int h, bool fLogNotFound = true);
 public:
   cEnigmaLogoCache(unsigned int cacheSizeP);
diff -bBurN skinenigmang-0.1.0/Makefile skinenigmang-0.1.0-logo/Makefile
--- skinenigmang-0.1.0/Makefile	2009-04-10 20:30:26.000000000 +0200
+++ skinenigmang-0.1.0-logo/Makefile	2009-05-02 08:46:25.000000000 +0200
@@ -12,7 +12,7 @@ 
 
 # If you have installed ImageMagick and want to use
 # images in event's and recording's details.
-#HAVE_IMAGEMAGICK = 1
+HAVE_IMAGEMAGICK = 1
 
 # If you are using the epgsearch plugin and want to see the number of
 # timer conflicts in the main menu's info area.
diff -bBurN skinenigmang-0.1.0/skinenigmang.c skinenigmang-0.1.0-logo/skinenigmang.c
--- skinenigmang-0.1.0/skinenigmang.c	2009-04-24 14:32:32.000000000 +0200
+++ skinenigmang-0.1.0-logo/skinenigmang.c	2009-05-02 08:47:54.000000000 +0200
@@ -20,7 +20,7 @@ 
 #endif
 
 
-static const char VERSION[] = "0.1.0";
+static const char VERSION[] = "0.1.0-jlac";
 static const char DESCRIPTION[] = trNOOP("EnigmaNG skin");
 
 class cPluginSkinEnigma : public cPlugin {
@@ -28,6 +28,7 @@ 
   bool fLogodirSet;
   bool fImagesDirSet;
 
+  cString SVDRPCommand_CHECKLOGOS( char *param, int &replyCode );
 public:
   cPluginSkinEnigma(void);
   virtual ~cPluginSkinEnigma();
@@ -268,11 +269,77 @@ 
   return NULL;
 }
 
-cString cPluginSkinEnigma::SVDRPCommand(const char * /* Command */, const char * /* Option */, int & /* ReplyCode */)
+cString cPluginSkinEnigma::SVDRPCommand(const char *Command , const char *Option , int &ReplyCode )
 {
+    char param[strlen( Option ) + 1];
+    strcpy( param, Option );
+    cString strRet;
+
+    if( strcasecmp( Command, "CHECKLOGOS" ) == 0 )
+    {
+        strRet = SVDRPCommand_CHECKLOGOS( param, ReplyCode );
+        return ( strRet );
+    }
+
   // process SVDRP commands this plugin implements
   return NULL;
 }
 
+cString cPluginSkinEnigma::SVDRPCommand_CHECKLOGOS( char *param, int &replyCode )
+{
+    char logoname[512];
+    char filename[512];
+    int i = 1;
+    int nbOk=0,nbKo=0,nbTt=0;
+    FILE *fLog;
+
+    fLog = fopen("/tmp/checklogos.log","wt");
+
+//    while( i <= Channels.MaxNumber(  ) )
+    while( i <= 200 )
+    {
+        cChannel *aChannel = Channels.GetByNumber( i, 1 );
+        if( aChannel )
+        {
+            char *strChannelID = EnigmaConfig.useChannelId && !aChannel->GroupSep() ? strdup(*aChannel->GetChannelID().ToString()) : NULL;
+            const char *Chlogoname = EnigmaConfig.useChannelId && !aChannel->GroupSep() ? strChannelID : aChannel->Name();
+            if (Chlogoname)
+            {
+                struct stat stbuf;
+                simplifyName(Chlogoname,logoname);
+                // create absolute filename
+                snprintf(filename,500, "%s/hqlogos/%s.jpg", EnigmaConfig.GetLogoDir(), logoname);
+                // check validity
+                nbTt++;
+                if(lstat(filename, &stbuf) == 0)
+                {
+                    nbOk++;
+                    if( fLog != NULL ) fprintf(fLog,"%d:'%s' : '%s' : found\n",aChannel->Number(  ),Chlogoname,filename );
+                }
+                else
+                {
+                    snprintf(filename,500, "%s/logos/%s.jpg", EnigmaConfig.GetLogoDir(), logoname);
+                    if(lstat(filename, &stbuf) == 0)
+                    {
+                        nbOk++;
+                        if( fLog != NULL ) fprintf(fLog,"%d:'%s' : '%s' : found\n",aChannel->Number(  ),Chlogoname,filename );
+                    }
+                    else
+                    {
+                        nbKo++;
+                        if( fLog != NULL ) fprintf(fLog,"%d:'%s' : '%s/[hq]logos/%s.jpg' : missing\n",aChannel->Number(  ),Chlogoname, EnigmaConfig.GetLogoDir(), logoname );
+                    }
+                }
+            }
+        }
+        i = aChannel->Number(  ) + 1;
+    }
+    fclose(fLog);
+    return( cString::sprintf( "checksLogos found:%d/%d  missing:%d/%d", nbOk,nbTt, nbKo, nbTt ) );
+}
+
+
+
+
 VDRPLUGINCREATOR(cPluginSkinEnigma);    // don't touch this!
 // vim:et:sw=2:ts=2:
diff -bBurN skinenigmang-0.1.0/themes/EnigmaNG-bgw.theme skinenigmang-0.1.0-logo/themes/EnigmaNG-bgw.theme
--- skinenigmang-0.1.0/themes/EnigmaNG-bgw.theme	1970-01-01 01:00:00.000000000 +0100
+++ skinenigmang-0.1.0-logo/themes/EnigmaNG-bgw.theme	2009-05-02 08:46:25.000000000 +0200
@@ -0,0 +1,48 @@ 
+Description = bgw
+clrBackground = E5DCDCDC
+clrAltBackground = E5A9A9A9
+clrTitleBg = E5333333
+clrLogoBg = E5707070
+clrBottomBg = E5333333
+clrBotProgBarBg = FF808080
+clrBotProgBarFg = FFDCDCDC
+clrTitleFg = FFDCDCDC
+clrTitleShadow = FF000000
+clrMenuTxtFg = FF000000
+clrMenuItemSelectableFg = FF202020
+clrMenuItemNotSelectableFg = E5404040
+clrVolumeBar = FFDCDCDC
+clrVolumeBarMute = E5A9A9A9
+clrSymbolActive = FFF0F0F0
+clrSymbolInactive = FF808080
+clrSymbolRecord = FFC40000
+clrSymbolRecordBg = FFFFFFFF
+clrSymbolTimerActive = FF0000C4
+clrSymbolVpsActive = FFC4C400
+clrSymbolRecActive = FFC40000
+clrSymbolRunActive = FF00C400
+clrButtonRedFg = FFFFFFFF
+clrButtonRedBg = E5C40000
+clrButtonGreenFg = FF000000
+clrButtonGreenBg = E500C400
+clrButtonYellowFg = FF000000
+clrButtonYellowBg = E5C4C400
+clrButtonBlueFg = FFFFFFFF
+clrButtonBlueBg = E50000C4
+clrMessageStatusFg = FF000000
+clrMessageStatusBg = E5D7FFD1
+clrMessageInfoFg = FF000000
+clrMessageInfoBg = E5D1DDFF
+clrMessageWarningFg = FF000000
+clrMessageWarningBg = E5F9FFD1
+clrMessageErrorFg = FF000000
+clrMessageErrorBg = E5FFD1D1
+clrReplayCurrent = FF1D2F7D
+clrReplayTotal = FF1D2F7D
+clrReplayModeJump = FF1D2F7D
+clrReplayBarAreaBg = E5DEE5FA
+clrReplayProgressSeen = FF8EA4E3
+clrReplayProgressRest = E5DEE5FA
+clrReplayProgressSelected = FF4158BC
+clrReplayProgressMark = FF4158BC
+clrReplayProgressCurrent = FFFF0000