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

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

Issue 2899253002: chromeos: Rename ash::WmShelf to Shelf (Closed)
Patch Set: cleanup 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
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/shelf.h"
16 #include "ash/shell.h" 16 #include "ash/shell.h"
17 #include "ash/shell_port.h" 17 #include "ash/shell_port.h"
18 #include "ash/wm/overview/window_selector_controller.h" 18 #include "ash/wm/overview/window_selector_controller.h"
19 #include "ash/wm/window_animation_types.h" 19 #include "ash/wm/window_animation_types.h"
20 #include "ash/wm/window_parenting_utils.h" 20 #include "ash/wm/window_parenting_utils.h"
21 #include "ash/wm/window_properties.h" 21 #include "ash/wm/window_properties.h"
22 #include "ash/wm/window_state.h" 22 #include "ash/wm/window_state.h"
23 #include "ash/wm/window_util.h" 23 #include "ash/wm/window_util.h"
24 #include "ash/wm_window.h" 24 #include "ash/wm_window.h"
25 #include "base/auto_reset.h" 25 #include "base/auto_reset.h"
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 181
182 } // namespace 182 } // namespace
183 183
184 class PanelCalloutWidget : public views::Widget { 184 class PanelCalloutWidget : public views::Widget {
185 public: 185 public:
186 explicit PanelCalloutWidget(WmWindow* container) : background_(nullptr) { 186 explicit PanelCalloutWidget(WmWindow* container) : background_(nullptr) {
187 InitWidget(container); 187 InitWidget(container);
188 } 188 }
189 189
190 // Updates the bounds based on the shelf alignment. 190 // Updates the bounds based on the shelf alignment.
191 void UpdateBounds(WmShelf* shelf) { 191 void UpdateBounds(Shelf* 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 (shelf->IsHorizontalAlignment()) { 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();
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 DCHECK(!dragged_panel_); 298 DCHECK(!dragged_panel_);
299 dragged_panel_ = panel; 299 dragged_panel_ = panel;
300 Relayout(); 300 Relayout();
301 } 301 }
302 302
303 void PanelLayoutManager::FinishDragging() { 303 void PanelLayoutManager::FinishDragging() {
304 dragged_panel_ = nullptr; 304 dragged_panel_ = nullptr;
305 Relayout(); 305 Relayout();
306 } 306 }
307 307
308 void PanelLayoutManager::SetShelf(WmShelf* shelf) { 308 void PanelLayoutManager::SetShelf(Shelf* shelf) {
309 DCHECK(!shelf_); 309 DCHECK(!shelf_);
310 shelf_ = shelf; 310 shelf_ = shelf;
311 shelf_->AddObserver(this); 311 shelf_->AddObserver(this);
312 WillChangeVisibilityState(shelf_->GetVisibilityState()); 312 WillChangeVisibilityState(shelf_->GetVisibilityState());
313 } 313 }
314 314
315 void PanelLayoutManager::ToggleMinimize(WmWindow* panel) { 315 void PanelLayoutManager::ToggleMinimize(WmWindow* panel) {
316 DCHECK(panel->GetParent() == panel_container_); 316 DCHECK(panel->GetParent() == panel_container_);
317 wm::WindowState* window_state = panel->GetWindowState(); 317 wm::WindowState* window_state = panel->GetWindowState();
318 if (window_state->IsMinimized()) 318 if (window_state->IsMinimized())
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after
580 580
581 ::wm::SetWindowVisibilityAnimationType( 581 ::wm::SetWindowVisibilityAnimationType(
582 panel, wm::WINDOW_VISIBILITY_ANIMATION_TYPE_MINIMIZE); 582 panel, wm::WINDOW_VISIBILITY_ANIMATION_TYPE_MINIMIZE);
583 ui::Layer* layer = panel->layer(); 583 ui::Layer* layer = panel->layer();
584 ui::ScopedLayerAnimationSettings panel_slide_settings(layer->GetAnimator()); 584 ui::ScopedLayerAnimationSettings panel_slide_settings(layer->GetAnimator());
585 panel_slide_settings.SetPreemptionStrategy( 585 panel_slide_settings.SetPreemptionStrategy(
586 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); 586 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET);
587 panel_slide_settings.SetTransitionDuration( 587 panel_slide_settings.SetTransitionDuration(
588 base::TimeDelta::FromMilliseconds(kPanelSlideDurationMilliseconds)); 588 base::TimeDelta::FromMilliseconds(kPanelSlideDurationMilliseconds));
589 gfx::Rect bounds(panel->bounds()); 589 gfx::Rect bounds(panel->bounds());
590 bounds.Offset(GetSlideInAnimationOffset(shelf_->GetAlignment())); 590 bounds.Offset(GetSlideInAnimationOffset(shelf_->alignment()));
591 SetChildBoundsDirect(panel, bounds); 591 SetChildBoundsDirect(panel, bounds);
592 panel->Hide(); 592 panel->Hide();
593 layer->SetOpacity(0); 593 layer->SetOpacity(0);
594 if (::wm::IsActiveWindow(panel)) 594 if (::wm::IsActiveWindow(panel))
595 ::wm::DeactivateWindow(panel); 595 ::wm::DeactivateWindow(panel);
596 Relayout(); 596 Relayout();
597 } 597 }
598 598
599 void PanelLayoutManager::RestorePanel(aura::Window* panel) { 599 void PanelLayoutManager::RestorePanel(aura::Window* panel) {
600 PanelList::iterator found = std::find( 600 PanelList::iterator found = std::find(
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
855 std::max(current_bounds.x() - callout_bounds.x(), 855 std::max(current_bounds.x() - callout_bounds.x(),
856 callout_bounds.right() - current_bounds.right()); 856 callout_bounds.right() - current_bounds.right());
857 } else { 857 } else {
858 callout_bounds.set_y(icon_bounds.y() + 858 callout_bounds.set_y(icon_bounds.y() +
859 (icon_bounds.height() - callout_bounds.height()) / 859 (icon_bounds.height() - callout_bounds.height()) /
860 2); 860 2);
861 distance_until_over_panel = 861 distance_until_over_panel =
862 std::max(current_bounds.y() - callout_bounds.y(), 862 std::max(current_bounds.y() - callout_bounds.y(),
863 callout_bounds.bottom() - current_bounds.bottom()); 863 callout_bounds.bottom() - current_bounds.bottom());
864 } 864 }
865 if (shelf_->GetAlignment() == SHELF_ALIGNMENT_LEFT) 865 if (shelf_->alignment() == SHELF_ALIGNMENT_LEFT)
866 callout_bounds.set_x(bounds.x() - callout_bounds.width()); 866 callout_bounds.set_x(bounds.x() - callout_bounds.width());
867 else if (shelf_->GetAlignment() == SHELF_ALIGNMENT_RIGHT) 867 else if (shelf_->alignment() == SHELF_ALIGNMENT_RIGHT)
868 callout_bounds.set_x(bounds.right()); 868 callout_bounds.set_x(bounds.right());
869 else 869 else
870 callout_bounds.set_y(bounds.bottom()); 870 callout_bounds.set_y(bounds.bottom());
871 callout_bounds = callout_widget_window->GetParent()->ConvertRectFromScreen( 871 callout_bounds = callout_widget_window->GetParent()->ConvertRectFromScreen(
872 callout_bounds); 872 callout_bounds);
873 873
874 SetChildBoundsDirect(callout_widget_window->aura_window(), callout_bounds); 874 SetChildBoundsDirect(callout_widget_window->aura_window(), callout_bounds);
875 DCHECK_EQ(panel_container_, callout_widget_window->GetParent()); 875 DCHECK_EQ(panel_container_, callout_widget_window->GetParent());
876 DCHECK_EQ(panel_container_, panel->GetParent()); 876 DCHECK_EQ(panel_container_, panel->GetParent());
877 panel_container_->StackChildAbove(callout_widget_window, panel); 877 panel_container_->StackChildAbove(callout_widget_window, panel);
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
942 // This bounds change will have caused a change to the Shelf which does not 942 // This bounds change will have caused a change to the Shelf which does not
943 // propogate automatically to this class, so manually recalculate bounds. 943 // propogate automatically to this class, so manually recalculate bounds.
944 OnWindowResized(); 944 OnWindowResized();
945 } 945 }
946 946
947 void PanelLayoutManager::OnKeyboardClosed() { 947 void PanelLayoutManager::OnKeyboardClosed() {
948 keyboard_observer_.RemoveAll(); 948 keyboard_observer_.RemoveAll();
949 } 949 }
950 950
951 } // namespace ash 951 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698