| 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/common/wm/panels/panel_layout_manager.h" | 5 #include "ash/common/wm/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/common/shelf/wm_shelf.h" | 11 #include "ash/common/shelf/wm_shelf.h" |
| 12 #include "ash/common/shelf/wm_shelf_util.h" | 12 #include "ash/common/shelf/wm_shelf_util.h" |
| 13 #include "ash/common/wm/overview/window_selector_controller.h" | 13 #include "ash/common/wm/overview/window_selector_controller.h" |
| 14 #include "ash/common/wm/window_animation_types.h" | 14 #include "ash/common/wm/window_animation_types.h" |
| 15 #include "ash/common/wm/window_parenting_utils.h" | 15 #include "ash/common/wm/window_parenting_utils.h" |
| 16 #include "ash/common/wm/window_state.h" | 16 #include "ash/common/wm/window_state.h" |
| 17 #include "ash/common/wm_lookup.h" | |
| 18 #include "ash/common/wm_shell.h" | 17 #include "ash/common/wm_shell.h" |
| 19 #include "ash/common/wm_window.h" | 18 #include "ash/common/wm_window.h" |
| 20 #include "ash/common/wm_window_property.h" | 19 #include "ash/common/wm_window_property.h" |
| 21 #include "ash/public/cpp/shell_window_ids.h" | 20 #include "ash/public/cpp/shell_window_ids.h" |
| 22 #include "ash/root_window_controller.h" | 21 #include "ash/root_window_controller.h" |
| 23 #include "ash/wm/window_properties.h" | 22 #include "ash/wm/window_properties.h" |
| 24 #include "base/auto_reset.h" | 23 #include "base/auto_reset.h" |
| 25 #include "third_party/skia/include/core/SkColor.h" | 24 #include "third_party/skia/include/core/SkColor.h" |
| 26 #include "third_party/skia/include/core/SkPath.h" | 25 #include "third_party/skia/include/core/SkPath.h" |
| 27 #include "ui/compositor/scoped_layer_animation_settings.h" | 26 #include "ui/compositor/scoped_layer_animation_settings.h" |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 | 173 |
| 175 } // namespace | 174 } // namespace |
| 176 | 175 |
| 177 class PanelCalloutWidget : public views::Widget { | 176 class PanelCalloutWidget : public views::Widget { |
| 178 public: | 177 public: |
| 179 explicit PanelCalloutWidget(WmWindow* container) : background_(nullptr) { | 178 explicit PanelCalloutWidget(WmWindow* container) : background_(nullptr) { |
| 180 InitWidget(container); | 179 InitWidget(container); |
| 181 } | 180 } |
| 182 | 181 |
| 183 void SetAlignment(ShelfAlignment alignment) { | 182 void SetAlignment(ShelfAlignment alignment) { |
| 184 WmWindow* window = WmLookup::Get()->GetWindowForWidget(this); | 183 WmWindow* window = WmWindow::Get(this->GetNativeWindow()); |
| 185 gfx::Rect callout_bounds = window->GetBounds(); | 184 gfx::Rect callout_bounds = window->GetBounds(); |
| 186 if (IsHorizontalAlignment(alignment)) { | 185 if (IsHorizontalAlignment(alignment)) { |
| 187 callout_bounds.set_width(kArrowWidth); | 186 callout_bounds.set_width(kArrowWidth); |
| 188 callout_bounds.set_height(kArrowHeight); | 187 callout_bounds.set_height(kArrowHeight); |
| 189 } else { | 188 } else { |
| 190 callout_bounds.set_width(kArrowHeight); | 189 callout_bounds.set_width(kArrowHeight); |
| 191 callout_bounds.set_height(kArrowWidth); | 190 callout_bounds.set_height(kArrowWidth); |
| 192 } | 191 } |
| 193 WmWindow* parent = window->GetParent(); | 192 WmWindow* parent = window->GetParent(); |
| 194 // It's important this go through WmWindow and not Widget. Going through | 193 // It's important this go through WmWindow and not Widget. Going through |
| (...skipping 15 matching lines...) Expand all Loading... |
| 210 params.keep_on_top = true; | 209 params.keep_on_top = true; |
| 211 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; | 210 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; |
| 212 params.bounds = parent->ConvertRectToScreen(gfx::Rect()); | 211 params.bounds = parent->ConvertRectToScreen(gfx::Rect()); |
| 213 params.bounds.set_width(kArrowWidth); | 212 params.bounds.set_width(kArrowWidth); |
| 214 params.bounds.set_height(kArrowHeight); | 213 params.bounds.set_height(kArrowHeight); |
| 215 params.accept_events = false; | 214 params.accept_events = false; |
| 216 parent->GetRootWindowController()->ConfigureWidgetInitParamsForContainer( | 215 parent->GetRootWindowController()->ConfigureWidgetInitParamsForContainer( |
| 217 this, parent->GetShellWindowId(), ¶ms); | 216 this, parent->GetShellWindowId(), ¶ms); |
| 218 set_focus_on_creation(false); | 217 set_focus_on_creation(false); |
| 219 Init(params); | 218 Init(params); |
| 220 WmWindow* widget_window = WmLookup::Get()->GetWindowForWidget(this); | 219 WmWindow* widget_window = WmWindow::Get(this->GetNativeWindow()); |
| 221 DCHECK_EQ(widget_window->GetRootWindow(), parent->GetRootWindow()); | 220 DCHECK_EQ(widget_window->GetRootWindow(), parent->GetRootWindow()); |
| 222 views::View* content_view = new views::View; | 221 views::View* content_view = new views::View; |
| 223 background_ = new CalloutWidgetBackground; | 222 background_ = new CalloutWidgetBackground; |
| 224 content_view->set_background(background_); | 223 content_view->set_background(background_); |
| 225 SetContentsView(content_view); | 224 SetContentsView(content_view); |
| 226 widget_window->GetLayer()->SetOpacity(0); | 225 widget_window->GetLayer()->SetOpacity(0); |
| 227 } | 226 } |
| 228 | 227 |
| 229 // Weak pointer owned by this widget's content view. | 228 // Weak pointer owned by this widget's content view. |
| 230 CalloutWidgetBackground* background_; | 229 CalloutWidgetBackground* background_; |
| (...skipping 576 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 807 // TODO(jamescook): Revert this after http://crbug.com/648964 is fixed. | 806 // TODO(jamescook): Revert this after http://crbug.com/648964 is fixed. |
| 808 if (!shelf_) | 807 if (!shelf_) |
| 809 return; | 808 return; |
| 810 | 809 |
| 811 const bool horizontal = shelf_->IsHorizontalAlignment(); | 810 const bool horizontal = shelf_->IsHorizontalAlignment(); |
| 812 for (PanelList::iterator iter = panel_windows_.begin(); | 811 for (PanelList::iterator iter = panel_windows_.begin(); |
| 813 iter != panel_windows_.end(); ++iter) { | 812 iter != panel_windows_.end(); ++iter) { |
| 814 WmWindow* panel = iter->window; | 813 WmWindow* panel = iter->window; |
| 815 views::Widget* callout_widget = iter->callout_widget; | 814 views::Widget* callout_widget = iter->callout_widget; |
| 816 WmWindow* callout_widget_window = | 815 WmWindow* callout_widget_window = |
| 817 WmLookup::Get()->GetWindowForWidget(callout_widget); | 816 WmWindow::Get(callout_widget->GetNativeWindow()); |
| 818 | 817 |
| 819 gfx::Rect current_bounds = panel->GetBoundsInScreen(); | 818 gfx::Rect current_bounds = panel->GetBoundsInScreen(); |
| 820 gfx::Rect bounds = | 819 gfx::Rect bounds = |
| 821 panel->GetParent()->ConvertRectToScreen(panel->GetTargetBounds()); | 820 panel->GetParent()->ConvertRectToScreen(panel->GetTargetBounds()); |
| 822 gfx::Rect icon_bounds = shelf_->GetScreenBoundsOfItemIconForWindow(panel); | 821 gfx::Rect icon_bounds = shelf_->GetScreenBoundsOfItemIconForWindow(panel); |
| 823 if (icon_bounds.IsEmpty() || !panel->GetLayer()->GetTargetVisibility() || | 822 if (icon_bounds.IsEmpty() || !panel->GetLayer()->GetTargetVisibility() || |
| 824 panel == dragged_panel_ || !show_callout_widgets_) { | 823 panel == dragged_panel_ || !show_callout_widgets_) { |
| 825 callout_widget->Hide(); | 824 callout_widget->Hide(); |
| 826 callout_widget_window->GetLayer()->SetOpacity(0); | 825 callout_widget_window->GetLayer()->SetOpacity(0); |
| 827 continue; | 826 continue; |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 921 } | 920 } |
| 922 } | 921 } |
| 923 // This bounds change will have caused a change to the Shelf which does not | 922 // This bounds change will have caused a change to the Shelf which does not |
| 924 // propogate automatically to this class, so manually recalculate bounds. | 923 // propogate automatically to this class, so manually recalculate bounds. |
| 925 OnWindowResized(); | 924 OnWindowResized(); |
| 926 } | 925 } |
| 927 | 926 |
| 928 void PanelLayoutManager::OnKeyboardClosed() {} | 927 void PanelLayoutManager::OnKeyboardClosed() {} |
| 929 | 928 |
| 930 } // namespace ash | 929 } // namespace ash |
| OLD | NEW |