| 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/panels/panel_layout_manager.h" | 5 #include "ash/wm/panels/panel_layout_manager.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <map> | 8 #include <map> |
| 9 | 9 |
| 10 #include "ash/screen_ash.h" | 10 #include "ash/screen_util.h" |
| 11 #include "ash/shelf/shelf.h" | 11 #include "ash/shelf/shelf.h" |
| 12 #include "ash/shelf/shelf_layout_manager.h" | 12 #include "ash/shelf/shelf_layout_manager.h" |
| 13 #include "ash/shelf/shelf_types.h" | 13 #include "ash/shelf/shelf_types.h" |
| 14 #include "ash/shelf/shelf_widget.h" | 14 #include "ash/shelf/shelf_widget.h" |
| 15 #include "ash/shell.h" | 15 #include "ash/shell.h" |
| 16 #include "ash/shell_window_ids.h" | 16 #include "ash/shell_window_ids.h" |
| 17 #include "ash/wm/window_animations.h" | 17 #include "ash/wm/window_animations.h" |
| 18 #include "ash/wm/window_state.h" | 18 #include "ash/wm/window_state.h" |
| 19 #include "ash/wm/window_util.h" | 19 #include "ash/wm/window_util.h" |
| 20 #include "base/auto_reset.h" | 20 #include "base/auto_reset.h" |
| (...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 225 | 225 |
| 226 private: | 226 private: |
| 227 void InitWidget(aura::Window* parent) { | 227 void InitWidget(aura::Window* parent) { |
| 228 views::Widget::InitParams params; | 228 views::Widget::InitParams params; |
| 229 params.type = views::Widget::InitParams::TYPE_POPUP; | 229 params.type = views::Widget::InitParams::TYPE_POPUP; |
| 230 params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW; | 230 params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW; |
| 231 params.can_activate = false; | 231 params.can_activate = false; |
| 232 params.keep_on_top = true; | 232 params.keep_on_top = true; |
| 233 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; | 233 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; |
| 234 params.parent = parent; | 234 params.parent = parent; |
| 235 params.bounds = ScreenAsh::ConvertRectToScreen(parent, gfx::Rect()); | 235 params.bounds = ScreenUtil::ConvertRectToScreen(parent, gfx::Rect()); |
| 236 params.bounds.set_width(kArrowWidth); | 236 params.bounds.set_width(kArrowWidth); |
| 237 params.bounds.set_height(kArrowHeight); | 237 params.bounds.set_height(kArrowHeight); |
| 238 // Why do we need this and can_activate = false? | 238 // Why do we need this and can_activate = false? |
| 239 set_focus_on_creation(false); | 239 set_focus_on_creation(false); |
| 240 Init(params); | 240 Init(params); |
| 241 DCHECK_EQ(GetNativeView()->GetRootWindow(), parent->GetRootWindow()); | 241 DCHECK_EQ(GetNativeView()->GetRootWindow(), parent->GetRootWindow()); |
| 242 views::View* content_view = new views::View; | 242 views::View* content_view = new views::View; |
| 243 background_ = new CalloutWidgetBackground; | 243 background_ = new CalloutWidgetBackground; |
| 244 content_view->set_background(background_); | 244 content_view->set_background(background_); |
| 245 SetContentsView(content_view); | 245 SetContentsView(content_view); |
| (...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 579 if (!shelf_ || !shelf_->shelf_widget()) | 579 if (!shelf_ || !shelf_->shelf_widget()) |
| 580 return; | 580 return; |
| 581 | 581 |
| 582 if (in_layout_) | 582 if (in_layout_) |
| 583 return; | 583 return; |
| 584 base::AutoReset<bool> auto_reset_in_layout(&in_layout_, true); | 584 base::AutoReset<bool> auto_reset_in_layout(&in_layout_, true); |
| 585 | 585 |
| 586 ShelfAlignment alignment = shelf_->shelf_widget()->GetAlignment(); | 586 ShelfAlignment alignment = shelf_->shelf_widget()->GetAlignment(); |
| 587 bool horizontal = alignment == SHELF_ALIGNMENT_TOP || | 587 bool horizontal = alignment == SHELF_ALIGNMENT_TOP || |
| 588 alignment == SHELF_ALIGNMENT_BOTTOM; | 588 alignment == SHELF_ALIGNMENT_BOTTOM; |
| 589 gfx::Rect shelf_bounds = ash::ScreenAsh::ConvertRectFromScreen( | 589 gfx::Rect shelf_bounds = ash::ScreenUtil::ConvertRectFromScreen( |
| 590 panel_container_, shelf_->shelf_widget()->GetWindowBoundsInScreen()); | 590 panel_container_, shelf_->shelf_widget()->GetWindowBoundsInScreen()); |
| 591 int panel_start_bounds = kPanelIdealSpacing; | 591 int panel_start_bounds = kPanelIdealSpacing; |
| 592 int panel_end_bounds = horizontal ? | 592 int panel_end_bounds = horizontal ? |
| 593 panel_container_->bounds().width() - kPanelIdealSpacing : | 593 panel_container_->bounds().width() - kPanelIdealSpacing : |
| 594 panel_container_->bounds().height() - kPanelIdealSpacing; | 594 panel_container_->bounds().height() - kPanelIdealSpacing; |
| 595 aura::Window* active_panel = NULL; | 595 aura::Window* active_panel = NULL; |
| 596 std::vector<VisiblePanelPositionInfo> visible_panels; | 596 std::vector<VisiblePanelPositionInfo> visible_panels; |
| 597 for (PanelList::iterator iter = panel_windows_.begin(); | 597 for (PanelList::iterator iter = panel_windows_.begin(); |
| 598 iter != panel_windows_.end(); ++iter) { | 598 iter != panel_windows_.end(); ++iter) { |
| 599 aura::Window* panel = iter->window; | 599 aura::Window* panel = iter->window; |
| (...skipping 23 matching lines...) Expand all Loading... |
| 623 // correctly and the panel can be aligned above where the hidden icon is. | 623 // correctly and the panel can be aligned above where the hidden icon is. |
| 624 if (icon_bounds.width() == 0 && icon_bounds.height() == 0) | 624 if (icon_bounds.width() == 0 && icon_bounds.height() == 0) |
| 625 continue; | 625 continue; |
| 626 | 626 |
| 627 if (panel->HasFocus() || | 627 if (panel->HasFocus() || |
| 628 panel->Contains( | 628 panel->Contains( |
| 629 aura::client::GetFocusClient(panel)->GetFocusedWindow())) { | 629 aura::client::GetFocusClient(panel)->GetFocusedWindow())) { |
| 630 DCHECK(!active_panel); | 630 DCHECK(!active_panel); |
| 631 active_panel = panel; | 631 active_panel = panel; |
| 632 } | 632 } |
| 633 icon_bounds = ScreenAsh::ConvertRectFromScreen(panel_container_, | 633 icon_bounds = ScreenUtil::ConvertRectFromScreen(panel_container_, |
| 634 icon_bounds); | 634 icon_bounds); |
| 635 gfx::Point icon_origin = icon_bounds.origin(); | 635 gfx::Point icon_origin = icon_bounds.origin(); |
| 636 VisiblePanelPositionInfo position_info; | 636 VisiblePanelPositionInfo position_info; |
| 637 int icon_start = horizontal ? icon_origin.x() : icon_origin.y(); | 637 int icon_start = horizontal ? icon_origin.x() : icon_origin.y(); |
| 638 int icon_end = icon_start + (horizontal ? icon_bounds.width() : | 638 int icon_end = icon_start + (horizontal ? icon_bounds.width() : |
| 639 icon_bounds.height()); | 639 icon_bounds.height()); |
| 640 position_info.major_length = horizontal ? | 640 position_info.major_length = horizontal ? |
| 641 panel->bounds().width() : panel->bounds().height(); | 641 panel->bounds().width() : panel->bounds().height(); |
| 642 position_info.min_major = std::max( | 642 position_info.min_major = std::max( |
| 643 panel_start_bounds + position_info.major_length / 2, | 643 panel_start_bounds + position_info.major_length / 2, |
| 644 icon_end - position_info.major_length / 2); | 644 icon_end - position_info.major_length / 2); |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 789 ShelfAlignment alignment = shelf_->alignment(); | 789 ShelfAlignment alignment = shelf_->alignment(); |
| 790 bool horizontal = alignment == SHELF_ALIGNMENT_TOP || | 790 bool horizontal = alignment == SHELF_ALIGNMENT_TOP || |
| 791 alignment == SHELF_ALIGNMENT_BOTTOM; | 791 alignment == SHELF_ALIGNMENT_BOTTOM; |
| 792 | 792 |
| 793 for (PanelList::iterator iter = panel_windows_.begin(); | 793 for (PanelList::iterator iter = panel_windows_.begin(); |
| 794 iter != panel_windows_.end(); ++iter) { | 794 iter != panel_windows_.end(); ++iter) { |
| 795 aura::Window* panel = iter->window; | 795 aura::Window* panel = iter->window; |
| 796 views::Widget* callout_widget = iter->callout_widget; | 796 views::Widget* callout_widget = iter->callout_widget; |
| 797 | 797 |
| 798 gfx::Rect current_bounds = panel->GetBoundsInScreen(); | 798 gfx::Rect current_bounds = panel->GetBoundsInScreen(); |
| 799 gfx::Rect bounds = ScreenAsh::ConvertRectToScreen(panel->parent(), | 799 gfx::Rect bounds = ScreenUtil::ConvertRectToScreen( |
| 800 panel->GetTargetBounds()); | 800 panel->parent(), |
| 801 panel->GetTargetBounds()); |
| 801 gfx::Rect icon_bounds = shelf_->GetScreenBoundsOfItemIconForWindow(panel); | 802 gfx::Rect icon_bounds = shelf_->GetScreenBoundsOfItemIconForWindow(panel); |
| 802 if (icon_bounds.IsEmpty() || !panel->layer()->GetTargetVisibility() || | 803 if (icon_bounds.IsEmpty() || !panel->layer()->GetTargetVisibility() || |
| 803 panel == dragged_panel_) { | 804 panel == dragged_panel_) { |
| 804 callout_widget->Hide(); | 805 callout_widget->Hide(); |
| 805 callout_widget->GetNativeWindow()->layer()->SetOpacity(0); | 806 callout_widget->GetNativeWindow()->layer()->SetOpacity(0); |
| 806 continue; | 807 continue; |
| 807 } | 808 } |
| 808 | 809 |
| 809 gfx::Rect callout_bounds = callout_widget->GetWindowBoundsInScreen(); | 810 gfx::Rect callout_bounds = callout_widget->GetWindowBoundsInScreen(); |
| 810 gfx::Vector2d slide_vector = bounds.origin() - current_bounds.origin(); | 811 gfx::Vector2d slide_vector = bounds.origin() - current_bounds.origin(); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 831 case SHELF_ALIGNMENT_LEFT: | 832 case SHELF_ALIGNMENT_LEFT: |
| 832 callout_bounds.set_x(bounds.x() - callout_bounds.width()); | 833 callout_bounds.set_x(bounds.x() - callout_bounds.width()); |
| 833 break; | 834 break; |
| 834 case SHELF_ALIGNMENT_RIGHT: | 835 case SHELF_ALIGNMENT_RIGHT: |
| 835 callout_bounds.set_x(bounds.right()); | 836 callout_bounds.set_x(bounds.right()); |
| 836 break; | 837 break; |
| 837 case SHELF_ALIGNMENT_TOP: | 838 case SHELF_ALIGNMENT_TOP: |
| 838 callout_bounds.set_y(bounds.y() - callout_bounds.height()); | 839 callout_bounds.set_y(bounds.y() - callout_bounds.height()); |
| 839 break; | 840 break; |
| 840 } | 841 } |
| 841 callout_bounds = ScreenAsh::ConvertRectFromScreen( | 842 callout_bounds = ScreenUtil::ConvertRectFromScreen( |
| 842 callout_widget->GetNativeWindow()->parent(), | 843 callout_widget->GetNativeWindow()->parent(), |
| 843 callout_bounds); | 844 callout_bounds); |
| 844 | 845 |
| 845 SetChildBoundsDirect(callout_widget->GetNativeWindow(), callout_bounds); | 846 SetChildBoundsDirect(callout_widget->GetNativeWindow(), callout_bounds); |
| 846 panel_container_->StackChildAbove(callout_widget->GetNativeWindow(), | 847 panel_container_->StackChildAbove(callout_widget->GetNativeWindow(), |
| 847 panel); | 848 panel); |
| 848 callout_widget->Show(); | 849 callout_widget->Show(); |
| 849 | 850 |
| 850 ui::Layer* layer = callout_widget->GetNativeWindow()->layer(); | 851 ui::Layer* layer = callout_widget->GetNativeWindow()->layer(); |
| 851 // If the panel is not over the callout position or has just become visible | 852 // If the panel is not over the callout position or has just become visible |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 883 | 884 |
| 884 void PanelLayoutManager::OnKeyboardBoundsChanging( | 885 void PanelLayoutManager::OnKeyboardBoundsChanging( |
| 885 const gfx::Rect& keyboard_bounds) { | 886 const gfx::Rect& keyboard_bounds) { |
| 886 // This bounds change will have caused a change to the Shelf which does not | 887 // This bounds change will have caused a change to the Shelf which does not |
| 887 // propogate automatically to this class, so manually recalculate bounds. | 888 // propogate automatically to this class, so manually recalculate bounds. |
| 888 OnWindowResized(); | 889 OnWindowResized(); |
| 889 } | 890 } |
| 890 | 891 |
| 891 } // namespace internal | 892 } // namespace internal |
| 892 } // namespace ash | 893 } // namespace ash |
| OLD | NEW |