namespace gfx {
class Animation;
class AnimationContainer;
-class Font;
class LinearAnimation;
class MultiAnimation;
+class ThrobAnimation;
}
namespace views {
class ImageButton;
+class Label;
}
///////////////////////////////////////////////////////////////////////////////
//
-// A View that renders a Tab, either in a TabStrip or in a DraggedTabView.
+// A View that renders a Tab in a TabStrip.
//
///////////////////////////////////////////////////////////////////////////////
class Tab : public gfx::AnimationDelegate,
explicit Tab(TabController* controller);
virtual ~Tab();
- TabController* controller() const { return controller_; }
-
// Used to set/check whether this Tab is being animated closed.
void set_closing(bool closing) { closing_ = closing; }
bool closing() const { return closing_; }
void set_dragging(bool dragging) { dragging_ = dragging; }
bool dragging() const { return dragging_; }
+ // Used to mark the tab as having been detached. Once this has happened, the
+ // tab should be invisibly closed. This is irreversible.
+ void set_detached() { detached_ = true; }
+ bool detached() const { return detached_; }
+
// Sets the container all animations run from.
void set_animation_container(gfx::AnimationContainer* container);
- // Set the theme provider - because we get detached, we are frequently
- // outside of a hierarchy with a theme provider at the top. This should be
- // called whenever we're detached or attached to a hierarchy.
- void set_theme_provider(ui::ThemeProvider* provider) {
- theme_provider_ = provider;
- }
-
// Returns true if this tab is the active tab.
bool IsActive() const;
return &hover_controller_;
}
+ // Returns the inset within the first dragged tab to use when calculating the
+ // "drag insertion point". If we simply used the x-coordinate of the tab,
+ // we'd be calculating based on a point well before where the user considers
+ // the tab to "be". The value here is chosen to "feel good" based on the
+ // widths of the tab images and the tab overlap.
+ //
+ // Note that this must return a value smaller than the midpoint of any tab's
+ // width, or else the user won't be able to drag a tab to the left of the
+ // first tab in the strip.
+ static int leading_width_for_drag() { return 16; }
+
// Returns the minimum possible size of a single unselected Tab.
static gfx::Size GetMinimumUnselectedSize();
// Returns the minimum possible size of a selected Tab. Selected tabs must
friend class TabStripTest;
FRIEND_TEST_ALL_PREFIXES(TabStripTest, TabHitTestMaskWhenStacked);
+ FRIEND_TEST_ALL_PREFIXES(TabStripTest, ClippedTabCloseButton);
// The animation object used to swap the favicon with the sad tab icon.
class FaviconCrashAnimation;
virtual void GetHitTestMask(HitTestSource source,
gfx::Path* path) const OVERRIDE;
virtual bool GetTooltipText(const gfx::Point& p,
- string16* tooltip) const OVERRIDE;
+ base::string16* tooltip) const OVERRIDE;
virtual bool GetTooltipTextOrigin(const gfx::Point& p,
gfx::Point* origin) const OVERRIDE;
- virtual ui::ThemeProvider* GetThemeProvider() const OVERRIDE;
virtual bool OnMousePressed(const ui::MouseEvent& event) OVERRIDE;
virtual bool OnMouseDragged(const ui::MouseEvent& event) OVERRIDE;
virtual void OnMouseReleased(const ui::MouseEvent& event) OVERRIDE;
virtual void OnMouseEntered(const ui::MouseEvent& event) OVERRIDE;
virtual void OnMouseMoved(const ui::MouseEvent& event) OVERRIDE;
virtual void OnMouseExited(const ui::MouseEvent& event) OVERRIDE;
- virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE;
+ virtual void GetAccessibleState(ui::AXViewState* state) OVERRIDE;
// Overridden from ui::EventHandler:
virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE;
- // Returns the bounds of the title and icon.
- const gfx::Rect& GetTitleBounds() const;
- const gfx::Rect& GetIconBounds() const;
-
// Invoked from Layout to adjust the position of the favicon or media
// indicator for mini tabs.
void MaybeAdjustLeftForMiniTab(gfx::Rect* bounds) const;
// Paint various portions of the Tab
void PaintTabBackground(gfx::Canvas* canvas);
- void PaintInactiveTabBackgroundWithTitleChange(
- gfx::Canvas* canvas,
- gfx::MultiAnimation* animation);
+ void PaintInactiveTabBackgroundWithTitleChange(gfx::Canvas* canvas);
void PaintInactiveTabBackground(gfx::Canvas* canvas);
void PaintInactiveTabBackgroundUsingResourceId(gfx::Canvas* canvas,
int tab_id);
void PaintActiveTabBackground(gfx::Canvas* canvas);
- // Paints the favicon, media indicator icon, etc., mirrored for RTL if needed.
+ // Paints the favicon and media indicator icon, mirrored for RTL if needed.
void PaintIcon(gfx::Canvas* canvas);
void PaintMediaIndicator(gfx::Canvas* canvas);
- void PaintTitle(gfx::Canvas* canvas, SkColor title_color);
// Invoked if data_.network_state changes, or the network_state is not none.
void AdvanceLoadingAnimation(TabRendererData::NetworkState old_state,
ui::ScaleFactor scale_factor,
const gfx::ImageSkia& image);
- // The controller.
- // WARNING: this is null during detached tab dragging.
+ // The controller, never NULL.
TabController* controller_;
TabRendererData data_;
// True if the tab is being dragged.
bool dragging_;
+ // True if the tab has been detached.
+ bool detached_;
+
// The offset used to animate the favicon location. This is used when the tab
// crashes.
int favicon_hiding_offset_;
bool should_display_crashed_favicon_;
// Whole-tab throbbing "pulse" animation.
- scoped_ptr<gfx::Animation> tab_animation_;
+ scoped_ptr<gfx::ThrobAnimation> pulse_animation_;
+
+ scoped_ptr<gfx::MultiAnimation> mini_title_change_animation_;
// Crash icon animation (in place of favicon).
scoped_ptr<gfx::LinearAnimation> crash_icon_animation_;
scoped_refptr<gfx::AnimationContainer> animation_container_;
views::ImageButton* close_button_;
-
- ui::ThemeProvider* theme_provider_;
+ views::Label* title_;
bool tab_activated_with_last_gesture_begin_;
// The bounds of various sections of the display.
gfx::Rect favicon_bounds_;
- gfx::Rect title_bounds_;
gfx::Rect media_indicator_bounds_;
// The offset used to paint the inactive background image.
// The current color of the close button.
SkColor close_button_color_;
- static gfx::Font* font_;
- static int font_height_;
-
// As the majority of the tabs are inactive, and painting tabs is slowish,
// we cache a handful of the inactive tab backgrounds here.
static ImageCache* image_cache_;