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

Side by Side Diff: ash/shell/widgets.cc

Issue 2901503003: Rename GetPreferredSize to CalculatePreferredSize in ash/ (Closed)
Patch Set: improvements Created 3 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
« 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 ~WidgetsWindow() override; 30 ~WidgetsWindow() override;
31 31
32 // Overridden from views::View: 32 // Overridden from views::View:
33 void OnPaint(gfx::Canvas* canvas) override; 33 void OnPaint(gfx::Canvas* canvas) override;
34 void Layout() override; 34 void Layout() override;
35 gfx::Size GetPreferredSize() const override; 35 gfx::Size CalculatePreferredSize() const override;
36 36
37 // Overridden from views::WidgetDelegate: 37 // Overridden from views::WidgetDelegate:
38 base::string16 GetWindowTitle() const override; 38 base::string16 GetWindowTitle() const override;
39 bool CanResize() const override; 39 bool CanResize() const override;
40 40
41 private: 41 private:
42 views::LabelButton* button_; 42 views::LabelButton* button_;
43 views::LabelButton* disabled_button_; 43 views::LabelButton* disabled_button_;
44 views::Checkbox* checkbox_; 44 views::Checkbox* checkbox_;
45 views::Checkbox* checkbox_disabled_; 45 views::Checkbox* checkbox_disabled_;
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 int left = 5; 107 int left = 5;
108 int top = kVerticalPad; 108 int top = kVerticalPad;
109 for (int i = 0; i < child_count(); ++i) { 109 for (int i = 0; i < child_count(); ++i) {
110 views::View* view = child_at(i); 110 views::View* view = child_at(i);
111 gfx::Size preferred = view->GetPreferredSize(); 111 gfx::Size preferred = view->GetPreferredSize();
112 view->SetBounds(left, top, preferred.width(), preferred.height()); 112 view->SetBounds(left, top, preferred.width(), preferred.height());
113 top += preferred.height() + kVerticalPad; 113 top += preferred.height() + kVerticalPad;
114 } 114 }
115 } 115 }
116 116
117 gfx::Size WidgetsWindow::GetPreferredSize() const { 117 gfx::Size WidgetsWindow::CalculatePreferredSize() const {
118 return gfx::Size(kWindowWidth, kWindowHeight); 118 return gfx::Size(kWindowWidth, kWindowHeight);
119 } 119 }
120 120
121 base::string16 WidgetsWindow::GetWindowTitle() const { 121 base::string16 WidgetsWindow::GetWindowTitle() const {
122 return base::ASCIIToUTF16("Examples: Widgets"); 122 return base::ASCIIToUTF16("Examples: Widgets");
123 } 123 }
124 124
125 bool WidgetsWindow::CanResize() const { 125 bool WidgetsWindow::CanResize() const {
126 return true; 126 return true;
127 } 127 }
128 128
129 } // namespace 129 } // namespace
130 130
131 namespace ash { 131 namespace ash {
132 namespace shell { 132 namespace shell {
133 133
134 void CreateWidgetsWindow() { 134 void CreateWidgetsWindow() {
135 gfx::Rect bounds(kWindowLeft, kWindowTop, kWindowWidth, kWindowHeight); 135 gfx::Rect bounds(kWindowLeft, kWindowTop, kWindowWidth, kWindowHeight);
136 views::Widget* widget = views::Widget::CreateWindowWithContextAndBounds( 136 views::Widget* widget = views::Widget::CreateWindowWithContextAndBounds(
137 new WidgetsWindow, Shell::GetPrimaryRootWindow(), bounds); 137 new WidgetsWindow, Shell::GetPrimaryRootWindow(), bounds);
138 widget->GetNativeView()->SetName("WidgetsWindow"); 138 widget->GetNativeView()->SetName("WidgetsWindow");
139 widget->Show(); 139 widget->Show();
140 } 140 }
141 141
142 } // namespace shell 142 } // namespace shell
143 } // namespace ash 143 } // 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