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

Side by Side Diff: chrome/browser/ui/views/location_bar/bubble_icon_view.h

Issue 1518543002: Adds MD ink ripple animations to buttons within location bar (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Adds MD ink ripple animations to buttons within location bar (split gesture support into a separate… Created 5 years 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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_LOCATION_BAR_BUBBLE_ICON_VIEW_H_ 5 #ifndef CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_BUBBLE_ICON_VIEW_H_
6 #define CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_BUBBLE_ICON_VIEW_H_ 6 #define CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_BUBBLE_ICON_VIEW_H_
7 7
8 #include "base/memory/scoped_ptr.h"
8 #include "ui/gfx/image/image_skia.h" 9 #include "ui/gfx/image/image_skia.h"
9 #include "ui/gfx/vector_icons_public.h" 10 #include "ui/gfx/vector_icons_public.h"
11 #include "ui/views/animation/ink_drop_host.h"
10 #include "ui/views/controls/image_view.h" 12 #include "ui/views/controls/image_view.h"
11 13
12 class CommandUpdater; 14 class CommandUpdater;
13 15
14 namespace gfx { 16 namespace gfx {
15 enum class VectorIconId; 17 enum class VectorIconId;
16 } 18 }
17 19
18 namespace views { 20 namespace views {
19 class BubbleDelegateView; 21 class BubbleDelegateView;
22 class InkDropDelegate;
20 } 23 }
21 24
22 // Represents an icon on the omnibox that shows a bubble when clicked. 25 // Represents an icon on the omnibox that shows a bubble when clicked.
23 class BubbleIconView : public views::ImageView { 26 class BubbleIconView : public views::ImageView,
27 public views::InkDropHost {
24 protected: 28 protected:
25 enum ExecuteSource { 29 enum ExecuteSource {
26 EXECUTE_SOURCE_MOUSE, 30 EXECUTE_SOURCE_MOUSE,
27 EXECUTE_SOURCE_KEYBOARD, 31 EXECUTE_SOURCE_KEYBOARD,
28 EXECUTE_SOURCE_GESTURE, 32 EXECUTE_SOURCE_GESTURE,
29 }; 33 };
30 34
31 BubbleIconView(CommandUpdater* command_updater, int command_id); 35 BubbleIconView(CommandUpdater* command_updater, int command_id);
32 ~BubbleIconView() override; 36 ~BubbleIconView() override;
33 37
34 // Returns true if a related bubble is showing. 38 // Returns true if a related bubble is showing.
35 bool IsBubbleShowing() const; 39 bool IsBubbleShowing() const;
36 40
37 // Invoked prior to executing the command. 41 // Invoked prior to executing the command.
38 virtual void OnExecuting(ExecuteSource execute_source) = 0; 42 virtual void OnExecuting(ExecuteSource execute_source) = 0;
39 43
40 // views::ImageView: 44 // views::ImageView:
41 void GetAccessibleState(ui::AXViewState* state) override; 45 void GetAccessibleState(ui::AXViewState* state) override;
42 bool GetTooltipText(const gfx::Point& p, base::string16* tooltip) const 46 bool GetTooltipText(const gfx::Point& p, base::string16* tooltip) const
43 override; 47 override;
48 void Layout() override;
44 bool OnMousePressed(const ui::MouseEvent& event) override; 49 bool OnMousePressed(const ui::MouseEvent& event) override;
45 void OnMouseReleased(const ui::MouseEvent& event) override; 50 void OnMouseReleased(const ui::MouseEvent& event) override;
46 bool OnKeyPressed(const ui::KeyEvent& event) override; 51 bool OnKeyPressed(const ui::KeyEvent& event) override;
52 void OnBubbleClosing() override;
47 void ViewHierarchyChanged( 53 void ViewHierarchyChanged(
48 const ViewHierarchyChangedDetails& details) override; 54 const ViewHierarchyChangedDetails& details) override;
49 void OnNativeThemeChanged(const ui::NativeTheme* theme) override; 55 void OnNativeThemeChanged(const ui::NativeTheme* theme) override;
50 56
51 // ui::EventHandler: 57 // ui::EventHandler:
52 void OnGestureEvent(ui::GestureEvent* event) override; 58 void OnGestureEvent(ui::GestureEvent* event) override;
53 59
60 // views::InkDropHost:
61 void AddInkDropLayer(ui::Layer* ink_drop_layer) override;
62 void RemoveInkDropLayer(ui::Layer* ink_drop_layer) override;
63
54 protected: 64 protected:
55 // Calls OnExecuting and runs |command_id_| with a valid |command_updater_|. 65 // Calls OnExecuting and runs |command_id_| with a valid |command_updater_|.
56 virtual void ExecuteCommand(ExecuteSource source); 66 virtual void ExecuteCommand(ExecuteSource source);
57 67
58 // Returns the bubble instance for the icon. 68 // Returns the bubble instance for the icon.
59 virtual views::BubbleDelegateView* GetBubble() const = 0; 69 virtual views::BubbleDelegateView* GetBubble() const = 0;
60 70
61 // Gets the given vector icon in the correct color and size based on |active| 71 // Gets the given vector icon in the correct color and size based on |active|
62 // and whether Chrome's in material design mode. 72 // and whether Chrome's in material design mode.
63 virtual gfx::VectorIconId GetVectorIcon() const = 0; 73 virtual gfx::VectorIconId GetVectorIcon() const = 0;
64 74
65 // Sets the image using a PNG from the resource bundle. Returns true if an 75 // Sets the image using a PNG from the resource bundle. Returns true if an
66 // image was set, or false if the icon should use a vector asset. This only 76 // image was set, or false if the icon should use a vector asset. This only
67 // exists for non-MD mode. TODO(estade): remove it. 77 // exists for non-MD mode. TODO(estade): remove it.
68 virtual bool SetRasterIcon(); 78 virtual bool SetRasterIcon();
69 79
70 // views::View: 80 // views::View:
71 void OnBoundsChanged(const gfx::Rect& previous_bounds) override; 81 void OnBoundsChanged(const gfx::Rect& previous_bounds) override;
72 82
83 // views::InkDropHost:
84 gfx::Point CalculateInkDropCenter() const override;
85
73 // Updates the icon after some state has changed. 86 // Updates the icon after some state has changed.
74 void UpdateIcon(); 87 void UpdateIcon();
75 88
76 // Sets the active state of the icon. An active icon will be displayed in a 89 // Sets the active state of the icon. An active icon will be displayed in a
77 // "call to action" color. 90 // "call to action" color.
78 void SetActiveInternal(bool active); 91 void SetActiveInternal(bool active);
79 92
80 bool active() const { return active_; } 93 bool active() const { return active_; }
81 94
82 private: 95 private:
83 // The CommandUpdater for the Browser object that owns the location bar. 96 // The CommandUpdater for the Browser object that owns the location bar.
84 CommandUpdater* command_updater_; 97 CommandUpdater* command_updater_;
85 98
86 // The command ID executed when the user clicks this icon. 99 // The command ID executed when the user clicks this icon.
87 const int command_id_; 100 const int command_id_;
88 101
89 // The active state. The precise definition of "active" is unique to each 102 // The active state. The precise definition of "active" is unique to each
90 // subclass, but generally indicates that the associated feature is acting on 103 // subclass, but generally indicates that the associated feature is acting on
91 // the web page. 104 // the web page.
92 bool active_; 105 bool active_;
93 106
94 // This is used to check if the bookmark bubble was showing during the mouse 107 // This is used to check if the bookmark bubble was showing during the mouse
95 // pressed event. If this is true then the mouse released event is ignored to 108 // pressed event. If this is true then the mouse released event is ignored to
96 // prevent the bubble from reshowing. 109 // prevent the bubble from reshowing.
97 bool suppress_mouse_released_action_; 110 bool suppress_mouse_released_action_;
98 111
112 // Animation delegate for the ink drop ripple effect.
113 scoped_ptr<views::InkDropDelegate> ink_drop_delegate_;
114
99 DISALLOW_COPY_AND_ASSIGN(BubbleIconView); 115 DISALLOW_COPY_AND_ASSIGN(BubbleIconView);
100 }; 116 };
101 117
102 #endif // CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_BUBBLE_ICON_VIEW_H_ 118 #endif // CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_BUBBLE_ICON_VIEW_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698