| 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/wm/common/panels/panel_layout_manager.h" | 5 #include "ash/wm/common/panels/panel_layout_manager.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <map> | 8 #include <map> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| 11 #include "ash/wm/common/shelf/wm_shelf.h" | 11 #include "ash/wm/common/shelf/wm_shelf.h" |
| 12 #include "ash/wm/common/shelf/wm_shelf_util.h" | 12 #include "ash/wm/common/shelf/wm_shelf_util.h" |
| 13 #include "ash/wm/common/window_animation_types.h" | 13 #include "ash/wm/common/window_animation_types.h" |
| 14 #include "ash/wm/common/window_parenting_utils.h" | 14 #include "ash/wm/common/window_parenting_utils.h" |
| 15 #include "ash/wm/common/window_state.h" | 15 #include "ash/wm/common/window_state.h" |
| 16 #include "ash/wm/common/wm_globals.h" | 16 #include "ash/wm/common/wm_globals.h" |
| 17 #include "ash/wm/common/wm_lookup.h" |
| 17 #include "ash/wm/common/wm_root_window_controller.h" | 18 #include "ash/wm/common/wm_root_window_controller.h" |
| 18 #include "ash/wm/common/wm_shell_window_ids.h" | 19 #include "ash/wm/common/wm_shell_window_ids.h" |
| 19 #include "ash/wm/common/wm_window.h" | 20 #include "ash/wm/common/wm_window.h" |
| 20 #include "ash/wm/common/wm_window_property.h" | 21 #include "ash/wm/common/wm_window_property.h" |
| 21 #include "base/auto_reset.h" | 22 #include "base/auto_reset.h" |
| 22 #include "third_party/skia/include/core/SkColor.h" | 23 #include "third_party/skia/include/core/SkColor.h" |
| 23 #include "third_party/skia/include/core/SkPaint.h" | 24 #include "third_party/skia/include/core/SkPaint.h" |
| 24 #include "third_party/skia/include/core/SkPath.h" | 25 #include "third_party/skia/include/core/SkPath.h" |
| 25 #include "ui/compositor/scoped_layer_animation_settings.h" | 26 #include "ui/compositor/scoped_layer_animation_settings.h" |
| 26 #include "ui/gfx/canvas.h" | 27 #include "ui/gfx/canvas.h" |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 202 params.keep_on_top = true; | 203 params.keep_on_top = true; |
| 203 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; | 204 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; |
| 204 params.bounds = parent->ConvertRectToScreen(gfx::Rect()); | 205 params.bounds = parent->ConvertRectToScreen(gfx::Rect()); |
| 205 params.bounds.set_width(kArrowWidth); | 206 params.bounds.set_width(kArrowWidth); |
| 206 params.bounds.set_height(kArrowHeight); | 207 params.bounds.set_height(kArrowHeight); |
| 207 params.accept_events = false; | 208 params.accept_events = false; |
| 208 parent->GetRootWindowController()->ConfigureWidgetInitParamsForContainer( | 209 parent->GetRootWindowController()->ConfigureWidgetInitParamsForContainer( |
| 209 this, parent->GetShellWindowId(), ¶ms); | 210 this, parent->GetShellWindowId(), ¶ms); |
| 210 set_focus_on_creation(false); | 211 set_focus_on_creation(false); |
| 211 Init(params); | 212 Init(params); |
| 212 wm::WmWindow* widget_window = wm::WmWindow::Get(this); | 213 wm::WmWindow* widget_window = wm::WmLookup::Get()->GetWindowForWidget(this); |
| 213 DCHECK_EQ(widget_window->GetRootWindow(), parent->GetRootWindow()); | 214 DCHECK_EQ(widget_window->GetRootWindow(), parent->GetRootWindow()); |
| 214 views::View* content_view = new views::View; | 215 views::View* content_view = new views::View; |
| 215 background_ = new CalloutWidgetBackground; | 216 background_ = new CalloutWidgetBackground; |
| 216 content_view->set_background(background_); | 217 content_view->set_background(background_); |
| 217 SetContentsView(content_view); | 218 SetContentsView(content_view); |
| 218 widget_window->GetLayer()->SetOpacity(0); | 219 widget_window->GetLayer()->SetOpacity(0); |
| 219 } | 220 } |
| 220 | 221 |
| 221 // Weak pointer owned by this widget's content view. | 222 // Weak pointer owned by this widget's content view. |
| 222 CalloutWidgetBackground* background_; | 223 CalloutWidgetBackground* background_; |
| (...skipping 558 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 781 panel_container_->StackChildAtTop(dragged_panel_); | 782 panel_container_->StackChildAtTop(dragged_panel_); |
| 782 last_active_panel_ = active_panel; | 783 last_active_panel_ = active_panel; |
| 783 } | 784 } |
| 784 | 785 |
| 785 void PanelLayoutManager::UpdateCallouts() { | 786 void PanelLayoutManager::UpdateCallouts() { |
| 786 const bool horizontal = wm::IsHorizontalAlignment(shelf_->GetAlignment()); | 787 const bool horizontal = wm::IsHorizontalAlignment(shelf_->GetAlignment()); |
| 787 for (PanelList::iterator iter = panel_windows_.begin(); | 788 for (PanelList::iterator iter = panel_windows_.begin(); |
| 788 iter != panel_windows_.end(); ++iter) { | 789 iter != panel_windows_.end(); ++iter) { |
| 789 wm::WmWindow* panel = iter->window; | 790 wm::WmWindow* panel = iter->window; |
| 790 views::Widget* callout_widget = iter->callout_widget; | 791 views::Widget* callout_widget = iter->callout_widget; |
| 791 wm::WmWindow* callout_widget_window = wm::WmWindow::Get(callout_widget); | 792 wm::WmWindow* callout_widget_window = |
| 793 wm::WmLookup::Get()->GetWindowForWidget(callout_widget); |
| 792 | 794 |
| 793 gfx::Rect current_bounds = panel->GetBoundsInScreen(); | 795 gfx::Rect current_bounds = panel->GetBoundsInScreen(); |
| 794 gfx::Rect bounds = | 796 gfx::Rect bounds = |
| 795 panel->GetParent()->ConvertRectToScreen(panel->GetTargetBounds()); | 797 panel->GetParent()->ConvertRectToScreen(panel->GetTargetBounds()); |
| 796 gfx::Rect icon_bounds = shelf_->GetScreenBoundsOfItemIconForWindow(panel); | 798 gfx::Rect icon_bounds = shelf_->GetScreenBoundsOfItemIconForWindow(panel); |
| 797 if (icon_bounds.IsEmpty() || !panel->GetLayer()->GetTargetVisibility() || | 799 if (icon_bounds.IsEmpty() || !panel->GetLayer()->GetTargetVisibility() || |
| 798 panel == dragged_panel_ || !show_callout_widgets_) { | 800 panel == dragged_panel_ || !show_callout_widgets_) { |
| 799 callout_widget->Hide(); | 801 callout_widget->Hide(); |
| 800 callout_widget_window->GetLayer()->SetOpacity(0); | 802 callout_widget_window->GetLayer()->SetOpacity(0); |
| 801 continue; | 803 continue; |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 891 // Keyboard hidden, restore original bounds if they exist. | 893 // Keyboard hidden, restore original bounds if they exist. |
| 892 panel->SetBoundsDirect(panel_state->GetRestoreBoundsInScreen()); | 894 panel->SetBoundsDirect(panel_state->GetRestoreBoundsInScreen()); |
| 893 } | 895 } |
| 894 } | 896 } |
| 895 // This bounds change will have caused a change to the Shelf which does not | 897 // This bounds change will have caused a change to the Shelf which does not |
| 896 // propogate automatically to this class, so manually recalculate bounds. | 898 // propogate automatically to this class, so manually recalculate bounds. |
| 897 OnWindowResized(); | 899 OnWindowResized(); |
| 898 } | 900 } |
| 899 | 901 |
| 900 } // namespace ash | 902 } // namespace ash |
| OLD | NEW |