Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(826)

Side by Side Diff: ash/system/tray/tray_background_view.cc

Issue 140323010: Ash:Shelf - Cleanup of Alternate Shelf (part 1) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: ... Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ash/system/tray/system_tray.cc ('k') | ash/system/tray/tray_constants.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
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; 265 SetBorder(views::Border::CreateEmptyBorder(
282 int horizontal_padding = kTrayContainerHorizontalPaddingBottomAlignment; 266 kPaddingFromEdgeOfShelf,
283 if (ash::switches::UseAlternateShelfLayout()) { 267 kPaddingFromEdgeOfShelf,
284 vertical_padding = kPaddingFromEdgeOfShelf; 268 kPaddingFromEdgeOfShelf,
285 horizontal_padding = kPaddingFromEdgeOfShelf; 269 kPaddingFromEdgeOfShelf));
286 }
287 SetBorder(views::Border::CreateEmptyBorder(vertical_padding,
288 horizontal_padding,
289 vertical_padding,
290 horizontal_padding));
291 270
292 views::BoxLayout* layout = 271 views::BoxLayout* layout =
293 new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, 0); 272 new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, 0);
294 layout->set_spread_blank_space(true); 273 layout->set_spread_blank_space(true);
295 views::View::SetLayoutManager(layout); 274 views::View::SetLayoutManager(layout);
296 } else { 275 } else {
297 int vertical_padding = kTrayContainerVerticalPaddingVerticalAlignment; 276 SetBorder(views::Border::CreateEmptyBorder(
298 int horizontal_padding = kTrayContainerHorizontalPaddingVerticalAlignment; 277 kPaddingFromEdgeOfShelf,
299 if (ash::switches::UseAlternateShelfLayout()) { 278 kPaddingFromEdgeOfShelf,
300 vertical_padding = kPaddingFromEdgeOfShelf; 279 kPaddingFromEdgeOfShelf,
301 horizontal_padding = kPaddingFromEdgeOfShelf; 280 kPaddingFromEdgeOfShelf));
302 }
303 SetBorder(views::Border::CreateEmptyBorder(vertical_padding,
304 horizontal_padding,
305 vertical_padding,
306 horizontal_padding));
307 281
308 views::BoxLayout* layout = 282 views::BoxLayout* layout =
309 new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0); 283 new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0);
310 layout->set_spread_blank_space(true); 284 layout->set_spread_blank_space(true);
311 views::View::SetLayoutManager(layout); 285 views::View::SetLayoutManager(layout);
312 } 286 }
313 PreferredSizeChanged(); 287 PreferredSizeChanged();
314 } 288 }
315 289
316 //////////////////////////////////////////////////////////////////////////////// 290 ////////////////////////////////////////////////////////////////////////////////
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
350 GetWidget()->AddObserver(widget_observer_.get()); 324 GetWidget()->AddObserver(widget_observer_.get());
351 SetTrayBorder(); 325 SetTrayBorder();
352 } 326 }
353 327
354 const char* TrayBackgroundView::GetClassName() const { 328 const char* TrayBackgroundView::GetClassName() const {
355 return kViewClassName; 329 return kViewClassName;
356 } 330 }
357 331
358 void TrayBackgroundView::OnMouseEntered(const ui::MouseEvent& event) { 332 void TrayBackgroundView::OnMouseEntered(const ui::MouseEvent& event) {
359 hovered_ = true; 333 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 } 334 }
366 335
367 void TrayBackgroundView::OnMouseExited(const ui::MouseEvent& event) { 336 void TrayBackgroundView::OnMouseExited(const ui::MouseEvent& event) {
368 hovered_ = false; 337 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 } 338 }
375 339
376 void TrayBackgroundView::ChildPreferredSizeChanged(views::View* child) { 340 void TrayBackgroundView::ChildPreferredSizeChanged(views::View* child) {
377 PreferredSizeChanged(); 341 PreferredSizeChanged();
378 } 342 }
379 343
380 void TrayBackgroundView::GetAccessibleState(ui::AXViewState* state) { 344 void TrayBackgroundView::GetAccessibleState(ui::AXViewState* state) {
381 state->role = ui::AX_ROLE_BUTTON; 345 state->role = ui::AX_ROLE_BUTTON;
382 state->name = GetAccessibleNameForTray(); 346 state->name = GetAccessibleNameForTray();
383 } 347 }
(...skipping 13 matching lines...) Expand all
397 // 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
398 // 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
399 // should be only around the container. 363 // should be only around the container.
400 return GetContentsBounds(); 364 return GetContentsBounds();
401 } 365 }
402 366
403 void TrayBackgroundView::UpdateBackground(int alpha) { 367 void TrayBackgroundView::UpdateBackground(int alpha) {
404 // 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.
405 if (!background_ || draw_background_as_active_) 369 if (!background_ || draw_background_as_active_)
406 return; 370 return;
407 DCHECK(!ash::switches::UseAlternateShelfLayout());
408 background_->set_alpha(hide_background_animator_.alpha() + 371 background_->set_alpha(hide_background_animator_.alpha() +
409 hover_background_animator_.alpha()); 372 hover_background_animator_.alpha());
410 SchedulePaint(); 373 SchedulePaint();
411 } 374 }
412 375
413 void TrayBackgroundView::SetContents(views::View* contents) { 376 void TrayBackgroundView::SetContents(views::View* contents) {
414 SetLayoutManager(new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0)); 377 SetLayoutManager(new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0));
415 AddChildView(contents); 378 AddChildView(contents);
416 } 379 }
417 380
418 void TrayBackgroundView::SetPaintsBackground( 381 void TrayBackgroundView::SetPaintsBackground(
419 bool value, BackgroundAnimatorChangeType change_type) { 382 bool value, BackgroundAnimatorChangeType change_type) {
420 DCHECK(!ash::switches::UseAlternateShelfLayout());
421 hide_background_animator_.SetPaintsBackground(value, change_type); 383 hide_background_animator_.SetPaintsBackground(value, change_type);
422 } 384 }
423 385
424 void TrayBackgroundView::SetContentsBackground() { 386 void TrayBackgroundView::SetContentsBackground() {
425 background_ = new internal::TrayBackground(this); 387 background_ = new internal::TrayBackground(this);
426 tray_container_->set_background(background_); 388 tray_container_->set_background(background_);
427 } 389 }
428 390
429 ShelfLayoutManager* TrayBackgroundView::GetShelfLayoutManager() { 391 ShelfLayoutManager* TrayBackgroundView::GetShelfLayoutManager() {
430 return ShelfLayoutManager::ForShelf(GetWidget()->GetNativeView()); 392 return ShelfLayoutManager::ForShelf(GetWidget()->GetNativeView());
431 } 393 }
432 394
433 void TrayBackgroundView::SetShelfAlignment(ShelfAlignment alignment) { 395 void TrayBackgroundView::SetShelfAlignment(ShelfAlignment alignment) {
434 shelf_alignment_ = alignment; 396 shelf_alignment_ = alignment;
435 SetTrayBorder(); 397 SetTrayBorder();
436 tray_container_->SetAlignment(alignment); 398 tray_container_->SetAlignment(alignment);
437 } 399 }
438 400
439 void TrayBackgroundView::SetTrayBorder() { 401 void TrayBackgroundView::SetTrayBorder() {
440 views::View* parent = status_area_widget_->status_area_widget_delegate(); 402 views::View* parent = status_area_widget_->status_area_widget_delegate();
441 // 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
442 bool on_edge = (this == parent->child_at(0)); 404 bool on_edge = (this == parent->child_at(0));
443 int left_edge, top_edge, right_edge, bottom_edge; 405 int left_edge, top_edge, right_edge, bottom_edge;
444 if (ash::switches::UseAlternateShelfLayout()) { 406 if (shelf_alignment() == SHELF_ALIGNMENT_BOTTOM) {
445 if (shelf_alignment() == SHELF_ALIGNMENT_BOTTOM) { 407 top_edge = ShelfLayoutManager::kShelfItemInset;
446 top_edge = ShelfLayoutManager::kShelfItemInset; 408 left_edge = 0;
447 left_edge = 0; 409 bottom_edge = kShelfSize -
448 bottom_edge = ShelfLayoutManager::GetPreferredShelfSize() - 410 ShelfLayoutManager::kShelfItemInset - GetShelfItemHeight();
449 ShelfLayoutManager::kShelfItemInset - GetShelfItemHeight(); 411 right_edge = on_edge ? kPaddingFromEdgeOfShelf : 0;
450 right_edge = on_edge ? kPaddingFromEdgeOfShelf : 0; 412 } else if (shelf_alignment() == SHELF_ALIGNMENT_LEFT) {
451 } else if (shelf_alignment() == SHELF_ALIGNMENT_LEFT) { 413 top_edge = 0;
452 top_edge = 0; 414 left_edge = kShelfSize -
453 left_edge = ShelfLayoutManager::GetPreferredShelfSize() - 415 ShelfLayoutManager::kShelfItemInset - GetShelfItemHeight();
454 ShelfLayoutManager::kShelfItemInset - GetShelfItemHeight(); 416 bottom_edge = on_edge ? kPaddingFromEdgeOfShelf : 0;
455 bottom_edge = on_edge ? kPaddingFromEdgeOfShelf : 0; 417 right_edge = ShelfLayoutManager::kShelfItemInset;
456 right_edge = ShelfLayoutManager::kShelfItemInset; 418 } else { // SHELF_ALIGNMENT_RIGHT
457 } else { // SHELF_ALIGNMENT_RIGHT 419 top_edge = 0;
458 top_edge = 0; 420 left_edge = ShelfLayoutManager::kShelfItemInset;
459 left_edge = ShelfLayoutManager::kShelfItemInset; 421 bottom_edge = on_edge ? kPaddingFromEdgeOfShelf : 0;
460 bottom_edge = on_edge ? kPaddingFromEdgeOfShelf : 0; 422 right_edge = kShelfSize -
461 right_edge = ShelfLayoutManager::GetPreferredShelfSize() - 423 ShelfLayoutManager::kShelfItemInset - GetShelfItemHeight();
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 } 424 }
490 SetBorder(views::Border::CreateEmptyBorder( 425 SetBorder(views::Border::CreateEmptyBorder(
491 top_edge, left_edge, bottom_edge, right_edge)); 426 top_edge, left_edge, bottom_edge, right_edge));
492 } 427 }
493 428
494 void TrayBackgroundView::InitializeBubbleAnimations( 429 void TrayBackgroundView::InitializeBubbleAnimations(
495 views::Widget* bubble_widget) { 430 views::Widget* bubble_widget) {
496 views::corewm::SetWindowVisibilityAnimationType( 431 views::corewm::SetWindowVisibilityAnimationType(
497 bubble_widget->GetNativeWindow(), 432 bubble_widget->GetNativeWindow(),
498 views::corewm::WINDOW_VISIBILITY_ANIMATION_TYPE_FADE); 433 views::corewm::WINDOW_VISIBILITY_ANIMATION_TYPE_FADE);
(...skipping 14 matching lines...) Expand all
513 gfx::Rect TrayBackgroundView::GetBubbleAnchorRect( 448 gfx::Rect TrayBackgroundView::GetBubbleAnchorRect(
514 views::Widget* anchor_widget, 449 views::Widget* anchor_widget,
515 TrayBubbleView::AnchorType anchor_type, 450 TrayBubbleView::AnchorType anchor_type,
516 TrayBubbleView::AnchorAlignment anchor_alignment) const { 451 TrayBubbleView::AnchorAlignment anchor_alignment) const {
517 gfx::Rect rect; 452 gfx::Rect rect;
518 if (anchor_widget && anchor_widget->IsVisible()) { 453 if (anchor_widget && anchor_widget->IsVisible()) {
519 rect = anchor_widget->GetWindowBoundsInScreen(); 454 rect = anchor_widget->GetWindowBoundsInScreen();
520 if (anchor_type == TrayBubbleView::ANCHOR_TYPE_TRAY) { 455 if (anchor_type == TrayBubbleView::ANCHOR_TYPE_TRAY) {
521 if (anchor_alignment == TrayBubbleView::ANCHOR_ALIGNMENT_BOTTOM) { 456 if (anchor_alignment == TrayBubbleView::ANCHOR_ALIGNMENT_BOTTOM) {
522 bool rtl = base::i18n::IsRTL(); 457 bool rtl = base::i18n::IsRTL();
523 if (!ash::switches::UseAlternateShelfLayout()) { 458 rect.Inset(
524 rect.Inset( 459 rtl ? kBubblePaddingHorizontalSide : 0,
525 rtl ? kPaddingFromRightEdgeOfScreenBottomAlignment : 0, 460 kBubblePaddingHorizontalBottom,
526 kTrayBubbleAnchorTopInsetBottomAnchor, 461 rtl ? 0 : kBubblePaddingHorizontalSide,
527 rtl ? 0 : kPaddingFromRightEdgeOfScreenBottomAlignment, 462 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) { 463 } else if (anchor_alignment == TrayBubbleView::ANCHOR_ALIGNMENT_LEFT) {
537 if (!ash::switches::UseAlternateShelfLayout()) { 464 rect.Inset(0, 0, kBubblePaddingVerticalSide + 4,
538 rect.Inset(0, 0, kPaddingFromInnerEdgeOfLauncherVerticalAlignment + 5, 465 kBubblePaddingVerticalBottom);
539 kPaddingFromBottomOfScreenVerticalAlignment);
540 } else {
541 rect.Inset(0, 0, kAlternateLayoutBubblePaddingVerticalSide + 4,
542 kAlternateLayoutBubblePaddingVerticalBottom);
543 }
544 } else { 466 } else {
545 if (!ash::switches::UseAlternateShelfLayout()) { 467 rect.Inset(kBubblePaddingVerticalSide, 0, 0,
546 rect.Inset(kPaddingFromInnerEdgeOfLauncherVerticalAlignment + 1, 468 kBubblePaddingVerticalBottom);
547 0, 0, kPaddingFromBottomOfScreenVerticalAlignment);
548 } else {
549 rect.Inset(kAlternateLayoutBubblePaddingVerticalSide, 0, 0,
550 kAlternateLayoutBubblePaddingVerticalBottom);
551 }
552 } 469 }
553 } else if (anchor_type == TrayBubbleView::ANCHOR_TYPE_BUBBLE) { 470 } else if (anchor_type == TrayBubbleView::ANCHOR_TYPE_BUBBLE) {
554 // Invert the offsets to align with the bubble below. 471 // Invert the offsets to align with the bubble below.
555 // Note that with the alternate shelf layout the tips are not shown and 472 int vertical_alignment = 0;
556 // the offsets for left and right alignment do not need to be applied. 473 int horizontal_alignment = kBubblePaddingVerticalBottom;
557 int vertical_alignment = ash::switches::UseAlternateShelfLayout() ?
558 0 :
559 kPaddingFromInnerEdgeOfLauncherVerticalAlignment;
560 int horizontal_alignment = ash::switches::UseAlternateShelfLayout() ?
561 kAlternateLayoutBubblePaddingVerticalBottom :
562 kPaddingFromBottomOfScreenVerticalAlignment;
563 if (anchor_alignment == TrayBubbleView::ANCHOR_ALIGNMENT_LEFT) 474 if (anchor_alignment == TrayBubbleView::ANCHOR_ALIGNMENT_LEFT)
564 rect.Inset(vertical_alignment, 0, 0, horizontal_alignment); 475 rect.Inset(vertical_alignment, 0, 0, horizontal_alignment);
565 else if (anchor_alignment == TrayBubbleView::ANCHOR_ALIGNMENT_RIGHT) 476 else if (anchor_alignment == TrayBubbleView::ANCHOR_ALIGNMENT_RIGHT)
566 rect.Inset(0, 0, vertical_alignment, horizontal_alignment); 477 rect.Inset(0, 0, vertical_alignment, horizontal_alignment);
567 } 478 }
568 } 479 }
569 480
570 // 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.
571 if (rect.IsEmpty()) { 482 if (rect.IsEmpty()) {
572 aura::Window* target_root = anchor_widget ? 483 aura::Window* target_root = anchor_widget ?
(...skipping 20 matching lines...) Expand all
593 return TrayBubbleView::ANCHOR_ALIGNMENT_RIGHT; 504 return TrayBubbleView::ANCHOR_ALIGNMENT_RIGHT;
594 case SHELF_ALIGNMENT_TOP: 505 case SHELF_ALIGNMENT_TOP:
595 return TrayBubbleView::ANCHOR_ALIGNMENT_TOP; 506 return TrayBubbleView::ANCHOR_ALIGNMENT_TOP;
596 } 507 }
597 NOTREACHED(); 508 NOTREACHED();
598 return TrayBubbleView::ANCHOR_ALIGNMENT_BOTTOM; 509 return TrayBubbleView::ANCHOR_ALIGNMENT_BOTTOM;
599 } 510 }
600 511
601 void TrayBackgroundView::SetDrawBackgroundAsActive(bool visible) { 512 void TrayBackgroundView::SetDrawBackgroundAsActive(bool visible) {
602 draw_background_as_active_ = visible; 513 draw_background_as_active_ = visible;
603 if (!background_ || !switches::UseAlternateShelfLayout()) 514 if (!background_)
604 return; 515 return;
605 516
606 // 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.
607 if (draw_background_as_active_) 518 if (draw_background_as_active_)
608 background_->set_color(kTrayBackgroundPressedColor); 519 background_->set_color(kTrayBackgroundPressedColor);
609 else if (hovered_) 520 else if (hovered_)
610 background_->set_alpha(kTrayBackgroundHoverAlpha); 521 background_->set_alpha(kTrayBackgroundHoverAlpha);
611 else 522 else
612 background_->set_alpha(kTrayBackgroundAlpha); 523 background_->set_alpha(kTrayBackgroundAlpha);
613 SchedulePaint(); 524 SchedulePaint();
614 } 525 }
615 526
616 void TrayBackgroundView::UpdateBubbleViewArrow( 527 void TrayBackgroundView::UpdateBubbleViewArrow(
617 views::TrayBubbleView* bubble_view) { 528 views::TrayBubbleView* bubble_view) {
618 if (switches::UseAlternateShelfLayout())
619 return;
620
621 aura::Window* root_window =
622 bubble_view->GetWidget()->GetNativeView()->GetRootWindow();
623 ash::internal::ShelfLayoutManager* shelf =
624 ShelfLayoutManager::ForShelf(root_window);
625 bubble_view->SetArrowPaintType(
626 (shelf && shelf->IsVisible()) ?
627 views::BubbleBorder::PAINT_NORMAL :
628 views::BubbleBorder::PAINT_TRANSPARENT);
629 } 529 }
630 530
631 } // namespace internal 531 } // namespace internal
632 } // namespace ash 532 } // namespace ash
OLDNEW
« no previous file with comments | « ash/system/tray/system_tray.cc ('k') | ash/system/tray/tray_constants.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698