| 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_views.h" | 5 #include "ash/system/tray/tray_views.h" |
| 6 | 6 |
| 7 #include "ash/system/tray/tray_constants.h" | 7 #include "ash/system/tray/tray_constants.h" |
| 8 #include "third_party/skia/include/core/SkBitmap.h" | 8 #include "third_party/skia/include/core/SkBitmap.h" |
| 9 #include "grit/ash_strings.h" | 9 #include "grit/ash_strings.h" |
| 10 #include "grit/ui_resources.h" | 10 #include "grit/ui_resources.h" |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 const int kPaddingAroundButtons = 5; | 29 const int kPaddingAroundButtons = 5; |
| 30 | 30 |
| 31 views::View* CreatePopupHeaderButtonsContainer() { | 31 views::View* CreatePopupHeaderButtonsContainer() { |
| 32 views::View* view = new views::View; | 32 views::View* view = new views::View; |
| 33 view->SetLayoutManager(new | 33 view->SetLayoutManager(new |
| 34 views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, -1)); | 34 views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, -1)); |
| 35 view->set_border(views::Border::CreateEmptyBorder(0, 0, 0, 5)); | 35 view->set_border(views::Border::CreateEmptyBorder(0, 0, 0, 5)); |
| 36 return view; | 36 return view; |
| 37 } | 37 } |
| 38 | 38 |
| 39 const int kNotificationCloseButtonWidth = 60; | |
| 40 } | 39 } |
| 41 | 40 |
| 42 //////////////////////////////////////////////////////////////////////////////// | 41 //////////////////////////////////////////////////////////////////////////////// |
| 43 // FixedSizedImageView | 42 // FixedSizedImageView |
| 44 | 43 |
| 45 FixedSizedImageView::FixedSizedImageView(int width, int height) | 44 FixedSizedImageView::FixedSizedImageView(int width, int height) |
| 46 : width_(width), | 45 : width_(width), |
| 47 height_(height) { | 46 height_(height) { |
| 48 SetHorizontalAlignment(views::ImageView::CENTER); | 47 SetHorizontalAlignment(views::ImageView::CENTER); |
| 49 SetVerticalAlignment(views::ImageView::CENTER); | 48 SetVerticalAlignment(views::ImageView::CENTER); |
| (...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 463 | 462 |
| 464 TrayNotificationView::TrayNotificationView() { | 463 TrayNotificationView::TrayNotificationView() { |
| 465 } | 464 } |
| 466 | 465 |
| 467 void TrayNotificationView::InitView(views::View* contents) { | 466 void TrayNotificationView::InitView(views::View* contents) { |
| 468 set_background(views::Background::CreateSolidBackground(kBackgroundColor)); | 467 set_background(views::Background::CreateSolidBackground(kBackgroundColor)); |
| 469 | 468 |
| 470 views::GridLayout* layout = new views::GridLayout(this); | 469 views::GridLayout* layout = new views::GridLayout(this); |
| 471 SetLayoutManager(layout); | 470 SetLayoutManager(layout); |
| 472 | 471 |
| 473 AddChildView(contents); | |
| 474 | |
| 475 views::ImageButton* close_button = new views::ImageButton(this); | 472 views::ImageButton* close_button = new views::ImageButton(this); |
| 476 close_button->SetImage(views::CustomButton::BS_NORMAL, | 473 close_button->SetImage(views::CustomButton::BS_NORMAL, |
| 477 ResourceBundle::GetSharedInstance().GetBitmapNamed( | 474 ResourceBundle::GetSharedInstance().GetBitmapNamed( |
| 478 IDR_AURA_WINDOW_CLOSE)); | 475 IDR_AURA_WINDOW_CLOSE)); |
| 479 AddChildView(close_button); | |
| 480 | 476 |
| 481 int contents_width = kTrayPopupWidth - kNotificationCloseButtonWidth; | 477 int contents_width = kTrayPopupWidth - kNotificationCloseButtonWidth; |
| 482 views::ColumnSet* columns = layout->AddColumnSet(0); | 478 views::ColumnSet* columns = layout->AddColumnSet(0); |
| 483 columns->AddColumn(views::GridLayout::TRAILING, views::GridLayout::FILL, | 479 columns->AddColumn(views::GridLayout::TRAILING, views::GridLayout::FILL, |
| 484 0, /* resize percent */ | 480 0, /* resize percent */ |
| 485 views::GridLayout::FIXED, | 481 views::GridLayout::FIXED, |
| 486 contents_width, | 482 contents_width, |
| 487 contents_width); | 483 contents_width); |
| 488 columns->AddColumn(views::GridLayout::CENTER, views::GridLayout::CENTER, | 484 columns->AddColumn(views::GridLayout::CENTER, views::GridLayout::CENTER, |
| 489 0, /* resize percent */ | 485 0, /* resize percent */ |
| 490 views::GridLayout::FIXED, | 486 views::GridLayout::FIXED, |
| 491 kNotificationCloseButtonWidth, | 487 kNotificationCloseButtonWidth, |
| 492 kNotificationCloseButtonWidth); | 488 kNotificationCloseButtonWidth); |
| 493 | 489 |
| 494 layout->StartRow(0, 0); | 490 layout->StartRow(0, 0); |
| 495 layout->AddView(contents); | 491 layout->AddView(contents); |
| 496 layout->AddView(close_button); | 492 layout->AddView(close_button); |
| 497 } | 493 } |
| 498 | 494 |
| 499 TrayNotificationView::~TrayNotificationView() { | 495 TrayNotificationView::~TrayNotificationView() { |
| 500 } | 496 } |
| 501 | 497 |
| 502 void TrayNotificationView::ButtonPressed(views::Button* sender, | 498 void TrayNotificationView::ButtonPressed(views::Button* sender, |
| 503 const views::Event& event) { | 499 const views::Event& event) { |
| 504 OnClose(); | 500 OnClose(); |
| 505 } | 501 } |
| 506 | 502 |
| 507 } // namespace internal | 503 } // namespace internal |
| 508 } // namespace ash | 504 } // namespace ash |
| OLD | NEW |