Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(601)

Unified Diff: chrome/browser/chromeos/status/status_area_button.cc

Issue 6904160: Implement new gray mock. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Review nits Created 9 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/chromeos/status/status_area_button.cc
diff --git a/chrome/browser/chromeos/status/status_area_button.cc b/chrome/browser/chromeos/status/status_area_button.cc
index 3abf6dd864a52267233ac0ef338a69c145605a5b..ec93c9906cf3d7e917ae51337536c4396a32f372 100644
--- a/chrome/browser/chromeos/status/status_area_button.cc
+++ b/chrome/browser/chromeos/status/status_area_button.cc
@@ -1,10 +1,12 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/chromeos/status/status_area_button.h"
+#include "content/common/notification_service.h"
#include "grit/theme_resources.h"
+#include "ui/base/resource/resource_bundle.h"
#include "ui/gfx/canvas.h"
#include "ui/gfx/skbitmap_operations.h"
#include "views/border.h"
@@ -12,22 +14,39 @@
namespace chromeos {
-// A 0.7 black to decorate status text. Same color is used for icon borders.
-static const SkColor kStatusTextHaloColor = SkColorSetARGB(0xB3, 0, 0, 0);
+// Colors for different text styles.
+static const SkColor kWhitePlainTextColor = 0x99ffffff;
+static const SkColor kWhiteHaloedTextColor = 0xb3ffffff;
+static const SkColor kWhiteHaloedHaloColor = 0xb3000000;
+static const SkColor kGrayEmbossedTextColor = 0xff4c4c4c;
+static const SkColor kGrayEmbossedShadowColor = 0x80ffffff;
+
+// Status area font is bigger.
+const int kFontSizeDelta = 1;
////////////////////////////////////////////////////////////////////////////////
// StatusAreaButton
-StatusAreaButton::StatusAreaButton(views::ViewMenuDelegate* menu_delegate)
+StatusAreaButton::StatusAreaButton(StatusAreaHost* host,
+ views::ViewMenuDelegate* menu_delegate)
: MenuButton(NULL, std::wstring(), menu_delegate, false),
- use_menu_button_paint_(false), active_(true) {
+ use_menu_button_paint_(false),
+ active_(true),
+ host_(host) {
+ set_border(NULL);
+ set_use_menu_button_paint(true);
+ gfx::Font font =
+ ResourceBundle::GetSharedInstance().GetFont(ResourceBundle::BaseFont);
+ font = font.DeriveFont(3, gfx::Font::BOLD);
+ SetFont(font);
+ SetShowMultipleIconStates(false);
+ set_alignment(TextButton::ALIGN_CENTER);
set_border(NULL);
// Use an offset that is top aligned with toolbar.
- set_menu_offset(0, 2);
+ set_menu_offset(0, 4);
- // Use a halo for status text as the icons.
- SetTextHaloColor(kStatusTextHaloColor);
+ UpdateTextStyle();
}
void StatusAreaButton::PaintButton(gfx::Canvas* canvas, PaintButtonMode mode) {
@@ -45,6 +64,25 @@ void StatusAreaButton::PaintButton(gfx::Canvas* canvas, PaintButtonMode mode) {
}
}
+void StatusAreaButton::SetText(const std::wstring& text) {
+ // TextButtons normally remember the max text size, so the button's preferred
+ // size will always be as large as the largest text ever put in it.
+ // We clear that max text size, so we can adjust the size to fit the text.
+ // The order is important. ClearMaxTextSize sets the size to that of the
+ // current text, so it must be called after SetText.
+ views::MenuButton::SetText(text);
+ ClearMaxTextSize();
+ PreferredSizeChanged();
+}
+
+bool StatusAreaButton::Activate() {
+ if (active_) {
+ return views::MenuButton::Activate();
+ } else {
+ return true;
+ }
+}
+
gfx::Size StatusAreaButton::GetPreferredSize() {
gfx::Insets insets = views::MenuButton::GetInsets();
gfx::Size prefsize(icon_width() + insets.width(),
@@ -75,22 +113,25 @@ gfx::Insets StatusAreaButton::GetInsets() const {
return insets_;
}
-void StatusAreaButton::SetText(const std::wstring& text) {
- // TextButtons normally remember the max text size, so the button's preferred
- // size will always be as large as the largest text ever put in it.
- // We clear that max text size, so we can adjust the size to fit the text.
- // The order is important. ClearMaxTextSize sets the size to that of the
- // current text, so it must be called after SetText.
- views::MenuButton::SetText(text);
- ClearMaxTextSize();
- PreferredSizeChanged();
+void StatusAreaButton::OnThemeChanged() {
+ UpdateTextStyle();
}
-bool StatusAreaButton::Activate() {
- if (active_) {
- return views::MenuButton::Activate();
- } else {
- return true;
+void StatusAreaButton::UpdateTextStyle() {
+ ClearEmbellishing();
+ switch (host_->GetTextStyle()) {
+ case StatusAreaHost::kWhitePlain:
+ SetEnabledColor(kWhitePlainTextColor);
+ break;
+ case StatusAreaHost::kWhiteHaloed:
+ SetEnabledColor(kWhiteHaloedTextColor);
+ SetTextHaloColor(kWhiteHaloedHaloColor);
+ break;
+ case StatusAreaHost::kGrayEmbossed:
+ SetEnabledColor(kGrayEmbossedTextColor);
+ SetTextShadowColors(kGrayEmbossedShadowColor, kGrayEmbossedShadowColor);
+ SetTextShadowOffset(0, 1);
+ break;
}
}
« no previous file with comments | « chrome/browser/chromeos/status/status_area_button.h ('k') | chrome/browser/chromeos/status/status_area_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698