Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(72)

Side by Side Diff: ui/views/examples/single_split_view_example.cc

Issue 8687013: Get the examples to run in aura_shell. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ui/views/examples/single_split_view_example.h ('k') | ui/views/examples/tabbed_pane_example.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/views/examples/single_split_view_example.h" 5 #include "ui/views/examples/single_split_view_example.h"
6 6
7 #include "ui/views/layout/grid_layout.h" 7 #include "ui/views/layout/grid_layout.h"
8 #include "views/controls/single_split_view.h" 8 #include "views/controls/single_split_view.h"
9 9
10 namespace views {
11 namespace examples {
10 namespace { 12 namespace {
11 13
12 // SingleSplitView's content, which draws gradient color on background. 14 // SingleSplitView's content, which draws gradient color on background.
13 class SplittedView : public views::View { 15 class SplittedView : public View {
14 public: 16 public:
15 SplittedView(); 17 SplittedView();
16 virtual ~SplittedView(); 18 virtual ~SplittedView();
17 19
18 void SetColor(SkColor from, SkColor to); 20 void SetColor(SkColor from, SkColor to);
19 21
20 private: 22 private:
21 // Overridden from views::View: 23 // Overridden from View:
22 virtual gfx::Size GetPreferredSize() OVERRIDE; 24 virtual gfx::Size GetPreferredSize() OVERRIDE;
23 virtual gfx::Size GetMinimumSize() OVERRIDE; 25 virtual gfx::Size GetMinimumSize() OVERRIDE;
24 virtual void Layout() OVERRIDE; 26 virtual void Layout() OVERRIDE;
25 27
26 DISALLOW_COPY_AND_ASSIGN(SplittedView); 28 DISALLOW_COPY_AND_ASSIGN(SplittedView);
27 }; 29 };
28 30
29 SplittedView::SplittedView() { 31 SplittedView::SplittedView() {
30 SetColor(SK_ColorRED, SK_ColorGREEN); 32 SetColor(SK_ColorRED, SK_ColorGREEN);
31 } 33 }
32 34
33 SplittedView::~SplittedView() { 35 SplittedView::~SplittedView() {
34 } 36 }
35 37
36 void SplittedView::SetColor(SkColor from, SkColor to) { 38 void SplittedView::SetColor(SkColor from, SkColor to) {
37 set_background(views::Background::CreateVerticalGradientBackground(from, to)); 39 set_background(Background::CreateVerticalGradientBackground(from, to));
38 } 40 }
39 41
40 gfx::Size SplittedView::GetPreferredSize() { 42 gfx::Size SplittedView::GetPreferredSize() {
41 return gfx::Size(width(), height()); 43 return gfx::Size(width(), height());
42 } 44 }
43 45
44 gfx::Size SplittedView::GetMinimumSize() { 46 gfx::Size SplittedView::GetMinimumSize() {
45 return gfx::Size(10, 10); 47 return gfx::Size(10, 10);
46 } 48 }
47 49
48 void SplittedView::Layout() { 50 void SplittedView::Layout() {
49 SizeToPreferredSize(); 51 SizeToPreferredSize();
50 } 52 }
51 53
52 } // namespace 54 } // namespace
53 55
54 namespace examples { 56 SingleSplitViewExample::SingleSplitViewExample()
55 57 : ExampleBase("Single Split View") {
56 SingleSplitViewExample::SingleSplitViewExample(ExamplesMain* main)
57 : ExampleBase(main, "Single Split View") {
58 } 58 }
59 59
60 SingleSplitViewExample::~SingleSplitViewExample() { 60 SingleSplitViewExample::~SingleSplitViewExample() {
61 } 61 }
62 62
63 void SingleSplitViewExample::CreateExampleView(views::View* container) { 63 void SingleSplitViewExample::CreateExampleView(View* container) {
64 SplittedView* splitted_view_1 = new SplittedView; 64 SplittedView* splitted_view_1 = new SplittedView;
65 SplittedView* splitted_view_2 = new SplittedView; 65 SplittedView* splitted_view_2 = new SplittedView;
66 66
67 splitted_view_1->SetColor(SK_ColorYELLOW, SK_ColorCYAN); 67 splitted_view_1->SetColor(SK_ColorYELLOW, SK_ColorCYAN);
68 68
69 single_split_view_ = new views::SingleSplitView( 69 single_split_view_ = new SingleSplitView(
70 splitted_view_1, splitted_view_2, 70 splitted_view_1, splitted_view_2,
71 views::SingleSplitView::HORIZONTAL_SPLIT, 71 SingleSplitView::HORIZONTAL_SPLIT,
72 this); 72 this);
73 73
74 views::GridLayout* layout = new views::GridLayout(container); 74 GridLayout* layout = new GridLayout(container);
75 container->SetLayoutManager(layout); 75 container->SetLayoutManager(layout);
76 76
77 views::ColumnSet* column_set = layout->AddColumnSet(0); 77 ColumnSet* column_set = layout->AddColumnSet(0);
78 column_set->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL, 1, 78 column_set->AddColumn(GridLayout::FILL, GridLayout::FILL, 1,
79 views::GridLayout::USE_PREF, 0, 0); 79 GridLayout::USE_PREF, 0, 0);
80 layout->StartRow(1, 0); 80 layout->StartRow(1, 0);
81 layout->AddView(single_split_view_); 81 layout->AddView(single_split_view_);
82 } 82 }
83 83
84 bool SingleSplitViewExample::SplitHandleMoved(views::SingleSplitView* sender) { 84 bool SingleSplitViewExample::SplitHandleMoved(SingleSplitView* sender) {
85 PrintStatus("Splitter moved"); 85 PrintStatus("Splitter moved");
86 return true; 86 return true;
87 } 87 }
88 88
89 } // namespace examples 89 } // namespace examples
90 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/examples/single_split_view_example.h ('k') | ui/views/examples/tabbed_pane_example.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698