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/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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
67 // don't actually overlap the toolbar, so this is used to know how many pixels | 67 // don't actually overlap the toolbar, so this is used to know how many pixels |
68 // at the bottom of the tab images are to be ignored. | 68 // at the bottom of the tab images are to be ignored. |
69 const int kToolbarOverlap = 1; | 69 const int kToolbarOverlap = 1; |
70 | 70 |
71 // How long the hover state takes. | 71 // How long the hover state takes. |
72 const int kHoverDurationMs = 90; | 72 const int kHoverDurationMs = 90; |
73 | 73 |
74 // How opaque to make the hover state (out of 1). | 74 // How opaque to make the hover state (out of 1). |
75 const double kHoverOpacity = 0.33; | 75 const double kHoverOpacity = 0.33; |
76 | 76 |
77 // Opacity for non-active selected tabs. | |
78 const double kSelectedTabOpacity = .45; | |
dpapad
2011/10/31 20:29:34
nit: s/.45/0.45 for consistency within this file.
| |
79 | |
80 // Selected (but not active) tabs have their throb value scaled down by this. | |
81 const double kSelectedTabThrobScale = .5; | |
dpapad
2011/10/31 20:29:34
nit: same here.
| |
82 | |
77 // Max opacity for the mini-tab title change animation. | 83 // Max opacity for the mini-tab title change animation. |
78 const double kMiniTitleChangeThrobOpacity = 0.75; | 84 const double kMiniTitleChangeThrobOpacity = 0.75; |
79 | 85 |
80 // Duration for when the title of an inactive mini-tab changes. | 86 // Duration for when the title of an inactive mini-tab changes. |
81 const int kMiniTitleChangeThrobDuration = 1000; | 87 const int kMiniTitleChangeThrobDuration = 1000; |
82 | 88 |
83 // The vertical and horizontal offset used to position the close button | 89 // The vertical and horizontal offset used to position the close button |
84 // in the tab. TODO(jhawkins): Ask pkasting what the Fuzz is about. | 90 // in the tab. TODO(jhawkins): Ask pkasting what the Fuzz is about. |
85 const int kCloseButtonVertFuzz = 0; | 91 const int kCloseButtonVertFuzz = 0; |
86 const int kCloseButtonHorzFuzz = 5; | 92 const int kCloseButtonHorzFuzz = 5; |
(...skipping 851 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
938 CairoCachedSurface* active_image_r = | 944 CairoCachedSurface* active_image_r = |
939 theme_service_->GetSurfaceNamed(right_idr, widget); | 945 theme_service_->GetSurfaceNamed(right_idr, widget); |
940 active_image_r->SetSource(cr, width() - active_image_r->Width(), 0); | 946 active_image_r->SetSource(cr, width() - active_image_r->Width(), 0); |
941 cairo_paint(cr); | 947 cairo_paint(cr); |
942 } | 948 } |
943 | 949 |
944 void TabRendererGtk::PaintInactiveTabBackground(GtkWidget* widget, | 950 void TabRendererGtk::PaintInactiveTabBackground(GtkWidget* widget, |
945 cairo_t* cr) { | 951 cairo_t* cr) { |
946 int theme_id = data_.incognito ? | 952 int theme_id = data_.incognito ? |
947 IDR_THEME_TAB_BACKGROUND_INCOGNITO : IDR_THEME_TAB_BACKGROUND; | 953 IDR_THEME_TAB_BACKGROUND_INCOGNITO : IDR_THEME_TAB_BACKGROUND; |
948 if (IsSelected()) | |
949 theme_id = IDR_THEME_TAB_BACKGROUND_V; | |
950 | 954 |
951 CairoCachedSurface* tab_bg = | 955 CairoCachedSurface* tab_bg = |
952 theme_service_->GetSurfaceNamed(theme_id, widget); | 956 theme_service_->GetSurfaceNamed(theme_id, widget); |
953 | 957 |
954 // If the theme is providing a custom background image, then its top edge | 958 // If the theme is providing a custom background image, then its top edge |
955 // should be at the top of the tab. Otherwise, we assume that the background | 959 // should be at the top of the tab. Otherwise, we assume that the background |
956 // image is a composited foreground + frame image. | 960 // image is a composited foreground + frame image. |
957 int offset_y = theme_service_->HasCustomImage(theme_id) ? | 961 int offset_y = theme_service_->HasCustomImage(theme_id) ? |
958 0 : background_offset_y_; | 962 0 : background_offset_y_; |
959 | 963 |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1017 G_CALLBACK(OnEnterNotifyEventThunk), this); | 1021 G_CALLBACK(OnEnterNotifyEventThunk), this); |
1018 g_signal_connect(button->widget(), "leave-notify-event", | 1022 g_signal_connect(button->widget(), "leave-notify-event", |
1019 G_CALLBACK(OnLeaveNotifyEventThunk), this); | 1023 G_CALLBACK(OnLeaveNotifyEventThunk), this); |
1020 gtk_widget_set_can_focus(button->widget(), FALSE); | 1024 gtk_widget_set_can_focus(button->widget(), FALSE); |
1021 gtk_fixed_put(GTK_FIXED(tab_.get()), button->widget(), 0, 0); | 1025 gtk_fixed_put(GTK_FIXED(tab_.get()), button->widget(), 0, 0); |
1022 | 1026 |
1023 return button; | 1027 return button; |
1024 } | 1028 } |
1025 | 1029 |
1026 double TabRendererGtk::GetThrobValue() { | 1030 double TabRendererGtk::GetThrobValue() { |
1031 bool is_selected = IsSelected(); | |
1032 double min = is_selected ? kSelectedTabOpacity : 0; | |
1033 double scale = is_selected ? kSelectedTabThrobScale : 1; | |
1034 | |
1027 if (mini_title_animation_.get() && mini_title_animation_->is_animating()) { | 1035 if (mini_title_animation_.get() && mini_title_animation_->is_animating()) { |
1028 return mini_title_animation_->GetCurrentValue() * | 1036 return mini_title_animation_->GetCurrentValue() * |
1029 kMiniTitleChangeThrobOpacity; | 1037 kMiniTitleChangeThrobOpacity * scale + min; |
1030 } | 1038 } |
1031 return hover_animation_.get() ? | 1039 |
1032 kHoverOpacity * hover_animation_->GetCurrentValue() : 0; | 1040 if (hover_animation_.get()) |
1041 return kHoverOpacity * hover_animation_->GetCurrentValue() * scale + min; | |
1042 | |
1043 return is_selected ? kSelectedTabOpacity : 0; | |
1033 } | 1044 } |
1034 | 1045 |
1035 void TabRendererGtk::CloseButtonClicked() { | 1046 void TabRendererGtk::CloseButtonClicked() { |
1036 // Nothing to do. | 1047 // Nothing to do. |
1037 } | 1048 } |
1038 | 1049 |
1039 void TabRendererGtk::OnCloseButtonClicked(GtkWidget* widget) { | 1050 void TabRendererGtk::OnCloseButtonClicked(GtkWidget* widget) { |
1040 CloseButtonClicked(); | 1051 CloseButtonClicked(); |
1041 } | 1052 } |
1042 | 1053 |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1102 | 1113 |
1103 close_button_width_ = rb.GetBitmapNamed(IDR_TAB_CLOSE)->width(); | 1114 close_button_width_ = rb.GetBitmapNamed(IDR_TAB_CLOSE)->width(); |
1104 close_button_height_ = rb.GetBitmapNamed(IDR_TAB_CLOSE)->height(); | 1115 close_button_height_ = rb.GetBitmapNamed(IDR_TAB_CLOSE)->height(); |
1105 | 1116 |
1106 const gfx::Font& base_font = rb.GetFont(ResourceBundle::BaseFont); | 1117 const gfx::Font& base_font = rb.GetFont(ResourceBundle::BaseFont); |
1107 title_font_ = new gfx::Font(base_font.GetFontName(), kFontPixelSize); | 1118 title_font_ = new gfx::Font(base_font.GetFontName(), kFontPixelSize); |
1108 title_font_height_ = title_font_->GetHeight(); | 1119 title_font_height_ = title_font_->GetHeight(); |
1109 | 1120 |
1110 initialized_ = true; | 1121 initialized_ = true; |
1111 } | 1122 } |
OLD | NEW |