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

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: Select the default picture. Added two more avatars. 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 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 InitLayout(); 101 InitLayout();
102 } 102 }
103 103
104 int DefaultImagesView::GetDefaultImageIndex() const { 104 int DefaultImagesView::GetDefaultImageIndex() const {
105 if (selected_image_index_ == -1) 105 if (selected_image_index_ == -1)
106 return -1; 106 return -1;
107 else 107 else
108 return selected_image_index_ - 1; 108 return selected_image_index_ - 1;
109 } 109 }
110 110
111 void DefaultImagesView::SetDefaultImageIndex(int image_index) {
112 selected_image_index_ = image_index + 1;
Nikita (slow) 2011/05/16 16:45:16 nit: Please comment that we're skipping camera ima
whywhat 2011/05/17 12:25:43 Done. I introduced a named constant and put a comm
113 if (delegate_)
114 delegate_->OnImageSelected(image_index % kDefaultImagesCount);
115 }
116
111 void DefaultImagesView::ClearSelection() { 117 void DefaultImagesView::ClearSelection() {
112 selected_image_index_ = -1; 118 selected_image_index_ = -1;
113 } 119 }
114 120
115 gfx::Size DefaultImagesView::GetPreferredSize() { 121 gfx::Size DefaultImagesView::GetPreferredSize() {
116 int image_size_with_margin = (kDefaultImageSize + 2 * kImageBorderSize); 122 int image_size_with_margin = (kDefaultImageSize + 2 * kImageBorderSize);
117 int width = kColumnsCount * image_size_with_margin + 123 int width = kColumnsCount * image_size_with_margin +
118 (kColumnsCount - 1) * kHorizontalPadding; 124 (kColumnsCount - 1) * kHorizontalPadding;
119 size_t image_count = default_images_.size(); 125 size_t image_count = default_images_.size();
120 int rows_count = (image_count + kColumnsCount - 1) / kColumnsCount; 126 int rows_count = (image_count + kColumnsCount - 1) / kColumnsCount;
(...skipping 13 matching lines...) Expand all
134 if (sender->GetID() == kCaptureButtonId) { 140 if (sender->GetID() == kCaptureButtonId) {
135 if (delegate_) 141 if (delegate_)
136 delegate_->OnCaptureButtonClicked(); 142 delegate_->OnCaptureButtonClicked();
137 } else { 143 } else {
138 int image_index = sender->GetID() - kImageStartId; 144 int image_index = sender->GetID() - kImageStartId;
139 int images_count = static_cast<int>(default_images_.size()); 145 int images_count = static_cast<int>(default_images_.size());
140 if (image_index < 0 || image_index >= images_count) { 146 if (image_index < 0 || image_index >= images_count) {
141 NOTREACHED() << "Got ButtonPressed event from a view with wrong id."; 147 NOTREACHED() << "Got ButtonPressed event from a view with wrong id.";
142 return; 148 return;
143 } 149 }
144 selected_image_index_ = image_index + 1; 150 SetDefaultImageIndex(image_index);
145 if (delegate_)
146 delegate_->OnImageSelected(image_index % kDefaultImagesCount);
147 } 151 }
148 } 152 }
149 153
150 void DefaultImagesView::InitButton(int resource_id, 154 void DefaultImagesView::InitButton(int resource_id,
151 UserImageButton* button) const { 155 UserImageButton* button) const {
152 const SkBitmap* original_image = 156 const SkBitmap* original_image =
153 ResourceBundle::GetSharedInstance().GetBitmapNamed(resource_id); 157 ResourceBundle::GetSharedInstance().GetBitmapNamed(resource_id);
154 SkBitmap resized_image = skia::ImageOperations::Resize( 158 SkBitmap resized_image = skia::ImageOperations::Resize(
155 *original_image, 159 *original_image,
156 skia::ImageOperations::RESIZE_BEST, 160 skia::ImageOperations::RESIZE_BEST,
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 for (int column = 0; column < kColumnsCount; ++column) { 207 for (int column = 0; column < kColumnsCount; ++column) {
204 if (current_image >= image_count) 208 if (current_image >= image_count)
205 break; 209 break;
206 layout->AddView(default_images_[current_image]); 210 layout->AddView(default_images_[current_image]);
207 ++current_image; 211 ++current_image;
208 } 212 }
209 } 213 }
210 } 214 }
211 215
212 } // namespace chromeos 216 } // 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