summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorskuhne@chromium.org <skuhne@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-09-06 06:09:22 +0000
committerskuhne@chromium.org <skuhne@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-09-06 06:09:22 +0000
commit7eb6c001f9dc636dc4c1a6129ff4bab0f27d8cb9 (patch)
tree9f327f9836ef0cd06ef24212a442bb3202128313
parenta84bbd1352167f17d5901354840bded487f6d8e8 (diff)
downloadchromium_src-7eb6c001f9dc636dc4c1a6129ff4bab0f27d8cb9.zip
chromium_src-7eb6c001f9dc636dc4c1a6129ff4bab0f27d8cb9.tar.gz
chromium_src-7eb6c001f9dc636dc4c1a6129ff4bab0f27d8cb9.tar.bz2
Fixing various problems with the new shelf layout in conjunction with the blue tray background on bubble activation
There was a mismatch between the hover animation & the activation state. I cleaned up the activation code, removed the old override functions, and added comments on various places which had none yet. BUG=274105 TEST=visual Review URL: https://chromiumcodereview.appspot.com/23531033 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@221597 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--ash/system/tray/system_tray.cc21
-rw-r--r--ash/system/tray/system_tray.h3
-rw-r--r--ash/system/tray/tray_background_view.cc39
-rw-r--r--ash/system/tray/tray_background_view.h21
-rw-r--r--ash/system/web_notification/web_notification_tray.cc6
-rw-r--r--ash/system/web_notification/web_notification_tray.h3
6 files changed, 43 insertions, 50 deletions
diff --git a/ash/system/tray/system_tray.cc b/ash/system/tray/system_tray.cc
index 47157ea..6419acd 100644
--- a/ash/system/tray/system_tray.cc
+++ b/ash/system/tray/system_tray.cc
@@ -320,16 +320,6 @@ bool SystemTray::HasNotificationBubble() const {
return notification_bubble_.get() != NULL;
}
-bool SystemTray::IsPressed() {
- // Only when a full system tray bubble gets shown true will be returned.
- // Small bubbles (like audio modifications via keyboard) should return false.
- // Since showing the e.g. network portion of the system tray menu will convert
- // the |system_bubble_| from type |BUBBLE_TYPE_DEFAULT| into
- // |BUBBLE_TYPE_DETAILED| the full tray cannot reliably be checked trhough the
- // type. As such |full_system_tray_menu_| gets checked here.
- return HasSystemBubble() && full_system_tray_menu_;
-}
-
internal::SystemTrayBubble* SystemTray::GetSystemBubble() {
if (!system_bubble_)
return NULL;
@@ -482,6 +472,11 @@ void SystemTray::ShowItems(const std::vector<SystemTrayItem*>& items,
if (!notification_bubble_)
UpdateWebNotifications();
GetShelfLayoutManager()->UpdateAutoHideState();
+
+ // When we show the system menu in our alternate shelf layout, we need to
+ // tint the background.
+ if (full_system_tray_menu_)
+ SetDrawBackgroundAsActive(true);
}
void SystemTray::UpdateNotificationBubble() {
@@ -591,6 +586,12 @@ void SystemTray::HideBubbleWithView(const TrayBubbleView* bubble_view) {
DestroySystemBubble();
UpdateNotificationBubble(); // State changed, re-create notifications.
GetShelfLayoutManager()->UpdateAutoHideState();
+ // When closing a system bubble with the alternate shelf layout, we need to
+ // turn off the active tinting of the shelf.
+ if (full_system_tray_menu_) {
+ SetDrawBackgroundAsActive(false);
+ full_system_tray_menu_ = false;
+ }
} else if (notification_bubble_.get() &&
bubble_view == notification_bubble_->bubble_view()) {
DestroyNotificationBubble();
diff --git a/ash/system/tray/system_tray.h b/ash/system/tray/system_tray.h
index b37a643..f6b47fe 100644
--- a/ash/system/tray/system_tray.h
+++ b/ash/system/tray/system_tray.h
@@ -156,9 +156,6 @@ class ASH_EXPORT SystemTray : public internal::TrayBackgroundView,
return tray_accessibility_;
}
- // Overridden from TrayBackgroundView.
- virtual bool IsPressed() OVERRIDE;
-
private:
// Creates the default set of items for the sytem tray.
void CreateItems(SystemTrayDelegate* delegate);
diff --git a/ash/system/tray/tray_background_view.cc b/ash/system/tray/tray_background_view.cc
index a20e371..d979b1a 100644
--- a/ash/system/tray/tray_background_view.cc
+++ b/ash/system/tray/tray_background_view.cc
@@ -163,7 +163,7 @@ class TrayBackground : public views::Background {
orientation = kImageVertical;
int state = kImageTypeDefault;
- if (tray_background_view_->IsPressed())
+ if (tray_background_view_->draw_background_as_active())
state = kImageTypePressed;
else if (shelf_widget && shelf_widget->GetDimsShelf())
state = kImageTypeOnBlack;
@@ -329,12 +329,13 @@ TrayBackgroundView::TrayBackgroundView(
hover_background_animator_(
this, 0, kTrayBackgroundHoverAlpha - kTrayBackgroundAlpha),
hovered_(false),
- pressed_(false),
+ draw_background_as_active_(false),
widget_observer_(new TrayWidgetObserver(this)) {
set_notify_enter_exit_on_child(true);
// Initially we want to paint the background, but without the hover effect.
- SetPaintsBackground(true, internal::BackgroundAnimator::CHANGE_IMMEDIATE);
+ hide_background_animator_.SetPaintsBackground(true,
+ internal::BackgroundAnimator::CHANGE_IMMEDIATE);
hover_background_animator_.SetPaintsBackground(false,
internal::BackgroundAnimator::CHANGE_IMMEDIATE);
@@ -359,22 +360,18 @@ const char* TrayBackgroundView::GetClassName() const {
void TrayBackgroundView::OnMouseEntered(const ui::MouseEvent& event) {
hovered_ = true;
- if (!background_)
- return;
- if (pressed_)
+ if (!background_ || draw_background_as_active_ ||
+ ash::switches::UseAlternateShelfLayout())
return;
-
hover_background_animator_.SetPaintsBackground(true,
internal::BackgroundAnimator::CHANGE_ANIMATE);
}
void TrayBackgroundView::OnMouseExited(const ui::MouseEvent& event) {
hovered_ = false;
- if (!background_)
+ if (!background_ || draw_background_as_active_ ||
+ ash::switches::UseAlternateShelfLayout())
return;
- if (pressed_)
- return;
-
hover_background_animator_.SetPaintsBackground(false,
internal::BackgroundAnimator::CHANGE_ANIMATE);
}
@@ -408,11 +405,10 @@ bool TrayBackgroundView::PerformAction(const ui::Event& event) {
}
void TrayBackgroundView::UpdateBackground(int alpha) {
- if (!background_)
+ // The animator should never fire when the alternate shelf layout is used.
+ if (!background_ || draw_background_as_active_)
return;
- if (pressed_)
- return;
-
+ DCHECK(!ash::switches::UseAlternateShelfLayout());
background_->set_alpha(hide_background_animator_.alpha() +
hover_background_animator_.alpha());
SchedulePaint();
@@ -426,6 +422,7 @@ void TrayBackgroundView::SetContents(views::View* contents) {
void TrayBackgroundView::SetPaintsBackground(
bool value,
internal::BackgroundAnimator::ChangeType change_type) {
+ DCHECK(!ash::switches::UseAlternateShelfLayout());
hide_background_animator_.SetPaintsBackground(value, change_type);
}
@@ -496,10 +493,6 @@ void TrayBackgroundView::InitializeBubbleAnimations(
base::TimeDelta::FromMilliseconds(kAnimationDurationForPopupMS));
}
-bool TrayBackgroundView::IsPressed() {
- return pressed_;
-}
-
aura::Window* TrayBackgroundView::GetBubbleWindowContainer() const {
return ash::Shell::GetContainer(
tray_container()->GetWidget()->GetNativeWindow()->GetRootWindow(),
@@ -575,13 +568,13 @@ TrayBubbleView::AnchorAlignment TrayBackgroundView::GetAnchorAlignment() const {
return TrayBubbleView::ANCHOR_ALIGNMENT_BOTTOM;
}
-void TrayBackgroundView::SetBubbleVisible(bool visible) {
- pressed_ = visible;
- if (!background_)
+void TrayBackgroundView::SetDrawBackgroundAsActive(bool visible) {
+ draw_background_as_active_ = visible;
+ if (!background_ || !switches::UseAlternateShelfLayout())
return;
// Do not change gradually, changing color between grey and blue is weird.
- if (pressed_)
+ if (draw_background_as_active_)
background_->set_color(kTrayBackgroundPressedColor);
else if (hovered_)
background_->set_alpha(kTrayBackgroundHoverAlpha);
diff --git a/ash/system/tray/tray_background_view.h b/ash/system/tray/tray_background_view.h
index b0f2806..7b29495 100644
--- a/ash/system/tray/tray_background_view.h
+++ b/ash/system/tray/tray_background_view.h
@@ -124,8 +124,11 @@ class ASH_EXPORT TrayBackgroundView : public ActionableView,
// Returns the bubble anchor alignment based on |shelf_alignment_|.
views::TrayBubbleView::AnchorAlignment GetAnchorAlignment() const;
- // Updates the view visual based on the visibility of the bubble.
- void SetBubbleVisible(bool visible);
+ // Forces the background to be drawn active if set to true.
+ void SetDrawBackgroundAsActive(bool visible);
+
+ // Returns true when the the background was overridden to be drawn as active.
+ bool draw_background_as_active() const {return draw_background_as_active_; }
StatusAreaWidget* status_area_widget() {
return status_area_widget_;
@@ -139,12 +142,9 @@ class ASH_EXPORT TrayBackgroundView : public ActionableView,
ShelfLayoutManager* GetShelfLayoutManager();
- // Updates the arrow visibilty based on the launcher visibilty.
+ // Updates the arrow visibility based on the launcher visibility.
void UpdateBubbleViewArrow(views::TrayBubbleView* bubble_view);
- // Provides the background with a function to query for pressed state.
- virtual bool IsPressed();
-
private:
class TrayWidgetObserver;
@@ -164,10 +164,17 @@ class ASH_EXPORT TrayBackgroundView : public ActionableView,
// Owned by the view passed to SetContents().
internal::TrayBackground* background_;
+ // Animators for the background. They are only used for the old shelf layout.
internal::BackgroundAnimator hide_background_animator_;
internal::BackgroundAnimator hover_background_animator_;
+
+ // True if the background gets hovered.
bool hovered_;
- bool pressed_;
+
+ // This variable stores the activation override which will tint the background
+ // differently if set to true.
+ bool draw_background_as_active_;
+
scoped_ptr<TrayWidgetObserver> widget_observer_;
scoped_ptr<TrayEventFilter> tray_event_filter_;
diff --git a/ash/system/web_notification/web_notification_tray.cc b/ash/system/web_notification/web_notification_tray.cc
index 5527133..d592afe 100644
--- a/ash/system/web_notification/web_notification_tray.cc
+++ b/ash/system/web_notification/web_notification_tray.cc
@@ -376,6 +376,7 @@ bool WebNotificationTray::ShowMessageCenterInternal(bool show_settings) {
status_area_widget()->SetHideSystemNotifications(true);
GetShelfLayoutManager()->UpdateAutoHideState();
button_->SetBubbleVisible(true);
+ SetDrawBackgroundAsActive(true);
return true;
}
@@ -386,6 +387,7 @@ bool WebNotificationTray::ShowMessageCenter() {
void WebNotificationTray::HideMessageCenter() {
if (!message_center_bubble())
return;
+ SetDrawBackgroundAsActive(false);
message_center_bubble_.reset();
should_block_shelf_auto_hide_ = false;
show_message_center_on_unlock_ = false;
@@ -568,10 +570,6 @@ void WebNotificationTray::ExecuteCommand(int command_id, int event_flags) {
message_center()->EnterQuietModeWithExpire(expires_in);
}
-bool WebNotificationTray::IsPressed() {
- return IsMessageCenterBubbleVisible();
-}
-
void WebNotificationTray::ButtonPressed(views::Button* sender,
const ui::Event& event) {
DCHECK_EQ(button_, sender);
diff --git a/ash/system/web_notification/web_notification_tray.h b/ash/system/web_notification/web_notification_tray.h
index 18a85ee..be449da 100644
--- a/ash/system/web_notification/web_notification_tray.h
+++ b/ash/system/web_notification/web_notification_tray.h
@@ -119,9 +119,6 @@ class ASH_EXPORT WebNotificationTray
ui::Accelerator* accelerator) OVERRIDE;
virtual void ExecuteCommand(int command_id, int event_flags) OVERRIDE;
- // Overridden from TrayBackgroundView.
- virtual bool IsPressed() OVERRIDE;
-
message_center::MessageCenter* message_center() const;
private: