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

Side by Side Diff: ash/shell/widgets.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 | « ash/shell/panel_window.cc ('k') | ash/shell/window_type_launcher.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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "ash/shell.h" 5 #include "ash/shell.h"
6 #include "base/strings/utf_string_conversions.h" 6 #include "base/strings/utf_string_conversions.h"
7 #include "ui/aura/window.h" 7 #include "ui/aura/window.h"
8 #include "ui/aura/window_event_dispatcher.h" 8 #include "ui/aura/window_event_dispatcher.h"
9 #include "ui/gfx/canvas.h" 9 #include "ui/gfx/canvas.h"
10 #include "ui/views/controls/button/checkbox.h" 10 #include "ui/views/controls/button/checkbox.h"
(...skipping 14 matching lines...) Expand all
25 25
26 // A window showing samples of commonly used widgets. 26 // A window showing samples of commonly used widgets.
27 class WidgetsWindow : public views::WidgetDelegateView { 27 class WidgetsWindow : public views::WidgetDelegateView {
28 public: 28 public:
29 WidgetsWindow(); 29 WidgetsWindow();
30 virtual ~WidgetsWindow(); 30 virtual ~WidgetsWindow();
31 31
32 // Overridden from views::View: 32 // Overridden from views::View:
33 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE; 33 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE;
34 virtual void Layout() OVERRIDE; 34 virtual void Layout() OVERRIDE;
35 virtual gfx::Size GetPreferredSize() OVERRIDE; 35 virtual gfx::Size GetPreferredSize() const OVERRIDE;
36 36
37 // Overridden from views::WidgetDelegate: 37 // Overridden from views::WidgetDelegate:
38 virtual views::View* GetContentsView() OVERRIDE; 38 virtual views::View* GetContentsView() OVERRIDE;
39 virtual base::string16 GetWindowTitle() const OVERRIDE; 39 virtual base::string16 GetWindowTitle() const OVERRIDE;
40 virtual bool CanResize() const OVERRIDE; 40 virtual bool CanResize() const OVERRIDE;
41 41
42 private: 42 private:
43 views::LabelButton* button_; 43 views::LabelButton* button_;
44 views::LabelButton* disabled_button_; 44 views::LabelButton* disabled_button_;
45 views::Checkbox* checkbox_; 45 views::Checkbox* checkbox_;
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 int left = 5; 106 int left = 5;
107 int top = kVerticalPad; 107 int top = kVerticalPad;
108 for (int i = 0; i < child_count(); ++i) { 108 for (int i = 0; i < child_count(); ++i) {
109 views::View* view = child_at(i); 109 views::View* view = child_at(i);
110 gfx::Size preferred = view->GetPreferredSize(); 110 gfx::Size preferred = view->GetPreferredSize();
111 view->SetBounds(left, top, preferred.width(), preferred.height()); 111 view->SetBounds(left, top, preferred.width(), preferred.height());
112 top += preferred.height() + kVerticalPad; 112 top += preferred.height() + kVerticalPad;
113 } 113 }
114 } 114 }
115 115
116 gfx::Size WidgetsWindow::GetPreferredSize() { 116 gfx::Size WidgetsWindow::GetPreferredSize() const {
117 return gfx::Size(kWindowWidth, kWindowHeight); 117 return gfx::Size(kWindowWidth, kWindowHeight);
118 } 118 }
119 119
120 views::View* WidgetsWindow::GetContentsView() { 120 views::View* WidgetsWindow::GetContentsView() {
121 return this; 121 return this;
122 } 122 }
123 123
124 base::string16 WidgetsWindow::GetWindowTitle() const { 124 base::string16 WidgetsWindow::GetWindowTitle() const {
125 return base::ASCIIToUTF16("Examples: Widgets"); 125 return base::ASCIIToUTF16("Examples: Widgets");
126 } 126 }
(...skipping 11 matching lines...) Expand all
138 gfx::Rect bounds(kWindowLeft, kWindowTop, kWindowWidth, kWindowHeight); 138 gfx::Rect bounds(kWindowLeft, kWindowTop, kWindowWidth, kWindowHeight);
139 views::Widget* widget = 139 views::Widget* widget =
140 views::Widget::CreateWindowWithContextAndBounds( 140 views::Widget::CreateWindowWithContextAndBounds(
141 new WidgetsWindow, Shell::GetPrimaryRootWindow(), bounds); 141 new WidgetsWindow, Shell::GetPrimaryRootWindow(), bounds);
142 widget->GetNativeView()->SetName("WidgetsWindow"); 142 widget->GetNativeView()->SetName("WidgetsWindow");
143 widget->Show(); 143 widget->Show();
144 } 144 }
145 145
146 } // namespace shell 146 } // namespace shell
147 } // namespace ash 147 } // namespace ash
OLDNEW
« no previous file with comments | « ash/shell/panel_window.cc ('k') | ash/shell/window_type_launcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698