OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "ui/aura_shell/drag_image_view.h" |
| 6 |
| 7 #include "views/widget/widget.h" |
| 8 |
| 9 namespace aura_shell { |
| 10 namespace internal { |
| 11 |
| 12 namespace { |
| 13 using views::Widget; |
| 14 |
| 15 Widget* CreateDragWidget() { |
| 16 Widget* drag_widget = new Widget; |
| 17 Widget::InitParams params; |
| 18 params.type = Widget::InitParams::TYPE_TOOLTIP; |
| 19 params.keep_on_top = true; |
| 20 params.accept_events = false; |
| 21 params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; |
| 22 params.transparent = true; |
| 23 drag_widget->Init(params); |
| 24 drag_widget->SetOpacity(0xFF); |
| 25 return drag_widget; |
| 26 } |
| 27 } |
| 28 |
| 29 DragImageView::DragImageView() : views::ImageView() { |
| 30 widget_.reset(CreateDragWidget()); |
| 31 widget_->SetContentsView(this); |
| 32 widget_->SetAlwaysOnTop(true); |
| 33 |
| 34 // We are owned by the DragDropController. |
| 35 set_parent_owned(false); |
| 36 } |
| 37 |
| 38 DragImageView::~DragImageView() { |
| 39 widget_->Hide(); |
| 40 } |
| 41 |
| 42 void DragImageView::SetScreenBounds(const gfx::Rect& bounds) { |
| 43 widget_->SetBounds(bounds); |
| 44 } |
| 45 |
| 46 void DragImageView::SetScreenPosition(const gfx::Point& position) { |
| 47 widget_->SetBounds(gfx::Rect(position, GetPreferredSize())); |
| 48 } |
| 49 |
| 50 void DragImageView::SetWidgetVisible(bool visible) { |
| 51 if (visible != widget_->IsVisible()) { |
| 52 if (visible) |
| 53 widget_->Show(); |
| 54 else |
| 55 widget_->Hide(); |
| 56 } |
| 57 } |
| 58 |
| 59 } // namespace internal |
| 60 } // namespace aura_shell |
OLD | NEW |