Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(601)

Side by Side Diff: chrome/browser/ui/views/bookmarks/bookmark_bar_view.h

Issue 1547563003: Fix and simplify bookmark bar detach/attach animation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | chrome/browser/ui/views/bookmarks/bookmark_bar_view.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #ifndef CHROME_BROWSER_UI_VIEWS_BOOKMARKS_BOOKMARK_BAR_VIEW_H_ 5 #ifndef CHROME_BROWSER_UI_VIEWS_BOOKMARKS_BOOKMARK_BAR_VIEW_H_
6 #define CHROME_BROWSER_UI_VIEWS_BOOKMARKS_BOOKMARK_BAR_VIEW_H_ 6 #define CHROME_BROWSER_UI_VIEWS_BOOKMARKS_BOOKMARK_BAR_VIEW_H_
7 7
8 #include <set> 8 #include <set>
9 9
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "base/memory/weak_ptr.h" 12 #include "base/memory/weak_ptr.h"
13 #include "base/observer_list.h" 13 #include "base/observer_list.h"
14 #include "base/prefs/pref_change_registrar.h" 14 #include "base/prefs/pref_change_registrar.h"
15 #include "chrome/browser/bookmarks/bookmark_stats.h" 15 #include "chrome/browser/bookmarks/bookmark_stats.h"
16 #include "chrome/browser/ui/bookmarks/bookmark_bar.h" 16 #include "chrome/browser/ui/bookmarks/bookmark_bar.h"
17 #include "chrome/browser/ui/bookmarks/bookmark_bar_instructions_delegate.h" 17 #include "chrome/browser/ui/bookmarks/bookmark_bar_instructions_delegate.h"
18 #include "chrome/browser/ui/bookmarks/bookmark_bubble_observer.h" 18 #include "chrome/browser/ui/bookmarks/bookmark_bubble_observer.h"
19 #include "chrome/browser/ui/views/bookmarks/bookmark_menu_controller_observer.h" 19 #include "chrome/browser/ui/views/bookmarks/bookmark_menu_controller_observer.h"
20 #include "components/bookmarks/browser/bookmark_model_observer.h" 20 #include "components/bookmarks/browser/bookmark_model_observer.h"
21 #include "components/bookmarks/browser/bookmark_node_data.h" 21 #include "components/bookmarks/browser/bookmark_node_data.h"
22 #include "ui/gfx/animation/animation_delegate.h" 22 #include "ui/gfx/animation/animation_delegate.h"
23 #include "ui/gfx/animation/slide_animation.h"
23 #include "ui/views/accessible_pane_view.h" 24 #include "ui/views/accessible_pane_view.h"
24 #include "ui/views/context_menu_controller.h" 25 #include "ui/views/context_menu_controller.h"
25 #include "ui/views/controls/button/button.h" 26 #include "ui/views/controls/button/button.h"
26 #include "ui/views/controls/button/menu_button_listener.h" 27 #include "ui/views/controls/button/menu_button_listener.h"
27 #include "ui/views/controls/menu/menu_types.h" 28 #include "ui/views/controls/menu/menu_types.h"
28 #include "ui/views/drag_controller.h" 29 #include "ui/views/drag_controller.h"
29 30
30 class BookmarkBarViewObserver; 31 class BookmarkBarViewObserver;
31 class BookmarkBarViewTestHelper; 32 class BookmarkBarViewTestHelper;
32 class BookmarkContextMenu; 33 class BookmarkContextMenu;
33 class Browser; 34 class Browser;
34 class BrowserView; 35 class BrowserView;
35 class Profile; 36 class Profile;
36 37
37 namespace bookmarks { 38 namespace bookmarks {
38 class BookmarkModel; 39 class BookmarkModel;
39 class ManagedBookmarkService; 40 class ManagedBookmarkService;
40 } 41 }
41 42
42 namespace content { 43 namespace content {
43 class PageNavigator; 44 class PageNavigator;
44 } 45 }
45 46
46 namespace gfx {
47 class SlideAnimation;
48 }
49
50 namespace views { 47 namespace views {
51 class CustomButton; 48 class CustomButton;
52 class MenuButton; 49 class MenuButton;
53 class MenuItemView; 50 class MenuItemView;
54 class LabelButton; 51 class LabelButton;
55 } 52 }
56 53
57 // BookmarkBarView renders the BookmarkModel. Each starred entry on the 54 // BookmarkBarView renders the BookmarkModel. Each starred entry on the
58 // BookmarkBar is rendered as a MenuButton. An additional MenuButton aligned to 55 // BookmarkBar is rendered as a MenuButton. An additional MenuButton aligned to
59 // the right allows the user to quickly see recently starred entries. 56 // the right allows the user to quickly see recently starred entries.
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 // Sets whether the containing browser is showing an infobar. This affects 91 // Sets whether the containing browser is showing an infobar. This affects
95 // layout during animation. 92 // layout during animation.
96 void set_infobar_visible(bool infobar_visible) { 93 void set_infobar_visible(bool infobar_visible) {
97 infobar_visible_ = infobar_visible; 94 infobar_visible_ = infobar_visible;
98 } 95 }
99 96
100 // Changes the state of the bookmark bar. 97 // Changes the state of the bookmark bar.
101 void SetBookmarkBarState(BookmarkBar::State state, 98 void SetBookmarkBarState(BookmarkBar::State state,
102 BookmarkBar::AnimateChangeType animate_type); 99 BookmarkBar::AnimateChangeType animate_type);
103 100
104 // Whether or not we are animating.
105 bool is_animating();
106
107 // If |loc| is over a bookmark button the node is returned corresponding to 101 // If |loc| is over a bookmark button the node is returned corresponding to
108 // the button and |model_start_index| is set to 0. If a overflow button is 102 // the button and |model_start_index| is set to 0. If a overflow button is
109 // showing and |loc| is over the overflow button, the bookmark bar node is 103 // showing and |loc| is over the overflow button, the bookmark bar node is
110 // returned and |model_start_index| is set to the index of the first node 104 // returned and |model_start_index| is set to the index of the first node
111 // contained in the overflow menu. 105 // contained in the overflow menu.
112 const bookmarks::BookmarkNode* GetNodeForButtonAtModelIndex( 106 const bookmarks::BookmarkNode* GetNodeForButtonAtModelIndex(
113 const gfx::Point& loc, 107 const gfx::Point& loc,
114 int* model_start_index); 108 int* model_start_index);
115 109
116 // Returns the MenuButton for node. 110 // Returns the MenuButton for node.
117 views::MenuButton* GetMenuButtonForNode(const bookmarks::BookmarkNode* node); 111 views::MenuButton* GetMenuButtonForNode(const bookmarks::BookmarkNode* node);
118 112
119 // Returns the position to anchor the menu for |button| at. 113 // Returns the position to anchor the menu for |button| at.
120 void GetAnchorPositionForButton(views::MenuButton* button, 114 void GetAnchorPositionForButton(views::MenuButton* button,
121 views::MenuAnchorPosition* anchor); 115 views::MenuAnchorPosition* anchor);
122 116
123 // Returns the button responsible for showing bookmarks in the 117 // Returns the button responsible for showing bookmarks in the
124 // "Other Bookmarks" folder. 118 // "Other Bookmarks" folder.
125 views::MenuButton* other_bookmarks_button() const { 119 views::MenuButton* other_bookmarks_button() const {
126 return other_bookmarks_button_; 120 return other_bookmarks_button_;
127 } 121 }
128 122
129 // Returns the button used when not all the items on the bookmark bar fit. 123 // Returns the button used when not all the items on the bookmark bar fit.
130 views::MenuButton* overflow_button() const { return overflow_button_; } 124 views::MenuButton* overflow_button() const { return overflow_button_; }
131 125
126 const gfx::Animation& size_animation() {
127 return size_animation_;
128 }
129
132 // Returns the active MenuItemView, or NULL if a menu isn't showing. 130 // Returns the active MenuItemView, or NULL if a menu isn't showing.
133 views::MenuItemView* GetMenu(); 131 views::MenuItemView* GetMenu();
134 132
135 // Returns the context menu, or null if one isn't showing. 133 // Returns the context menu, or null if one isn't showing.
136 views::MenuItemView* GetContextMenu(); 134 views::MenuItemView* GetContextMenu();
137 135
138 // Returns the drop MenuItemView, or NULL if a menu isn't showing. 136 // Returns the drop MenuItemView, or NULL if a menu isn't showing.
139 views::MenuItemView* GetDropMenu(); 137 views::MenuItemView* GetDropMenu();
140 138
141 // If a button is currently throbbing, it is stopped. If immediate is true 139 // If a button is currently throbbing, it is stopped. If immediate is true
142 // the throb stops immediately, otherwise it stops after a couple more 140 // the throb stops immediately, otherwise it stops after a couple more
143 // throbs. 141 // throbs.
144 void StopThrobbing(bool immediate); 142 void StopThrobbing(bool immediate);
145 143
146 // Returns the tooltip text for the specified url and title. The returned 144 // Returns the tooltip text for the specified url and title. The returned
147 // text is clipped to fit within the bounds of the monitor. |context| is 145 // text is clipped to fit within the bounds of the monitor. |context| is
148 // used to determine which gfx::Screen is used to retrieve bounds. 146 // used to determine which gfx::Screen is used to retrieve bounds.
149 // 147 //
150 // Note that we adjust the direction of both the URL and the title based on 148 // Note that we adjust the direction of both the URL and the title based on
151 // the locale so that pure LTR strings are displayed properly in RTL locales. 149 // the locale so that pure LTR strings are displayed properly in RTL locales.
152 static base::string16 CreateToolTipForURLAndTitle(const views::Widget* widget, 150 static base::string16 CreateToolTipForURLAndTitle(const views::Widget* widget,
153 const gfx::Point& screen_loc, 151 const gfx::Point& screen_loc,
154 const GURL& url, 152 const GURL& url,
155 const base::string16& title, 153 const base::string16& title,
156 Profile* profile); 154 Profile* profile);
157 155
158 // Returns true if Bookmarks Bar is currently detached from the Toolbar. 156 // Returns true if Bookmarks Bar is currently detached from the Toolbar.
159 bool IsDetached() const; 157 bool IsDetached() const;
160 158
161 // Returns the current state of the resize animation (show/hide).
162 double GetAnimationValue() const;
163
164 // Returns the current amount of overlap atop the browser toolbar. 159 // Returns the current amount of overlap atop the browser toolbar.
165 int GetToolbarOverlap() const; 160 int GetToolbarOverlap() const;
166 161
167 // views::View: 162 // views::View:
168 gfx::Size GetPreferredSize() const override; 163 gfx::Size GetPreferredSize() const override;
169 gfx::Size GetMinimumSize() const override; 164 gfx::Size GetMinimumSize() const override;
170 bool CanProcessEventsWithinSubtree() const override; 165 bool CanProcessEventsWithinSubtree() const override;
171 void Layout() override; 166 void Layout() override;
172 void ViewHierarchyChanged( 167 void ViewHierarchyChanged(
173 const ViewHierarchyChangedDetails& details) override; 168 const ViewHierarchyChangedDetails& details) override;
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after
439 434
440 ButtonSeparatorView* bookmarks_separator_view_; 435 ButtonSeparatorView* bookmarks_separator_view_;
441 436
442 Browser* browser_; 437 Browser* browser_;
443 BrowserView* browser_view_; 438 BrowserView* browser_view_;
444 439
445 // True if the owning browser is showing an infobar. 440 // True if the owning browser is showing an infobar.
446 bool infobar_visible_; 441 bool infobar_visible_;
447 442
448 // Animation controlling showing and hiding of the bar. 443 // Animation controlling showing and hiding of the bar.
449 scoped_ptr<gfx::SlideAnimation> size_animation_; 444 gfx::SlideAnimation size_animation_;
450 445
451 // If the bookmark bubble is showing, this is the visible ancestor of the URL. 446 // If the bookmark bubble is showing, this is the visible ancestor of the URL.
452 // The visible ancestor is either the |other_bookmarks_button_|, 447 // The visible ancestor is either the |other_bookmarks_button_|,
453 // |overflow_button_| or a button on the bar. 448 // |overflow_button_| or a button on the bar.
454 views::CustomButton* throbbing_view_; 449 views::CustomButton* throbbing_view_;
455 450
456 BookmarkBar::State bookmark_bar_state_; 451 BookmarkBar::State bookmark_bar_state_;
457 452
458 // Are we animating to or from the detached state? 453 // Are we animating to or from the detached state?
459 bool animating_detached_; 454 bool animating_detached_;
460 455
461 base::ObserverList<BookmarkBarViewObserver> observers_; 456 base::ObserverList<BookmarkBarViewObserver> observers_;
462 457
463 // Factory used to delay showing of the drop menu. 458 // Factory used to delay showing of the drop menu.
464 base::WeakPtrFactory<BookmarkBarView> show_folder_method_factory_; 459 base::WeakPtrFactory<BookmarkBarView> show_folder_method_factory_;
465 460
466 DISALLOW_COPY_AND_ASSIGN(BookmarkBarView); 461 DISALLOW_COPY_AND_ASSIGN(BookmarkBarView);
467 }; 462 };
468 463
469 #endif // CHROME_BROWSER_UI_VIEWS_BOOKMARKS_BOOKMARK_BAR_VIEW_H_ 464 #endif // CHROME_BROWSER_UI_VIEWS_BOOKMARKS_BOOKMARK_BAR_VIEW_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/views/bookmarks/bookmark_bar_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698