diff options
author | sadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-04-12 01:47:58 +0000 |
---|---|---|
committer | sadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-04-12 01:47:58 +0000 |
commit | 5793906a89da44f153d3ec999544653fae5e58e1 (patch) | |
tree | 6916cc6dd1733cf56a2d34edf5a16a76fefdd415 | |
parent | 94a7de34e8770c07c01ee6c2c2e07223b2c5b4a4 (diff) | |
download | chromium_src-5793906a89da44f153d3ec999544653fae5e58e1.zip chromium_src-5793906a89da44f153d3ec999544653fae5e58e1.tar.gz chromium_src-5793906a89da44f153d3ec999544653fae5e58e1.tar.bz2 |
ash: Some UI tweaks in the header items.
Instead of underlining the text on hover, change the background color. And for
the sub-popup header items, use a color scheme different from the other items in
the popup.
BUG=120201,121963
TEST=none
Review URL: https://chromiumcodereview.appspot.com/9969173
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@131895 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | ash/system/bluetooth/tray_bluetooth.cc | 2 | ||||
-rw-r--r-- | ash/system/date/date_view.cc | 18 | ||||
-rw-r--r-- | ash/system/date/date_view.h | 2 | ||||
-rw-r--r-- | ash/system/ime/tray_ime.cc | 2 | ||||
-rw-r--r-- | ash/system/network/tray_network.cc | 2 | ||||
-rw-r--r-- | ash/system/power/tray_power.cc | 28 | ||||
-rw-r--r-- | ash/system/tray/tray_constants.cc | 3 | ||||
-rw-r--r-- | ash/system/tray/tray_constants.h | 3 | ||||
-rw-r--r-- | ash/system/tray/tray_views.cc | 17 | ||||
-rw-r--r-- | ash/system/tray/tray_views.h | 8 |
10 files changed, 53 insertions, 32 deletions
diff --git a/ash/system/bluetooth/tray_bluetooth.cc b/ash/system/bluetooth/tray_bluetooth.cc index 4d5bc35..3a4d17d 100644 --- a/ash/system/bluetooth/tray_bluetooth.cc +++ b/ash/system/bluetooth/tray_bluetooth.cc @@ -60,7 +60,7 @@ class BluetoothDetailedView : public views::View, add_device_(NULL), toggle_bluetooth_(NULL) { SetLayoutManager(new views::BoxLayout( - views::BoxLayout::kVertical, 1, 1, 1)); + views::BoxLayout::kVertical, 0, 0, 0)); set_background(views::Background::CreateSolidBackground(kBackgroundColor)); BluetoothDeviceList list; diff --git a/ash/system/date/date_view.cc b/ash/system/date/date_view.cc index 1a39580..9d8add8 100644 --- a/ash/system/date/date_view.cc +++ b/ash/system/date/date_view.cc @@ -125,24 +125,6 @@ bool DateView::PerformAction(const views::Event& event) { return true; } -void DateView::OnMouseEntered(const views::MouseEvent& event) { - if (!actionable_) - return; - gfx::Font font = label_->font(); - label_->SetFont(font.DeriveFont(0, - font.GetStyle() | gfx::Font::UNDERLINED)); - SchedulePaint(); -} - -void DateView::OnMouseExited(const views::MouseEvent& event) { - if (!actionable_) - return; - gfx::Font font = label_->font(); - label_->SetFont(font.DeriveFont(0, - font.GetStyle() & ~gfx::Font::UNDERLINED)); - SchedulePaint(); -} - void DateView::OnLocaleChanged() { UpdateText(); } diff --git a/ash/system/date/date_view.h b/ash/system/date/date_view.h index 8e0faaa..787ca69 100644 --- a/ash/system/date/date_view.h +++ b/ash/system/date/date_view.h @@ -44,8 +44,6 @@ class DateView : public ActionableView { virtual bool PerformAction(const views::Event& event) OVERRIDE; // Overridden from views::View. - virtual void OnMouseEntered(const views::MouseEvent& event) OVERRIDE; - virtual void OnMouseExited(const views::MouseEvent& event) OVERRIDE; virtual void OnLocaleChanged() OVERRIDE; base::OneShotTimer<DateView> timer_; diff --git a/ash/system/ime/tray_ime.cc b/ash/system/ime/tray_ime.cc index 8c43ad3..29aa9c0 100644 --- a/ash/system/ime/tray_ime.cc +++ b/ash/system/ime/tray_ime.cc @@ -60,7 +60,7 @@ class IMEDetailedView : public views::View, : login_(login), header_(NULL) { SetLayoutManager(new views::BoxLayout( - views::BoxLayout::kVertical, 1, 1, 1)); + views::BoxLayout::kVertical, 0, 0, 0)); set_background(views::Background::CreateSolidBackground(kBackgroundColor)); SystemTrayDelegate* delegate = Shell::GetInstance()->tray_delegate(); IMEInfoList list; diff --git a/ash/system/network/tray_network.cc b/ash/system/network/tray_network.cc index 712af7e..9fa70e6 100644 --- a/ash/system/network/tray_network.cc +++ b/ash/system/network/tray_network.cc @@ -173,7 +173,7 @@ class NetworkDetailedView : public views::View, proxy_settings_(NULL), info_bubble_(NULL) { SetLayoutManager(new views::BoxLayout( - views::BoxLayout::kVertical, 1, 1, 1)); + views::BoxLayout::kVertical, 0, 0, 0)); set_background(views::Background::CreateSolidBackground(kBackgroundColor)); SystemTrayDelegate* delegate = Shell::GetInstance()->tray_delegate(); delegate->RequestNetworkScan(); diff --git a/ash/system/power/tray_power.cc b/ash/system/power/tray_power.cc index df895d1..c157890 100644 --- a/ash/system/power/tray_power.cc +++ b/ash/system/power/tray_power.cc @@ -9,6 +9,7 @@ #include "ash/system/power/power_supply_status.h" #include "ash/system/tray/system_tray_delegate.h" #include "ash/system/tray/tray_constants.h" +#include "ash/system/tray/tray_views.h" #include "base/string_number_conversions.h" #include "base/stringprintf.h" #include "base/utf_string_conversions.h" @@ -25,6 +26,7 @@ #include "ui/views/controls/image_view.h" #include "ui/views/controls/label.h" #include "ui/views/layout/box_layout.h" +#include "ui/views/layout/fill_layout.h" #include "ui/views/view.h" #include "ui/views/widget/widget.h" #include "unicode/fieldpos.h" @@ -39,6 +41,8 @@ const int kBatteryImageHeight = 25; const int kBatteryImageWidth = 25; // Number of different power states. const int kNumPowerImages = 15; +// Top/bottom padding of the text items. +const int kPaddingVertical = 10; } namespace tray { @@ -181,23 +185,37 @@ views::View* TrayPower::CreateTrayView(user::LoginStatus status) { views::View* TrayPower::CreateDefaultView(user::LoginStatus status) { date_.reset(new tray::DateView(tray::DateView::DATE)); - if (status != user::LOGGED_IN_NONE && status != user::LOGGED_IN_LOCKED) - date_->SetActionable(true); views::View* container = new views::View; views::BoxLayout* layout = new views::BoxLayout(views::BoxLayout::kHorizontal, - kTrayPopupPaddingHorizontal, 10, 0); + 0, 0, 0); + layout->set_spread_blank_space(true); container->SetLayoutManager(layout); container->set_background(views::Background::CreateSolidBackground( - SkColorSetRGB(0xf1, 0xf1, 0xf1))); - container->AddChildView(date_.get()); + kHeaderBackgroundColor)); + HoverHighlightView* view = new HoverHighlightView(NULL); + view->SetLayoutManager(new views::BoxLayout(views::BoxLayout::kHorizontal, + kTrayPopupPaddingHorizontal, kPaddingVertical, 0)); + view->AddChildView(date_.get()); + container->AddChildView(view); + + if (status != user::LOGGED_IN_NONE && status != user::LOGGED_IN_LOCKED) { + date_->SetActionable(true); + view->set_highlight_color(kHeaderHoverBackgroundColor); + } else { + view->set_highlight_color(SkColorSetARGB(0, 0, 0, 0)); + } PowerSupplyStatus power_status = ash::Shell::GetInstance()->tray_delegate()->GetPowerSupplyStatus(); if (power_status.battery_is_present) { power_.reset(new tray::PowerPopupView()); power_->UpdatePowerStatus(power_status); + power_->set_border(views::Border::CreateSolidSidedBorder( + kPaddingVertical, kTrayPopupPaddingHorizontal, + kPaddingVertical, kTrayPopupPaddingHorizontal, + SkColorSetARGB(0, 0, 0, 0))); container->AddChildView(power_.get()); } return container; diff --git a/ash/system/tray/tray_constants.cc b/ash/system/tray/tray_constants.cc index a576f2c..6caa626 100644 --- a/ash/system/tray/tray_constants.cc +++ b/ash/system/tray/tray_constants.cc @@ -20,6 +20,9 @@ const int kTrayRoundedBorderRadius = 2; const SkColor kBackgroundColor = SkColorSetRGB(0xfe, 0xfe, 0xfe); const SkColor kHoverBackgroundColor = SkColorSetRGB(0xf5, 0xf5, 0xf5); +const SkColor kHeaderBackgroundColor = SkColorSetRGB(0xf1, 0xf1, 0xf1); +const SkColor kHeaderHoverBackgroundColor = SkColorSetRGB(0xe1, 0xe1, 0xe1); + const SkColor kBorderDarkColor = SkColorSetARGB(51, 0, 0, 0); const SkColor kBorderLightColor = SkColorSetRGB(0xeb, 0xeb, 0xeb); diff --git a/ash/system/tray/tray_constants.h b/ash/system/tray/tray_constants.h index 2d72a9e..bea5b94 100644 --- a/ash/system/tray/tray_constants.h +++ b/ash/system/tray/tray_constants.h @@ -22,6 +22,9 @@ extern const int kTrayRoundedBorderRadius; extern const SkColor kBackgroundColor; extern const SkColor kHoverBackgroundColor; +extern const SkColor kHeaderBackgroundColor; +extern const SkColor kHeaderHoverBackgroundColor; + extern const SkColor kBorderDarkColor; extern const SkColor kBorderLightColor; diff --git a/ash/system/tray/tray_views.cc b/ash/system/tray/tray_views.cc index b292407..4875109 100644 --- a/ash/system/tray/tray_views.cc +++ b/ash/system/tray/tray_views.cc @@ -10,6 +10,7 @@ #include "grit/ui_resources.h" #include "ui/base/accessibility/accessible_view_state.h" #include "ui/base/resource/resource_bundle.h" +#include "ui/gfx/canvas.h" #include "ui/gfx/image/image.h" #include "ui/views/border.h" #include "ui/views/controls/label.h" @@ -68,7 +69,10 @@ bool ActionableView::OnMousePressed(const views::MouseEvent& event) { // HoverHighlightView HoverHighlightView::HoverHighlightView(ViewClickListener* listener) - : listener_(listener) { + : listener_(listener), + highlight_color_(kHoverBackgroundColor), + default_color_(0), + hover_(false) { set_notify_enter_exit_on_child(true); } @@ -117,13 +121,12 @@ bool HoverHighlightView::PerformAction(const views::Event& event) { } void HoverHighlightView::OnMouseEntered(const views::MouseEvent& event) { - set_background(views::Background::CreateSolidBackground( - ash::kHoverBackgroundColor)); + hover_ = true; SchedulePaint(); } void HoverHighlightView::OnMouseExited(const views::MouseEvent& event) { - set_background(NULL); + hover_ = false; SchedulePaint(); } @@ -132,6 +135,10 @@ void HoverHighlightView::GetAccessibleState(ui::AccessibleViewState* state) { state->name = accessible_name_; } +void HoverHighlightView::OnPaintBackground(gfx::Canvas* canvas) { + canvas->DrawColor(hover_ ? highlight_color_ : default_color_); +} + //////////////////////////////////////////////////////////////////////////////// // FixedSizedScrollView @@ -185,6 +192,8 @@ views::View* CreateDetailedHeaderEntry(int string_id, container->AddChildView(header); container->SetAccessibleName( rb.GetLocalizedString(IDS_ASH_STATUS_TRAY_PREVIOUS_MENU)); + container->set_highlight_color(kHeaderHoverBackgroundColor); + container->set_default_color(kHeaderBackgroundColor); return container; } diff --git a/ash/system/tray/tray_views.h b/ash/system/tray/tray_views.h index 535f3d0..e06c574 100644 --- a/ash/system/tray/tray_views.h +++ b/ash/system/tray/tray_views.h @@ -13,6 +13,7 @@ #include "ui/views/view.h" class SkBitmap; +typedef unsigned int SkColor; namespace views { class Label; @@ -84,6 +85,9 @@ class HoverHighlightView : public ActionableView { // Set the accessible name. Should be used if this doesn't match the label. void SetAccessibleName(const string16& name); + void set_highlight_color(SkColor color) { highlight_color_ = color; } + void set_default_color(SkColor color) { default_color_ = color; } + private: // Overridden from ActionableView. virtual bool PerformAction(const views::Event& event) OVERRIDE; @@ -92,9 +96,13 @@ class HoverHighlightView : public ActionableView { virtual void OnMouseEntered(const views::MouseEvent& event) OVERRIDE; virtual void OnMouseExited(const views::MouseEvent& event) OVERRIDE; virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE; + virtual void OnPaintBackground(gfx::Canvas* canvas) OVERRIDE; ViewClickListener* listener_; string16 accessible_name_; + SkColor highlight_color_; + SkColor default_color_; + bool hover_; DISALLOW_COPY_AND_ASSIGN(HoverHighlightView); }; |