Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(425)

Side by Side Diff: chrome/browser/ui/gtk/tabs/tab_renderer_gtk.cc

Issue 6933037: Multi-tab selection for Linux. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixing clang errors Created 9 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/gtk/tabs/tab_renderer_gtk.h" 5 #include "chrome/browser/ui/gtk/tabs/tab_renderer_gtk.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/utf_string_conversions.h" 10 #include "base/utf_string_conversions.h"
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after
342 if (data_.blocked == blocked) 342 if (data_.blocked == blocked)
343 return; 343 return;
344 data_.blocked = blocked; 344 data_.blocked = blocked;
345 // TODO(zelidrag) bug 32399: Make tabs pulse on Linux as well. 345 // TODO(zelidrag) bug 32399: Make tabs pulse on Linux as well.
346 } 346 }
347 347
348 bool TabRendererGtk::is_blocked() const { 348 bool TabRendererGtk::is_blocked() const {
349 return data_.blocked; 349 return data_.blocked;
350 } 350 }
351 351
352 bool TabRendererGtk::IsActive() const {
353 return true;
354 }
355
352 bool TabRendererGtk::IsSelected() const { 356 bool TabRendererGtk::IsSelected() const {
353 return true; 357 return true;
354 } 358 }
355 359
356 bool TabRendererGtk::IsVisible() const { 360 bool TabRendererGtk::IsVisible() const {
357 return GTK_WIDGET_FLAGS(tab_.get()) & GTK_VISIBLE; 361 return GTK_WIDGET_FLAGS(tab_.get()) & GTK_VISIBLE;
358 } 362 }
359 363
360 void TabRendererGtk::SetVisible(bool visible) const { 364 void TabRendererGtk::SetVisible(bool visible) const {
361 if (visible) { 365 if (visible) {
(...skipping 21 matching lines...) Expand all
383 event->area.height = favicon_bounds_.height(); 387 event->area.height = favicon_bounds_.height();
384 gfx::CanvasSkiaPaint canvas(event, false); 388 gfx::CanvasSkiaPaint canvas(event, false);
385 389
386 // The actual paint methods expect 0, 0 to be the tab top left (see 390 // The actual paint methods expect 0, 0 to be the tab top left (see
387 // PaintTab). 391 // PaintTab).
388 canvas.TranslateInt(x(), y()); 392 canvas.TranslateInt(x(), y());
389 393
390 // Paint the background behind the favicon. 394 // Paint the background behind the favicon.
391 int theme_id; 395 int theme_id;
392 int offset_y = 0; 396 int offset_y = 0;
393 if (IsSelected()) { 397 if (IsActive()) {
394 theme_id = IDR_THEME_TOOLBAR; 398 theme_id = IDR_THEME_TOOLBAR;
395 } else { 399 } else {
396 if (!data_.incognito) { 400 if (!data_.incognito) {
397 theme_id = IDR_THEME_TAB_BACKGROUND; 401 theme_id = IDR_THEME_TAB_BACKGROUND;
398 } else { 402 } else {
399 theme_id = IDR_THEME_TAB_BACKGROUND_INCOGNITO; 403 theme_id = IDR_THEME_TAB_BACKGROUND_INCOGNITO;
400 } 404 }
401 if (!theme_service_->HasCustomImage(theme_id)) 405 if (!theme_service_->HasCustomImage(theme_id))
402 offset_y = background_offset_y_; 406 offset_y = background_offset_y_;
403 } 407 }
404 SkBitmap* tab_bg = theme_service_->GetBitmapNamed(theme_id); 408 SkBitmap* tab_bg = theme_service_->GetBitmapNamed(theme_id);
405 canvas.TileImageInt(*tab_bg, 409 canvas.TileImageInt(*tab_bg,
406 x() + favicon_bounds_.x(), offset_y + favicon_bounds_.y(), 410 x() + favicon_bounds_.x(), offset_y + favicon_bounds_.y(),
407 favicon_bounds_.x(), favicon_bounds_.y(), 411 favicon_bounds_.x(), favicon_bounds_.y(),
408 favicon_bounds_.width(), favicon_bounds_.height()); 412 favicon_bounds_.width(), favicon_bounds_.height());
409 413
410 if (!IsSelected()) { 414 if (!IsActive()) {
411 double throb_value = GetThrobValue(); 415 double throb_value = GetThrobValue();
412 if (throb_value > 0) { 416 if (throb_value > 0) {
413 SkRect bounds; 417 SkRect bounds;
414 bounds.set(favicon_bounds_.x(), favicon_bounds_.y(), 418 bounds.set(favicon_bounds_.x(), favicon_bounds_.y(),
415 favicon_bounds_.right(), favicon_bounds_.bottom()); 419 favicon_bounds_.right(), favicon_bounds_.bottom());
416 canvas.saveLayerAlpha(&bounds, static_cast<int>(throb_value * 0xff), 420 canvas.saveLayerAlpha(&bounds, static_cast<int>(throb_value * 0xff),
417 SkCanvas::kARGB_ClipLayer_SaveFlag); 421 SkCanvas::kARGB_ClipLayer_SaveFlag);
418 canvas.drawARGB(0, 255, 255, 255, SkXfermode::kClear_Mode); 422 canvas.drawARGB(0, 255, 255, 255, SkXfermode::kClear_Mode);
419 SkBitmap* active_bg = theme_service_->GetBitmapNamed(IDR_THEME_TOOLBAR); 423 SkBitmap* active_bg = theme_service_->GetBitmapNamed(IDR_THEME_TOOLBAR);
420 canvas.TileImageInt(*active_bg, 424 canvas.TileImageInt(*active_bg,
421 x() + favicon_bounds_.x(), favicon_bounds_.y(), 425 x() + favicon_bounds_.x(), favicon_bounds_.y(),
422 favicon_bounds_.x(), favicon_bounds_.y(), 426 favicon_bounds_.x(), favicon_bounds_.y(),
423 favicon_bounds_.width(), favicon_bounds_.height()); 427 favicon_bounds_.width(), favicon_bounds_.height());
424 canvas.restore(); 428 canvas.restore();
425 } 429 }
426 } 430 }
427 431
428 // Now paint the icon. 432 // Now paint the icon.
429 PaintIcon(&canvas); 433 PaintIcon(&canvas);
430 } 434 }
431 435
432 bool TabRendererGtk::ShouldShowIcon() const { 436 bool TabRendererGtk::ShouldShowIcon() const {
433 if (mini() && height() >= GetMinimumUnselectedSize().height()) { 437 if (mini() && height() >= GetMinimumUnselectedSize().height()) {
434 return true; 438 return true;
435 } else if (!data_.show_icon) { 439 } else if (!data_.show_icon) {
436 return false; 440 return false;
437 } else if (IsSelected()) { 441 } else if (IsActive()) {
438 // The selected tab clips favicon before close button. 442 // The active tab clips favicon before close button.
439 return IconCapacity() >= 2; 443 return IconCapacity() >= 2;
440 } 444 }
441 // Non-selected tabs clip close button before favicon. 445 // Non-selected tabs clip close button before favicon.
442 return IconCapacity() >= 1; 446 return IconCapacity() >= 1;
443 } 447 }
444 448
445 // static 449 // static
446 gfx::Size TabRendererGtk::GetMinimumUnselectedSize() { 450 gfx::Size TabRendererGtk::GetMinimumUnselectedSize() {
447 InitResources(); 451 InitResources();
448 452
(...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after
872 kFaviconSize + faviconHeightDelta, 876 kFaviconSize + faviconHeightDelta,
873 true); 877 true);
874 } 878 }
875 } 879 }
876 } 880 }
877 canvas->Restore(); 881 canvas->Restore();
878 } 882 }
879 } 883 }
880 884
881 void TabRendererGtk::PaintTabBackground(gfx::Canvas* canvas) { 885 void TabRendererGtk::PaintTabBackground(gfx::Canvas* canvas) {
882 if (IsSelected()) { 886 if (IsActive()) {
883 PaintActiveTabBackground(canvas); 887 PaintActiveTabBackground(canvas);
884 } else { 888 } else {
885 PaintInactiveTabBackground(canvas); 889 PaintInactiveTabBackground(canvas);
886 890
887 double throb_value = GetThrobValue(); 891 double throb_value = GetThrobValue();
888 if (throb_value > 0) { 892 if (throb_value > 0) {
889 canvas->SaveLayerAlpha(static_cast<int>(throb_value * 0xff), 893 canvas->SaveLayerAlpha(static_cast<int>(throb_value * 0xff),
890 gfx::Rect(width(), height())); 894 gfx::Rect(width(), height()));
891 canvas->AsCanvasSkia()->drawARGB(0, 255, 255, 255, 895 canvas->AsCanvasSkia()->drawARGB(0, 255, 255, 255,
892 SkXfermode::kClear_Mode); 896 SkXfermode::kClear_Mode);
893 PaintActiveTabBackground(canvas); 897 PaintActiveTabBackground(canvas);
894 canvas->Restore(); 898 canvas->Restore();
895 } 899 }
896 } 900 }
897 } 901 }
898 902
899 void TabRendererGtk::PaintInactiveTabBackground(gfx::Canvas* canvas) { 903 void TabRendererGtk::PaintInactiveTabBackground(gfx::Canvas* canvas) {
900 904
901 // The tab image needs to be lined up with the background image 905 // The tab image needs to be lined up with the background image
902 // so that it feels partially transparent. 906 // so that it feels partially transparent.
903 int offset_x = background_offset_x_; 907 int offset_x = background_offset_x_;
904 908
905 int tab_id = data_.incognito ? 909 int tab_id = data_.incognito ?
906 IDR_THEME_TAB_BACKGROUND_INCOGNITO : IDR_THEME_TAB_BACKGROUND; 910 IDR_THEME_TAB_BACKGROUND_INCOGNITO : IDR_THEME_TAB_BACKGROUND;
911 if (IsSelected())
912 tab_id = IDR_THEME_TAB_BACKGROUND_V;
907 913
908 SkBitmap* tab_bg = theme_service_->GetBitmapNamed(tab_id); 914 SkBitmap* tab_bg = theme_service_->GetBitmapNamed(tab_id);
909 915
910 // If the theme is providing a custom background image, then its top edge 916 // If the theme is providing a custom background image, then its top edge
911 // should be at the top of the tab. Otherwise, we assume that the background 917 // should be at the top of the tab. Otherwise, we assume that the background
912 // image is a composited foreground + frame image. 918 // image is a composited foreground + frame image.
913 int offset_y = theme_service_->HasCustomImage(tab_id) ? 919 int offset_y = theme_service_->HasCustomImage(tab_id) ?
914 0 : background_offset_y_; 920 0 : background_offset_y_;
915 921
916 // Draw left edge. 922 // Draw left edge.
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
985 } 991 }
986 992
987 int TabRendererGtk::IconCapacity() const { 993 int TabRendererGtk::IconCapacity() const {
988 if (height() < GetMinimumUnselectedSize().height()) 994 if (height() < GetMinimumUnselectedSize().height())
989 return 0; 995 return 0;
990 return (width() - kLeftPadding - kRightPadding) / kFaviconSize; 996 return (width() - kLeftPadding - kRightPadding) / kFaviconSize;
991 } 997 }
992 998
993 bool TabRendererGtk::ShouldShowCloseBox() const { 999 bool TabRendererGtk::ShouldShowCloseBox() const {
994 // The selected tab never clips close button. 1000 // The selected tab never clips close button.
995 return !mini() && (IsSelected() || IconCapacity() >= 3); 1001 return !mini() && (IsActive() || IconCapacity() >= 3);
996 } 1002 }
997 1003
998 CustomDrawButton* TabRendererGtk::MakeCloseButton() { 1004 CustomDrawButton* TabRendererGtk::MakeCloseButton() {
999 CustomDrawButton* button = new CustomDrawButton(IDR_TAB_CLOSE, 1005 CustomDrawButton* button = new CustomDrawButton(IDR_TAB_CLOSE,
1000 IDR_TAB_CLOSE_P, IDR_TAB_CLOSE_H, IDR_TAB_CLOSE); 1006 IDR_TAB_CLOSE_P, IDR_TAB_CLOSE_H, IDR_TAB_CLOSE);
1001 1007
1002 gtk_widget_set_tooltip_text(button->widget(), 1008 gtk_widget_set_tooltip_text(button->widget(),
1003 l10n_util::GetStringUTF8(IDS_TOOLTIP_CLOSE_TAB).c_str()); 1009 l10n_util::GetStringUTF8(IDS_TOOLTIP_CLOSE_TAB).c_str());
1004 1010
1005 g_signal_connect(button->widget(), "clicked", 1011 g_signal_connect(button->widget(), "clicked",
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
1088 1094
1089 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); 1095 ResourceBundle& rb = ResourceBundle::GetSharedInstance();
1090 const gfx::Font& base_font = rb.GetFont(ResourceBundle::BaseFont); 1096 const gfx::Font& base_font = rb.GetFont(ResourceBundle::BaseFont);
1091 title_font_ = new gfx::Font(base_font.GetFontName(), kFontPixelSize); 1097 title_font_ = new gfx::Font(base_font.GetFontName(), kFontPixelSize);
1092 title_font_height_ = title_font_->GetHeight(); 1098 title_font_height_ = title_font_->GetHeight();
1093 1099
1094 crashed_favicon = rb.GetBitmapNamed(IDR_SAD_FAVICON); 1100 crashed_favicon = rb.GetBitmapNamed(IDR_SAD_FAVICON);
1095 1101
1096 initialized_ = true; 1102 initialized_ = true;
1097 } 1103 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/gtk/tabs/tab_renderer_gtk.h ('k') | chrome/browser/ui/gtk/tabs/tab_strip_gtk.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698