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

Side by Side Diff: views/desktop/desktop_window.cc

Issue 7206055: Add an option to run Chrome in the views desktop. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 6 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/desktop/desktop_window.h ('k') | views/views.gyp » ('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 "views/desktop/desktop_window.h" 5 #include "views/desktop/desktop_window.h"
6 6
7 #include "ui/gfx/canvas.h" 7 #include "ui/gfx/canvas.h"
8 #include "ui/gfx/transform.h" 8 #include "ui/gfx/transform.h"
9 #include "views/desktop/desktop_background.h" 9 #include "views/desktop/desktop_background.h"
10 #include "views/desktop/desktop_window_root_view.h" 10 #include "views/desktop/desktop_window_root_view.h"
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 // window, so we need to construct a NativeWidgetWin by hand. 102 // window, so we need to construct a NativeWidgetWin by hand.
103 // TODO(beng): Replace this with NativeWindow::CreateNativeRootWindow(). 103 // TODO(beng): Replace this with NativeWindow::CreateNativeRootWindow().
104 #if defined(OS_WIN) 104 #if defined(OS_WIN)
105 params.native_widget = new views::NativeWidgetWin(window); 105 params.native_widget = new views::NativeWidgetWin(window);
106 #elif defined(TOOLKIT_USES_GTK) 106 #elif defined(TOOLKIT_USES_GTK)
107 params.native_widget = new views::NativeWidgetGtk(window); 107 params.native_widget = new views::NativeWidgetGtk(window);
108 #endif 108 #endif
109 params.bounds = gfx::Rect(20, 20, 1920, 1200); 109 params.bounds = gfx::Rect(20, 20, 1920, 1200);
110 window->Init(params); 110 window->Init(params);
111 window->Show(); 111 window->Show();
112
113 desktop_window->CreateTestWindow(L"Sample Window 1", SK_ColorWHITE,
114 gfx::Rect(500, 200, 400, 400), true);
115 desktop_window->CreateTestWindow(L"Sample Window 2", SK_ColorRED,
116 gfx::Rect(600, 450, 450, 300), false);
117 } 112 }
118 113
119 void DesktopWindow::ActivateWidget(Widget* widget) { 114 void DesktopWindow::ActivateWidget(Widget* widget) {
120 if (widget && widget->IsActive()) 115 if (widget && widget->IsActive())
121 return; 116 return;
122 117
123 if (active_widget_) 118 if (active_widget_)
124 active_widget_->OnActivate(false); 119 active_widget_->OnActivate(false);
125 if (widget) { 120 if (widget) {
126 widget->MoveToTop(); 121 widget->MoveToTop();
127 active_widget_ = static_cast<NativeWidgetViews*>(widget->native_widget()); 122 active_widget_ = static_cast<NativeWidgetViews*>(widget->native_widget());
128 active_widget_->OnActivate(true); 123 active_widget_->OnActivate(true);
129 } 124 }
130 } 125 }
131 126
127
128 void DesktopWindow::CreateTestWindow(const std::wstring& title,
129 SkColor color,
130 gfx::Rect initial_bounds,
131 bool rotate) {
132 views::Widget* window = views::Widget::CreateWindowWithBounds(
133 new TestWindowContentView(title, color),
134 initial_bounds);
135 window->Show();
136
137 if (rotate) {
138 ui::Transform transform;
139 transform.SetRotate(90.0f);
140 transform.SetTranslateX(window->GetWindowScreenBounds().width());
141 static_cast<NativeWidgetViews*>(window->native_widget())->GetView()->
142 SetTransform(transform);
143 }
144 }
145
132 //////////////////////////////////////////////////////////////////////////////// 146 ////////////////////////////////////////////////////////////////////////////////
133 // DesktopWindow, View overrides: 147 // DesktopWindow, View overrides:
134 148
135 void DesktopWindow::Layout() { 149 void DesktopWindow::Layout() {
136 } 150 }
137 151
138 //////////////////////////////////////////////////////////////////////////////// 152 ////////////////////////////////////////////////////////////////////////////////
139 // DesktopWindow, WindowDelegate implementation: 153 // DesktopWindow, WindowDelegate implementation:
140 154
141 bool DesktopWindow::CanResize() const { 155 bool DesktopWindow::CanResize() const {
(...skipping 21 matching lines...) Expand all
163 } 177 }
164 178
165 void DesktopWindow::WindowClosing() { 179 void DesktopWindow::WindowClosing() {
166 MessageLoopForUI::current()->Quit(); 180 MessageLoopForUI::current()->Quit();
167 } 181 }
168 182
169 View* DesktopWindow::GetContentsView() { 183 View* DesktopWindow::GetContentsView() {
170 return this; 184 return this;
171 } 185 }
172 186
173 ////////////////////////////////////////////////////////////////////////////////
174 // DesktopWindow, private:
175
176 void DesktopWindow::CreateTestWindow(const std::wstring& title,
177 SkColor color,
178 gfx::Rect initial_bounds,
179 bool rotate) {
180 views::Widget* window = views::Widget::CreateWindowWithBounds(
181 new TestWindowContentView(title, color),
182 initial_bounds);
183 window->Show();
184
185 if (rotate) {
186 ui::Transform transform;
187 transform.SetRotate(90.0f);
188 transform.SetTranslateX(window->GetWindowScreenBounds().width());
189 static_cast<NativeWidgetViews*>(window->native_widget())->GetView()->
190 SetTransform(transform);
191 }
192 }
193
194 } // namespace desktop 187 } // namespace desktop
195 } // namespace views 188 } // namespace views
OLDNEW
« no previous file with comments | « views/desktop/desktop_window.h ('k') | views/views.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698