summaryrefslogtreecommitdiffstats
path: root/chrome/browser/views/tabs/tab_strip.h
diff options
context:
space:
mode:
authorshess@chromium.org <shess@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-04-22 00:03:07 +0000
committershess@chromium.org <shess@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-04-22 00:03:07 +0000
commitc5b90374f3e454dbc5d5f2a4f23c49e7cba93147 (patch)
tree5d7980ec19bf794793fc31dcb1aa1245bc29f897 /chrome/browser/views/tabs/tab_strip.h
parenta32abb551892ef6a9987a5372b3c9896adb7a55e (diff)
downloadchromium_src-c5b90374f3e454dbc5d5f2a4f23c49e7cba93147.zip
chromium_src-c5b90374f3e454dbc5d5f2a4f23c49e7cba93147.tar.gz
chromium_src-c5b90374f3e454dbc5d5f2a4f23c49e7cba93147.tar.bz2
Temporarily revert certain Omnibox, toolbar, tab animations, and other
UI changes for purposes of testing and merging into mstone-5. Also ++kThemePackVersion and regenerate the cached theme pak. Reverted changes: r45213: GTK: Override cursor colors in chrome-theme mode. r45103: Support drawing nano tabs in the tabstrip. r45084: GTK: Position the EV certificate stuff inside a green bubble. r44979: Subclassing the InfoBubble to handle anchoring bubbles basedon... r44957: GTK: Tint the geolocation icons in gtk mode. r44943: Changes FormatURL to not strip http if the host starts with ft... r44930: Remove an icon that is no longer used. r44929: SSL UI changes, Windows, code side (images are separate). r44859: SSL UI changes (icons). TBRed since trybots hate binary patches. r44822: GTK: Select better greens in the native omnibox popup. r44814: GTK: navigate to URL on PRIMARY when middle-clicking the locat... r44789: [Mac] Bookmark star missing on NTP and BMM. r44775: [Mac] Centralize hack to make tests work with AutocompleteClas... r44678: Display the SECURITY_WARNING status in the location bar for the r44648: [Mac] Add an arrow cursor rect for the location image. r44615: Revert r44611 because it may have broken "unit_tests" on "Vist... r44611: Display the SECURITY_WARNING status in the location bar for the r44577: Revert 44572 - [Mac] Update locationbar icon as user types. r44572: [Mac] Update location-bar icon as user types. r44555: GTK: Use correct button mask on reload button. r44545: [Mac] Omnibox text drag drag URL when select-all. r44523: GTK: Prevent inappropriate drag of location bar location icon. r44519: GTK: make the primary selection include the url's scheme when ... r44492: [Mac] Fix search icon in keyword search to be right-side-up. r44415: GTK: Update top padding on icons in the autocomplete popup. r44401: GTK: Tint omnibox icons in GTK mode differently. r44380: GTK: Move reload in gtk mode and fix omnibox popup location. r44282: Fixes crash in autocomplete when typing some URLs. The problem r44273: [Mac] PDF icons for omnibox nits. r44269: Fix build break due to bad merge resolve r44268: Shift omnibox dropdown in and up on Windows, and square off th... r44178: GTK: fix TTS padding. r44177: Round the top left and right edges of the toolbar. r44171: Images only checkin for try server goodness. r44163: GTK: fix padding of autocomplete popup. r44152: [Mac] PDF icons for omnibox. r44145: GTK: Theme the icons in the location bar and use GTK colors fo... r44140: Strips http from the omnibox r44131: Fixes bugs in new tab strip animations where they weren't doin... r44116: Change the default theme colors. r44117: Add newline to EOF to fix CrOS builder. r44115: Make the bottom edges of the opaque frame rounded. r44091: [Mac] No star icon or page actions in omnibox on popups. r44087: Don't allow drag or click on location icon when editing in omn... r44021: [GTK] Add TTS lens graphic to linux TTS box. r44008: [Mac] Tweak location icon spacing in omnibox. r43977: GTK: don't show the star or page actions in ShouldOnlyShowLoca... r43972: Make the firstrun bubble point at a better spot now that the l... r43971: [Mac] Location icon in omnibox as drag source. r43970: Make the star and page action icons not appear on popup windows. r43954: Fixes bug in TabStrip where dragging tab out then back in rapidly r43864: Tweaks to BoundsAnimator/SlideAnimation and TabStrip: r43787: Allow location icon to be dragged & dropped. This also fixes ... r43759: Changes end cap of tab-to-search images. r43740: Change bookmark bar toggle to ctrl-shift-b. r43723: Show Page Info dialog on mouse up, not mouse down. r43677: Fix Mac build failure. r43676: Replace omnibox icons with new set that are all the same size ... r43596: Fix browser test TestStarButtonAccObj. r43593: Disables TestStarButtonAccObj. r43582: Changes tab strip to use BoundsAnimator for tab strip animatio... r43563: GTK: don't show reload button for popup/app windows. r43562: Star/reload shuffle, Windows version. r43540: [Mac] Magnifying glass in keyword-search bubble. r43482: Adds images needed for new tab animation. I'm separating this ... r43422: Add reload mask resource. r43392: GTK: make the location icon a drag source. r43376: [Mac] Move star button into page-actions area of omnibox. r43357: [Mac] Line up omnibox popup under field. r43290: gtk: fix display of icons in omnibox popup r43269: GTK: fix reload button. r43249: [Mac] Rearrange SSL status icon/label in omnibox. r43248: BrowserThemePack: Adds persistant ids for the reload endcaps. r43241: GTK: more location bar updates. r43191: Fix memory leak in BrowserThemePack. r43154: GTK: set the new star button's ID r43151: Fix bad conflict resolution for r43146. r43146: GTK: toolbar reload/star shuffle. r43025: Show the location bar icon (almost) all the time, and have its... r43023: Add new images for new reload button. No code change. r42782: Remove this icon, now that it's no longer used (due to my secu... r42502: Omnibox M5 work, part 1: Security changes r42245: Check in new icons for omnibox security changes alone, so that... BUG=none TEST=Eyjafjallajokull R=pkasting@chromium.org,beng@chromium.org git-svn-id: svn://svn.chromium.org/chrome/trunk/src@45267 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/views/tabs/tab_strip.h')
-rw-r--r--chrome/browser/views/tabs/tab_strip.h248
1 files changed, 97 insertions, 151 deletions
diff --git a/chrome/browser/views/tabs/tab_strip.h b/chrome/browser/views/tabs/tab_strip.h
index e1cbfda..af6cc34 100644
--- a/chrome/browser/views/tabs/tab_strip.h
+++ b/chrome/browser/views/tabs/tab_strip.h
@@ -5,16 +5,11 @@
#ifndef CHROME_BROWSER_VIEWS_TABS_TAB_STRIP_H_
#define CHROME_BROWSER_VIEWS_TABS_TAB_STRIP_H_
-#include "app/animation_container.h"
#include "base/message_loop.h"
-#include "base/ref_counted.h"
-#include "base/timer.h"
#include "chrome/browser/tabs/tab_strip_model.h"
#include "chrome/browser/views/tabs/base_tab_strip.h"
#include "chrome/browser/views/tabs/tab.h"
#include "gfx/point.h"
-#include "gfx/rect.h"
-#include "views/animation/bounds_animator.h"
#include "views/controls/button/image_button.h"
class DraggedTabController;
@@ -47,8 +42,7 @@ class TabStrip : public BaseTabStrip,
public TabStripModelObserver,
public Tab::TabDelegate,
public views::ButtonListener,
- public MessageLoopForUI::Observer,
- public views::BoundsAnimatorObserver {
+ public MessageLoopForUI::Observer {
public:
explicit TabStrip(TabStripModel* model);
virtual ~TabStrip();
@@ -68,7 +62,7 @@ class TabStrip : public BaseTabStrip,
void DestroyDraggedSourceTab(Tab* tab);
// Retrieves the ideal bounds for the Tab at the specified index.
- gfx::Rect GetIdealBounds(int tab_data_index);
+ gfx::Rect GetIdealBounds(int index);
// Returns the currently selected tab.
Tab* GetSelectedTab() const;
@@ -109,9 +103,6 @@ class TabStrip : public BaseTabStrip,
virtual views::View* GetViewForPoint(const gfx::Point& point);
virtual void ThemeChanged();
- // BoundsAnimator::Observer overrides:
- virtual void OnBoundsAnimatorDone(views::BoundsAnimator* animator);
-
protected:
// Creates a new tab.
virtual Tab* CreateTab();
@@ -123,24 +114,21 @@ class TabStrip : public BaseTabStrip,
// TabStripModelObserver implementation:
virtual void TabInsertedAt(TabContents* contents,
- int model_index,
+ int index,
bool foreground);
- virtual void TabDetachedAt(TabContents* contents, int model_index);
+ virtual void TabDetachedAt(TabContents* contents, int index);
virtual void TabSelectedAt(TabContents* old_contents,
TabContents* contents,
- int model_index,
+ int index,
bool user_gesture);
- virtual void TabMoved(TabContents* contents,
- int from_model_index,
- int to_model_index);
- virtual void TabChangedAt(TabContents* contents,
- int model_index,
+ virtual void TabMoved(TabContents* contents, int from_index, int to_index);
+ virtual void TabChangedAt(TabContents* contents, int index,
TabChangeType change_type);
virtual void TabReplacedAt(TabContents* old_contents,
TabContents* new_contents,
- int model_index);
- virtual void TabMiniStateChanged(TabContents* contents, int model_index);
- virtual void TabBlockedStateChanged(TabContents* contents, int model_index);
+ int index);
+ virtual void TabMiniStateChanged(TabContents* contents, int index);
+ virtual void TabBlockedStateChanged(TabContents* contents, int index);
// Tab::Delegate implementation:
virtual bool IsTabSelected(const Tab* tab) const;
@@ -177,70 +165,22 @@ class TabStrip : public BaseTabStrip,
static const int mini_to_non_mini_gap_;
private:
- class RemoveTabDelegate;
+ class InsertTabAnimation;
+ class MiniMoveAnimation;
+ class MiniTabAnimation;
+ class MoveTabAnimation;
+ class RemoveTabAnimation;
+ class ResizeLayoutAnimation;
+ class TabAnimation;
friend class DraggedTabController;
-
- // AnimationType used for tracking animations that require additional
- // state beyond just animating the bounds of a view.
- //
- // Currently the only animation special cased is that of inserting the new tab
- // page at the end of the tab strip. Here's the steps that take place when
- // this happens.
- // . The newly inserted tab is set to render for the new tab animation
- // |set_render_as_new_tab|. The timer new_tab_timer_ is used to determine
- // when to turn this off. This is represented by state ANIMATION_NEW_TAB_1.
- // . The new tab is rendered in the background with an ever increasing alpha
- // value and the tab goes slightly past the new tab button. The new tab
- // button is not visible during this animation. This is represented by the
- // state ANIMATION_NEW_TAB_2.
- // . The new tab is animated to its final position and the new tab button is
- // rendered beneath the selected tab. This is represented by the state
- // ANIMATION_NEW_TAB_3.
- enum AnimationType {
- ANIMATION_DEFAULT,
-
- ANIMATION_NEW_TAB_1,
- ANIMATION_NEW_TAB_2,
- ANIMATION_NEW_TAB_3
- };
-
- // Used during a drop session of a url. Tracks the position of the drop as
- // well as a window used to highlight where the drop occurs.
- struct DropInfo {
- DropInfo(int index, bool drop_before, bool paint_down);
- ~DropInfo();
-
- // Index of the tab to drop on. If drop_before is true, the drop should
- // occur between the tab at drop_index - 1 and drop_index.
- // WARNING: if drop_before is true it is possible this will == tab_count,
- // which indicates the drop should create a new tab at the end of the tabs.
- int drop_index;
- bool drop_before;
-
- // Direction the arrow should point in. If true, the arrow is displayed
- // above the tab and points down. If false, the arrow is displayed beneath
- // the tab and points up.
- bool point_down;
-
- // Renders the drop indicator.
- // TODO(beng): should be views::Widget.
-#if defined(OS_WIN)
- views::WidgetWin* arrow_window;
-#else
- views::WidgetGtk* arrow_window;
-#endif
- views::ImageView* arrow_view;
-
- private:
- DISALLOW_COPY_AND_ASSIGN(DropInfo);
- };
-
- // The Tabs we contain, and their last generated "good" bounds.
- struct TabData {
- Tab* tab;
- gfx::Rect ideal_bounds;
- };
+ friend class InsertTabAnimation;
+ friend class MiniMoveAnimation;
+ friend class MiniTabAnimation;
+ friend class MoveTabAnimation;
+ friend class RemoveTabAnimation;
+ friend class ResizeLayoutAnimation;
+ friend class TabAnimation;
TabStrip();
void Init();
@@ -248,9 +188,9 @@ class TabStrip : public BaseTabStrip,
// Set the images for the new tab button.
void LoadNewTabButtonImage();
- // Retrieves the Tab at the specified index. Remember, the specified index
- // is in terms of tab_data, *not* the model.
- Tab* GetTabAtTabDataIndex(int tab_data_index) const;
+ // Retrieves the Tab at the specified index. Take care in using this, you may
+ // need to use GetTabAtAdjustForAnimation.
+ Tab* GetTabAt(int index) const;
// Returns the tab at the specified index. If a remove animation is on going
// and the index is >= the index of the tab being removed, the index is
@@ -258,13 +198,10 @@ class TabStrip : public BaseTabStrip,
// do not line up with the indices of the view. This method adjusts the index
// accordingly.
//
- // Use this instead of GetTabAtTabDataIndex if the index comes from the model.
- Tab* GetTabAtModelIndex(int model_index) const;
+ // Use this instead of GetTabAt if the index comes from the model.
+ Tab* GetTabAtAdjustForAnimation(int index) const;
// Gets the number of Tabs in the collection.
- // WARNING: this is the number of tabs displayed by the tabstrip, which if
- // an animation is ongoing is not necessarily the same as the number of tabs
- // in the model.
int GetTabCount() const;
// Returns the number of mini-tabs.
@@ -287,6 +224,9 @@ class TabStrip : public BaseTabStrip,
double* unselected_width,
double* selected_width) const;
+ // Returns the horizontal offset before the tab at |tab_index|.
+ int GetTabHOffset(int tab_index);
+
// Perform an animated resize-relayout of the TabStrip immediately.
void ResizeLayoutTabs();
@@ -310,7 +250,7 @@ class TabStrip : public BaseTabStrip,
void UpdateDropIndex(const views::DropTargetEvent& event);
// Sets the location of the drop, repainting as necessary.
- void SetDropIndex(int tab_data_index, bool drop_before);
+ void SetDropIndex(int index, bool drop_before);
// Returns the drop effect for dropping a URL on the tab strip. This does
// not query the data in anyway, it only looks at the source operations.
@@ -328,38 +268,32 @@ class TabStrip : public BaseTabStrip,
// stable representations of Tab positions.
void GenerateIdealBounds();
- // Both of these are invoked when a part of the new tab animation completes.
- // They configure state for the next step in the animation and start it.
- void NewTabAnimation1Done();
- void NewTabAnimation2Done();
-
- // Animates all the views to their ideal bounds.
- // NOTE: this does *not* invoke GenerateIdealBounds, it uses the bounds
- // currently set in ideal_bounds.
- void AnimateToIdealBounds();
+ // Lays out the New Tab button, assuming the right edge of the last Tab on
+ // the TabStrip at |last_tab_right|.
+ void LayoutNewTabButton(double last_tab_right, double unselected_width);
- // Returns true if a new tab inserted at specified index should start the
- // new tab animation. See description above AnimationType for details on
- // this animation.
- bool ShouldStartIntertTabAnimationAtEnd(int model_index, bool foreground);
+ // A generic Layout method for various classes of TabStrip animations,
+ // including Insert, Remove and Resize Layout cases/
+ void AnimationLayout(double unselected_width);
// Starts various types of TabStrip animations.
void StartResizeLayoutAnimation();
- void StartInsertTabAnimationAtEnd();
- void StartInsertTabAnimation(int model_index);
- void StartRemoveTabAnimation(int model_index);
- void StartMoveTabAnimation(int from_model_index,
- int to_model_index);
- void StartMiniTabAnimation();
-
- // Stops any ongoing animations. If |layout| is true and an animation is
- // ongoing this does a layout.
- void StopAnimating(bool layout);
-
- // Resets all state related to animations. This is invoked when an animation
- // completes, prior to starting an animation or when we cancel an animation.
- // If |stop_new_tab_timer| is true, |new_tab_timer_| is stopped.
- void ResetAnimationState(bool stop_new_tab_timer);
+ void StartInsertTabAnimation(int index);
+ void StartRemoveTabAnimation(int index, TabContents* contents);
+ void StartMoveTabAnimation(int from_index, int to_index);
+ void StartMiniTabAnimation(int index);
+ void StartMiniMoveTabAnimation(int from_index,
+ int to_index,
+ const gfx::Rect& start_bounds);
+
+ // Notifies the TabStrip that the specified TabAnimation has completed.
+ // Optionally a full Layout will be performed, specified by |layout|.
+ void FinishAnimation(TabAnimation* animation, bool layout);
+
+ // Finds the index of the TabContents corresponding to |tab| in our
+ // associated TabStripModel, or -1 if there is none (e.g. the specified |tab|
+ // is being animated closed).
+ int GetIndexOfTab(const Tab* tab) const;
// Calculates the available width for tabs, assuming a Tab is to be closed.
int GetAvailableWidthForTabs(Tab* last_tab) const;
@@ -368,9 +302,9 @@ class TabStrip : public BaseTabStrip,
// hit-test region of the specified Tab.
bool IsPointInTab(Tab* tab, const gfx::Point& point_in_tabstrip_coords);
- // Cleans up the Tab from the TabStrip. This is called from the tab animation
- // code and is not a general-purpose method.
- void RemoveTab(Tab* tab);
+ // Cleans up the Tab from the TabStrip at the specified |index|. This is
+ // called from the tab animation code and is not a general-purpose method.
+ void RemoveTabAt(int index);
// Called from the message loop observer when a mouse movement has occurred
// anywhere over our containing window.
@@ -379,19 +313,6 @@ class TabStrip : public BaseTabStrip,
// Returns true if any of the tabs are phantom.
bool HasPhantomTabs() const;
- // Returns the index of the specified tab in the model coordiate system, or
- // -1 if tab is closing or not in |tab_data_|.
- int GetModelIndexOfTab(const Tab* tab) const;
-
- // Returns the index into |tab_data_| corresponding to the index from the
- // TabStripModel, or |tab_data_.size()| if there is no tab representing
- // |model_index|.
- int ModelIndexToTabDataIndex(int model_index) const;
-
- // Returns the index into |tab_data_| corresponding to the specified tab, or
- // -1 if the tab isn't in |tab_data_|.
- int TabDataIndexOfTab(Tab* tab) const;
-
// -- Member Variables ------------------------------------------------------
// Our model.
@@ -410,9 +331,7 @@ class TabStrip : public BaseTabStrip,
// The "New Tab" button.
views::ImageButton* newtab_button_;
-
- // Ideal bounds of the new tab button.
- gfx::Rect newtab_button_bounds_;
+ gfx::Size newtab_button_size_;
// The current widths of various types of tabs. We save these so that, as
// users close tabs while we're holding them at the same size, we can lay out
@@ -440,6 +359,37 @@ class TabStrip : public BaseTabStrip,
static const int kNewTabButtonWidth = 28;
static const int kNewTabButtonHeight = 18;
+ // Used during a drop session of a url. Tracks the position of the drop as
+ // well as a window used to highlight where the drop occurs.
+ struct DropInfo {
+ DropInfo(int index, bool drop_before, bool paint_down);
+ ~DropInfo();
+
+ // Index of the tab to drop on. If drop_before is true, the drop should
+ // occur between the tab at drop_index - 1 and drop_index.
+ // WARNING: if drop_before is true it is possible this will == tab_count,
+ // which indicates the drop should create a new tab at the end of the tabs.
+ int drop_index;
+ bool drop_before;
+
+ // Direction the arrow should point in. If true, the arrow is displayed
+ // above the tab and points down. If false, the arrow is displayed beneath
+ // the tab and points up.
+ bool point_down;
+
+ // Renders the drop indicator.
+ // TODO(beng): should be views::Widget.
+#if defined(OS_WIN)
+ views::WidgetWin* arrow_window;
+#else
+ views::WidgetGtk* arrow_window;
+#endif
+ views::ImageView* arrow_view;
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(DropInfo);
+ };
+
// Valid for the lifetime of a drag over us.
scoped_ptr<DropInfo> drop_info_;
@@ -447,19 +397,15 @@ class TabStrip : public BaseTabStrip,
// the drag session.
scoped_ptr<DraggedTabController> drag_controller_;
+ // The Tabs we contain, and their last generated "good" bounds.
+ struct TabData {
+ Tab* tab;
+ gfx::Rect ideal_bounds;
+ };
std::vector<TabData> tab_data_;
- // To ensure all tabs pulse at the same time they share the same animation
- // container. This is that animation container.
- scoped_refptr<AnimationContainer> animation_container_;
-
- views::BoundsAnimator bounds_animator_;
-
- // Used for stage 1 of new tab animation.
- base::OneShotTimer<TabStrip> new_tab_timer_;
-
- // Set for special animations.
- AnimationType animation_type_;
+ // The currently running animation.
+ scoped_ptr<TabAnimation> active_animation_;
DISALLOW_COPY_AND_ASSIGN(TabStrip);
};