| 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 "ui/views/background.h" | |
| 8 #include "ui/views/controls/single_split_view.h" | |
| 9 #include "ui/views/layout/grid_layout.h" | |
| 10 | |
| 11 namespace views { | |
| 12 namespace examples { | |
| 13 | |
| 14 namespace { | |
| 15 | |
| 16 // DoubleSplitViews's content, which draws gradient color on background. | |
| 17 class SplittedView : public View { | |
| 18 public: | |
| 19 SplittedView(); | |
| 20 virtual ~SplittedView(); | |
| 21 | |
| 22 void SetColor(SkColor from, SkColor to); | |
| 23 | |
| 24 // View: | |
| 25 virtual gfx::Size GetMinimumSize() const override; | |
| 26 | |
| 27 private: | |
| 28 DISALLOW_COPY_AND_ASSIGN(SplittedView); | |
| 29 }; | |
| 30 | |
| 31 SplittedView::SplittedView() { | |
| 32 SetColor(SK_ColorRED, SK_ColorGREEN); | |
| 33 } | |
| 34 | |
| 35 SplittedView::~SplittedView() { | |
| 36 } | |
| 37 | |
| 38 void SplittedView::SetColor(SkColor from, SkColor to) { | |
| 39 set_background(Background::CreateVerticalGradientBackground(from, to)); | |
| 40 } | |
| 41 | |
| 42 gfx::Size SplittedView::GetMinimumSize() const { | |
| 43 return gfx::Size(10, 10); | |
| 44 } | |
| 45 | |
| 46 } // namespace | |
| 47 | |
| 48 DoubleSplitViewExample::DoubleSplitViewExample() | |
| 49 : ExampleBase("Double Split View") { | |
| 50 } | |
| 51 | |
| 52 DoubleSplitViewExample::~DoubleSplitViewExample() { | |
| 53 } | |
| 54 | |
| 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(); | |
| 59 | |
| 60 inner_single_split_view_ = new SingleSplitView( | |
| 61 splitted_view_1, splitted_view_2, | |
| 62 SingleSplitView::HORIZONTAL_SPLIT, | |
| 63 NULL); | |
| 64 | |
| 65 outer_single_split_view_ = new SingleSplitView( | |
| 66 inner_single_split_view_, splitted_view_3, | |
| 67 SingleSplitView::HORIZONTAL_SPLIT, | |
| 68 NULL); | |
| 69 | |
| 70 GridLayout* layout = new GridLayout(container); | |
| 71 container->SetLayoutManager(layout); | |
| 72 | |
| 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_); | |
| 79 } | |
| 80 | |
| 81 } // namespace examples | |
| 82 } // namespace views | |
| OLD | NEW |