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

Unified Diff: views/examples/scroll_view_example.cc

Issue 8555013: views: Move examples/ directory to ui/views/. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « views/examples/scroll_view_example.h ('k') | views/examples/single_split_view_example.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: views/examples/scroll_view_example.cc
diff --git a/views/examples/scroll_view_example.cc b/views/examples/scroll_view_example.cc
deleted file mode 100644
index 7ed2ece938f93ff2e6bbbe2b72c244a6666ffae2..0000000000000000000000000000000000000000
--- a/views/examples/scroll_view_example.cc
+++ /dev/null
@@ -1,114 +0,0 @@
-// 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/scroll_view_example.h"
-
-#include "base/stringprintf.h"
-#include "base/utf_string_conversions.h"
-#include "views/controls/button/radio_button.h"
-#include "views/layout/grid_layout.h"
-#include "views/view.h"
-
-namespace examples {
-
-// ScrollView's content, which draws gradient color on background.
-// TODO(oshima): add child views as well.
-class ScrollViewExample::ScrollableView : public views::View {
- public:
- ScrollableView() {
- SetColor(SK_ColorRED, SK_ColorCYAN);
- AddChildView(new views::TextButton(NULL, ASCIIToUTF16("Button")));
- AddChildView(new views::RadioButton(ASCIIToUTF16("Radio Button"), 0));
- }
-
- virtual gfx::Size GetPreferredSize() {
- return gfx::Size(width(), height());
- }
-
- void SetColor(SkColor from, SkColor to) {
- set_background(
- views::Background::CreateVerticalGradientBackground(from, to));
- }
-
- void PlaceChildY(int index, int y) {
- views::View* view = child_at(index);
- gfx::Size size = view->GetPreferredSize();
- view->SetBounds(0, y, size.width(), size.height());
- }
-
- virtual void Layout() {
- PlaceChildY(0, 0);
- PlaceChildY(1, height() / 2);
- SizeToPreferredSize();
- }
-
- private:
- DISALLOW_COPY_AND_ASSIGN(ScrollableView);
-};
-
-ScrollViewExample::ScrollViewExample(ExamplesMain* main)
- : ExampleBase(main, "Scroll View") {
-}
-
-ScrollViewExample::~ScrollViewExample() {
-}
-
-void ScrollViewExample::CreateExampleView(views::View* container) {
- wide_ = new views::TextButton(this, ASCIIToUTF16("Wide"));
- tall_ = new views::TextButton(this, ASCIIToUTF16("Tall"));
- big_square_ = new views::TextButton(this, ASCIIToUTF16("Big Square"));
- small_square_ = new views::TextButton(this, ASCIIToUTF16("Small Square"));
- scroll_to_ = new views::TextButton(this, ASCIIToUTF16("Scroll to"));
- scrollable_ = new ScrollableView();
- scroll_view_ = new views::ScrollView();
- scroll_view_->SetContents(scrollable_);
- scrollable_->SetBounds(0, 0, 1000, 100);
- scrollable_->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(scroll_view_);
-
- // Add control buttons.
- column_set = layout->AddColumnSet(1);
- for (int i = 0; i < 5; i++) {
- column_set->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL, 1,
- views::GridLayout::USE_PREF, 0, 0);
- }
- layout->StartRow(0, 1);
- layout->AddView(wide_);
- layout->AddView(tall_);
- layout->AddView(big_square_);
- layout->AddView(small_square_);
- layout->AddView(scroll_to_);
-}
-
-void ScrollViewExample::ButtonPressed(views::Button* sender,
- const views::Event& event) {
- if (sender == wide_) {
- scrollable_->SetBounds(0, 0, 1000, 100);
- scrollable_->SetColor(SK_ColorYELLOW, SK_ColorCYAN);
- } else if (sender == tall_) {
- scrollable_->SetBounds(0, 0, 100, 1000);
- scrollable_->SetColor(SK_ColorRED, SK_ColorCYAN);
- } else if (sender == big_square_) {
- scrollable_->SetBounds(0, 0, 1000, 1000);
- scrollable_->SetColor(SK_ColorRED, SK_ColorGREEN);
- } else if (sender == small_square_) {
- scrollable_->SetBounds(0, 0, 100, 100);
- scrollable_->SetColor(SK_ColorYELLOW, SK_ColorGREEN);
- } else if (sender == scroll_to_) {
- scroll_view_->ScrollContentsRegionToBeVisible(
- gfx::Rect(20, 500, 1000, 500));
- }
- scroll_view_->Layout();
-}
-
-} // namespace examples
« no previous file with comments | « views/examples/scroll_view_example.h ('k') | views/examples/single_split_view_example.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698