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 "ash/system/tray/tray_details_view.h" | 5 #include "ash/system/tray/tray_details_view.h" |
6 | 6 |
7 #include "ash/system/tray/fixed_sized_scroll_view.h" | 7 #include "ash/system/tray/fixed_sized_scroll_view.h" |
8 #include "ash/system/tray/system_tray.h" | 8 #include "ash/system/tray/system_tray.h" |
9 #include "ash/system/tray/system_tray_item.h" | 9 #include "ash/system/tray/system_tray_item.h" |
10 #include "ash/system/tray/tray_constants.h" | 10 #include "ash/system/tray/tray_constants.h" |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 // Cache pointer to owner in this function scope. TrayDetailsView will be | 119 // Cache pointer to owner in this function scope. TrayDetailsView will be |
120 // deleted after called ShowDefaultView. | 120 // deleted after called ShowDefaultView. |
121 SystemTrayItem* owner = owner_; | 121 SystemTrayItem* owner = owner_; |
122 if (footer_ && footer_->content() && footer_->content()->HasFocus()) | 122 if (footer_ && footer_->content() && footer_->content()->HasFocus()) |
123 owner->set_restore_focus(true); | 123 owner->set_restore_focus(true); |
124 owner->system_tray()->ShowDefaultView(BUBBLE_USE_EXISTING); | 124 owner->system_tray()->ShowDefaultView(BUBBLE_USE_EXISTING); |
125 owner->set_restore_focus(false); | 125 owner->set_restore_focus(false); |
126 } | 126 } |
127 | 127 |
128 void TrayDetailsView::Layout() { | 128 void TrayDetailsView::Layout() { |
129 if (!scroller_ || !footer_ || bounds().IsEmpty()) { | 129 if (bounds().IsEmpty()) { |
130 views::View::Layout(); | 130 views::View::Layout(); |
131 return; | 131 return; |
132 } | 132 } |
133 | 133 |
134 scroller_->set_fixed_size(gfx::Size()); | 134 if (scroller_) { |
135 gfx::Size size = GetPreferredSize(); | 135 scroller_->set_fixed_size(gfx::Size()); |
| 136 gfx::Size size = GetPreferredSize(); |
136 | 137 |
137 // Set the scroller to fill the space above the bottom row, so that the | 138 // Set the scroller to fill the space above the bottom row, so that the |
138 // bottom row of the detailed view will always stay just above the footer. | 139 // bottom row of the detailed view will always stay just above the footer. |
139 gfx::Size scroller_size = scroll_content_->GetPreferredSize(); | 140 gfx::Size scroller_size = scroll_content_->GetPreferredSize(); |
140 scroller_->set_fixed_size(gfx::Size( | 141 scroller_->set_fixed_size( |
141 width() + scroller_->GetScrollBarWidth(), | 142 gfx::Size(width() + scroller_->GetScrollBarWidth(), |
142 scroller_size.height() - (size.height() - height()))); | 143 scroller_size.height() - (size.height() - height()))); |
| 144 } |
143 | 145 |
144 views::View::Layout(); | 146 views::View::Layout(); |
145 // Always make sure the footer element is bottom aligned. | 147 |
146 gfx::Rect fbounds = footer_->bounds(); | 148 if (footer_) { |
147 fbounds.set_y(height() - footer_->height()); | 149 // Always make sure the footer element is bottom aligned. |
148 footer_->SetBoundsRect(fbounds); | 150 gfx::Rect fbounds = footer_->bounds(); |
| 151 fbounds.set_y(height() - footer_->height()); |
| 152 footer_->SetBoundsRect(fbounds); |
| 153 } |
149 } | 154 } |
150 | 155 |
151 void TrayDetailsView::OnPaintBorder(gfx::Canvas* canvas) { | 156 void TrayDetailsView::OnPaintBorder(gfx::Canvas* canvas) { |
152 if (scroll_border_) { | 157 if (scroll_border_) { |
153 int index = GetIndexOf(scroller_); | 158 int index = GetIndexOf(scroller_); |
154 if (index < child_count() - 1 && child_at(index + 1) != footer_) | 159 if (index < child_count() - 1 && child_at(index + 1) != footer_) |
155 scroll_border_->set_visible(true); | 160 scroll_border_->set_visible(true); |
156 else | 161 else |
157 scroll_border_->set_visible(false); | 162 scroll_border_->set_visible(false); |
158 } | 163 } |
159 | 164 |
160 views::View::OnPaintBorder(canvas); | 165 views::View::OnPaintBorder(canvas); |
161 } | 166 } |
162 | 167 |
163 } // namespace ash | 168 } // namespace ash |
OLD | NEW |