OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "ash/system/tray/tray_background_view.h" | 5 #include "ash/system/tray/tray_background_view.h" |
6 | 6 |
7 #include "ash/launcher/background_animator.h" | 7 #include "ash/launcher/background_animator.h" |
8 #include "ash/shell.h" | 8 #include "ash/shell.h" |
9 #include "ash/shell_window_ids.h" | 9 #include "ash/shell_window_ids.h" |
10 #include "ash/system/tray/tray_constants.h" | 10 #include "ash/system/tray/tray_constants.h" |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 this, 0, kTrayBackgroundAlpha)), | 130 this, 0, kTrayBackgroundAlpha)), |
131 ALLOW_THIS_IN_INITIALIZER_LIST(hover_background_animator_( | 131 ALLOW_THIS_IN_INITIALIZER_LIST(hover_background_animator_( |
132 this, 0, kTrayBackgroundHoverAlpha - kTrayBackgroundAlpha)) { | 132 this, 0, kTrayBackgroundHoverAlpha - kTrayBackgroundAlpha)) { |
133 set_notify_enter_exit_on_child(true); | 133 set_notify_enter_exit_on_child(true); |
134 | 134 |
135 // Initially we want to paint the background, but without the hover effect. | 135 // Initially we want to paint the background, but without the hover effect. |
136 SetPaintsBackground(true, internal::BackgroundAnimator::CHANGE_IMMEDIATE); | 136 SetPaintsBackground(true, internal::BackgroundAnimator::CHANGE_IMMEDIATE); |
137 hover_background_animator_.SetPaintsBackground(false, | 137 hover_background_animator_.SetPaintsBackground(false, |
138 internal::BackgroundAnimator::CHANGE_IMMEDIATE); | 138 internal::BackgroundAnimator::CHANGE_IMMEDIATE); |
139 | 139 |
140 SetBorder(); | |
141 | |
142 tray_container_ = new TrayContainer(shelf_alignment_); | 140 tray_container_ = new TrayContainer(shelf_alignment_); |
143 SetContents(tray_container_); | 141 SetContents(tray_container_); |
144 } | 142 } |
145 | 143 |
146 TrayBackgroundView::~TrayBackgroundView() { | 144 TrayBackgroundView::~TrayBackgroundView() { |
147 } | 145 } |
148 | 146 |
149 void TrayBackgroundView::OnMouseEntered(const views::MouseEvent& event) { | 147 void TrayBackgroundView::OnMouseEntered(const views::MouseEvent& event) { |
150 hover_background_animator_.SetPaintsBackground(true, | 148 hover_background_animator_.SetPaintsBackground(true, |
151 internal::BackgroundAnimator::CHANGE_ANIMATE); | 149 internal::BackgroundAnimator::CHANGE_ANIMATE); |
(...skipping 29 matching lines...) Expand all Loading... |
181 } | 179 } |
182 | 180 |
183 void TrayBackgroundView::SetPaintsBackground( | 181 void TrayBackgroundView::SetPaintsBackground( |
184 bool value, | 182 bool value, |
185 internal::BackgroundAnimator::ChangeType change_type) { | 183 internal::BackgroundAnimator::ChangeType change_type) { |
186 hide_background_animator_.SetPaintsBackground(value, change_type); | 184 hide_background_animator_.SetPaintsBackground(value, change_type); |
187 } | 185 } |
188 | 186 |
189 void TrayBackgroundView::SetShelfAlignment(ShelfAlignment alignment) { | 187 void TrayBackgroundView::SetShelfAlignment(ShelfAlignment alignment) { |
190 shelf_alignment_ = alignment; | 188 shelf_alignment_ = alignment; |
191 SetBorder(); | |
192 tray_container_->SetAlignment(alignment); | 189 tray_container_->SetAlignment(alignment); |
193 } | 190 } |
194 | 191 |
195 void TrayBackgroundView::SetBorder() { | |
196 // Change the border padding for different shelf alignment. | |
197 if (shelf_alignment() == SHELF_ALIGNMENT_BOTTOM) { | |
198 set_border(views::Border::CreateEmptyBorder(0, 0, | |
199 kPaddingFromBottomOfScreenBottomAlignment, | |
200 kPaddingFromRightEdgeOfScreenBottomAlignment)); | |
201 } else if (shelf_alignment() == SHELF_ALIGNMENT_LEFT) { | |
202 set_border(views::Border::CreateEmptyBorder(0, | |
203 kPaddingFromOuterEdgeOfLauncherVerticalAlignment, | |
204 kPaddingFromBottomOfScreenVerticalAlignment, | |
205 kPaddingFromInnerEdgeOfLauncherVerticalAlignment)); | |
206 } else { | |
207 set_border(views::Border::CreateEmptyBorder(0, | |
208 kPaddingFromInnerEdgeOfLauncherVerticalAlignment, | |
209 kPaddingFromBottomOfScreenVerticalAlignment, | |
210 kPaddingFromOuterEdgeOfLauncherVerticalAlignment)); | |
211 } | |
212 } | |
213 | |
214 } // namespace internal | 192 } // namespace internal |
215 } // namespace ash | 193 } // namespace ash |
OLD | NEW |