OLD | NEW |
---|---|
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 "ui/aura_shell/shell.h" | 5 #include "ui/aura_shell/shell.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "ui/aura/aura_switches.h" | 9 #include "ui/aura/aura_switches.h" |
10 #include "ui/aura/desktop.h" | 10 #include "ui/aura/desktop.h" |
11 #include "ui/aura/event.h" | |
11 #include "ui/aura/screen_aura.h" | 12 #include "ui/aura/screen_aura.h" |
12 #include "ui/aura/toplevel_window_container.h" | 13 #include "ui/aura/toplevel_window_container.h" |
13 #include "ui/aura/window.h" | 14 #include "ui/aura/window.h" |
14 #include "ui/aura/window_types.h" | 15 #include "ui/aura/window_types.h" |
15 #include "ui/aura_shell/default_container_event_filter.h" | 16 #include "ui/aura_shell/default_container_event_filter.h" |
16 #include "ui/aura_shell/default_container_layout_manager.h" | 17 #include "ui/aura_shell/default_container_layout_manager.h" |
17 #include "ui/aura_shell/desktop_layout_manager.h" | 18 #include "ui/aura_shell/desktop_layout_manager.h" |
18 #include "ui/aura_shell/launcher/launcher.h" | 19 #include "ui/aura_shell/launcher/launcher.h" |
19 #include "ui/aura_shell/shell_delegate.h" | 20 #include "ui/aura_shell/shell_delegate.h" |
20 #include "ui/aura_shell/shell_factory.h" | 21 #include "ui/aura_shell/shell_factory.h" |
21 #include "ui/aura_shell/shell_window_ids.h" | 22 #include "ui/aura_shell/shell_window_ids.h" |
22 #include "ui/aura_shell/workspace/workspace_controller.h" | 23 #include "ui/aura_shell/workspace/workspace_controller.h" |
24 #include "ui/base/dragdrop/os_exchange_data_provider_aura.h" | |
23 #include "ui/gfx/compositor/layer.h" | 25 #include "ui/gfx/compositor/layer.h" |
24 #include "ui/gfx/compositor/layer_animator.h" | 26 #include "ui/gfx/compositor/layer_animator.h" |
27 #include "views/controls/image_view.h" | |
25 #include "views/widget/native_widget_aura.h" | 28 #include "views/widget/native_widget_aura.h" |
26 #include "views/widget/widget.h" | 29 #include "views/widget/widget.h" |
27 | 30 |
28 namespace aura_shell { | 31 namespace aura_shell { |
29 | 32 |
30 namespace { | 33 namespace { |
31 | 34 |
32 // The right/left margin of work area in the screen. | 35 // The right/left margin of work area in the screen. |
33 const int kWorkAreaHorizontalMargin = 15; | 36 const int kWorkAreaHorizontalMargin = 15; |
34 | 37 |
(...skipping 28 matching lines...) Expand all Loading... | |
63 | 66 |
64 aura::Window* status_container = new aura::Window(NULL); | 67 aura::Window* status_container = new aura::Window(NULL); |
65 status_container->set_id(internal::kShellWindowId_StatusContainer); | 68 status_container->set_id(internal::kShellWindowId_StatusContainer); |
66 containers->push_back(status_container); | 69 containers->push_back(status_container); |
67 | 70 |
68 aura::Window* menu_container = new aura::Window(NULL); | 71 aura::Window* menu_container = new aura::Window(NULL); |
69 menu_container->set_id(internal::kShellWindowId_MenusAndTooltipsContainer); | 72 menu_container->set_id(internal::kShellWindowId_MenusAndTooltipsContainer); |
70 containers->push_back(menu_container); | 73 containers->push_back(menu_container); |
71 } | 74 } |
72 | 75 |
76 | |
77 Widget* CreateDragWidget() { | |
78 Widget* drag_widget = new Widget; | |
79 Widget::InitParams params; | |
80 params.type = Widget::InitParams::TYPE_TOOLTIP; | |
Ben Goodger (Google)
2011/11/07 20:33:36
I fear overloading types like this. It's not actua
varunjain
2011/11/08 21:59:35
My intention was to put it in the same container a
| |
81 params.keep_on_top = true; | |
82 params.accept_events = false; | |
83 params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; | |
84 drag_widget->Init(params); | |
85 drag_widget->SetOpacity(0xFF); | |
86 return drag_widget; | |
87 } | |
88 | |
73 } // namespace | 89 } // namespace |
74 | 90 |
75 // static | 91 // static |
76 Shell* Shell::instance_ = NULL; | 92 Shell* Shell::instance_ = NULL; |
77 | 93 |
78 //////////////////////////////////////////////////////////////////////////////// | 94 //////////////////////////////////////////////////////////////////////////////// |
79 // Shell, public: | 95 // Shell, public: |
80 | 96 |
81 Shell::Shell() | 97 Shell::Shell() |
82 : ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)) { | 98 : ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)), |
99 drag_data_(NULL), | |
100 drag_widget_(NULL) { | |
83 aura::Desktop::GetInstance()->SetDelegate(this); | 101 aura::Desktop::GetInstance()->SetDelegate(this); |
84 } | 102 } |
85 | 103 |
86 Shell::~Shell() { | 104 Shell::~Shell() { |
87 } | 105 } |
88 | 106 |
89 // static | 107 // static |
90 Shell* Shell::GetInstance() { | 108 Shell* Shell::GetInstance() { |
91 if (!instance_) { | 109 if (!instance_) { |
92 instance_ = new Shell; | 110 instance_ = new Shell; |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
189 parent->AddChild(window); | 207 parent->AddChild(window); |
190 } | 208 } |
191 | 209 |
192 aura::Window* Shell::GetTopmostWindowToActivate(aura::Window* ignore) const { | 210 aura::Window* Shell::GetTopmostWindowToActivate(aura::Window* ignore) const { |
193 const aura::ToplevelWindowContainer* container = | 211 const aura::ToplevelWindowContainer* container = |
194 GetContainer(internal::kShellWindowId_DefaultContainer)-> | 212 GetContainer(internal::kShellWindowId_DefaultContainer)-> |
195 AsToplevelWindowContainer(); | 213 AsToplevelWindowContainer(); |
196 return container->GetTopmostWindowToActivate(ignore); | 214 return container->GetTopmostWindowToActivate(ignore); |
197 } | 215 } |
198 | 216 |
217 aura::DragDropController* Shell::GetDragDropController() const { | |
218 #if defined(OS_WIN) | |
219 return NULL; | |
Ben Goodger (Google)
2011/11/07 20:33:36
why?
varunjain
2011/11/08 21:59:35
Done.
| |
220 #else | |
221 return const_cast<aura_shell::Shell*>(this); | |
222 #endif | |
223 } | |
224 | |
225 void Shell::StartDragAndDrop(const ui::OSExchangeData& data, | |
226 int operation, | |
227 const gfx::Point& location) { | |
228 #if !defined(OS_WIN) | |
Ben Goodger (Google)
2011/11/07 20:33:36
why?
varunjain
2011/11/08 21:59:35
Done.
| |
229 DCHECK(drag_data_ == NULL); | |
230 DCHECK(drag_widget_.get() == NULL); | |
231 drag_data_ = &data; | |
232 drag_widget_.reset(CreateDragWidget()); | |
233 const ui::OSExchangeDataProviderAura& provider = | |
234 static_cast<const ui::OSExchangeDataProviderAura&>(data.provider()); | |
235 | |
236 views::ImageView* image_view = new views::ImageView(); | |
237 image_view->SetImage(provider.drag_image()); | |
238 drag_widget_->SetContentsView(image_view); | |
239 drag_widget_->SetBounds(gfx::Rect(location, | |
240 image_view->GetPreferredSize())); | |
241 drag_widget_->Show(); | |
242 #endif | |
243 } | |
244 | |
245 void Shell::DragUpdate(const aura::MouseEvent& event) { | |
246 #if !defined(OS_WIN) | |
Ben Goodger (Google)
2011/11/07 20:33:36
why?
varunjain
2011/11/08 21:59:35
Done.
| |
247 // TODO(varunjain): forward drag update to the window under cursor: | |
248 aura::Window* window = aura::Desktop::GetInstance()-> | |
249 GetEventHandlerForPoint(event.location()); | |
250 // window->DragUpdate(data, event); | |
251 | |
252 DCHECK(drag_widget_.get()); | |
253 if (drag_widget_->IsVisible()) { | |
254 gfx::Rect bounds = drag_widget_->GetClientAreaScreenBounds(); | |
255 bounds.set_origin(event.location()); | |
256 drag_widget_->SetBounds(bounds); | |
257 } | |
258 NOTIMPLEMENTED(); | |
259 #endif | |
260 } | |
261 | |
262 void Shell::Drop(const aura::MouseEvent& event) { | |
263 #if !defined(OS_WIN) | |
Ben Goodger (Google)
2011/11/07 20:33:36
etc
varunjain
2011/11/08 21:59:35
Done.
| |
264 // TODO(varunjain): forward drop event to the window under cursor | |
265 aura::Window* window = aura::Desktop::GetInstance()-> | |
266 GetEventHandlerForPoint(event.location()); | |
267 // if (window->CanDrop(data, event)) | |
268 // window->Drop(data, event); | |
269 // else | |
270 // Do drag widget flying back animation | |
271 drag_widget_->Hide(); | |
272 drag_widget_.reset(); | |
273 drag_data_ = NULL; | |
274 NOTIMPLEMENTED(); | |
275 #endif | |
276 } | |
277 | |
199 } // namespace aura_shell | 278 } // namespace aura_shell |
OLD | NEW |