| 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 "chrome/browser/ui/panels/docked_panel_strip.h" | 5 #include "chrome/browser/ui/panels/docked_panel_strip.h" | 
| 6 | 6 | 
| 7 #include <algorithm> | 7 #include <algorithm> | 
| 8 #include <vector> | 8 #include <vector> | 
| 9 | 9 | 
| 10 #include "base/auto_reset.h" | 10 #include "base/auto_reset.h" | 
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 92 | 92 | 
| 93   RefreshLayout(); | 93   RefreshLayout(); | 
| 94 } | 94 } | 
| 95 | 95 | 
| 96 void DockedPanelStrip::AddPanel(Panel* panel, | 96 void DockedPanelStrip::AddPanel(Panel* panel, | 
| 97                                 PositioningMask positioning_mask) { | 97                                 PositioningMask positioning_mask) { | 
| 98   // This method does not handle minimized panels. | 98   // This method does not handle minimized panels. | 
| 99   DCHECK_EQ(Panel::EXPANDED, panel->expansion_state()); | 99   DCHECK_EQ(Panel::EXPANDED, panel->expansion_state()); | 
| 100 | 100 | 
| 101   DCHECK_NE(this, panel->panel_strip()); | 101   DCHECK_NE(this, panel->panel_strip()); | 
| 102   panel->SetPanelStrip(this); | 102   panel->set_panel_strip(this); | 
| 103 | 103 | 
| 104   bool known_position = (positioning_mask & KNOWN_POSITION) != 0; | 104   bool known_position = (positioning_mask & KNOWN_POSITION) != 0; | 
| 105   bool update_bounds = (positioning_mask & DO_NOT_UPDATE_BOUNDS) == 0; | 105   bool update_bounds = (positioning_mask & DO_NOT_UPDATE_BOUNDS) == 0; | 
| 106 | 106 | 
| 107   if (!panel->initialized()) { | 107   if (!panel->initialized()) { | 
| 108     DCHECK(!known_position && update_bounds); | 108     DCHECK(!known_position && update_bounds); | 
| 109     InsertNewlyCreatedPanel(panel); | 109     InsertNewlyCreatedPanel(panel); | 
| 110   } else if (known_position) { | 110   } else if (known_position) { | 
| 111     DCHECK(update_bounds); | 111     DCHECK(update_bounds); | 
| 112     InsertExistingPanelAtKnownPosition(panel); | 112     InsertExistingPanelAtKnownPosition(panel); | 
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 210   return display_area_.right(); | 210   return display_area_.right(); | 
| 211 } | 211 } | 
| 212 | 212 | 
| 213 int DockedPanelStrip::GetRightMostAvailablePosition() const { | 213 int DockedPanelStrip::GetRightMostAvailablePosition() const { | 
| 214   return panels_.empty() ? StartingRightPosition() : | 214   return panels_.empty() ? StartingRightPosition() : | 
| 215       (panels_.back()->GetBounds().x() - kPanelsHorizontalSpacing); | 215       (panels_.back()->GetBounds().x() - kPanelsHorizontalSpacing); | 
| 216 } | 216 } | 
| 217 | 217 | 
| 218 void DockedPanelStrip::RemovePanel(Panel* panel) { | 218 void DockedPanelStrip::RemovePanel(Panel* panel) { | 
| 219   DCHECK_EQ(this, panel->panel_strip()); | 219   DCHECK_EQ(this, panel->panel_strip()); | 
| 220   panel->SetPanelStrip(NULL); | 220   panel->set_panel_strip(NULL); | 
| 221 | 221 | 
| 222   // Removing an element from the list will invalidate the iterator that refers | 222   // Removing an element from the list will invalidate the iterator that refers | 
| 223   // to it. We need to update the iterator in that case. | 223   // to it. We need to update the iterator in that case. | 
| 224   DCHECK(dragging_panel_current_iterator_ == panels_.end() || | 224   DCHECK(dragging_panel_current_iterator_ == panels_.end() || | 
| 225          *dragging_panel_current_iterator_ != panel); | 225          *dragging_panel_current_iterator_ != panel); | 
| 226 | 226 | 
| 227   // Optimize for the common case of removing the last panel. | 227   // Optimize for the common case of removing the last panel. | 
| 228   DCHECK(!panels_.empty()); | 228   DCHECK(!panels_.empty()); | 
| 229   if (panels_.back() == panel) { | 229   if (panels_.back() == panel) { | 
| 230     panels_.pop_back(); | 230     panels_.pop_back(); | 
| (...skipping 645 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 876   // Update limits if the panel is still autosizable, in case the limit has | 876   // Update limits if the panel is still autosizable, in case the limit has | 
| 877   // changed. If the panel is not autoresizable, then it was resized | 877   // changed. If the panel is not autoresizable, then it was resized | 
| 878   // by the user or by the app via API. | 878   // by the user or by the app via API. | 
| 879   if (panel->auto_resizable()) { | 879   if (panel->auto_resizable()) { | 
| 880     int max_panel_width = GetMaxPanelWidth(); | 880     int max_panel_width = GetMaxPanelWidth(); | 
| 881     int max_panel_height = GetMaxPanelHeight(); | 881     int max_panel_height = GetMaxPanelHeight(); | 
| 882     panel->SetSizeRange(gfx::Size(kPanelMinWidth, kPanelMinHeight), | 882     panel->SetSizeRange(gfx::Size(kPanelMinWidth, kPanelMinHeight), | 
| 883                         gfx::Size(max_panel_width, max_panel_height)); | 883                         gfx::Size(max_panel_width, max_panel_height)); | 
| 884   } | 884   } | 
| 885   panel->set_attention_mode(Panel::USE_PANEL_ATTENTION); | 885   panel->set_attention_mode(Panel::USE_PANEL_ATTENTION); | 
| 886   panel->SetAppIconVisibility(true); |  | 
| 887   panel->SetAlwaysOnTop(true); | 886   panel->SetAlwaysOnTop(true); | 
| 888   panel->EnableResizeByMouse(true); | 887   panel->EnableResizeByMouse(true); | 
|  | 888   panel->UpdateTitlebarButtons(); | 
| 889 } | 889 } | 
| 890 | 890 | 
| 891 void DockedPanelStrip::OnPanelActiveStateChanged(Panel* panel) { | 891 void DockedPanelStrip::OnPanelActiveStateChanged(Panel* panel) { | 
| 892   // Refresh layout, but wait till active states settle. | 892   // Refresh layout, but wait till active states settle. | 
| 893   // This lets us avoid refreshing too many times when one panel loses | 893   // This lets us avoid refreshing too many times when one panel loses | 
| 894   // focus and another gains it. | 894   // focus and another gains it. | 
| 895   refresh_action_factory_.InvalidateWeakPtrs(); | 895   refresh_action_factory_.InvalidateWeakPtrs(); | 
| 896   MessageLoop::current()->PostDelayedTask( | 896   MessageLoop::current()->PostDelayedTask( | 
| 897       FROM_HERE, | 897       FROM_HERE, | 
| 898       base::Bind(&DockedPanelStrip::RefreshLayout, | 898       base::Bind(&DockedPanelStrip::RefreshLayout, | 
| 899           refresh_action_factory_.GetWeakPtr()), | 899           refresh_action_factory_.GetWeakPtr()), | 
| 900       base::TimeDelta::FromMilliseconds(PanelManager::AdjustTimeInterval( | 900       base::TimeDelta::FromMilliseconds(PanelManager::AdjustTimeInterval( | 
| 901           kRefreshLayoutAfterActivePanelChangeDelayMs))); | 901           kRefreshLayoutAfterActivePanelChangeDelayMs))); | 
| 902 } | 902 } | 
| 903 | 903 | 
| 904 bool DockedPanelStrip::HasPanel(Panel* panel) const { | 904 bool DockedPanelStrip::HasPanel(Panel* panel) const { | 
| 905   return find(panels_.begin(), panels_.end(), panel) != panels_.end(); | 905   return find(panels_.begin(), panels_.end(), panel) != panels_.end(); | 
| 906 } | 906 } | 
| OLD | NEW | 
|---|