OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "ash/desktop_background/desktop_background_widget_controller.h" |
| 6 |
| 7 #include "ui/aura/root_window.h" |
| 8 #include "ui/views/widget/widget.h" |
| 9 |
| 10 DECLARE_WINDOW_PROPERTY_TYPE(ash::internal::DesktopBackgroundWidgetController*); |
| 11 |
| 12 namespace ash { |
| 13 namespace internal { |
| 14 |
| 15 DEFINE_OWNED_WINDOW_PROPERTY_KEY(DesktopBackgroundWidgetController, |
| 16 kWindowDesktopComponent, NULL); |
| 17 |
| 18 DesktopBackgroundWidgetController::DesktopBackgroundWidgetController( |
| 19 views::Widget* widget) : widget_(widget) { |
| 20 } |
| 21 |
| 22 DesktopBackgroundWidgetController::DesktopBackgroundWidgetController( |
| 23 ui::Layer* layer) : widget_(NULL) { |
| 24 layer_.reset(layer); |
| 25 } |
| 26 |
| 27 DesktopBackgroundWidgetController::~DesktopBackgroundWidgetController() { |
| 28 if (widget_) { |
| 29 widget_->CloseNow(); |
| 30 widget_ = NULL; |
| 31 } else if (layer_.get()) |
| 32 layer_.reset(NULL); |
| 33 } |
| 34 |
| 35 void DesktopBackgroundWidgetController::SetBounds(gfx::Rect bounds) { |
| 36 if (widget_) |
| 37 widget_->SetBounds(bounds); |
| 38 else if (layer_.get()) |
| 39 layer_->SetBounds(bounds); |
| 40 } |
| 41 |
| 42 |
| 43 void DesktopBackgroundWidgetController::Reparent(aura::RootWindow* root_window, |
| 44 int src_container, |
| 45 int dest_container) { |
| 46 if (widget_) { |
| 47 views::Widget::ReparentNativeView(widget_->GetNativeView(), |
| 48 root_window->GetChildById(dest_container)); |
| 49 } else if (layer_.get()) { |
| 50 ui::Layer* layer = layer_.get(); |
| 51 root_window->GetChildById(src_container)->layer()->Remove(layer); |
| 52 root_window->GetChildById(dest_container)->layer()->Add(layer); |
| 53 } |
| 54 } |
| 55 |
| 56 } // namespace internal |
| 57 } // namespace ash |
OLD | NEW |