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

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

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