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

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

Issue 10694043: Handle gesture events in notifications. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase + remove extra WS Created 8 years, 5 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_views.h ('k') | ash/system/web_notification/web_notification_tray.cc » ('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_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 "grit/ash_strings.h" 8 #include "grit/ash_strings.h"
9 #include "grit/ui_resources_standard.h" 9 #include "grit/ui_resources_standard.h"
10 #include "grit/ui_resources_standard.h"
11 #include "ui/base/accessibility/accessible_view_state.h" 10 #include "ui/base/accessibility/accessible_view_state.h"
12 #include "ui/base/resource/resource_bundle.h" 11 #include "ui/base/resource/resource_bundle.h"
13 #include "ui/gfx/canvas.h" 12 #include "ui/gfx/canvas.h"
14 #include "ui/gfx/image/image.h" 13 #include "ui/gfx/image/image.h"
15 #include "ui/gfx/image/image_skia.h" 14 #include "ui/gfx/image/image_skia.h"
16 #include "ui/views/border.h" 15 #include "ui/views/border.h"
17 #include "ui/views/controls/button/image_button.h" 16 #include "ui/views/controls/button/image_button.h"
18 #include "ui/views/controls/label.h" 17 #include "ui/views/controls/label.h"
19 #include "ui/views/layout/box_layout.h" 18 #include "ui/views/layout/box_layout.h"
20 #include "ui/views/layout/fill_layout.h" 19 #include "ui/views/layout/fill_layout.h"
(...skipping 484 matching lines...) Expand 10 before | Expand all | Expand 10 after
505 bounds.set_height(content_bounds.height()); 504 bounds.set_height(content_bounds.height());
506 bounds = content_bounds.Center(bounds.size()); 505 bounds = content_bounds.Center(bounds.size());
507 bounds.set_x(content_bounds.width() - bounds.width()); 506 bounds.set_x(content_bounds.width() - bounds.width());
508 button_container_->SetBoundsRect(bounds); 507 button_container_->SetBoundsRect(bounds);
509 508
510 bounds = content_->bounds(); 509 bounds = content_->bounds();
511 bounds.set_width(button_container_->x()); 510 bounds.set_width(button_container_->x());
512 content_->SetBoundsRect(bounds); 511 content_->SetBoundsRect(bounds);
513 } 512 }
514 513
515 ////////////////////////////////////////////////////////////////////////////////
516 // TrayNotificationView
517
518 TrayNotificationView::TrayNotificationView(int icon_id) : icon_id_(icon_id) {
519 }
520
521 TrayNotificationView::~TrayNotificationView() {
522 }
523
524 void TrayNotificationView::InitView(views::View* contents) {
525 set_background(views::Background::CreateSolidBackground(kBackgroundColor));
526
527 views::GridLayout* layout = new views::GridLayout(this);
528 SetLayoutManager(layout);
529
530 views::ImageButton* close_button = new views::ImageButton(this);
531 close_button->SetImage(views::CustomButton::BS_NORMAL,
532 ResourceBundle::GetSharedInstance().GetImageSkiaNamed(
533 IDR_AURA_WINDOW_CLOSE));
534
535 icon_ = new views::ImageView;
536 if (icon_id_ != 0) {
537 icon_->SetImage(
538 ResourceBundle::GetSharedInstance().GetImageSkiaNamed(icon_id_));
539 }
540
541 views::ColumnSet* columns = layout->AddColumnSet(0);
542
543 columns->AddPaddingColumn(0, kTrayPopupPaddingHorizontal/2);
544
545 // Icon
546 columns->AddColumn(views::GridLayout::CENTER, views::GridLayout::CENTER,
547 0, /* resize percent */
548 views::GridLayout::FIXED,
549 kNotificationIconWidth, kNotificationIconWidth);
550
551 columns->AddPaddingColumn(0, kTrayPopupPaddingHorizontal/2);
552
553 // Contents
554 columns->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL,
555 0, /* resize percent */
556 views::GridLayout::FIXED,
557 kTrayNotificationContentsWidth,
558 kTrayNotificationContentsWidth);
559
560 columns->AddPaddingColumn(0, kTrayPopupPaddingHorizontal/2);
561
562 // Close button
563 columns->AddColumn(views::GridLayout::CENTER, views::GridLayout::CENTER,
564 0, /* resize percent */
565 views::GridLayout::FIXED,
566 kNotificationIconWidth, kNotificationIconWidth);
567
568 columns->AddPaddingColumn(0, kTrayPopupPaddingHorizontal/2);
569
570 // Layout rows
571 layout->AddPaddingRow(0, kTrayPopupPaddingBetweenItems);
572 layout->StartRow(0, 0);
573 layout->AddView(icon_);
574 layout->AddView(contents);
575 layout->AddView(close_button);
576 layout->AddPaddingRow(0, kTrayPopupPaddingBetweenItems);
577 }
578
579 void TrayNotificationView::SetIconImage(const gfx::ImageSkia& image) {
580 icon_->SetImage(image);
581 SchedulePaint();
582 }
583
584 void TrayNotificationView::UpdateView(views::View* new_contents) {
585 RemoveAllChildViews(true);
586 InitView(new_contents);
587 Layout();
588 PreferredSizeChanged();
589 SchedulePaint();
590 }
591
592 void TrayNotificationView::UpdateViewAndImage(views::View* new_contents,
593 const gfx::ImageSkia& image) {
594 RemoveAllChildViews(true);
595 InitView(new_contents);
596 icon_->SetImage(image);
597 Layout();
598 PreferredSizeChanged();
599 SchedulePaint();
600 }
601
602 void TrayNotificationView::ButtonPressed(views::Button* sender,
603 const views::Event& event) {
604 OnClose();
605 }
606
607 void SetupLabelForTray(views::Label* label) { 514 void SetupLabelForTray(views::Label* label) {
608 label->SetFont( 515 label->SetFont(
609 label->font().DeriveFont(2, gfx::Font::BOLD)); 516 label->font().DeriveFont(2, gfx::Font::BOLD));
610 label->SetAutoColorReadabilityEnabled(false); 517 label->SetAutoColorReadabilityEnabled(false);
611 label->SetEnabledColor(SK_ColorWHITE); 518 label->SetEnabledColor(SK_ColorWHITE);
612 label->SetBackgroundColor(SkColorSetARGB(0, 255, 255, 255)); 519 label->SetBackgroundColor(SkColorSetARGB(0, 255, 255, 255));
613 label->SetShadowColors(SkColorSetARGB(64, 0, 0, 0), 520 label->SetShadowColors(SkColorSetARGB(64, 0, 0, 0),
614 SkColorSetARGB(64, 0, 0, 0)); 521 SkColorSetARGB(64, 0, 0, 0));
615 label->SetShadowOffset(0, 1); 522 label->SetShadowOffset(0, 1);
616 } 523 }
617 524
618 } // namespace internal 525 } // namespace internal
619 } // namespace ash 526 } // namespace ash
OLDNEW
« no previous file with comments | « ash/system/tray/tray_views.h ('k') | ash/system/web_notification/web_notification_tray.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698