OLD | NEW |
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 #include "ui/message_center/views/message_center_bubble.h" | 5 #include "ui/message_center/views/message_center_bubble.h" |
6 | 6 |
7 #include "ui/message_center/message_center_style.h" | 7 #include "ui/message_center/message_center_style.h" |
8 #include "ui/message_center/views/message_center_view.h" | 8 #include "ui/message_center/views/message_center_view.h" |
9 #include "ui/views/layout/fill_layout.h" | 9 #include "ui/views/layout/fill_layout.h" |
10 #include "ui/views/widget/widget.h" | 10 #include "ui/views/widget/widget.h" |
11 | 11 |
12 namespace message_center { | 12 namespace message_center { |
13 | 13 |
14 // ContentsView //////////////////////////////////////////////////////////////// | 14 // ContentsView //////////////////////////////////////////////////////////////// |
15 | 15 |
16 // Handles changes in MessageCenterView sizes. | 16 // Handles changes in MessageCenterView sizes. |
17 class ContentsView : public views::View { | 17 class ContentsView : public views::View { |
18 public: | 18 public: |
19 explicit ContentsView(MessageCenterBubble* bubble, views::View* contents); | 19 explicit ContentsView(MessageCenterBubble* bubble, views::View* contents); |
20 virtual ~ContentsView(); | 20 virtual ~ContentsView(); |
21 | 21 |
22 // Overridden from views::View: | 22 // Overridden from views::View: |
23 virtual int GetHeightForWidth(int width) OVERRIDE; | 23 virtual int GetHeightForWidth(int width) const OVERRIDE; |
24 | 24 |
25 protected: | 25 protected: |
26 // Overridden from views::View: | 26 // Overridden from views::View: |
27 virtual void ChildPreferredSizeChanged(View* child) OVERRIDE; | 27 virtual void ChildPreferredSizeChanged(View* child) OVERRIDE; |
28 | 28 |
29 private: | 29 private: |
30 base::WeakPtr<MessageCenterBubble> bubble_; | 30 base::WeakPtr<MessageCenterBubble> bubble_; |
31 | 31 |
32 DISALLOW_COPY_AND_ASSIGN(ContentsView); | 32 DISALLOW_COPY_AND_ASSIGN(ContentsView); |
33 }; | 33 }; |
34 | 34 |
35 ContentsView::ContentsView(MessageCenterBubble* bubble, views::View* contents) | 35 ContentsView::ContentsView(MessageCenterBubble* bubble, views::View* contents) |
36 : bubble_(bubble->AsWeakPtr()) { | 36 : bubble_(bubble->AsWeakPtr()) { |
37 SetLayoutManager(new views::FillLayout()); | 37 SetLayoutManager(new views::FillLayout()); |
38 AddChildView(contents); | 38 AddChildView(contents); |
39 } | 39 } |
40 | 40 |
41 ContentsView::~ContentsView() { | 41 ContentsView::~ContentsView() { |
42 } | 42 } |
43 | 43 |
44 int ContentsView::GetHeightForWidth(int width) { | 44 int ContentsView::GetHeightForWidth(int width) const { |
45 DCHECK_EQ(1, child_count()); | 45 DCHECK_EQ(1, child_count()); |
46 int contents_width = std::max(width - GetInsets().width(), 0); | 46 int contents_width = std::max(width - GetInsets().width(), 0); |
47 int contents_height = child_at(0)->GetHeightForWidth(contents_width); | 47 int contents_height = child_at(0)->GetHeightForWidth(contents_width); |
48 return contents_height + GetInsets().height(); | 48 return contents_height + GetInsets().height(); |
49 } | 49 } |
50 | 50 |
51 void ContentsView::ChildPreferredSizeChanged(View* child) { | 51 void ContentsView::ChildPreferredSizeChanged(View* child) { |
52 // TODO(dharcourt): Reduce the amount of updating this requires. | 52 // TODO(dharcourt): Reduce the amount of updating this requires. |
53 if (bubble_.get()) | 53 if (bubble_.get()) |
54 bubble_->bubble_view()->UpdateBubble(); | 54 bubble_->bubble_view()->UpdateBubble(); |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 } | 130 } |
131 | 131 |
132 void MessageCenterBubble::OnMouseExitedView() { | 132 void MessageCenterBubble::OnMouseExitedView() { |
133 } | 133 } |
134 | 134 |
135 size_t MessageCenterBubble::NumMessageViewsForTest() const { | 135 size_t MessageCenterBubble::NumMessageViewsForTest() const { |
136 return message_center_view_->NumMessageViewsForTest(); | 136 return message_center_view_->NumMessageViewsForTest(); |
137 } | 137 } |
138 | 138 |
139 } // namespace message_center | 139 } // namespace message_center |
OLD | NEW |