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

Side by Side Diff: ui/views/examples/single_split_view_example.cc

Issue 273223002: views: Make view::Views::GetPreferredSize() const. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: More compile fix for ToT Created 6 years, 7 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 | « ui/views/examples/scroll_view_example.cc ('k') | ui/views/examples/throbber_example.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/views/examples/single_split_view_example.h" 5 #include "ui/views/examples/single_split_view_example.h"
6 6
7 #include "ui/views/background.h" 7 #include "ui/views/background.h"
8 #include "ui/views/controls/single_split_view.h" 8 #include "ui/views/controls/single_split_view.h"
9 #include "ui/views/layout/grid_layout.h" 9 #include "ui/views/layout/grid_layout.h"
10 10
11 namespace views { 11 namespace views {
12 namespace examples { 12 namespace examples {
13 namespace { 13 namespace {
14 14
15 // SingleSplitView's content, which draws gradient color on background. 15 // SingleSplitView's content, which draws gradient color on background.
16 class SplittedView : public View { 16 class SplittedView : public View {
17 public: 17 public:
18 SplittedView(); 18 SplittedView();
19 virtual ~SplittedView(); 19 virtual ~SplittedView();
20 20
21 void SetColor(SkColor from, SkColor to); 21 void SetColor(SkColor from, SkColor to);
22 22
23 private: 23 private:
24 // View: 24 // View:
25 virtual gfx::Size GetPreferredSize() OVERRIDE; 25 virtual gfx::Size GetPreferredSize() const OVERRIDE;
26 virtual gfx::Size GetMinimumSize() OVERRIDE; 26 virtual gfx::Size GetMinimumSize() const OVERRIDE;
27 virtual void Layout() OVERRIDE; 27 virtual void Layout() OVERRIDE;
28 28
29 DISALLOW_COPY_AND_ASSIGN(SplittedView); 29 DISALLOW_COPY_AND_ASSIGN(SplittedView);
30 }; 30 };
31 31
32 SplittedView::SplittedView() { 32 SplittedView::SplittedView() {
33 SetColor(SK_ColorRED, SK_ColorGREEN); 33 SetColor(SK_ColorRED, SK_ColorGREEN);
34 } 34 }
35 35
36 SplittedView::~SplittedView() { 36 SplittedView::~SplittedView() {
37 } 37 }
38 38
39 void SplittedView::SetColor(SkColor from, SkColor to) { 39 void SplittedView::SetColor(SkColor from, SkColor to) {
40 set_background(Background::CreateVerticalGradientBackground(from, to)); 40 set_background(Background::CreateVerticalGradientBackground(from, to));
41 } 41 }
42 42
43 gfx::Size SplittedView::GetPreferredSize() { 43 gfx::Size SplittedView::GetPreferredSize() const {
44 return gfx::Size(width(), height()); 44 return gfx::Size(width(), height());
45 } 45 }
46 46
47 gfx::Size SplittedView::GetMinimumSize() { 47 gfx::Size SplittedView::GetMinimumSize() const {
48 return gfx::Size(10, 10); 48 return gfx::Size(10, 10);
49 } 49 }
50 50
51 void SplittedView::Layout() { 51 void SplittedView::Layout() {
52 SizeToPreferredSize(); 52 SizeToPreferredSize();
53 } 53 }
54 54
55 } // namespace 55 } // namespace
56 56
57 SingleSplitViewExample::SingleSplitViewExample() 57 SingleSplitViewExample::SingleSplitViewExample()
(...skipping 24 matching lines...) Expand all
82 layout->AddView(single_split_view_); 82 layout->AddView(single_split_view_);
83 } 83 }
84 84
85 bool SingleSplitViewExample::SplitHandleMoved(SingleSplitView* sender) { 85 bool SingleSplitViewExample::SplitHandleMoved(SingleSplitView* sender) {
86 PrintStatus("Splitter moved"); 86 PrintStatus("Splitter moved");
87 return true; 87 return true;
88 } 88 }
89 89
90 } // namespace examples 90 } // namespace examples
91 } // namespace views 91 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/examples/scroll_view_example.cc ('k') | ui/views/examples/throbber_example.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698