Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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. | |
| 4 | |
| 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_ | |
| 7 | |
| 8 #include "base/basictypes.h" | |
| 9 #include "base/compiler_specific.h" | |
| 10 #include "base/memory/weak_ptr.h" | |
| 11 #include "chrome/browser/ui/views/message_center/web_notification_tray.h" | |
| 12 #include "ui/base/animation/animation_delegate.h" | |
| 13 #include "ui/base/animation/slide_animation.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" | |
| 20 | |
| 21 namespace gfx { | |
| 22 class Rect; | |
| 23 } | |
| 24 | |
| 25 namespace ui { | |
| 26 class SlideAnimation; | |
| 27 class AnimationDelegate; | |
| 28 } | |
| 29 | |
| 30 class StatusIcon; | |
| 31 | |
| 32 namespace message_center { | |
| 33 | |
| 34 enum Alignment { | |
| 35 ALIGNMENT_TOP = 1, | |
| 36 ALIGNMENT_LEFT = 2, | |
| 37 ALIGNMENT_BOTTOM = 4, | |
| 38 ALIGNMENT_RIGHT = 8, | |
| 39 ALIGNMENT_NONE = 16 | |
| 40 }; | |
| 41 | |
| 42 class WebNotificationTray; | |
| 43 class MessageCenterFrameView; | |
| 44 | |
| 45 class MessageCenterWidgetDelegate : public views::WidgetDelegate, | |
| 46 public message_center::MessageCenterView, | |
| 47 public views::WidgetObserver { | |
| 48 public: | |
| 49 // AnchorAlignment determines to which side of the anchor the bubble will | |
| 50 // align itself. | |
| 51 | |
| 52 MessageCenterWidgetDelegate(WebNotificationTray* tray, | |
| 53 MessageCenterTray* mc_tray, | |
| 54 bool initially_settings_visible); | |
| 55 virtual ~MessageCenterWidgetDelegate(); | |
| 56 | |
| 57 // WidgetDelegate overrides: | |
| 58 virtual View* GetContentsView() OVERRIDE; | |
| 59 virtual views::NonClientFrameView* CreateNonClientFrameView( | |
| 60 views::Widget* widget) OVERRIDE; | |
| 61 virtual views::Widget* GetWidget() OVERRIDE; | |
| 62 virtual const views::Widget* GetWidget() const OVERRIDE; | |
| 63 | |
| 64 // WidgetObserver overrides: | |
| 65 virtual void OnWidgetActivationChanged(views::Widget* widget, bool active) | |
| 66 OVERRIDE; | |
| 67 | |
| 68 // View overrides: | |
| 69 virtual void PreferredSizeChanged() OVERRIDE; | |
| 70 virtual gfx::Size GetPreferredSize() OVERRIDE; | |
| 71 virtual gfx::Size GetMaximumSize() OVERRIDE; | |
| 72 virtual int GetHeightForWidth(int width) OVERRIDE; | |
| 73 virtual bool AcceleratorPressed(const ui::Accelerator& accelerator) OVERRIDE; | |
| 74 virtual void OnNativeThemeChanged(const ui::NativeTheme* theme) OVERRIDE; | |
| 75 | |
| 76 void InitWidget(); | |
| 77 void CloseWidget(); | |
| 78 | |
| 79 // Called after the bubble view has been constructed. Creates and initializes | |
| 80 // the bubble contents. | |
| 81 void InitializeContents(); | |
| 82 | |
| 83 // Update the bubble color from |theme|, unless it was explicitly set. | |
| 84 void UpdateColorsFromTheme(const ui::NativeTheme* theme); | |
| 85 | |
| 86 void UpdateNotifications(); | |
| 87 MessageCenterFrameView* GetBubbleFrameView() const; | |
| 88 gfx::Rect GetBubbleBounds(); | |
| 89 | |
| 90 int min_width() const { return min_width_; } | |
| 91 void set_min_width(int min_width) { min_width_ = min_width; } | |
| 92 | |
| 93 int max_width() const { return max_width_; } | |
| 94 void set_max_width(int max_width) { max_width_ = max_width; } | |
| 95 | |
| 96 int max_height() const { return max_height_; } | |
| 97 void set_max_height(int max_height) { max_height_ = max_height; } | |
| 98 | |
| 99 SkColor color() const { return color_; } | |
|
dewittj
2013/06/28 01:13:18
Can this be private?
sidharthms
2013/07/02 18:09:51
Done. Actually removed
| |
| 100 void set_color(SkColor color) { | |
|
dewittj
2013/06/28 01:13:18
Is this method used anywhere?
sidharthms
2013/07/02 18:09:51
Done.
| |
| 101 color_ = color; | |
| 102 color_explicitly_set_ = true; | |
| 103 } | |
| 104 | |
| 105 bool close_on_esc() const { return close_on_esc_; } | |
|
dewittj
2013/06/28 01:13:18
private
sidharthms
2013/07/02 18:09:51
Done.
| |
| 106 void set_close_on_esc(bool close_on_esc) { close_on_esc_ = close_on_esc; } | |
|
dewittj
2013/06/28 01:13:18
remove
sidharthms
2013/07/02 18:09:51
Done.
| |
| 107 | |
| 108 bool close_on_deactivate() const { return close_on_deactivate_; } | |
|
dewittj
2013/06/28 01:13:18
private
sidharthms
2013/07/02 18:09:51
Done.
| |
| 109 void set_close_on_deactivate(bool close) { close_on_deactivate_ = close; } | |
|
dewittj
2013/06/28 01:13:18
remove
sidharthms
2013/07/02 18:09:51
Done.
| |
| 110 | |
| 111 protected: | |
| 112 // ui::AnimationDelegate overrides: | |
| 113 virtual void AnimationEnded(const ui::Animation* animation) OVERRIDE; | |
|
dewittj
2013/06/28 01:13:18
Do you ever start an animation? If not, remove th
sidharthms
2013/07/02 18:09:51
Done.
| |
| 114 virtual void AnimationProgressed(const ui::Animation* animation) OVERRIDE; | |
| 115 | |
| 116 private: | |
| 117 gfx::Point GetCorrectedAnchor(gfx::Size calculated_size); | |
| 118 void PositionAnchor(); | |
| 119 | |
| 120 int min_width_; | |
| 121 int max_width_; | |
| 122 int max_height_; | |
| 123 | |
| 124 // Alignment of the message center relative to the center of the screen. | |
| 125 Alignment bubble_alignment_; | |
| 126 | |
| 127 // Alignment of the systray and taskbar relative to the center of the screen. | |
| 128 Alignment systray_alignment_; | |
| 129 | |
| 130 // The anchor point must fall somewhere along one of the edge of the message | |
| 131 // center. But since we don't know the size until | |
| 132 gfx::Point inital_anchor_point_; | |
| 133 | |
| 134 // Fade animation for bubble. | |
| 135 scoped_ptr<ui::SlideAnimation> fade_animation_; | |
| 136 | |
| 137 // The background color of the bubble; and flag for when it's explicitly set. | |
| 138 SkColor color_; | |
| 139 bool color_explicitly_set_; | |
|
dewittj
2013/06/28 01:13:18
I suspect this is unnecessarily copied.
sidharthms
2013/07/02 18:09:51
Done.
| |
| 140 | |
| 141 // Flags controlling bubble closure on the escape key and deactivation. | |
| 142 bool close_on_esc_; | |
| 143 bool close_on_deactivate_; | |
| 144 | |
| 145 // Preferred width of message center. | |
| 146 int preferred_width_; | |
| 147 | |
| 148 WebNotificationTray* tray_; | |
| 149 }; | |
| 150 | |
| 151 } // namespace message_center | |
| 152 | |
| 153 #endif // CHROME_BROWSER_UI_VIEWS_MESSAGE_CENTER_MESSAGE_CENTER_WIDGET_DELEGATE _H_ | |
| OLD | NEW |