diff options
author | oshima@chromium.org <oshima@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-01-25 20:35:25 +0000 |
---|---|---|
committer | oshima@chromium.org <oshima@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-01-25 20:35:25 +0000 |
commit | cb34b251707323165c85b7079467e9a03c65af8e (patch) | |
tree | 611d83716b4998fa5caf8fe52faff86d73d9f696 /views | |
parent | 4329776454c79eab08647c7ea86268a5e1e4c1da (diff) | |
download | chromium_src-cb34b251707323165c85b7079467e9a03c65af8e.zip chromium_src-cb34b251707323165c85b7079467e9a03c65af8e.tar.gz chromium_src-cb34b251707323165c85b7079467e9a03c65af8e.tar.bz2 |
SingleSplitView example
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/555078
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@37031 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views')
-rw-r--r-- | views/examples/examples_main.cc | 5 | ||||
-rw-r--r-- | views/examples/single_split_view_example.h | 83 | ||||
-rw-r--r-- | views/views.gyp | 1 |
3 files changed, 89 insertions, 0 deletions
diff --git a/views/examples/examples_main.cc b/views/examples/examples_main.cc index 93bbaf4..cb02329 100644 --- a/views/examples/examples_main.cc +++ b/views/examples/examples_main.cc @@ -17,6 +17,7 @@ #include "views/examples/menu_example.h" #include "views/examples/radio_button_example.h" #include "views/examples/scroll_view_example.h" +#include "views/examples/single_split_view_example.h" // Slider is not yet ported to Windows. #if defined(OS_LINUX) #include "views/examples/slider_example.h" @@ -114,6 +115,10 @@ void ExamplesMain::Run() { tabbed_pane->AddTab(scroll_view_example.GetExampleTitle(), scroll_view_example.GetExampleView()); + examples::SingleSplitViewExample single_split_view_example(this); + tabbed_pane->AddTab(single_split_view_example.GetExampleTitle(), + single_split_view_example.GetExampleView()); + #if defined(OS_WIN) examples::TableExample table_example(this); tabbed_pane->AddTab(table_example.GetExampleTitle(), diff --git a/views/examples/single_split_view_example.h b/views/examples/single_split_view_example.h new file mode 100644 index 0000000..599cc32 --- /dev/null +++ b/views/examples/single_split_view_example.h @@ -0,0 +1,83 @@ +// Copyright (c) 2010 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. + +#ifndef VIEWS_EXAMPLES_SINGLE_SPLIT_VIEW_EXAMPLE_H_ +#define VIEWS_EXAMPLES_SINGLE_SPLIT_VIEW_EXAMPLE_H_ + +#include "views/controls/single_split_view.h" +#include "views/examples/example_base.h" + +namespace examples { + +class SingleSplitViewExample : public ExampleBase { + public: + explicit SingleSplitViewExample(ExamplesMain* main) + : ExampleBase(main) { + } + + 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); + + 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_); + } + + 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); + } + + void SetColor(SkColor from, SkColor to) { + set_background( + views::Background::CreateVerticalGradientBackground(from, to)); + } + + virtual void Layout() { + SizeToPreferredSize(); + } + + private: + DISALLOW_COPY_AND_ASSIGN(SplittedView); + }; + + // The SinleSplitView to test. + views::SingleSplitView* single_split_view_; + + DISALLOW_COPY_AND_ASSIGN(SingleSplitViewExample); +}; + +} // namespace examples + +#endif // VIEWS_EXAMPLES_SINGLE_SPLIT_VIEW_EXAMPLE_H_ diff --git a/views/views.gyp b/views/views.gyp index bfab674..97f712e 100644 --- a/views/views.gyp +++ b/views/views.gyp @@ -369,6 +369,7 @@ 'examples/menu_example.h', 'examples/radio_button_example.h', 'examples/scroll_view_example.h', + 'examples/single_split_view_example.h', 'examples/slider_example.h', 'examples/tabbed_pane_example.h', 'examples/textfield_example.h', |