summaryrefslogtreecommitdiffstats
path: root/chrome/browser
diff options
context:
space:
mode:
authormirandac@chromium.org <mirandac@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-12-12 00:07:42 +0000
committermirandac@chromium.org <mirandac@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-12-12 00:07:42 +0000
commit8b1a931b39efcd75b1a8e212e23b4c52e33308af (patch)
treeac1ef4bf7c2cdee1d1cfaf55d10411d4dbdc79f1 /chrome/browser
parent6f020e99420b83918f752e7df9302e659630e0f9 (diff)
downloadchromium_src-8b1a931b39efcd75b1a8e212e23b4c52e33308af.zip
chromium_src-8b1a931b39efcd75b1a8e212e23b4c52e33308af.tar.gz
chromium_src-8b1a931b39efcd75b1a8e212e23b4c52e33308af.tar.bz2
Theme download status message, so that it's readable in themes of any color.
BUG= 21176 TEST= Download something large in a dark or light theme. Note that status update (notification of how much data is left to download) is legible. Review URL: http://codereview.chromium.org/488002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@34395 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r--chrome/browser/views/download_item_view.cc61
1 files changed, 39 insertions, 22 deletions
diff --git a/chrome/browser/views/download_item_view.cc b/chrome/browser/views/download_item_view.cc
index 0f220b8..ecef749 100644
--- a/chrome/browser/views/download_item_view.cc
+++ b/chrome/browser/views/download_item_view.cc
@@ -7,6 +7,7 @@
#include <vector>
#include "app/gfx/canvas.h"
+#include "app/gfx/color_utils.h"
#include "app/gfx/text_elider.h"
#include "app/l10n_util.h"
#include "app/resource_bundle.h"
@@ -67,6 +68,11 @@ static const int kCompleteAnimationDurationMs = 2500;
// downloaded item.
static const int kDisabledOnOpenDuration = 3000;
+// Darken light-on-dark download status text by 20% before drawing, thus
+// creating a "muted" version of title text for both dark-on-light and
+// light-on-dark themes.
+static const double kDownloadItemLuminanceMod = 0.8;
+
// DownloadShelfContextMenuWin -------------------------------------------------
class DownloadShelfContextMenuWin : public DownloadShelfContextMenu,
@@ -523,6 +529,31 @@ void DownloadItemView::Paint(gfx::Canvas* canvas) {
if (center_width <= 0)
return;
+ // Draw status before button image to effectively lighten text.
+ if (!IsDangerousMode()) {
+ if (show_status_text_) {
+ int mirrored_x = MirroredXWithWidthInsideView(
+ download_util::kSmallProgressIconSize, kTextWidth);
+ // Add font_.height() to compensate for title, which is drawn later.
+ int y = box_y_ + kVerticalPadding + font_.height() +
+ kVerticalTextPadding;
+ SkColor file_name_color = GetThemeProvider()->GetColor(
+ BrowserThemeProvider::COLOR_BOOKMARK_TEXT);
+ // If text is light-on-dark, lightening it alone will do nothing.
+ // Therefore we mute luminance a wee bit before drawing in this case.
+ if (color_utils::RelativeLuminance(file_name_color) > 0.5)
+ file_name_color = SkColorSetRGB(
+ static_cast<int>(kDownloadItemLuminanceMod *
+ SkColorGetR(file_name_color)),
+ static_cast<int>(kDownloadItemLuminanceMod *
+ SkColorGetG(file_name_color)),
+ static_cast<int>(kDownloadItemLuminanceMod *
+ SkColorGetB(file_name_color)));
+ canvas->DrawStringInt(status_text_, font_, file_name_color,
+ mirrored_x, y, kTextWidth, font_.height());
+ }
+ }
+
// Paint the background images.
int x = kLeftPadding;
bool rtl_ui = UILayoutIsRightToLeft();
@@ -643,28 +674,14 @@ void DownloadItemView::Paint(gfx::Canvas* canvas) {
download_util::kSmallProgressIconSize, kTextWidth);
SkColor file_name_color = GetThemeProvider()->GetColor(
BrowserThemeProvider::COLOR_BOOKMARK_TEXT);
- if (show_status_text_) {
- int y = box_y_ + kVerticalPadding;
-
- // Draw the file's name.
- canvas->DrawStringInt(filename, font_,
- IsEnabled() ? file_name_color :
- kFileNameDisabledColor,
- mirrored_x, y, kTextWidth, font_.height());
-
- y += font_.height() + kVerticalTextPadding;
-
- canvas->DrawStringInt(status_text_, font_, kStatusColor, mirrored_x, y,
- kTextWidth, font_.height());
- } else {
- int y = box_y_ + (box_height_ - font_.height()) / 2;
-
- // Draw the file's name.
- canvas->DrawStringInt(filename, font_,
- IsEnabled() ? file_name_color :
- kFileNameDisabledColor,
- mirrored_x, y, kTextWidth, font_.height());
- }
+ int y = box_y_ + (show_status_text_ ? kVerticalPadding :
+ (box_height_ - font_.height()) / 2);
+
+ // Draw the file's name.
+ canvas->DrawStringInt(filename, font_,
+ IsEnabled() ? file_name_color :
+ kFileNameDisabledColor,
+ mirrored_x, y, kTextWidth, font_.height());
}
// Paint the icon.