Icon label visibility diff...
- From: "Gene Z. Ragan" <diskzero mac com>
- To: nautilus-list gnome org
- Subject: Icon label visibility diff...
- Date: Sun, 03 Dec 2006 00:30:36 -0800
Comrades,
Here is an idea that I have been playing around with. It was a nice
little feature to get me back into the Nautilus code.
My primary view is usually icon view. Crowded.png is a bit contrived,
but I frequently have situations with a variety of overlapping icons and
labels. (I didn't know if inline images were ok on this list.)
In certain areas, you just see a jumble of letters. A user could apply
one of the Arrange Item modes,
but perhaps they have a specific layout that was messed up as a result
of a drag or file download. They want to be able to hone in and move or
otherwise deal with some specific items.
less.png shows is a nice way to visually clean up the clutter. If the
background in white or a solid color, the label selection frame is done
using that color with an opacity value. If the background is a bitmap,
nothing is done. In the bitmap case, it would probably be possible to
sample the background image at the location, but it seemed like a lot of
work.
What do you thing? Please take a look at the attacked diff. It has
been a while since I have coded to the nautilus guidelines and I have
made some obvious mistakes.
Thanks!
Gene
Index: libnautilus-private/nautilus-icon-canvas-item.c
===================================================================
RCS file: /cvs/gnome/nautilus/libnautilus-private/nautilus-icon-canvas-item.c,v
retrieving revision 1.203
diff -p -u -r1.203 nautilus-icon-canvas-item.c
--- libnautilus-private/nautilus-icon-canvas-item.c 30 Nov 2006 11:10:31 -0000 1.203
+++ libnautilus-private/nautilus-icon-canvas-item.c 3 Dec 2006 08:03:18 -0000
@@ -33,6 +33,7 @@
#include "nautilus-icon-factory.h"
#include "nautilus-icon-private.h"
#include <eel/eel-art-extensions.h>
+#include <eel/eel-background.h>
#include <eel/eel-gdk-extensions.h>
#include <eel/eel-gdk-pixbuf-extensions.h>
#include <eel/eel-glib-extensions.h>
@@ -957,6 +958,7 @@ draw_or_measure_label_text (NautilusIcon
guint editable_height, editable_width, editable_dx;
guint additional_height, additional_width, additional_dx;
EelCanvasItem *canvas_item;
+ EelBackground *background;
PangoLayout *editable_layout;
PangoLayout *additional_layout;
GdkColor *label_color;
@@ -967,6 +969,9 @@ draw_or_measure_label_text (NautilusIcon
GdkGC *gc;
ArtIRect text_rect;
int text_back_padding_x, text_back_padding_y;
+ char *color_spec;
+ GdkColor background_color_gdk;
+ guint background_color_rgb;
icon_width = 0;
gc = NULL;
@@ -1075,21 +1080,59 @@ draw_or_measure_label_text (NautilusIcon
}
text_rect = compute_text_rectangle (item, icon_rect, TRUE);
+
+ if (!details->is_renaming && details->text_width > 0 && details->text_height > 0) {
+ /* if the icon is highlighted, do some set-up */
+ if (needs_highlight)
+ {
+ draw_frame (item,
+ drawable,
+ GTK_WIDGET_HAS_FOCUS (GTK_WIDGET (container)) ? container->details->highlight_color_rgba : container->details->active_color_rgba,
+ create_mask,
+ text_rect.x0,
+ text_rect.y0,
+ text_rect.x1 - text_rect.x0,
+ text_rect.y1 - text_rect.y0);
+ } else {
+ /* Check and see if the background is a solid color. If it is,
+ * we can do a nice visual effect to help disambiguate item
+ * text when items are in close proximity to one-another.
+ */
+
+ /* Get the container and EelBackground */
+ container = (NAUTILUS_ICON_CONTAINER (canvas_item->canvas));
+ background = eel_get_widget_background (GTK_WIDGET (container));
- /* if the icon is highlighted, do some set-up */
- if (needs_highlight && !details->is_renaming &&
- details->text_width > 0 && details->text_height > 0) {
- draw_frame (item,
- drawable,
- GTK_WIDGET_HAS_FOCUS (GTK_WIDGET (container)) ? container->details->highlight_color_rgba : container->details->active_color_rgba,
- create_mask,
- text_rect.x0,
- text_rect.y0,
- text_rect.x1 - text_rect.x0,
- text_rect.y1 - text_rect.y0);
+ /* Check and see if we have a solid color */
+ color_spec = eel_background_get_color (background);
+
+ if (color_spec != NULL) {
+ /* Convert the color spec into a gdk color */
+ eel_gdk_color_parse_with_white_default (color_spec, &background_color_gdk);
+
+ /* Get the color as an rgb value and set the alpha */
+ background_color_rgb = EEL_RGBA_COLOR_PACK (background_color_gdk.red >> 8,
+ background_color_gdk.green >> 8,
+ background_color_gdk.blue >> 8,
+ 200);
+
+ /* Draw the frame with a transparent background fill so that stacked
+ * labels are less visually noisy.
+ */
+ draw_frame (item,
+ drawable,
+ background_color_rgb,
+ create_mask,
+ text_rect.x0,
+ text_rect.y0,
+ text_rect.x1 - text_rect.x0,
+ text_rect.y1 - text_rect.y0);
+
+ g_free (color_spec);
+ }
+ }
}
-
if (container->details->label_position == NAUTILUS_ICON_LABEL_POSITION_BESIDE) {
x = text_rect.x0 + 2;
} else {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]