OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 "ash/system/tray/special_popup_row.h" | 5 #include "ash/system/tray/special_popup_row.h" |
6 | 6 |
7 #include "ash/system/tray/hover_highlight_view.h" | 7 #include "ash/system/tray/hover_highlight_view.h" |
8 #include "ash/system/tray/throbber_view.h" | 8 #include "ash/system/tray/throbber_view.h" |
9 #include "ash/system/tray/tray_constants.h" | 9 #include "ash/system/tray/tray_constants.h" |
10 #include "ash/system/tray/tray_popup_header_button.h" | 10 #include "ash/system/tray/tray_popup_header_button.h" |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 } | 89 } |
90 | 90 |
91 void SpecialPopupRow::AddThrobber(ThrobberView* throbber) { | 91 void SpecialPopupRow::AddThrobber(ThrobberView* throbber) { |
92 if (!button_container_) { | 92 if (!button_container_) { |
93 button_container_ = CreatePopupHeaderButtonsContainer(); | 93 button_container_ = CreatePopupHeaderButtonsContainer(); |
94 AddChildView(button_container_); | 94 AddChildView(button_container_); |
95 } | 95 } |
96 button_container_->AddChildView(throbber); | 96 button_container_->AddChildView(throbber); |
97 } | 97 } |
98 | 98 |
99 gfx::Size SpecialPopupRow::GetPreferredSize() { | 99 gfx::Size SpecialPopupRow::GetPreferredSize() const { |
100 gfx::Size size = views::View::GetPreferredSize(); | 100 gfx::Size size = views::View::GetPreferredSize(); |
101 size.set_height(kSpecialPopupRowHeight); | 101 size.set_height(kSpecialPopupRowHeight); |
102 return size; | 102 return size; |
103 } | 103 } |
104 | 104 |
105 int SpecialPopupRow::GetHeightForWidth(int width) { | 105 int SpecialPopupRow::GetHeightForWidth(int width) const { |
106 return kSpecialPopupRowHeight; | 106 return kSpecialPopupRowHeight; |
107 } | 107 } |
108 | 108 |
109 void SpecialPopupRow::Layout() { | 109 void SpecialPopupRow::Layout() { |
110 views::View::Layout(); | 110 views::View::Layout(); |
111 gfx::Rect content_bounds = GetContentsBounds(); | 111 gfx::Rect content_bounds = GetContentsBounds(); |
112 if (content_bounds.IsEmpty()) | 112 if (content_bounds.IsEmpty()) |
113 return; | 113 return; |
114 if (!button_container_) { | 114 if (!button_container_) { |
115 content_->SetBoundsRect(GetContentsBounds()); | 115 content_->SetBoundsRect(GetContentsBounds()); |
116 return; | 116 return; |
117 } | 117 } |
118 | 118 |
119 gfx::Rect bounds(button_container_->GetPreferredSize()); | 119 gfx::Rect bounds(button_container_->GetPreferredSize()); |
120 bounds.set_height(content_bounds.height()); | 120 bounds.set_height(content_bounds.height()); |
121 gfx::Rect container_bounds = content_bounds; | 121 gfx::Rect container_bounds = content_bounds; |
122 container_bounds.ClampToCenteredSize(bounds.size()); | 122 container_bounds.ClampToCenteredSize(bounds.size()); |
123 container_bounds.set_x(content_bounds.width() - container_bounds.width()); | 123 container_bounds.set_x(content_bounds.width() - container_bounds.width()); |
124 button_container_->SetBoundsRect(container_bounds); | 124 button_container_->SetBoundsRect(container_bounds); |
125 | 125 |
126 bounds = content_->bounds(); | 126 bounds = content_->bounds(); |
127 bounds.set_width(button_container_->x()); | 127 bounds.set_width(button_container_->x()); |
128 content_->SetBoundsRect(bounds); | 128 content_->SetBoundsRect(bounds); |
129 } | 129 } |
130 | 130 |
131 } // namespace ash | 131 } // namespace ash |
OLD | NEW |