 Chromium Code Reviews
 Chromium Code Reviews Issue 2887002:
  Fixed positions of label and border windows to avoid flickering on initial sh...  (Closed) 
  Base URL: svn://chrome-svn/chrome/trunk/src/
    
  
    Issue 2887002:
  Fixed positions of label and border windows to avoid flickering on initial sh...  (Closed) 
  Base URL: svn://chrome-svn/chrome/trunk/src/| OLD | NEW | 
|---|---|
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/user_controller.h" | 5 #include "chrome/browser/chromeos/login/user_controller.h" | 
| 6 | 6 | 
| 7 #include <algorithm> | 7 #include <algorithm> | 
| 8 #include <vector> | 8 #include <vector> | 
| 9 | 9 | 
| 10 #include "app/l10n_util.h" | 10 #include "app/l10n_util.h" | 
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 216 image_window_ = CreateImageWindow(index); | 216 image_window_ = CreateImageWindow(index); | 
| 217 CreateBorderWindow(index, total_user_count, controls_height); | 217 CreateBorderWindow(index, total_user_count, controls_height); | 
| 218 label_window_ = CreateLabelWindow(index, WM_IPC_WINDOW_LOGIN_LABEL); | 218 label_window_ = CreateLabelWindow(index, WM_IPC_WINDOW_LOGIN_LABEL); | 
| 219 unselected_label_window_ = | 219 unselected_label_window_ = | 
| 220 CreateLabelWindow(index, WM_IPC_WINDOW_LOGIN_UNSELECTED_LABEL); | 220 CreateLabelWindow(index, WM_IPC_WINDOW_LOGIN_UNSELECTED_LABEL); | 
| 221 } | 221 } | 
| 222 | 222 | 
| 223 void UserController::SetPasswordEnabled(bool enable) { | 223 void UserController::SetPasswordEnabled(bool enable) { | 
| 224 DCHECK(!is_guest_); | 224 DCHECK(!is_guest_); | 
| 225 password_field_->SetEnabled(enable); | 225 password_field_->SetEnabled(enable); | 
| 226 submit_button_->SetEnabled(enable); | 226 // submit_button_->SetEnabled(enable); | 
| 
Dmitry Polukhin
2010/06/30 08:57:05
Why is it here?
 
whywhat
2010/06/30 09:00:14
Forgot to uncomment. Done.
 | |
| 227 enable ? user_view_->StopThrobber() : user_view_->StartThrobber(); | 227 enable ? user_view_->StopThrobber() : user_view_->StartThrobber(); | 
| 228 } | 228 } | 
| 229 | 229 | 
| 230 void UserController::ClearAndEnablePassword() { | 230 void UserController::ClearAndEnablePassword() { | 
| 231 if (is_guest_) { | 231 if (is_guest_) { | 
| 232 new_user_view_->ClearAndEnablePassword(); | 232 new_user_view_->ClearAndEnablePassword(); | 
| 233 } else { | 233 } else { | 
| 234 password_field_->SetText(string16()); | 234 password_field_->SetText(string16()); | 
| 235 SetPasswordEnabled(true); | 235 SetPasswordEnabled(true); | 
| 236 FocusPasswordField(); | 236 FocusPasswordField(); | 
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 337 layout->StartRow(0, 0); | 337 layout->StartRow(0, 0); | 
| 338 layout->AddView(password_field_); | 338 layout->AddView(password_field_); | 
| 339 layout->AddView(submit_button_); | 339 layout->AddView(submit_button_); | 
| 340 } | 340 } | 
| 341 | 341 | 
| 342 WidgetGtk* window = new WidgetGtk(WidgetGtk::TYPE_WINDOW); | 342 WidgetGtk* window = new WidgetGtk(WidgetGtk::TYPE_WINDOW); | 
| 343 window->MakeTransparent(); | 343 window->MakeTransparent(); | 
| 344 window->Init(NULL, gfx::Rect()); | 344 window->Init(NULL, gfx::Rect()); | 
| 345 window->SetContentsView(control_view); | 345 window->SetContentsView(control_view); | 
| 346 window->SetWidgetDelegate(this); | 346 window->SetWidgetDelegate(this); | 
| 347 *height = is_guest_ ? kUserImageSize + kControlsHeight | |
| 348 : control_view->GetPreferredSize().height(); | |
| 349 std::vector<int> params; | 347 std::vector<int> params; | 
| 350 params.push_back(index); | 348 params.push_back(index); | 
| 351 WmIpc::instance()->SetWindowType( | 349 WmIpc::instance()->SetWindowType( | 
| 352 window->GetNativeView(), | 350 window->GetNativeView(), | 
| 353 WM_IPC_WINDOW_LOGIN_CONTROLS, | 351 WM_IPC_WINDOW_LOGIN_CONTROLS, | 
| 354 ¶ms); | 352 ¶ms); | 
| 353 *height = is_guest_ ? kUserImageSize + kControlsHeight | |
| 354 : control_view->GetPreferredSize().height(); | |
| 355 window->SetBounds(gfx::Rect(0, 0, kUserImageSize, *height)); | 355 window->SetBounds(gfx::Rect(0, 0, kUserImageSize, *height)); | 
| 356 window->Show(); | 356 window->Show(); | 
| 357 return window; | 357 return window; | 
| 358 } | 358 } | 
| 359 | 359 | 
| 360 WidgetGtk* UserController::CreateImageWindow(int index) { | 360 WidgetGtk* UserController::CreateImageWindow(int index) { | 
| 361 user_view_ = new UserView(this, true); | 361 user_view_ = new UserView(this, true); | 
| 362 | 362 | 
| 363 if (!is_guest_) { | 363 if (!is_guest_) { | 
| 364 user_view_->SetImage(user_.image()); | 364 user_view_->SetImage(user_.image()); | 
| (...skipping 12 matching lines...) Expand all Loading... | |
| 377 window->GetNativeView(), | 377 window->GetNativeView(), | 
| 378 WM_IPC_WINDOW_LOGIN_IMAGE, | 378 WM_IPC_WINDOW_LOGIN_IMAGE, | 
| 379 ¶ms); | 379 ¶ms); | 
| 380 window->Show(); | 380 window->Show(); | 
| 381 return window; | 381 return window; | 
| 382 } | 382 } | 
| 383 | 383 | 
| 384 void UserController::CreateBorderWindow(int index, | 384 void UserController::CreateBorderWindow(int index, | 
| 385 int total_user_count, | 385 int total_user_count, | 
| 386 int controls_height) { | 386 int controls_height) { | 
| 387 // Guest login controls window is much higher than exsisting user's controls | |
| 388 // window so window manager will place the control instead of image window. | |
| 389 int width = kUserImageSize + kBorderSize * 2; | |
| 390 int height = kBorderSize * 2 + controls_height; | |
| 391 if (!is_guest_) | |
| 392 height += kBorderSize + kUserImageSize; | |
| 387 border_window_ = new WidgetGtk(WidgetGtk::TYPE_WINDOW); | 393 border_window_ = new WidgetGtk(WidgetGtk::TYPE_WINDOW); | 
| 388 border_window_->Init(NULL, gfx::Rect()); | 394 border_window_->Init(NULL, gfx::Rect(0, 0, width, height)); | 
| 389 border_window_->GetRootView()->set_background( | 395 border_window_->GetRootView()->set_background( | 
| 390 views::Background::CreateSolidBackground(kBackgroundColor)); | 396 views::Background::CreateSolidBackground(kBackgroundColor)); | 
| 391 UpdateUserCount(index, total_user_count); | 397 UpdateUserCount(index, total_user_count); | 
| 392 | 398 | 
| 393 // Guest login controls window is much higher than exsisting user's controls | |
| 394 // window so window manager will place the control instead of image window. | |
| 395 int height = kBorderSize * 2 + controls_height; | |
| 396 height += is_guest_ ? 0 : kBorderSize + kUserImageSize; | |
| 397 border_window_->SetBounds(gfx::Rect(0, 0, kUserImageSize + kBorderSize * 2, | |
| 398 height)); | |
| 399 border_window_->Show(); | 399 border_window_->Show(); | 
| 400 } | 400 } | 
| 401 | 401 | 
| 402 void UserController::UpdateUserCount(int index, int total_user_count) { | 402 void UserController::UpdateUserCount(int index, int total_user_count) { | 
| 403 user_index_ = index; | 403 user_index_ = index; | 
| 404 std::vector<int> params; | 404 std::vector<int> params; | 
| 405 params.push_back(index); | 405 params.push_back(index); | 
| 406 params.push_back(total_user_count); | 406 params.push_back(total_user_count); | 
| 407 params.push_back(kUnselectedSize); | 407 params.push_back(kUnselectedSize); | 
| 408 params.push_back(kPadding); | 408 params.push_back(kPadding); | 
| 409 WmIpc::instance()->SetWindowType( | 409 WmIpc::instance()->SetWindowType( | 
| 410 border_window_->GetNativeView(), | 410 border_window_->GetNativeView(), | 
| 411 WM_IPC_WINDOW_LOGIN_BORDER, | 411 WM_IPC_WINDOW_LOGIN_BORDER, | 
| 412 ¶ms); | 412 ¶ms); | 
| 413 } | 413 } | 
| 414 | 414 | 
| 415 WidgetGtk* UserController::CreateLabelWindow(int index, | 415 WidgetGtk* UserController::CreateLabelWindow(int index, | 
| 416 WmIpcWindowType type) { | 416 WmIpcWindowType type) { | 
| 417 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | 417 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | 
| 418 const gfx::Font& font = (type == WM_IPC_WINDOW_LOGIN_LABEL) ? | 418 const gfx::Font& font = (type == WM_IPC_WINDOW_LOGIN_LABEL) ? | 
| 419 rb.GetFont(ResourceBundle::LargeFont).DeriveFont(0, gfx::Font::BOLD) : | 419 rb.GetFont(ResourceBundle::LargeFont).DeriveFont(0, gfx::Font::BOLD) : | 
| 420 rb.GetFont(ResourceBundle::BaseFont).DeriveFont(0, gfx::Font::BOLD); | 420 rb.GetFont(ResourceBundle::BaseFont).DeriveFont(0, gfx::Font::BOLD); | 
| 421 int width = (type == WM_IPC_WINDOW_LOGIN_LABEL) ? | |
| 422 kUserImageSize : kUnselectedSize; | |
| 423 WidgetGtk* window = new ClickNotifyingWidget(WidgetGtk::TYPE_WINDOW, this); | |
| 424 window->MakeTransparent(); | |
| 425 window->Init(NULL, gfx::Rect()); | |
| 426 std::wstring text = is_guest_ ? l10n_util::GetString(IDS_GUEST) : | 421 std::wstring text = is_guest_ ? l10n_util::GetString(IDS_GUEST) : | 
| 427 UTF8ToWide(user_.GetDisplayName()); | 422 UTF8ToWide(user_.GetDisplayName()); | 
| 428 views::Label* label = new views::Label(text); | 423 views::Label* label = new views::Label(text); | 
| 429 label->SetColor(kTextColor); | 424 label->SetColor(kTextColor); | 
| 430 label->SetFont(font); | 425 label->SetFont(font); | 
| 431 if (type == WM_IPC_WINDOW_LOGIN_LABEL) | 426 if (type == WM_IPC_WINDOW_LOGIN_LABEL) | 
| 432 label_view_ = label; | 427 label_view_ = label; | 
| 433 else | 428 else | 
| 434 unselected_label_view_ = label; | 429 unselected_label_view_ = label; | 
| 435 | 430 | 
| 431 int width = (type == WM_IPC_WINDOW_LOGIN_LABEL) ? | |
| 432 kUserImageSize : kUnselectedSize; | |
| 433 int height = label->GetPreferredSize().height(); | |
| 434 WidgetGtk* window = new ClickNotifyingWidget(WidgetGtk::TYPE_WINDOW, this); | |
| 435 window->MakeTransparent(); | |
| 436 window->Init(NULL, gfx::Rect(0, 0, width, height)); | |
| 436 window->SetContentsView(label); | 437 window->SetContentsView(label); | 
| 437 | 438 | 
| 438 int height = label->GetPreferredSize().height(); | |
| 439 std::vector<int> params; | 439 std::vector<int> params; | 
| 440 params.push_back(index); | 440 params.push_back(index); | 
| 441 WmIpc::instance()->SetWindowType(window->GetNativeView(), type, ¶ms); | 441 WmIpc::instance()->SetWindowType(window->GetNativeView(), type, ¶ms); | 
| 442 window->SetBounds(gfx::Rect(0, 0, width, height)); | |
| 443 window->Show(); | 442 window->Show(); | 
| 444 return window; | 443 return window; | 
| 445 } | 444 } | 
| 446 | 445 | 
| 447 gfx::Rect UserController::GetScreenBounds() const { | 446 gfx::Rect UserController::GetScreenBounds() const { | 
| 448 if (is_guest_) { | 447 if (is_guest_) { | 
| 449 return new_user_view_->GetPasswordBounds(); | 448 return new_user_view_->GetPasswordBounds(); | 
| 450 } else { | 449 } else { | 
| 451 gfx::Rect screen_bounds(password_field_->bounds()); | 450 gfx::Rect screen_bounds(password_field_->bounds()); | 
| 452 gfx::Point origin(screen_bounds.origin()); | 451 gfx::Point origin(screen_bounds.origin()); | 
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 484 | 483 | 
| 485 void UserController::SelectUser(int index) { | 484 void UserController::SelectUser(int index) { | 
| 486 delegate_->SelectUser(index); | 485 delegate_->SelectUser(index); | 
| 487 } | 486 } | 
| 488 | 487 | 
| 489 void UserController::FocusPasswordField() { | 488 void UserController::FocusPasswordField() { | 
| 490 password_field_->RequestFocus(); | 489 password_field_->RequestFocus(); | 
| 491 } | 490 } | 
| 492 | 491 | 
| 493 } // namespace chromeos | 492 } // namespace chromeos | 
| OLD | NEW |