• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_DEFAULT_IMAGES_VIEW_H_
6 #define CHROME_BROWSER_CHROMEOS_LOGIN_DEFAULT_IMAGES_VIEW_H_
7 #pragma once
8 
9 #include "views/controls/button/button.h"
10 #include "views/view.h"
11 
12 #include <vector>
13 
14 class SkBitmap;
15 
16 namespace chromeos {
17 
18 class UserImageButton;
19 
20 // View used for selecting user image on OOBE screen.
21 class DefaultImagesView : public views::View,
22                           public views::ButtonListener {
23  public:
24   class Delegate {
25    public:
~Delegate()26     virtual ~Delegate() {}
27 
28     // Called when user clicks on capture button.
29     virtual void OnCaptureButtonClicked() = 0;
30 
31     // Called when user selects an image.
32     virtual void OnImageSelected(int image_index) = 0;
33   };
34 
35   explicit DefaultImagesView(Delegate* delegate);
36 
37   // Initializes this view, its children and layout.
38   void Init();
39 
40   // Returns the index of the selected default image or -1 if there's no
41   // selected image.
42   int GetDefaultImageIndex() const;
43 
44   // Allows to specify the selected image index specifically.
45   void SetDefaultImageIndex(int index);
46 
47   // Unselects the selected image if there's one.
48   void ClearSelection();
49 
50   // Overridden from views::View:
51   virtual gfx::Size GetPreferredSize();
52 
53   // Overridden from views::ButtonListener.
54   virtual void ButtonPressed(views::Button* sender, const views::Event& event);
55 
56  private:
57   // Resizes and sets image with specified resource id for the button.
58   void InitButton(int resource_id, UserImageButton* button) const;
59 
60   // Initializes layout manager for this view.
61   void InitLayout();
62 
63   // Vector of image buttons corresponding to default images and take photo
64   // button.
65   std::vector<UserImageButton*> default_images_;
66 
67   // Index of the currently selected image or -1.
68   int selected_image_index_;
69 
70   Delegate* delegate_;
71 
72   DISALLOW_COPY_AND_ASSIGN(DefaultImagesView);
73 };
74 
75 }  // namespace chromeos
76 
77 #endif  // CHROME_BROWSER_CHROMEOS_LOGIN_DEFAULT_IMAGES_VIEW_H_
78 
79 
80