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

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

Issue 8438064: Separate StatusAreaView from StatusAreaViewChromeos (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Clang fixes + fixup Delegate Created 9 years, 1 month 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 e4b4103999d185db30efa0844ce1c1758b1ad5b6..657136982cdef0715204186381651a32c04560ab 100644
--- a/chrome/browser/chromeos/status/status_area_button.cc
+++ b/chrome/browser/chromeos/status/status_area_button.cc
@@ -29,26 +29,19 @@ const int kIconHorizontalPad = 2;
}
-namespace chromeos {
-
////////////////////////////////////////////////////////////////////////////////
// StatusAreaButton
-StatusAreaButton::StatusAreaButton(StatusAreaHost* host,
+StatusAreaButton::StatusAreaButton(Delegate* button_delegate,
views::ViewMenuDelegate* menu_delegate)
: MenuButton(NULL, string16(), menu_delegate, false),
- use_menu_button_paint_(false),
- active_(true),
- host_(host) {
+ menu_active_(true),
+ delegate_(button_delegate) {
set_border(NULL);
- set_use_menu_button_paint(true);
-
- bool webui_login = host_->GetScreenMode() == StatusAreaHost::kWebUILoginMode;
gfx::Font font =
ResourceBundle::GetSharedInstance().GetFont(ResourceBundle::BaseFont);
- font = font.DeriveFont(kFontSizeDelta, webui_login ? font.GetStyle()
- : gfx::Font::BOLD);
+ font = font.DeriveFont(kFontSizeDelta, delegate_->GetFontStyle(font));
SetFont(font);
SetShowMultipleIconStates(false);
@@ -68,12 +61,7 @@ void StatusAreaButton::PaintButton(gfx::Canvas* canvas, PaintButtonMode mode) {
canvas->FillRect(SkColorSetARGB(0x19, 0xFF, 0xFF, 0xFF), GetLocalBounds());
}
- if (use_menu_button_paint_) {
- views::MenuButton::PaintButton(canvas, mode);
- } else {
- canvas->DrawBitmapInt(icon(), horizontal_padding(), 0);
- OnPaintFocusBorder(canvas);
- }
+ views::MenuButton::PaintButton(canvas, mode);
}
void StatusAreaButton::SetText(const string16& text) {
@@ -88,7 +76,7 @@ void StatusAreaButton::SetText(const string16& text) {
}
bool StatusAreaButton::Activate() {
- if (active_)
+ if (menu_active_)
return views::MenuButton::Activate();
else
return true;
@@ -100,18 +88,14 @@ gfx::Size StatusAreaButton::GetPreferredSize() {
icon_height() + insets.height());
// Adjusts size when use menu button paint.
- if (use_menu_button_paint_) {
- gfx::Size menu_button_size = views::MenuButton::GetPreferredSize();
- prefsize.SetSize(
- std::max(prefsize.width(), menu_button_size.width()),
- std::max(prefsize.height(), menu_button_size.height())
- );
-
- // Shift 1-pixel down for odd number of pixels in vertical space.
- if ((prefsize.height() - menu_button_size.height()) % 2) {
- insets_.Set(insets.top() + 1, insets.left(),
- insets.bottom(), insets.right());
- }
+ gfx::Size menu_button_size = views::MenuButton::GetPreferredSize();
+ prefsize.SetSize(std::max(prefsize.width(), menu_button_size.width()),
+ std::max(prefsize.height(), menu_button_size.height()));
+
+ // Shift 1-pixel down for odd number of pixels in vertical space.
+ if ((prefsize.height() - menu_button_size.height()) % 2) {
+ insets_.Set(insets.top() + 1, insets.left(),
+ insets.bottom(), insets.right());
}
// Add padding.
@@ -131,7 +115,7 @@ void StatusAreaButton::OnThemeChanged() {
void StatusAreaButton::SetVisible(bool visible) {
if (visible != IsVisible()) {
views::MenuButton::SetVisible(visible);
- host_->ButtonVisibilityChanged(this);
+ delegate_->ButtonVisibilityChanged(this);
}
}
@@ -158,23 +142,21 @@ int StatusAreaButton::horizontal_padding() {
void StatusAreaButton::UpdateTextStyle() {
ClearEmbellishing();
- switch (host_->GetTextStyle()) {
- case StatusAreaHost::kWhitePlain:
+ switch (delegate_->GetTextStyle()) {
+ case WHITE_PLAIN:
SetEnabledColor(kWhitePlainTextColor);
break;
- case StatusAreaHost::kGrayPlain:
+ case GRAY_PLAIN:
SetEnabledColor(kGrayPlainTextColor);
break;
- case StatusAreaHost::kWhiteHaloed:
+ case WHITE_HALOED:
SetEnabledColor(kWhiteHaloedTextColor);
SetTextHaloColor(kWhiteHaloedHaloColor);
break;
- case StatusAreaHost::kGrayEmbossed:
+ case GRAY_EMBOSSED:
SetEnabledColor(kGrayEmbossedTextColor);
SetTextShadowColors(kGrayEmbossedShadowColor, kGrayEmbossedShadowColor);
SetTextShadowOffset(0, 1);
break;
}
}
-
-} // namespace chromeos

Powered by Google App Engine
This is Rietveld 408576698