| 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/session/session_state_delegate.h" | 5 #include "ash/session/session_state_delegate.h" |
| 6 #include "ash/shell.h" | 6 #include "ash/shell.h" |
| 7 #include "ash/shell/example_factory.h" | 7 #include "ash/shell/example_factory.h" |
| 8 #include "ash/shell_window_ids.h" | 8 #include "ash/shell_window_ids.h" |
| 9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 10 #include "ui/aura/window.h" | 10 #include "ui/aura/window.h" |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 public: | 28 public: |
| 29 LockView() : unlock_button_(new views::LabelButton( | 29 LockView() : unlock_button_(new views::LabelButton( |
| 30 this, base::ASCIIToUTF16("Unlock"))) { | 30 this, base::ASCIIToUTF16("Unlock"))) { |
| 31 unlock_button_->SetStyle(views::Button::STYLE_BUTTON); | 31 unlock_button_->SetStyle(views::Button::STYLE_BUTTON); |
| 32 AddChildView(unlock_button_); | 32 AddChildView(unlock_button_); |
| 33 unlock_button_->SetFocusable(true); | 33 unlock_button_->SetFocusable(true); |
| 34 } | 34 } |
| 35 virtual ~LockView() {} | 35 virtual ~LockView() {} |
| 36 | 36 |
| 37 // Overridden from views::View: | 37 // Overridden from views::View: |
| 38 virtual gfx::Size GetPreferredSize() const OVERRIDE { | 38 virtual gfx::Size GetPreferredSize() const override { |
| 39 return gfx::Size(500, 400); | 39 return gfx::Size(500, 400); |
| 40 } | 40 } |
| 41 | 41 |
| 42 private: | 42 private: |
| 43 // Overridden from views::View: | 43 // Overridden from views::View: |
| 44 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE { | 44 virtual void OnPaint(gfx::Canvas* canvas) override { |
| 45 canvas->FillRect(GetLocalBounds(), SK_ColorYELLOW); | 45 canvas->FillRect(GetLocalBounds(), SK_ColorYELLOW); |
| 46 base::string16 text = base::ASCIIToUTF16("LOCKED!"); | 46 base::string16 text = base::ASCIIToUTF16("LOCKED!"); |
| 47 int string_width = gfx::GetStringWidth(text, font_list_); | 47 int string_width = gfx::GetStringWidth(text, font_list_); |
| 48 canvas->DrawStringRect(text, font_list_, SK_ColorRED, | 48 canvas->DrawStringRect(text, font_list_, SK_ColorRED, |
| 49 gfx::Rect((width() - string_width)/ 2, | 49 gfx::Rect((width() - string_width)/ 2, |
| 50 (height() - font_list_.GetHeight()) / 2, | 50 (height() - font_list_.GetHeight()) / 2, |
| 51 string_width, font_list_.GetHeight())); | 51 string_width, font_list_.GetHeight())); |
| 52 } | 52 } |
| 53 virtual void Layout() OVERRIDE { | 53 virtual void Layout() override { |
| 54 gfx::Rect bounds = GetLocalBounds(); | 54 gfx::Rect bounds = GetLocalBounds(); |
| 55 gfx::Size ps = unlock_button_->GetPreferredSize(); | 55 gfx::Size ps = unlock_button_->GetPreferredSize(); |
| 56 bounds.set_y(bounds.bottom() - ps.height() - 5); | 56 bounds.set_y(bounds.bottom() - ps.height() - 5); |
| 57 bounds.set_x((bounds.width() - ps.width()) / 2); | 57 bounds.set_x((bounds.width() - ps.width()) / 2); |
| 58 bounds.set_size(ps); | 58 bounds.set_size(ps); |
| 59 unlock_button_->SetBoundsRect(bounds); | 59 unlock_button_->SetBoundsRect(bounds); |
| 60 } | 60 } |
| 61 virtual void ViewHierarchyChanged( | 61 virtual void ViewHierarchyChanged( |
| 62 const ViewHierarchyChangedDetails& details) OVERRIDE { | 62 const ViewHierarchyChangedDetails& details) override { |
| 63 if (details.is_add && details.child == this) | 63 if (details.is_add && details.child == this) |
| 64 unlock_button_->RequestFocus(); | 64 unlock_button_->RequestFocus(); |
| 65 } | 65 } |
| 66 | 66 |
| 67 // Overridden from views::WidgetDelegateView: | 67 // Overridden from views::WidgetDelegateView: |
| 68 virtual void WindowClosing() OVERRIDE { | 68 virtual void WindowClosing() override { |
| 69 Shell::GetInstance()->session_state_delegate()->UnlockScreen(); | 69 Shell::GetInstance()->session_state_delegate()->UnlockScreen(); |
| 70 } | 70 } |
| 71 | 71 |
| 72 // Overridden from views::ButtonListener: | 72 // Overridden from views::ButtonListener: |
| 73 virtual void ButtonPressed(views::Button* sender, | 73 virtual void ButtonPressed(views::Button* sender, |
| 74 const ui::Event& event) OVERRIDE { | 74 const ui::Event& event) override { |
| 75 DCHECK(sender == unlock_button_); | 75 DCHECK(sender == unlock_button_); |
| 76 GetWidget()->Close(); | 76 GetWidget()->Close(); |
| 77 } | 77 } |
| 78 | 78 |
| 79 gfx::FontList font_list_; | 79 gfx::FontList font_list_; |
| 80 views::LabelButton* unlock_button_; | 80 views::LabelButton* unlock_button_; |
| 81 | 81 |
| 82 DISALLOW_COPY_AND_ASSIGN(LockView); | 82 DISALLOW_COPY_AND_ASSIGN(LockView); |
| 83 }; | 83 }; |
| 84 | 84 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 102 widget->GetNativeView()->SetName("LockView"); | 102 widget->GetNativeView()->SetName("LockView"); |
| 103 widget->GetNativeView()->Focus(); | 103 widget->GetNativeView()->Focus(); |
| 104 | 104 |
| 105 // TODO: it shouldn't be necessary to invoke UpdateTooltip() here. | 105 // TODO: it shouldn't be necessary to invoke UpdateTooltip() here. |
| 106 Shell::GetInstance()->tooltip_controller()->UpdateTooltip( | 106 Shell::GetInstance()->tooltip_controller()->UpdateTooltip( |
| 107 widget->GetNativeView()); | 107 widget->GetNativeView()); |
| 108 } | 108 } |
| 109 | 109 |
| 110 } // namespace shell | 110 } // namespace shell |
| 111 } // namespace ash | 111 } // namespace ash |
| OLD | NEW |