Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(25)

Side by Side Diff: ash/wm/panels/panel_layout_manager.cc

Issue 2844563003: chromeos: Remove wm_shelf_util.h (Closed)
Patch Set: rebase Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ash/system/web_notification/web_notification_tray.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include <utility> 9 #include <utility>
10 10
11 #include "ash/keyboard/keyboard_observer_register.h" 11 #include "ash/keyboard/keyboard_observer_register.h"
12 #include "ash/public/cpp/shell_window_ids.h" 12 #include "ash/public/cpp/shell_window_ids.h"
13 #include "ash/public/cpp/window_properties.h" 13 #include "ash/public/cpp/window_properties.h"
14 #include "ash/root_window_controller.h" 14 #include "ash/root_window_controller.h"
15 #include "ash/shelf/wm_shelf.h" 15 #include "ash/shelf/wm_shelf.h"
16 #include "ash/shelf/wm_shelf_util.h"
17 #include "ash/shell.h" 16 #include "ash/shell.h"
18 #include "ash/shell_port.h" 17 #include "ash/shell_port.h"
19 #include "ash/wm/overview/window_selector_controller.h" 18 #include "ash/wm/overview/window_selector_controller.h"
20 #include "ash/wm/window_animation_types.h" 19 #include "ash/wm/window_animation_types.h"
21 #include "ash/wm/window_parenting_utils.h" 20 #include "ash/wm/window_parenting_utils.h"
22 #include "ash/wm/window_properties.h" 21 #include "ash/wm/window_properties.h"
23 #include "ash/wm/window_state.h" 22 #include "ash/wm/window_state.h"
24 #include "ash/wm/window_state_aura.h" 23 #include "ash/wm/window_state_aura.h"
25 #include "ash/wm/window_util.h" 24 #include "ash/wm/window_util.h"
26 #include "ash/wm_window.h" 25 #include "ash/wm_window.h"
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 } 180 }
182 181
183 } // namespace 182 } // namespace
184 183
185 class PanelCalloutWidget : public views::Widget { 184 class PanelCalloutWidget : public views::Widget {
186 public: 185 public:
187 explicit PanelCalloutWidget(WmWindow* container) : background_(nullptr) { 186 explicit PanelCalloutWidget(WmWindow* container) : background_(nullptr) {
188 InitWidget(container); 187 InitWidget(container);
189 } 188 }
190 189
191 void SetAlignment(ShelfAlignment alignment) { 190 // Updates the bounds based on the shelf alignment.
191 void UpdateBounds(WmShelf* shelf) {
192 WmWindow* window = WmWindow::Get(this->GetNativeWindow()); 192 WmWindow* window = WmWindow::Get(this->GetNativeWindow());
193 gfx::Rect callout_bounds = window->GetBounds(); 193 gfx::Rect callout_bounds = window->GetBounds();
194 if (IsHorizontalAlignment(alignment)) { 194 if (shelf->IsHorizontalAlignment()) {
195 callout_bounds.set_width(kArrowWidth); 195 callout_bounds.set_width(kArrowWidth);
196 callout_bounds.set_height(kArrowHeight); 196 callout_bounds.set_height(kArrowHeight);
197 } else { 197 } else {
198 callout_bounds.set_width(kArrowHeight); 198 callout_bounds.set_width(kArrowHeight);
199 callout_bounds.set_height(kArrowWidth); 199 callout_bounds.set_height(kArrowWidth);
200 } 200 }
201 WmWindow* parent = window->GetParent(); 201 WmWindow* parent = window->GetParent();
202 // It's important this go through WmWindow and not Widget. Going through 202 // It's important this go through WmWindow and not Widget. Going through
203 // Widget means it may move do a different screen, we don't want that. 203 // Widget means it may move do a different screen, we don't want that.
204 window->SetBounds(callout_bounds); 204 window->SetBounds(callout_bounds);
205 // Setting the bounds should not trigger changing the parent. 205 // Setting the bounds should not trigger changing the parent.
206 DCHECK_EQ(parent, window->GetParent()); 206 DCHECK_EQ(parent, window->GetParent());
207 if (background_->alignment() != alignment) { 207 if (background_->alignment() != shelf->alignment()) {
208 background_->set_alignment(alignment); 208 background_->set_alignment(shelf->alignment());
209 SchedulePaintInRect(gfx::Rect(callout_bounds.size())); 209 SchedulePaintInRect(gfx::Rect(callout_bounds.size()));
210 } 210 }
211 } 211 }
212 212
213 private: 213 private:
214 void InitWidget(WmWindow* parent) { 214 void InitWidget(WmWindow* parent) {
215 views::Widget::InitParams params; 215 views::Widget::InitParams params;
216 params.type = views::Widget::InitParams::TYPE_POPUP; 216 params.type = views::Widget::InitParams::TYPE_POPUP;
217 params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW; 217 params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW;
218 params.keep_on_top = true; 218 params.keep_on_top = true;
(...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after
616 WindowSelectorController* window_selector_controller = 616 WindowSelectorController* window_selector_controller =
617 Shell::Get()->window_selector_controller(); 617 Shell::Get()->window_selector_controller();
618 if (in_layout_ || 618 if (in_layout_ ||
619 (window_selector_controller->IsSelecting() && 619 (window_selector_controller->IsSelecting() &&
620 !window_selector_controller->IsRestoringMinimizedWindows())) { 620 !window_selector_controller->IsRestoringMinimizedWindows())) {
621 return; 621 return;
622 } 622 }
623 623
624 base::AutoReset<bool> auto_reset_in_layout(&in_layout_, true); 624 base::AutoReset<bool> auto_reset_in_layout(&in_layout_, true);
625 625
626 const ShelfAlignment alignment = shelf_->GetAlignment();
627 const bool horizontal = shelf_->IsHorizontalAlignment(); 626 const bool horizontal = shelf_->IsHorizontalAlignment();
628 gfx::Rect shelf_bounds = panel_container_->ConvertRectFromScreen( 627 gfx::Rect shelf_bounds = panel_container_->ConvertRectFromScreen(
629 shelf_->GetWindow()->GetBoundsInScreen()); 628 shelf_->GetWindow()->GetBoundsInScreen());
630 int panel_start_bounds = kPanelIdealSpacing; 629 int panel_start_bounds = kPanelIdealSpacing;
631 int panel_end_bounds = 630 int panel_end_bounds =
632 horizontal ? panel_container_->GetBounds().width() - kPanelIdealSpacing 631 horizontal ? panel_container_->GetBounds().width() - kPanelIdealSpacing
633 : panel_container_->GetBounds().height() - kPanelIdealSpacing; 632 : panel_container_->GetBounds().height() - kPanelIdealSpacing;
634 WmWindow* active_panel = nullptr; 633 WmWindow* active_panel = nullptr;
635 std::vector<VisiblePanelPositionInfo> visible_panels; 634 std::vector<VisiblePanelPositionInfo> visible_panels;
636 for (PanelList::iterator iter = panel_windows_.begin(); 635 for (PanelList::iterator iter = panel_windows_.begin();
637 iter != panel_windows_.end(); ++iter) { 636 iter != panel_windows_.end(); ++iter) {
638 WmWindow* panel = iter->window; 637 WmWindow* panel = iter->window;
639 iter->callout_widget->SetAlignment(alignment); 638 iter->callout_widget->UpdateBounds(shelf_);
640 639
641 // Consider the dragged panel as part of the layout as long as it is 640 // Consider the dragged panel as part of the layout as long as it is
642 // touching the shelf. 641 // touching the shelf.
643 if ((!panel->IsVisible() && !iter->slide_in) || 642 if ((!panel->IsVisible() && !iter->slide_in) ||
644 (panel == dragged_panel_ && 643 (panel == dragged_panel_ &&
645 !BoundsAdjacent(panel->GetBounds(), shelf_bounds))) { 644 !BoundsAdjacent(panel->GetBounds(), shelf_bounds))) {
646 continue; 645 continue;
647 } 646 }
648 647
649 // If the shelf is currently hidden (full-screen mode), minimize panel until 648 // If the shelf is currently hidden (full-screen mode), minimize panel until
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
708 } 707 }
709 } 708 }
710 FanOutPanels(visible_panels.begin() + first_overlapping_panel, 709 FanOutPanels(visible_panels.begin() + first_overlapping_panel,
711 visible_panels.end()); 710 visible_panels.end());
712 711
713 for (size_t i = 0; i < visible_panels.size(); ++i) { 712 for (size_t i = 0; i < visible_panels.size(); ++i) {
714 if (visible_panels[i].window == dragged_panel_) 713 if (visible_panels[i].window == dragged_panel_)
715 continue; 714 continue;
716 bool slide_in = visible_panels[i].slide_in; 715 bool slide_in = visible_panels[i].slide_in;
717 gfx::Rect bounds = visible_panels[i].window->GetTargetBounds(); 716 gfx::Rect bounds = visible_panels[i].window->GetTargetBounds();
718 if (alignment == SHELF_ALIGNMENT_LEFT) 717 if (shelf_->alignment() == SHELF_ALIGNMENT_LEFT)
719 bounds.set_x(shelf_bounds.right()); 718 bounds.set_x(shelf_bounds.right());
720 else if (alignment == SHELF_ALIGNMENT_RIGHT) 719 else if (shelf_->alignment() == SHELF_ALIGNMENT_RIGHT)
721 bounds.set_x(shelf_bounds.x() - bounds.width()); 720 bounds.set_x(shelf_bounds.x() - bounds.width());
722 else 721 else
723 bounds.set_y(shelf_bounds.y() - bounds.height()); 722 bounds.set_y(shelf_bounds.y() - bounds.height());
724 bool on_shelf = visible_panels[i].window->GetTargetBounds() == bounds; 723 bool on_shelf = visible_panels[i].window->GetTargetBounds() == bounds;
725 724
726 if (horizontal) { 725 if (horizontal) {
727 bounds.set_x(visible_panels[i].major_pos - 726 bounds.set_x(visible_panels[i].major_pos -
728 visible_panels[i].major_length / 2); 727 visible_panels[i].major_length / 2);
729 } else { 728 } else {
730 bounds.set_y(visible_panels[i].major_pos - 729 bounds.set_y(visible_panels[i].major_pos -
731 visible_panels[i].major_length / 2); 730 visible_panels[i].major_length / 2);
732 } 731 }
733 732
734 ui::Layer* layer = visible_panels[i].window->GetLayer(); 733 ui::Layer* layer = visible_panels[i].window->GetLayer();
735 if (slide_in) { 734 if (slide_in) {
736 // New windows shift up from the shelf into position and fade in. 735 // New windows shift up from the shelf into position and fade in.
737 layer->SetOpacity(0); 736 layer->SetOpacity(0);
738 gfx::Rect initial_bounds(bounds); 737 gfx::Rect initial_bounds(bounds);
739 initial_bounds.Offset(GetSlideInAnimationOffset(alignment)); 738 initial_bounds.Offset(GetSlideInAnimationOffset(shelf_->alignment()));
740 visible_panels[i].window->SetBoundsDirect(initial_bounds); 739 visible_panels[i].window->SetBoundsDirect(initial_bounds);
741 // Set on shelf so that the panel animates into its target position. 740 // Set on shelf so that the panel animates into its target position.
742 on_shelf = true; 741 on_shelf = true;
743 } 742 }
744 743
745 if (on_shelf) { 744 if (on_shelf) {
746 ui::ScopedLayerAnimationSettings panel_slide_settings( 745 ui::ScopedLayerAnimationSettings panel_slide_settings(
747 layer->GetAnimator()); 746 layer->GetAnimator());
748 panel_slide_settings.SetPreemptionStrategy( 747 panel_slide_settings.SetPreemptionStrategy(
749 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); 748 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET);
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
941 // This bounds change will have caused a change to the Shelf which does not 940 // This bounds change will have caused a change to the Shelf which does not
942 // propogate automatically to this class, so manually recalculate bounds. 941 // propogate automatically to this class, so manually recalculate bounds.
943 OnWindowResized(); 942 OnWindowResized();
944 } 943 }
945 944
946 void PanelLayoutManager::OnKeyboardClosed() { 945 void PanelLayoutManager::OnKeyboardClosed() {
947 keyboard_observer_.RemoveAll(); 946 keyboard_observer_.RemoveAll();
948 } 947 }
949 948
950 } // namespace ash 949 } // namespace ash
OLDNEW
« no previous file with comments | « ash/system/web_notification/web_notification_tray.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698