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: views/examples/double_split_view_example.cc

Issue 7846010: Fixed crash when a SinglesplitView gets embdedded inside SingleSplitView (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: incorporated all review comments by Sky and Tfarina Created 9 years, 3 months 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
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "views/examples/double_split_view_example.h"
6
7 #include "views/layout/grid_layout.h"
8
9 namespace {
10
11 // DoubleSplitViews's content, which draws gradient color on background.
12 class SplittedView : public views::View {
13 public:
14 SplittedView();
15 virtual ~SplittedView();
16
17 void SetColor(SkColor from, SkColor to);
18
19 // Overridden from views::View.
20 virtual gfx::Size GetPreferredSize() OVERRIDE;
21 virtual gfx::Size GetMinimumSize() OVERRIDE;
22
23 private:
24 DISALLOW_COPY_AND_ASSIGN(SplittedView);
25 };
26
27 SplittedView::SplittedView() {
28 SetColor(SK_ColorRED, SK_ColorGREEN);
29 }
30
31 SplittedView::~SplittedView() {
32 }
33
34 void SplittedView::SetColor(SkColor from, SkColor to) {
35 set_background(
36 views::Background::CreateVerticalGradientBackground(from, to));
37 }
38
39 gfx::Size SplittedView::GetPreferredSize() {
40 return gfx::Size(width(), height());
41 }
42
43 gfx::Size SplittedView::GetMinimumSize() {
44 return gfx::Size(10, 10);
45 }
46
47 } // namespace
48
49 namespace examples {
50
51 DoubleSplitViewExample::DoubleSplitViewExample(ExamplesMain* main)
52 : ExampleBase(main) {
53 }
54
55 DoubleSplitViewExample::~DoubleSplitViewExample() {
56 }
57
58 std::wstring DoubleSplitViewExample::GetExampleTitle() {
59 return L"Double Split View";
60 }
61
62 void DoubleSplitViewExample::CreateExampleView(views::View* container) {
63 SplittedView* splitted_view_1 = new SplittedView();
64 SplittedView* splitted_view_2 = new SplittedView();
65 SplittedView* splitted_view_3 = new SplittedView();
66
67 inner_single_split_view_ = new views::SingleSplitView(
68 splitted_view_1, splitted_view_2,
69 views::SingleSplitView::HORIZONTAL_SPLIT,
70 NULL);
71
72 outer_single_split_view_ = new views::SingleSplitView(
73 inner_single_split_view_, splitted_view_3,
74 views::SingleSplitView::HORIZONTAL_SPLIT,
75 NULL);
76
77 views::GridLayout* layout = new views::GridLayout(container);
78 container->SetLayoutManager(layout);
79
80 // Add scroll view.
81 views::ColumnSet* column_set = layout->AddColumnSet(0);
82 column_set->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL, 1,
83 views::GridLayout::USE_PREF, 0, 0);
84 layout->StartRow(1, 0);
85 layout->AddView(outer_single_split_view_);
86 }
87
88 } // namespace examples
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698