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/tab_strip.h" | 5 #include "chrome/browser/ui/views/tabs/tab_strip.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 #include "base/stl_util-inl.h" | 10 #include "base/stl_util-inl.h" |
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
269 Tab* dragging_tab = NULL; | 269 Tab* dragging_tab = NULL; |
270 | 270 |
271 for (int i = tab_count() - 1; i >= 0; --i) { | 271 for (int i = tab_count() - 1; i >= 0; --i) { |
272 Tab* tab = GetTabAtTabDataIndex(i); | 272 Tab* tab = GetTabAtTabDataIndex(i); |
273 // We must ask the _Tab's_ model, not ourselves, because in some situations | 273 // We must ask the _Tab's_ model, not ourselves, because in some situations |
274 // the model will be different to this object, e.g. when a Tab is being | 274 // the model will be different to this object, e.g. when a Tab is being |
275 // removed after its TabContents has been destroyed. | 275 // removed after its TabContents has been destroyed. |
276 if (tab->dragging()) { | 276 if (tab->dragging()) { |
277 dragging_tab = tab; | 277 dragging_tab = tab; |
278 } else if (!tab->IsSelected()) { | 278 } else if (!tab->IsSelected()) { |
279 tab->ProcessPaint(canvas); | 279 tab->Paint(canvas); |
280 } else { | 280 } else { |
281 selected_tab = tab; | 281 selected_tab = tab; |
282 } | 282 } |
283 } | 283 } |
284 | 284 |
285 if (GetWindow()->GetNonClientView()->UseNativeFrame()) { | 285 if (GetWindow()->GetNonClientView()->UseNativeFrame()) { |
286 // Make sure unselected tabs are somewhat transparent. | 286 // Make sure unselected tabs are somewhat transparent. |
287 SkPaint paint; | 287 SkPaint paint; |
288 paint.setColor(SkColorSetARGB(200, 255, 255, 255)); | 288 paint.setColor(SkColorSetARGB(200, 255, 255, 255)); |
289 paint.setXfermodeMode(SkXfermode::kDstIn_Mode); | 289 paint.setXfermodeMode(SkXfermode::kDstIn_Mode); |
290 paint.setStyle(SkPaint::kFill_Style); | 290 paint.setStyle(SkPaint::kFill_Style); |
291 canvas->DrawRectInt(0, 0, width(), | 291 canvas->DrawRectInt(0, 0, width(), |
292 height() - 2, // Visible region that overlaps the toolbar. | 292 height() - 2, // Visible region that overlaps the toolbar. |
293 paint); | 293 paint); |
294 } | 294 } |
295 | 295 |
296 // Paint the selected tab last, so it overlaps all the others. | 296 // Paint the selected tab last, so it overlaps all the others. |
297 if (selected_tab) | 297 if (selected_tab) |
298 selected_tab->ProcessPaint(canvas); | 298 selected_tab->Paint(canvas); |
299 | 299 |
300 // Paint the New Tab button. | 300 // Paint the New Tab button. |
301 newtab_button_->ProcessPaint(canvas); | 301 newtab_button_->Paint(canvas); |
302 | 302 |
303 // And the dragged tab. | 303 // And the dragged tab. |
304 if (dragging_tab) | 304 if (dragging_tab) |
305 dragging_tab->ProcessPaint(canvas); | 305 dragging_tab->Paint(canvas); |
306 } | 306 } |
307 | 307 |
308 // Overridden to support automation. See automation_proxy_uitest.cc. | 308 // Overridden to support automation. See automation_proxy_uitest.cc. |
309 const views::View* TabStrip::GetViewByID(int view_id) const { | 309 const views::View* TabStrip::GetViewByID(int view_id) const { |
310 if (tab_count() > 0) { | 310 if (tab_count() > 0) { |
311 if (view_id == VIEW_ID_TAB_LAST) { | 311 if (view_id == VIEW_ID_TAB_LAST) { |
312 return GetTabAtTabDataIndex(tab_count() - 1); | 312 return GetTabAtTabDataIndex(tab_count() - 1); |
313 } else if ((view_id >= VIEW_ID_TAB_0) && (view_id < VIEW_ID_TAB_LAST)) { | 313 } else if ((view_id >= VIEW_ID_TAB_0) && (view_id < VIEW_ID_TAB_LAST)) { |
314 int index = view_id - VIEW_ID_TAB_0; | 314 int index = view_id - VIEW_ID_TAB_0; |
315 if (index >= 0 && index < tab_count()) { | 315 if (index >= 0 && index < tab_count()) { |
(...skipping 629 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
945 int TabStrip::GetAvailableWidthForTabs(Tab* last_tab) const { | 945 int TabStrip::GetAvailableWidthForTabs(Tab* last_tab) const { |
946 return last_tab->x() + last_tab->width(); | 946 return last_tab->x() + last_tab->width(); |
947 } | 947 } |
948 | 948 |
949 bool TabStrip::IsPointInTab(Tab* tab, | 949 bool TabStrip::IsPointInTab(Tab* tab, |
950 const gfx::Point& point_in_tabstrip_coords) { | 950 const gfx::Point& point_in_tabstrip_coords) { |
951 gfx::Point point_in_tab_coords(point_in_tabstrip_coords); | 951 gfx::Point point_in_tab_coords(point_in_tabstrip_coords); |
952 View::ConvertPointToView(this, tab, &point_in_tab_coords); | 952 View::ConvertPointToView(this, tab, &point_in_tab_coords); |
953 return tab->HitTest(point_in_tab_coords); | 953 return tab->HitTest(point_in_tab_coords); |
954 } | 954 } |
OLD | NEW |