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

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: Examples order changed 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
« no previous file with comments | « views/examples/double_split_view_example.h ('k') | views/examples/examples_main.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/controls/single_split_view.h"
8 #include "views/layout/grid_layout.h"
9
10 namespace {
11
12 // DoubleSplitViews's content, which draws gradient color on background.
13 class SplittedView : public views::View {
14 public:
15 SplittedView();
16 virtual ~SplittedView();
17
18 void SetColor(SkColor from, SkColor to);
19
20 // Overridden from views::View.
21 virtual gfx::Size GetPreferredSize() OVERRIDE;
22 virtual gfx::Size GetMinimumSize() OVERRIDE;
23
24 private:
25 DISALLOW_COPY_AND_ASSIGN(SplittedView);
26 };
27
28 SplittedView::SplittedView() {
29 SetColor(SK_ColorRED, SK_ColorGREEN);
30 }
31
32 SplittedView::~SplittedView() {
33 }
34
35 void SplittedView::SetColor(SkColor from, SkColor to) {
36 set_background(
37 views::Background::CreateVerticalGradientBackground(from, to));
38 }
39
40 gfx::Size SplittedView::GetPreferredSize() {
41 return gfx::Size(width(), height());
42 }
43
44 gfx::Size SplittedView::GetMinimumSize() {
45 return gfx::Size(10, 10);
46 }
47
48 } // namespace
49
50 namespace examples {
51
52 DoubleSplitViewExample::DoubleSplitViewExample(ExamplesMain* main)
53 : ExampleBase(main) {
54 }
55
56 DoubleSplitViewExample::~DoubleSplitViewExample() {
57 }
58
59 std::wstring DoubleSplitViewExample::GetExampleTitle() {
60 return L"Double Split View";
61 }
62
63 void DoubleSplitViewExample::CreateExampleView(views::View* container) {
64 SplittedView* splitted_view_1 = new SplittedView();
65 SplittedView* splitted_view_2 = new SplittedView();
66 SplittedView* splitted_view_3 = new SplittedView();
67
68 inner_single_split_view_ = new views::SingleSplitView(
69 splitted_view_1, splitted_view_2,
70 views::SingleSplitView::HORIZONTAL_SPLIT,
71 NULL);
72
73 outer_single_split_view_ = new views::SingleSplitView(
74 inner_single_split_view_, splitted_view_3,
75 views::SingleSplitView::HORIZONTAL_SPLIT,
76 NULL);
77
78 views::GridLayout* layout = new views::GridLayout(container);
79 container->SetLayoutManager(layout);
80
81 // Add scroll view.
82 views::ColumnSet* column_set = layout->AddColumnSet(0);
83 column_set->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL, 1,
84 views::GridLayout::USE_PREF, 0, 0);
85 layout->StartRow(1, 0);
86 layout->AddView(outer_single_split_view_);
87 }
88
89 } // namespace examples
OLDNEW
« no previous file with comments | « views/examples/double_split_view_example.h ('k') | views/examples/examples_main.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698