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

Side by Side Diff: ash/drag_drop/drag_image_view.cc

Issue 2016203002: Widget opacity goes from 0 to 1, not 0 to 255. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Resync Created 4 years, 6 months 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 unified diff | Download patch
« no previous file with comments | « no previous file | ash/system/user/user_view.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
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
OLDNEW
« no previous file with comments | « no previous file | ash/system/user/user_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698