1 // Copyright 2014 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef CHROME_BROWSER_UI_TOOLBAR_TOOLBAR_ACTIONS_BAR_DELEGATE_H_ 6 #define CHROME_BROWSER_UI_TOOLBAR_TOOLBAR_ACTIONS_BAR_DELEGATE_H_ 7 8 #include <stddef.h> 9 10 #include <memory> 11 12 #include "ui/gfx/animation/tween.h" 13 #include "ui/gfx/geometry/size.h" 14 15 class ToolbarActionViewController; 16 class ToolbarActionsBarBubbleDelegate; 17 18 // The delegate class (which, in production, represents the view) of the 19 // ToolbarActionsBar. 20 class ToolbarActionsBarDelegate { 21 public: 22 enum GetWidthTime { 23 GET_WIDTH_CURRENT, // Returns the current width. 24 GET_WIDTH_AFTER_ANIMATION, // Returns the width after a running animation. 25 }; 26 ~ToolbarActionsBarDelegate()27 virtual ~ToolbarActionsBarDelegate() {} 28 29 // Adds a view for the given |action| at |index|. 30 virtual void AddViewForAction(ToolbarActionViewController* action, 31 size_t index) = 0; 32 33 // Removes the view for the given |action|. 34 virtual void RemoveViewForAction(ToolbarActionViewController* action) = 0; 35 36 // Removes all action views. 37 virtual void RemoveAllViews() = 0; 38 39 // Redraws the view for the toolbar actions bar. |order_changed| indicates 40 // whether or not the change caused a reordering of the actions. 41 virtual void Redraw(bool order_changed) = 0; 42 43 // Resizes the view to the |target_width| and animates with the given 44 // |tween_type|. 45 virtual void ResizeAndAnimate(gfx::Tween::Type tween_type, 46 int target_width) = 0; 47 48 // Returns the width of the view according to |get_width_time|. 49 virtual int GetWidth(GetWidthTime get_width_time) const = 0; 50 51 // Returns true if the view is animating. 52 virtual bool IsAnimating() const = 0; 53 54 // Stops the current animation (width remains where it currently is). 55 virtual void StopAnimating() = 0; 56 57 // Shows the given |bubble|. Must not be called if another bubble is showing 58 // or if the toolbar is animating. 59 virtual void ShowToolbarActionBubble( 60 std::unique_ptr<ToolbarActionsBarBubbleDelegate> bubble) = 0; 61 62 // Closes the overflow menu, if it was open. Returns whether or not the 63 // overflow menu was closed. 64 virtual bool CloseOverflowMenuIfOpen() = 0; 65 }; 66 67 #endif // CHROME_BROWSER_UI_TOOLBAR_TOOLBAR_ACTIONS_BAR_DELEGATE_H_ 68