r3231 - in software/ui: data src

Miriam Ruiz baby-guest at alioth.debian.org
Wed Jul 4 13:45:31 UTC 2007


Author: baby-guest
Date: 2007-07-04 13:45:31 +0000 (Wed, 04 Jul 2007)
New Revision: 3231

Added:
   software/ui/data/no_screenshot.alpha.png
   software/ui/data/stars_border.big.png
   software/ui/data/stars_on.alpha.png
   software/ui/data/stars_on.png
   software/ui/data/starts_filled.big.png
   software/ui/data/starts_off.alpha.png
   software/ui/data/starts_off.big.png
   software/ui/data/starts_off.png
   software/ui/data/starts_on.big.png
Modified:
   software/ui/data/no_screenshot.png
   software/ui/src/common.h
   software/ui/src/games.cpp
   software/ui/src/pkgbrowser.cpp
   software/ui/src/pkgbrowser.h
Log:
Skeleton for the graphical visualization of popcon stats



Added: software/ui/data/no_screenshot.alpha.png
===================================================================
(Binary files differ)


Property changes on: software/ui/data/no_screenshot.alpha.png
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Modified: software/ui/data/no_screenshot.png
===================================================================
(Binary files differ)

Added: software/ui/data/stars_border.big.png
===================================================================
(Binary files differ)


Property changes on: software/ui/data/stars_border.big.png
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: software/ui/data/stars_on.alpha.png
===================================================================
(Binary files differ)


Property changes on: software/ui/data/stars_on.alpha.png
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: software/ui/data/stars_on.png
===================================================================
(Binary files differ)


Property changes on: software/ui/data/stars_on.png
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: software/ui/data/starts_filled.big.png
===================================================================
(Binary files differ)


Property changes on: software/ui/data/starts_filled.big.png
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: software/ui/data/starts_off.alpha.png
===================================================================
(Binary files differ)


Property changes on: software/ui/data/starts_off.alpha.png
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: software/ui/data/starts_off.big.png
===================================================================
(Binary files differ)


Property changes on: software/ui/data/starts_off.big.png
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: software/ui/data/starts_off.png
===================================================================
(Binary files differ)


Property changes on: software/ui/data/starts_off.png
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: software/ui/data/starts_on.big.png
===================================================================
(Binary files differ)


Property changes on: software/ui/data/starts_on.big.png
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Modified: software/ui/src/common.h
===================================================================
--- software/ui/src/common.h	2007-07-04 10:03:19 UTC (rev 3230)
+++ software/ui/src/common.h	2007-07-04 13:45:31 UTC (rev 3231)
@@ -37,6 +37,14 @@
 #define FILE_NO_SCREENSHOT DATADIR "/no_screenshot.png"
 #endif
 
+#ifndef FILE_STARS_ON
+#define FILE_STARS_ON DATADIR "/stars_on.png"
+#endif
+
+#ifndef FILE_STARS_OFF
+#define FILE_STARS_OFF DATADIR "/stars_off.png"
+#endif
+
 #ifndef THUMBNAILSDIR
 #define THUMBNAILSDIR DATADIR "/screenshots"
 #endif

Modified: software/ui/src/games.cpp
===================================================================
--- software/ui/src/games.cpp	2007-07-04 10:03:19 UTC (rev 3230)
+++ software/ui/src/games.cpp	2007-07-04 13:45:31 UTC (rev 3231)
@@ -161,13 +161,13 @@
 	{
 		ui.ResultsBrowser->column_widths(widths_with_popcon);
 		// tab delimited columns with colors
-		ui.ResultsBrowser->add("@B12 at C7@b at .PACKAGE\t at B12@C7 at b@.DESCRIPTION\t at B12@C7 at b@.POPCON");
+		ui.ResultsBrowser->add(_("@B12 at C7@b at .PACKAGE\t at B12@C7 at b@.DESCRIPTION\t at B12@C7 at b@.POPCON"));
 	}
 	else
 	{
 		ui.ResultsBrowser->column_widths(widths_without_popcon);
 		// tab delimited columns with colors
-		ui.ResultsBrowser->add("@B12 at C7@b at .PACKAGE\t at B12@C7 at b@.DESCRIPTION");
+		ui.ResultsBrowser->add(_("@B12 at C7@b at .PACKAGE\t at B12@C7 at b@.DESCRIPTION"));
 	}
 
 	// FIXME: there are better ways to remember the previous item
@@ -205,10 +205,9 @@
 		string desc = rec.package() + "\t" + rec.shortDescription();
 		if (engine.popcon().hasData())
 		{
-			desc += "\t*";
+			desc += "\t#";
 			int stars = (int)rintf(i->popcon * 4 / engine.popconLocalMax());
-			for (int j = 0; j < stars; ++j)
-				desc += '*';
+			for (int j = 0; j < stars; ++j) desc += '*';
 			printf ("%s (%s): POPCON=%f\n", rec.package().c_str(), rec.shortDescription().c_str(), i->popcon);
 		}
 		ui.ResultsBrowser->add(desc.c_str(), userData);

Modified: software/ui/src/pkgbrowser.cpp
===================================================================
--- software/ui/src/pkgbrowser.cpp	2007-07-04 10:03:19 UTC (rev 3230)
+++ software/ui/src/pkgbrowser.cpp	2007-07-04 13:45:31 UTC (rev 3231)
@@ -4,7 +4,14 @@
  * VersatileBrowser uses ColResizeBrowser, written by Greg Ercolano
  * ColResizeBrowser (C) Greg Ercolano <erco at seriss.com>
  * URL: http://seriss.com/people/erco/fltk/
+ * GNU GPL License (version 2 or, at your option, any later version)
  *
+ * PackageBrowser::item_draw uses code from FLTK 1.1 Fl_Browser.cxx
+ * Browser widget for the Fast Light Tool Kit (FLTK).
+ * Copyright 1998-2005 by Bill Spitzak and others.
+ * URL: http://www.fltk.org/
+ * GNU LGPL License (version 2 or, at your option, any later version)
+ *
  * This program 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
@@ -46,13 +53,21 @@
 using namespace ept::textsearch;
 
 PackageBrowser::PackageBrowser(int x, int y, int w, int h, const char *l)
-	: VersatileBrowser(x, y, w, h, l)
+	: VersatileBrowser(x, y, w, h, l), stars_on(NULL), stars_off(NULL)
 {
 	showcolsep(1);
 	//colsepcolor(FL_RED);
 	column_char('\t'); // tabs as column delimiters
+	stars_on = new Fl_PNG_Image(FILE_STARS_ON);
+	stars_off = new Fl_PNG_Image(FILE_STARS_OFF);
 }
 
+PackageBrowser::~PackageBrowser()
+{
+	if (stars_on) delete stars_on;
+	if (stars_off) delete stars_off;
+}
+
 void PackageBrowser::item_select(void *p, int s)
 {
 	VersatileBrowser::item_select(p, s);
@@ -134,7 +149,7 @@
 			ui->DebTagsBrowser->clear();
 			ui->DebTagsBrowser->showcolsep(1);
 			ui->DebTagsBrowser->column_widths(widths);
-			ui->DebTagsBrowser->add("@B12 at C7@b at .FACET\t at B12@C7 at b@.TAG");
+			ui->DebTagsBrowser->add(_("@B12 at C7@b at .FACET\t at B12@C7 at b@.TAG"));
 
 			set<Tag> tags = ui->engine->debtags().getTagsOfItem((const char *)data);
 			char *tag_txt = new char[512];
@@ -153,9 +168,100 @@
 	}
 }
 
+void PackageBrowser::item_draw(void *p, int x, int y, int w, int h) const
+{
+	//printf("PackageBrowser::item_draw(p=0x%lX, x=%d, y=%d, w=%d, h=%d)\n", (unsigned long)p, x, y, w, h);
+	int n = VersatileBrowser::lineno(p);
+	//void *data = VersatileBrowser::data(n);
+	//printf("   data=\"%s\"\n", (char *)data);
+	char *text = strdup(VersatileBrowser::text(n));
+	char *str = text;
+	const int* i = column_widths();
+
+	while (w > 6)
+	{	// do each tab-seperated field
+		int w1 = w;	// width for this field
+		char* e = 0; // pointer to end of field or null if none
+		if (*i)
+		{ // find end of field and temporarily replace with 0
+			e = strchr(str, column_char());
+			if (e) {*e = 0; w1 = *i++;}
+		}
+		int tsize = textsize();
+		Fl_Font font = textfont();
+		Fl_Color lcol = textcolor();
+		Fl_Align talign = FL_ALIGN_LEFT;
+		// check for all the @-lines recognized by XForms:
+		while (*str == format_char() && *++str && *str != format_char())
+		{
+			switch (*str++)
+			{
+				case 'l': case 'L': tsize = 24; break;
+				case 'm': case 'M': tsize = 18; break;
+				case 's': tsize = 11; break;
+				case 'b': font = (Fl_Font)(font|FL_BOLD); break;
+				case 'i': font = (Fl_Font)(font|FL_ITALIC); break;
+				case 'f': case 't': font = FL_COURIER; break;
+				case 'c': talign = FL_ALIGN_CENTER; break;
+				case 'r': talign = FL_ALIGN_RIGHT; break;
+				case 'B': 
+					if (!item_selected(p))
+					{
+						fl_color((Fl_Color)strtol(str, &str, 10));
+						fl_rectf(x, y, w1, h);
+					}
+					else
+						strtol(str, &str, 10);
+					break;
+				case 'C': lcol = (Fl_Color)strtol(str, &str, 10); break;
+				case 'F': font = (Fl_Font)strtol(str, &str, 10); break;
+				case 'N': lcol = FL_INACTIVE_COLOR; break;
+				case 'S': tsize = strtol(str, &str, 10); break;
+				case '-':
+					fl_color(FL_DARK3);
+					fl_line(x + 3, y + h/2, x + w1 - 3, y + h/2);
+					fl_color(FL_LIGHT3);
+					fl_line(x + 3, y + h/2 + 1, x + w1 - 3, y + h/2 + 1);
+					break;
+				case 'u':
+				case '_':
+					fl_color(lcol);
+					fl_line(x + 3, y + h - 1, x + w1 - 3, y + h - 1);
+					break;
+				case '.': goto BREAK;
+				case '@': str--; goto BREAK;
+			}
+		}
+
+	BREAK:
+		if (*str=='#')
+		{
+			if (stars_on)
+				stars_on->draw(x + 3, y, w1-6, h, 0, 0);
+		}
+		else
+		{
+			fl_font(font, tsize);
+			if (item_selected(p))
+				lcol = fl_contrast(lcol, selection_color());
+			if (!active_r()) lcol = fl_inactive(lcol);
+			fl_color(lcol);
+			fl_draw(str, x + 3, y, w1-6, h, e ? Fl_Align(talign|FL_ALIGN_CLIP) : talign, 0, 0);
+		}
+
+		if (!e) break; // no more fields...
+		*e = column_char(); // put the seperator back
+		x += w1;
+		w -= w1;
+		str = e+1;
+	}
+
+	free (text);
+}
+
 int PackageBrowser::handle(int e)
 {
-//	printf("PackageBrowser::handle(int e = 0x%X)\n", e);
+//	printf("PackageBrowser::handle(int e = 0x%)\n", e);
 //	fflush(stdout);
 
 	int ret = VersatileBrowser::handle(e);

Modified: software/ui/src/pkgbrowser.h
===================================================================
--- software/ui/src/pkgbrowser.h	2007-07-04 10:03:19 UTC (rev 3230)
+++ software/ui/src/pkgbrowser.h	2007-07-04 13:45:31 UTC (rev 3231)
@@ -4,6 +4,7 @@
  * VersatileBrowser uses ColResizeBrowser, written by Greg Ercolano
  * ColResizeBrowser (C) Greg Ercolano <erco at seriss.com>
  * URL: http://seriss.com/people/erco/fltk/
+ * GNU GPL License (version 2 or, at your option, any later version)
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -199,10 +200,16 @@
 {
 public:
 	PackageBrowser(int x, int y, int w, int h, const char *l = NULL);
+	virtual ~PackageBrowser();
 
-private:
+protected:
 	virtual void item_select(void *p, int s=1);
+	virtual void item_draw(void *p, int x, int y, int w, int h)  const;
 	virtual int handle(int e);
+
+private:
+	Fl_Image *stars_on;
+	Fl_Image *stars_off;
 };
 
 class PackageView : public Fl_Help_View




More information about the Pkg-games-commits mailing list