Revision: 1425
http://geeqie.svn.sourceforge.net/geeqie/?rev=1425&view=rev
Author: zas_
Date: 2009-02-26 20:50:36 +0000 (Thu, 26 Feb 2009)
Log Message:
-----------
Clean up histogram stuff: options saving/restoring, osd histogram separation,
tidy up.
Modified Paths:
--------------
trunk/src/bar_histogram.c
trunk/src/histogram.c
trunk/src/image-overlay.c
trunk/src/options.c
trunk/src/options.h
trunk/src/rcfile.c
trunk/src/typedefs.h
Modified: trunk/src/bar_histogram.c
===================================================================
--- trunk/src/bar_histogram.c 2009-02-26 17:34:14 UTC (rev 1424)
+++ trunk/src/bar_histogram.c 2009-02-26 20:50:36 UTC (rev 1425)
@@ -40,8 +40,6 @@
Histogram *histogram;
gint histogram_width;
gint histogram_height;
- gint histogram_channel;
- gint histogram_logmode;
GdkPixbuf *pixbuf;
FileData *fd;
};
@@ -91,8 +89,8 @@
indent++;
WRITE_CHAR(*phd, pane.title);
WRITE_BOOL(*phd, pane.expanded);
- WRITE_INT(*phd, histogram_channel);
- WRITE_INT(*phd, histogram_logmode);
+ WRITE_INT(*phd->histogram, histogram_channel);
+ WRITE_INT(*phd->histogram, histogram_mode);
indent--;
WRITE_STRING("/>\n");
}
@@ -167,7 +165,6 @@
if (channel == histogram_get_channel(phd->histogram)) return;
histogram_set_channel(phd->histogram, channel);
- phd->histogram_channel = channel;
bar_pane_histogram_update(phd);
}
@@ -186,7 +183,6 @@
if (logmode == histogram_get_mode(phd->histogram)) return;
histogram_set_mode(phd->histogram, logmode);
- phd->histogram_logmode = logmode;
bar_pane_histogram_update(phd);
}
@@ -294,7 +290,7 @@
}
-GtkWidget *bar_pane_histogram_new(const gchar *title, gint height, gint
expanded, gint histogram_channel, gint histogram_logmode)
+GtkWidget *bar_pane_histogram_new(const gchar *title, gint height, gint
expanded, gint histogram_channel, gint histogram_mode)
{
PaneHistogramData *phd;
@@ -308,7 +304,7 @@
phd->histogram = histogram_new();
histogram_set_channel(phd->histogram, histogram_channel);
- histogram_set_mode(phd->histogram, histogram_logmode);
+ histogram_set_mode(phd->histogram, histogram_mode);
phd->widget = gtk_vbox_new(FALSE, PREF_PAD_GAP);
@@ -345,7 +341,7 @@
gboolean expanded = TRUE;
gint height = 80;
gint histogram_channel = HCHAN_RGB;
- gint histogram_logmode = 0;
+ gint histogram_mode = 0;
while (*attribute_names)
{
@@ -355,13 +351,13 @@
if (READ_CHAR_FULL("pane.title", title)) continue;
if (READ_BOOL_FULL("pane.expanded", expanded)) continue;
if (READ_INT_FULL("histogram_channel", histogram_channel))
continue;
- if (READ_INT_FULL("histogram_logmode", histogram_logmode))
continue;
+ if (READ_INT_FULL("histogram_mode", histogram_mode)) continue;
DEBUG_1("unknown attribute %s = %s", option, value);
}
- return bar_pane_histogram_new(title, height, expanded,
histogram_channel, histogram_logmode);
+ return bar_pane_histogram_new(title, height, expanded,
histogram_channel, histogram_mode);
}
Modified: trunk/src/histogram.c
===================================================================
--- trunk/src/histogram.c 2009-02-26 17:34:14 UTC (rev 1424)
+++ trunk/src/histogram.c 2009-02-26 20:50:36 UTC (rev 1425)
@@ -32,27 +32,14 @@
gulong max[HISTMAP_SIZE];
};
-struct _Histogram {
- gint channel_mode; /* drawing mode for histogram */
- gint log_mode; /* logarithmical or not */
- guint vgrid; /* number of vertical divisions, 0 for none */
- guint hgrid; /* number of horizontal divisions, 0 for none */
- struct {
- int R; /* red */
- int G; /* green */
- int B; /* blue */
- int A; /* alpha */
- } grid_color; /* grid color */
-};
-
Histogram *histogram_new(void)
{
Histogram *histogram;
histogram = g_new0(Histogram, 1);
- histogram->channel_mode = options->histogram.last_channel_mode;
- histogram->log_mode = options->histogram.last_log_mode;
+ histogram->histogram_channel = HCHAN_RGB;
+ histogram->histogram_mode = 0;
/* grid */
histogram->vgrid = 5;
@@ -74,27 +61,27 @@
gint histogram_set_channel(Histogram *histogram, gint chan)
{
if (!histogram) return 0;
- options->histogram.last_channel_mode = histogram->channel_mode = chan;
+ histogram->histogram_channel = chan;
return chan;
}
gint histogram_get_channel(Histogram *histogram)
{
if (!histogram) return 0;
- return histogram->channel_mode;
+ return histogram->histogram_channel;
}
gint histogram_set_mode(Histogram *histogram, gint mode)
{
if (!histogram) return 0;
- options->histogram.last_log_mode = histogram->log_mode = mode;
+ histogram->histogram_mode = mode;
return mode;
}
gint histogram_get_mode(Histogram *histogram)
{
if (!histogram) return 0;
- return histogram->log_mode;
+ return histogram->histogram_mode;
}
gint histogram_toggle_channel(Histogram *histogram)
@@ -115,8 +102,8 @@
if (!histogram) return NULL;
- if (histogram->log_mode)
- switch (histogram->channel_mode)
+ if (histogram->histogram_mode)
+ switch (histogram->histogram_channel)
{
case HCHAN_R: t1 = _("logarithmical histogram on
red"); break;
case HCHAN_G: t1 = _("logarithmical histogram on
green"); break;
@@ -125,7 +112,7 @@
case HCHAN_MAX: t1 = _("logarithmical histogram on max
value"); break;
}
else
- switch (histogram->channel_mode)
+ switch (histogram->histogram_channel)
{
case HCHAN_R: t1 = _("linear histogram on red");
break;
case HCHAN_G: t1 = _("linear histogram on green");
break;
@@ -277,15 +264,13 @@
for (j = 0; j < 4; j++)
{
- gint k;
- gint chanmax = 0;
+ gint chanmax = HCHAN_R;
- for (k = 1; k < 3; k++)
- if (v[k] > v[chanmax])
- chanmax = k;
+ if (v[HCHAN_G] > v[HCHAN_R]) chanmax = HCHAN_G;
+ if (v[HCHAN_B] > v[HCHAN_G]) chanmax = HCHAN_B;
- if (histogram->channel_mode >= HCHAN_RGB
- || chanmax == histogram->channel_mode)
+ if (histogram->histogram_channel >= HCHAN_RGB
+ || chanmax == histogram->histogram_channel)
{
gulong pt;
gint r = rplus;
@@ -294,28 +279,28 @@
switch (chanmax)
{
- case 0: rplus = r = 255; break;
- case 1: gplus = g = 255; break;
- case 2: bplus = b = 255; break;
+ case HCHAN_R: rplus = r = 255; break;
+ case HCHAN_G: gplus = g = 255; break;
+ case HCHAN_B: bplus = b = 255; break;
}
- switch (histogram->channel_mode)
+ switch (histogram->histogram_channel)
{
case HCHAN_RGB:
if (r == 255 && g == 255 && b
== 255)
{
- r = 0; b = 0; g = 0;
+ r = 0; b = 0; g = 0;
}
break;
- case HCHAN_R: b = 0; g = 0; break;
- case HCHAN_G: r = 0; b = 0; break;
- case HCHAN_B: r = 0; g = 0; break;
- case HCHAN_MAX: r = 0; b = 0; g = 0;
break;
+ case HCHAN_R: b = 0; g = 0;
break;
+ case HCHAN_G: r = 0; b = 0;
break;
+ case HCHAN_B: r = 0; g = 0;
break;
+ case HCHAN_MAX: r = 0; b = 0; g = 0;
break;
}
if (v[chanmax] == 0)
pt = 0;
- else if (histogram->log_mode)
+ else if (histogram->histogram_mode)
pt = ((gdouble)log(v[chanmax])) /
logmax * (height - 1);
else
pt = ((gdouble)v[chanmax]) / max *
(height - 1);
Modified: trunk/src/image-overlay.c
===================================================================
--- trunk/src/image-overlay.c 2009-02-26 17:34:14 UTC (rev 1424)
+++ trunk/src/image-overlay.c 2009-02-26 20:50:36 UTC (rev 1425)
@@ -131,6 +131,7 @@
if (!osd || !osd->histogram) return;
histogram_toggle_channel(osd->histogram);
+ options->image_overlay.common.histogram_channel =
histogram_get_channel(osd->histogram);
image_osd_update(imd);
}
@@ -141,6 +142,7 @@
if (!osd || !osd->histogram) return;
histogram_toggle_mode(osd->histogram);
+ options->image_overlay.common.histogram_mode =
histogram_get_mode(osd->histogram);
image_osd_update(imd);
}
@@ -1020,7 +1022,11 @@
}
if (show & OSD_SHOW_HISTOGRAM)
+ {
osd->histogram = histogram_new();
+ histogram_set_channel(osd->histogram,
options->image_overlay.common.histogram_channel);
+ histogram_set_mode(osd->histogram,
options->image_overlay.common.histogram_mode);
+ }
else if (osd->histogram)
{
histogram_free(osd->histogram);
Modified: trunk/src/options.c
===================================================================
--- trunk/src/options.c 2009-02-26 17:34:14 UTC (rev 1424)
+++ trunk/src/options.c 2009-02-26 20:50:36 UTC (rev 1425)
@@ -59,8 +59,8 @@
options->fullscreen.disable_saver = TRUE;
options->fullscreen.screen = -1;
- options->histogram.last_channel_mode = HCHAN_RGB;
- options->histogram.last_log_mode = 1;
+ options->image_overlay.common.histogram_channel = HCHAN_RGB;
+ options->image_overlay.common.histogram_mode = 1;
memset(&options->image.border_color, 0,
sizeof(options->image.border_color));
options->image.dither_quality = GDK_RGB_DITHER_NORMAL;
Modified: trunk/src/options.h
===================================================================
--- trunk/src/options.h 2009-02-26 17:34:14 UTC (rev 1424)
+++ trunk/src/options.h 2009-02-26 20:50:36 UTC (rev 1425)
@@ -138,12 +138,6 @@
gboolean above;
} fullscreen;
- /* histogram */
- struct {
- guint last_channel_mode;
- guint last_log_mode;
- } histogram;
-
/* image overlay */
struct {
struct {
@@ -152,6 +146,8 @@
gchar *template_string;
gint x;
gint y;
+ gint histogram_channel;
+ gint histogram_mode;
} common;
} image_overlay;
Modified: trunk/src/rcfile.c
===================================================================
--- trunk/src/rcfile.c 2009-02-26 17:34:14 UTC (rev 1424)
+++ trunk/src/rcfile.c 2009-02-26 20:50:36 UTC (rev 1425)
@@ -371,15 +371,12 @@
WRITE_BOOL(*options, fullscreen.above);
-// WRITE_SUBTITLE("Histogram Options");
- WRITE_UINT(*options, histogram.last_channel_mode);
- WRITE_UINT(*options, histogram.last_log_mode);
-
-
// WRITE_SUBTITLE("Image Overlay Options");
WRITE_UINT(*options, image_overlay.common.state);
WRITE_BOOL(*options, image_overlay.common.show_at_startup);
WRITE_CHAR(*options, image_overlay.common.template_string);
+ WRITE_INT(*options, image_overlay.common.histogram_channel);
+ WRITE_INT(*options, image_overlay.common.histogram_mode);
WRITE_SEPARATOR();
// g_string_append_printf(outstr, "# these are relative positions:\n");
@@ -674,14 +671,12 @@
if (READ_BOOL(*options, fullscreen.disable_saver)) continue;
if (READ_BOOL(*options, fullscreen.above)) continue;
- /* histogram */
- if (READ_UINT(*options, histogram.last_channel_mode)) continue;
- if (READ_UINT(*options, histogram.last_log_mode)) continue;
-
/* image overlay */
if (READ_UINT(*options, image_overlay.common.state)) continue;
if (READ_BOOL(*options, image_overlay.common.show_at_startup))
continue;
if (READ_CHAR(*options, image_overlay.common.template_string))
continue;
+ if (READ_INT(*options, image_overlay.common.histogram_channel))
continue;
+ if (READ_INT(*options, image_overlay.common.histogram_mode))
continue;
if (READ_INT(*options, image_overlay.common.x)) continue;
if (READ_INT(*options, image_overlay.common.y)) continue;
Modified: trunk/src/typedefs.h
===================================================================
--- trunk/src/typedefs.h 2009-02-26 17:34:14 UTC (rev 1424)
+++ trunk/src/typedefs.h 2009-02-26 20:50:36 UTC (rev 1425)
@@ -211,6 +211,21 @@
typedef struct _CommandLine CommandLine;
+struct _Histogram {
+ gint histogram_channel; /* drawing mode for histogram */
+ gint histogram_mode; /* logarithmical or not */
+ guint vgrid; /* number of vertical divisions, 0 for none */
+ guint hgrid; /* number of horizontal divisions, 0 for none */
+ struct {
+ int R; /* red */
+ int G; /* green */
+ int B; /* blue */
+ int A; /* alpha */
+ } grid_color; /* grid color */
+
+};
+
+
struct _EditorDescription {
gchar *key; /* desktop file name, not including path,
including extension */
gchar *name; /* Name, localized name presented to user */
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
_______________________________________________
Geeqie-svn mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geeqie-svn