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

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

Issue 2676673005: ash: Clean up shelf GetAlignment() and IsHorizontalAlignment() calls (Closed)
Patch Set: Created 3 years, 10 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/common/shelf/shelf_widget.cc ('k') | ash/shelf/shelf_layout_manager_unittest.cc » ('j') | 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/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
(...skipping 584 matching lines...) Expand 10 before | Expand all | Expand 10 after
595 WmShell::Get()->window_selector_controller(); 595 WmShell::Get()->window_selector_controller();
596 if (in_layout_ || 596 if (in_layout_ ||
597 (window_selector_controller->IsSelecting() && 597 (window_selector_controller->IsSelecting() &&
598 !window_selector_controller->IsRestoringMinimizedWindows())) { 598 !window_selector_controller->IsRestoringMinimizedWindows())) {
599 return; 599 return;
600 } 600 }
601 601
602 base::AutoReset<bool> auto_reset_in_layout(&in_layout_, true); 602 base::AutoReset<bool> auto_reset_in_layout(&in_layout_, true);
603 603
604 const ShelfAlignment alignment = shelf_->GetAlignment(); 604 const ShelfAlignment alignment = shelf_->GetAlignment();
605 const bool horizontal = IsHorizontalAlignment(shelf_->GetAlignment()); 605 const bool horizontal = shelf_->IsHorizontalAlignment();
606 gfx::Rect shelf_bounds = panel_container_->ConvertRectFromScreen( 606 gfx::Rect shelf_bounds = panel_container_->ConvertRectFromScreen(
607 shelf_->GetWindow()->GetBoundsInScreen()); 607 shelf_->GetWindow()->GetBoundsInScreen());
608 int panel_start_bounds = kPanelIdealSpacing; 608 int panel_start_bounds = kPanelIdealSpacing;
609 int panel_end_bounds = 609 int panel_end_bounds =
610 horizontal ? panel_container_->GetBounds().width() - kPanelIdealSpacing 610 horizontal ? panel_container_->GetBounds().width() - kPanelIdealSpacing
611 : panel_container_->GetBounds().height() - kPanelIdealSpacing; 611 : panel_container_->GetBounds().height() - kPanelIdealSpacing;
612 WmWindow* active_panel = nullptr; 612 WmWindow* active_panel = nullptr;
613 std::vector<VisiblePanelPositionInfo> visible_panels; 613 std::vector<VisiblePanelPositionInfo> visible_panels;
614 for (PanelList::iterator iter = panel_windows_.begin(); 614 for (PanelList::iterator iter = panel_windows_.begin();
615 iter != panel_windows_.end(); ++iter) { 615 iter != panel_windows_.end(); ++iter) {
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
758 // We want to to stack the panels like a deck of cards: 758 // We want to to stack the panels like a deck of cards:
759 // ,--,--,--,-------.--.--. 759 // ,--,--,--,-------.--.--.
760 // | | | | | | | 760 // | | | | | | |
761 // | | | | | | | 761 // | | | | | | |
762 // 762 //
763 // We use the middle of each panel to figure out how to stack the panels. This 763 // We use the middle of each panel to figure out how to stack the panels. This
764 // allows us to update the stacking when a panel is being dragged around by 764 // allows us to update the stacking when a panel is being dragged around by
765 // the titlebar--even though it doesn't update the shelf icon positions, we 765 // the titlebar--even though it doesn't update the shelf icon positions, we
766 // still want the visual effect. 766 // still want the visual effect.
767 std::map<int, WmWindow*> window_ordering; 767 std::map<int, WmWindow*> window_ordering;
768 const bool horizontal = IsHorizontalAlignment(shelf_->GetAlignment()); 768 const bool horizontal = shelf_->IsHorizontalAlignment();
769 for (PanelList::const_iterator it = panel_windows_.begin(); 769 for (PanelList::const_iterator it = panel_windows_.begin();
770 it != panel_windows_.end(); ++it) { 770 it != panel_windows_.end(); ++it) {
771 gfx::Rect bounds = it->window->GetBounds(); 771 gfx::Rect bounds = it->window->GetBounds();
772 window_ordering.insert( 772 window_ordering.insert(
773 std::make_pair(horizontal ? bounds.x() + bounds.width() / 2 773 std::make_pair(horizontal ? bounds.x() + bounds.width() / 2
774 : bounds.y() + bounds.height() / 2, 774 : bounds.y() + bounds.height() / 2,
775 it->window)); 775 it->window));
776 } 776 }
777 777
778 WmWindow* previous_panel = nullptr; 778 WmWindow* previous_panel = nullptr;
(...skipping 18 matching lines...) Expand all
797 panel_container_->StackChildAtTop(dragged_panel_); 797 panel_container_->StackChildAtTop(dragged_panel_);
798 last_active_panel_ = active_panel; 798 last_active_panel_ = active_panel;
799 } 799 }
800 800
801 void PanelLayoutManager::UpdateCallouts() { 801 void PanelLayoutManager::UpdateCallouts() {
802 // Clusterfuzz can trigger panel accelerators before the shelf is created. 802 // Clusterfuzz can trigger panel accelerators before the shelf is created.
803 // TODO(jamescook): Revert this after http://crbug.com/648964 is fixed. 803 // TODO(jamescook): Revert this after http://crbug.com/648964 is fixed.
804 if (!shelf_) 804 if (!shelf_)
805 return; 805 return;
806 806
807 const bool horizontal = IsHorizontalAlignment(shelf_->GetAlignment()); 807 const bool horizontal = shelf_->IsHorizontalAlignment();
808 for (PanelList::iterator iter = panel_windows_.begin(); 808 for (PanelList::iterator iter = panel_windows_.begin();
809 iter != panel_windows_.end(); ++iter) { 809 iter != panel_windows_.end(); ++iter) {
810 WmWindow* panel = iter->window; 810 WmWindow* panel = iter->window;
811 views::Widget* callout_widget = iter->callout_widget; 811 views::Widget* callout_widget = iter->callout_widget;
812 WmWindow* callout_widget_window = 812 WmWindow* callout_widget_window =
813 WmLookup::Get()->GetWindowForWidget(callout_widget); 813 WmLookup::Get()->GetWindowForWidget(callout_widget);
814 814
815 gfx::Rect current_bounds = panel->GetBoundsInScreen(); 815 gfx::Rect current_bounds = panel->GetBoundsInScreen();
816 gfx::Rect bounds = 816 gfx::Rect bounds =
817 panel->GetParent()->ConvertRectToScreen(panel->GetTargetBounds()); 817 panel->GetParent()->ConvertRectToScreen(panel->GetTargetBounds());
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
917 } 917 }
918 } 918 }
919 // This bounds change will have caused a change to the Shelf which does not 919 // This bounds change will have caused a change to the Shelf which does not
920 // propogate automatically to this class, so manually recalculate bounds. 920 // propogate automatically to this class, so manually recalculate bounds.
921 OnWindowResized(); 921 OnWindowResized();
922 } 922 }
923 923
924 void PanelLayoutManager::OnKeyboardClosed() {} 924 void PanelLayoutManager::OnKeyboardClosed() {}
925 925
926 } // namespace ash 926 } // namespace ash
OLDNEW
« no previous file with comments | « ash/common/shelf/shelf_widget.cc ('k') | ash/shelf/shelf_layout_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698