diff options
| author | Marco Trevisan (Treviño) <mail@3v1n0.net> | 2015-11-04 15:55:39 +0100 |
|---|---|---|
| committer | Marco Trevisan (Treviño) <mail@3v1n0.net> | 2015-11-04 15:55:39 +0100 |
| commit | e0a645d5d79e46ae6bb1ffd19d999ed838f8c350 (patch) | |
| tree | f74336013de15bbac9d865c6c1c17d2fe050a3e8 /dash | |
| parent | 8f2ecfa170e536aa54bfe67aadd5df4f389008b7 (diff) | |
| parent | 20ac92b16740ba68ec5d1f991c7971029bebac9e (diff) | |
Merging with trunk
(bzr r4008.14.2)
Diffstat (limited to 'dash')
| -rw-r--r-- | dash/ResultRenderer.cpp | 21 | ||||
| -rw-r--r-- | dash/ResultRendererTile.cpp | 15 | ||||
| -rw-r--r-- | dash/ResultRendererTile.h | 2 |
3 files changed, 17 insertions, 21 deletions
diff --git a/dash/ResultRenderer.cpp b/dash/ResultRenderer.cpp index c0566b3ba..8a0bfad41 100644 --- a/dash/ResultRenderer.cpp +++ b/dash/ResultRenderer.cpp @@ -21,11 +21,12 @@ */ #include "ResultRenderer.h" +#include "unity-shared/RawPixel.h" #include <gtk/gtk.h> #include <unity-protocol.h> #include <NuxGraphics/GdkGraphics.h> -#include <UnityCore/GTKWrapper.h> +#include <UnityCore/GLibWrapper.h> namespace unity { @@ -34,13 +35,14 @@ 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) { GdkPixbuf *pbuf; GtkIconTheme *theme; - gtk::IconInfo info; + glib::Object<GtkIconInfo> info; glib::Error error; glib::Object<GIcon> icon; @@ -67,11 +69,11 @@ GdkPixbuf* _icon_hint_get_drag_pixbuf(std::string icon_hint, int size) { auto anno = glib::object_cast<UnityProtocolAnnotatedIcon>(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 +81,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 +89,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 +97,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 +145,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(); } } } - 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<float>(pixbuf_height) / pixbuf_width; // already sanitized width/height so can not be 0.0 + double aspect = static_cast<double>(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<int>((width - (pixbuf_width * scale)) * 0.5), - // static_cast<int>((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<GdkPixbuf> const& pixbuf, - std::string icon_name, + std::string const& icon_name, Result const& row) { TextureContainer *container = row.renderer<TextureContainer*>(); 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<GdkPixbuf> 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<GdkPixbuf> const& pixbuf); |
