| OLD | NEW |
| 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/l10n_util.h" | 7 #include "app/l10n_util.h" |
| 8 #include "app/resource_bundle.h" | 8 #include "app/resource_bundle.h" |
| 9 #include "chrome/browser/browser.h" | 9 #include "chrome/browser/browser.h" |
| 10 #include "chrome/browser/browser_theme_provider.h" | 10 #include "chrome/browser/browser_theme_provider.h" |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 if (animation_state_ != ANIMATION_NONE) { | 118 if (animation_state_ != ANIMATION_NONE) { |
| 119 animation_frame_ = ++animation_frame_ % | 119 animation_frame_ = ++animation_frame_ % |
| 120 ((animation_state_ == ANIMATION_WAITING) ? | 120 ((animation_state_ == ANIMATION_WAITING) ? |
| 121 data_->waiting_animation_frame_count : | 121 data_->waiting_animation_frame_count : |
| 122 data_->loading_animation_frame_count); | 122 data_->loading_animation_frame_count); |
| 123 } else { | 123 } else { |
| 124 animation_frame_ = 0; | 124 animation_frame_ = 0; |
| 125 } | 125 } |
| 126 } | 126 } |
| 127 | 127 |
| 128 bool TabRendererGtk::IsVisible() { | |
| 129 // TODO(jhawkins): Implement this and SetVisible. | |
| 130 return true; | |
| 131 } | |
| 132 | |
| 133 //////////////////////////////////////////////////////////////////////////////// | 128 //////////////////////////////////////////////////////////////////////////////// |
| 134 // TabRendererGtk, public: | 129 // TabRendererGtk, public: |
| 135 | 130 |
| 136 TabRendererGtk::TabRendererGtk() | 131 TabRendererGtk::TabRendererGtk() |
| 137 : showing_icon_(false), | 132 : showing_icon_(false), |
| 138 showing_download_icon_(false), | 133 showing_download_icon_(false), |
| 139 showing_close_button_(false), | 134 showing_close_button_(false), |
| 140 fav_icon_hiding_offset_(0), | 135 fav_icon_hiding_offset_(0), |
| 141 should_display_crashed_favicon_(false), | 136 should_display_crashed_favicon_(false), |
| 142 loading_animation_(&loading_animation_data) { | 137 loading_animation_(&loading_animation_data) { |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 176 | 171 |
| 177 void TabRendererGtk::UpdateFromModel() { | 172 void TabRendererGtk::UpdateFromModel() { |
| 178 // Force a layout, since the tab may have grown a favicon. | 173 // Force a layout, since the tab may have grown a favicon. |
| 179 Layout(); | 174 Layout(); |
| 180 } | 175 } |
| 181 | 176 |
| 182 bool TabRendererGtk::IsSelected() const { | 177 bool TabRendererGtk::IsSelected() const { |
| 183 return true; | 178 return true; |
| 184 } | 179 } |
| 185 | 180 |
| 181 bool TabRendererGtk::IsVisible() const { |
| 182 return GTK_WIDGET_FLAGS(tab_.get()) & GTK_VISIBLE; |
| 183 } |
| 184 |
| 185 void TabRendererGtk::SetVisible(bool visible) const { |
| 186 if (visible) { |
| 187 gtk_widget_show(tab_.get()); |
| 188 } else { |
| 189 gtk_widget_hide(tab_.get()); |
| 190 } |
| 191 } |
| 192 |
| 186 void TabRendererGtk::CloseButtonResized(const gfx::Rect& bounds) { | 193 void TabRendererGtk::CloseButtonResized(const gfx::Rect& bounds) { |
| 187 // Nothing to do. | 194 // Nothing to do. |
| 188 } | 195 } |
| 189 | 196 |
| 190 void TabRendererGtk::ValidateLoadingAnimation(AnimationState animation_state) { | 197 void TabRendererGtk::ValidateLoadingAnimation(AnimationState animation_state) { |
| 191 loading_animation_.ValidateLoadingAnimation(animation_state); | 198 loading_animation_.ValidateLoadingAnimation(animation_state); |
| 192 } | 199 } |
| 193 | 200 |
| 194 // static | 201 // static |
| 195 gfx::Size TabRendererGtk::GetMinimumUnselectedSize() { | 202 gfx::Size TabRendererGtk::GetMinimumUnselectedSize() { |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 330 Browser::FormatTitleForDisplay(&title); | 337 Browser::FormatTitleForDisplay(&title); |
| 331 } | 338 } |
| 332 | 339 |
| 333 SkColor title_color = IsSelected() ? kSelectedTitleColor | 340 SkColor title_color = IsSelected() ? kSelectedTitleColor |
| 334 : kUnselectedTitleColor; | 341 : kUnselectedTitleColor; |
| 335 canvas.DrawStringInt(title, *title_font_, title_color, title_bounds_.x(), | 342 canvas.DrawStringInt(title, *title_font_, title_color, title_bounds_.x(), |
| 336 title_bounds_.y(), title_bounds_.width(), | 343 title_bounds_.y(), title_bounds_.width(), |
| 337 title_bounds_.height()); | 344 title_bounds_.height()); |
| 338 } | 345 } |
| 339 | 346 |
| 347 void TabRendererGtk::SchedulePaint() { |
| 348 gtk_widget_queue_draw(tab_.get()); |
| 349 } |
| 350 |
| 340 void TabRendererGtk::Layout() { | 351 void TabRendererGtk::Layout() { |
| 341 gfx::Rect local_bounds = bounds_; | 352 gfx::Rect local_bounds = bounds_; |
| 342 if (local_bounds.IsEmpty()) | 353 if (local_bounds.IsEmpty()) |
| 343 return; | 354 return; |
| 344 local_bounds.Inset(kLeftPadding, kTopPadding, kRightPadding, kBottomPadding); | 355 local_bounds.Inset(kLeftPadding, kTopPadding, kRightPadding, kBottomPadding); |
| 345 | 356 |
| 346 // Figure out who is tallest. | 357 // Figure out who is tallest. |
| 347 int content_height = GetContentHeight(); | 358 int content_height = GetContentHeight(); |
| 348 | 359 |
| 349 // Size the Favicon. | 360 // Size the Favicon. |
| (...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 589 LoadTabImages(); | 600 LoadTabImages(); |
| 590 | 601 |
| 591 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | 602 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
| 592 title_font_ = new gfx::Font(rb.GetFont(ResourceBundle::BaseFont)); | 603 title_font_ = new gfx::Font(rb.GetFont(ResourceBundle::BaseFont)); |
| 593 title_font_height_ = title_font_->height(); | 604 title_font_height_ = title_font_->height(); |
| 594 | 605 |
| 595 InitializeLoadingAnimationData(&rb, &loading_animation_data); | 606 InitializeLoadingAnimationData(&rb, &loading_animation_data); |
| 596 | 607 |
| 597 initialized_ = true; | 608 initialized_ = true; |
| 598 } | 609 } |
| OLD | NEW |