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

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

Issue 145033006: views: Make View::set_border() take a scoped_ptr<>. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase to ToT Created 6 years, 11 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/tray_background_view.h ('k') | ash/system/tray/tray_details_view.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 266 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 // Adjust the size of status tray dark background by adding additional 277 // Adjust the size of status tray dark background by adding additional
278 // empty border. 278 // empty border.
279 if (alignment_ == SHELF_ALIGNMENT_BOTTOM || 279 if (alignment_ == SHELF_ALIGNMENT_BOTTOM ||
280 alignment_ == SHELF_ALIGNMENT_TOP) { 280 alignment_ == SHELF_ALIGNMENT_TOP) {
281 int vertical_padding = kTrayContainerVerticalPaddingBottomAlignment; 281 int vertical_padding = kTrayContainerVerticalPaddingBottomAlignment;
282 int horizontal_padding = kTrayContainerHorizontalPaddingBottomAlignment; 282 int horizontal_padding = kTrayContainerHorizontalPaddingBottomAlignment;
283 if (ash::switches::UseAlternateShelfLayout()) { 283 if (ash::switches::UseAlternateShelfLayout()) {
284 vertical_padding = kPaddingFromEdgeOfShelf; 284 vertical_padding = kPaddingFromEdgeOfShelf;
285 horizontal_padding = kPaddingFromEdgeOfShelf; 285 horizontal_padding = kPaddingFromEdgeOfShelf;
286 } 286 }
287 set_border(views::Border::CreateEmptyBorder( 287 SetBorder(views::Border::CreateEmptyBorder(vertical_padding,
288 vertical_padding, 288 horizontal_padding,
289 horizontal_padding, 289 vertical_padding,
290 vertical_padding, 290 horizontal_padding));
291 horizontal_padding));
292 291
293 views::BoxLayout* layout = 292 views::BoxLayout* layout =
294 new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, 0); 293 new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, 0);
295 layout->set_spread_blank_space(true); 294 layout->set_spread_blank_space(true);
296 views::View::SetLayoutManager(layout); 295 views::View::SetLayoutManager(layout);
297 } else { 296 } else {
298 int vertical_padding = kTrayContainerVerticalPaddingVerticalAlignment; 297 int vertical_padding = kTrayContainerVerticalPaddingVerticalAlignment;
299 int horizontal_padding = kTrayContainerHorizontalPaddingVerticalAlignment; 298 int horizontal_padding = kTrayContainerHorizontalPaddingVerticalAlignment;
300 if (ash::switches::UseAlternateShelfLayout()) { 299 if (ash::switches::UseAlternateShelfLayout()) {
301 vertical_padding = kPaddingFromEdgeOfShelf; 300 vertical_padding = kPaddingFromEdgeOfShelf;
302 horizontal_padding = kPaddingFromEdgeOfShelf; 301 horizontal_padding = kPaddingFromEdgeOfShelf;
303 } 302 }
304 set_border(views::Border::CreateEmptyBorder( 303 SetBorder(views::Border::CreateEmptyBorder(vertical_padding,
305 vertical_padding, 304 horizontal_padding,
306 horizontal_padding, 305 vertical_padding,
307 vertical_padding, 306 horizontal_padding));
308 horizontal_padding));
309 307
310 views::BoxLayout* layout = 308 views::BoxLayout* layout =
311 new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0); 309 new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0);
312 layout->set_spread_blank_space(true); 310 layout->set_spread_blank_space(true);
313 views::View::SetLayoutManager(layout); 311 views::View::SetLayoutManager(layout);
314 } 312 }
315 PreferredSizeChanged(); 313 PreferredSizeChanged();
316 } 314 }
317 315
318 //////////////////////////////////////////////////////////////////////////////// 316 ////////////////////////////////////////////////////////////////////////////////
(...skipping 24 matching lines...) Expand all
343 tray_event_filter_.reset(new TrayEventFilter); 341 tray_event_filter_.reset(new TrayEventFilter);
344 } 342 }
345 343
346 TrayBackgroundView::~TrayBackgroundView() { 344 TrayBackgroundView::~TrayBackgroundView() {
347 if (GetWidget()) 345 if (GetWidget())
348 GetWidget()->RemoveObserver(widget_observer_.get()); 346 GetWidget()->RemoveObserver(widget_observer_.get());
349 } 347 }
350 348
351 void TrayBackgroundView::Initialize() { 349 void TrayBackgroundView::Initialize() {
352 GetWidget()->AddObserver(widget_observer_.get()); 350 GetWidget()->AddObserver(widget_observer_.get());
353 SetBorder(); 351 SetTrayBorder();
354 } 352 }
355 353
356 const char* TrayBackgroundView::GetClassName() const { 354 const char* TrayBackgroundView::GetClassName() const {
357 return kViewClassName; 355 return kViewClassName;
358 } 356 }
359 357
360 void TrayBackgroundView::OnMouseEntered(const ui::MouseEvent& event) { 358 void TrayBackgroundView::OnMouseEntered(const ui::MouseEvent& event) {
361 hovered_ = true; 359 hovered_ = true;
362 if (!background_ || draw_background_as_active_ || 360 if (!background_ || draw_background_as_active_ ||
363 ash::switches::UseAlternateShelfLayout()) 361 ash::switches::UseAlternateShelfLayout())
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
427 background_ = new internal::TrayBackground(this); 425 background_ = new internal::TrayBackground(this);
428 tray_container_->set_background(background_); 426 tray_container_->set_background(background_);
429 } 427 }
430 428
431 ShelfLayoutManager* TrayBackgroundView::GetShelfLayoutManager() { 429 ShelfLayoutManager* TrayBackgroundView::GetShelfLayoutManager() {
432 return ShelfLayoutManager::ForShelf(GetWidget()->GetNativeView()); 430 return ShelfLayoutManager::ForShelf(GetWidget()->GetNativeView());
433 } 431 }
434 432
435 void TrayBackgroundView::SetShelfAlignment(ShelfAlignment alignment) { 433 void TrayBackgroundView::SetShelfAlignment(ShelfAlignment alignment) {
436 shelf_alignment_ = alignment; 434 shelf_alignment_ = alignment;
437 SetBorder(); 435 SetTrayBorder();
438 tray_container_->SetAlignment(alignment); 436 tray_container_->SetAlignment(alignment);
439 } 437 }
440 438
441 void TrayBackgroundView::SetBorder() { 439 void TrayBackgroundView::SetTrayBorder() {
442 views::View* parent = status_area_widget_->status_area_widget_delegate(); 440 views::View* parent = status_area_widget_->status_area_widget_delegate();
443 // 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
444 bool on_edge = (this == parent->child_at(0)); 442 bool on_edge = (this == parent->child_at(0));
445 int left_edge, top_edge, right_edge, bottom_edge; 443 int left_edge, top_edge, right_edge, bottom_edge;
446 if (ash::switches::UseAlternateShelfLayout()) { 444 if (ash::switches::UseAlternateShelfLayout()) {
447 if (shelf_alignment() == SHELF_ALIGNMENT_BOTTOM) { 445 if (shelf_alignment() == SHELF_ALIGNMENT_BOTTOM) {
448 top_edge = ShelfLayoutManager::kShelfItemInset; 446 top_edge = ShelfLayoutManager::kShelfItemInset;
449 left_edge = 0; 447 left_edge = 0;
450 bottom_edge = ShelfLayoutManager::GetPreferredShelfSize() - 448 bottom_edge = ShelfLayoutManager::GetPreferredShelfSize() -
451 ShelfLayoutManager::kShelfItemInset - GetShelfItemHeight(); 449 ShelfLayoutManager::kShelfItemInset - GetShelfItemHeight();
(...skipping 30 matching lines...) Expand all
482 left_edge = kPaddingFromOuterEdgeOfLauncherVerticalAlignment; 480 left_edge = kPaddingFromOuterEdgeOfLauncherVerticalAlignment;
483 bottom_edge = on_edge ? kPaddingFromBottomOfScreenVerticalAlignment : 0; 481 bottom_edge = on_edge ? kPaddingFromBottomOfScreenVerticalAlignment : 0;
484 right_edge = kPaddingFromInnerEdgeOfLauncherVerticalAlignment; 482 right_edge = kPaddingFromInnerEdgeOfLauncherVerticalAlignment;
485 } else { 483 } else {
486 top_edge = 0; 484 top_edge = 0;
487 left_edge = kPaddingFromInnerEdgeOfLauncherVerticalAlignment; 485 left_edge = kPaddingFromInnerEdgeOfLauncherVerticalAlignment;
488 bottom_edge = on_edge ? kPaddingFromBottomOfScreenVerticalAlignment : 0; 486 bottom_edge = on_edge ? kPaddingFromBottomOfScreenVerticalAlignment : 0;
489 right_edge = kPaddingFromOuterEdgeOfLauncherVerticalAlignment; 487 right_edge = kPaddingFromOuterEdgeOfLauncherVerticalAlignment;
490 } 488 }
491 } 489 }
492 set_border(views::Border::CreateEmptyBorder( 490 SetBorder(views::Border::CreateEmptyBorder(
493 top_edge, left_edge, bottom_edge, right_edge)); 491 top_edge, left_edge, bottom_edge, right_edge));
494 } 492 }
495 493
496 void TrayBackgroundView::InitializeBubbleAnimations( 494 void TrayBackgroundView::InitializeBubbleAnimations(
497 views::Widget* bubble_widget) { 495 views::Widget* bubble_widget) {
498 views::corewm::SetWindowVisibilityAnimationType( 496 views::corewm::SetWindowVisibilityAnimationType(
499 bubble_widget->GetNativeWindow(), 497 bubble_widget->GetNativeWindow(),
500 views::corewm::WINDOW_VISIBILITY_ANIMATION_TYPE_FADE); 498 views::corewm::WINDOW_VISIBILITY_ANIMATION_TYPE_FADE);
501 views::corewm::SetWindowVisibilityAnimationTransition( 499 views::corewm::SetWindowVisibilityAnimationTransition(
502 bubble_widget->GetNativeWindow(), 500 bubble_widget->GetNativeWindow(),
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
625 ash::internal::ShelfLayoutManager* shelf = 623 ash::internal::ShelfLayoutManager* shelf =
626 ShelfLayoutManager::ForShelf(root_window); 624 ShelfLayoutManager::ForShelf(root_window);
627 bubble_view->SetArrowPaintType( 625 bubble_view->SetArrowPaintType(
628 (shelf && shelf->IsVisible()) ? 626 (shelf && shelf->IsVisible()) ?
629 views::BubbleBorder::PAINT_NORMAL : 627 views::BubbleBorder::PAINT_NORMAL :
630 views::BubbleBorder::PAINT_TRANSPARENT); 628 views::BubbleBorder::PAINT_TRANSPARENT);
631 } 629 }
632 630
633 } // namespace internal 631 } // namespace internal
634 } // namespace ash 632 } // namespace ash
OLDNEW
« no previous file with comments | « ash/system/tray/tray_background_view.h ('k') | ash/system/tray/tray_details_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698