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