From d82b7d50ac2ec644f4c2206c587aa105f911fa8d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Sat, 3 Oct 2015 02:14:29 +0200 Subject: Use GTK_ICON_LOOKUP_FORCE_SIZE when loading icons everywhere (bzr r4008.11.2) --- dash/ResultRenderer.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'dash') diff --git a/dash/ResultRenderer.cpp b/dash/ResultRenderer.cpp index c0566b3ba..56230f3d0 100644 --- a/dash/ResultRenderer.cpp +++ b/dash/ResultRenderer.cpp @@ -21,8 +21,8 @@ */ #include "ResultRenderer.h" +#include "unity-shared/RawPixel.h" -#include #include #include #include @@ -34,7 +34,8 @@ namespace dash namespace { -#define DEFAULT_GICON ". GThemedIcon text-x-preview" +const std::string DEFAULT_GICON = ". GThemedIcon text-x-preview"; +const RawPixel DEFAULT_ICON_SIZE = 64_em; GdkPixbuf* _icon_hint_get_drag_pixbuf(std::string icon_hint, int size) { @@ -67,11 +68,11 @@ GdkPixbuf* _icon_hint_get_drag_pixbuf(std::string icon_hint, int size) { auto anno = glib::object_cast(icon); GIcon *base_icon = unity_protocol_annotated_icon_get_icon(anno); - info = gtk_icon_theme_lookup_by_gicon(theme, base_icon, size, (GtkIconLookupFlags)0); + info = gtk_icon_theme_lookup_by_gicon(theme, base_icon, size, GTK_ICON_LOOKUP_FORCE_SIZE); } else { - info = gtk_icon_theme_lookup_by_gicon(theme, icon, size, (GtkIconLookupFlags)0); + info = gtk_icon_theme_lookup_by_gicon(theme, icon, size, GTK_ICON_LOOKUP_FORCE_SIZE); } } else @@ -79,7 +80,7 @@ GdkPixbuf* _icon_hint_get_drag_pixbuf(std::string icon_hint, int size) info = gtk_icon_theme_lookup_icon(theme, icon_hint.c_str(), size, - (GtkIconLookupFlags) 0); + GTK_ICON_LOOKUP_FORCE_SIZE); } if (!info) @@ -87,7 +88,7 @@ GdkPixbuf* _icon_hint_get_drag_pixbuf(std::string icon_hint, int size) info = gtk_icon_theme_lookup_icon(theme, "application-default-icon", size, - (GtkIconLookupFlags) 0); + GTK_ICON_LOOKUP_FORCE_SIZE); } if (!gtk_icon_info_get_filename(info)) @@ -95,7 +96,7 @@ GdkPixbuf* _icon_hint_get_drag_pixbuf(std::string icon_hint, int size) info = gtk_icon_theme_lookup_icon(theme, "application-default-icon", size, - (GtkIconLookupFlags) 0); + GTK_ICON_LOOKUP_FORCE_SIZE); } pbuf = gtk_icon_info_load_icon(info, &error); @@ -143,10 +144,9 @@ void ResultRenderer::Unload(Result const& row) nux::NBitmapData* ResultRenderer::GetDndImage(Result const& row) const { - nux::GdkGraphics graphics(_icon_hint_get_drag_pixbuf(row.icon_hint, 64)); + nux::GdkGraphics graphics(_icon_hint_get_drag_pixbuf(row.icon_hint, DEFAULT_ICON_SIZE.CP(scale))); return graphics.GetBitmap(); } } } - -- cgit v1.2.3 From da38a410292d83c6a534cc52aeac52383ebef7f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Sat, 3 Oct 2015 03:08:12 +0200 Subject: ResultRendererTile: consider global scaling when scaling a not-squared icon Fixes LP: #1499286 (bzr r4008.10.1) --- dash/ResultRendererTile.cpp | 15 +++++---------- dash/ResultRendererTile.h | 2 +- 2 files changed, 6 insertions(+), 11 deletions(-) (limited to 'dash') diff --git a/dash/ResultRendererTile.cpp b/dash/ResultRendererTile.cpp index 5d37bf203..83abd127e 100644 --- a/dash/ResultRendererTile.cpp +++ b/dash/ResultRendererTile.cpp @@ -290,7 +290,7 @@ void ResultRendererTile::LoadIcon(Result const& row) if (icon.IsType(G_TYPE_ICON)) { bool use_large_icon = icon.IsType(G_TYPE_FILE_ICON) || !icon.IsType(G_TYPE_THEMED_ICON); - container->slot_handle = IconLoader::GetDefault().LoadFromGIconString(icon_name, + container->slot_handle = IconLoader::GetDefault().LoadFromGIconString(icon_name, tile_size, use_large_icon ? tile_size : tile_gsize, slot); @@ -326,7 +326,7 @@ nux::BaseTexture* ResultRendererTile::CreateTextureCallback(std::string const& t { // slow path for non square icons that must be resized to fit in the square // texture - float aspect = static_cast(pixbuf_height) / pixbuf_width; // already sanitized width/height so can not be 0.0 + double aspect = static_cast(pixbuf_height) / pixbuf_width; // already sanitized width/height so can not be 0.0 if (aspect < 1.0f) { pixbuf_width = Style::Instance().GetTileImageSize().CP(scale); @@ -358,13 +358,8 @@ nux::BaseTexture* ResultRendererTile::CreateTextureCallback(std::string const& t cairo_set_operator(cr, CAIRO_OPERATOR_CLEAR); cairo_paint(cr); - float scale = float(pixbuf_height) / gdk_pixbuf_get_height(pixbuf); - - //cairo_translate(cr, - // static_cast((width - (pixbuf_width * scale)) * 0.5), - // static_cast((height - (pixbuf_height * scale)) * 0.5)); - - cairo_scale(cr, scale, scale); + double pixmap_scale = float(pixbuf_height) / gdk_pixbuf_get_height(pixbuf) / scale(); + cairo_scale(cr, pixmap_scale, pixmap_scale); cairo_set_operator(cr, CAIRO_OPERATOR_OVER); gdk_cairo_set_source_pixbuf(cr, pixbuf, 0, 0); @@ -378,7 +373,7 @@ void ResultRendererTile::IconLoaded(std::string const& texid, int max_width, int max_height, glib::Object const& pixbuf, - std::string icon_name, + std::string const& icon_name, Result const& row) { TextureContainer *container = row.renderer(); diff --git a/dash/ResultRendererTile.h b/dash/ResultRendererTile.h index fab30fae4..e54517b4e 100644 --- a/dash/ResultRendererTile.h +++ b/dash/ResultRendererTile.h @@ -87,7 +87,7 @@ private: //icon loading callbacks void IconLoaded(std::string const& texid, int max_width, int max_height, glib::Object const& pixbuf, - std::string icon_name, Result const& row); + std::string const& icon_name, Result const& row); nux::BaseTexture* CreateTextureCallback(std::string const& texid, int width, int height, glib::Object const& pixbuf); -- cgit v1.2.3 From 9041b655be4d896cafdd5b8df887de82a0da4225 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Mon, 5 Oct 2015 18:52:24 +0200 Subject: GtkWrapper: remove it as it's not needed anymore (bzr r4008.11.3) --- dash/ResultRenderer.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'dash') diff --git a/dash/ResultRenderer.cpp b/dash/ResultRenderer.cpp index 56230f3d0..8a0bfad41 100644 --- a/dash/ResultRenderer.cpp +++ b/dash/ResultRenderer.cpp @@ -23,9 +23,10 @@ #include "ResultRenderer.h" #include "unity-shared/RawPixel.h" +#include #include #include -#include +#include namespace unity { @@ -41,7 +42,7 @@ GdkPixbuf* _icon_hint_get_drag_pixbuf(std::string icon_hint, int size) { GdkPixbuf *pbuf; GtkIconTheme *theme; - gtk::IconInfo info; + glib::Object info; glib::Error error; glib::Object icon; -- cgit v1.2.3