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

Unified Diff: ui/aura_shell/drag_image_view.cc

Issue 8450018: First shot at implementing drag&drop for Aura (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fixed windows build errors Created 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/aura_shell/drag_image_view.h ('k') | ui/aura_shell/shell.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/aura_shell/drag_image_view.cc
diff --git a/ui/aura_shell/drag_image_view.cc b/ui/aura_shell/drag_image_view.cc
new file mode 100644
index 0000000000000000000000000000000000000000..db807f0a57e0aa8bb56e3be43de25a03668a0c3b
--- /dev/null
+++ b/ui/aura_shell/drag_image_view.cc
@@ -0,0 +1,60 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ui/aura_shell/drag_image_view.h"
+
+#include "views/widget/widget.h"
+
+namespace aura_shell {
+namespace internal {
+
+namespace {
+using views::Widget;
+
+Widget* CreateDragWidget() {
+ Widget* drag_widget = new Widget;
+ Widget::InitParams params;
+ params.type = Widget::InitParams::TYPE_TOOLTIP;
+ params.keep_on_top = true;
+ params.accept_events = false;
+ params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
+ params.transparent = true;
+ drag_widget->Init(params);
+ drag_widget->SetOpacity(0xFF);
+ return drag_widget;
+}
+}
+
+DragImageView::DragImageView() : views::ImageView() {
+ widget_.reset(CreateDragWidget());
+ widget_->SetContentsView(this);
+ widget_->SetAlwaysOnTop(true);
+
+ // We are owned by the DragDropController.
+ set_parent_owned(false);
+}
+
+DragImageView::~DragImageView() {
+ widget_->Hide();
+}
+
+void DragImageView::SetScreenBounds(const gfx::Rect& bounds) {
+ widget_->SetBounds(bounds);
+}
+
+void DragImageView::SetScreenPosition(const gfx::Point& position) {
+ widget_->SetBounds(gfx::Rect(position, GetPreferredSize()));
+}
+
+void DragImageView::SetWidgetVisible(bool visible) {
+ if (visible != widget_->IsVisible()) {
+ if (visible)
+ widget_->Show();
+ else
+ widget_->Hide();
+ }
+}
+
+} // namespace internal
+} // namespace aura_shell
« no previous file with comments | « ui/aura_shell/drag_image_view.h ('k') | ui/aura_shell/shell.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698