| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 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_skia.h" | 10 #include "ui/gfx/canvas_skia.h" |
| 11 #include "views/widget/widget.h" | 11 #include "views/widget/widget.h" |
| 12 | 12 |
| 13 #if defined(OS_WIN) | 13 #if defined(USE_AURA) |
| 14 #include "views/widget/native_widget_aura.h" |
| 15 #elif defined(OS_WIN) |
| 14 #include "views/widget/native_widget_win.h" | 16 #include "views/widget/native_widget_win.h" |
| 15 #elif defined(TOOLKIT_USES_GTK) | 17 #elif defined(TOOLKIT_USES_GTK) |
| 16 #include "views/widget/native_widget_gtk.h" | 18 #include "views/widget/native_widget_gtk.h" |
| 17 #endif | 19 #endif |
| 18 | 20 |
| 19 static const int kTransparentAlpha = 200; | 21 static const int kTransparentAlpha = 200; |
| 20 static const int kOpaqueAlpha = 255; | 22 static const int kOpaqueAlpha = 255; |
| 21 static const int kDragFrameBorderSize = 2; | 23 static const int kDragFrameBorderSize = 2; |
| 22 static const int kTwiceDragFrameBorderSize = 2 * kDragFrameBorderSize; | 24 static const int kTwiceDragFrameBorderSize = 2 * kDragFrameBorderSize; |
| 23 static const float kScalingFactor = 0.5; | 25 static const float kScalingFactor = 0.5; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 40 set_parent_owned(false); | 42 set_parent_owned(false); |
| 41 | 43 |
| 42 container_.reset(new views::Widget); | 44 container_.reset(new views::Widget); |
| 43 views::Widget::InitParams params(views::Widget::InitParams::TYPE_POPUP); | 45 views::Widget::InitParams params(views::Widget::InitParams::TYPE_POPUP); |
| 44 params.transparent = true; | 46 params.transparent = true; |
| 45 params.keep_on_top = true; | 47 params.keep_on_top = true; |
| 46 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; | 48 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; |
| 47 params.bounds = gfx::Rect(PreferredContainerSize()); | 49 params.bounds = gfx::Rect(PreferredContainerSize()); |
| 48 container_->Init(params); | 50 container_->Init(params); |
| 49 container_->SetContentsView(this); | 51 container_->SetContentsView(this); |
| 50 #if defined(OS_WIN) | 52 #if defined(OS_WIN) && !defined(USE_AURA) |
| 51 static_cast<views::NativeWidgetWin*>(container_->native_widget())-> | 53 static_cast<views::NativeWidgetWin*>(container_->native_widget())-> |
| 52 set_can_update_layered_window(false); | 54 set_can_update_layered_window(false); |
| 53 | 55 |
| 54 BOOL drag; | 56 BOOL drag; |
| 55 if ((::SystemParametersInfo(SPI_GETDRAGFULLWINDOWS, 0, &drag, 0) != 0) && | 57 if ((::SystemParametersInfo(SPI_GETDRAGFULLWINDOWS, 0, &drag, 0) != 0) && |
| 56 (drag == FALSE)) { | 58 (drag == FALSE)) { |
| 57 show_contents_on_drag_ = false; | 59 show_contents_on_drag_ = false; |
| 58 } | 60 } |
| 59 #endif | 61 #endif |
| 60 container_->SetOpacity(kTransparentAlpha); | 62 container_->SetOpacity(kTransparentAlpha); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 73 // On RTL locales, a dragged tab (when it is not attached to a tab strip) | 75 // On RTL locales, a dragged tab (when it is not attached to a tab strip) |
| 74 // is rendered using a right-to-left orientation so we should calculate the | 76 // is rendered using a right-to-left orientation so we should calculate the |
| 75 // window position differently. | 77 // window position differently. |
| 76 gfx::Size ps = GetPreferredSize(); | 78 gfx::Size ps = GetPreferredSize(); |
| 77 x = screen_point.x() + ScaleValue(mouse_tab_offset_.x() - ps.width()); | 79 x = screen_point.x() + ScaleValue(mouse_tab_offset_.x() - ps.width()); |
| 78 } else { | 80 } else { |
| 79 x = screen_point.x() - ScaleValue(mouse_tab_offset_.x()); | 81 x = screen_point.x() - ScaleValue(mouse_tab_offset_.x()); |
| 80 } | 82 } |
| 81 int y = screen_point.y() - ScaleValue(mouse_tab_offset_.y()); | 83 int y = screen_point.y() - ScaleValue(mouse_tab_offset_.y()); |
| 82 | 84 |
| 83 #if defined(OS_WIN) | 85 #if defined(OS_WIN) && !defined(USE_AURA) |
| 84 // TODO(beng): make this cross-platform | 86 // TODO(beng): make this cross-platform |
| 85 int show_flags = container_->IsVisible() ? SWP_NOZORDER : SWP_SHOWWINDOW; | 87 int show_flags = container_->IsVisible() ? SWP_NOZORDER : SWP_SHOWWINDOW; |
| 86 SetWindowPos(container_->GetNativeView(), HWND_TOP, x, y, 0, 0, | 88 SetWindowPos(container_->GetNativeView(), HWND_TOP, x, y, 0, 0, |
| 87 SWP_NOSIZE | SWP_NOACTIVATE | show_flags); | 89 SWP_NOSIZE | SWP_NOACTIVATE | show_flags); |
| 88 #else | 90 #else |
| 89 gfx::Rect bounds = container_->GetWindowScreenBounds(); | 91 gfx::Rect bounds = container_->GetWindowScreenBounds(); |
| 90 container_->SetBounds(gfx::Rect(x, y, bounds.width(), bounds.height())); | 92 container_->SetBounds(gfx::Rect(x, y, bounds.width(), bounds.height())); |
| 91 if (!container_->IsVisible()) | 93 if (!container_->IsVisible()) |
| 92 container_->Show(); | 94 container_->Show(); |
| 93 #endif | 95 #endif |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 187 } | 189 } |
| 188 | 190 |
| 189 gfx::Size DraggedTabView::PreferredContainerSize() { | 191 gfx::Size DraggedTabView::PreferredContainerSize() { |
| 190 gfx::Size ps = GetPreferredSize(); | 192 gfx::Size ps = GetPreferredSize(); |
| 191 return gfx::Size(ScaleValue(ps.width()), ScaleValue(ps.height())); | 193 return gfx::Size(ScaleValue(ps.width()), ScaleValue(ps.height())); |
| 192 } | 194 } |
| 193 | 195 |
| 194 int DraggedTabView::ScaleValue(int value) { | 196 int DraggedTabView::ScaleValue(int value) { |
| 195 return static_cast<int>(value * kScalingFactor); | 197 return static_cast<int>(value * kScalingFactor); |
| 196 } | 198 } |
| OLD | NEW |