Updating trunk VERSION from 2139.0 to 2140.0
[chromium-blink-merge.git] / ui / views / examples / double_split_view_example.cc
blob8ff40df66a8541e644936d83612a6a184d10346a
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"
11 namespace views {
12 namespace examples {
14 namespace {
16 // DoubleSplitViews's content, which draws gradient color on background.
17 class SplittedView : public View {
18 public:
19 SplittedView();
20 virtual ~SplittedView();
22 void SetColor(SkColor from, SkColor to);
24 // View:
25 virtual gfx::Size GetMinimumSize() const OVERRIDE;
27 private:
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);
46 } // namespace
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,
63 NULL);
65 outer_single_split_view_ = new SingleSplitView(
66 inner_single_split_view_, splitted_view_3,
67 SingleSplitView::HORIZONTAL_SPLIT,
68 NULL);
70 GridLayout* layout = new GridLayout(container);
71 container->SetLayoutManager(layout);
73 // Add scroll view.
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
82 } // namespace views