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/ash_switches.h" | 7 #include "ash/ash_switches.h" |
8 #include "ash/root_window_controller.h" | 8 #include "ash/root_window_controller.h" |
9 #include "ash/screen_util.h" | 9 #include "ash/screen_util.h" |
10 #include "ash/shelf/shelf_layout_manager.h" | 10 #include "ash/shelf/shelf_layout_manager.h" |
(...skipping 19 matching lines...) Expand all Loading... |
30 #include "ui/gfx/skia_util.h" | 30 #include "ui/gfx/skia_util.h" |
31 #include "ui/views/background.h" | 31 #include "ui/views/background.h" |
32 #include "ui/views/layout/box_layout.h" | 32 #include "ui/views/layout/box_layout.h" |
33 | 33 |
34 namespace { | 34 namespace { |
35 | 35 |
36 const int kTrayBackgroundAlpha = 100; | 36 const int kTrayBackgroundAlpha = 100; |
37 const int kTrayBackgroundHoverAlpha = 150; | 37 const int kTrayBackgroundHoverAlpha = 150; |
38 const SkColor kTrayBackgroundPressedColor = SkColorSetRGB(66, 129, 244); | 38 const SkColor kTrayBackgroundPressedColor = SkColorSetRGB(66, 129, 244); |
39 | 39 |
40 // Adjust the size of TrayContainer with additional padding. | |
41 const int kTrayContainerVerticalPaddingBottomAlignment = 1; | |
42 const int kTrayContainerHorizontalPaddingBottomAlignment = 1; | |
43 const int kTrayContainerVerticalPaddingVerticalAlignment = 1; | |
44 const int kTrayContainerHorizontalPaddingVerticalAlignment = 1; | |
45 | |
46 const int kAnimationDurationForPopupMS = 200; | 40 const int kAnimationDurationForPopupMS = 200; |
47 | 41 |
48 } // namespace | 42 } // namespace |
49 | 43 |
50 using views::TrayBubbleView; | 44 using views::TrayBubbleView; |
51 | 45 |
52 namespace ash { | 46 namespace ash { |
53 | 47 |
54 // static | 48 // static |
55 const char TrayBackgroundView::kViewClassName[] = "tray/TrayBackgroundView"; | 49 const char TrayBackgroundView::kViewClassName[] = "tray/TrayBackgroundView"; |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 SkColor color() { return color_; } | 140 SkColor color() { return color_; } |
147 void set_color(SkColor color) { color_ = color; } | 141 void set_color(SkColor color) { color_ = color; } |
148 void set_alpha(int alpha) { color_ = SkColorSetARGB(alpha, 0, 0, 0); } | 142 void set_alpha(int alpha) { color_ = SkColorSetARGB(alpha, 0, 0, 0); } |
149 | 143 |
150 private: | 144 private: |
151 ShelfWidget* GetShelfWidget() const { | 145 ShelfWidget* GetShelfWidget() const { |
152 return RootWindowController::ForWindow(tray_background_view_-> | 146 return RootWindowController::ForWindow(tray_background_view_-> |
153 status_area_widget()->GetNativeWindow())->shelf(); | 147 status_area_widget()->GetNativeWindow())->shelf(); |
154 } | 148 } |
155 | 149 |
156 void PaintForAlternateShelf(gfx::Canvas* canvas, views::View* view) const { | 150 // Overridden from views::Background. |
| 151 virtual void Paint(gfx::Canvas* canvas, views::View* view) const OVERRIDE { |
157 int orientation = kImageHorizontal; | 152 int orientation = kImageHorizontal; |
158 ShelfWidget* shelf_widget = GetShelfWidget(); | 153 ShelfWidget* shelf_widget = GetShelfWidget(); |
159 if (shelf_widget && | 154 if (shelf_widget && |
160 !shelf_widget->shelf_layout_manager()->IsHorizontalAlignment()) | 155 !shelf_widget->shelf_layout_manager()->IsHorizontalAlignment()) |
161 orientation = kImageVertical; | 156 orientation = kImageVertical; |
162 | 157 |
163 int state = kImageTypeDefault; | 158 int state = kImageTypeDefault; |
164 if (tray_background_view_->draw_background_as_active()) | 159 if (tray_background_view_->draw_background_as_active()) |
165 state = kImageTypePressed; | 160 state = kImageTypePressed; |
166 else if (shelf_widget && shelf_widget->GetDimsShelf()) | 161 else if (shelf_widget && shelf_widget->GetDimsShelf()) |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
202 trailing_location.x(), | 197 trailing_location.x(), |
203 trailing_location.y()); | 198 trailing_location.y()); |
204 | 199 |
205 canvas->TileImageInt(*middle, | 200 canvas->TileImageInt(*middle, |
206 middle_bounds.x(), | 201 middle_bounds.x(), |
207 middle_bounds.y(), | 202 middle_bounds.y(), |
208 middle_bounds.width(), | 203 middle_bounds.width(), |
209 middle_bounds.height()); | 204 middle_bounds.height()); |
210 } | 205 } |
211 | 206 |
212 // Overridden from views::Background. | |
213 virtual void Paint(gfx::Canvas* canvas, views::View* view) const OVERRIDE { | |
214 if (ash::switches::UseAlternateShelfLayout()) { | |
215 PaintForAlternateShelf(canvas, view); | |
216 } else { | |
217 SkPaint paint; | |
218 paint.setAntiAlias(true); | |
219 paint.setStyle(SkPaint::kFill_Style); | |
220 paint.setColor(color_); | |
221 SkPath path; | |
222 gfx::Rect bounds(view->GetLocalBounds()); | |
223 SkScalar radius = SkIntToScalar(kTrayRoundedBorderRadius); | |
224 path.addRoundRect(gfx::RectToSkRect(bounds), radius, radius); | |
225 canvas->DrawPath(path, paint); | |
226 } | |
227 } | |
228 | |
229 SkColor color_; | 207 SkColor color_; |
230 // Reference to the TrayBackgroundView for which this is a background. | 208 // Reference to the TrayBackgroundView for which this is a background. |
231 TrayBackgroundView* tray_background_view_; | 209 TrayBackgroundView* tray_background_view_; |
232 | 210 |
233 // References to the images used as backgrounds, they are owned by the | 211 // References to the images used as backgrounds, they are owned by the |
234 // resource bundle class. | 212 // resource bundle class. |
235 const gfx::ImageSkia* leading_images_[kNumOrientations][kNumStates]; | 213 const gfx::ImageSkia* leading_images_[kNumOrientations][kNumStates]; |
236 const gfx::ImageSkia* middle_images_[kNumOrientations][kNumStates]; | 214 const gfx::ImageSkia* middle_images_[kNumOrientations][kNumStates]; |
237 const gfx::ImageSkia* trailing_images_[kNumOrientations][kNumStates]; | 215 const gfx::ImageSkia* trailing_images_[kNumOrientations][kNumStates]; |
238 | 216 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
270 const ViewHierarchyChangedDetails& details) { | 248 const ViewHierarchyChangedDetails& details) { |
271 if (details.parent == this) | 249 if (details.parent == this) |
272 PreferredSizeChanged(); | 250 PreferredSizeChanged(); |
273 } | 251 } |
274 | 252 |
275 void TrayBackgroundView::TrayContainer::UpdateLayout() { | 253 void TrayBackgroundView::TrayContainer::UpdateLayout() { |
276 // Adjust the size of status tray dark background by adding additional | 254 // Adjust the size of status tray dark background by adding additional |
277 // empty border. | 255 // empty border. |
278 if (alignment_ == SHELF_ALIGNMENT_BOTTOM || | 256 if (alignment_ == SHELF_ALIGNMENT_BOTTOM || |
279 alignment_ == SHELF_ALIGNMENT_TOP) { | 257 alignment_ == SHELF_ALIGNMENT_TOP) { |
280 int vertical_padding = kTrayContainerVerticalPaddingBottomAlignment; | 258 SetBorder(views::Border::CreateEmptyBorder( |
281 int horizontal_padding = kTrayContainerHorizontalPaddingBottomAlignment; | 259 kPaddingFromEdgeOfShelf, |
282 if (ash::switches::UseAlternateShelfLayout()) { | 260 kPaddingFromEdgeOfShelf, |
283 vertical_padding = kPaddingFromEdgeOfShelf; | 261 kPaddingFromEdgeOfShelf, |
284 horizontal_padding = kPaddingFromEdgeOfShelf; | 262 kPaddingFromEdgeOfShelf)); |
285 } | |
286 SetBorder(views::Border::CreateEmptyBorder(vertical_padding, | |
287 horizontal_padding, | |
288 vertical_padding, | |
289 horizontal_padding)); | |
290 | 263 |
291 views::BoxLayout* layout = | 264 views::BoxLayout* layout = |
292 new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, 0); | 265 new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, 0); |
293 layout->set_spread_blank_space(true); | 266 layout->set_spread_blank_space(true); |
294 views::View::SetLayoutManager(layout); | 267 views::View::SetLayoutManager(layout); |
295 } else { | 268 } else { |
296 int vertical_padding = kTrayContainerVerticalPaddingVerticalAlignment; | 269 SetBorder(views::Border::CreateEmptyBorder( |
297 int horizontal_padding = kTrayContainerHorizontalPaddingVerticalAlignment; | 270 kPaddingFromEdgeOfShelf, |
298 if (ash::switches::UseAlternateShelfLayout()) { | 271 kPaddingFromEdgeOfShelf, |
299 vertical_padding = kPaddingFromEdgeOfShelf; | 272 kPaddingFromEdgeOfShelf, |
300 horizontal_padding = kPaddingFromEdgeOfShelf; | 273 kPaddingFromEdgeOfShelf)); |
301 } | |
302 SetBorder(views::Border::CreateEmptyBorder(vertical_padding, | |
303 horizontal_padding, | |
304 vertical_padding, | |
305 horizontal_padding)); | |
306 | 274 |
307 views::BoxLayout* layout = | 275 views::BoxLayout* layout = |
308 new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0); | 276 new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0); |
309 layout->set_spread_blank_space(true); | 277 layout->set_spread_blank_space(true); |
310 views::View::SetLayoutManager(layout); | 278 views::View::SetLayoutManager(layout); |
311 } | 279 } |
312 PreferredSizeChanged(); | 280 PreferredSizeChanged(); |
313 } | 281 } |
314 | 282 |
315 //////////////////////////////////////////////////////////////////////////////// | 283 //////////////////////////////////////////////////////////////////////////////// |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
350 GetWidget()->AddObserver(widget_observer_.get()); | 318 GetWidget()->AddObserver(widget_observer_.get()); |
351 SetTrayBorder(); | 319 SetTrayBorder(); |
352 } | 320 } |
353 | 321 |
354 const char* TrayBackgroundView::GetClassName() const { | 322 const char* TrayBackgroundView::GetClassName() const { |
355 return kViewClassName; | 323 return kViewClassName; |
356 } | 324 } |
357 | 325 |
358 void TrayBackgroundView::OnMouseEntered(const ui::MouseEvent& event) { | 326 void TrayBackgroundView::OnMouseEntered(const ui::MouseEvent& event) { |
359 hovered_ = true; | 327 hovered_ = true; |
360 if (!background_ || draw_background_as_active_ || | |
361 ash::switches::UseAlternateShelfLayout()) | |
362 return; | |
363 hover_background_animator_.SetPaintsBackground( | |
364 true, BACKGROUND_CHANGE_ANIMATE); | |
365 } | 328 } |
366 | 329 |
367 void TrayBackgroundView::OnMouseExited(const ui::MouseEvent& event) { | 330 void TrayBackgroundView::OnMouseExited(const ui::MouseEvent& event) { |
368 hovered_ = false; | 331 hovered_ = false; |
369 if (!background_ || draw_background_as_active_ || | |
370 ash::switches::UseAlternateShelfLayout()) | |
371 return; | |
372 hover_background_animator_.SetPaintsBackground( | |
373 false, BACKGROUND_CHANGE_ANIMATE); | |
374 } | 332 } |
375 | 333 |
376 void TrayBackgroundView::ChildPreferredSizeChanged(views::View* child) { | 334 void TrayBackgroundView::ChildPreferredSizeChanged(views::View* child) { |
377 PreferredSizeChanged(); | 335 PreferredSizeChanged(); |
378 } | 336 } |
379 | 337 |
380 void TrayBackgroundView::GetAccessibleState(ui::AXViewState* state) { | 338 void TrayBackgroundView::GetAccessibleState(ui::AXViewState* state) { |
381 state->role = ui::AX_ROLE_BUTTON; | 339 state->role = ui::AX_ROLE_BUTTON; |
382 state->name = GetAccessibleNameForTray(); | 340 state->name = GetAccessibleNameForTray(); |
383 } | 341 } |
(...skipping 13 matching lines...) Expand all Loading... |
397 // The tray itself expands to the right and bottom edge of the screen to make | 355 // The tray itself expands to the right and bottom edge of the screen to make |
398 // sure clicking on the edges brings up the popup. However, the focus border | 356 // sure clicking on the edges brings up the popup. However, the focus border |
399 // should be only around the container. | 357 // should be only around the container. |
400 return GetContentsBounds(); | 358 return GetContentsBounds(); |
401 } | 359 } |
402 | 360 |
403 void TrayBackgroundView::UpdateBackground(int alpha) { | 361 void TrayBackgroundView::UpdateBackground(int alpha) { |
404 // The animator should never fire when the alternate shelf layout is used. | 362 // The animator should never fire when the alternate shelf layout is used. |
405 if (!background_ || draw_background_as_active_) | 363 if (!background_ || draw_background_as_active_) |
406 return; | 364 return; |
407 DCHECK(!ash::switches::UseAlternateShelfLayout()); | |
408 background_->set_alpha(hide_background_animator_.alpha() + | 365 background_->set_alpha(hide_background_animator_.alpha() + |
409 hover_background_animator_.alpha()); | 366 hover_background_animator_.alpha()); |
410 SchedulePaint(); | 367 SchedulePaint(); |
411 } | 368 } |
412 | 369 |
413 void TrayBackgroundView::SetContents(views::View* contents) { | 370 void TrayBackgroundView::SetContents(views::View* contents) { |
414 SetLayoutManager(new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0)); | 371 SetLayoutManager(new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0)); |
415 AddChildView(contents); | 372 AddChildView(contents); |
416 } | 373 } |
417 | 374 |
418 void TrayBackgroundView::SetPaintsBackground( | 375 void TrayBackgroundView::SetPaintsBackground( |
419 bool value, BackgroundAnimatorChangeType change_type) { | 376 bool value, BackgroundAnimatorChangeType change_type) { |
420 DCHECK(!ash::switches::UseAlternateShelfLayout()); | |
421 hide_background_animator_.SetPaintsBackground(value, change_type); | 377 hide_background_animator_.SetPaintsBackground(value, change_type); |
422 } | 378 } |
423 | 379 |
424 void TrayBackgroundView::SetContentsBackground() { | 380 void TrayBackgroundView::SetContentsBackground() { |
425 background_ = new TrayBackground(this); | 381 background_ = new TrayBackground(this); |
426 tray_container_->set_background(background_); | 382 tray_container_->set_background(background_); |
427 } | 383 } |
428 | 384 |
429 ShelfLayoutManager* TrayBackgroundView::GetShelfLayoutManager() { | 385 ShelfLayoutManager* TrayBackgroundView::GetShelfLayoutManager() { |
430 return ShelfLayoutManager::ForShelf(GetWidget()->GetNativeView()); | 386 return ShelfLayoutManager::ForShelf(GetWidget()->GetNativeView()); |
431 } | 387 } |
432 | 388 |
433 void TrayBackgroundView::SetShelfAlignment(ShelfAlignment alignment) { | 389 void TrayBackgroundView::SetShelfAlignment(ShelfAlignment alignment) { |
434 shelf_alignment_ = alignment; | 390 shelf_alignment_ = alignment; |
435 SetTrayBorder(); | 391 SetTrayBorder(); |
436 tray_container_->SetAlignment(alignment); | 392 tray_container_->SetAlignment(alignment); |
437 } | 393 } |
438 | 394 |
439 void TrayBackgroundView::SetTrayBorder() { | 395 void TrayBackgroundView::SetTrayBorder() { |
440 views::View* parent = status_area_widget_->status_area_widget_delegate(); | 396 views::View* parent = status_area_widget_->status_area_widget_delegate(); |
441 // Tray views are laid out right-to-left or bottom-to-top | 397 // Tray views are laid out right-to-left or bottom-to-top |
442 bool on_edge = (this == parent->child_at(0)); | 398 bool on_edge = (this == parent->child_at(0)); |
443 int left_edge, top_edge, right_edge, bottom_edge; | 399 int left_edge, top_edge, right_edge, bottom_edge; |
444 if (ash::switches::UseAlternateShelfLayout()) { | 400 if (shelf_alignment() == SHELF_ALIGNMENT_BOTTOM) { |
445 if (shelf_alignment() == SHELF_ALIGNMENT_BOTTOM) { | 401 top_edge = ShelfLayoutManager::kShelfItemInset; |
446 top_edge = ShelfLayoutManager::kShelfItemInset; | 402 left_edge = 0; |
447 left_edge = 0; | 403 bottom_edge = kShelfSize - |
448 bottom_edge = ShelfLayoutManager::GetPreferredShelfSize() - | 404 ShelfLayoutManager::kShelfItemInset - kShelfItemHeight; |
449 ShelfLayoutManager::kShelfItemInset - GetShelfItemHeight(); | 405 right_edge = on_edge ? kPaddingFromEdgeOfShelf : 0; |
450 right_edge = on_edge ? kPaddingFromEdgeOfShelf : 0; | 406 } else if (shelf_alignment() == SHELF_ALIGNMENT_LEFT) { |
451 } else if (shelf_alignment() == SHELF_ALIGNMENT_LEFT) { | 407 top_edge = 0; |
452 top_edge = 0; | 408 left_edge = kShelfSize - |
453 left_edge = ShelfLayoutManager::GetPreferredShelfSize() - | 409 ShelfLayoutManager::kShelfItemInset - kShelfItemHeight; |
454 ShelfLayoutManager::kShelfItemInset - GetShelfItemHeight(); | 410 bottom_edge = on_edge ? kPaddingFromEdgeOfShelf : 0; |
455 bottom_edge = on_edge ? kPaddingFromEdgeOfShelf : 0; | 411 right_edge = ShelfLayoutManager::kShelfItemInset; |
456 right_edge = ShelfLayoutManager::kShelfItemInset; | 412 } else { // SHELF_ALIGNMENT_RIGHT |
457 } else { // SHELF_ALIGNMENT_RIGHT | 413 top_edge = 0; |
458 top_edge = 0; | 414 left_edge = ShelfLayoutManager::kShelfItemInset; |
459 left_edge = ShelfLayoutManager::kShelfItemInset; | 415 bottom_edge = on_edge ? kPaddingFromEdgeOfShelf : 0; |
460 bottom_edge = on_edge ? kPaddingFromEdgeOfShelf : 0; | 416 right_edge = kShelfSize - |
461 right_edge = ShelfLayoutManager::GetPreferredShelfSize() - | 417 ShelfLayoutManager::kShelfItemInset - kShelfItemHeight; |
462 ShelfLayoutManager::kShelfItemInset - GetShelfItemHeight(); | |
463 } | |
464 } else { | |
465 // Change the border padding for different shelf alignment. | |
466 if (shelf_alignment() == SHELF_ALIGNMENT_BOTTOM) { | |
467 top_edge = 0; | |
468 left_edge = 0; | |
469 bottom_edge = on_edge ? kPaddingFromBottomOfScreenBottomAlignment : | |
470 kPaddingFromBottomOfScreenBottomAlignment - 1; | |
471 right_edge = on_edge ? kPaddingFromRightEdgeOfScreenBottomAlignment : 0; | |
472 } else if (shelf_alignment() == SHELF_ALIGNMENT_TOP) { | |
473 top_edge = on_edge ? kPaddingFromBottomOfScreenBottomAlignment : | |
474 kPaddingFromBottomOfScreenBottomAlignment - 1; | |
475 left_edge = 0; | |
476 bottom_edge = 0; | |
477 right_edge = on_edge ? kPaddingFromRightEdgeOfScreenBottomAlignment : 0; | |
478 } else if (shelf_alignment() == SHELF_ALIGNMENT_LEFT) { | |
479 top_edge = 0; | |
480 left_edge = kPaddingFromOuterEdgeOfLauncherVerticalAlignment; | |
481 bottom_edge = on_edge ? kPaddingFromBottomOfScreenVerticalAlignment : 0; | |
482 right_edge = kPaddingFromInnerEdgeOfLauncherVerticalAlignment; | |
483 } else { | |
484 top_edge = 0; | |
485 left_edge = kPaddingFromInnerEdgeOfLauncherVerticalAlignment; | |
486 bottom_edge = on_edge ? kPaddingFromBottomOfScreenVerticalAlignment : 0; | |
487 right_edge = kPaddingFromOuterEdgeOfLauncherVerticalAlignment; | |
488 } | |
489 } | 418 } |
490 SetBorder(views::Border::CreateEmptyBorder( | 419 SetBorder(views::Border::CreateEmptyBorder( |
491 top_edge, left_edge, bottom_edge, right_edge)); | 420 top_edge, left_edge, bottom_edge, right_edge)); |
492 } | 421 } |
493 | 422 |
494 void TrayBackgroundView::InitializeBubbleAnimations( | 423 void TrayBackgroundView::InitializeBubbleAnimations( |
495 views::Widget* bubble_widget) { | 424 views::Widget* bubble_widget) { |
496 wm::SetWindowVisibilityAnimationType( | 425 wm::SetWindowVisibilityAnimationType( |
497 bubble_widget->GetNativeWindow(), | 426 bubble_widget->GetNativeWindow(), |
498 wm::WINDOW_VISIBILITY_ANIMATION_TYPE_FADE); | 427 wm::WINDOW_VISIBILITY_ANIMATION_TYPE_FADE); |
(...skipping 14 matching lines...) Expand all Loading... |
513 gfx::Rect TrayBackgroundView::GetBubbleAnchorRect( | 442 gfx::Rect TrayBackgroundView::GetBubbleAnchorRect( |
514 views::Widget* anchor_widget, | 443 views::Widget* anchor_widget, |
515 TrayBubbleView::AnchorType anchor_type, | 444 TrayBubbleView::AnchorType anchor_type, |
516 TrayBubbleView::AnchorAlignment anchor_alignment) const { | 445 TrayBubbleView::AnchorAlignment anchor_alignment) const { |
517 gfx::Rect rect; | 446 gfx::Rect rect; |
518 if (anchor_widget && anchor_widget->IsVisible()) { | 447 if (anchor_widget && anchor_widget->IsVisible()) { |
519 rect = anchor_widget->GetWindowBoundsInScreen(); | 448 rect = anchor_widget->GetWindowBoundsInScreen(); |
520 if (anchor_type == TrayBubbleView::ANCHOR_TYPE_TRAY) { | 449 if (anchor_type == TrayBubbleView::ANCHOR_TYPE_TRAY) { |
521 if (anchor_alignment == TrayBubbleView::ANCHOR_ALIGNMENT_BOTTOM) { | 450 if (anchor_alignment == TrayBubbleView::ANCHOR_ALIGNMENT_BOTTOM) { |
522 bool rtl = base::i18n::IsRTL(); | 451 bool rtl = base::i18n::IsRTL(); |
523 if (!ash::switches::UseAlternateShelfLayout()) { | 452 rect.Inset( |
524 rect.Inset( | 453 rtl ? kBubblePaddingHorizontalSide : 0, |
525 rtl ? kPaddingFromRightEdgeOfScreenBottomAlignment : 0, | 454 kBubblePaddingHorizontalBottom, |
526 kTrayBubbleAnchorTopInsetBottomAnchor, | 455 rtl ? 0 : kBubblePaddingHorizontalSide, |
527 rtl ? 0 : kPaddingFromRightEdgeOfScreenBottomAlignment, | 456 0); |
528 kPaddingFromBottomOfScreenBottomAlignment); | |
529 } else { | |
530 rect.Inset( | |
531 rtl ? kAlternateLayoutBubblePaddingHorizontalSide : 0, | |
532 kAlternateLayoutBubblePaddingHorizontalBottom, | |
533 rtl ? 0 : kAlternateLayoutBubblePaddingHorizontalSide, | |
534 0); | |
535 } | |
536 } else if (anchor_alignment == TrayBubbleView::ANCHOR_ALIGNMENT_LEFT) { | 457 } else if (anchor_alignment == TrayBubbleView::ANCHOR_ALIGNMENT_LEFT) { |
537 if (!ash::switches::UseAlternateShelfLayout()) { | 458 rect.Inset(0, 0, kBubblePaddingVerticalSide + 4, |
538 rect.Inset(0, 0, kPaddingFromInnerEdgeOfLauncherVerticalAlignment + 5, | 459 kBubblePaddingVerticalBottom); |
539 kPaddingFromBottomOfScreenVerticalAlignment); | |
540 } else { | |
541 rect.Inset(0, 0, kAlternateLayoutBubblePaddingVerticalSide + 4, | |
542 kAlternateLayoutBubblePaddingVerticalBottom); | |
543 } | |
544 } else { | 460 } else { |
545 if (!ash::switches::UseAlternateShelfLayout()) { | 461 rect.Inset(kBubblePaddingVerticalSide, 0, 0, |
546 rect.Inset(kPaddingFromInnerEdgeOfLauncherVerticalAlignment + 1, | 462 kBubblePaddingVerticalBottom); |
547 0, 0, kPaddingFromBottomOfScreenVerticalAlignment); | |
548 } else { | |
549 rect.Inset(kAlternateLayoutBubblePaddingVerticalSide, 0, 0, | |
550 kAlternateLayoutBubblePaddingVerticalBottom); | |
551 } | |
552 } | 463 } |
553 } else if (anchor_type == TrayBubbleView::ANCHOR_TYPE_BUBBLE) { | 464 } else if (anchor_type == TrayBubbleView::ANCHOR_TYPE_BUBBLE) { |
554 // Invert the offsets to align with the bubble below. | 465 // Invert the offsets to align with the bubble below. |
555 // Note that with the alternate shelf layout the tips are not shown and | 466 // Note that with the alternate shelf layout the tips are not shown and |
556 // the offsets for left and right alignment do not need to be applied. | 467 // the offsets for left and right alignment do not need to be applied. |
557 int vertical_alignment = ash::switches::UseAlternateShelfLayout() ? | 468 int vertical_alignment = 0; |
558 0 : | 469 int horizontal_alignment = kBubblePaddingVerticalBottom; |
559 kPaddingFromInnerEdgeOfLauncherVerticalAlignment; | |
560 int horizontal_alignment = ash::switches::UseAlternateShelfLayout() ? | |
561 kAlternateLayoutBubblePaddingVerticalBottom : | |
562 kPaddingFromBottomOfScreenVerticalAlignment; | |
563 if (anchor_alignment == TrayBubbleView::ANCHOR_ALIGNMENT_LEFT) | 470 if (anchor_alignment == TrayBubbleView::ANCHOR_ALIGNMENT_LEFT) |
564 rect.Inset(vertical_alignment, 0, 0, horizontal_alignment); | 471 rect.Inset(vertical_alignment, 0, 0, horizontal_alignment); |
565 else if (anchor_alignment == TrayBubbleView::ANCHOR_ALIGNMENT_RIGHT) | 472 else if (anchor_alignment == TrayBubbleView::ANCHOR_ALIGNMENT_RIGHT) |
566 rect.Inset(0, 0, vertical_alignment, horizontal_alignment); | 473 rect.Inset(0, 0, vertical_alignment, horizontal_alignment); |
567 } | 474 } |
568 } | 475 } |
569 | 476 |
570 // TODO(jennyz): May need to add left/right alignment in the following code. | 477 // TODO(jennyz): May need to add left/right alignment in the following code. |
571 if (rect.IsEmpty()) { | 478 if (rect.IsEmpty()) { |
572 aura::Window* target_root = anchor_widget ? | 479 aura::Window* target_root = anchor_widget ? |
(...skipping 20 matching lines...) Expand all Loading... |
593 return TrayBubbleView::ANCHOR_ALIGNMENT_RIGHT; | 500 return TrayBubbleView::ANCHOR_ALIGNMENT_RIGHT; |
594 case SHELF_ALIGNMENT_TOP: | 501 case SHELF_ALIGNMENT_TOP: |
595 return TrayBubbleView::ANCHOR_ALIGNMENT_TOP; | 502 return TrayBubbleView::ANCHOR_ALIGNMENT_TOP; |
596 } | 503 } |
597 NOTREACHED(); | 504 NOTREACHED(); |
598 return TrayBubbleView::ANCHOR_ALIGNMENT_BOTTOM; | 505 return TrayBubbleView::ANCHOR_ALIGNMENT_BOTTOM; |
599 } | 506 } |
600 | 507 |
601 void TrayBackgroundView::SetDrawBackgroundAsActive(bool visible) { | 508 void TrayBackgroundView::SetDrawBackgroundAsActive(bool visible) { |
602 draw_background_as_active_ = visible; | 509 draw_background_as_active_ = visible; |
603 if (!background_ || !switches::UseAlternateShelfLayout()) | 510 if (!background_) |
604 return; | 511 return; |
605 | 512 |
606 // Do not change gradually, changing color between grey and blue is weird. | 513 // Do not change gradually, changing color between grey and blue is weird. |
607 if (draw_background_as_active_) | 514 if (draw_background_as_active_) |
608 background_->set_color(kTrayBackgroundPressedColor); | 515 background_->set_color(kTrayBackgroundPressedColor); |
609 else if (hovered_) | 516 else if (hovered_) |
610 background_->set_alpha(kTrayBackgroundHoverAlpha); | 517 background_->set_alpha(kTrayBackgroundHoverAlpha); |
611 else | 518 else |
612 background_->set_alpha(kTrayBackgroundAlpha); | 519 background_->set_alpha(kTrayBackgroundAlpha); |
613 SchedulePaint(); | 520 SchedulePaint(); |
614 } | 521 } |
615 | 522 |
616 void TrayBackgroundView::UpdateBubbleViewArrow( | 523 void TrayBackgroundView::UpdateBubbleViewArrow( |
617 views::TrayBubbleView* bubble_view) { | 524 views::TrayBubbleView* bubble_view) { |
618 if (switches::UseAlternateShelfLayout()) | 525 // Nothing to do here. |
619 return; | |
620 | |
621 aura::Window* root_window = | |
622 bubble_view->GetWidget()->GetNativeView()->GetRootWindow(); | |
623 ash::ShelfLayoutManager* shelf = ShelfLayoutManager::ForShelf(root_window); | |
624 bubble_view->SetArrowPaintType( | |
625 (shelf && shelf->IsVisible()) ? | |
626 views::BubbleBorder::PAINT_NORMAL : | |
627 views::BubbleBorder::PAINT_TRANSPARENT); | |
628 } | 526 } |
629 | 527 |
630 } // namespace ash | 528 } // namespace ash |
OLD | NEW |