diff --git a/src/nautilus-canvas-item.c b/src/nautilus-canvas-item.c index f51967d23f7eadb56608a21be2d2a483761a2906..d833b6d4904a6501555caf1a7f0cb73804063391 100644 --- a/src/nautilus-canvas-item.c +++ b/src/nautilus-canvas-item.c @@ -1362,20 +1362,29 @@ nautilus_canvas_item_draw (EelCanvasItem *item, context = gtk_widget_get_style_context (GTK_WIDGET (container)); gtk_style_context_save (context); gtk_style_context_add_class (context, "nautilus-canvas-item"); - if (details->is_thumbnail) - { - gtk_style_context_add_class (context, "thumbnail"); - } icon_rect = canvas_item->details->icon_rect; temp_surface = map_surface (canvas_item); + if (details->is_thumbnail) + { + /* Draw box shadow before drawing the thumbnail. */ + gtk_style_context_save (context); + gtk_style_context_add_class (context, "thumbnail"); + gtk_render_background (context, cr, + icon_rect.x0, + icon_rect.y0, + icon_rect.x1 - icon_rect.x0, + icon_rect.y1 - icon_rect.y0); + gtk_style_context_restore (context); + } gtk_render_icon_surface (context, cr, temp_surface, icon_rect.x0, icon_rect.y0); cairo_surface_destroy (temp_surface); /* Draw the label text. */ + gtk_style_context_add_class (context, "label-text"); draw_label_text (canvas_item, cr, icon_rect); gtk_style_context_restore (context); diff --git a/src/nautilus-list-view.c b/src/nautilus-list-view.c index 77278fab196059b2570dff9dd8b988db37f06c4b..bb7fbe3ee6f89e87efbb61daa32b8a770e64deb2 100644 --- a/src/nautilus-list-view.c +++ b/src/nautilus-list-view.c @@ -1578,16 +1578,6 @@ starred_cell_data_func (GtkTreeViewColumn *column, g_autofree gchar *text = NULL; g_autofree gchar *uri = NULL; NautilusFile *file; - GtkStyleContext *context; - - /* The "thumbnail" style class is set before rendering each icon cell with - * a thumbnail. However, style classes are not applied to each cell, but - * alwyas to the whole GtkTreeView widget. So, before the star icon is - * rendered, we must ensure that the style is not set, otherwise the star - * icon is going to get the styles meant only for thumbnail icons. - */ - context = gtk_widget_get_style_context (GTK_WIDGET (view)); - gtk_style_context_remove_class (context, "thumbnail"); gtk_tree_model_get (model, iter, view->details->file_name_column_num, &text, @@ -1659,10 +1649,6 @@ icon_cell_data_func (GtkTreeViewColumn *column, &file, -1); - /* Hack: Set/unset the style class in advance of rendering. This makes a - * major assumption that's all but clearly stated in the documentation of - * GtkCellLayout: that the DataFunc is called before rendering each cell. - */ is_thumbnail = FALSE; if (zoom_level_is_enough_for_thumbnails (view) && file != NULL) { @@ -1678,11 +1664,53 @@ icon_cell_data_func (GtkTreeViewColumn *column, if (is_thumbnail) { + cairo_surface_t *new_surface; + cairo_t *cr; + int w, h; + + /* The shadow extends 1px up, 3px down, and 2px left and right. For that + * reason, the final surface must be 4px taller and 4px wider, with the + * original icon starting at (2, 1). + * + * *#######################* -+ + * *#. #* -+ | + * *# \ #* | | + * *# \ #* | | + * *# (2, 1) #* | | + * *# #* | h | + * *# #* | | h + 4 + * *# #* | | + * *# #* | | + * *# #* -+ | + * *#######################* | + * *#######################* | + * ************************* -+ + * | | + * +-------------------+ :¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨: + * w : #### --> Solid shadow : + * | | : : + * +-----------------------+ : **** --> Blur shadow : + * w + 4 '.......................' + */ + w = cairo_image_surface_get_width (surface); + h = cairo_image_surface_get_height (surface); + + new_surface = cairo_surface_create_similar (surface, + CAIRO_CONTENT_COLOR_ALPHA, + w + 4, + h + 4); + cr = cairo_create (new_surface); + + gtk_style_context_save (context); gtk_style_context_add_class (context, "thumbnail"); - } - else - { - gtk_style_context_remove_class (context, "thumbnail"); + gtk_render_background (context, cr, 2, 1, w, h); + gtk_render_icon_surface (context, cr, surface, 2, 1); + gtk_style_context_restore (context); + + cairo_destroy (cr); + + cairo_surface_destroy (surface); + surface = new_surface; } g_object_set (renderer, diff --git a/src/resources/css/Adwaita.css b/src/resources/css/Adwaita.css index 4991979cf05da73d5cb56368b0228854d1b7f529..f96cddc19959492c2fab6484719f255c7ea3ef6c 100644 --- a/src/resources/css/Adwaita.css +++ b/src/resources/css/Adwaita.css @@ -9,14 +9,11 @@ } .nautilus-canvas-item { - border-radius: 5px; + border-radius: 0px; } -.nautilus-canvas-item.thumbnail { - -gtk-icon-shadow: 0px 1px 2px @borders, - 1px 0px 0px alpha(@borders, 0.25), - -1px 0px 0px alpha(@borders, 0.25), - 0px 2px 0px alpha(@borders, 0.5); +.nautilus-canvas-item.label-text { + border-radius: 5px; } .nautilus-canvas-item.dim-label { @@ -194,13 +191,6 @@ entry.search > * { border-bottom: 1px solid @theme_bg_color; } -.nautilus-list-view.thumbnail { - -gtk-icon-shadow: 0px 1px 2px @borders, - 1px 0px 0px alpha(@borders, 0.25), - -1px 0px 0px alpha(@borders, 0.25), - 0px 2px 0px alpha(@borders, 0.5); -} - .search-information { background-color: @theme_selected_bg_color; color:white; @@ -239,10 +229,6 @@ flowboxchild:selected { flowboxchild .thumbnail { margin: 4px; - box-shadow: 0px 1px 2px 0px alpha(@borders, 0.5), - 0px 0px 0px 1px alpha(@borders, 0.5), - 0px 2px 0px 0px alpha(@borders, 0.5); - border-radius: 2px; } .icon-ui-labels-box { @@ -262,3 +248,12 @@ flowboxchild:selected image { */ -gtk-icon-shadow: 0px 0px @theme_selected_bg_color; } + +.thumbnail { + box-shadow: 0px 1px 2px 0px alpha(@borders, 0.5), + 0px 0px 0px 1px alpha(@borders, 0.5), + 0px 2px 0px 0px alpha(@borders, 0.5); + border-radius: 2px; + /* Opaque background for thumbnails with transparent areas. */ + background-color: #fafafa; +}