summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-17 00:43:43 +0000
committerestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-17 00:43:43 +0000
commit4118ab959e390b81735c81e84af7df2173826584 (patch)
treeda502a0e8625401866d50f5eb7f8cce8ceeb0dc0
parent816cb613e0210984e25fc997803acc8876e5adbe (diff)
downloadchromium_src-4118ab959e390b81735c81e84af7df2173826584.zip
chromium_src-4118ab959e390b81735c81e84af7df2173826584.tar.gz
chromium_src-4118ab959e390b81735c81e84af7df2173826584.tar.bz2
gtk: Make sure icon is right size in download item.
This results in kind of an ugly icon sometimes. When we get SVG support the number of ugly cases should go down. http://crbug.com/13791 Review URL: http://codereview.chromium.org/126245 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@18575 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/gtk/download_item_gtk.cc23
-rw-r--r--chrome/browser/icon_manager.h8
2 files changed, 22 insertions, 9 deletions
diff --git a/chrome/browser/gtk/download_item_gtk.cc b/chrome/browser/gtk/download_item_gtk.cc
index 744f8fc..6ed474f 100644
--- a/chrome/browser/gtk/download_item_gtk.cc
+++ b/chrome/browser/gtk/download_item_gtk.cc
@@ -603,9 +603,24 @@ gboolean DownloadItemGtk::OnProgressAreaExpose(GtkWidget* widget,
// TODO(estade): draw a default icon if |icon_| is null.
if (download_item->icon_) {
- canvas.DrawBitmapInt(*download_item->icon_,
- widget->allocation.x + download_util::kSmallProgressIconOffset,
- widget->allocation.y + download_util::kSmallProgressIconOffset);
+ int width = download_item->icon_->width();
+ int height = download_item->icon_->height();
+ // Sometimes we get back icons that are the wrong size. Draw the correct
+ // size. This code should hopefully be made obsolete after we support SVG
+ // icons (although it could still be hit if a theme doesn't provide SVG or
+ // 16x16).
+ const int sixteen = download_util::kSmallIconSize;
+ const int offset = download_util::kSmallProgressIconOffset;
+ if (sixteen != width || sixteen != height) {
+ // Draw the bitmap at a reduced scale.
+ download_item->icon_->buildMipMap(false);
+ canvas.DrawBitmapInt(*download_item->icon_, 0, 0, width, height,
+ widget->allocation.x + offset, widget->allocation.y + offset,
+ sixteen, sixteen, true);
+ } else {
+ canvas.DrawBitmapInt(*download_item->icon_,
+ widget->allocation.x + offset, widget->allocation.y + offset);
+ }
}
return TRUE;
@@ -621,8 +636,6 @@ gboolean DownloadItemGtk::OnMenuButtonPressEvent(GtkWidget* button,
item->complete_animation_->End();
}
- // TODO(port): this never puts the button into the "active" state,
- // so this may need to be changed. See note in BrowserToolbarGtk.
if (event->type == GDK_BUTTON_PRESS) {
GdkEventButton* event_button = reinterpret_cast<GdkEventButton*>(event);
if (event_button->button == 1) {
diff --git a/chrome/browser/icon_manager.h b/chrome/browser/icon_manager.h
index 44d17da..1bb8fdf 100644
--- a/chrome/browser/icon_manager.h
+++ b/chrome/browser/icon_manager.h
@@ -70,15 +70,15 @@ class IconManager : public IconLoader::Delegate,
SkBitmap* LookupIcon(const FilePath& file_name,
IconLoader::IconSize size);
+ typedef CancelableRequestProvider::Handle Handle;
+ typedef Callback2<Handle, SkBitmap*>::Type IconRequestCallback;
+
// Asynchronous call to lookup and return the icon associated with file. The
// work is done on the file thread, with the callbacks running on the UI
// thread. The return value is the 'request_id' that will be passed to the
- // client in the callback.
+ // client in the callback. Note: this does *not* check the cache.
//
// WATCH OUT: The returned bitmap pointer may be NULL if decoding failed.
- typedef CancelableRequestProvider::Handle Handle;
- typedef Callback2<Handle, SkBitmap*>::Type IconRequestCallback;
-
Handle LoadIcon(const FilePath& file_name,
IconLoader::IconSize size,
CancelableRequestConsumerBase* consumer,