|
From: Peter <sw...@ho...> - 2007-01-22 11:04:17
|
On Sun, 21 Jan 2007 19:25:57 +0000, Peter wrote:
It seems to perform as advertised. Only thing I do not like is the need
for 4 more radio choices. Perhaps a fly-out submenu would be better, but
I don't know how to do that with the rox helper functions.
This patch is against the current svn. I hope it's good. Try it with long
or narrow images to test its effects. One note. The tooltips format
differently for me on alternating radio choices even though they are
identical. Perhaps that has something to do with the helper functions or
the fact that I embed \n in it?
Anyway, feedback and improvements are welcome :)!
--- /tmp/rox/ROX-Filer/src/pinboard.h 2007-01-22 05:28:50.000000000 -0500
+++ src/pinboard.h 2007-01-21 13:45:43.000000000 -0500
@@ -18,7 +18,8 @@
typedef enum {
BACKDROP_NONE,
BACKDROP_PROGRAM,
- BACKDROP_CENTRE, BACKDROP_SCALE, BACKDROP_STRETCH, BACKDROP_TILE, BACKDROP_FIT
+ BACKDROP_CENTRE, BACKDROP_SCALE, BACKDROP_STRETCH, BACKDROP_TILE,
+ BACKDROP_FIT, BACKDROP_FIT_L, BACKDROP_FIT_R, BACKDROP_FIT_T, BACKDROP_FIT_B
} BackdropStyle;
void pinboard_init(void);
--- /tmp/rox/ROX-Filer/src/pinboard.c 2007-01-22 05:28:50.000000000 -0500
+++ src/pinboard.c 2007-01-22 05:56:09.000000000 -0500
@@ -702,13 +702,30 @@
radios_add(radios, _("Scale the image to fit the backdrop area, "
"without distorting it"),
BACKDROP_SCALE, _("Scale"));
- radios_add(radios, _("Scale the image to fit the backdrop area, "
- "regardless of image dimensions - overscale"),
- BACKDROP_FIT, _("Fit"));
radios_add(radios, _("Stretch the image to fill the backdrop area"),
BACKDROP_STRETCH, _("Stretch"));
radios_add(radios, _("Tile the image over the backdrop area"),
BACKDROP_TILE, _("Tile"));
+ radios_add(radios, _("Fit image to fill the backdrop area, "
+ "preserving aspect - Align Center\n"
+ "(Image may be cropped)"),
+ BACKDROP_FIT, _("Fit"));
+ radios_add(radios, _("Fit image to fill the backdrop area, "
+ "preserving aspect - Align Left\n"
+ "(Image may be cropped)"),
+ BACKDROP_FIT_L, _("Fit\nLeft"));
+ radios_add(radios, _("Fit image to fill the backdrop area, "
+ "preserving aspect - Align Right\n"
+ "(Image may be cropped)"),
+ BACKDROP_FIT_R, _("Fit\nRight"));
+ radios_add(radios, _("Fit image to fill the backdrop area, "
+ "preserving aspect - Align Top\n"
+ "(Image may be cropped)"),
+ BACKDROP_FIT_T, _("Fit\nTop"));
+ radios_add(radios, _("Fit image to fill the backdrop area, "
+ "preserving aspect - Align Bottom\n"
+ "(Image may be cropped)"),
+ BACKDROP_FIT_B, _("Fit\nBottom"));
update_radios(dialog);
@@ -1407,10 +1424,14 @@
current_pinboard->backdrop_style =
g_strcasecmp(style, "Tiled") == 0 ? BACKDROP_TILE :
g_strcasecmp(style, "Scaled") == 0 ? BACKDROP_SCALE :
- g_strcasecmp(style, "Fit") == 0 ? BACKDROP_FIT :
g_strcasecmp(style, "Stretched") == 0 ? BACKDROP_STRETCH :
g_strcasecmp(style, "Centred") == 0 ? BACKDROP_CENTRE :
g_strcasecmp(style, "Program") == 0 ? BACKDROP_PROGRAM :
+ g_strcasecmp(style, "Fit") == 0 ? BACKDROP_FIT :
+ g_strcasecmp(style, "Fit_L") == 0 ? BACKDROP_FIT_L :
+ g_strcasecmp(style, "Fit_R") == 0 ? BACKDROP_FIT_R :
+ g_strcasecmp(style, "Fit_T") == 0 ? BACKDROP_FIT_T :
+ g_strcasecmp(style, "Fit_B") == 0 ? BACKDROP_FIT_B :
BACKDROP_NONE;
g_free(style);
}
@@ -1557,8 +1578,12 @@
style == BACKDROP_TILE ? "Tiled" :
style == BACKDROP_CENTRE ? "Centred" :
style == BACKDROP_SCALE ? "Scaled" :
- style == BACKDROP_FIT ? "Fit" :
style == BACKDROP_STRETCH ? "Stretched" :
+ style == BACKDROP_FIT ? "Fit" :
+ style == BACKDROP_FIT_L ? "Fit_L" :
+ style == BACKDROP_FIT_R ? "Fit_R" :
+ style == BACKDROP_FIT_T ? "Fit_T" :
+ style == BACKDROP_FIT_B ? "Fit_B" :
"Program");
}
@@ -2245,25 +2270,23 @@
g_object_unref(old);
}
- else if (style == BACKDROP_CENTRE || style == BACKDROP_SCALE || style == BACKDROP_FIT)
+ else if (style == BACKDROP_CENTRE || style == BACKDROP_SCALE || style >= BACKDROP_FIT)
{
GdkPixbuf *old = pixbuf;
- int x, y, width, height;
- float scale;
+ int dest_x, dest_y, offset_x, offset_y,width, height;
+ float scale, scale_x, scale_y;
width = gdk_pixbuf_get_width(pixbuf);
height = gdk_pixbuf_get_height(pixbuf);
if (style == BACKDROP_SCALE)
{
- float scale_x, scale_y;
scale_x = screen_width / ((float) width);
scale_y = screen_height / ((float) height);
scale = MIN(scale_x, scale_y);
}
- else if (style == BACKDROP_FIT)
+ else if (style >= BACKDROP_FIT)
{
- float scale_x, scale_y;
scale_x = screen_width / ((float) width);
scale_y = screen_height / ((float) height);
scale = MAX(scale_x, scale_y);
@@ -2278,16 +2301,38 @@
((pin_text_bg_col.green & 0xff00) << 8) |
((pin_text_bg_col.blue & 0xff00)));
- x = (screen_width - width * scale) / 2;
- y = (screen_height - height * scale) / 2;
- x = MAX(x, 0);
- y = MAX(y, 0);
+ switch ( style )
+ {
+ case BACKDROP_FIT_L:
+ offset_x = 0;
+ offset_y = (screen_height - height * scale) / 2;
+ break;
+ case BACKDROP_FIT_R:
+ offset_x = (screen_width - width * scale);
+ offset_y = (screen_height - height * scale) / 2;
+ break;
+ case BACKDROP_FIT_T:
+ offset_x = (screen_width - width * scale) / 2;
+ offset_y = 0;
+ break;
+ case BACKDROP_FIT_B:
+ offset_x = (screen_width - width * scale) / 2;
+ offset_y = (screen_height - height * scale );
+ break;
+ default: /* FIT SCALE CENTRE */
+ offset_x = (screen_width - width * scale) / 2;
+ offset_y = (screen_height - height * scale) / 2;
+ break;
+ }
+
+ dest_x = MAX(offset_x, 0);
+ dest_y = MAX(offset_y, 0);
gdk_pixbuf_composite(old, pixbuf,
- x, y,
+ dest_x, dest_y,
MIN(screen_width, width * scale),
MIN(screen_height, height * scale),
- x, y, scale, scale,
+ offset_x, offset_y, scale, scale,
o_pinboard_image_scaling.int_value?
GDK_INTERP_BILINEAR: GDK_INTERP_HYPER,
255);
@@ -2341,11 +2386,6 @@
style = BACKDROP_SCALE;
command += 6;
}
- else if (strncmp(command, "fit ", 4) == 0)
- {
- style = BACKDROP_FIT;
- command += 4;
- }
else if (strncmp(command, "stretch ", 8) == 0)
{
style = BACKDROP_STRETCH;
@@ -2356,6 +2396,31 @@
style = BACKDROP_CENTRE;
command += 7;
}
+ else if (strncmp(command, "fit ", 4) == 0)
+ {
+ style = BACKDROP_FIT;
+ command += 4;
+ }
+ else if (strncmp(command, "fit_l ", 6) == 0)
+ {
+ style = BACKDROP_FIT_L;
+ command += 6;
+ }
+ else if (strncmp(command, "fit_r ", 6) == 0)
+ {
+ style = BACKDROP_FIT_R;
+ command += 6;
+ }
+ else if (strncmp(command, "fit_t ", 6) == 0)
+ {
+ style = BACKDROP_FIT_T;
+ command += 6;
+ }
+ else if (strncmp(command, "fit_b ", 6) == 0)
+ {
+ style = BACKDROP_FIT_B;
+ command += 6;
+ }
else
{
g_warning("Invalid command '%s' from backdrop app\n",
@@ -2757,6 +2822,10 @@
case BACKDROP_SCALE:
case BACKDROP_CENTRE:
case BACKDROP_FIT:
+ case BACKDROP_FIT_L:
+ case BACKDROP_FIT_R:
+ case BACKDROP_FIT_T:
+ case BACKDROP_FIT_B:
radios_set_value(radios,
current_pinboard->backdrop_style);
gtk_widget_set_sensitive(hbox, TRUE);
--
Peter
|