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

Unified Diff: ui/aura_shell/examples/lock_view.cc

Issue 8120014: Add a lock screen example. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/aura_shell/examples/example_factory.h ('k') | ui/aura_shell/examples/window_type_launcher.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/aura_shell/examples/lock_view.cc
===================================================================
--- ui/aura_shell/examples/lock_view.cc (revision 0)
+++ ui/aura_shell/examples/lock_view.cc (revision 0)
@@ -0,0 +1,70 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ui/aura/desktop.h"
+#include "ui/aura/window.h"
+#include "ui/aura_shell/examples/example_factory.h"
+#include "ui/aura_shell/shell_window_ids.h"
+#include "ui/gfx/canvas.h"
+#include "ui/gfx/font.h"
+#include "views/widget/widget.h"
+#include "views/widget/widget_delegate.h"
+
+namespace aura_shell {
+namespace examples {
+
+class LockView : public views::WidgetDelegateView {
+ public:
+ LockView() {
+ }
+ virtual ~LockView() {}
+
+ // Overridden from View:
+ virtual gfx::Size GetPreferredSize() OVERRIDE {
+ return gfx::Size(500, 400);
+ }
+
+ private:
+ // Overridden from View:
+ virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE {
+ canvas->FillRectInt(SK_ColorYELLOW, 0, 0, width(), height());
+ string16 text = L"LOCKED!";
+ int string_width = font_.GetStringWidth(text);
+ canvas->DrawStringInt(text, font_, SK_ColorRED, (width() - string_width)/ 2,
+ (height() - font_.GetHeight()) / 2,
+ string_width, font_.GetHeight());
+ }
+ virtual bool OnMousePressed(const views::MouseEvent& event) OVERRIDE {
+ return true;
+ }
+ virtual void OnMouseReleased(const views::MouseEvent& event) OVERRIDE {
+ GetWidget()->Close();
+ }
+
+ gfx::Font font_;
+
+ DISALLOW_COPY_AND_ASSIGN(LockView);
+};
+
+void CreateLock() {
+ LockView* lock_view = new LockView;
+ views::Widget* widget = new views::Widget;
+ views::Widget::InitParams params(views::Widget::InitParams::TYPE_CONTROL);
+ gfx::Size ps = lock_view->GetPreferredSize();
+
+ gfx::Rect desktop_bounds = aura::Desktop::GetInstance()->window()->bounds();
+ params.bounds = gfx::Rect((desktop_bounds.width() - ps.width()) / 2,
+ (desktop_bounds.height() - ps.height()) / 2,
+ ps.width(), ps.height());
+ params.delegate = lock_view;
+ params.parent = aura::Desktop::GetInstance()->window()->GetChildById(
+ aura_shell::internal::kShellWindowId_LockScreenContainer);
+ widget->Init(params);
+ widget->SetContentsView(lock_view);
+ widget->Show();
+ widget->GetNativeView()->set_name("LockView");
+}
+
+} // namespace examples
+} // namespace aura_shell
Property changes on: ui\aura_shell\examples\lock_view.cc
___________________________________________________________________
Added: svn:eol-style
+ LF
« no previous file with comments | « ui/aura_shell/examples/example_factory.h ('k') | ui/aura_shell/examples/window_type_launcher.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698