| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_USER_IMAGE_VIEW_H_ | |
| 6 #define CHROME_BROWSER_CHROMEOS_LOGIN_USER_IMAGE_VIEW_H_ | |
| 7 | |
| 8 #include "views/controls/button/button.h" | |
| 9 #include "views/view.h" | |
| 10 | |
| 11 class SkBitmap; | |
| 12 | |
| 13 namespace views { | |
| 14 class ImageView; | |
| 15 class Label; | |
| 16 class NativeButton; | |
| 17 class ImageButton; | |
| 18 } // namespace views | |
| 19 | |
| 20 namespace chromeos { | |
| 21 | |
| 22 // View used for selecting user image. | |
| 23 class UserImageView : public views::View, | |
| 24 public views::ButtonListener { | |
| 25 public: | |
| 26 // Delegate class to get notifications from the view. | |
| 27 class Delegate { | |
| 28 public: | |
| 29 virtual ~Delegate() {} | |
| 30 | |
| 31 // Called if user accepts the selected image. The image is passed as a | |
| 32 // parameter. | |
| 33 virtual void OnOK(const SkBitmap& image) = 0; | |
| 34 | |
| 35 // Called if user decides to skip image selection screen. | |
| 36 virtual void OnCancel() = 0; | |
| 37 }; | |
| 38 | |
| 39 explicit UserImageView(Delegate* delegate); | |
| 40 virtual ~UserImageView(); | |
| 41 | |
| 42 // Initialize view layout. | |
| 43 void Init(); | |
| 44 | |
| 45 // Update strings from the resources. Executed on language change. | |
| 46 void UpdateLocalizedStrings(); | |
| 47 | |
| 48 // Updates snapshot from camera on camera image view. | |
| 49 void UpdateVideoFrame(const SkBitmap& frame); | |
| 50 | |
| 51 // Called when user left-clicks video image control. | |
| 52 void OnVideoImageClicked(); | |
| 53 | |
| 54 // Overridden from views::View: | |
| 55 virtual gfx::Size GetPreferredSize(); | |
| 56 virtual void Layout(); | |
| 57 | |
| 58 // Overridden from views::ButtonListener. | |
| 59 virtual void ButtonPressed(views::Button* sender, const views::Event& event); | |
| 60 | |
| 61 protected: | |
| 62 // views::View overrides: | |
| 63 virtual void LocaleChanged(); | |
| 64 | |
| 65 private: | |
| 66 // Delete and recreate native controls that fail to update preferred size | |
| 67 // after string update. | |
| 68 void RecreateNativeControls(); | |
| 69 | |
| 70 views::Label* title_label_; | |
| 71 views::NativeButton* ok_button_; | |
| 72 views::NativeButton* cancel_button_; | |
| 73 views::ImageButton* video_button_; | |
| 74 views::ImageView* selected_image_; | |
| 75 | |
| 76 // Notifications receiver. | |
| 77 Delegate* delegate_; | |
| 78 | |
| 79 // Indicates that some image was selected and OK can be pressed. | |
| 80 bool image_selected_; | |
| 81 | |
| 82 // Last frame that was received from the camera in its original resolution. | |
| 83 scoped_ptr<SkBitmap> last_frame_; | |
| 84 | |
| 85 DISALLOW_COPY_AND_ASSIGN(UserImageView); | |
| 86 }; | |
| 87 | |
| 88 } // namespace chromeos | |
| 89 | |
| 90 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_USER_IMAGE_VIEW_H_ | |
| 91 | |
| OLD | NEW |