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 "ui/views/examples/double_split_view_example.h" | 5 #include "ui/views/examples/double_split_view_example.h" |
6 | 6 |
7 #include "ui/views/controls/single_split_view.h" | 7 #include "ui/views/controls/single_split_view.h" |
8 #include "ui/views/layout/grid_layout.h" | 8 #include "ui/views/layout/grid_layout.h" |
9 | 9 |
| 10 namespace views { |
| 11 namespace examples { |
| 12 |
10 namespace { | 13 namespace { |
11 | 14 |
12 // DoubleSplitViews's content, which draws gradient color on background. | 15 // DoubleSplitViews's content, which draws gradient color on background. |
13 class SplittedView : public views::View { | 16 class SplittedView : public View { |
14 public: | 17 public: |
15 SplittedView(); | 18 SplittedView(); |
16 virtual ~SplittedView(); | 19 virtual ~SplittedView(); |
17 | 20 |
18 void SetColor(SkColor from, SkColor to); | 21 void SetColor(SkColor from, SkColor to); |
19 | 22 |
20 // Overridden from views::View. | 23 // Overridden from View. |
21 virtual gfx::Size GetMinimumSize() OVERRIDE; | 24 virtual gfx::Size GetMinimumSize() OVERRIDE; |
22 | 25 |
23 private: | 26 private: |
24 DISALLOW_COPY_AND_ASSIGN(SplittedView); | 27 DISALLOW_COPY_AND_ASSIGN(SplittedView); |
25 }; | 28 }; |
26 | 29 |
27 SplittedView::SplittedView() { | 30 SplittedView::SplittedView() { |
28 SetColor(SK_ColorRED, SK_ColorGREEN); | 31 SetColor(SK_ColorRED, SK_ColorGREEN); |
29 } | 32 } |
30 | 33 |
31 SplittedView::~SplittedView() { | 34 SplittedView::~SplittedView() { |
32 } | 35 } |
33 | 36 |
34 void SplittedView::SetColor(SkColor from, SkColor to) { | 37 void SplittedView::SetColor(SkColor from, SkColor to) { |
35 set_background( | 38 set_background(Background::CreateVerticalGradientBackground(from, to)); |
36 views::Background::CreateVerticalGradientBackground(from, to)); | |
37 } | 39 } |
38 | 40 |
39 gfx::Size SplittedView::GetMinimumSize() { | 41 gfx::Size SplittedView::GetMinimumSize() { |
40 return gfx::Size(10, 10); | 42 return gfx::Size(10, 10); |
41 } | 43 } |
42 | 44 |
43 } // namespace | 45 } // namespace |
44 | 46 |
45 namespace views { | |
46 namespace examples { | |
47 | |
48 DoubleSplitViewExample::DoubleSplitViewExample() | 47 DoubleSplitViewExample::DoubleSplitViewExample() |
49 : ExampleBase("Double Split View") { | 48 : ExampleBase("Double Split View") { |
50 } | 49 } |
51 | 50 |
52 DoubleSplitViewExample::~DoubleSplitViewExample() { | 51 DoubleSplitViewExample::~DoubleSplitViewExample() { |
53 } | 52 } |
54 | 53 |
55 void DoubleSplitViewExample::CreateExampleView(View* container) { | 54 void DoubleSplitViewExample::CreateExampleView(View* container) { |
56 SplittedView* splitted_view_1 = new SplittedView(); | 55 SplittedView* splitted_view_1 = new SplittedView(); |
57 SplittedView* splitted_view_2 = new SplittedView(); | 56 SplittedView* splitted_view_2 = new SplittedView(); |
(...skipping 15 matching lines...) Expand all Loading... |
73 // Add scroll view. | 72 // Add scroll view. |
74 ColumnSet* column_set = layout->AddColumnSet(0); | 73 ColumnSet* column_set = layout->AddColumnSet(0); |
75 column_set->AddColumn(GridLayout::FILL, GridLayout::FILL, 1, | 74 column_set->AddColumn(GridLayout::FILL, GridLayout::FILL, 1, |
76 GridLayout::USE_PREF, 0, 0); | 75 GridLayout::USE_PREF, 0, 0); |
77 layout->StartRow(1, 0); | 76 layout->StartRow(1, 0); |
78 layout->AddView(outer_single_split_view_); | 77 layout->AddView(outer_single_split_view_); |
79 } | 78 } |
80 | 79 |
81 } // namespace examples | 80 } // namespace examples |
82 } // namespace views | 81 } // namespace views |
OLD | NEW |