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

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

Issue 155701: Changes the width of pinned tabs to be slightly bigger. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 5 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
« no previous file with comments | « chrome/browser/gtk/tabs/tab_renderer_gtk.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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/gtk/tabs/tab_renderer_gtk.h" 5 #include "chrome/browser/gtk/tabs/tab_renderer_gtk.h"
6 6
7 #include "app/gfx/canvas_paint.h" 7 #include "app/gfx/canvas_paint.h"
8 #include "app/gfx/favicon_size.h" 8 #include "app/gfx/favicon_size.h"
9 #include "app/l10n_util.h" 9 #include "app/l10n_util.h"
10 #include "app/resource_bundle.h" 10 #include "app/resource_bundle.h"
(...skipping 12 matching lines...) Expand all
23 namespace { 23 namespace {
24 24
25 const int kLeftPadding = 16; 25 const int kLeftPadding = 16;
26 const int kTopPadding = 6; 26 const int kTopPadding = 6;
27 const int kRightPadding = 15; 27 const int kRightPadding = 15;
28 const int kBottomPadding = 5; 28 const int kBottomPadding = 5;
29 const int kFavIconTitleSpacing = 4; 29 const int kFavIconTitleSpacing = 4;
30 const int kTitleCloseButtonSpacing = 5; 30 const int kTitleCloseButtonSpacing = 5;
31 const int kStandardTitleWidth = 175; 31 const int kStandardTitleWidth = 175;
32 const int kDropShadowOffset = 2; 32 const int kDropShadowOffset = 2;
33 // Value added to pinned_tab_pref_width_ to get 33 // Preferred width of pinned tabs.
34 // pinned_tab_renderer_as_tab_width_. See description of 34 const int kPinnedTabWidth = 56;
35 // pinned_tab_renderer_as_tab_width_ for details. 35 // When a non-pinned tab is pinned the width of the tab animates. If the width
36 const int kPinnedTabRendererAsNonPinnedWidth = 30; 36 // of a pinned tab is >= kPinnedTabRendererAsTabWidth then the tab is rendered
37 // as a normal tab. This is done to avoid having the title immediately
38 // disappear when transitioning a tab from normal to pinned.
39 const int kPinnedTabRendererAsTabWidth = kPinnedTabWidth + 30;
37 40
38 // How long the hover state takes. 41 // How long the hover state takes.
39 const int kHoverDurationMs = 90; 42 const int kHoverDurationMs = 90;
40 43
41 // How opaque to make the hover state (out of 1). 44 // How opaque to make the hover state (out of 1).
42 const double kHoverOpacity = 0.33; 45 const double kHoverOpacity = 0.33;
43 46
44 const SkScalar kTabCapWidth = 15; 47 const SkScalar kTabCapWidth = 15;
45 const SkScalar kTabTopCurveWidth = 4; 48 const SkScalar kTabTopCurveWidth = 4;
46 const SkScalar kTabBottomCurveWidth = 3; 49 const SkScalar kTabBottomCurveWidth = 3;
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 bool TabRendererGtk::initialized_ = false; 100 bool TabRendererGtk::initialized_ = false;
98 TabRendererGtk::TabImage TabRendererGtk::tab_active_ = {0}; 101 TabRendererGtk::TabImage TabRendererGtk::tab_active_ = {0};
99 TabRendererGtk::TabImage TabRendererGtk::tab_inactive_ = {0}; 102 TabRendererGtk::TabImage TabRendererGtk::tab_inactive_ = {0};
100 TabRendererGtk::TabImage TabRendererGtk::tab_alpha = {0}; 103 TabRendererGtk::TabImage TabRendererGtk::tab_alpha = {0};
101 gfx::Font* TabRendererGtk::title_font_ = NULL; 104 gfx::Font* TabRendererGtk::title_font_ = NULL;
102 int TabRendererGtk::title_font_height_ = 0; 105 int TabRendererGtk::title_font_height_ = 0;
103 int TabRendererGtk::close_button_width_ = 0; 106 int TabRendererGtk::close_button_width_ = 0;
104 int TabRendererGtk::close_button_height_ = 0; 107 int TabRendererGtk::close_button_height_ = 0;
105 SkColor TabRendererGtk::selected_title_color_ = SK_ColorBLACK; 108 SkColor TabRendererGtk::selected_title_color_ = SK_ColorBLACK;
106 SkColor TabRendererGtk::unselected_title_color_ = SkColorSetRGB(64, 64, 64); 109 SkColor TabRendererGtk::unselected_title_color_ = SkColorSetRGB(64, 64, 64);
107 int TabRendererGtk::pinned_tab_renderer_as_tab_width_ = 0;
108 int TabRendererGtk::pinned_tab_pref_width_ = 0;
109 110
110 //////////////////////////////////////////////////////////////////////////////// 111 ////////////////////////////////////////////////////////////////////////////////
111 // TabRendererGtk::LoadingAnimation, public: 112 // TabRendererGtk::LoadingAnimation, public:
112 // 113 //
113 TabRendererGtk::LoadingAnimation::LoadingAnimation( 114 TabRendererGtk::LoadingAnimation::LoadingAnimation(
114 ThemeProvider* theme_provider) 115 ThemeProvider* theme_provider)
115 : data_(new Data(theme_provider)), 116 : data_(new Data(theme_provider)),
116 theme_provider_(theme_provider), 117 theme_provider_(theme_provider),
117 animation_state_(ANIMATION_NONE), 118 animation_state_(ANIMATION_NONE),
118 animation_frame_(0) { 119 animation_frame_(0) {
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
312 313
313 // static 314 // static
314 gfx::Size TabRendererGtk::GetStandardSize() { 315 gfx::Size TabRendererGtk::GetStandardSize() {
315 gfx::Size standard_size = GetMinimumUnselectedSize(); 316 gfx::Size standard_size = GetMinimumUnselectedSize();
316 standard_size.Enlarge(kFavIconTitleSpacing + kStandardTitleWidth, 0); 317 standard_size.Enlarge(kFavIconTitleSpacing + kStandardTitleWidth, 0);
317 return standard_size; 318 return standard_size;
318 } 319 }
319 320
320 // static 321 // static
321 int TabRendererGtk::GetPinnedWidth() { 322 int TabRendererGtk::GetPinnedWidth() {
322 return pinned_tab_pref_width_; 323 return kPinnedTabWidth;
323 } 324 }
324 325
325 // static 326 // static
326 int TabRendererGtk::GetContentHeight() { 327 int TabRendererGtk::GetContentHeight() {
327 // The height of the content of the Tab is the largest of the favicon, 328 // The height of the content of the Tab is the largest of the favicon,
328 // the title text and the close button graphic. 329 // the title text and the close button graphic.
329 int content_height = std::max(kFavIconSize, title_font_height_); 330 int content_height = std::max(kFavIconSize, title_font_height_);
330 return std::max(content_height, close_button_height_); 331 return std::max(content_height, close_button_height_);
331 } 332 }
332 333
(...skipping 11 matching lines...) Expand all
344 tab_active_.r_width = tab_active_.image_r->width(); 345 tab_active_.r_width = tab_active_.image_r->width();
345 346
346 tab_inactive_.image_l = rb.GetBitmapNamed(IDR_TAB_INACTIVE_LEFT); 347 tab_inactive_.image_l = rb.GetBitmapNamed(IDR_TAB_INACTIVE_LEFT);
347 tab_inactive_.image_c = rb.GetBitmapNamed(IDR_TAB_INACTIVE_CENTER); 348 tab_inactive_.image_c = rb.GetBitmapNamed(IDR_TAB_INACTIVE_CENTER);
348 tab_inactive_.image_r = rb.GetBitmapNamed(IDR_TAB_INACTIVE_RIGHT); 349 tab_inactive_.image_r = rb.GetBitmapNamed(IDR_TAB_INACTIVE_RIGHT);
349 tab_inactive_.l_width = tab_inactive_.image_l->width(); 350 tab_inactive_.l_width = tab_inactive_.image_l->width();
350 tab_inactive_.r_width = tab_inactive_.image_r->width(); 351 tab_inactive_.r_width = tab_inactive_.image_r->width();
351 352
352 close_button_width_ = rb.GetBitmapNamed(IDR_TAB_CLOSE)->width(); 353 close_button_width_ = rb.GetBitmapNamed(IDR_TAB_CLOSE)->width();
353 close_button_height_ = rb.GetBitmapNamed(IDR_TAB_CLOSE)->height(); 354 close_button_height_ = rb.GetBitmapNamed(IDR_TAB_CLOSE)->height();
354
355 pinned_tab_pref_width_ = kLeftPadding + kFavIconSize + kRightPadding;
356 pinned_tab_renderer_as_tab_width_ = pinned_tab_pref_width_ +
357 kPinnedTabRendererAsNonPinnedWidth;
358 } 355 }
359 356
360 // static 357 // static
361 void TabRendererGtk::SetSelectedTitleColor(SkColor color) { 358 void TabRendererGtk::SetSelectedTitleColor(SkColor color) {
362 selected_title_color_ = color; 359 selected_title_color_ = color;
363 } 360 }
364 361
365 // static 362 // static
366 void TabRendererGtk::SetUnselectedTitleColor(SkColor color) { 363 void TabRendererGtk::SetUnselectedTitleColor(SkColor color) {
367 unselected_title_color_ = color; 364 unselected_title_color_ = color;
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
435 return; 432 return;
436 433
437 // See if the model changes whether the icons should be painted. 434 // See if the model changes whether the icons should be painted.
438 const bool show_icon = ShouldShowIcon(); 435 const bool show_icon = ShouldShowIcon();
439 const bool show_close_button = ShouldShowCloseBox(); 436 const bool show_close_button = ShouldShowCloseBox();
440 if (show_icon != showing_icon_ || 437 if (show_icon != showing_icon_ ||
441 show_close_button != showing_close_button_) 438 show_close_button != showing_close_button_)
442 Layout(); 439 Layout();
443 440
444 PaintTabBackground(canvas); 441 PaintTabBackground(canvas);
445 if (!is_pinned() || width() > pinned_tab_renderer_as_tab_width_) 442 if (!is_pinned() || width() > kPinnedTabRendererAsTabWidth)
446 PaintTitle(canvas); 443 PaintTitle(canvas);
447 444
448 if (show_icon) 445 if (show_icon)
449 PaintIcon(canvas); 446 PaintIcon(canvas);
450 } 447 }
451 448
452 SkBitmap TabRendererGtk::PaintBitmap() { 449 SkBitmap TabRendererGtk::PaintBitmap() {
453 gfx::Canvas canvas(width(), height(), false); 450 gfx::Canvas canvas(width(), height(), false);
454 Paint(&canvas); 451 Paint(&canvas);
455 return canvas.ExtractBitmap(); 452 return canvas.ExtractBitmap();
(...skipping 15 matching lines...) Expand all
471 468
472 // Figure out who is tallest. 469 // Figure out who is tallest.
473 int content_height = GetContentHeight(); 470 int content_height = GetContentHeight();
474 471
475 // Size the Favicon. 472 // Size the Favicon.
476 showing_icon_ = ShouldShowIcon(); 473 showing_icon_ = ShouldShowIcon();
477 if (showing_icon_) { 474 if (showing_icon_) {
478 int favicon_top = kTopPadding + (content_height - kFavIconSize) / 2; 475 int favicon_top = kTopPadding + (content_height - kFavIconSize) / 2;
479 favicon_bounds_.SetRect(local_bounds.x(), favicon_top, 476 favicon_bounds_.SetRect(local_bounds.x(), favicon_top,
480 kFavIconSize, kFavIconSize); 477 kFavIconSize, kFavIconSize);
478 if (is_pinned() && bounds_.width() < kPinnedTabRendererAsTabWidth)
479 favicon_bounds_.set_x((bounds_.width() - kFavIconSize) / 2);
481 } else { 480 } else {
482 favicon_bounds_.SetRect(local_bounds.x(), local_bounds.y(), 0, 0); 481 favicon_bounds_.SetRect(local_bounds.x(), local_bounds.y(), 0, 0);
483 } 482 }
484 483
485 // Size the Close button. 484 // Size the Close button.
486 showing_close_button_ = ShouldShowCloseBox(); 485 showing_close_button_ = ShouldShowCloseBox();
487 if (showing_close_button_) { 486 if (showing_close_button_) {
488 int close_button_top = 487 int close_button_top =
489 kTopPadding + kCloseButtonVertFuzz + 488 kTopPadding + kCloseButtonVertFuzz +
490 (content_height - close_button_height_) / 2; 489 (content_height - close_button_height_) / 2;
491 close_button_bounds_.SetRect(local_bounds.width() + kCloseButtonHorzFuzz, 490 close_button_bounds_.SetRect(local_bounds.width() + kCloseButtonHorzFuzz,
492 close_button_top, close_button_width_, 491 close_button_top, close_button_width_,
493 close_button_height_); 492 close_button_height_);
494 } else { 493 } else {
495 close_button_bounds_.SetRect(0, 0, 0, 0); 494 close_button_bounds_.SetRect(0, 0, 0, 0);
496 } 495 }
497 496
498 if (!is_pinned() || width() >= pinned_tab_renderer_as_tab_width_) { 497 if (!is_pinned() || width() >= kPinnedTabRendererAsTabWidth) {
499 // Size the Title text to fill the remaining space. 498 // Size the Title text to fill the remaining space.
500 int title_left = favicon_bounds_.right() + kFavIconTitleSpacing; 499 int title_left = favicon_bounds_.right() + kFavIconTitleSpacing;
501 int title_top = kTopPadding + (content_height - title_font_height_) / 2; 500 int title_top = kTopPadding + (content_height - title_font_height_) / 2;
502 501
503 // If the user has big fonts, the title will appear rendered too far down 502 // If the user has big fonts, the title will appear rendered too far down
504 // on the y-axis if we use the regular top padding, so we need to adjust it 503 // on the y-axis if we use the regular top padding, so we need to adjust it
505 // so that the text appears centered. 504 // so that the text appears centered.
506 gfx::Size minimum_size = GetMinimumUnselectedSize(); 505 gfx::Size minimum_size = GetMinimumUnselectedSize();
507 int text_height = title_top + title_font_height_ + kBottomPadding; 506 int text_height = title_top + title_font_height_ + kBottomPadding;
508 if (text_height > minimum_size.height()) 507 if (text_height > minimum_size.height())
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after
821 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); 820 ResourceBundle& rb = ResourceBundle::GetSharedInstance();
822 // Force the font size to 10pt. 821 // Force the font size to 10pt.
823 gfx::Font base_font = rb.GetFont(ResourceBundle::BaseFont); 822 gfx::Font base_font = rb.GetFont(ResourceBundle::BaseFont);
824 title_font_ = new gfx::Font(gfx::Font::CreateFont(base_font.FontName(), 10)); 823 title_font_ = new gfx::Font(gfx::Font::CreateFont(base_font.FontName(), 10));
825 title_font_height_ = title_font_->height(); 824 title_font_height_ = title_font_->height();
826 825
827 crashed_fav_icon = rb.GetBitmapNamed(IDR_SAD_FAVICON); 826 crashed_fav_icon = rb.GetBitmapNamed(IDR_SAD_FAVICON);
828 827
829 initialized_ = true; 828 initialized_ = true;
830 } 829 }
OLDNEW
« no previous file with comments | « chrome/browser/gtk/tabs/tab_renderer_gtk.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698