blob: afc4ca71c634f7eb75337d0d914581d827cb1d07 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
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 "ui/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
|