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_strip.h" | 5 #include "chrome/browser/ui/views/tabs/tab_strip.h" |
6 | 6 |
7 #if defined(OS_WIN) | 7 #if defined(OS_WIN) |
8 #include <windowsx.h> | 8 #include <windowsx.h> |
9 #endif | 9 #endif |
10 | 10 |
(...skipping 1180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1191 DoLayout(); | 1191 DoLayout(); |
1192 } | 1192 } |
1193 | 1193 |
1194 void TabStrip::PaintChildren(gfx::Canvas* canvas) { | 1194 void TabStrip::PaintChildren(gfx::Canvas* canvas) { |
1195 // The view order doesn't match the paint order (tabs_ contains the tab | 1195 // The view order doesn't match the paint order (tabs_ contains the tab |
1196 // ordering). Additionally we need to paint the tabs that are closing in | 1196 // ordering). Additionally we need to paint the tabs that are closing in |
1197 // |tabs_closing_map_|. | 1197 // |tabs_closing_map_|. |
1198 Tab* active_tab = NULL; | 1198 Tab* active_tab = NULL; |
1199 std::vector<Tab*> tabs_dragging; | 1199 std::vector<Tab*> tabs_dragging; |
1200 std::vector<Tab*> selected_tabs; | 1200 std::vector<Tab*> selected_tabs; |
| 1201 int selected_tab_count = 0; |
1201 bool is_dragging = false; | 1202 bool is_dragging = false; |
1202 int active_tab_index = -1; | 1203 int active_tab_index = -1; |
1203 // Since |touch_layout_| is created based on number of tabs and width we use | 1204 // Since |touch_layout_| is created based on number of tabs and width we use |
1204 // the ideal state to determine if we should paint stacked. This minimizes | 1205 // the ideal state to determine if we should paint stacked. This minimizes |
1205 // painting changes as we switch between the two. | 1206 // painting changes as we switch between the two. |
1206 const bool stacking = (layout_type_ == TAB_STRIP_LAYOUT_STACKED) || | 1207 const bool stacking = (layout_type_ == TAB_STRIP_LAYOUT_STACKED) || |
1207 IsStackingDraggedTabs(); | 1208 IsStackingDraggedTabs(); |
1208 | 1209 |
1209 if (kInactiveTabAndNewTabButtonAlpha < 255) | 1210 if (kInactiveTabAndNewTabButtonAlpha < 255) |
1210 canvas->SaveLayerAlpha(kInactiveTabAndNewTabButtonAlpha); | 1211 canvas->SaveLayerAlpha(kInactiveTabAndNewTabButtonAlpha); |
1211 | 1212 |
1212 PaintClosingTabs(canvas, tab_count()); | 1213 PaintClosingTabs(canvas, tab_count()); |
1213 | 1214 |
1214 for (int i = tab_count() - 1; i >= 0; --i) { | 1215 for (int i = tab_count() - 1; i >= 0; --i) { |
1215 Tab* tab = tab_at(i); | 1216 Tab* tab = tab_at(i); |
| 1217 if (tab->IsSelected()) |
| 1218 selected_tab_count++; |
1216 if (tab->dragging() && !stacking) { | 1219 if (tab->dragging() && !stacking) { |
1217 is_dragging = true; | 1220 is_dragging = true; |
1218 if (tab->IsActive()) { | 1221 if (tab->IsActive()) { |
1219 active_tab = tab; | 1222 active_tab = tab; |
1220 active_tab_index = i; | 1223 active_tab_index = i; |
1221 } else { | 1224 } else { |
1222 tabs_dragging.push_back(tab); | 1225 tabs_dragging.push_back(tab); |
1223 } | 1226 } |
1224 } else if (!tab->IsActive()) { | 1227 } else if (!tab->IsActive()) { |
1225 if (!tab->IsSelected()) { | 1228 if (!tab->IsSelected()) { |
(...skipping 18 matching lines...) Expand all Loading... |
1244 | 1247 |
1245 for (int i = tab_count() - 1; i > active_tab_index; --i) { | 1248 for (int i = tab_count() - 1; i > active_tab_index; --i) { |
1246 Tab* tab = tab_at(i); | 1249 Tab* tab = tab_at(i); |
1247 tab->Paint(canvas); | 1250 tab->Paint(canvas); |
1248 } | 1251 } |
1249 } | 1252 } |
1250 if (kInactiveTabAndNewTabButtonAlpha < 255) | 1253 if (kInactiveTabAndNewTabButtonAlpha < 255) |
1251 canvas->Restore(); | 1254 canvas->Restore(); |
1252 | 1255 |
1253 if (GetWidget()->ShouldUseNativeFrame()) { | 1256 if (GetWidget()->ShouldUseNativeFrame()) { |
1254 bool multiple_tabs_selected = (!selected_tabs.empty() || | |
1255 tabs_dragging.size() > 1); | |
1256 // Make sure non-active tabs are somewhat transparent. | 1257 // Make sure non-active tabs are somewhat transparent. |
1257 SkPaint paint; | 1258 SkPaint paint; |
1258 // If there are multiple tabs selected, fade non-selected tabs more to make | 1259 // If there are multiple tabs selected, fade non-selected tabs more to make |
1259 // the selected tabs more noticable. | 1260 // the selected tabs more noticable. |
1260 int alpha = multiple_tabs_selected ? | 1261 int alpha = selected_tab_count > 1 ? |
1261 kNativeFrameInactiveTabAlphaMultiSelection : | 1262 kNativeFrameInactiveTabAlphaMultiSelection : |
1262 kNativeFrameInactiveTabAlpha; | 1263 kNativeFrameInactiveTabAlpha; |
1263 paint.setColor(SkColorSetARGB(alpha, 255, 255, 255)); | 1264 paint.setColor(SkColorSetARGB(alpha, 255, 255, 255)); |
1264 paint.setXfermodeMode(SkXfermode::kDstIn_Mode); | 1265 paint.setXfermodeMode(SkXfermode::kDstIn_Mode); |
1265 paint.setStyle(SkPaint::kFill_Style); | 1266 paint.setStyle(SkPaint::kFill_Style); |
1266 // The tabstrip area overlaps the toolbar area by 2 px. | 1267 // The tabstrip area overlaps the toolbar area by 2 px. |
1267 canvas->DrawRect(gfx::Rect(0, 0, width(), height() - 2), paint); | 1268 canvas->DrawRect(gfx::Rect(0, 0, width(), height() - 2), paint); |
1268 } | 1269 } |
1269 | 1270 |
1270 // Now selected but not active. We don't want these dimmed if using native | 1271 // Now selected but not active. We don't want these dimmed if using native |
(...skipping 1299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2570 if (!adjust_layout_) | 2571 if (!adjust_layout_) |
2571 return false; | 2572 return false; |
2572 | 2573 |
2573 #if !defined(OS_CHROMEOS) | 2574 #if !defined(OS_CHROMEOS) |
2574 if (ui::GetDisplayLayout() != ui::LAYOUT_TOUCH) | 2575 if (ui::GetDisplayLayout() != ui::LAYOUT_TOUCH) |
2575 return false; | 2576 return false; |
2576 #endif | 2577 #endif |
2577 | 2578 |
2578 return true; | 2579 return true; |
2579 } | 2580 } |
OLD | NEW |