OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/chromeos/login/user_view.h" | 5 #include "chrome/browser/chromeos/login/user_view.h" |
6 | 6 |
7 #include "base/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
8 #include "chrome/browser/chromeos/login/helper.h" | 8 #include "chrome/browser/chromeos/login/helper.h" |
9 #include "chrome/browser/chromeos/login/rounded_rect_painter.h" | 9 #include "chrome/browser/chromeos/login/rounded_rect_painter.h" |
10 #include "chrome/browser/chromeos/login/rounded_view.h" | 10 #include "chrome/browser/chromeos/login/rounded_view.h" |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 SetEnabledColor(SK_ColorWHITE); | 141 SetEnabledColor(SK_ColorWHITE); |
142 SetDisabledColor(SK_ColorWHITE); | 142 SetDisabledColor(SK_ColorWHITE); |
143 SetHighlightColor(SK_ColorWHITE); | 143 SetHighlightColor(SK_ColorWHITE); |
144 SetHoverColor(SK_ColorWHITE); | 144 SetHoverColor(SK_ColorWHITE); |
145 SetIcon(icon_); | 145 SetIcon(icon_); |
146 UpdatePosition(); | 146 UpdatePosition(); |
147 } | 147 } |
148 | 148 |
149 protected: | 149 protected: |
150 // Overridden from View: | 150 // Overridden from View: |
151 virtual void OnMouseExited(const views::MouseEvent& event) { | 151 virtual void OnMouseExited(const views::MouseEvent& event) OVERRIDE { |
152 SetIcon(icon_); | 152 SetIcon(icon_); |
153 views::TextButton::SetText(std::wstring()); | 153 views::TextButton::SetText(std::wstring()); |
154 ClearMaxTextSize(); | 154 ClearMaxTextSize(); |
155 set_background(NULL); | 155 set_background(NULL); |
156 set_border(new views::TextButtonBorder); | 156 set_border(new views::TextButtonBorder); |
157 UpdatePosition(); | 157 UpdatePosition(); |
158 views::TextButton::OnMouseExited(event); | 158 views::TextButton::OnMouseExited(event); |
159 was_first_click_ = false; | 159 was_first_click_ = false; |
160 } | 160 } |
161 | 161 |
162 void NotifyClick(const views::Event& event) { | 162 virtual void NotifyClick(const views::Event& event) OVERRIDE { |
163 if (!was_first_click_) { | 163 if (!was_first_click_) { |
164 // On first click transform image to "remove" label. | 164 // On first click transform image to "remove" label. |
165 SetIcon(SkBitmap()); | 165 SetIcon(SkBitmap()); |
166 views::TextButton::SetText(text_); | 166 views::TextButton::SetText(text_); |
167 | 167 |
168 const SkColor kStrokeColor = SK_ColorWHITE; | 168 const SkColor kStrokeColor = SK_ColorWHITE; |
169 const SkColor kButtonColor = 0xFFE94949; | 169 const SkColor kButtonColor = 0xFFE94949; |
170 const int kStrokeWidth = 1; | 170 const int kStrokeWidth = 1; |
171 const int kVerticalPadding = 4; | 171 const int kVerticalPadding = 4; |
172 const int kHorizontalPadding = 8; | 172 const int kHorizontalPadding = 8; |
(...skipping 10 matching lines...) Expand all Loading... |
183 kHorizontalPadding)); | 183 kHorizontalPadding)); |
184 | 184 |
185 UpdatePosition(); | 185 UpdatePosition(); |
186 was_first_click_ = true; | 186 was_first_click_ = true; |
187 } else { | 187 } else { |
188 // On second click propagate to base class to fire ButtonPressed. | 188 // On second click propagate to base class to fire ButtonPressed. |
189 views::TextButton::NotifyClick(event); | 189 views::TextButton::NotifyClick(event); |
190 } | 190 } |
191 } | 191 } |
192 | 192 |
193 void SetText(const std::wstring& text) { | 193 virtual void SetText(const std::wstring& text) OVERRIDE { |
194 text_ = text; | 194 text_ = text; |
195 } | 195 } |
196 | 196 |
197 private: | 197 private: |
198 // Update button position and schedule paint event for the view and parent. | 198 // Update button position and schedule paint event for the view and parent. |
199 void UpdatePosition() { | 199 void UpdatePosition() { |
200 gfx::Size size = GetPreferredSize(); | 200 gfx::Size size = GetPreferredSize(); |
201 gfx::Point origin = top_right_; | 201 gfx::Point origin = top_right_; |
202 origin.Offset(-size.width(), 0); | 202 origin.Offset(-size.width(), 0); |
203 SetBoundsRect(gfx::Rect(origin, size)); | 203 SetBoundsRect(gfx::Rect(origin, size)); |
(...skipping 16 matching lines...) Expand all Loading... |
220 : delegate_(delegate) { } | 220 : delegate_(delegate) { } |
221 | 221 |
222 void SetImage(const SkBitmap& image, const SkBitmap& image_hot) { | 222 void SetImage(const SkBitmap& image, const SkBitmap& image_hot) { |
223 image_ = image; | 223 image_ = image; |
224 image_hot_ = image_hot; | 224 image_hot_ = image_hot; |
225 views::ImageView::SetImage(image_); | 225 views::ImageView::SetImage(image_); |
226 } | 226 } |
227 | 227 |
228 protected: | 228 protected: |
229 // Overridden from View: | 229 // Overridden from View: |
230 virtual void OnMouseEntered(const views::MouseEvent& event) { | 230 virtual void OnMouseEntered(const views::MouseEvent& event) OVERRIDE { |
231 views::ImageView::SetImage(image_hot_); | 231 views::ImageView::SetImage(image_hot_); |
232 } | 232 } |
233 | 233 |
234 virtual void OnMouseExited(const views::MouseEvent& event) { | 234 virtual void OnMouseExited(const views::MouseEvent& event) OVERRIDE { |
235 views::ImageView::SetImage(image_); | 235 views::ImageView::SetImage(image_); |
236 } | 236 } |
237 | 237 |
238 gfx::NativeCursor GetCursorForPoint( | 238 gfx::NativeCursor GetCursorForPoint(ui::EventType event_type, |
239 ui::EventType event_type, | 239 const gfx::Point& p) OVERRIDE { |
240 const gfx::Point& p) { | |
241 return (delegate_->IsUserSelected()) ? NULL : gfx::GetCursor(GDK_HAND2); | 240 return (delegate_->IsUserSelected()) ? NULL : gfx::GetCursor(GDK_HAND2); |
242 } | 241 } |
243 | 242 |
244 private: | 243 private: |
245 const UserView::Delegate* delegate_; | 244 const UserView::Delegate* delegate_; |
246 | 245 |
247 SkBitmap image_; | 246 SkBitmap image_; |
248 SkBitmap image_hot_; | 247 SkBitmap image_hot_; |
249 | 248 |
250 DISALLOW_COPY_AND_ASSIGN(PodImageView); | 249 DISALLOW_COPY_AND_ASSIGN(PodImageView); |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
339 delegate_->OnRemoveUser(); | 338 delegate_->OnRemoveUser(); |
340 } | 339 } |
341 | 340 |
342 void UserView::OnLocaleChanged() { | 341 void UserView::OnLocaleChanged() { |
343 remove_button_->SetText( | 342 remove_button_->SetText( |
344 UTF16ToWide(l10n_util::GetStringUTF16(IDS_LOGIN_REMOVE))); | 343 UTF16ToWide(l10n_util::GetStringUTF16(IDS_LOGIN_REMOVE))); |
345 delegate_->OnLocaleChanged(); | 344 delegate_->OnLocaleChanged(); |
346 } | 345 } |
347 | 346 |
348 } // namespace chromeos | 347 } // namespace chromeos |
OLD | NEW |