Commit a38f3a35 authored by tfarina@chromium.org's avatar tfarina@chromium.org

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
parent 6cd9455e
// 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
// 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);
......
......@@ -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',
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment