| 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 "chrome/browser/ui/views/tabs/dragged_tab_view.h" | 5 #include "chrome/browser/ui/views/tabs/dragged_tab_view.h" |
| 6 | 6 |
| 7 #include "base/stl_util.h" | 7 #include "base/stl_util.h" |
| 8 #include "chrome/browser/ui/views/tabs/native_view_photobooth.h" | 8 #include "chrome/browser/ui/views/tabs/native_view_photobooth.h" |
| 9 #include "third_party/skia/include/core/SkShader.h" | 9 #include "third_party/skia/include/core/SkShader.h" |
| 10 #include "ui/gfx/canvas.h" | 10 #include "ui/gfx/canvas.h" |
| 11 #include "ui/views/widget/widget.h" | 11 #include "ui/views/widget/widget.h" |
| 12 | 12 |
| 13 #if defined(USE_AURA) | 13 #if defined(USE_AURA) |
| 14 #include "ui/views/widget/native_widget_aura.h" | 14 #include "ui/views/widget/native_widget_aura.h" |
| 15 #elif defined(OS_WIN) | 15 #elif defined(OS_WIN) |
| 16 #include "ui/base/win/dpi.h" |
| 16 #include "ui/views/widget/native_widget_win.h" | 17 #include "ui/views/widget/native_widget_win.h" |
| 17 #endif | 18 #endif |
| 18 | 19 |
| 19 static const int kTransparentAlpha = 200; | 20 static const int kTransparentAlpha = 200; |
| 20 static const int kOpaqueAlpha = 255; | 21 static const int kOpaqueAlpha = 255; |
| 21 static const int kDragFrameBorderSize = 2; | 22 static const int kDragFrameBorderSize = 2; |
| 22 static const int kTwiceDragFrameBorderSize = 2 * kDragFrameBorderSize; | 23 static const int kTwiceDragFrameBorderSize = 2 * kDragFrameBorderSize; |
| 23 static const float kScalingFactor = 0.5; | 24 static const float kScalingFactor = 0.5; |
| 24 static const SkColor kDraggedTabBorderColor = SkColorSetRGB(103, 129, 162); | 25 static const SkColor kDraggedTabBorderColor = SkColorSetRGB(103, 129, 162); |
| 25 | 26 |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 // is rendered using a right-to-left orientation so we should calculate the | 75 // is rendered using a right-to-left orientation so we should calculate the |
| 75 // window position differently. | 76 // window position differently. |
| 76 gfx::Size ps = GetPreferredSize(); | 77 gfx::Size ps = GetPreferredSize(); |
| 77 x = screen_point.x() + ScaleValue(mouse_tab_offset_.x() - ps.width()); | 78 x = screen_point.x() + ScaleValue(mouse_tab_offset_.x() - ps.width()); |
| 78 } else { | 79 } else { |
| 79 x = screen_point.x() - ScaleValue(mouse_tab_offset_.x()); | 80 x = screen_point.x() - ScaleValue(mouse_tab_offset_.x()); |
| 80 } | 81 } |
| 81 int y = screen_point.y() - ScaleValue(mouse_tab_offset_.y()); | 82 int y = screen_point.y() - ScaleValue(mouse_tab_offset_.y()); |
| 82 | 83 |
| 83 #if defined(OS_WIN) && !defined(USE_AURA) | 84 #if defined(OS_WIN) && !defined(USE_AURA) |
| 85 double scale = ui::win::GetDeviceScaleFactor(); |
| 86 x = static_cast<int>(scale * screen_point.x()); |
| 87 y = static_cast<int>(scale * screen_point.y()); |
| 84 // TODO(beng): make this cross-platform | 88 // TODO(beng): make this cross-platform |
| 85 int show_flags = container_->IsVisible() ? SWP_NOZORDER : SWP_SHOWWINDOW; | 89 int show_flags = container_->IsVisible() ? SWP_NOZORDER : SWP_SHOWWINDOW; |
| 86 SetWindowPos(container_->GetNativeView(), HWND_TOP, x, y, 0, 0, | 90 SetWindowPos(container_->GetNativeView(), HWND_TOP, x, y, 0, 0, |
| 87 SWP_NOSIZE | SWP_NOACTIVATE | show_flags); | 91 SWP_NOSIZE | SWP_NOACTIVATE | show_flags); |
| 88 #else | 92 #else |
| 89 gfx::Rect bounds = container_->GetWindowBoundsInScreen(); | 93 gfx::Rect bounds = container_->GetWindowBoundsInScreen(); |
| 90 container_->SetBounds(gfx::Rect(x, y, bounds.width(), bounds.height())); | 94 container_->SetBounds(gfx::Rect(x, y, bounds.width(), bounds.height())); |
| 91 if (!container_->IsVisible()) | 95 if (!container_->IsVisible()) |
| 92 container_->Show(); | 96 container_->Show(); |
| 93 #endif | 97 #endif |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 179 } | 183 } |
| 180 | 184 |
| 181 gfx::Size DraggedTabView::PreferredContainerSize() { | 185 gfx::Size DraggedTabView::PreferredContainerSize() { |
| 182 gfx::Size ps = GetPreferredSize(); | 186 gfx::Size ps = GetPreferredSize(); |
| 183 return gfx::Size(ScaleValue(ps.width()), ScaleValue(ps.height())); | 187 return gfx::Size(ScaleValue(ps.width()), ScaleValue(ps.height())); |
| 184 } | 188 } |
| 185 | 189 |
| 186 int DraggedTabView::ScaleValue(int value) { | 190 int DraggedTabView::ScaleValue(int value) { |
| 187 return static_cast<int>(value * kScalingFactor); | 191 return static_cast<int>(value * kScalingFactor); |
| 188 } | 192 } |
| OLD | NEW |