| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ash/drag_drop/drag_image_view.h" | 5 #include "ash/drag_drop/drag_image_view.h" |
| 6 | 6 |
| 7 #include "skia/ext/image_operations.h" | 7 #include "skia/ext/image_operations.h" |
| 8 #include "ui/aura/window.h" | 8 #include "ui/aura/window.h" |
| 9 #include "ui/base/resource/resource_bundle.h" | 9 #include "ui/base/resource/resource_bundle.h" |
| 10 #include "ui/compositor/dip_util.h" | 10 #include "ui/compositor/dip_util.h" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 Widget* CreateDragWidget(gfx::NativeView context) { | 21 Widget* CreateDragWidget(gfx::NativeView context) { |
| 22 Widget* drag_widget = new Widget; | 22 Widget* drag_widget = new Widget; |
| 23 Widget::InitParams params; | 23 Widget::InitParams params; |
| 24 params.type = Widget::InitParams::TYPE_TOOLTIP; | 24 params.type = Widget::InitParams::TYPE_TOOLTIP; |
| 25 params.keep_on_top = true; | 25 params.keep_on_top = true; |
| 26 params.context = context; | 26 params.context = context; |
| 27 params.accept_events = false; | 27 params.accept_events = false; |
| 28 params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; | 28 params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; |
| 29 params.opacity = Widget::InitParams::TRANSLUCENT_WINDOW; | 29 params.opacity = Widget::InitParams::TRANSLUCENT_WINDOW; |
| 30 drag_widget->Init(params); | 30 drag_widget->Init(params); |
| 31 drag_widget->SetOpacity(0xFF); | 31 drag_widget->SetOpacity(1.f); |
| 32 drag_widget->GetNativeWindow()->set_owned_by_parent(false); | 32 drag_widget->GetNativeWindow()->set_owned_by_parent(false); |
| 33 drag_widget->GetNativeWindow()->SetName("DragWidget"); | 33 drag_widget->GetNativeWindow()->SetName("DragWidget"); |
| 34 SetShadowType(drag_widget->GetNativeView(), wm::SHADOW_TYPE_NONE); | 34 SetShadowType(drag_widget->GetNativeView(), wm::SHADOW_TYPE_NONE); |
| 35 return drag_widget; | 35 return drag_widget; |
| 36 } | 36 } |
| 37 } | 37 } |
| 38 | 38 |
| 39 DragImageView::DragImageView(gfx::NativeView context, | 39 DragImageView::DragImageView(gfx::NativeView context, |
| 40 ui::DragDropTypes::DragEventSource event_source) | 40 ui::DragDropTypes::DragEventSource event_source) |
| 41 : views::ImageView(), | 41 : views::ImageView(), |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 const gfx::Point& position) { | 92 const gfx::Point& position) { |
| 93 if (touch_drag_operation_indicator_position_ == position) | 93 if (touch_drag_operation_indicator_position_ == position) |
| 94 return; | 94 return; |
| 95 touch_drag_operation_indicator_position_ = position; | 95 touch_drag_operation_indicator_position_ = position; |
| 96 SchedulePaint(); | 96 SchedulePaint(); |
| 97 } | 97 } |
| 98 | 98 |
| 99 void DragImageView::SetOpacity(float visibility) { | 99 void DragImageView::SetOpacity(float visibility) { |
| 100 DCHECK_GE(visibility, 0.0f); | 100 DCHECK_GE(visibility, 0.0f); |
| 101 DCHECK_LE(visibility, 1.0f); | 101 DCHECK_LE(visibility, 1.0f); |
| 102 widget_->SetOpacity(static_cast<int>(0xff * visibility)); | 102 widget_->SetOpacity(visibility); |
| 103 } | 103 } |
| 104 | 104 |
| 105 void DragImageView::OnPaint(gfx::Canvas* canvas) { | 105 void DragImageView::OnPaint(gfx::Canvas* canvas) { |
| 106 if (GetImage().isNull()) | 106 if (GetImage().isNull()) |
| 107 return; | 107 return; |
| 108 | 108 |
| 109 // |widget_size_| is in DIP. ImageSkia::size() also returns the size in DIP. | 109 // |widget_size_| is in DIP. ImageSkia::size() also returns the size in DIP. |
| 110 if (GetImage().size() == widget_size_) { | 110 if (GetImage().size() == widget_size_) { |
| 111 canvas->DrawImageInt(GetImage(), 0, 0); | 111 canvas->DrawImageInt(GetImage(), 0, 0); |
| 112 } else { | 112 } else { |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 178 // Enlarge widget if required to fit the drag hint image. | 178 // Enlarge widget if required to fit the drag hint image. |
| 179 if (drag_hint_size.width() > widget_size_.width() || | 179 if (drag_hint_size.width() > widget_size_.width() || |
| 180 drag_hint_size.height() > widget_size_.height()) { | 180 drag_hint_size.height() > widget_size_.height()) { |
| 181 gfx::Size new_widget_size = widget_size_; | 181 gfx::Size new_widget_size = widget_size_; |
| 182 new_widget_size.SetToMax(drag_hint_size); | 182 new_widget_size.SetToMax(drag_hint_size); |
| 183 widget_->SetSize(new_widget_size); | 183 widget_->SetSize(new_widget_size); |
| 184 } | 184 } |
| 185 } | 185 } |
| 186 | 186 |
| 187 } // namespace ash | 187 } // namespace ash |
| OLD | NEW |