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_views.h" | 5 #include "ash/system/tray/tray_views.h" |
6 | 6 |
7 #include "ash/system/tray/tray_constants.h" | 7 #include "ash/system/tray/tray_constants.h" |
8 #include "third_party/skia/include/core/SkBitmap.h" | 8 #include "third_party/skia/include/core/SkBitmap.h" |
9 #include "grit/ash_strings.h" | 9 #include "grit/ash_strings.h" |
10 #include "grit/ui_resources.h" | 10 #include "grit/ui_resources.h" |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
200 } | 200 } |
201 | 201 |
202 FixedSizedScrollView::~FixedSizedScrollView() {} | 202 FixedSizedScrollView::~FixedSizedScrollView() {} |
203 | 203 |
204 void FixedSizedScrollView::SetContentsView(View* view) { | 204 void FixedSizedScrollView::SetContentsView(View* view) { |
205 SetContents(view); | 205 SetContents(view); |
206 view->SetBoundsRect(gfx::Rect(view->GetPreferredSize())); | 206 view->SetBoundsRect(gfx::Rect(view->GetPreferredSize())); |
207 } | 207 } |
208 | 208 |
209 gfx::Size FixedSizedScrollView::GetPreferredSize() { | 209 gfx::Size FixedSizedScrollView::GetPreferredSize() { |
210 return fixed_size_; | 210 return fixed_size_.IsEmpty() ? GetContents()->GetPreferredSize() : |
| 211 fixed_size_; |
211 } | 212 } |
212 | 213 |
213 void FixedSizedScrollView::Layout() { | 214 void FixedSizedScrollView::Layout() { |
214 views::View* contents = GetContents(); | 215 views::View* contents = GetContents(); |
215 gfx::Rect bounds = gfx::Rect(contents->GetPreferredSize()); | 216 gfx::Rect bounds = gfx::Rect(contents->GetPreferredSize()); |
216 bounds.set_width(std::max(0, width() - GetScrollBarWidth())); | 217 bounds.set_width(std::max(0, width() - GetScrollBarWidth())); |
217 contents->SetBoundsRect(bounds); | 218 contents->SetBoundsRect(bounds); |
218 | 219 |
219 views::ScrollView::Layout(); | 220 views::ScrollView::Layout(); |
| 221 if (!vertical_scroll_bar()->visible()) { |
| 222 gfx::Rect bounds = contents->bounds(); |
| 223 bounds.set_width(bounds.width() + GetScrollBarWidth()); |
| 224 contents->SetBoundsRect(bounds); |
| 225 } |
220 } | 226 } |
221 | 227 |
222 void FixedSizedScrollView::OnBoundsChanged(const gfx::Rect& previous_bounds) { | 228 void FixedSizedScrollView::OnBoundsChanged(const gfx::Rect& previous_bounds) { |
223 views::View* contents = GetContents(); | 229 views::View* contents = GetContents(); |
224 gfx::Rect bounds = gfx::Rect(contents->GetPreferredSize()); | 230 gfx::Rect bounds = gfx::Rect(contents->GetPreferredSize()); |
225 bounds.set_width(std::max(0, width() - GetScrollBarWidth())); | 231 bounds.set_width(std::max(0, width() - GetScrollBarWidth())); |
226 contents->SetBoundsRect(bounds); | 232 contents->SetBoundsRect(bounds); |
227 } | 233 } |
228 | 234 |
229 void FixedSizedScrollView::OnMouseEntered(const views::MouseEvent& event) { | 235 void FixedSizedScrollView::OnMouseEntered(const views::MouseEvent& event) { |
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
493 TrayNotificationView::~TrayNotificationView() { | 499 TrayNotificationView::~TrayNotificationView() { |
494 } | 500 } |
495 | 501 |
496 void TrayNotificationView::ButtonPressed(views::Button* sender, | 502 void TrayNotificationView::ButtonPressed(views::Button* sender, |
497 const views::Event& event) { | 503 const views::Event& event) { |
498 OnClose(); | 504 OnClose(); |
499 } | 505 } |
500 | 506 |
501 } // namespace internal | 507 } // namespace internal |
502 } // namespace ash | 508 } // namespace ash |
OLD | NEW |