| Index: ash/shell/lock_view.cc
|
| ===================================================================
|
| --- ash/shell/lock_view.cc (revision 128508)
|
| +++ ash/shell/lock_view.cc (working copy)
|
| @@ -3,6 +3,7 @@
|
| // found in the LICENSE file.
|
|
|
| #include "ash/shell.h"
|
| +#include "ash/shell_delegate.h"
|
| #include "ash/shell_window_ids.h"
|
| #include "ash/shell/example_factory.h"
|
| #include "ash/tooltips/tooltip_controller.h"
|
| @@ -11,6 +12,7 @@
|
| #include "ui/aura/window.h"
|
| #include "ui/gfx/canvas.h"
|
| #include "ui/gfx/font.h"
|
| +#include "ui/views/controls/button/text_button.h"
|
| #include "ui/views/widget/widget.h"
|
| #include "ui/views/widget/widget_delegate.h"
|
|
|
| @@ -19,18 +21,23 @@
|
| namespace ash {
|
| namespace shell {
|
|
|
| -class LockView : public views::WidgetDelegateView {
|
| +class LockView : public views::WidgetDelegateView,
|
| + public views::ButtonListener {
|
| public:
|
| - LockView() {}
|
| + LockView() : unlock_button_(ALLOW_THIS_IN_INITIALIZER_LIST(
|
| + new views::NativeTextButton(this, ASCIIToUTF16("Unlock")))) {
|
| + AddChildView(unlock_button_);
|
| + unlock_button_->set_focusable(true);
|
| + }
|
| virtual ~LockView() {}
|
|
|
| - // Overridden from View:
|
| + // Overridden from views::View:
|
| virtual gfx::Size GetPreferredSize() OVERRIDE {
|
| return gfx::Size(500, 400);
|
| }
|
|
|
| private:
|
| - // Overridden from View:
|
| + // Overridden from views::View:
|
| virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE {
|
| canvas->FillRect(GetLocalBounds(), SK_ColorYELLOW);
|
| string16 text = ASCIIToUTF16("LOCKED!");
|
| @@ -39,14 +46,35 @@
|
| (height() - font_.GetHeight()) / 2,
|
| string_width, font_.GetHeight());
|
| }
|
| - virtual bool OnMousePressed(const views::MouseEvent& event) OVERRIDE {
|
| - return true;
|
| + virtual void Layout() OVERRIDE {
|
| + gfx::Rect bounds = GetLocalBounds();
|
| + gfx::Size ps = unlock_button_->GetPreferredSize();
|
| + bounds.set_y(bounds.bottom() - ps.height() - 5);
|
| + bounds.set_x((bounds.width() - ps.width()) / 2);
|
| + bounds.set_size(ps);
|
| + unlock_button_->SetBoundsRect(bounds);
|
| }
|
| - virtual void OnMouseReleased(const views::MouseEvent& event) OVERRIDE {
|
| + virtual void ViewHierarchyChanged(bool is_add,
|
| + views::View* parent,
|
| + views::View* child) OVERRIDE {
|
| + if (is_add && child == this)
|
| + unlock_button_->RequestFocus();
|
| + }
|
| +
|
| + // Overridden from views::WidgetDelegateView:
|
| + virtual void WindowClosing() OVERRIDE {
|
| + Shell::GetInstance()->delegate()->UnlockScreen();
|
| + }
|
| +
|
| + // Overridden from views::ButtonListener:
|
| + virtual void ButtonPressed(views::Button* sender,
|
| + const views::Event& event) OVERRIDE {
|
| + DCHECK(sender == unlock_button_);
|
| GetWidget()->Close();
|
| }
|
|
|
| gfx::Font font_;
|
| + views::NativeTextButton* unlock_button_;
|
|
|
| DISALLOW_COPY_AND_ASSIGN(LockView);
|
| };
|
| @@ -54,7 +82,8 @@
|
| void CreateLockScreen() {
|
| LockView* lock_view = new LockView;
|
| views::Widget* widget = new views::Widget;
|
| - views::Widget::InitParams params(views::Widget::InitParams::TYPE_CONTROL);
|
| + views::Widget::InitParams params(
|
| + views::Widget::InitParams::TYPE_WINDOW_FRAMELESS);
|
| gfx::Size ps = lock_view->GetPreferredSize();
|
|
|
| gfx::Size root_window_size = Shell::GetRootWindow()->bounds().size();
|
| @@ -69,6 +98,7 @@
|
| widget->SetContentsView(lock_view);
|
| widget->Show();
|
| widget->GetNativeView()->SetName("LockView");
|
| + widget->GetNativeView()->Focus();
|
|
|
| Shell::GetInstance()->tooltip_controller()->UpdateTooltip(
|
| widget->GetNativeView());
|
|
|