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

Side by Side Diff: chrome/browser/ui/views/profiles/new_avatar_button.h

Issue 2851543002: Update avatar button to MD (part 1) (Closed)
Patch Set: Created 3 years, 7 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 2014 The Chromium Authors. All rights reserved. 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 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_PROFILES_NEW_AVATAR_BUTTON_H_ 5 #ifndef CHROME_BROWSER_UI_VIEWS_PROFILES_NEW_AVATAR_BUTTON_H_
6 #define CHROME_BROWSER_UI_VIEWS_PROFILES_NEW_AVATAR_BUTTON_H_ 6 #define CHROME_BROWSER_UI_VIEWS_PROFILES_NEW_AVATAR_BUTTON_H_
7 7
8 #include "base/macros.h" 8 #include "base/macros.h"
9 #include "chrome/browser/profiles/profile_attributes_storage.h" 9 #include "chrome/browser/profiles/profile_attributes_storage.h"
10 #include "chrome/browser/ui/avatar_button_error_controller.h" 10 #include "chrome/browser/ui/avatar_button_error_controller.h"
11 #include "chrome/browser/ui/avatar_button_error_controller_delegate.h" 11 #include "chrome/browser/ui/avatar_button_error_controller_delegate.h"
12 #include "chrome/browser/ui/views/frame/browser_view.h"
12 #include "chrome/browser/ui/views/profiles/avatar_button_style.h" 13 #include "chrome/browser/ui/views/profiles/avatar_button_style.h"
13 #include "ui/views/controls/button/label_button.h" 14 #include "ui/views/controls/button/menu_button.h"
14 15
15 class AvatarButtonDelegate; 16 class AvatarButtonDelegate;
16 class Profile; 17 class Profile;
17 18
18 // Avatar button that displays the active profile's name in the caption area. 19 class AvatarButton : public views::MenuButton,
Evan Stade 2017/04/27 17:15:02 does this really need to be a menu button? what is
emx 2017/04/28 12:39:40 MenuButton takes care of the ink drop animation on
Evan Stade 2017/04/28 18:38:29 I believe all of the things you've described are a
emx 2017/05/02 15:17:11 I forgot to say: AvatarButton used to override OnM
Evan Stade 2017/05/02 15:49:20 I don't know if that's what the avatar button is o
19 class NewAvatarButton : public views::LabelButton, 20 public AvatarButtonErrorControllerDelegate,
20 public AvatarButtonErrorControllerDelegate, 21 public ProfileAttributesStorage::Observer {
21 public ProfileAttributesStorage::Observer {
22 public: 22 public:
23 NewAvatarButton(AvatarButtonDelegate* delegate, 23 AvatarButton(AvatarButtonDelegate* delegate, Profile* profile);
24 AvatarButtonStyle button_style, 24 ~AvatarButton() override;
25 Profile* profile);
26 ~NewAvatarButton() override;
27 25
28 // Views::LabelButton 26 // Update the avatar button height previously calculated by GetPreferredSize,
29 bool OnMousePressed(const ui::MouseEvent& event) override; 27 // if needed, now that the button's position is known.
30 void OnMouseReleased(const ui::MouseEvent& event) override; 28 virtual void UpdateButtonHeightForPosition(const int button_x,
29 int* button_height) const {}
31 30
32 // Views 31 protected:
33 void OnGestureEvent(ui::GestureEvent* event) override; 32 // MenuButton
33 bool IsTriggerableEvent(const ui::Event& event) override;
34
35 // Called when the profile info cache or signin/sync error has changed, which
36 // means we might have to update the icon/text of the button.
37 void Update();
38
39 void set_generic_avatar(const gfx::ImageSkia& generic_avatar) {
40 generic_avatar_ = generic_avatar;
41 }
34 42
35 private: 43 private:
36 friend class ProfileChooserViewExtensionsTest; 44 friend class ProfileChooserViewExtensionsTest;
37 45
38 // AvatarButtonErrorControllerDelegate: 46 // AvatarButtonErrorControllerDelegate:
39 void OnAvatarErrorChanged() override; 47 void OnAvatarErrorChanged() override;
40 48
41 // ProfileAttributesStorage::Observer: 49 // ProfileAttributesStorage::Observer:
42 void OnProfileAdded(const base::FilePath& profile_path) override; 50 void OnProfileAdded(const base::FilePath& profile_path) override;
43 void OnProfileWasRemoved(const base::FilePath& profile_path, 51 void OnProfileWasRemoved(const base::FilePath& profile_path,
44 const base::string16& profile_name) override; 52 const base::string16& profile_name) override;
45 void OnProfileNameChanged(const base::FilePath& profile_path, 53 void OnProfileNameChanged(const base::FilePath& profile_path,
46 const base::string16& old_profile_name) override; 54 const base::string16& old_profile_name) override;
47 void OnProfileSupervisedUserIdChanged( 55 void OnProfileSupervisedUserIdChanged(
48 const base::FilePath& profile_path) override; 56 const base::FilePath& profile_path) override;
49 57
50 // Called when the profile info cache or signin/sync error has changed, which 58 void UpdateButton(bool use_generic_button);
51 // means we might have to update the icon/text of the button.
52 void Update();
53 59
54 AvatarButtonDelegate* delegate_; 60 AvatarButtonDelegate* delegate_;
55 AvatarButtonErrorController error_controller_; 61 AvatarButtonErrorController error_controller_;
56 Profile* profile_; 62 Profile* profile_;
57 63
58 // The icon displayed instead of the profile name in the local profile case. 64 // The icon displayed instead of the profile name in the local profile case.
59 // Different assets are used depending on the OS version. 65 // Different assets are used depending on the OS version.
60 gfx::ImageSkia generic_avatar_; 66 gfx::ImageSkia generic_avatar_;
61 67
62 // This is used to check if the bubble was showing during the mouse pressed 68 DISALLOW_COPY_AND_ASSIGN(AvatarButton);
63 // event. If this is true then the mouse released event is ignored to prevent 69 };
64 // the bubble from reshowing. 70
65 bool suppress_mouse_released_action_; 71 // Avatar button that displays the active profile's name in the caption area.
72 class NewAvatarButton : public AvatarButton {
73 public:
74 NewAvatarButton(AvatarButtonDelegate* delegate,
75 AvatarButtonStyle button_style,
76 Profile* profile);
77 ~NewAvatarButton() override;
78
79 protected:
80 gfx::Size GetPreferredSize() const override;
81
82 private:
83 std::unique_ptr<views::Border> CreateBorder(
84 const int normal_image_set[],
85 const int hot_image_set[],
86 const int pushed_image_set[]) const;
87 // Sets generic_avatar_ to the image with the specified IDR.
88 void SetButtonAvatar(int avatar_idr);
66 89
67 DISALLOW_COPY_AND_ASSIGN(NewAvatarButton); 90 DISALLOW_COPY_AND_ASSIGN(NewAvatarButton);
68 }; 91 };
69 92
93 class MaterialDesignAvatarButton : public AvatarButton {
94 public:
95 MaterialDesignAvatarButton(AvatarButtonDelegate* delegate,
96 Profile* profile,
97 BrowserView* browser_view);
98 ~MaterialDesignAvatarButton() override;
99
100 void UpdateButtonHeightForPosition(const int button_x,
101 int* button_height) const override;
102
103 protected:
104 gfx::Size GetPreferredSize() const override;
105 std::unique_ptr<views::InkDrop> CreateInkDrop() override;
106 std::unique_ptr<views::InkDropRipple> CreateInkDropRipple() const override;
107 std::unique_ptr<views::InkDropHighlight> CreateInkDropHighlight()
108 const override;
109
110 private:
111 std::unique_ptr<views::Border> CreateBorder() const;
112
113 BrowserView* browser_view_;
114
115 DISALLOW_COPY_AND_ASSIGN(MaterialDesignAvatarButton);
116 };
117
70 #endif // CHROME_BROWSER_UI_VIEWS_PROFILES_NEW_AVATAR_BUTTON_H_ 118 #endif // CHROME_BROWSER_UI_VIEWS_PROFILES_NEW_AVATAR_BUTTON_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698