| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "ash/system/user/tray_user.h" | 5 #include "ash/system/user/tray_user.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <climits> | 8 #include <climits> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 265 for (std::vector<string16>::const_iterator it = lines.begin(); | 265 for (std::vector<string16>::const_iterator it = lines.begin(); |
| 266 it != lines.end(); ++it) { | 266 it != lines.end(); ++it) { |
| 267 gfx::RenderText* line = gfx::RenderText::CreateInstance(); | 267 gfx::RenderText* line = gfx::RenderText::CreateInstance(); |
| 268 line->SetDirectionalityMode(gfx::DIRECTIONALITY_FROM_UI); | 268 line->SetDirectionalityMode(gfx::DIRECTIONALITY_FROM_UI); |
| 269 line->SetText(*it); | 269 line->SetText(*it); |
| 270 const gfx::Size size(contents_area.width(), line->GetStringSize().height()); | 270 const gfx::Size size(contents_area.width(), line->GetStringSize().height()); |
| 271 line->SetDisplayRect(gfx::Rect(position, size)); | 271 line->SetDisplayRect(gfx::Rect(position, size)); |
| 272 position.set_y(position.y() + size.height()); | 272 position.set_y(position.y() + size.height()); |
| 273 | 273 |
| 274 // Set the default text color for the line. | 274 // Set the default text color for the line. |
| 275 gfx::StyleRange default_style(line->default_style()); | 275 line->SetColor(kPublicAccountUserCardTextColor); |
| 276 default_style.foreground = kPublicAccountUserCardTextColor; | |
| 277 line->set_default_style(default_style); | |
| 278 line->ApplyDefaultStyle(); | |
| 279 | 276 |
| 280 // If a range of the line contains the user's display name, apply a custom | 277 // If a range of the line contains the user's display name, apply a custom |
| 281 // text color to it. | 278 // text color to it. |
| 282 if (display_name.is_empty()) | 279 if (display_name.is_empty()) |
| 283 display_name.set_start(it->find(kDisplayNameMark)); | 280 display_name.set_start(it->find(kDisplayNameMark)); |
| 284 if (!display_name.is_empty()) { | 281 if (!display_name.is_empty()) { |
| 285 display_name.set_end( | 282 display_name.set_end( |
| 286 it->find(kDisplayNameMark, display_name.start() + 1)); | 283 it->find(kDisplayNameMark, display_name.start() + 1)); |
| 287 gfx::StyleRange display_name_style(line->default_style()); | |
| 288 display_name_style.foreground = kPublicAccountUserCardNameColor; | |
| 289 ui::Range line_range(0, it->size()); | 284 ui::Range line_range(0, it->size()); |
| 290 display_name_style.range = display_name.Intersect(line_range); | 285 line->ApplyColor(kPublicAccountUserCardNameColor, |
| 291 line->ApplyStyleRange(display_name_style); | 286 display_name.Intersect(line_range)); |
| 292 // Update the range for the next line. | 287 // Update the range for the next line. |
| 293 if (display_name.end() >= line_range.end()) | 288 if (display_name.end() >= line_range.end()) |
| 294 display_name.set_start(0); | 289 display_name.set_start(0); |
| 295 else | 290 else |
| 296 display_name = ui::Range::InvalidRange(); | 291 display_name = ui::Range::InvalidRange(); |
| 297 } | 292 } |
| 298 | 293 |
| 299 lines_.push_back(line); | 294 lines_.push_back(line); |
| 300 } | 295 } |
| 301 | 296 |
| (...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 640 // Check for null to avoid crbug.com/150944. | 635 // Check for null to avoid crbug.com/150944. |
| 641 if (avatar_) { | 636 if (avatar_) { |
| 642 avatar_->SetImage( | 637 avatar_->SetImage( |
| 643 ash::Shell::GetInstance()->system_tray_delegate()->GetUserImage(), | 638 ash::Shell::GetInstance()->system_tray_delegate()->GetUserImage(), |
| 644 gfx::Size(kUserIconSize, kUserIconSize)); | 639 gfx::Size(kUserIconSize, kUserIconSize)); |
| 645 } | 640 } |
| 646 } | 641 } |
| 647 | 642 |
| 648 } // namespace internal | 643 } // namespace internal |
| 649 } // namespace ash | 644 } // namespace ash |
| OLD | NEW |