| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "views/examples/single_split_view_example.h" | |
| 6 | |
| 7 #include "views/controls/single_split_view.h" | |
| 8 #include "views/layout/grid_layout.h" | |
| 9 | |
| 10 namespace { | |
| 11 | |
| 12 // SingleSplitView's content, which draws gradient color on background. | |
| 13 class SplittedView : public views::View { | |
| 14 public: | |
| 15 SplittedView(); | |
| 16 virtual ~SplittedView(); | |
| 17 | |
| 18 void SetColor(SkColor from, SkColor to); | |
| 19 | |
| 20 private: | |
| 21 // Overridden from views::View: | |
| 22 virtual gfx::Size GetPreferredSize() OVERRIDE; | |
| 23 virtual gfx::Size GetMinimumSize() OVERRIDE; | |
| 24 virtual void Layout() OVERRIDE; | |
| 25 | |
| 26 DISALLOW_COPY_AND_ASSIGN(SplittedView); | |
| 27 }; | |
| 28 | |
| 29 SplittedView::SplittedView() { | |
| 30 SetColor(SK_ColorRED, SK_ColorGREEN); | |
| 31 } | |
| 32 | |
| 33 SplittedView::~SplittedView() { | |
| 34 } | |
| 35 | |
| 36 void SplittedView::SetColor(SkColor from, SkColor to) { | |
| 37 set_background(views::Background::CreateVerticalGradientBackground(from, to)); | |
| 38 } | |
| 39 | |
| 40 gfx::Size SplittedView::GetPreferredSize() { | |
| 41 return gfx::Size(width(), height()); | |
| 42 } | |
| 43 | |
| 44 gfx::Size SplittedView::GetMinimumSize() { | |
| 45 return gfx::Size(10, 10); | |
| 46 } | |
| 47 | |
| 48 void SplittedView::Layout() { | |
| 49 SizeToPreferredSize(); | |
| 50 } | |
| 51 | |
| 52 } // namespace | |
| 53 | |
| 54 namespace examples { | |
| 55 | |
| 56 SingleSplitViewExample::SingleSplitViewExample(ExamplesMain* main) | |
| 57 : ExampleBase(main, "Single Split View") { | |
| 58 } | |
| 59 | |
| 60 SingleSplitViewExample::~SingleSplitViewExample() { | |
| 61 } | |
| 62 | |
| 63 void SingleSplitViewExample::CreateExampleView(views::View* container) { | |
| 64 SplittedView* splitted_view_1 = new SplittedView; | |
| 65 SplittedView* splitted_view_2 = new SplittedView; | |
| 66 | |
| 67 splitted_view_1->SetColor(SK_ColorYELLOW, SK_ColorCYAN); | |
| 68 | |
| 69 single_split_view_ = new views::SingleSplitView( | |
| 70 splitted_view_1, splitted_view_2, | |
| 71 views::SingleSplitView::HORIZONTAL_SPLIT, | |
| 72 this); | |
| 73 | |
| 74 views::GridLayout* layout = new views::GridLayout(container); | |
| 75 container->SetLayoutManager(layout); | |
| 76 | |
| 77 views::ColumnSet* column_set = layout->AddColumnSet(0); | |
| 78 column_set->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL, 1, | |
| 79 views::GridLayout::USE_PREF, 0, 0); | |
| 80 layout->StartRow(1, 0); | |
| 81 layout->AddView(single_split_view_); | |
| 82 } | |
| 83 | |
| 84 bool SingleSplitViewExample::SplitHandleMoved(views::SingleSplitView* sender) { | |
| 85 PrintStatus("Splitter moved"); | |
| 86 return true; | |
| 87 } | |
| 88 | |
| 89 } // namespace examples | |
| OLD | NEW |