| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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_controller.h" | 5 #include "chrome/browser/views/tabs/dragged_tab_controller.h" |
| 6 | 6 |
| 7 #include <math.h> | 7 #include <math.h> |
| 8 #include <set> | 8 #include <set> |
| 9 | 9 |
| 10 #include "app/animation.h" | 10 #include "app/animation.h" |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 #include "chrome/browser/views/tabs/base_tab.h" | 23 #include "chrome/browser/views/tabs/base_tab.h" |
| 24 #include "chrome/browser/views/tabs/base_tab_strip.h" | 24 #include "chrome/browser/views/tabs/base_tab_strip.h" |
| 25 #include "chrome/browser/views/tabs/browser_tab_strip_controller.h" | 25 #include "chrome/browser/views/tabs/browser_tab_strip_controller.h" |
| 26 #include "chrome/browser/views/tabs/dragged_tab_view.h" | 26 #include "chrome/browser/views/tabs/dragged_tab_view.h" |
| 27 #include "chrome/browser/views/tabs/native_view_photobooth.h" | 27 #include "chrome/browser/views/tabs/native_view_photobooth.h" |
| 28 #include "chrome/browser/views/tabs/side_tab.h" | 28 #include "chrome/browser/views/tabs/side_tab.h" |
| 29 #include "chrome/browser/views/tabs/side_tab_strip.h" | 29 #include "chrome/browser/views/tabs/side_tab_strip.h" |
| 30 #include "chrome/browser/views/tabs/tab.h" | 30 #include "chrome/browser/views/tabs/tab.h" |
| 31 #include "chrome/browser/views/tabs/tab_strip.h" | 31 #include "chrome/browser/views/tabs/tab_strip.h" |
| 32 #include "chrome/common/notification_service.h" | 32 #include "chrome/common/notification_service.h" |
| 33 #include "gfx/canvas.h" | 33 #include "gfx/canvas_skia.h" |
| 34 #include "grit/theme_resources.h" | 34 #include "grit/theme_resources.h" |
| 35 #include "third_party/skia/include/core/SkBitmap.h" | 35 #include "third_party/skia/include/core/SkBitmap.h" |
| 36 #include "views/event.h" | 36 #include "views/event.h" |
| 37 #include "views/widget/root_view.h" | 37 #include "views/widget/root_view.h" |
| 38 #include "views/widget/widget.h" | 38 #include "views/widget/widget.h" |
| 39 #include "views/window/window.h" | 39 #include "views/window/window.h" |
| 40 | 40 |
| 41 #if defined(OS_WIN) | 41 #if defined(OS_WIN) |
| 42 #include "views/widget/widget_win.h" | 42 #include "views/widget/widget_win.h" |
| 43 #endif | 43 #endif |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 | 78 |
| 79 virtual void PaintBackground(gfx::Canvas* canvas) { | 79 virtual void PaintBackground(gfx::Canvas* canvas) { |
| 80 SkRect outer_rect = { SkIntToScalar(0), SkIntToScalar(0), | 80 SkRect outer_rect = { SkIntToScalar(0), SkIntToScalar(0), |
| 81 SkIntToScalar(width()), | 81 SkIntToScalar(width()), |
| 82 SkIntToScalar(height()) }; | 82 SkIntToScalar(height()) }; |
| 83 | 83 |
| 84 // Fill the background rect. | 84 // Fill the background rect. |
| 85 SkPaint paint; | 85 SkPaint paint; |
| 86 paint.setColor(SkColorSetRGB(108, 108, 108)); | 86 paint.setColor(SkColorSetRGB(108, 108, 108)); |
| 87 paint.setStyle(SkPaint::kFill_Style); | 87 paint.setStyle(SkPaint::kFill_Style); |
| 88 canvas->drawRoundRect(outer_rect, SkIntToScalar(kRoundedRectRadius), | 88 canvas->AsCanvasSkia()->drawRoundRect( |
| 89 SkIntToScalar(kRoundedRectRadius), paint); | 89 outer_rect, SkIntToScalar(kRoundedRectRadius), |
| 90 SkIntToScalar(kRoundedRectRadius), paint); |
| 90 | 91 |
| 91 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | 92 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
| 92 | 93 |
| 93 SkBitmap* high_icon = rb.GetBitmapNamed(IDR_DOCK_HIGH); | 94 SkBitmap* high_icon = rb.GetBitmapNamed(IDR_DOCK_HIGH); |
| 94 SkBitmap* wide_icon = rb.GetBitmapNamed(IDR_DOCK_WIDE); | 95 SkBitmap* wide_icon = rb.GetBitmapNamed(IDR_DOCK_WIDE); |
| 95 | 96 |
| 96 bool rtl_ui = base::i18n::IsRTL(); | 97 bool rtl_ui = base::i18n::IsRTL(); |
| 97 if (rtl_ui) { | 98 if (rtl_ui) { |
| 98 // Flip canvas to draw the mirrored tab images for RTL UI. | 99 // Flip canvas to draw the mirrored tab images for RTL UI. |
| 99 canvas->save(); | 100 canvas->AsCanvasSkia()->save(); |
| 100 canvas->TranslateInt(width(), 0); | 101 canvas->TranslateInt(width(), 0); |
| 101 canvas->ScaleInt(-1, 1); | 102 canvas->ScaleInt(-1, 1); |
| 102 } | 103 } |
| 103 int x_of_active_tab = -1; | 104 int x_of_active_tab = -1; |
| 104 int x_of_inactive_tab = -1; | 105 int x_of_inactive_tab = -1; |
| 105 switch (type_) { | 106 switch (type_) { |
| 106 case DockInfo::LEFT_OF_WINDOW: | 107 case DockInfo::LEFT_OF_WINDOW: |
| 107 case DockInfo::LEFT_HALF: | 108 case DockInfo::LEFT_HALF: |
| 108 if (!rtl_ui) { | 109 if (!rtl_ui) { |
| 109 x_of_active_tab = width() / 2 - high_icon->width() - kTabSpacing / 2; | 110 x_of_active_tab = width() / 2 - high_icon->width() - kTabSpacing / 2; |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 163 (width() - wide_icon->width()) / 2, | 164 (width() - wide_icon->width()) / 2, |
| 164 height() / 2 - kTabSpacing / 2 - wide_icon->height()); | 165 height() / 2 - kTabSpacing / 2 - wide_icon->height()); |
| 165 } | 166 } |
| 166 break; | 167 break; |
| 167 | 168 |
| 168 default: | 169 default: |
| 169 NOTREACHED(); | 170 NOTREACHED(); |
| 170 break; | 171 break; |
| 171 } | 172 } |
| 172 if (rtl_ui) | 173 if (rtl_ui) |
| 173 canvas->restore(); | 174 canvas->AsCanvasSkia()->restore(); |
| 174 } | 175 } |
| 175 | 176 |
| 176 private: | 177 private: |
| 177 void DrawBitmapWithAlpha(gfx::Canvas* canvas, const SkBitmap& image, | 178 void DrawBitmapWithAlpha(gfx::Canvas* canvas, const SkBitmap& image, |
| 178 int x, int y) { | 179 int x, int y) { |
| 179 SkPaint paint; | 180 SkPaint paint; |
| 180 paint.setAlpha(128); | 181 paint.setAlpha(128); |
| 181 canvas->DrawBitmapInt(image, x, y, paint); | 182 canvas->DrawBitmapInt(image, x, y, paint); |
| 182 } | 183 } |
| 183 | 184 |
| (...skipping 1142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1326 #else | 1327 #else |
| 1327 NOTIMPLEMENTED(); | 1328 NOTIMPLEMENTED(); |
| 1328 #endif | 1329 #endif |
| 1329 } | 1330 } |
| 1330 } | 1331 } |
| 1331 | 1332 |
| 1332 TabStripModel* DraggedTabController::GetModel(BaseTabStrip* tabstrip) const { | 1333 TabStripModel* DraggedTabController::GetModel(BaseTabStrip* tabstrip) const { |
| 1333 return static_cast<BrowserTabStripController*>(tabstrip->controller())-> | 1334 return static_cast<BrowserTabStripController*>(tabstrip->controller())-> |
| 1334 model(); | 1335 model(); |
| 1335 } | 1336 } |
| OLD | NEW |