| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "views/examples/scroll_view_example.h" | 5 #include "views/examples/scroll_view_example.h" |
| 6 | 6 |
| 7 #include "base/stringprintf.h" | 7 #include "base/stringprintf.h" |
| 8 #include "views/controls/button/radio_button.h" | 8 #include "views/controls/button/radio_button.h" |
| 9 #include "views/layout/grid_layout.h" | 9 #include "views/layout/grid_layout.h" |
| 10 #include "views/view.h" | 10 #include "views/view.h" |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 virtual gfx::Size GetPreferredSize() { | 24 virtual gfx::Size GetPreferredSize() { |
| 25 return gfx::Size(width(), height()); | 25 return gfx::Size(width(), height()); |
| 26 } | 26 } |
| 27 | 27 |
| 28 void SetColor(SkColor from, SkColor to) { | 28 void SetColor(SkColor from, SkColor to) { |
| 29 set_background( | 29 set_background( |
| 30 views::Background::CreateVerticalGradientBackground(from, to)); | 30 views::Background::CreateVerticalGradientBackground(from, to)); |
| 31 } | 31 } |
| 32 | 32 |
| 33 void PlaceChildY(int index, int y) { | 33 void PlaceChildY(int index, int y) { |
| 34 views::View* view = GetChildViewAt(index); | 34 views::View* view = child_at(index); |
| 35 gfx::Size size = view->GetPreferredSize(); | 35 gfx::Size size = view->GetPreferredSize(); |
| 36 view->SetBounds(0, y, size.width(), size.height()); | 36 view->SetBounds(0, y, size.width(), size.height()); |
| 37 } | 37 } |
| 38 | 38 |
| 39 virtual void Layout() { | 39 virtual void Layout() { |
| 40 PlaceChildY(0, 0); | 40 PlaceChildY(0, 0); |
| 41 PlaceChildY(1, height() / 2); | 41 PlaceChildY(1, height() / 2); |
| 42 SizeToPreferredSize(); | 42 SizeToPreferredSize(); |
| 43 } | 43 } |
| 44 | 44 |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 scrollable_->SetBounds(0, 0, 100, 100); | 108 scrollable_->SetBounds(0, 0, 100, 100); |
| 109 scrollable_->SetColor(SK_ColorYELLOW, SK_ColorGREEN); | 109 scrollable_->SetColor(SK_ColorYELLOW, SK_ColorGREEN); |
| 110 } else if (sender == scroll_to_) { | 110 } else if (sender == scroll_to_) { |
| 111 scroll_view_->ScrollContentsRegionToBeVisible( | 111 scroll_view_->ScrollContentsRegionToBeVisible( |
| 112 gfx::Rect(20, 500, 1000, 500)); | 112 gfx::Rect(20, 500, 1000, 500)); |
| 113 } | 113 } |
| 114 scroll_view_->Layout(); | 114 scroll_view_->Layout(); |
| 115 } | 115 } |
| 116 | 116 |
| 117 } // namespace examples | 117 } // namespace examples |
| OLD | NEW |