| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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/views/tabs/dragged_tab_view.h" | 5 #include "chrome/browser/views/tabs/dragged_tab_view.h" |
| 6 | 6 |
| 7 #include "app/gfx/chrome_canvas.h" | 7 #include "app/gfx/canvas.h" |
| 8 #include "chrome/browser/tab_contents/tab_contents.h" | 8 #include "chrome/browser/tab_contents/tab_contents.h" |
| 9 #include "chrome/browser/tabs/tab_strip_model.h" | 9 #include "chrome/browser/tabs/tab_strip_model.h" |
| 10 #include "chrome/browser/views/tabs/hwnd_photobooth.h" | 10 #include "chrome/browser/views/tabs/hwnd_photobooth.h" |
| 11 #include "chrome/browser/views/tabs/tab_renderer.h" | 11 #include "chrome/browser/views/tabs/tab_renderer.h" |
| 12 #include "third_party/skia/include/core/SkShader.h" | 12 #include "third_party/skia/include/core/SkShader.h" |
| 13 #include "views/widget/widget_win.h" | 13 #include "views/widget/widget_win.h" |
| 14 | 14 |
| 15 const int kTransparentAlpha = 200; | 15 const int kTransparentAlpha = 200; |
| 16 const int kOpaqueAlpha = 255; | 16 const int kOpaqueAlpha = 255; |
| 17 const int kDragFrameBorderSize = 2; | 17 const int kDragFrameBorderSize = 2; |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 animation_callback_->Run(); | 141 animation_callback_->Run(); |
| 142 } | 142 } |
| 143 | 143 |
| 144 void DraggedTabView::AnimationCanceled(const Animation* animation) { | 144 void DraggedTabView::AnimationCanceled(const Animation* animation) { |
| 145 AnimationEnded(animation); | 145 AnimationEnded(animation); |
| 146 } | 146 } |
| 147 | 147 |
| 148 /////////////////////////////////////////////////////////////////////////////// | 148 /////////////////////////////////////////////////////////////////////////////// |
| 149 // DraggedTabView, views::View overrides: | 149 // DraggedTabView, views::View overrides: |
| 150 | 150 |
| 151 void DraggedTabView::Paint(ChromeCanvas* canvas) { | 151 void DraggedTabView::Paint(gfx::Canvas* canvas) { |
| 152 if (!show_contents_on_drag_) { | 152 if (!show_contents_on_drag_) { |
| 153 PaintFocusRect(canvas); | 153 PaintFocusRect(canvas); |
| 154 } else if (attached_) { | 154 } else if (attached_) { |
| 155 PaintAttachedTab(canvas); | 155 PaintAttachedTab(canvas); |
| 156 } else { | 156 } else { |
| 157 PaintDetachedView(canvas); | 157 PaintDetachedView(canvas); |
| 158 } | 158 } |
| 159 } | 159 } |
| 160 | 160 |
| 161 void DraggedTabView::Layout() { | 161 void DraggedTabView::Layout() { |
| (...skipping 16 matching lines...) Expand all Loading... |
| 178 int width = std::max(attached_tab_size_.width(), contents_size_.width()) + | 178 int width = std::max(attached_tab_size_.width(), contents_size_.width()) + |
| 179 kTwiceDragFrameBorderSize; | 179 kTwiceDragFrameBorderSize; |
| 180 int height = attached_tab_size_.height() + kDragFrameBorderSize + | 180 int height = attached_tab_size_.height() + kDragFrameBorderSize + |
| 181 contents_size_.height(); | 181 contents_size_.height(); |
| 182 return gfx::Size(width, height); | 182 return gfx::Size(width, height); |
| 183 } | 183 } |
| 184 | 184 |
| 185 //////////////////////////////////////////////////////////////////////////////// | 185 //////////////////////////////////////////////////////////////////////////////// |
| 186 // DraggedTabView, private: | 186 // DraggedTabView, private: |
| 187 | 187 |
| 188 void DraggedTabView::PaintAttachedTab(ChromeCanvas* canvas) { | 188 void DraggedTabView::PaintAttachedTab(gfx::Canvas* canvas) { |
| 189 renderer_->ProcessPaint(canvas); | 189 renderer_->ProcessPaint(canvas); |
| 190 } | 190 } |
| 191 | 191 |
| 192 void DraggedTabView::PaintDetachedView(ChromeCanvas* canvas) { | 192 void DraggedTabView::PaintDetachedView(gfx::Canvas* canvas) { |
| 193 gfx::Size ps = GetPreferredSize(); | 193 gfx::Size ps = GetPreferredSize(); |
| 194 ChromeCanvas scale_canvas(ps.width(), ps.height(), false); | 194 gfx::Canvas scale_canvas(ps.width(), ps.height(), false); |
| 195 SkBitmap& bitmap_device = const_cast<SkBitmap&>( | 195 SkBitmap& bitmap_device = const_cast<SkBitmap&>( |
| 196 scale_canvas.getTopPlatformDevice().accessBitmap(true)); | 196 scale_canvas.getTopPlatformDevice().accessBitmap(true)); |
| 197 bitmap_device.eraseARGB(0, 0, 0, 0); | 197 bitmap_device.eraseARGB(0, 0, 0, 0); |
| 198 | 198 |
| 199 scale_canvas.FillRectInt(kDraggedTabBorderColor, 0, | 199 scale_canvas.FillRectInt(kDraggedTabBorderColor, 0, |
| 200 attached_tab_size_.height() - kDragFrameBorderSize, | 200 attached_tab_size_.height() - kDragFrameBorderSize, |
| 201 ps.width(), ps.height() - attached_tab_size_.height()); | 201 ps.width(), ps.height() - attached_tab_size_.height()); |
| 202 int image_x = kDragFrameBorderSize; | 202 int image_x = kDragFrameBorderSize; |
| 203 int image_y = attached_tab_size_.height(); | 203 int image_y = attached_tab_size_.height(); |
| 204 int image_w = ps.width() - kTwiceDragFrameBorderSize; | 204 int image_w = ps.width() - kTwiceDragFrameBorderSize; |
| (...skipping 24 matching lines...) Expand all Loading... |
| 229 bitmap_shader->unref(); | 229 bitmap_shader->unref(); |
| 230 | 230 |
| 231 SkRect rc; | 231 SkRect rc; |
| 232 rc.fLeft = 0; | 232 rc.fLeft = 0; |
| 233 rc.fTop = 0; | 233 rc.fTop = 0; |
| 234 rc.fRight = SkIntToScalar(ps.width()); | 234 rc.fRight = SkIntToScalar(ps.width()); |
| 235 rc.fBottom = SkIntToScalar(ps.height()); | 235 rc.fBottom = SkIntToScalar(ps.height()); |
| 236 canvas->drawRect(rc, paint); | 236 canvas->drawRect(rc, paint); |
| 237 } | 237 } |
| 238 | 238 |
| 239 void DraggedTabView::PaintFocusRect(ChromeCanvas* canvas) { | 239 void DraggedTabView::PaintFocusRect(gfx::Canvas* canvas) { |
| 240 gfx::Size ps = GetPreferredSize(); | 240 gfx::Size ps = GetPreferredSize(); |
| 241 canvas->DrawFocusRect(0, 0, | 241 canvas->DrawFocusRect(0, 0, |
| 242 static_cast<int>(ps.width() * kScalingFactor), | 242 static_cast<int>(ps.width() * kScalingFactor), |
| 243 static_cast<int>(ps.height() * kScalingFactor)); | 243 static_cast<int>(ps.height() * kScalingFactor)); |
| 244 } | 244 } |
| 245 | 245 |
| 246 void DraggedTabView::ResizeContainer() { | 246 void DraggedTabView::ResizeContainer() { |
| 247 gfx::Size ps = GetPreferredSize(); | 247 gfx::Size ps = GetPreferredSize(); |
| 248 SetWindowPos(container_->GetNativeView(), HWND_TOPMOST, 0, 0, | 248 SetWindowPos(container_->GetNativeView(), HWND_TOPMOST, 0, 0, |
| 249 ScaleValue(ps.width()), ScaleValue(ps.height()), | 249 ScaleValue(ps.width()), ScaleValue(ps.height()), |
| 250 SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE); | 250 SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE); |
| 251 } | 251 } |
| 252 | 252 |
| 253 int DraggedTabView::ScaleValue(int value) { | 253 int DraggedTabView::ScaleValue(int value) { |
| 254 return attached_ ? value : static_cast<int>(value * kScalingFactor); | 254 return attached_ ? value : static_cast<int>(value * kScalingFactor); |
| 255 } | 255 } |
| OLD | NEW |