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

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
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 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 // window, so we need to construct a NativeWidgetWin by hand. 91 // window, so we need to construct a NativeWidgetWin by hand.
92 // TODO(beng): Replace this with NativeWindow::CreateNativeRootWindow(). 92 // TODO(beng): Replace this with NativeWindow::CreateNativeRootWindow().
93 #if defined(OS_WIN) 93 #if defined(OS_WIN)
94 params.native_widget = new views::NativeWidgetWin(window); 94 params.native_widget = new views::NativeWidgetWin(window);
95 #elif defined(TOOLKIT_USES_GTK) 95 #elif defined(TOOLKIT_USES_GTK)
96 params.native_widget = new views::NativeWidgetGtk(window); 96 params.native_widget = new views::NativeWidgetGtk(window);
97 #endif 97 #endif
98 params.bounds = gfx::Rect(20, 20, 1920, 1200); 98 params.bounds = gfx::Rect(20, 20, 1920, 1200);
99 window->Init(params); 99 window->Init(params);
100 window->Show(); 100 window->Show();
101
102 desktop_window->CreateTestWindow(L"Sample Window 1", SK_ColorWHITE,
103 gfx::Rect(500, 200, 400, 400), true);
104 desktop_window->CreateTestWindow(L"Sample Window 2", SK_ColorRED,
105 gfx::Rect(600, 450, 450, 300), false);
106 } 101 }
107 102
108 void DesktopWindow::ActivateWidget(Widget* widget) { 103 void DesktopWindow::ActivateWidget(Widget* widget) {
109 if (widget && widget->IsActive()) 104 if (widget && widget->IsActive())
110 return; 105 return;
111 106
112 if (active_widget_) 107 if (active_widget_)
113 active_widget_->OnActivate(false); 108 active_widget_->OnActivate(false);
114 if (widget) { 109 if (widget) {
115 widget->MoveToTop(); 110 widget->MoveToTop();
116 active_widget_ = static_cast<NativeWidgetViews*>(widget->native_widget()); 111 active_widget_ = static_cast<NativeWidgetViews*>(widget->native_widget());
117 active_widget_->OnActivate(true); 112 active_widget_->OnActivate(true);
118 } 113 }
119 } 114 }
120 115
116
117 void DesktopWindow::CreateTestWindow(const std::wstring& title,
118 SkColor color,
119 gfx::Rect initial_bounds,
120 bool rotate) {
121 views::Widget* window = views::Widget::CreateWindowWithBounds(
122 new TestWindowContentView(title, color),
123 initial_bounds);
124 window->Show();
125
126 if (rotate) {
127 ui::Transform transform;
128 transform.SetRotate(90.0f);
129 transform.SetTranslateX(window->GetWindowScreenBounds().width());
130 static_cast<NativeWidgetViews*>(window->native_widget())->GetView()->
131 SetTransform(transform);
132 }
133 }
134
121 //////////////////////////////////////////////////////////////////////////////// 135 ////////////////////////////////////////////////////////////////////////////////
122 // DesktopWindow, View overrides: 136 // DesktopWindow, View overrides:
123 137
124 void DesktopWindow::Layout() { 138 void DesktopWindow::Layout() {
125 } 139 }
126 140
127 //////////////////////////////////////////////////////////////////////////////// 141 ////////////////////////////////////////////////////////////////////////////////
128 // DesktopWindow, WindowDelegate implementation: 142 // DesktopWindow, WindowDelegate implementation:
129 143
130 bool DesktopWindow::CanResize() const { 144 bool DesktopWindow::CanResize() const {
(...skipping 21 matching lines...) Expand all
152 } 166 }
153 167
154 void DesktopWindow::WindowClosing() { 168 void DesktopWindow::WindowClosing() {
155 MessageLoopForUI::current()->Quit(); 169 MessageLoopForUI::current()->Quit();
156 } 170 }
157 171
158 View* DesktopWindow::GetContentsView() { 172 View* DesktopWindow::GetContentsView() {
159 return this; 173 return this;
160 } 174 }
161 175
162 ////////////////////////////////////////////////////////////////////////////////
163 // DesktopWindow, private:
164
165 void DesktopWindow::CreateTestWindow(const std::wstring& title,
166 SkColor color,
167 gfx::Rect initial_bounds,
168 bool rotate) {
169 views::Widget* window = views::Widget::CreateWindowWithBounds(
170 new TestWindowContentView(title, color),
171 initial_bounds);
172 window->Show();
173
174 if (rotate) {
175 ui::Transform transform;
176 transform.SetRotate(90.0f);
177 transform.SetTranslateX(window->GetWindowScreenBounds().width());
178 static_cast<NativeWidgetViews*>(window->native_widget())->GetView()->
179 SetTransform(transform);
180 }
181 }
182
183 } // namespace desktop 176 } // namespace desktop
184 } // namespace views 177 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698