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

Side by Side Diff: mojo/examples/window_manager/debug_panel.cc

Issue 383123006: Preliminary interactive layout of window manager's demo_launcher (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 5 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 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 "mojo/examples/window_manager/debug_panel.h" 5 #include "mojo/examples/window_manager/debug_panel.h"
6 6
7 #include "base/strings/stringprintf.h" 7 #include "base/strings/stringprintf.h"
8 #include "base/strings/utf_string_conversions.h" 8 #include "base/strings/utf_string_conversions.h"
9 #include "mojo/services/public/cpp/view_manager/node.h" 9 #include "mojo/services/public/cpp/view_manager/node.h"
10 #include "mojo/views/native_widget_view_manager.h" 10 #include "mojo/views/native_widget_view_manager.h"
(...skipping 28 matching lines...) Expand all
39 colored_square_(new views::BlueButton( 39 colored_square_(new views::BlueButton(
40 this, base::ASCIIToUTF16("Local nav test"))), 40 this, base::ASCIIToUTF16("Local nav test"))),
41 close_last_(new views::BlueButton( 41 close_last_(new views::BlueButton(
42 this, base::ASCIIToUTF16("Close last window"))), 42 this, base::ASCIIToUTF16("Close last window"))),
43 cross_app_(new views::BlueButton( 43 cross_app_(new views::BlueButton(
44 this, base::ASCIIToUTF16("Cross-app nav test"))) { 44 this, base::ASCIIToUTF16("Cross-app nav test"))) {
45 navigation_target_label_->SetHorizontalAlignment(gfx::ALIGN_LEFT); 45 navigation_target_label_->SetHorizontalAlignment(gfx::ALIGN_LEFT);
46 navigation_target_default_->SetChecked(true); 46 navigation_target_default_->SetChecked(true);
47 47
48 views::WidgetDelegateView* widget_delegate = new views::WidgetDelegateView(); 48 views::WidgetDelegateView* widget_delegate = new views::WidgetDelegateView();
49 widget_delegate->GetContentsView()->set_background( 49 contents_view_ = widget_delegate->GetContentsView();
50 contents_view_->set_background(
50 views::Background::CreateSolidBackground(0xFFDDDDDD)); 51 views::Background::CreateSolidBackground(0xFFDDDDDD));
51 widget_delegate->GetContentsView()->AddChildView(navigation_target_label_); 52 contents_view_->AddChildView(navigation_target_label_);
52 widget_delegate->GetContentsView()->AddChildView(navigation_target_default_); 53 contents_view_->AddChildView(navigation_target_default_);
53 widget_delegate->GetContentsView()->AddChildView(navigation_target_new_); 54 contents_view_->AddChildView(navigation_target_new_);
54 widget_delegate->GetContentsView()->AddChildView(navigation_target_source_); 55 contents_view_->AddChildView(navigation_target_source_);
55 widget_delegate->GetContentsView()->AddChildView(colored_square_); 56 contents_view_->AddChildView(colored_square_);
56 widget_delegate->GetContentsView()->AddChildView(close_last_); 57 contents_view_->AddChildView(close_last_);
57 widget_delegate->GetContentsView()->AddChildView(cross_app_); 58 contents_view_->AddChildView(cross_app_);
58 widget_delegate->GetContentsView()->SetLayoutManager(this); 59 contents_view_->SetLayoutManager(this);
59 60
60 views::Widget* widget = new views::Widget(); 61 widget_ = new views::Widget();
61 views::Widget::InitParams params( 62 views::Widget::InitParams params(
62 views::Widget::InitParams::TYPE_WINDOW_FRAMELESS); 63 views::Widget::InitParams::TYPE_WINDOW_FRAMELESS);
63 params.native_widget = new NativeWidgetViewManager(widget, node); 64 params.native_widget = new NativeWidgetViewManager(widget_, node);
64 params.delegate = widget_delegate; 65 params.delegate = widget_delegate;
65 params.bounds = gfx::Rect(node->bounds().size()); 66 params.bounds = gfx::Rect(node->bounds().size());
66 widget->Init(params); 67 widget_->Init(params);
67 widget->Show(); 68 widget_->Show();
69
70 node->AddObserver(this);
68 } 71 }
69 72
70 DebugPanel::~DebugPanel() { 73 DebugPanel::~DebugPanel() {
71 } 74 }
72 75
73 gfx::Size DebugPanel::GetPreferredSize(const views::View* view) const { 76 gfx::Size DebugPanel::GetPreferredSize(const views::View* view) const {
74 return gfx::Size(); 77 return gfx::Size();
75 } 78 }
76 79
77 navigation::Target DebugPanel::navigation_target() const { 80 navigation::Target DebugPanel::navigation_target() const {
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 } 130 }
128 } 131 }
129 132
130 void DebugPanel::Navigate(const std::string& url) { 133 void DebugPanel::Navigate(const std::string& url) {
131 navigation::NavigationDetailsPtr details( 134 navigation::NavigationDetailsPtr details(
132 navigation::NavigationDetails::New()); 135 navigation::NavigationDetails::New());
133 details->url = url; 136 details->url = url;
134 delegate_->RequestNavigate(node_->id(), navigation::NEW_NODE, details.Pass()); 137 delegate_->RequestNavigate(node_->id(), navigation::NEW_NODE, details.Pass());
135 } 138 }
136 139
140 void DebugPanel::OnNodeBoundsChanged(view_manager::Node* node,
141 const gfx::Rect& /*old_bounds*/,
142 const gfx::Rect& /*new_bounds*/) {
143 widget_->SetBounds(gfx::Rect(node->bounds().size()));
144 contents_view_->Layout();
145 }
146
147
137 } // namespace examples 148 } // namespace examples
138 } // namespace mojo 149 } // namespace mojo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698