Chromium Code Reviews| Index: ui/aura_shell/shell.cc |
| diff --git a/ui/aura_shell/shell.cc b/ui/aura_shell/shell.cc |
| index 659bfc8bdf0e353b562504a1da9361e49eba00f3..f76927564e55e5b961d294b784efb5e45becedc9 100644 |
| --- a/ui/aura_shell/shell.cc |
| +++ b/ui/aura_shell/shell.cc |
| @@ -8,6 +8,7 @@ |
| #include "base/command_line.h" |
| #include "ui/aura/aura_switches.h" |
| #include "ui/aura/desktop.h" |
| +#include "ui/aura/event.h" |
| #include "ui/aura/screen_aura.h" |
| #include "ui/aura/toplevel_window_container.h" |
| #include "ui/aura/window.h" |
| @@ -20,8 +21,10 @@ |
| #include "ui/aura_shell/shell_factory.h" |
| #include "ui/aura_shell/shell_window_ids.h" |
| #include "ui/aura_shell/workspace/workspace_controller.h" |
| +#include "ui/base/dragdrop/os_exchange_data_provider_aura.h" |
| #include "ui/gfx/compositor/layer.h" |
| #include "ui/gfx/compositor/layer_animator.h" |
| +#include "views/controls/image_view.h" |
| #include "views/widget/native_widget_aura.h" |
| #include "views/widget/widget.h" |
| @@ -70,6 +73,19 @@ void CreateSpecialContainers(aura::Window::Windows* containers) { |
| containers->push_back(menu_container); |
| } |
| + |
| +Widget* CreateDragWidget() { |
| + Widget* drag_widget = new Widget; |
| + Widget::InitParams params; |
| + 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
|
| + params.keep_on_top = true; |
| + params.accept_events = false; |
| + params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; |
| + drag_widget->Init(params); |
| + drag_widget->SetOpacity(0xFF); |
| + return drag_widget; |
| +} |
| + |
| } // namespace |
| // static |
| @@ -79,7 +95,9 @@ Shell* Shell::instance_ = NULL; |
| // Shell, public: |
| Shell::Shell() |
| - : ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)) { |
| + : ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)), |
| + drag_data_(NULL), |
| + drag_widget_(NULL) { |
| aura::Desktop::GetInstance()->SetDelegate(this); |
| } |
| @@ -196,4 +214,65 @@ aura::Window* Shell::GetTopmostWindowToActivate(aura::Window* ignore) const { |
| return container->GetTopmostWindowToActivate(ignore); |
| } |
| +aura::DragDropController* Shell::GetDragDropController() const { |
| +#if defined(OS_WIN) |
| + return NULL; |
|
Ben Goodger (Google)
2011/11/07 20:33:36
why?
varunjain
2011/11/08 21:59:35
Done.
|
| +#else |
| + return const_cast<aura_shell::Shell*>(this); |
| +#endif |
| +} |
| + |
| +void Shell::StartDragAndDrop(const ui::OSExchangeData& data, |
| + int operation, |
| + const gfx::Point& location) { |
| +#if !defined(OS_WIN) |
|
Ben Goodger (Google)
2011/11/07 20:33:36
why?
varunjain
2011/11/08 21:59:35
Done.
|
| + DCHECK(drag_data_ == NULL); |
| + DCHECK(drag_widget_.get() == NULL); |
| + drag_data_ = &data; |
| + drag_widget_.reset(CreateDragWidget()); |
| + const ui::OSExchangeDataProviderAura& provider = |
| + static_cast<const ui::OSExchangeDataProviderAura&>(data.provider()); |
| + |
| + views::ImageView* image_view = new views::ImageView(); |
| + image_view->SetImage(provider.drag_image()); |
| + drag_widget_->SetContentsView(image_view); |
| + drag_widget_->SetBounds(gfx::Rect(location, |
| + image_view->GetPreferredSize())); |
| + drag_widget_->Show(); |
| +#endif |
| +} |
| + |
| +void Shell::DragUpdate(const aura::MouseEvent& event) { |
| +#if !defined(OS_WIN) |
|
Ben Goodger (Google)
2011/11/07 20:33:36
why?
varunjain
2011/11/08 21:59:35
Done.
|
| + // TODO(varunjain): forward drag update to the window under cursor: |
| + aura::Window* window = aura::Desktop::GetInstance()-> |
| + GetEventHandlerForPoint(event.location()); |
| + // window->DragUpdate(data, event); |
| + |
| + DCHECK(drag_widget_.get()); |
| + if (drag_widget_->IsVisible()) { |
| + gfx::Rect bounds = drag_widget_->GetClientAreaScreenBounds(); |
| + bounds.set_origin(event.location()); |
| + drag_widget_->SetBounds(bounds); |
| + } |
| + NOTIMPLEMENTED(); |
| +#endif |
| +} |
| + |
| +void Shell::Drop(const aura::MouseEvent& event) { |
| +#if !defined(OS_WIN) |
|
Ben Goodger (Google)
2011/11/07 20:33:36
etc
varunjain
2011/11/08 21:59:35
Done.
|
| + // TODO(varunjain): forward drop event to the window under cursor |
| + aura::Window* window = aura::Desktop::GetInstance()-> |
| + GetEventHandlerForPoint(event.location()); |
| + // if (window->CanDrop(data, event)) |
| + // window->Drop(data, event); |
| + // else |
| + // Do drag widget flying back animation |
| + drag_widget_->Hide(); |
| + drag_widget_.reset(); |
| + drag_data_ = NULL; |
| + NOTIMPLEMENTED(); |
| +#endif |
| +} |
| + |
| } // namespace aura_shell |