Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(46)

Side by Side Diff: chrome/browser/chromeos/login/default_images_view.cc

Issue 7015041: [cros] Update default avatars and guest icon (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed comments Created 9 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/default_images_view.h" 5 #include "chrome/browser/chromeos/login/default_images_view.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/utf_string_conversions.h" 8 #include "base/utf_string_conversions.h"
9 #include "chrome/browser/chromeos/login/default_user_images.h" 9 #include "chrome/browser/chromeos/login/default_user_images.h"
10 #include "chrome/browser/chromeos/login/rounded_rect_painter.h" 10 #include "chrome/browser/chromeos/login/rounded_rect_painter.h"
(...skipping 28 matching lines...) Expand all
39 const int kImageBorderSize = 1; 39 const int kImageBorderSize = 1;
40 // Color of default image border. 40 // Color of default image border.
41 const SkColor kImageBorderColor = SkColorSetARGB(38, 0, 0, 0); 41 const SkColor kImageBorderColor = SkColorSetARGB(38, 0, 0, 0);
42 // Color of default image background. 42 // Color of default image background.
43 const SkColor kImageBackgroundColor = SK_ColorWHITE; 43 const SkColor kImageBackgroundColor = SK_ColorWHITE;
44 // We give each image control an ID so we could distinguish them. Since 0 is 44 // We give each image control an ID so we could distinguish them. Since 0 is
45 // the default ID we want an offset for IDs we set. 45 // the default ID we want an offset for IDs we set.
46 const int kImageStartId = 100; 46 const int kImageStartId = 100;
47 // ID for image control for video capture. 47 // ID for image control for video capture.
48 const int kCaptureButtonId = 1000; 48 const int kCaptureButtonId = 1000;
49 // A number of the first buttons that don't correspond to any default image
50 // (i.e. button to take a photo).
51 const int kNonDefaultImageButtonsCount = 1;
49 52
50 } // namespace 53 } // namespace
51 54
52 // Image button with border and background. Corrects view size by border 55 // Image button with border and background. Corrects view size by border
53 // insets as ImageButton ignores it. 56 // insets as ImageButton ignores it.
54 class UserImageButton : public views::ImageButton { 57 class UserImageButton : public views::ImageButton {
55 public: 58 public:
56 explicit UserImageButton(views::ButtonListener* listener); 59 explicit UserImageButton(views::ButtonListener* listener);
57 60
58 // Overridden from views::View: 61 // Overridden from views::View:
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 InitButton(kDefaultImageResources[i], image_button); 101 InitButton(kDefaultImageResources[i], image_button);
99 default_images_.push_back(image_button); 102 default_images_.push_back(image_button);
100 } 103 }
101 InitLayout(); 104 InitLayout();
102 } 105 }
103 106
104 int DefaultImagesView::GetDefaultImageIndex() const { 107 int DefaultImagesView::GetDefaultImageIndex() const {
105 if (selected_image_index_ == -1) 108 if (selected_image_index_ == -1)
106 return -1; 109 return -1;
107 else 110 else
108 return selected_image_index_ - 1; 111 return selected_image_index_ - kNonDefaultImageButtonsCount;
112 }
113
114 void DefaultImagesView::SetDefaultImageIndex(int image_index) {
115 selected_image_index_ = image_index + kNonDefaultImageButtonsCount;
116 if (delegate_)
117 delegate_->OnImageSelected(image_index % kDefaultImagesCount);
109 } 118 }
110 119
111 void DefaultImagesView::ClearSelection() { 120 void DefaultImagesView::ClearSelection() {
112 selected_image_index_ = -1; 121 selected_image_index_ = -1;
113 } 122 }
114 123
115 gfx::Size DefaultImagesView::GetPreferredSize() { 124 gfx::Size DefaultImagesView::GetPreferredSize() {
116 int image_size_with_margin = (kDefaultImageSize + 2 * kImageBorderSize); 125 int image_size_with_margin = (kDefaultImageSize + 2 * kImageBorderSize);
117 int width = kColumnsCount * image_size_with_margin + 126 int width = kColumnsCount * image_size_with_margin +
118 (kColumnsCount - 1) * kHorizontalPadding; 127 (kColumnsCount - 1) * kHorizontalPadding;
(...skipping 15 matching lines...) Expand all
134 if (sender->GetID() == kCaptureButtonId) { 143 if (sender->GetID() == kCaptureButtonId) {
135 if (delegate_) 144 if (delegate_)
136 delegate_->OnCaptureButtonClicked(); 145 delegate_->OnCaptureButtonClicked();
137 } else { 146 } else {
138 int image_index = sender->GetID() - kImageStartId; 147 int image_index = sender->GetID() - kImageStartId;
139 int images_count = static_cast<int>(default_images_.size()); 148 int images_count = static_cast<int>(default_images_.size());
140 if (image_index < 0 || image_index >= images_count) { 149 if (image_index < 0 || image_index >= images_count) {
141 NOTREACHED() << "Got ButtonPressed event from a view with wrong id."; 150 NOTREACHED() << "Got ButtonPressed event from a view with wrong id.";
142 return; 151 return;
143 } 152 }
144 selected_image_index_ = image_index + 1; 153 SetDefaultImageIndex(image_index);
145 if (delegate_)
146 delegate_->OnImageSelected(image_index % kDefaultImagesCount);
147 } 154 }
148 } 155 }
149 156
150 void DefaultImagesView::InitButton(int resource_id, 157 void DefaultImagesView::InitButton(int resource_id,
151 UserImageButton* button) const { 158 UserImageButton* button) const {
152 const SkBitmap* original_image = 159 const SkBitmap* original_image =
153 ResourceBundle::GetSharedInstance().GetBitmapNamed(resource_id); 160 ResourceBundle::GetSharedInstance().GetBitmapNamed(resource_id);
154 SkBitmap resized_image = skia::ImageOperations::Resize( 161 SkBitmap resized_image = skia::ImageOperations::Resize(
155 *original_image, 162 *original_image,
156 skia::ImageOperations::RESIZE_BEST, 163 skia::ImageOperations::RESIZE_BEST,
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 for (int column = 0; column < kColumnsCount; ++column) { 210 for (int column = 0; column < kColumnsCount; ++column) {
204 if (current_image >= image_count) 211 if (current_image >= image_count)
205 break; 212 break;
206 layout->AddView(default_images_[current_image]); 213 layout->AddView(default_images_[current_image]);
207 ++current_image; 214 ++current_image;
208 } 215 }
209 } 216 }
210 } 217 }
211 218
212 } // namespace chromeos 219 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/login/default_images_view.h ('k') | chrome/browser/chromeos/login/default_user_images.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698