diff options
author | sadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-05-11 18:08:06 +0000 |
---|---|---|
committer | sadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-05-11 18:08:06 +0000 |
commit | 082276bffc1bf9706663e965370be0aac47867e0 (patch) | |
tree | 636a3318393fb980415a6bd53e6cf7646075e7ec | |
parent | 2736c031e3c5193012fe6dba36125fa450c51fcd (diff) | |
download | chromium_src-082276bffc1bf9706663e965370be0aac47867e0.zip chromium_src-082276bffc1bf9706663e965370be0aac47867e0.tar.gz chromium_src-082276bffc1bf9706663e965370be0aac47867e0.tar.bz2 |
ash: Add hover-effect to the items in the bottom rows of the uber tray popups.
BUG=127430
TEST=none
Review URL: https://chromiumcodereview.appspot.com/10377107
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@136612 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | ash/system/bluetooth/tray_bluetooth.cc | 4 | ||||
-rw-r--r-- | ash/system/date/date_view.cc | 18 | ||||
-rw-r--r-- | ash/system/date/date_view.h | 4 | ||||
-rw-r--r-- | ash/system/date/tray_date.cc | 12 | ||||
-rw-r--r-- | ash/system/network/tray_network.cc | 12 | ||||
-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 | 63 | ||||
-rw-r--r-- | ash/system/tray/tray_views.h | 10 | ||||
-rw-r--r-- | ui/resources/ui_resources.grd | 10 |
10 files changed, 110 insertions, 29 deletions
diff --git a/ash/system/bluetooth/tray_bluetooth.cc b/ash/system/bluetooth/tray_bluetooth.cc index dcd561b..1f55bcd 100644 --- a/ash/system/bluetooth/tray_bluetooth.cc +++ b/ash/system/bluetooth/tray_bluetooth.cc @@ -104,7 +104,9 @@ class BluetoothDetailedView : public views::View, ash::Shell::GetInstance()->tray_delegate(); toggle_bluetooth_ = new TrayPopupHeaderButton(this, IDR_AURA_UBER_TRAY_BLUETOOTH_ENABLED, - IDR_AURA_UBER_TRAY_BLUETOOTH_DISABLED); + IDR_AURA_UBER_TRAY_BLUETOOTH_DISABLED, + IDR_AURA_UBER_TRAY_BLUETOOTH_ENABLED_HOVER, + IDR_AURA_UBER_TRAY_BLUETOOTH_DISABLED_HOVER); toggle_bluetooth_->SetToggled(!delegate->GetBluetoothEnabled()); header_->AddButton(toggle_bluetooth_); } diff --git a/ash/system/date/date_view.cc b/ash/system/date/date_view.cc index 3481d2a..c1e6166 100644 --- a/ash/system/date/date_view.cc +++ b/ash/system/date/date_view.cc @@ -109,6 +109,8 @@ DateView::DateView() : actionable_(false) { date_label_ = CreateLabel(); date_label_->SetFont(date_label_->font().DeriveFont(0, gfx::Font::BOLD)); day_of_week_label_ = CreateLabel(); + date_label_->SetEnabledColor(kHeaderTextColorNormal); + day_of_week_label_->SetEnabledColor(kHeaderTextColorNormal); UpdateTextInternal(base::Time::Now()); AddChildView(date_label_); AddChildView(day_of_week_label_); @@ -136,6 +138,22 @@ bool DateView::PerformAction(const views::Event& event) { return true; } +void DateView::OnMouseEntered(const views::MouseEvent& event) { + if (!actionable_) + return; + date_label_->SetEnabledColor(kHeaderTextColorHover); + day_of_week_label_->SetEnabledColor(kHeaderTextColorHover); + SchedulePaint(); +} + +void DateView::OnMouseExited(const views::MouseEvent& event) { + if (!actionable_) + return; + date_label_->SetEnabledColor(kHeaderTextColorNormal); + day_of_week_label_->SetEnabledColor(kHeaderTextColorNormal); + SchedulePaint(); +} + TimeView::TimeView() : hour_type_( ash::Shell::GetInstance()->tray_delegate()->GetHourClockType()) { diff --git a/ash/system/date/date_view.h b/ash/system/date/date_view.h index 6ed3ac1..081ed6f 100644 --- a/ash/system/date/date_view.h +++ b/ash/system/date/date_view.h @@ -66,6 +66,10 @@ class DateView : public BaseDateTimeView { // Overridden from 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; + views::Label* date_label_; views::Label* day_of_week_label_; diff --git a/ash/system/date/tray_date.cc b/ash/system/date/tray_date.cc index 5288947..a3224a5 100644 --- a/ash/system/date/tray_date.cc +++ b/ash/system/date/tray_date.cc @@ -66,20 +66,26 @@ class DateDefaultView : public views::View, help_ = new ash::internal::TrayPopupHeaderButton(this, IDR_AURA_UBER_TRAY_HELP, - IDR_AURA_UBER_TRAY_HELP); + IDR_AURA_UBER_TRAY_HELP, + IDR_AURA_UBER_TRAY_HELP_HOVER, + IDR_AURA_UBER_TRAY_HELP_HOVER); view->AddButton(help_); if (login != ash::user::LOGGED_IN_LOCKED && login != ash::user::LOGGED_IN_KIOSK) { shutdown_ = new ash::internal::TrayPopupHeaderButton(this, IDR_AURA_UBER_TRAY_SHUTDOWN, - IDR_AURA_UBER_TRAY_SHUTDOWN); + IDR_AURA_UBER_TRAY_SHUTDOWN, + IDR_AURA_UBER_TRAY_SHUTDOWN_HOVER, + IDR_AURA_UBER_TRAY_SHUTDOWN_HOVER); view->AddButton(shutdown_); if (login != ash::user::LOGGED_IN_GUEST) { lock_ = new ash::internal::TrayPopupHeaderButton(this, IDR_AURA_UBER_TRAY_LOCKSCREEN, - IDR_AURA_UBER_TRAY_LOCKSCREEN); + IDR_AURA_UBER_TRAY_LOCKSCREEN, + IDR_AURA_UBER_TRAY_LOCKSCREEN_HOVER, + IDR_AURA_UBER_TRAY_LOCKSCREEN_HOVER); view->AddButton(lock_); } } diff --git a/ash/system/network/tray_network.cc b/ash/system/network/tray_network.cc index 4e7ae09..c75db53 100644 --- a/ash/system/network/tray_network.cc +++ b/ash/system/network/tray_network.cc @@ -227,17 +227,23 @@ class NetworkDetailedView : public views::View, void AppendHeaderButtons() { button_wifi_ = new TrayPopupHeaderButton(this, IDR_AURA_UBER_TRAY_WIFI_ENABLED, - IDR_AURA_UBER_TRAY_WIFI_DISABLED); + IDR_AURA_UBER_TRAY_WIFI_DISABLED, + IDR_AURA_UBER_TRAY_WIFI_ENABLED_HOVER, + IDR_AURA_UBER_TRAY_WIFI_DISABLED_HOVER); header_->AddButton(button_wifi_); button_cellular_ = new TrayPopupHeaderButton(this, IDR_AURA_UBER_TRAY_CELLULAR_ENABLED, - IDR_AURA_UBER_TRAY_CELLULAR_DISABLED); + IDR_AURA_UBER_TRAY_CELLULAR_DISABLED, + IDR_AURA_UBER_TRAY_CELLULAR_ENABLED_HOVER, + IDR_AURA_UBER_TRAY_CELLULAR_DISABLED_HOVER); header_->AddButton(button_cellular_); info_icon_ = new TrayPopupHeaderButton(this, IDR_AURA_UBER_TRAY_NETWORK_INFO, - IDR_AURA_UBER_TRAY_NETWORK_INFO); + IDR_AURA_UBER_TRAY_NETWORK_INFO, + IDR_AURA_UBER_TRAY_NETWORK_INFO_HOVER, + IDR_AURA_UBER_TRAY_NETWORK_INFO_HOVER); header_->AddButton(info_icon_); } diff --git a/ash/system/tray/tray_constants.cc b/ash/system/tray/tray_constants.cc index 4799a31..4a9ddad 100644 --- a/ash/system/tray/tray_constants.cc +++ b/ash/system/tray/tray_constants.cc @@ -33,6 +33,9 @@ const SkColor kButtonStrokeColor = SkColorSetRGB(0xdd, 0xdd, 0xdd); const SkColor kFocusBorderColor = SkColorSetRGB(64, 128, 250); +const SkColor kHeaderTextColorNormal = SkColorSetARGB(0x7f, 0, 0, 0); +const SkColor kHeaderTextColorHover = SkColorSetARGB(0xd3, 0, 0, 0); + const int kTrayPopupWidth = 300; } // namespace ash diff --git a/ash/system/tray/tray_constants.h b/ash/system/tray/tray_constants.h index 852db20..3f0dd51 100644 --- a/ash/system/tray/tray_constants.h +++ b/ash/system/tray/tray_constants.h @@ -35,6 +35,9 @@ extern const SkColor kButtonStrokeColor; extern const SkColor kFocusBorderColor; +extern const SkColor kHeaderTextColorNormal; +extern const SkColor kHeaderTextColorHover; + extern const int kTrayPopupWidth; } // namespace ash diff --git a/ash/system/tray/tray_views.cc b/ash/system/tray/tray_views.cc index 573f5cc..84f5f16 100644 --- a/ash/system/tray/tray_views.cc +++ b/ash/system/tray/tray_views.cc @@ -97,8 +97,11 @@ void ActionableView::GetAccessibleState(ui::AccessibleViewState* state) { HoverHighlightView::HoverHighlightView(ViewClickListener* listener) : listener_(listener), + text_label_(NULL), highlight_color_(kHoverBackgroundColor), default_color_(0), + text_highlight_color_(0), + text_default_color_(0), fixed_height_(0), hover_(false) { set_notify_enter_exit_on_child(true); @@ -117,9 +120,11 @@ void HoverHighlightView::AddIconAndLabel(const SkBitmap& image, image_view->SetImage(image); AddChildView(image_view); - views::Label* label = new views::Label(text); - label->SetFont(label->font().DeriveFont(0, style)); - AddChildView(label); + text_label_ = new views::Label(text); + text_label_->SetFont(text_label_->font().DeriveFont(0, style)); + if (text_default_color_) + text_label_->SetEnabledColor(text_default_color_); + AddChildView(text_label_); SetAccessibleName(text); } @@ -127,13 +132,15 @@ void HoverHighlightView::AddIconAndLabel(const SkBitmap& image, void HoverHighlightView::AddLabel(const string16& text, gfx::Font::FontStyle style) { SetLayoutManager(new views::FillLayout()); - views::Label* label = new views::Label(text); - label->set_border(views::Border::CreateEmptyBorder( + text_label_ = new views::Label(text); + text_label_->set_border(views::Border::CreateEmptyBorder( 5, kTrayPopupDetailsIconWidth + kIconPaddingLeft, 5, 0)); - label->SetHorizontalAlignment(views::Label::ALIGN_LEFT); - label->SetFont(label->font().DeriveFont(0, style)); - label->SetDisabledColor(SkColorSetARGB(127, 0, 0, 0)); - AddChildView(label); + text_label_->SetHorizontalAlignment(views::Label::ALIGN_LEFT); + text_label_->SetFont(text_label_->font().DeriveFont(0, style)); + text_label_->SetDisabledColor(SkColorSetARGB(127, 0, 0, 0)); + if (text_default_color_) + text_label_->SetEnabledColor(text_default_color_); + AddChildView(text_label_); SetAccessibleName(text); } @@ -154,11 +161,15 @@ gfx::Size HoverHighlightView::GetPreferredSize() { void HoverHighlightView::OnMouseEntered(const views::MouseEvent& event) { hover_ = true; + if (text_highlight_color_ && text_label_) + text_label_->SetEnabledColor(text_highlight_color_); SchedulePaint(); } void HoverHighlightView::OnMouseExited(const views::MouseEvent& event) { hover_ = false; + if (text_default_color_ && text_label_) + text_label_->SetEnabledColor(text_default_color_); SchedulePaint(); } @@ -305,16 +316,26 @@ void TrayPopupTextButtonContainer::AddTextButton(TrayPopupTextButton* button) { TrayPopupHeaderButton::TrayPopupHeaderButton(views::ButtonListener* listener, int enabled_resource_id, - int disabled_resource_id) + int disabled_resource_id, + int enabled_resource_id_hover, + int disabled_resource_id_hover) : views::ToggleImageButton(listener) { ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance(); SetImage(views::CustomButton::BS_NORMAL, bundle.GetImageNamed(enabled_resource_id).ToSkBitmap()); SetToggledImage(views::CustomButton::BS_NORMAL, bundle.GetImageNamed(disabled_resource_id).ToSkBitmap()); + SetImage(views::CustomButton::BS_HOT, + bundle.GetImageNamed(enabled_resource_id_hover).ToSkBitmap()); + SetToggledImage(views::CustomButton::BS_HOT, + bundle.GetImageNamed(disabled_resource_id_hover).ToSkBitmap()); SetImageAlignment(views::ImageButton::ALIGN_CENTER, views::ImageButton::ALIGN_MIDDLE); set_focusable(true); + + // TODO(sad): Turn animation back on once there are proper assets. + // http://crbug.com/119832 + set_animate_on_state_change(false); } TrayPopupHeaderButton::~TrayPopupHeaderButton() {} @@ -364,19 +385,19 @@ void SpecialPopupRow::SetTextLabel(int string_id, ViewClickListener* listener) { container->set_fixed_height(kTrayPopupItemHeight); container->SetLayoutManager(new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 3, kIconPaddingLeft)); - views::ImageView* back = - new FixedSizedImageView(kTrayPopupDetailsIconWidth, 0); - back->EnableCanvasFlippingForRTLUI(true); - back->SetImage(rb.GetImageNamed(IDR_AURA_UBER_TRAY_LESS).ToSkBitmap()); - container->AddChildView(back); - views::Label* header = new views::Label(rb.GetLocalizedString(string_id)); - header->SetHorizontalAlignment(views::Label::ALIGN_LEFT); - header->SetFont(header->font().DeriveFont(0, gfx::Font::BOLD)); - container->AddChildView(header); - container->SetAccessibleName( - rb.GetLocalizedString(IDS_ASH_STATUS_TRAY_PREVIOUS_MENU)); + container->set_highlight_color(SkColorSetARGB(0, 0, 0, 0)); container->set_default_color(SkColorSetARGB(0, 0, 0, 0)); + container->set_text_highlight_color(kHeaderTextColorHover); + container->set_text_default_color(kHeaderTextColorNormal); + + container->AddIconAndLabel( + *rb.GetImageNamed(IDR_AURA_UBER_TRAY_LESS).ToSkBitmap(), + rb.GetLocalizedString(string_id), + gfx::Font::BOLD); + + container->SetAccessibleName( + rb.GetLocalizedString(IDS_ASH_STATUS_TRAY_PREVIOUS_MENU)); SetContent(container); } diff --git a/ash/system/tray/tray_views.h b/ash/system/tray/tray_views.h index 54b2846..dab672e 100644 --- a/ash/system/tray/tray_views.h +++ b/ash/system/tray/tray_views.h @@ -99,6 +99,8 @@ class HoverHighlightView : public ActionableView { void set_highlight_color(SkColor color) { highlight_color_ = color; } void set_default_color(SkColor color) { default_color_ = color; } + void set_text_highlight_color(SkColor c) { text_highlight_color_ = c; } + void set_text_default_color(SkColor color) { text_default_color_ = color; } void set_fixed_height(int height) { fixed_height_ = height; } private: @@ -114,8 +116,11 @@ class HoverHighlightView : public ActionableView { virtual void OnFocus() OVERRIDE; ViewClickListener* listener_; + views::Label* text_label_; SkColor highlight_color_; SkColor default_color_; + SkColor text_highlight_color_; + SkColor text_default_color_; int fixed_height_; bool hover_; @@ -192,7 +197,9 @@ class TrayPopupHeaderButton : public views::ToggleImageButton { public: TrayPopupHeaderButton(views::ButtonListener* listener, int enabled_resource_id, - int disabled_resource_id); + int disabled_resource_id, + int enabled_resource_id_hover, + int disabled_resource_id_hover); virtual ~TrayPopupHeaderButton(); private: @@ -227,6 +234,7 @@ class SpecialPopupRow : public views::View { views::View* content_; views::View* button_container_; + views::Label* text_label_; DISALLOW_COPY_AND_ASSIGN(SpecialPopupRow); }; diff --git a/ui/resources/ui_resources.grd b/ui/resources/ui_resources.grd index c22db97..d6ea2e6 100644 --- a/ui/resources/ui_resources.grd +++ b/ui/resources/ui_resources.grd @@ -288,6 +288,7 @@ <include name="IDR_AURA_UBER_TRAY_POWER_SMALL_DARK" file="aura/status_power_small_all_dark.png" type="BINDATA" /> <include name="IDR_AURA_UBER_TRAY_NETWORK_AIRPLANE" file="aura/status_network_airplane.png" type="BINDATA" /> <include name="IDR_AURA_UBER_TRAY_NETWORK_INFO" file="aura/status_network_info.png" type="BINDATA" /> + <include name="IDR_AURA_UBER_TRAY_NETWORK_INFO_HOVER" file="oak.png" type="BINDATA" /> <include name="IDR_AURA_UBER_TRAY_MORE" file="aura/status_more.png" type="BINDATA" /> <include name="IDR_AURA_UBER_TRAY_LESS" file="aura/status_less.png" type="BINDATA" /> <include name="IDR_AURA_UBER_TRAY_ACCESSIBILITY" file="aura/status_accessibility_mode.png" type="BINDATA" /> @@ -304,14 +305,23 @@ <include name="IDR_AURA_UBER_TRAY_UPDATE" file="aura/status_update.png" type="BINDATA" /> <include name="IDR_AURA_UBER_TRAY_UPDATE_DARK" file="aura/status_update_dark.png" type="BINDATA" /> <include name="IDR_AURA_UBER_TRAY_WIFI_ENABLED" file="aura/status_wifi_enabled.png" type="BINDATA" /> + <include name="IDR_AURA_UBER_TRAY_WIFI_ENABLED_HOVER" file="oak.png" type="BINDATA" /> <include name="IDR_AURA_UBER_TRAY_WIFI_DISABLED" file="aura/status_wifi_disabled.png" type="BINDATA" /> + <include name="IDR_AURA_UBER_TRAY_WIFI_DISABLED_HOVER" file="oak.png" type="BINDATA" /> <include name="IDR_AURA_UBER_TRAY_CELLULAR_ENABLED" file="aura/status_cellular_enabled.png" type="BINDATA" /> + <include name="IDR_AURA_UBER_TRAY_CELLULAR_ENABLED_HOVER" file="oak.png" type="BINDATA" /> <include name="IDR_AURA_UBER_TRAY_CELLULAR_DISABLED" file="aura/status_cellular_disabled.png" type="BINDATA" /> + <include name="IDR_AURA_UBER_TRAY_CELLULAR_DISABLED_HOVER" file="oak.png" type="BINDATA" /> <include name="IDR_AURA_UBER_TRAY_BLUETOOTH_ENABLED" file="aura/status_bluetooth_enabled.png" type="BINDATA" /> + <include name="IDR_AURA_UBER_TRAY_BLUETOOTH_ENABLED_HOVER" file="oak.png" type="BINDATA" /> <include name="IDR_AURA_UBER_TRAY_BLUETOOTH_DISABLED" file="aura/status_bluetooth_disabled.png" type="BINDATA" /> + <include name="IDR_AURA_UBER_TRAY_BLUETOOTH_DISABLED_HOVER" file="oak.png" type="BINDATA" /> <include name="IDR_AURA_UBER_TRAY_SHUTDOWN" file="aura/status_shutdown.png" type="BINDATA" /> + <include name="IDR_AURA_UBER_TRAY_SHUTDOWN_HOVER" file="oak.png" type="BINDATA" /> <include name="IDR_AURA_UBER_TRAY_LOCKSCREEN" file="aura/status_lockscreen.png" type="BINDATA" /> + <include name="IDR_AURA_UBER_TRAY_LOCKSCREEN_HOVER" file="oak.png" type="BINDATA" /> <include name="IDR_AURA_UBER_TRAY_HELP" file="aura/status_help.png" type="BINDATA" /> + <include name="IDR_AURA_UBER_TRAY_HELP_HOVER" file="oak.png" type="BINDATA" /> <include name="IDR_AURA_SWITCH_MONITOR" file="aura/switch_monitor.png" type="BINDATA" /> <include name="IDR_OAK" file="oak.png" type="BINDATA"/> |