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