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

Side by Side Diff: ash/system/tray/tray_background_view.h

Issue 10824153: Change Ash web notification behavior (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix unit tests Created 8 years, 4 months 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef ASH_SYSTEM_TRAY_TRAY_BACKGROUND_VIEW_H_ 5 #ifndef ASH_SYSTEM_TRAY_TRAY_BACKGROUND_VIEW_H_
6 #define ASH_SYSTEM_TRAY_TRAY_BACKGROUND_VIEW_H_ 6 #define ASH_SYSTEM_TRAY_TRAY_BACKGROUND_VIEW_H_
7 7
8 #include "ash/ash_export.h" 8 #include "ash/ash_export.h"
9 #include "ash/launcher/background_animator.h" 9 #include "ash/launcher/background_animator.h"
10 #include "ash/system/tray/tray_views.h" 10 #include "ash/system/tray/tray_views.h"
11 #include "ash/wm/shelf_types.h" 11 #include "ash/wm/shelf_types.h"
12 12
13 namespace ash { 13 namespace ash {
14 namespace internal { 14 namespace internal {
15 15
16 class StatusAreaWidget;
16 class TrayBackground; 17 class TrayBackground;
17 18
18 // Base class for children of StatusAreaWidget: SystemTray, WebNotificationTray. 19 // Base class for children of StatusAreaWidget: SystemTray, WebNotificationTray.
19 // This class handles setting and animating the background when the Launcher 20 // This class handles setting and animating the background when the Launcher
20 // his shown/hidden. It also inherits from ActionableView so that the tray 21 // his shown/hidden. It also inherits from ActionableView so that the tray
21 // items can override PerformAction when clicked on. 22 // items can override PerformAction when clicked on.
22 23
23 class ASH_EXPORT TrayBackgroundView : public internal::ActionableView, 24 class ASH_EXPORT TrayBackgroundView : public internal::ActionableView,
24 public BackgroundAnimatorDelegate { 25 public BackgroundAnimatorDelegate {
25 public: 26 public:
26 TrayBackgroundView(); 27 // Base class for tray containers. Sets the border and layout. The container
28 // auto-resizes the widget when necessary.
29 class TrayContainer : public views::View {
30 public:
31 explicit TrayContainer(ShelfAlignment alignment);
32 virtual ~TrayContainer() {}
33
34 void SetAlignment(ShelfAlignment alignment);
35
36 void set_size(const gfx::Size& size) { size_ = size; }
37
38 // Overridden from views::View.
39 virtual gfx::Size GetPreferredSize();
40
41 protected:
42 // Overridden from views::View.
43 virtual void ChildPreferredSizeChanged(views::View* child) OVERRIDE;
44 virtual void ChildVisibilityChanged(View* child) OVERRIDE;
45 virtual void ViewHierarchyChanged(bool is_add,
46 View* parent,
47 View* child) OVERRIDE;
48
49 private:
50 void UpdateLayout();
51
52 ShelfAlignment alignment_;
53 gfx::Size size_;
54
55 DISALLOW_COPY_AND_ASSIGN(TrayContainer);
56 };
57
58 explicit TrayBackgroundView(internal::StatusAreaWidget* status_area_widget);
27 virtual ~TrayBackgroundView(); 59 virtual ~TrayBackgroundView();
28 60
29 // Overridden from views::View. 61 // Overridden from views::View.
30 virtual void OnMouseEntered(const views::MouseEvent& event) OVERRIDE; 62 virtual void OnMouseEntered(const views::MouseEvent& event) OVERRIDE;
31 virtual void OnMouseExited(const views::MouseEvent& event) OVERRIDE; 63 virtual void OnMouseExited(const views::MouseEvent& event) OVERRIDE;
32 virtual void ChildPreferredSizeChanged(views::View* child) OVERRIDE; 64 virtual void ChildPreferredSizeChanged(views::View* child) OVERRIDE;
33 65
34 // Overridden from internal::ActionableView. 66 // Overridden from internal::ActionableView.
35 virtual bool PerformAction(const views::Event& event) OVERRIDE; 67 virtual bool PerformAction(const views::Event& event) OVERRIDE;
36 68
37 // Overridden from internal::BackgroundAnimatorDelegate. 69 // Overridden from internal::BackgroundAnimatorDelegate.
38 virtual void UpdateBackground(int alpha) OVERRIDE; 70 virtual void UpdateBackground(int alpha) OVERRIDE;
39 71
40 // Called whenever the shelf alignment changes. 72 // Called whenever the shelf alignment changes.
41 virtual void SetShelfAlignment(ShelfAlignment alignment); 73 virtual void SetShelfAlignment(ShelfAlignment alignment);
42 74
43 // Sets |contents| as a child and sets its background to |background_|. 75 // Sets |contents| as a child and sets its background to |background_|.
44 void SetContents(views::View* contents); 76 void SetContents(views::View* contents);
45 77
46 // Sets whether the tray paints a background. Default is true, but is set to 78 // Sets whether the tray paints a background. Default is true, but is set to
47 // false if a window overlaps the shelf. 79 // false if a window overlaps the shelf.
48 void SetPaintsBackground( 80 void SetPaintsBackground(
49 bool value, 81 bool value,
50 internal::BackgroundAnimator::ChangeType change_type); 82 internal::BackgroundAnimator::ChangeType change_type);
51 83
84 StatusAreaWidget* status_area_widget() {
85 return status_area_widget_;
86 }
87 TrayContainer* tray_container() const { return tray_container_; }
52 ShelfAlignment shelf_alignment() const { return shelf_alignment_; } 88 ShelfAlignment shelf_alignment() const { return shelf_alignment_; }
53 89
54 private: 90 private:
91 void SetBorder();
92
93 // Unowned pointer to parent widget.
94 StatusAreaWidget* status_area_widget_;
95
96 // Convenience pointer to the contents view.
97 TrayContainer* tray_container_;
98
55 // Shelf alignment. 99 // Shelf alignment.
56 ShelfAlignment shelf_alignment_; 100 ShelfAlignment shelf_alignment_;
57 101
58 // Owned by the view passed to SetContents(). 102 // Owned by the view passed to SetContents().
59 internal::TrayBackground* background_; 103 internal::TrayBackground* background_;
60 104
61 internal::BackgroundAnimator hide_background_animator_; 105 internal::BackgroundAnimator hide_background_animator_;
62 internal::BackgroundAnimator hover_background_animator_; 106 internal::BackgroundAnimator hover_background_animator_;
63 107
64 DISALLOW_COPY_AND_ASSIGN(TrayBackgroundView); 108 DISALLOW_COPY_AND_ASSIGN(TrayBackgroundView);
65 }; 109 };
66 110
67 } // namespace internal 111 } // namespace internal
68 } // namespace ash 112 } // namespace ash
69 113
70 #endif // ASH_SYSTEM_TRAY_TRAY_BACKGROUND_VIEW_H_ 114 #endif // ASH_SYSTEM_TRAY_TRAY_BACKGROUND_VIEW_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698