| 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/tab_drag_controller.h" | 5 #include "chrome/browser/ui/views/tabs/tab_drag_controller.h" |
| 6 | 6 |
| 7 #include <math.h> | 7 #include <math.h> |
| 8 #include <set> | 8 #include <set> |
| 9 | 9 |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 #include "chrome/browser/ui/views/tabs/touch_tab_strip_layout.h" | 24 #include "chrome/browser/ui/views/tabs/touch_tab_strip_layout.h" |
| 25 #include "chrome/common/chrome_notification_types.h" | 25 #include "chrome/common/chrome_notification_types.h" |
| 26 #include "chrome/common/chrome_switches.h" | 26 #include "chrome/common/chrome_switches.h" |
| 27 #include "content/public/browser/notification_details.h" | 27 #include "content/public/browser/notification_details.h" |
| 28 #include "content/public/browser/notification_service.h" | 28 #include "content/public/browser/notification_service.h" |
| 29 #include "content/public/browser/notification_source.h" | 29 #include "content/public/browser/notification_source.h" |
| 30 #include "content/public/browser/notification_types.h" | 30 #include "content/public/browser/notification_types.h" |
| 31 #include "content/public/browser/user_metrics.h" | 31 #include "content/public/browser/user_metrics.h" |
| 32 #include "content/public/browser/web_contents.h" | 32 #include "content/public/browser/web_contents.h" |
| 33 #include "grit/theme_resources.h" | 33 #include "grit/theme_resources.h" |
| 34 #include "third_party/skia/include/core/SkBitmap.h" | |
| 35 #include "ui/base/animation/animation.h" | 34 #include "ui/base/animation/animation.h" |
| 36 #include "ui/base/animation/animation_delegate.h" | 35 #include "ui/base/animation/animation_delegate.h" |
| 37 #include "ui/base/animation/slide_animation.h" | 36 #include "ui/base/animation/slide_animation.h" |
| 38 #include "ui/base/events.h" | 37 #include "ui/base/events.h" |
| 39 #include "ui/base/resource/resource_bundle.h" | 38 #include "ui/base/resource/resource_bundle.h" |
| 40 #include "ui/gfx/canvas.h" | 39 #include "ui/gfx/canvas.h" |
| 40 #include "ui/gfx/image/image_skia.h" |
| 41 #include "ui/gfx/screen.h" | 41 #include "ui/gfx/screen.h" |
| 42 #include "ui/views/events/event.h" | 42 #include "ui/views/events/event.h" |
| 43 #include "ui/views/widget/root_view.h" | 43 #include "ui/views/widget/root_view.h" |
| 44 #include "ui/views/widget/widget.h" | 44 #include "ui/views/widget/widget.h" |
| 45 | 45 |
| 46 #if defined(USE_ASH) | 46 #if defined(USE_ASH) |
| 47 #include "ash/shell.h" | 47 #include "ash/shell.h" |
| 48 #include "ash/wm/property_util.h" | 48 #include "ash/wm/property_util.h" |
| 49 #endif | 49 #endif |
| 50 | 50 |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 // Fill the background rect. | 99 // Fill the background rect. |
| 100 SkPaint paint; | 100 SkPaint paint; |
| 101 paint.setColor(SkColorSetRGB(108, 108, 108)); | 101 paint.setColor(SkColorSetRGB(108, 108, 108)); |
| 102 paint.setStyle(SkPaint::kFill_Style); | 102 paint.setStyle(SkPaint::kFill_Style); |
| 103 canvas->sk_canvas()->drawRoundRect( | 103 canvas->sk_canvas()->drawRoundRect( |
| 104 outer_rect, SkIntToScalar(kRoundedRectRadius), | 104 outer_rect, SkIntToScalar(kRoundedRectRadius), |
| 105 SkIntToScalar(kRoundedRectRadius), paint); | 105 SkIntToScalar(kRoundedRectRadius), paint); |
| 106 | 106 |
| 107 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | 107 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
| 108 | 108 |
| 109 SkBitmap* high_icon = rb.GetBitmapNamed(IDR_DOCK_HIGH); | 109 gfx::ImageSkia* high_icon = rb.GetImageSkiaNamed(IDR_DOCK_HIGH); |
| 110 SkBitmap* wide_icon = rb.GetBitmapNamed(IDR_DOCK_WIDE); | 110 gfx::ImageSkia* wide_icon = rb.GetImageSkiaNamed(IDR_DOCK_WIDE); |
| 111 | 111 |
| 112 canvas->Save(); | 112 canvas->Save(); |
| 113 bool rtl_ui = base::i18n::IsRTL(); | 113 bool rtl_ui = base::i18n::IsRTL(); |
| 114 if (rtl_ui) { | 114 if (rtl_ui) { |
| 115 // Flip canvas to draw the mirrored tab images for RTL UI. | 115 // Flip canvas to draw the mirrored tab images for RTL UI. |
| 116 canvas->Translate(gfx::Point(width(), 0)); | 116 canvas->Translate(gfx::Point(width(), 0)); |
| 117 canvas->Scale(-1, 1); | 117 canvas->Scale(-1, 1); |
| 118 } | 118 } |
| 119 int x_of_active_tab = width() / 2 + kTabSpacing / 2; | 119 int x_of_active_tab = width() / 2 + kTabSpacing / 2; |
| 120 int x_of_inactive_tab = width() / 2 - high_icon->width() - kTabSpacing / 2; | 120 int x_of_inactive_tab = width() / 2 - high_icon->width() - kTabSpacing / 2; |
| 121 switch (type_) { | 121 switch (type_) { |
| 122 case DockInfo::LEFT_OF_WINDOW: | 122 case DockInfo::LEFT_OF_WINDOW: |
| 123 case DockInfo::LEFT_HALF: | 123 case DockInfo::LEFT_HALF: |
| 124 if (!rtl_ui) | 124 if (!rtl_ui) |
| 125 std::swap(x_of_active_tab, x_of_inactive_tab); | 125 std::swap(x_of_active_tab, x_of_inactive_tab); |
| 126 canvas->DrawBitmapInt(*high_icon, x_of_active_tab, | 126 canvas->DrawBitmapInt(*high_icon, x_of_active_tab, |
| 127 (height() - high_icon->height()) / 2); | 127 (height() - high_icon->height()) / 2); |
| 128 if (type_ == DockInfo::LEFT_OF_WINDOW) { | 128 if (type_ == DockInfo::LEFT_OF_WINDOW) { |
| 129 DrawBitmapWithAlpha(canvas, *high_icon, x_of_inactive_tab, | 129 DrawImageWithAlpha(canvas, *high_icon, x_of_inactive_tab, |
| 130 (height() - high_icon->height()) / 2); | 130 (height() - high_icon->height()) / 2); |
| 131 } | 131 } |
| 132 break; | 132 break; |
| 133 | 133 |
| 134 | 134 |
| 135 case DockInfo::RIGHT_OF_WINDOW: | 135 case DockInfo::RIGHT_OF_WINDOW: |
| 136 case DockInfo::RIGHT_HALF: | 136 case DockInfo::RIGHT_HALF: |
| 137 if (rtl_ui) | 137 if (rtl_ui) |
| 138 std::swap(x_of_active_tab, x_of_inactive_tab); | 138 std::swap(x_of_active_tab, x_of_inactive_tab); |
| 139 canvas->DrawBitmapInt(*high_icon, x_of_active_tab, | 139 canvas->DrawBitmapInt(*high_icon, x_of_active_tab, |
| 140 (height() - high_icon->height()) / 2); | 140 (height() - high_icon->height()) / 2); |
| 141 if (type_ == DockInfo::RIGHT_OF_WINDOW) { | 141 if (type_ == DockInfo::RIGHT_OF_WINDOW) { |
| 142 DrawBitmapWithAlpha(canvas, *high_icon, x_of_inactive_tab, | 142 DrawImageWithAlpha(canvas, *high_icon, x_of_inactive_tab, |
| 143 (height() - high_icon->height()) / 2); | 143 (height() - high_icon->height()) / 2); |
| 144 } | 144 } |
| 145 break; | 145 break; |
| 146 | 146 |
| 147 case DockInfo::TOP_OF_WINDOW: | 147 case DockInfo::TOP_OF_WINDOW: |
| 148 canvas->DrawBitmapInt(*wide_icon, (width() - wide_icon->width()) / 2, | 148 canvas->DrawBitmapInt(*wide_icon, (width() - wide_icon->width()) / 2, |
| 149 height() / 2 - high_icon->height()); | 149 height() / 2 - high_icon->height()); |
| 150 break; | 150 break; |
| 151 | 151 |
| 152 case DockInfo::MAXIMIZE: { | 152 case DockInfo::MAXIMIZE: { |
| 153 SkBitmap* max_icon = rb.GetBitmapNamed(IDR_DOCK_MAX); | 153 gfx::ImageSkia* max_icon = rb.GetImageSkiaNamed(IDR_DOCK_MAX); |
| 154 canvas->DrawBitmapInt(*max_icon, (width() - max_icon->width()) / 2, | 154 canvas->DrawBitmapInt(*max_icon, (width() - max_icon->width()) / 2, |
| 155 (height() - max_icon->height()) / 2); | 155 (height() - max_icon->height()) / 2); |
| 156 break; | 156 break; |
| 157 } | 157 } |
| 158 | 158 |
| 159 case DockInfo::BOTTOM_HALF: | 159 case DockInfo::BOTTOM_HALF: |
| 160 case DockInfo::BOTTOM_OF_WINDOW: | 160 case DockInfo::BOTTOM_OF_WINDOW: |
| 161 canvas->DrawBitmapInt(*wide_icon, (width() - wide_icon->width()) / 2, | 161 canvas->DrawBitmapInt(*wide_icon, (width() - wide_icon->width()) / 2, |
| 162 height() / 2 + kTabSpacing / 2); | 162 height() / 2 + kTabSpacing / 2); |
| 163 if (type_ == DockInfo::BOTTOM_OF_WINDOW) { | 163 if (type_ == DockInfo::BOTTOM_OF_WINDOW) { |
| 164 DrawBitmapWithAlpha(canvas, *wide_icon, | 164 DrawImageWithAlpha(canvas, *wide_icon, |
| 165 (width() - wide_icon->width()) / 2, | 165 (width() - wide_icon->width()) / 2, |
| 166 height() / 2 - kTabSpacing / 2 - wide_icon->height()); | 166 height() / 2 - kTabSpacing / 2 - wide_icon->height()); |
| 167 } | 167 } |
| 168 break; | 168 break; |
| 169 | 169 |
| 170 default: | 170 default: |
| 171 NOTREACHED(); | 171 NOTREACHED(); |
| 172 break; | 172 break; |
| 173 } | 173 } |
| 174 canvas->Restore(); | 174 canvas->Restore(); |
| 175 } | 175 } |
| 176 | 176 |
| 177 private: | 177 private: |
| 178 void DrawBitmapWithAlpha(gfx::Canvas* canvas, const SkBitmap& image, | 178 void DrawImageWithAlpha(gfx::Canvas* canvas, const gfx::ImageSkia& image, |
| 179 int x, int y) { | 179 int x, int y) { |
| 180 SkPaint paint; | 180 SkPaint paint; |
| 181 paint.setAlpha(128); | 181 paint.setAlpha(128); |
| 182 canvas->DrawBitmapInt(image, x, y, paint); | 182 canvas->DrawBitmapInt(image, x, y, paint); |
| 183 } | 183 } |
| 184 | 184 |
| 185 DockInfo::Type type_; | 185 DockInfo::Type type_; |
| 186 | 186 |
| 187 DISALLOW_COPY_AND_ASSIGN(DockView); | 187 DISALLOW_COPY_AND_ASSIGN(DockView); |
| 188 }; | 188 }; |
| 189 | 189 |
| (...skipping 1687 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1877 } | 1877 } |
| 1878 | 1878 |
| 1879 default: | 1879 default: |
| 1880 break; // Nothing to do for DETACH_ABOVE_OR_BELOW. | 1880 break; // Nothing to do for DETACH_ABOVE_OR_BELOW. |
| 1881 } | 1881 } |
| 1882 | 1882 |
| 1883 SetTrackedByWorkspace(browser->window()->GetNativeHandle(), false); | 1883 SetTrackedByWorkspace(browser->window()->GetNativeHandle(), false); |
| 1884 browser->window()->SetBounds(new_bounds); | 1884 browser->window()->SetBounds(new_bounds); |
| 1885 return browser; | 1885 return browser; |
| 1886 } | 1886 } |
| OLD | NEW |