summaryrefslogtreecommitdiffstats
path: root/views
diff options
context:
space:
mode:
authortfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-01-21 02:01:23 +0000
committertfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-01-21 02:01:23 +0000
commita38f3a356d50a026eb0874b01bd665e84451e07b (patch)
treeda75a5cf707d2ca2e262d404a4c18560f0558e75 /views
parent6cd9455e58104831eb1a5a9a1c2288df7b1b0411 (diff)
downloadchromium_src-a38f3a356d50a026eb0874b01bd665e84451e07b.zip
chromium_src-a38f3a356d50a026eb0874b01bd665e84451e07b.tar.gz
chromium_src-a38f3a356d50a026eb0874b01bd665e84451e07b.tar.bz2
views: Move the implementation of SingleSplitViewExample from the header file to the source file.
BUG=None TEST=run out/Debug/views_examples, it should work as before. Review URL: http://codereview.chromium.org/6377004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@72086 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views')
-rw-r--r--views/examples/single_split_view_example.cc68
-rw-r--r--views/examples/single_split_view_example.h62
-rw-r--r--views/views.gyp1
3 files changed, 82 insertions, 49 deletions
diff --git a/views/examples/single_split_view_example.cc b/views/examples/single_split_view_example.cc
new file mode 100644
index 0000000..a9f6647
--- /dev/null
+++ b/views/examples/single_split_view_example.cc
@@ -0,0 +1,68 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "views/examples/single_split_view_example.h"
+
+#include "views/grid_layout.h"
+
+namespace examples {
+
+SingleSplitViewExample::SingleSplitViewExample(ExamplesMain* main)
+ : ExampleBase(main) {
+}
+
+SingleSplitViewExample::~SingleSplitViewExample() {
+}
+
+std::wstring SingleSplitViewExample::GetExampleTitle() {
+ return L"Single Split View";
+}
+
+void SingleSplitViewExample::CreateExampleView(views::View* container) {
+ SplittedView* splitted_view_1 = new SplittedView();
+ SplittedView* splitted_view_2 = new SplittedView();
+
+ single_split_view_ = new views::SingleSplitView(
+ splitted_view_1, splitted_view_2,
+ views::SingleSplitView::HORIZONTAL_SPLIT,
+ NULL);
+
+ splitted_view_1->SetColor(SK_ColorYELLOW, SK_ColorCYAN);
+
+ views::GridLayout* layout = new views::GridLayout(container);
+ container->SetLayoutManager(layout);
+
+ // Add scroll view.
+ views::ColumnSet* column_set = layout->AddColumnSet(0);
+ column_set->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL, 1,
+ views::GridLayout::USE_PREF, 0, 0);
+ layout->StartRow(1, 0);
+ layout->AddView(single_split_view_);
+}
+
+SingleSplitViewExample::SplittedView::SplittedView() {
+ SetColor(SK_ColorRED, SK_ColorGREEN);
+}
+
+SingleSplitViewExample::SplittedView::~SplittedView() {
+}
+
+void SingleSplitViewExample::SplittedView::SetColor(SkColor from, SkColor to) {
+ set_background(
+ views::Background::CreateVerticalGradientBackground(from, to));
+}
+
+gfx::Size SingleSplitViewExample::SplittedView::GetPreferredSize() {
+ return gfx::Size(width(), height());
+}
+
+gfx::Size SingleSplitViewExample::SplittedView::GetMinimumSize() {
+ return gfx::Size(10, 10);
+}
+
+void SingleSplitViewExample::SplittedView::Layout() {
+ SizeToPreferredSize();
+}
+
+} // namespace examples
diff --git a/views/examples/single_split_view_example.h b/views/examples/single_split_view_example.h
index 73d69a6..223955c 100644
--- a/views/examples/single_split_view_example.h
+++ b/views/examples/single_split_view_example.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -13,62 +13,26 @@ namespace examples {
class SingleSplitViewExample : public ExampleBase {
public:
- explicit SingleSplitViewExample(ExamplesMain* main)
- : ExampleBase(main) {
- }
+ explicit SingleSplitViewExample(ExamplesMain* main);
+ virtual ~SingleSplitViewExample();
- virtual ~SingleSplitViewExample() {}
-
- virtual std::wstring GetExampleTitle() {
- return L"Single Split View";
- }
-
- virtual void CreateExampleView(views::View* container) {
- SplittedView* splitted_view_1 = new SplittedView();
- SplittedView* splitted_view_2 = new SplittedView();
-
- single_split_view_ = new views::SingleSplitView(
- splitted_view_1, splitted_view_2,
- views::SingleSplitView::HORIZONTAL_SPLIT,
- NULL);
-
- splitted_view_1->SetColor(SK_ColorYELLOW, SK_ColorCYAN);
-
- views::GridLayout* layout = new views::GridLayout(container);
- container->SetLayoutManager(layout);
-
- // Add scroll view.
- views::ColumnSet* column_set = layout->AddColumnSet(0);
- column_set->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL, 1,
- views::GridLayout::USE_PREF, 0, 0);
- layout->StartRow(1, 0);
- layout->AddView(single_split_view_);
- }
+ // Overridden from ExampleBase:
+ virtual std::wstring GetExampleTitle();
+ virtual void CreateExampleView(views::View* container);
private:
// SingleSplitView's content, which draws gradient color on background.
class SplittedView : public views::View {
public:
- SplittedView() {
- SetColor(SK_ColorRED, SK_ColorGREEN);
- }
-
- virtual gfx::Size GetPreferredSize() {
- return gfx::Size(width(), height());
- }
-
- virtual gfx::Size GetMinimumSize() {
- return gfx::Size(10, 10);
- }
+ SplittedView();
+ virtual ~SplittedView();
- void SetColor(SkColor from, SkColor to) {
- set_background(
- views::Background::CreateVerticalGradientBackground(from, to));
- }
+ void SetColor(SkColor from, SkColor to);
- virtual void Layout() {
- SizeToPreferredSize();
- }
+ // Overridden from views::View:
+ virtual gfx::Size GetPreferredSize();
+ virtual gfx::Size GetMinimumSize();
+ virtual void Layout();
private:
DISALLOW_COPY_AND_ASSIGN(SplittedView);
diff --git a/views/views.gyp b/views/views.gyp
index e9fb72b..34013a6 100644
--- a/views/views.gyp
+++ b/views/views.gyp
@@ -529,6 +529,7 @@
'examples/menu_example.h',
'examples/radio_button_example.h',
'examples/scroll_view_example.h',
+ 'examples/single_split_view_example.cc',
'examples/single_split_view_example.h',
'examples/slider_example.h',
'examples/tabbed_pane_example.h',