user_image_view.h revision 72a454cd3513ac24fbdd0e0cb9ad70b86a99b801
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 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#pragma once 8 9#include "views/controls/button/button.h" 10#include "views/view.h" 11 12class SkBitmap; 13 14namespace views { 15class ImageButton; 16class Label; 17class NativeButton; 18} // namespace views 19 20namespace chromeos { 21 22class CameraImageView; 23 24// View used for selecting user image. 25class UserImageView : public views::View, 26 public views::ButtonListener { 27 public: 28 // Delegate class to get notifications from the view. 29 class Delegate { 30 public: 31 virtual ~Delegate() {} 32 33 // Called if user accepts the selected image. The image is passed as a 34 // parameter. 35 virtual void OnOK(const SkBitmap& image) = 0; 36 37 // Called if user decides to skip image selection screen. 38 virtual void OnSkip() = 0; 39 }; 40 41 explicit UserImageView(Delegate* delegate); 42 virtual ~UserImageView(); 43 44 // Initializes this view, its children and layout. 45 void Init(); 46 47 // Updates image from camera. 48 void UpdateVideoFrame(const SkBitmap& frame); 49 50 // If in capturing mode, shows that camera is initializing by running 51 // throbber above the picture. Disables snapshot button until frame is 52 // received. 53 void ShowCameraInitializing(); 54 55 // If in capturing mode, shows that camera is broken instead of video 56 // frame and disables snapshot button until new frame is received. 57 void ShowCameraError(); 58 59 // Overridden from views::View: 60 virtual gfx::Size GetPreferredSize(); 61 62 // Overridden from views::ButtonListener. 63 virtual void ButtonPressed(views::Button* sender, const views::Event& event); 64 65 private: 66 // Initializes layout manager for this view. 67 void InitLayout(); 68 69 views::Label* title_label_; 70 views::NativeButton* ok_button_; 71 views::NativeButton* skip_button_; 72 views::ImageButton* snapshot_button_; 73 CameraImageView* user_image_; 74 75 // Notifications receiver. 76 Delegate* delegate_; 77 78 // Indicates that we're in capturing mode. When |false|, new video frames 79 // are not shown to user if received. 80 bool is_capturing_; 81 82 DISALLOW_COPY_AND_ASSIGN(UserImageView); 83}; 84 85} // namespace chromeos 86 87#endif // CHROME_BROWSER_CHROMEOS_LOGIN_USER_IMAGE_VIEW_H_ 88