1 // Copyright 2013 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.
5 #ifndef CHROME_BROWSER_UI_VIEWS_MESSAGE_CENTER_MESSAGE_CENTER_WIDGET_DELEGATE_H_
6 #define CHROME_BROWSER_UI_VIEWS_MESSAGE_CENTER_MESSAGE_CENTER_WIDGET_DELEGATE_H_
8 #include "base/basictypes.h"
9 #include "base/compiler_specific.h"
10 #include "base/memory/weak_ptr.h"
11 #include "base/strings/string16.h"
12 #include "ui/gfx/geometry/point.h"
13 #include "ui/gfx/geometry/rect.h"
14 #include "ui/message_center/message_center.h"
15 #include "ui/message_center/message_center_tray.h"
16 #include "ui/message_center/message_center_tray_delegate.h"
17 #include "ui/message_center/views/message_center_view.h"
18 #include "ui/views/widget/widget_delegate.h"
19 #include "ui/views/widget/widget_observer.h"
21 namespace message_center
{
24 ALIGNMENT_TOP
= 1 << 0,
25 ALIGNMENT_LEFT
= 1 << 1,
26 ALIGNMENT_BOTTOM
= 1 << 2,
27 ALIGNMENT_RIGHT
= 1 << 3,
28 ALIGNMENT_NONE
= 1 << 4,
34 // Alignment of the message center relative to the center of the screen.
35 Alignment message_center_alignment
;
37 // Alignment of the taskbar relative to the center of the screen.
38 Alignment taskbar_alignment
;
40 // Point relative to which message center is positioned.
41 gfx::Point inital_anchor_point
;
44 class WebNotificationTray
;
45 class MessageCenterFrameView
;
47 // MessageCenterWidgetDelegate is the message center's client view. It also
48 // creates the message center widget and sets the notifications.
50 ////////////////////////////////////////////////////////////////////////////////
51 class MessageCenterWidgetDelegate
: public views::WidgetDelegate
,
52 public message_center::MessageCenterView
,
53 public views::WidgetObserver
{
55 MessageCenterWidgetDelegate(WebNotificationTray
* tray
,
56 MessageCenterTray
* mc_tray
,
57 bool initially_settings_visible
,
58 const PositionInfo
& pos_info
,
59 const base::string16
& title
);
60 ~MessageCenterWidgetDelegate() override
;
62 // WidgetDelegate overrides:
63 View
* GetContentsView() override
;
64 views::NonClientFrameView
* CreateNonClientFrameView(
65 views::Widget
* widget
) override
;
66 void DeleteDelegate() override
;
67 views::Widget
* GetWidget() override
;
68 const views::Widget
* GetWidget() const override
;
70 // WidgetObserver overrides:
71 void OnWidgetActivationChanged(views::Widget
* widget
, bool active
) override
;
72 void OnWidgetClosing(views::Widget
* widget
) override
;
75 void PreferredSizeChanged() override
;
76 gfx::Size
GetPreferredSize() const override
;
77 gfx::Size
GetMaximumSize() const override
;
78 int GetHeightForWidth(int width
) const override
;
79 bool AcceleratorPressed(const ui::Accelerator
& accelerator
) override
;
82 // Creates and initializes the message center widget.
85 // Shifts the message center anchor point such that the mouse click point is
86 // along the middle 60% of the width of the message center if taskbar is
87 // horizontal aligned. If vertically aligned, ensures that mouse click point
88 // is along the height of the message center (at least at a corner).
89 gfx::Point
GetCorrectedAnchor(gfx::Size calculated_size
);
91 // Calculates the message center bounds using the position info and the
93 gfx::Rect
GetMessageCenterBounds();
95 // Insets of the message center border (set in MessageCenterFrameView).
96 gfx::Insets border_insets_
;
98 // Info necessary to calculate the estimated position of the message center.
99 PositionInfo pos_info_
;
101 WebNotificationTray
* tray_
;
104 } // namespace message_center
106 #endif // CHROME_BROWSER_UI_VIEWS_MESSAGE_CENTER_MESSAGE_CENTER_WIDGET_DELEGATE_H_