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/ui/views/tabs/tab.h" | 5 #include "chrome/browser/ui/views/tabs/tab.h" |
6 | 6 |
7 #include <limits> | 7 #include <limits> |
8 | 8 |
9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
10 #include "chrome/browser/defaults.h" | 10 #include "chrome/browser/defaults.h" |
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
294 title_bounds_.SetRect(title_left, title_top, 0, 0); | 294 title_bounds_.SetRect(title_left, title_top, 0, 0); |
295 } | 295 } |
296 | 296 |
297 // Certain UI elements within the Tab (the favicon, etc.) are not represented | 297 // Certain UI elements within the Tab (the favicon, etc.) are not represented |
298 // as child Views (which is the preferred method). Instead, these UI elements | 298 // as child Views (which is the preferred method). Instead, these UI elements |
299 // are drawn directly on the canvas from within Tab::Paint(). The Tab's child | 299 // are drawn directly on the canvas from within Tab::Paint(). The Tab's child |
300 // Views (for example, the Tab's close button which is a views::Button | 300 // Views (for example, the Tab's close button which is a views::Button |
301 // instance) are automatically mirrored by the mirroring infrastructure in | 301 // instance) are automatically mirrored by the mirroring infrastructure in |
302 // views. The elements Tab draws directly on the canvas need to be manually | 302 // views. The elements Tab draws directly on the canvas need to be manually |
303 // mirrored if the View's layout is right-to-left. | 303 // mirrored if the View's layout is right-to-left. |
304 title_bounds_.set_x(MirroredLeftPointForRect(title_bounds_)); | 304 title_bounds_.set_x(GetMirroredXForRect(title_bounds_)); |
305 } | 305 } |
306 | 306 |
307 void Tab::OnThemeChanged() { | 307 void Tab::OnThemeChanged() { |
308 LoadTabImages(); | 308 LoadTabImages(); |
309 } | 309 } |
310 | 310 |
311 bool Tab::HasHitTestMask() const { | 311 bool Tab::HasHitTestMask() const { |
312 return true; | 312 return true; |
313 } | 313 } |
314 | 314 |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
432 canvas->DrawBitmapInt(hover_image, 0, 0); | 432 canvas->DrawBitmapInt(hover_image, 0, 0); |
433 } | 433 } |
434 } | 434 } |
435 | 435 |
436 void Tab::PaintInactiveTabBackground(gfx::Canvas* canvas) { | 436 void Tab::PaintInactiveTabBackground(gfx::Canvas* canvas) { |
437 bool is_otr = data().off_the_record; | 437 bool is_otr = data().off_the_record; |
438 | 438 |
439 // The tab image needs to be lined up with the background image | 439 // The tab image needs to be lined up with the background image |
440 // so that it feels partially transparent. These offsets represent the tab | 440 // so that it feels partially transparent. These offsets represent the tab |
441 // position within the frame background image. | 441 // position within the frame background image. |
442 int offset = GetX(views::View::APPLY_MIRRORING_TRANSFORMATION) + | 442 int offset = GetMirroredX() + background_offset_.x(); |
443 background_offset_.x(); | |
444 | 443 |
445 int tab_id; | 444 int tab_id; |
446 if (GetWidget() && | 445 if (GetWidget() && |
447 GetWidget()->GetWindow()->GetNonClientView()->UseNativeFrame()) { | 446 GetWidget()->GetWindow()->GetNonClientView()->UseNativeFrame()) { |
448 tab_id = IDR_THEME_TAB_BACKGROUND_V; | 447 tab_id = IDR_THEME_TAB_BACKGROUND_V; |
449 } else { | 448 } else { |
450 tab_id = is_otr ? IDR_THEME_TAB_BACKGROUND_INCOGNITO : | 449 tab_id = is_otr ? IDR_THEME_TAB_BACKGROUND_INCOGNITO : |
451 IDR_THEME_TAB_BACKGROUND; | 450 IDR_THEME_TAB_BACKGROUND; |
452 } | 451 } |
453 | 452 |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
518 canvas->TileImageInt(*tab_inactive_image->image_c, | 517 canvas->TileImageInt(*tab_inactive_image->image_c, |
519 tab_inactive_image->l_width, 0, | 518 tab_inactive_image->l_width, 0, |
520 width() - tab_inactive_image->l_width - | 519 width() - tab_inactive_image->l_width - |
521 tab_inactive_image->r_width, | 520 tab_inactive_image->r_width, |
522 height()); | 521 height()); |
523 canvas->DrawBitmapInt(*tab_inactive_image->image_r, | 522 canvas->DrawBitmapInt(*tab_inactive_image->image_r, |
524 width() - tab_inactive_image->r_width, 0); | 523 width() - tab_inactive_image->r_width, 0); |
525 } | 524 } |
526 | 525 |
527 void Tab::PaintActiveTabBackground(gfx::Canvas* canvas) { | 526 void Tab::PaintActiveTabBackground(gfx::Canvas* canvas) { |
528 int offset = GetX(views::View::APPLY_MIRRORING_TRANSFORMATION) + | 527 int offset = GetMirroredX() + background_offset_.x(); |
529 background_offset_.x(); | |
530 ui::ThemeProvider* tp = GetThemeProvider(); | 528 ui::ThemeProvider* tp = GetThemeProvider(); |
531 DCHECK(tp) << "Unable to get theme provider"; | 529 DCHECK(tp) << "Unable to get theme provider"; |
532 | 530 |
533 SkBitmap* tab_bg = GetThemeProvider()->GetBitmapNamed(IDR_THEME_TOOLBAR); | 531 SkBitmap* tab_bg = GetThemeProvider()->GetBitmapNamed(IDR_THEME_TOOLBAR); |
534 | 532 |
535 TabImage* tab_image = &tab_active_; | 533 TabImage* tab_image = &tab_active_; |
536 TabImage* alpha = &tab_alpha_; | 534 TabImage* alpha = &tab_alpha_; |
537 | 535 |
538 // Draw left edge. | 536 // Draw left edge. |
539 SkBitmap tab_l = SkBitmapOperations::CreateTiledBitmap( | 537 SkBitmap tab_l = SkBitmapOperations::CreateTiledBitmap( |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
667 tab_active_.image_r = rb.GetBitmapNamed(IDR_TAB_ACTIVE_RIGHT); | 665 tab_active_.image_r = rb.GetBitmapNamed(IDR_TAB_ACTIVE_RIGHT); |
668 tab_active_.l_width = tab_active_.image_l->width(); | 666 tab_active_.l_width = tab_active_.image_l->width(); |
669 tab_active_.r_width = tab_active_.image_r->width(); | 667 tab_active_.r_width = tab_active_.image_r->width(); |
670 | 668 |
671 tab_inactive_.image_l = rb.GetBitmapNamed(IDR_TAB_INACTIVE_LEFT); | 669 tab_inactive_.image_l = rb.GetBitmapNamed(IDR_TAB_INACTIVE_LEFT); |
672 tab_inactive_.image_c = rb.GetBitmapNamed(IDR_TAB_INACTIVE_CENTER); | 670 tab_inactive_.image_c = rb.GetBitmapNamed(IDR_TAB_INACTIVE_CENTER); |
673 tab_inactive_.image_r = rb.GetBitmapNamed(IDR_TAB_INACTIVE_RIGHT); | 671 tab_inactive_.image_r = rb.GetBitmapNamed(IDR_TAB_INACTIVE_RIGHT); |
674 tab_inactive_.l_width = tab_inactive_.image_l->width(); | 672 tab_inactive_.l_width = tab_inactive_.image_l->width(); |
675 tab_inactive_.r_width = tab_inactive_.image_r->width(); | 673 tab_inactive_.r_width = tab_inactive_.image_r->width(); |
676 } | 674 } |
OLD | NEW |