Commit 2d684526 authored by derat@chromium.org's avatar derat@chromium.org

chromeos/aura: Make login screen status area font non-bold.

This removes StatusAreaButton::Delegate's
GetStatusAreaFont() method and updates the text styles
returned by GetStatusAreaTextStyle() to include the font
weight.

I'm also removing the translucency from the light gray text
style so it'll match the header text on the WebUI login
page.

BUG=111364
TEST=manual


Review URL: http://codereview.chromium.org/9307099

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@120756 0039d316-1c4b-4281-b951-d872f2087c98
parent e0b2c312
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Copyright (c) 2012 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.
......@@ -527,19 +527,15 @@ void BrowserView::ExecuteStatusAreaCommand(
}
}
gfx::Font BrowserView::GetStatusAreaFont(const gfx::Font& font) const {
return font.DeriveFont(0, gfx::Font::BOLD);
}
StatusAreaButton::TextStyle BrowserView::GetStatusAreaTextStyle() const {
ThemeService* theme_service =
ThemeServiceFactory::GetForProfile(browser()->profile());
if (!theme_service->UsingDefaultTheme())
return StatusAreaButton::WHITE_HALOED;
return StatusAreaButton::WHITE_HALOED_BOLD;
return IsOffTheRecord() ?
StatusAreaButton::WHITE_PLAIN : StatusAreaButton::GRAY_EMBOSSED;
StatusAreaButton::WHITE_PLAIN_BOLD : StatusAreaButton::GRAY_EMBOSSED_BOLD;
}
void BrowserView::ButtonVisibilityChanged(views::View* button_view) {
......
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Copyright (c) 2012 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.
......@@ -92,7 +92,6 @@ class BrowserView : public ::BrowserView,
const views::View* button_view, int command_id) const OVERRIDE;
virtual void ExecuteStatusAreaCommand(
const views::View* button_view, int command_id) OVERRIDE;
virtual gfx::Font GetStatusAreaFont(const gfx::Font& font) const OVERRIDE;
virtual StatusAreaButton::TextStyle GetStatusAreaTextStyle() const OVERRIDE;
virtual void ButtonVisibilityChanged(views::View* button_view) OVERRIDE;
......
......@@ -269,12 +269,8 @@ void WebUILoginView::ExecuteStatusAreaCommand(
}
}
gfx::Font WebUILoginView::GetStatusAreaFont(const gfx::Font& font) const {
return font;
}
StatusAreaButton::TextStyle WebUILoginView::GetStatusAreaTextStyle() const {
return StatusAreaButton::GRAY_PLAIN;
return StatusAreaButton::GRAY_PLAIN_LIGHT;
}
void WebUILoginView::ButtonVisibilityChanged(views::View* button_view) {
......
......@@ -87,7 +87,6 @@ class WebUILoginView : public views::WidgetDelegateView,
const views::View* button_view, int command_id) const OVERRIDE;
virtual void ExecuteStatusAreaCommand(
const views::View* button_view, int command_id) OVERRIDE;
virtual gfx::Font GetStatusAreaFont(const gfx::Font& font) const OVERRIDE;
virtual StatusAreaButton::TextStyle GetStatusAreaTextStyle() const OVERRIDE;
virtual void ButtonVisibilityChanged(views::View* button_view) OVERRIDE;
......
......@@ -15,7 +15,7 @@ namespace {
// Colors for different text styles.
const SkColor kWhitePlainTextColor = 0x99ffffff;
const SkColor kGrayPlainTextColor = 0x99666666;
const SkColor kGrayPlainTextColor = 0xff666666;
const SkColor kWhiteHaloedTextColor = 0xb3ffffff;
const SkColor kWhiteHaloedHaloColor = 0xb3000000;
const SkColor kGrayEmbossedTextColor = 0xff4c4c4c;
......@@ -39,11 +39,10 @@ StatusAreaButton::StatusAreaButton(Delegate* button_delegate,
delegate_(button_delegate) {
set_border(NULL);
gfx::Font font =
ResourceBundle::GetSharedInstance().GetFont(ResourceBundle::BaseFont);
font = font.DeriveFont(kFontSizeDelta);
font = delegate_->GetStatusAreaFont(font);
SetFont(font);
light_font_ =
ResourceBundle::GetSharedInstance().GetFont(ResourceBundle::BaseFont).
DeriveFont(kFontSizeDelta);
bold_font_ = light_font_.DeriveFont(0, gfx::Font::BOLD);
SetShowMultipleIconStates(false);
set_alignment(TextButton::ALIGN_CENTER);
......@@ -136,17 +135,21 @@ void StatusAreaButton::SetMenuActive(bool active) {
void StatusAreaButton::UpdateTextStyle() {
ClearEmbellishing();
switch (delegate_->GetStatusAreaTextStyle()) {
case WHITE_PLAIN:
case WHITE_PLAIN_BOLD:
SetFont(bold_font_);
SetEnabledColor(kWhitePlainTextColor);
break;
case GRAY_PLAIN:
case GRAY_PLAIN_LIGHT:
SetFont(light_font_);
SetEnabledColor(kGrayPlainTextColor);
break;
case WHITE_HALOED:
case WHITE_HALOED_BOLD:
SetFont(bold_font_);
SetEnabledColor(kWhiteHaloedTextColor);
SetTextHaloColor(kWhiteHaloedHaloColor);
break;
case GRAY_EMBOSSED:
case GRAY_EMBOSSED_BOLD:
SetFont(bold_font_);
SetEnabledColor(kGrayEmbossedTextColor);
SetTextShadowColors(kGrayEmbossedShadowColor, kGrayEmbossedShadowColor);
SetTextShadowOffset(0, 1);
......
......@@ -8,23 +8,20 @@
#include "base/compiler_specific.h"
#include "base/string16.h"
#include "ui/gfx/font.h"
#include "ui/views/controls/button/menu_button.h"
#include "ui/views/controls/menu/view_menu_delegate.h"
namespace gfx {
class Font;
}
// Button to be used to represent status and allow menus to be popped up.
// Shows current button state by drawing a border around the current icon.
class StatusAreaButton : public views::MenuButton {
public:
// Different text styles for different types of backgrounds.
enum TextStyle {
WHITE_PLAIN,
GRAY_PLAIN,
WHITE_HALOED,
GRAY_EMBOSSED
WHITE_PLAIN_BOLD,
GRAY_PLAIN_LIGHT,
WHITE_HALOED_BOLD,
GRAY_EMBOSSED_BOLD
};
class Delegate {
......@@ -43,9 +40,8 @@ class StatusAreaButton : public views::MenuButton {
virtual void ExecuteStatusAreaCommand(
const views::View* button_view, int command_id) = 0;
// Return the button font. |font| is set to the default button font.
virtual gfx::Font GetStatusAreaFont(const gfx::Font& font) const = 0;
// Get the style that should currently be used in rendering the button's
// text.
virtual TextStyle GetStatusAreaTextStyle() const = 0;
// Handle visibility changes (e.g. resize the status area).
......@@ -106,6 +102,10 @@ class StatusAreaButton : public views::MenuButton {
private:
Delegate* delegate_;
// Fonts used to render the button's text.
gfx::Font light_font_;
gfx::Font bold_font_;
DISALLOW_COPY_AND_ASSIGN(StatusAreaButton);
};
......
......@@ -184,36 +184,32 @@ void StatusAreaHostAura::ExecuteStatusAreaCommand(
#endif
}
gfx::Font StatusAreaHostAura::GetStatusAreaFont(const gfx::Font& font) const {
return font.DeriveFont(0, gfx::Font::BOLD);
}
StatusAreaButton::TextStyle StatusAreaHostAura::GetStatusAreaTextStyle() const {
#if defined(OS_CHROMEOS)
if (!chromeos::UserManager::Get()->user_is_logged_in())
return StatusAreaButton::GRAY_PLAIN;
return StatusAreaButton::GRAY_PLAIN_LIGHT;
const chromeos::ScreenLocker* locker =
chromeos::ScreenLocker::default_screen_locker();
if (locker && locker->locked())
return StatusAreaButton::GRAY_PLAIN;
return StatusAreaButton::GRAY_PLAIN_LIGHT;
#endif
if (ash::Shell::GetInstance()->IsWindowModeCompact()) {
Browser* browser = BrowserList::GetLastActive();
if (!browser)
return StatusAreaButton::WHITE_HALOED;
return StatusAreaButton::WHITE_HALOED_BOLD;
ThemeService* theme_service =
ThemeServiceFactory::GetForProfile(browser->profile());
if (!theme_service->UsingDefaultTheme())
return StatusAreaButton::WHITE_HALOED;
return StatusAreaButton::WHITE_HALOED_BOLD;
return browser->profile()->IsOffTheRecord() ?
StatusAreaButton::WHITE_PLAIN :
StatusAreaButton::GRAY_EMBOSSED;
StatusAreaButton::WHITE_PLAIN_BOLD :
StatusAreaButton::GRAY_EMBOSSED_BOLD;
} else {
return StatusAreaButton::WHITE_HALOED;
return StatusAreaButton::WHITE_HALOED_BOLD;
}
}
......
......@@ -45,7 +45,6 @@ class StatusAreaHostAura : public StatusAreaButton::Delegate,
const views::View* button_view, int command_id) const OVERRIDE;
virtual void ExecuteStatusAreaCommand(
const views::View* button_view, int command_id) OVERRIDE;
virtual gfx::Font GetStatusAreaFont(const gfx::Font& font) const OVERRIDE;
virtual StatusAreaButton::TextStyle GetStatusAreaTextStyle() const OVERRIDE;
virtual void ButtonVisibilityChanged(views::View* button_view) OVERRIDE;
......
......@@ -31,7 +31,7 @@ IN_PROC_BROWSER_TEST_F(StatusAreaHostAuraTest, TextStyle) {
#if defined(OS_CHROMEOS)
ASSERT_FALSE(chromeos::UserManager::Get()->user_is_logged_in());
EXPECT_EQ(StatusAreaButton::GRAY_PLAIN, host->GetStatusAreaTextStyle());
EXPECT_EQ(StatusAreaButton::GRAY_PLAIN_LIGHT, host->GetStatusAreaTextStyle());
// ProfileManager expects a profile dir to be set on Chrome OS.
CommandLine::ForCurrentProcess()->AppendSwitchNative(
......@@ -41,15 +41,19 @@ IN_PROC_BROWSER_TEST_F(StatusAreaHostAuraTest, TextStyle) {
#endif
if (ash::Shell::GetInstance()->IsWindowModeCompact()) {
EXPECT_EQ(StatusAreaButton::GRAY_EMBOSSED, host->GetStatusAreaTextStyle());
EXPECT_EQ(StatusAreaButton::GRAY_EMBOSSED_BOLD,
host->GetStatusAreaTextStyle());
Browser* incognito_browser = CreateIncognitoBrowser();
EXPECT_EQ(StatusAreaButton::WHITE_PLAIN, host->GetStatusAreaTextStyle());
EXPECT_EQ(StatusAreaButton::WHITE_PLAIN_BOLD,
host->GetStatusAreaTextStyle());
incognito_browser->CloseWindow();
EXPECT_EQ(StatusAreaButton::GRAY_EMBOSSED, host->GetStatusAreaTextStyle());
EXPECT_EQ(StatusAreaButton::GRAY_EMBOSSED_BOLD,
host->GetStatusAreaTextStyle());
} else {
EXPECT_EQ(StatusAreaButton::WHITE_HALOED, host->GetStatusAreaTextStyle());
EXPECT_EQ(StatusAreaButton::WHITE_HALOED_BOLD,
host->GetStatusAreaTextStyle());
}
#if defined(OS_CHROMEOS)
......@@ -64,7 +68,7 @@ IN_PROC_BROWSER_TEST_F(StatusAreaHostAuraTest, TextStyle) {
if (!tester->IsLocked())
lock_state_observer.Wait();
ASSERT_TRUE(tester->IsLocked());
EXPECT_EQ(StatusAreaButton::GRAY_PLAIN, host->GetStatusAreaTextStyle());
EXPECT_EQ(StatusAreaButton::GRAY_PLAIN_LIGHT, host->GetStatusAreaTextStyle());
chromeos::ScreenLocker::Hide();
ui_test_utils::RunAllPendingInMessageLoop();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment