OLD | NEW |
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 #include "chrome/browser/ui/views/avatar_menu_bubble_view.h" | 5 #include "chrome/browser/ui/views/avatar_menu_bubble_view.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
10 #include "chrome/browser/browser_process.h" | 10 #include "chrome/browser/browser_process.h" |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 // EditProfileLink ------------------------------------------------------------ | 128 // EditProfileLink ------------------------------------------------------------ |
129 | 129 |
130 // A custom Link control that forwards highlight state changes. We need to do | 130 // A custom Link control that forwards highlight state changes. We need to do |
131 // this to make sure that the ProfileItemView looks highlighted even when | 131 // this to make sure that the ProfileItemView looks highlighted even when |
132 // the mouse is over this link. | 132 // the mouse is over this link. |
133 class EditProfileLink : public views::Link { | 133 class EditProfileLink : public views::Link { |
134 public: | 134 public: |
135 explicit EditProfileLink(const string16& title, | 135 explicit EditProfileLink(const string16& title, |
136 HighlightDelegate* delegate); | 136 HighlightDelegate* delegate); |
137 | 137 |
138 virtual void OnMouseEntered(const views::MouseEvent& event) OVERRIDE; | 138 virtual void OnMouseEntered(const ui::MouseEvent& event) OVERRIDE; |
139 virtual void OnMouseExited(const views::MouseEvent& event) OVERRIDE; | 139 virtual void OnMouseExited(const ui::MouseEvent& event) OVERRIDE; |
140 virtual void OnFocus() OVERRIDE; | 140 virtual void OnFocus() OVERRIDE; |
141 virtual void OnBlur() OVERRIDE; | 141 virtual void OnBlur() OVERRIDE; |
142 | 142 |
143 views::CustomButton::ButtonState state() { return state_; } | 143 views::CustomButton::ButtonState state() { return state_; } |
144 | 144 |
145 private: | 145 private: |
146 HighlightDelegate* delegate_; | 146 HighlightDelegate* delegate_; |
147 views::CustomButton::ButtonState state_; | 147 views::CustomButton::ButtonState state_; |
148 }; | 148 }; |
149 | 149 |
150 EditProfileLink::EditProfileLink(const string16& title, | 150 EditProfileLink::EditProfileLink(const string16& title, |
151 HighlightDelegate* delegate) | 151 HighlightDelegate* delegate) |
152 : views::Link(title), | 152 : views::Link(title), |
153 delegate_(delegate), | 153 delegate_(delegate), |
154 state_(views::CustomButton::BS_NORMAL) { | 154 state_(views::CustomButton::BS_NORMAL) { |
155 } | 155 } |
156 | 156 |
157 void EditProfileLink::OnMouseEntered(const views::MouseEvent& event) { | 157 void EditProfileLink::OnMouseEntered(const ui::MouseEvent& event) { |
158 views::Link::OnMouseEntered(event); | 158 views::Link::OnMouseEntered(event); |
159 state_ = views::CustomButton::BS_HOT; | 159 state_ = views::CustomButton::BS_HOT; |
160 delegate_->OnHighlightStateChanged(); | 160 delegate_->OnHighlightStateChanged(); |
161 } | 161 } |
162 | 162 |
163 void EditProfileLink::OnMouseExited(const views::MouseEvent& event) { | 163 void EditProfileLink::OnMouseExited(const ui::MouseEvent& event) { |
164 views::Link::OnMouseExited(event); | 164 views::Link::OnMouseExited(event); |
165 state_ = views::CustomButton::BS_NORMAL; | 165 state_ = views::CustomButton::BS_NORMAL; |
166 delegate_->OnHighlightStateChanged(); | 166 delegate_->OnHighlightStateChanged(); |
167 } | 167 } |
168 | 168 |
169 void EditProfileLink::OnFocus() { | 169 void EditProfileLink::OnFocus() { |
170 views::Link::OnFocus(); | 170 views::Link::OnFocus(); |
171 delegate_->OnFocusStateChanged(true); | 171 delegate_->OnFocusStateChanged(true); |
172 } | 172 } |
173 | 173 |
(...skipping 23 matching lines...) Expand all Loading... |
197 // Control that shows information about a single profile. | 197 // Control that shows information about a single profile. |
198 class ProfileItemView : public views::CustomButton, | 198 class ProfileItemView : public views::CustomButton, |
199 public HighlightDelegate { | 199 public HighlightDelegate { |
200 public: | 200 public: |
201 ProfileItemView(const AvatarMenuModel::Item& item, | 201 ProfileItemView(const AvatarMenuModel::Item& item, |
202 views::ButtonListener* switch_profile_listener, | 202 views::ButtonListener* switch_profile_listener, |
203 views::LinkListener* edit_profile_listener); | 203 views::LinkListener* edit_profile_listener); |
204 | 204 |
205 virtual gfx::Size GetPreferredSize() OVERRIDE; | 205 virtual gfx::Size GetPreferredSize() OVERRIDE; |
206 virtual void Layout() OVERRIDE; | 206 virtual void Layout() OVERRIDE; |
207 virtual void OnMouseEntered(const views::MouseEvent& event) OVERRIDE; | 207 virtual void OnMouseEntered(const ui::MouseEvent& event) OVERRIDE; |
208 virtual void OnMouseExited(const views::MouseEvent& event) OVERRIDE; | 208 virtual void OnMouseExited(const ui::MouseEvent& event) OVERRIDE; |
209 virtual void OnFocus() OVERRIDE; | 209 virtual void OnFocus() OVERRIDE; |
210 virtual void OnBlur() OVERRIDE; | 210 virtual void OnBlur() OVERRIDE; |
211 | 211 |
212 virtual void OnHighlightStateChanged() OVERRIDE; | 212 virtual void OnHighlightStateChanged() OVERRIDE; |
213 virtual void OnFocusStateChanged(bool has_focus) OVERRIDE; | 213 virtual void OnFocusStateChanged(bool has_focus) OVERRIDE; |
214 | 214 |
215 EditProfileLink* edit_link() { return edit_link_; } | 215 EditProfileLink* edit_link() { return edit_link_; } |
216 const AvatarMenuModel::Item& item() { return item_; } | 216 const AvatarMenuModel::Item& item() { return item_; } |
217 | 217 |
218 private: | 218 private: |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
316 name_label_->SetBounds(label_x, y, name_size.width(), name_size.height()); | 316 name_label_->SetBounds(label_x, y, name_size.width(), name_size.height()); |
317 | 317 |
318 int bottom = y + labels_height; | 318 int bottom = y + labels_height; |
319 sync_state_label_->SetBounds(label_x, bottom - state_size.height(), | 319 sync_state_label_->SetBounds(label_x, bottom - state_size.height(), |
320 state_size.width(), state_size.height()); | 320 state_size.width(), state_size.height()); |
321 // The edit link overlaps the sync state label. | 321 // The edit link overlaps the sync state label. |
322 edit_link_->SetBounds(label_x, bottom - edit_size.height(), | 322 edit_link_->SetBounds(label_x, bottom - edit_size.height(), |
323 edit_size.width(), edit_size.height()); | 323 edit_size.width(), edit_size.height()); |
324 } | 324 } |
325 | 325 |
326 void ProfileItemView::OnMouseEntered(const views::MouseEvent& event) { | 326 void ProfileItemView::OnMouseEntered(const ui::MouseEvent& event) { |
327 views::CustomButton::OnMouseEntered(event); | 327 views::CustomButton::OnMouseEntered(event); |
328 OnHighlightStateChanged(); | 328 OnHighlightStateChanged(); |
329 } | 329 } |
330 | 330 |
331 void ProfileItemView::OnMouseExited(const views::MouseEvent& event) { | 331 void ProfileItemView::OnMouseExited(const ui::MouseEvent& event) { |
332 views::CustomButton::OnMouseExited(event); | 332 views::CustomButton::OnMouseExited(event); |
333 OnHighlightStateChanged(); | 333 OnHighlightStateChanged(); |
334 } | 334 } |
335 | 335 |
336 void ProfileItemView::OnFocus() { | 336 void ProfileItemView::OnFocus() { |
337 views::CustomButton::OnFocus(); | 337 views::CustomButton::OnFocus(); |
338 OnFocusStateChanged(true); | 338 OnFocusStateChanged(true); |
339 } | 339 } |
340 | 340 |
341 void ProfileItemView::OnBlur() { | 341 void ProfileItemView::OnBlur() { |
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
551 add_profile_link_->SetHorizontalAlignment(views::Label::ALIGN_LEFT); | 551 add_profile_link_->SetHorizontalAlignment(views::Label::ALIGN_LEFT); |
552 add_profile_link_->SetBackgroundColor(color()); | 552 add_profile_link_->SetBackgroundColor(color()); |
553 add_profile_link_->SetEnabledColor(SkColorSetRGB(0xe3, 0xed, 0xf6)); | 553 add_profile_link_->SetEnabledColor(SkColorSetRGB(0xe3, 0xed, 0xf6)); |
554 AddChildView(add_profile_link_); | 554 AddChildView(add_profile_link_); |
555 | 555 |
556 // If the bubble has already been shown then resize and reposition the bubble. | 556 // If the bubble has already been shown then resize and reposition the bubble. |
557 Layout(); | 557 Layout(); |
558 if (GetBubbleFrameView()) | 558 if (GetBubbleFrameView()) |
559 SizeToContents(); | 559 SizeToContents(); |
560 } | 560 } |
OLD | NEW |