OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #include "ui/views/examples/double_split_view_example.h" | |
6 | |
7 #include "base/macros.h" | |
8 #include "ui/views/background.h" | |
9 #include "ui/views/controls/single_split_view.h" | |
10 #include "ui/views/layout/grid_layout.h" | |
11 | |
12 namespace views { | |
13 namespace examples { | |
14 | |
15 namespace { | |
16 | |
17 // DoubleSplitViews's content, which draws gradient color on background. | |
18 class SplittedView : public View { | |
19 public: | |
20 SplittedView(); | |
21 ~SplittedView() override; | |
22 | |
23 void SetColor(SkColor from, SkColor to); | |
24 | |
25 // View: | |
26 gfx::Size GetMinimumSize() const override; | |
27 | |
28 private: | |
29 DISALLOW_COPY_AND_ASSIGN(SplittedView); | |
30 }; | |
31 | |
32 SplittedView::SplittedView() { | |
33 SetColor(SK_ColorRED, SK_ColorGREEN); | |
34 } | |
35 | |
36 SplittedView::~SplittedView() { | |
37 } | |
38 | |
39 void SplittedView::SetColor(SkColor from, SkColor to) { | |
40 set_background(Background::CreateVerticalGradientBackground(from, to)); | |
41 } | |
42 | |
43 gfx::Size SplittedView::GetMinimumSize() const { | |
44 return gfx::Size(10, 10); | |
45 } | |
46 | |
47 } // namespace | |
48 | |
49 DoubleSplitViewExample::DoubleSplitViewExample() | |
50 : ExampleBase("Double Split View") { | |
51 } | |
52 | |
53 DoubleSplitViewExample::~DoubleSplitViewExample() { | |
54 } | |
55 | |
56 void DoubleSplitViewExample::CreateExampleView(View* container) { | |
57 SplittedView* splitted_view_1 = new SplittedView(); | |
58 SplittedView* splitted_view_2 = new SplittedView(); | |
59 SplittedView* splitted_view_3 = new SplittedView(); | |
60 | |
61 inner_single_split_view_ = new SingleSplitView( | |
62 splitted_view_1, splitted_view_2, | |
63 SingleSplitView::HORIZONTAL_SPLIT, | |
64 NULL); | |
65 | |
66 outer_single_split_view_ = new SingleSplitView( | |
67 inner_single_split_view_, splitted_view_3, | |
68 SingleSplitView::HORIZONTAL_SPLIT, | |
69 NULL); | |
70 | |
71 GridLayout* layout = new GridLayout(container); | |
72 container->SetLayoutManager(layout); | |
73 | |
74 // Add scroll view. | |
75 ColumnSet* column_set = layout->AddColumnSet(0); | |
76 column_set->AddColumn(GridLayout::FILL, GridLayout::FILL, 1, | |
77 GridLayout::USE_PREF, 0, 0); | |
78 layout->StartRow(1, 0); | |
79 layout->AddView(outer_single_split_view_); | |
80 } | |
81 | |
82 } // namespace examples | |
83 } // namespace views | |
OLD | NEW |