| OLD | NEW |
| (Empty) |
| 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: | |
| 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 virtual ~DefaultImagesView(); | |
| 37 | |
| 38 // Initializes this view, its children and layout. | |
| 39 void Init(); | |
| 40 | |
| 41 // Returns the index of the selected default image or -1 if there's no | |
| 42 // selected image. | |
| 43 int GetDefaultImageIndex() const; | |
| 44 | |
| 45 // Allows to specify the selected image index specifically. | |
| 46 void SetDefaultImageIndex(int index); | |
| 47 | |
| 48 // Unselects the selected image if there's one. | |
| 49 void ClearSelection(); | |
| 50 | |
| 51 // Used navigate the images via keyboard. | |
| 52 void SelectNextImage(); | |
| 53 void SelectPreviousImage(); | |
| 54 void SelectNextRowImage(); | |
| 55 void SelectPreviousRowImage(); | |
| 56 | |
| 57 // Overridden from views::View: | |
| 58 virtual gfx::Size GetPreferredSize(); | |
| 59 | |
| 60 // Overridden from views::ButtonListener. | |
| 61 virtual void ButtonPressed(views::Button* sender, const views::Event& event); | |
| 62 | |
| 63 private: | |
| 64 // Resizes and sets image with specified resource id for the button. | |
| 65 void InitButton(int resource_id, UserImageButton* button) const; | |
| 66 | |
| 67 // Initializes layout manager for this view. | |
| 68 void InitLayout(); | |
| 69 | |
| 70 // Update the current selected image after keyboard navigation. | |
| 71 void UpdateSelectedImage(); | |
| 72 | |
| 73 // Vector of image buttons corresponding to default images and take photo | |
| 74 // button. | |
| 75 std::vector<UserImageButton*> default_images_; | |
| 76 | |
| 77 // Index of the currently selected image or -1. | |
| 78 int selected_image_index_; | |
| 79 | |
| 80 Delegate* delegate_; | |
| 81 | |
| 82 DISALLOW_COPY_AND_ASSIGN(DefaultImagesView); | |
| 83 }; | |
| 84 | |
| 85 } // namespace chromeos | |
| 86 | |
| 87 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_DEFAULT_IMAGES_VIEW_H_ | |
| OLD | NEW |