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

Side by Side Diff: chrome/browser/views/notifications/balloon_view.h

Issue 338051: Adds UI components for desktop notifications, including balloon view classes ... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: use notused.png resources for try servers Created 11 years, 1 month 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
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
1 // Copyright (c) 2009 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_VIEWS_NOTIFICATIONS_BALLOON_VIEW_H_
8 #define CHROME_BROWSER_VIEWS_NOTIFICATIONS_BALLOON_VIEW_H_
9
10 #include "app/gfx/path.h"
11 #include "app/slide_animation.h"
12 #include "base/basictypes.h"
13 #include "base/gfx/point.h"
14 #include "base/gfx/rect.h"
15 #include "base/gfx/size.h"
16 #include "base/scoped_ptr.h"
17 #include "base/task.h"
18 #include "chrome/browser/notifications/balloon.h"
19 #include "chrome/common/notification_registrar.h"
20 #include "chrome/common/notification_service.h"
21 #include "views/view.h"
22
23 namespace views {
24 class ButtonListener;
25 class ImagePainter;
26 class TextButton;
27 class WidgetWin;
28 } // namespace views
29
30 class BalloonViewHost;
31 class NotificationDetails;
32 class NotificationSource;
33 class SlideAnimation;
34
35 // A balloon view is the UI component for a desktop notification toasts.
36 // It draws a border, and within the border an HTML renderer.
37 class BalloonViewImpl : public BalloonView,
38 public views::View,
39 public NotificationObserver,
40 public AnimationDelegate {
41 public:
42 BalloonViewImpl();
43 ~BalloonViewImpl();
44
45 // BalloonView interface.
46 void Show(Balloon* balloon);
47 void RepositionToBalloon();
48 void Close();
49
50 private:
51 // Overridden from views::View.
52 virtual void Paint(gfx::Canvas* canvas);
53 virtual void DidChangeBounds(const gfx::Rect& previous,
54 const gfx::Rect& current);
55 virtual gfx::Size GetPreferredSize() {
56 return gfx::Size(1000, 1000);
57 }
58
59 // NotificationObserver method.
60 virtual void Observe(NotificationType type,
61 const NotificationSource& source,
62 const NotificationDetails& details);
63
64 // AnimationDelegate method.
65 virtual void AnimationProgressed(const Animation* animation);
66
67 // How to mask the balloon contents to fit within the frame.
68 // Populates |path| with the outline.
69 void GetContentsMask(const gfx::Rect& contents_rect, gfx::Path* path) const;
70
71 // Adjust the contents window size to be appropriate for the frame.
72 void SizeContentsWindow();
73
74 // Do the delayed close work.
75 void DelayedClose();
76
77 // The height of the balloon's shelf.
78 // The shelf is where is close button is located.
79 int GetShelfHeight() const;
80
81 // The width of the frame (not including any shadow).
82 int GetFrameWidth() const;
83
84 // The height of the frame (not including any shadow).
85 int GetTotalFrameHeight() const;
86
87 // The height of the part of the frame around the balloon.
88 int GetBalloonFrameHeight() const;
89
90 // Where the balloon contents should be placed with respect to the top left
91 // of the frame.
92 gfx::Point GetContentsOffset() const;
93
94 // Where the balloon contents should be in screen coordinates.
95 gfx::Rect GetContentsRectangle() const;
96
97 // Non-owned pointer to the balloon which owns this object.
98 Balloon* balloon_;
99
100 // The window that contains the frame of the notification.
101 // Pointer owned by the View subclass.
102 views::Widget* frame_container_;
103
104 // The window that contains the contents of the notification.
105 // Pointer owned by the View subclass.
106 views::Widget* html_container_;
107
108 // The renderer of the HTML contents. Pointer owned by the views hierarchy.
109 BalloonViewHost* html_contents_;
110
111 // The following factory is used to call methods at a later time.
112 ScopedRunnableMethodFactory<BalloonViewImpl> method_factory_;
113
114 // Image painters for the frame of the toast.
115 scoped_ptr<views::Painter> shelf_background_;
116 scoped_ptr<views::Painter> balloon_background_;
117
118 // Pointer to sub-view is owned by the View sub-class.
119 views::TextButton* close_button_;
120
121 // Listener for clicks on the close button.
122 scoped_ptr<views::ButtonListener> close_button_listener_;
123
124 // An animation to move the balloon on the screen as its position changes.
125 scoped_ptr<SlideAnimation> animation_;
126 gfx::Rect anim_frame_start_;
127 gfx::Rect anim_frame_end_;
128
129 NotificationRegistrar notification_registrar_;
130
131 DISALLOW_COPY_AND_ASSIGN(BalloonViewImpl);
132 };
133
134 #endif // CHROME_BROWSER_VIEWS_NOTIFICATIONS_BALLOON_VIEW_H_
OLDNEW
« no previous file with comments | « chrome/browser/notifications/balloons.h ('k') | chrome/browser/views/notifications/balloon_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698