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

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 (missing member init) Created 4 years, 10 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
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/macros.h" 8 #include "base/macros.h"
9 #include "base/memory/scoped_ptr.h"
9 #include "ui/gfx/image/image_skia.h" 10 #include "ui/gfx/image/image_skia.h"
10 #include "ui/gfx/vector_icons_public.h" 11 #include "ui/gfx/vector_icons_public.h"
12 #include "ui/views/animation/ink_drop_host.h"
11 #include "ui/views/controls/image_view.h" 13 #include "ui/views/controls/image_view.h"
14 #include "ui/views/widget/widget_observer.h"
12 15
13 class CommandUpdater; 16 class CommandUpdater;
14 17
15 namespace gfx { 18 namespace gfx {
16 enum class VectorIconId; 19 enum class VectorIconId;
17 } 20 }
18 21
19 namespace views { 22 namespace views {
20 class BubbleDelegateView; 23 class BubbleDelegateView;
24 class InkDropDelegate;
21 } 25 }
22 26
23 // Represents an icon on the omnibox that shows a bubble when clicked. 27 // Represents an icon on the omnibox that shows a bubble when clicked.
24 class BubbleIconView : public views::ImageView { 28 class BubbleIconView : public views::View,
29 public views::InkDropHost,
30 public views::WidgetObserver {
25 protected: 31 protected:
26 enum ExecuteSource { 32 enum ExecuteSource {
27 EXECUTE_SOURCE_MOUSE, 33 EXECUTE_SOURCE_MOUSE,
28 EXECUTE_SOURCE_KEYBOARD, 34 EXECUTE_SOURCE_KEYBOARD,
29 EXECUTE_SOURCE_GESTURE, 35 EXECUTE_SOURCE_GESTURE,
30 }; 36 };
31 37
32 BubbleIconView(CommandUpdater* command_updater, int command_id); 38 BubbleIconView(CommandUpdater* command_updater, int command_id);
33 ~BubbleIconView() override; 39 ~BubbleIconView() override;
34 40
35 // Returns true if a related bubble is showing. 41 // Returns true if a related bubble is showing.
36 bool IsBubbleShowing() const; 42 bool IsBubbleShowing() const;
37 43
44 // Sets the image that should be displayed in |image_|.
45 void SetImage(const gfx::ImageSkia* image_skia);
46
47 // Returns the image currently displayed, which can be empty if not set.
48 // The returned image is owned by |image_|.
49 const gfx::ImageSkia& GetImage() const;
50
51 // Sets the tooltip text.
52 void SetTooltipText(const base::string16& tooltip);
53
38 // Invoked prior to executing the command. 54 // Invoked prior to executing the command.
39 virtual void OnExecuting(ExecuteSource execute_source) = 0; 55 virtual void OnExecuting(ExecuteSource execute_source) = 0;
40 56
41 // views::ImageView: 57 // views::View:
42 void GetAccessibleState(ui::AXViewState* state) override; 58 void GetAccessibleState(ui::AXViewState* state) override;
43 bool GetTooltipText(const gfx::Point& p, base::string16* tooltip) const 59 bool GetTooltipText(const gfx::Point& p, base::string16* tooltip) const
44 override; 60 override;
61 gfx::Size GetPreferredSize() const override;
62 void Layout() override;
45 bool OnMousePressed(const ui::MouseEvent& event) override; 63 bool OnMousePressed(const ui::MouseEvent& event) override;
46 void OnMouseReleased(const ui::MouseEvent& event) override; 64 void OnMouseReleased(const ui::MouseEvent& event) override;
47 bool OnKeyPressed(const ui::KeyEvent& event) override; 65 bool OnKeyPressed(const ui::KeyEvent& event) override;
48 void ViewHierarchyChanged( 66 void ViewHierarchyChanged(
49 const ViewHierarchyChangedDetails& details) override; 67 const ViewHierarchyChangedDetails& details) override;
50 void OnNativeThemeChanged(const ui::NativeTheme* theme) override; 68 void OnNativeThemeChanged(const ui::NativeTheme* theme) override;
51 69
52 // ui::EventHandler: 70 // ui::EventHandler:
53 void OnGestureEvent(ui::GestureEvent* event) override; 71 void OnGestureEvent(ui::GestureEvent* event) override;
54 72
73 // views::InkDropHost:
74 void AddInkDropLayer(ui::Layer* ink_drop_layer) override;
75 void RemoveInkDropLayer(ui::Layer* ink_drop_layer) override;
76
77 // views::WidgetObserver:
78 void OnWidgetDestroying(views::Widget* widget) override;
79 void OnWidgetVisibilityChanged(views::Widget* widget,
80 bool visible) override;
81
55 protected: 82 protected:
56 // Calls OnExecuting and runs |command_id_| with a valid |command_updater_|. 83 // Calls OnExecuting and runs |command_id_| with a valid |command_updater_|.
57 virtual void ExecuteCommand(ExecuteSource source); 84 virtual void ExecuteCommand(ExecuteSource source);
58 85
59 // Returns the bubble instance for the icon. 86 // Returns the bubble instance for the icon.
60 virtual views::BubbleDelegateView* GetBubble() const = 0; 87 virtual views::BubbleDelegateView* GetBubble() const = 0;
61 88
62 // Gets the given vector icon in the correct color and size based on |active| 89 // Gets the given vector icon in the correct color and size based on |active|
63 // and whether Chrome's in material design mode. 90 // and whether Chrome's in material design mode.
64 virtual gfx::VectorIconId GetVectorIcon() const = 0; 91 virtual gfx::VectorIconId GetVectorIcon() const;
65 92
66 // Sets the image using a PNG from the resource bundle. Returns true if an 93 // Sets the image using a PNG from the resource bundle. Returns true if an
67 // image was set, or false if the icon should use a vector asset. This only 94 // image was set, or false if the icon should use a vector asset. This only
68 // exists for non-MD mode. TODO(estade): remove it. 95 // exists for non-MD mode. TODO(estade): remove it.
69 virtual bool SetRasterIcon(); 96 virtual bool SetRasterIcon();
70 97
71 // views::View: 98 // views::View:
72 void OnBoundsChanged(const gfx::Rect& previous_bounds) override; 99 void OnBoundsChanged(const gfx::Rect& previous_bounds) override;
73 100
101 // views::InkDropHost:
102 gfx::Point CalculateInkDropCenter() const override;
103 bool ShouldShowInkDropHover() const override;
104
74 // Updates the icon after some state has changed. 105 // Updates the icon after some state has changed.
75 void UpdateIcon(); 106 void UpdateIcon();
76 107
77 // Sets the active state of the icon. An active icon will be displayed in a 108 // Sets the active state of the icon. An active icon will be displayed in a
78 // "call to action" color. 109 // "call to action" color.
79 void SetActiveInternal(bool active); 110 void SetActiveInternal(bool active);
80 111
81 bool active() const { return active_; } 112 bool active() const { return active_; }
82 113
83 private: 114 private:
115 // The image shown in the button.
116 views::ImageView* image_;
117
84 // The CommandUpdater for the Browser object that owns the location bar. 118 // The CommandUpdater for the Browser object that owns the location bar.
85 CommandUpdater* command_updater_; 119 CommandUpdater* command_updater_;
86 120
87 // The command ID executed when the user clicks this icon. 121 // The command ID executed when the user clicks this icon.
88 const int command_id_; 122 const int command_id_;
89 123
90 // The active state. The precise definition of "active" is unique to each 124 // The active state. The precise definition of "active" is unique to each
91 // subclass, but generally indicates that the associated feature is acting on 125 // subclass, but generally indicates that the associated feature is acting on
92 // the web page. 126 // the web page.
93 bool active_; 127 bool active_;
94 128
95 // This is used to check if the bookmark bubble was showing during the mouse 129 // This is used to check if the bookmark bubble was showing during the mouse
96 // pressed event. If this is true then the mouse released event is ignored to 130 // pressed event. If this is true then the mouse released event is ignored to
97 // prevent the bubble from reshowing. 131 // prevent the bubble from reshowing.
98 bool suppress_mouse_released_action_; 132 bool suppress_mouse_released_action_;
99 133
134 // Animation delegate for the ink drop ripple effect.
135 scoped_ptr<views::InkDropDelegate> ink_drop_delegate_;
136
100 DISALLOW_COPY_AND_ASSIGN(BubbleIconView); 137 DISALLOW_COPY_AND_ASSIGN(BubbleIconView);
101 }; 138 };
102 139
103 #endif // CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_BUBBLE_ICON_VIEW_H_ 140 #endif // CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_BUBBLE_ICON_VIEW_H_
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/frame/browser_view.cc ('k') | chrome/browser/ui/views/location_bar/bubble_icon_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698