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.
5 #include "ui/views/examples/double_split_view_example.h"
7 #include "ui/views/background.h"
8 #include "ui/views/controls/single_split_view.h"
9 #include "ui/views/layout/grid_layout.h"
16 // DoubleSplitViews's content, which draws gradient color on background.
17 class SplittedView
: public View
{
20 ~SplittedView() override
;
22 void SetColor(SkColor from
, SkColor to
);
25 gfx::Size
GetMinimumSize() const override
;
28 DISALLOW_COPY_AND_ASSIGN(SplittedView
);
31 SplittedView::SplittedView() {
32 SetColor(SK_ColorRED
, SK_ColorGREEN
);
35 SplittedView::~SplittedView() {
38 void SplittedView::SetColor(SkColor from
, SkColor to
) {
39 set_background(Background::CreateVerticalGradientBackground(from
, to
));
42 gfx::Size
SplittedView::GetMinimumSize() const {
43 return gfx::Size(10, 10);
48 DoubleSplitViewExample::DoubleSplitViewExample()
49 : ExampleBase("Double Split View") {
52 DoubleSplitViewExample::~DoubleSplitViewExample() {
55 void DoubleSplitViewExample::CreateExampleView(View
* container
) {
56 SplittedView
* splitted_view_1
= new SplittedView();
57 SplittedView
* splitted_view_2
= new SplittedView();
58 SplittedView
* splitted_view_3
= new SplittedView();
60 inner_single_split_view_
= new SingleSplitView(
61 splitted_view_1
, splitted_view_2
,
62 SingleSplitView::HORIZONTAL_SPLIT
,
65 outer_single_split_view_
= new SingleSplitView(
66 inner_single_split_view_
, splitted_view_3
,
67 SingleSplitView::HORIZONTAL_SPLIT
,
70 GridLayout
* layout
= new GridLayout(container
);
71 container
->SetLayoutManager(layout
);
74 ColumnSet
* column_set
= layout
->AddColumnSet(0);
75 column_set
->AddColumn(GridLayout::FILL
, GridLayout::FILL
, 1,
76 GridLayout::USE_PREF
, 0, 0);
77 layout
->StartRow(1, 0);
78 layout
->AddView(outer_single_split_view_
);
81 } // namespace examples