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

Side by Side Diff: mojo/examples/media_viewer/media_viewer.cc

Issue 658923003: Remove dependency on ui from view_manager. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: rebase Created 6 years, 1 month 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 <map> 5 #include <map>
6 #include <string> 6 #include <string>
7 7
8 #include "base/macros.h" 8 #include "base/macros.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 button->SetBorder(scoped_ptr<views::Border>(new CustomButtonBorder)); 157 button->SetBorder(scoped_ptr<views::Border>(new CustomButtonBorder));
158 buttons_[type] = button; 158 buttons_[type] = button;
159 widget_delegate->GetContentsView()->AddChildView(button); 159 widget_delegate->GetContentsView()->AddChildView(button);
160 } 160 }
161 161
162 views::Widget* widget = new views::Widget; 162 views::Widget* widget = new views::Widget;
163 views::Widget::InitParams params( 163 views::Widget::InitParams params(
164 views::Widget::InitParams::TYPE_WINDOW_FRAMELESS); 164 views::Widget::InitParams::TYPE_WINDOW_FRAMELESS);
165 params.native_widget = new NativeWidgetViewManager(widget, shell, view); 165 params.native_widget = new NativeWidgetViewManager(widget, shell, view);
166 params.delegate = widget_delegate; 166 params.delegate = widget_delegate;
167 params.bounds = gfx::Rect(view->bounds().width(), view->bounds().height()); 167 params.bounds = gfx::Rect(view->bounds().width, view->bounds().height);
168 params.opacity = views::Widget::InitParams::OPAQUE_WINDOW; 168 params.opacity = views::Widget::InitParams::OPAQUE_WINDOW;
169 widget->Init(params); 169 widget->Init(params);
170 widget->Show(); 170 widget->Show();
171 } 171 }
172 172
173 private: 173 private:
174 // Overridden from views::ButtonListener: 174 // Overridden from views::ButtonListener:
175 virtual void ButtonPressed(views::Button* sender, 175 virtual void ButtonPressed(views::Button* sender,
176 const ui::Event& event) override { 176 const ui::Event& event) override {
177 for (int i = 0; i < CONTROL_COUNT; ++i) { 177 for (int i = 0; i < CONTROL_COUNT; ++i) {
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 } 225 }
226 226
227 virtual bool ConfigureIncomingConnection(ApplicationConnection* connection) 227 virtual bool ConfigureIncomingConnection(ApplicationConnection* connection)
228 override { 228 override {
229 connection->AddService(view_manager_client_factory_.get()); 229 connection->AddService(view_manager_client_factory_.get());
230 return true; 230 return true;
231 } 231 }
232 232
233 void LayoutViews() { 233 void LayoutViews() {
234 View* root = content_view_->parent(); 234 View* root = content_view_->parent();
235 gfx::Rect control_bounds(root->bounds().width(), 28); 235 Rect control_bounds;
236 control_bounds.width = root->bounds().width;
237 control_bounds.height = 28;
236 control_view_->SetBounds(control_bounds); 238 control_view_->SetBounds(control_bounds);
237 gfx::Rect content_bounds(0, control_bounds.height(), root->bounds().width(), 239 Rect content_bounds;
238 root->bounds().height() - control_bounds.height()); 240 content_bounds.y = control_bounds.height;
241 content_bounds.width = root->bounds().width;
242 content_bounds.height = root->bounds().height - control_bounds.height;
239 content_view_->SetBounds(content_bounds); 243 content_view_->SetBounds(content_bounds);
240 } 244 }
241 245
242 // Overridden from ViewManagerDelegate: 246 // Overridden from ViewManagerDelegate:
243 virtual void OnEmbed(ViewManager* view_manager, 247 virtual void OnEmbed(ViewManager* view_manager,
244 View* root, 248 View* root,
245 ServiceProviderImpl* exported_services, 249 ServiceProviderImpl* exported_services,
246 scoped_ptr<ServiceProvider> imported_services) override { 250 scoped_ptr<ServiceProvider> imported_services) override {
247 root_view_ = root; 251 root_view_ = root;
248 view_manager_ = view_manager; 252 view_manager_ = view_manager;
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 case ControlPanel::CONTROL_ZOOM_OUT: 284 case ControlPanel::CONTROL_ZOOM_OUT:
281 zoomable_media_->ZoomOut(); 285 zoomable_media_->ZoomOut();
282 break; 286 break;
283 default: 287 default:
284 NOTIMPLEMENTED(); 288 NOTIMPLEMENTED();
285 } 289 }
286 } 290 }
287 291
288 // ViewObserver: 292 // ViewObserver:
289 virtual void OnViewBoundsChanged(View* view, 293 virtual void OnViewBoundsChanged(View* view,
290 const gfx::Rect& old_bounds, 294 const Rect& old_bounds,
291 const gfx::Rect& new_bounds) override { 295 const Rect& new_bounds) override {
292 LayoutViews(); 296 LayoutViews();
293 } 297 }
294 virtual void OnViewDestroyed(View* view) override { 298 virtual void OnViewDestroyed(View* view) override {
295 DCHECK_EQ(view, root_view_); 299 DCHECK_EQ(view, root_view_);
296 view->RemoveObserver(this); 300 view->RemoveObserver(this);
297 root_view_ = NULL; 301 root_view_ = NULL;
298 } 302 }
299 303
300 std::string GetHandlerForContentType(const std::string& content_type) { 304 std::string GetHandlerForContentType(const std::string& content_type) {
301 HandlerMap::const_iterator it = handler_map_.find(content_type); 305 HandlerMap::const_iterator it = handler_map_.find(content_type);
(...skipping 17 matching lines...) Expand all
319 DISALLOW_COPY_AND_ASSIGN(MediaViewer); 323 DISALLOW_COPY_AND_ASSIGN(MediaViewer);
320 }; 324 };
321 325
322 } // namespace examples 326 } // namespace examples
323 } // namespace mojo 327 } // namespace mojo
324 328
325 MojoResult MojoMain(MojoHandle shell_handle) { 329 MojoResult MojoMain(MojoHandle shell_handle) {
326 mojo::ApplicationRunnerChromium runner(new mojo::examples::MediaViewer); 330 mojo::ApplicationRunnerChromium runner(new mojo::examples::MediaViewer);
327 return runner.Run(shell_handle); 331 return runner.Run(shell_handle);
328 } 332 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698