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::SetVisible(bool visible) { | |
Ben Goodger (Google)
2011/11/16 00:13:20
This feels weird. In general I dislike overriding.
varunjain
2011/11/16 20:30:15
Done.
| |
51 // We simply show/hide the container widget. | |
52 if (visible != widget_->IsVisible()) { | |
53 if (visible) | |
54 widget_->Show(); | |
55 else | |
56 widget_->Hide(); | |
57 } | |
58 View::SetVisible(visible); | |
59 } | |
60 | |
61 } // namespace internal | |
62 } // namespace aura_shell | |
OLD | NEW |