Commit fce1fb39 authored by pkasting@chromium.org's avatar pkasting@chromium.org

Browser actions container layout changes for M6 theme.

In short, this:
* Eliminates the divider on the right (the new chevron has a built-in divider)
* Changes the padding between items (see updated comments in header for precise layout details)
* Updates the imagery for the new theme
* Makes the chevron respond to theme changes

BUG=50107
TEST=none
Review URL: http://codereview.chromium.org/3057016

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@54174 0039d316-1c4b-4281-b951-d872f2087c98
parent c512b99e
...@@ -176,24 +176,24 @@ class BrowserActionView : public views::View { ...@@ -176,24 +176,24 @@ class BrowserActionView : public views::View {
// The BrowserActionsContainer is a container view, responsible for drawing the // The BrowserActionsContainer is a container view, responsible for drawing the
// browser action icons (extensions that add icons to the toolbar). // browser action icons (extensions that add icons to the toolbar).
// //
// The BrowserActionsContainer (when it contains one or more icons) consists of // The container is placed flush against the omnibox and wrench menu, and its
// the following elements, numbered as seen below the line: // layout looks like:
// // rI_I_IcCs
// r _ Icon _ Icon _ Icon _ [chevron] _ | _ // Where the letters are as follows:
// ----------------------------------------- // r: An invisible resize area. This is ToolbarView::kStandardSpacing pixels
// 1 2 3 4 5 6 7 8 // wide and directly adjacent to the omnibox.
// // I: An icon. This is as wide as the IDR_BROWSER_ACTION image.
// 1) An invisible resize area. // _: kItemSpacing pixels of empty space.
// 2) Padding (kHorizontalPadding). // c: kChevronSpacing pixels of empty space. Only present if C is present.
// 3) The browser action icon button (BrowserActionView). // C: An optional chevron, visible for overflow. As wide as the
// 4) Padding to visually separate icons from one another // IDR_BROWSER_ACTIONS_OVERFLOW image.
// (kBrowserActionButtonPadding). Not included if only one icon visible. // s: ToolbarView::kStandardSpacing pixels of empty space (before the wrench
// 5) The chevron menu (MenuButton), shown when there is not enough room to show // menu).
// all the icons. // The reason the container contains the trailing space "s", rather than having
// 6) Padding (kDividerHorizontalMargin). // it be handled by the parent view, is so that when the chevron is invisible
// 7) A thin vertical divider drawn during Paint to create visual separation for // and the user starts dragging an icon around, we have the space to draw the
// the container from the Page and Wrench menus. // ultimate drop indicator. (Otherwise, we'd be trying to draw it into the
// 8) Padding (kChevronRightMargin). // padding beyond our right edge, and it wouldn't appear.)
// //
// The BrowserActionsContainer follows a few rules, in terms of user experience: // The BrowserActionsContainer follows a few rules, in terms of user experience:
// //
...@@ -259,6 +259,8 @@ class BrowserActionsContainer ...@@ -259,6 +259,8 @@ class BrowserActionsContainer
static void RegisterUserPrefs(PrefService* prefs); static void RegisterUserPrefs(PrefService* prefs);
void Init();
// Get the number of browser actions being displayed. // Get the number of browser actions being displayed.
int num_browser_actions() const { return browser_action_views_.size(); } int num_browser_actions() const { return browser_action_views_.size(); }
...@@ -319,6 +321,7 @@ class BrowserActionsContainer ...@@ -319,6 +321,7 @@ class BrowserActionsContainer
virtual int OnDragUpdated(const views::DropTargetEvent& event); virtual int OnDragUpdated(const views::DropTargetEvent& event);
virtual void OnDragExited(); virtual void OnDragExited();
virtual int OnPerformDrop(const views::DropTargetEvent& event); virtual int OnPerformDrop(const views::DropTargetEvent& event);
virtual void OnThemeChanged();
virtual bool GetAccessibleRole(AccessibilityTypes::Role* role); virtual bool GetAccessibleRole(AccessibilityTypes::Role* role);
// Overridden from views::ViewMenuDelegate: // Overridden from views::ViewMenuDelegate:
...@@ -373,16 +376,25 @@ class BrowserActionsContainer ...@@ -373,16 +376,25 @@ class BrowserActionsContainer
static bool disable_animations_during_testing_; static bool disable_animations_during_testing_;
private: private:
friend class BrowserActionView; // So it can access IconHeight().
friend class ShowFolderMenuTask; friend class ShowFolderMenuTask;
typedef std::vector<BrowserActionView*> BrowserActionViews; typedef std::vector<BrowserActionView*> BrowserActionViews;
// Returns the width of an icon, optionally with its padding.
static int IconWidth(bool include_padding);
// Returns the height of an icon.
static int IconHeight();
// ExtensionToolbarModel::Observer implementation. // ExtensionToolbarModel::Observer implementation.
virtual void BrowserActionAdded(Extension* extension, int index); virtual void BrowserActionAdded(Extension* extension, int index);
virtual void BrowserActionRemoved(Extension* extension); virtual void BrowserActionRemoved(Extension* extension);
virtual void BrowserActionMoved(Extension* extension, int index); virtual void BrowserActionMoved(Extension* extension, int index);
virtual void ModelLoaded(); virtual void ModelLoaded();
void LoadImages();
// Sets the initial container width. // Sets the initial container width.
void SetContainerWidth(); void SetContainerWidth();
...@@ -402,26 +414,19 @@ class BrowserActionsContainer ...@@ -402,26 +414,19 @@ class BrowserActionsContainer
// changed). // changed).
void SetDropIndicator(int x_pos); void SetDropIndicator(int x_pos);
// Takes a width in pixels, calculates how many icons fit within that space // Given a number of |icons| and whether to |display_chevron|, returns the
// (up to the maximum number of icons in our vector) and shaves off the // amount of pixels needed to draw the entire container. For convenience,
// excess pixels. |allow_shrink_to_minimum| specifies whether this function // callers can set |icons| to -1 to mean "all icons".
// clamps the size down further (down to ContainerMinSize()) if there is not int IconCountToWidth(int icons, bool display_chevron) const;
// room for even one icon. When determining how large the container should be
// this should be |true|. When determining where to place items, such as the
// drop indicator, this should be |false|.
int ClampToNearestIconCount(int pixels, bool allow_shrink_to_minimum) const;
// Calculates the width of the container area NOT used to show the icons (the
// controls to the left and to the right of the icons).
int WidthOfNonIconArea() const;
// Given a number of |icons| return the amount of pixels needed to draw it, // Given a pixel width, returns the number of icons that fit, assuming we need
// including the controls (chevron if visible and resize area). // to show a chevron.
int IconCountToWidth(int icons) const; int WidthToIconCount(int pixels) const;
// Returns the absolute minimum size you can shrink the container down to and // Returns the absolute minimum size you can shrink the container down to and
// still show it. We account for the chevron and the resize gripper, but not // still show it. This assumes a visible chevron because the only way we
// all the padding that we normally show if there are icons. // would not have a chevron when shrinking down this far is if there were no
// icons, in which case the container wouldn't be shown at all.
int ContainerMinSize() const; int ContainerMinSize() const;
// Animate to the target value (unless testing, in which case we go straight // Animate to the target value (unless testing, in which case we go straight
......
...@@ -178,6 +178,7 @@ void ToolbarView::Init(Profile* profile) { ...@@ -178,6 +178,7 @@ void ToolbarView::Init(Profile* profile) {
location_bar_->Init(); location_bar_->Init();
show_home_button_.Init(prefs::kShowHomeButton, profile->GetPrefs(), this); show_home_button_.Init(prefs::kShowHomeButton, profile->GetPrefs(), this);
browser_actions_->Init();
SetProfile(profile); SetProfile(profile);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment