OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef ASH_SYSTEM_TRAY_TRAY_NOTIFICATION_VIEW_H_ |
| 6 #define ASH_SYSTEM_TRAY_TRAY_NOTIFICATION_VIEWS_H_ |
| 7 #pragma once |
| 8 |
| 9 #include "ui/views/controls/button/image_button.h" |
| 10 #include "ui/views/view.h" |
| 11 |
| 12 namespace gfx { |
| 13 class ImageSkia; |
| 14 } |
| 15 |
| 16 namespace views { |
| 17 class ImageView; |
| 18 } |
| 19 |
| 20 namespace ash { |
| 21 |
| 22 class SystemTrayItem; |
| 23 |
| 24 namespace internal { |
| 25 |
| 26 // A view for closable notification views, laid out like: |
| 27 // ------------------- |
| 28 // | icon contents x | |
| 29 // ----------------v-- |
| 30 // The close button will call OnClose() when clicked. |
| 31 class TrayNotificationView : public views::View, |
| 32 public views::ButtonListener { |
| 33 public: |
| 34 // If icon_id is 0, no icon image will be set. SetIconImage can be called |
| 35 // to later set the icon image. |
| 36 TrayNotificationView(SystemTrayItem* tray, int icon_id); |
| 37 virtual ~TrayNotificationView(); |
| 38 |
| 39 // InitView must be called once with the contents to be displayed. |
| 40 void InitView(views::View* contents); |
| 41 |
| 42 // Sets/updates the icon image. |
| 43 void SetIconImage(const gfx::ImageSkia& image); |
| 44 |
| 45 // Replaces the contents view. |
| 46 void UpdateView(views::View* new_contents); |
| 47 |
| 48 // Replaces the contents view and updates the icon image. |
| 49 void UpdateViewAndImage(views::View* new_contents, |
| 50 const gfx::ImageSkia& image); |
| 51 |
| 52 // Overridden from ButtonListener. |
| 53 virtual void ButtonPressed(views::Button* sender, |
| 54 const views::Event& event) OVERRIDE; |
| 55 |
| 56 // Overridden from views::View. |
| 57 virtual bool OnMousePressed(const views::MouseEvent& event) OVERRIDE; |
| 58 virtual ui::GestureStatus OnGestureEvent( |
| 59 const views::GestureEvent& event) OVERRIDE; |
| 60 |
| 61 protected: |
| 62 // Called when the close button is pressed. Does nothing by default. |
| 63 virtual void OnClose(); |
| 64 // Called when the notification is clicked on. Does nothing by default. |
| 65 virtual void OnClickAction(); |
| 66 |
| 67 SystemTrayItem* tray() { return tray_; } |
| 68 |
| 69 private: |
| 70 void HandleClose(); |
| 71 void HandleClickAction(); |
| 72 |
| 73 SystemTrayItem* tray_; |
| 74 int icon_id_; |
| 75 views::ImageView* icon_; |
| 76 |
| 77 DISALLOW_COPY_AND_ASSIGN(TrayNotificationView); |
| 78 }; |
| 79 |
| 80 } // namespace internal |
| 81 } // namespace ash |
| 82 |
| 83 #endif // ASH_SYSTEM_TRAY_TRAY_NOTIFICATION_VIEWS_H_ |
OLD | NEW |