| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "ui/aura_shell/desktop_background_view.h" | 5 #include "ui/aura_shell/desktop_background_view.h" |
| 6 | 6 |
| 7 #include "base/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
| 8 #include "grit/ui_resources.h" | 8 #include "grit/ui_resources.h" |
| 9 #include "ui/aura/root_window.h" | 9 #include "ui/aura/root_window.h" |
| 10 #include "ui/aura_shell/aura_shell_export.h" | 10 #include "ui/aura_shell/aura_shell_export.h" |
| 11 #include "ui/aura_shell/shell.h" | 11 #include "ui/aura_shell/shell.h" |
| 12 #include "ui/aura_shell/shell_window_ids.h" | 12 #include "ui/aura_shell/shell_window_ids.h" |
| 13 #include "ui/base/resource/resource_bundle.h" | 13 #include "ui/base/resource/resource_bundle.h" |
| 14 #include "ui/gfx/canvas.h" | 14 #include "ui/gfx/canvas.h" |
| 15 #include "ui/views/widget/widget.h" | 15 #include "ui/views/widget/widget.h" |
| 16 | 16 |
| 17 namespace aura_shell { | 17 namespace aura_shell { |
| 18 namespace internal { | 18 namespace internal { |
| 19 | 19 |
| 20 //////////////////////////////////////////////////////////////////////////////// | 20 //////////////////////////////////////////////////////////////////////////////// |
| 21 // DesktopBackgroundView, public: | 21 // DesktopBackgroundView, public: |
| 22 | 22 |
| 23 DesktopBackgroundView::DesktopBackgroundView() { | 23 DesktopBackgroundView::DesktopBackgroundView() { |
| 24 wallpaper_ = *ResourceBundle::GetSharedInstance().GetBitmapNamed( | 24 wallpaper_ = *ResourceBundle::GetSharedInstance().GetBitmapNamed( |
| 25 IDR_AURA_WALLPAPER); | 25 IDR_AURA_WALLPAPER); |
| 26 wallpaper_.buildMipMap(false); |
| 26 } | 27 } |
| 27 | 28 |
| 28 DesktopBackgroundView::~DesktopBackgroundView() { | 29 DesktopBackgroundView::~DesktopBackgroundView() { |
| 29 } | 30 } |
| 30 | 31 |
| 31 //////////////////////////////////////////////////////////////////////////////// | 32 //////////////////////////////////////////////////////////////////////////////// |
| 32 // DesktopBackgroundView, views::View overrides: | 33 // DesktopBackgroundView, views::View overrides: |
| 33 | 34 |
| 34 void DesktopBackgroundView::OnPaint(gfx::Canvas* canvas) { | 35 void DesktopBackgroundView::OnPaint(gfx::Canvas* canvas) { |
| 35 canvas->TileImageInt(wallpaper_, 0, 0, width(), height()); | 36 canvas->DrawBitmapInt(wallpaper_, |
| 37 0, 0, wallpaper_.width(), wallpaper_.height(), |
| 38 0, 0, width(), height(), |
| 39 true); |
| 36 } | 40 } |
| 37 | 41 |
| 38 bool DesktopBackgroundView::OnMousePressed(const views::MouseEvent& event) { | 42 bool DesktopBackgroundView::OnMousePressed(const views::MouseEvent& event) { |
| 39 return true; | 43 return true; |
| 40 } | 44 } |
| 41 | 45 |
| 42 void DesktopBackgroundView::OnMouseReleased(const views::MouseEvent& event) { | 46 void DesktopBackgroundView::OnMouseReleased(const views::MouseEvent& event) { |
| 43 Shell::GetInstance()->ToggleOverview(); | 47 Shell::GetInstance()->ToggleOverview(); |
| 44 } | 48 } |
| 45 | 49 |
| 46 views::Widget* CreateDesktopBackground() { | 50 views::Widget* CreateDesktopBackground() { |
| 47 views::Widget* desktop_widget = new views::Widget; | 51 views::Widget* desktop_widget = new views::Widget; |
| 48 views::Widget::InitParams params( | 52 views::Widget::InitParams params( |
| 49 views::Widget::InitParams::TYPE_WINDOW_FRAMELESS); | 53 views::Widget::InitParams::TYPE_WINDOW_FRAMELESS); |
| 50 DesktopBackgroundView* view = new DesktopBackgroundView; | 54 DesktopBackgroundView* view = new DesktopBackgroundView; |
| 51 params.delegate = view; | 55 params.delegate = view; |
| 52 desktop_widget->Init(params); | 56 desktop_widget->Init(params); |
| 53 Shell::GetInstance()->GetContainer( | 57 Shell::GetInstance()->GetContainer( |
| 54 aura_shell::internal::kShellWindowId_DesktopBackgroundContainer)-> | 58 aura_shell::internal::kShellWindowId_DesktopBackgroundContainer)-> |
| 55 AddChild(desktop_widget->GetNativeView()); | 59 AddChild(desktop_widget->GetNativeView()); |
| 56 desktop_widget->SetContentsView(view); | 60 desktop_widget->SetContentsView(view); |
| 57 desktop_widget->Show(); | 61 desktop_widget->Show(); |
| 58 desktop_widget->GetNativeView()->SetName("DesktopBackgroundView"); | 62 desktop_widget->GetNativeView()->SetName("DesktopBackgroundView"); |
| 59 return desktop_widget; | 63 return desktop_widget; |
| 60 } | 64 } |
| 61 | 65 |
| 62 } // namespace internal | 66 } // namespace internal |
| 63 } // namespace aura_shell | 67 } // namespace aura_shell |
| OLD | NEW |