OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2010 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 // Draws the view for the balloons. |
| 6 |
| 7 #ifndef CHROME_BROWSER_UI_GTK_NOTIFICATIONS_BALLOON_VIEW_GTK_H_ |
| 8 #define CHROME_BROWSER_UI_GTK_NOTIFICATIONS_BALLOON_VIEW_GTK_H_ |
| 9 #pragma once |
| 10 |
| 11 #include "app/gtk_signal.h" |
| 12 #include "base/basictypes.h" |
| 13 #include "base/scoped_ptr.h" |
| 14 #include "chrome/browser/gtk/menu_gtk.h" |
| 15 #include "chrome/browser/gtk/notifications/balloon_view_host_gtk.h" |
| 16 #include "chrome/browser/notifications/balloon.h" |
| 17 #include "chrome/common/notification_observer.h" |
| 18 #include "chrome/common/notification_registrar.h" |
| 19 #include "gfx/point.h" |
| 20 #include "gfx/rect.h" |
| 21 #include "gfx/size.h" |
| 22 #include "ui/base/animation/animation_delegate.h" |
| 23 |
| 24 class BalloonCollection; |
| 25 class CustomDrawButton; |
| 26 class GtkThemeProvider; |
| 27 class MenuGtk; |
| 28 class NotificationDetails; |
| 29 class NotificationOptionsMenuModel; |
| 30 class NotificationSource; |
| 31 |
| 32 namespace ui { |
| 33 class SlideAnimation; |
| 34 } |
| 35 |
| 36 // A balloon view is the UI component for desktop notification toasts. |
| 37 // It draws a border, and within the border an HTML renderer. |
| 38 class BalloonViewImpl : public BalloonView, |
| 39 public MenuGtk::Delegate, |
| 40 public NotificationObserver, |
| 41 public ui::AnimationDelegate { |
| 42 public: |
| 43 explicit BalloonViewImpl(BalloonCollection* collection); |
| 44 ~BalloonViewImpl(); |
| 45 |
| 46 // BalloonView interface. |
| 47 virtual void Show(Balloon* balloon); |
| 48 virtual void Update(); |
| 49 virtual void RepositionToBalloon(); |
| 50 virtual void Close(bool by_user); |
| 51 virtual gfx::Size GetSize() const; |
| 52 virtual BalloonHost* GetHost() const; |
| 53 |
| 54 private: |
| 55 // NotificationObserver interface. |
| 56 virtual void Observe(NotificationType type, |
| 57 const NotificationSource& source, |
| 58 const NotificationDetails& details); |
| 59 |
| 60 // ui::AnimationDelegate interface. |
| 61 virtual void AnimationProgressed(const ui::Animation* animation); |
| 62 |
| 63 // Do the delayed close work. |
| 64 void DelayedClose(bool by_user); |
| 65 |
| 66 // The height of the balloon's shelf. |
| 67 // The shelf is where is close button is located. |
| 68 int GetShelfHeight() const; |
| 69 |
| 70 // The width and height that the frame should be. If the balloon inside |
| 71 // changes size, this will not be the same as the actual frame size until |
| 72 // RepositionToBalloon() has been called and the animation completes. |
| 73 int GetDesiredTotalWidth() const; |
| 74 int GetDesiredTotalHeight() const; |
| 75 |
| 76 // Where the balloon contents should be placed with respect to the top left |
| 77 // of the frame. |
| 78 gfx::Point GetContentsOffset() const; |
| 79 |
| 80 // Where the balloon contents should be in screen coordinates. |
| 81 gfx::Rect GetContentsRectangle() const; |
| 82 |
| 83 CHROMEGTK_CALLBACK_0(BalloonViewImpl, void, OnCloseButton); |
| 84 CHROMEGTK_CALLBACK_1(BalloonViewImpl, gboolean, OnExpose, GdkEventExpose*); |
| 85 CHROMEGTK_CALLBACK_0(BalloonViewImpl, void, OnOptionsMenuButton); |
| 86 CHROMEGTK_CALLBACK_0(BalloonViewImpl, gboolean, OnDestroy); |
| 87 |
| 88 // Non-owned pointer to the balloon which owns this object. |
| 89 Balloon* balloon_; |
| 90 |
| 91 GtkThemeProvider* theme_provider_; |
| 92 |
| 93 // The window that contains the frame of the notification. |
| 94 GtkWidget* frame_container_; |
| 95 |
| 96 // The widget that contains the shelf. |
| 97 GtkWidget* shelf_; |
| 98 |
| 99 // The hbox within the shelf that contains the buttons. |
| 100 GtkWidget* hbox_; |
| 101 |
| 102 // The window that contains the contents of the notification. |
| 103 GtkWidget* html_container_; |
| 104 |
| 105 // The renderer of the HTML contents. |
| 106 scoped_ptr<BalloonViewHost> html_contents_; |
| 107 |
| 108 // The following factory is used to call methods at a later time. |
| 109 ScopedRunnableMethodFactory<BalloonViewImpl> method_factory_; |
| 110 |
| 111 // Close button. |
| 112 scoped_ptr<CustomDrawButton> close_button_; |
| 113 |
| 114 // An animation to move the balloon on the screen as its position changes. |
| 115 scoped_ptr<ui::SlideAnimation> animation_; |
| 116 gfx::Rect anim_frame_start_; |
| 117 gfx::Rect anim_frame_end_; |
| 118 |
| 119 // The options menu. |
| 120 scoped_ptr<MenuGtk> options_menu_; |
| 121 scoped_ptr<NotificationOptionsMenuModel> options_menu_model_; |
| 122 // The button to open the options menu. |
| 123 scoped_ptr<CustomDrawButton> options_menu_button_; |
| 124 |
| 125 NotificationRegistrar notification_registrar_; |
| 126 |
| 127 DISALLOW_COPY_AND_ASSIGN(BalloonViewImpl); |
| 128 }; |
| 129 |
| 130 #endif // CHROME_BROWSER_UI_GTK_NOTIFICATIONS_BALLOON_VIEW_GTK_H_ |
OLD | NEW |