Index: chrome/browser/ui/panels/panel_strip.cc |
diff --git a/chrome/browser/ui/panels/panel_strip.cc b/chrome/browser/ui/panels/panel_strip.cc |
index d2cc30f6954df21e0a18ddc35e72bf04f24046cb..1f9d7358783dd567168a7afc325527f2951ba4b6 100644 |
--- a/chrome/browser/ui/panels/panel_strip.cc |
+++ b/chrome/browser/ui/panels/panel_strip.cc |
@@ -81,7 +81,7 @@ void PanelStrip::SetDisplayArea(const gfx::Rect& new_area) { |
} |
void PanelStrip::AddPanel(Panel* panel) { |
- DCHECK_NE(Panel::IN_OVERFLOW, panel->expansion_state()); |
+ DCHECK_NE(Panel::IN_OVERFLOW, panel->strip_owner()); |
// Always update limits, even for exiting panels, in case the maximums changed |
// while panel was out of the strip. |
@@ -99,10 +99,14 @@ void PanelStrip::AddPanel(Panel* panel) { |
int x; |
while ((x = GetRightMostAvailablePosition() - width) < display_area_.x()) { |
DCHECK(!panels_.empty()); |
- panels_.back()->SetExpansionState(Panel::IN_OVERFLOW); |
+ panels_.back()->SetStripOwner(Panel::IN_OVERFLOW); |
} |
int y = display_area_.bottom() - height; |
panel->SetPanelBounds(gfx::Rect(x, y, width, height)); |
+ |
+ if (panel->expansion_state() == Panel::TITLE_ONLY || |
jennb
2012/01/19 18:41:21
I expected to see this in the new On...Changed() h
|
+ panel->expansion_state() == Panel::MINIMIZED) |
+ IncrementMinimizedPanels(); |
} else { |
// Initialize the newly created panel. Does not bump any panels from strip. |
if (height == 0 && width == 0) { |
@@ -193,7 +197,7 @@ bool PanelStrip::Remove(Panel* panel) { |
// Don't rearrange the strip if a panel is being moved from the panel strip |
// to the overflow strip. |
- if (panel->expansion_state() != Panel::IN_OVERFLOW) |
+ if (panel->strip_owner() == Panel::DOCKED) |
Rearrange(); |
return true; |
@@ -351,34 +355,62 @@ void PanelStrip::EndDragging(bool cancelled) { |
DelayedRemove(); |
} |
-void PanelStrip::OnPanelExpansionStateChanged(Panel* panel) { |
- gfx::Size size = panel->restored_size(); |
+void PanelStrip::OnPanelStripOwnerChanged(Panel* panel, |
+ Panel::StripOwner old_owner) { |
+ Panel::StripOwner strip_owner = panel->strip_owner(); |
Panel::ExpansionState expansion_state = panel->expansion_state(); |
- Panel::ExpansionState old_state = panel->old_expansion_state(); |
- if (old_state == Panel::IN_OVERFLOW) { |
- panel_manager_->panel_overflow_strip()->Remove(panel); |
- AddPanel(panel); |
- panel->SetAppIconVisibility(true); |
- panel->set_draggable(true); |
+ switch (strip_owner) { |
+ case Panel::DOCKED: |
+ if (old_owner == Panel::IN_OVERFLOW) { |
+ panel_manager_->panel_overflow_strip()->Remove(panel); |
+ AddPanel(panel); |
+ panel->SetAppIconVisibility(true); |
+ panel->set_draggable(true); |
+ UpdateBoundsPerExpansionState(panel); |
+ } |
+ break; |
+ case Panel::DETACHED: |
+ case Panel::IN_OVERFLOW: |
+ DCHECK_EQ(Panel::DOCKED, old_owner); |
+ break; |
+ default: |
+ NOTREACHED(); |
+ break; |
+ } |
+} |
+ |
+void PanelStrip::OnPanelExpansionStateChanged(Panel* panel, |
+ Panel::ExpansionState old_state) { |
+ DCHECK_EQ(Panel::DOCKED, panel->strip_owner()); |
+ |
+ switch (panel->expansion_state()) { |
+ case Panel::EXPANDED: |
+ DecrementMinimizedPanels(); |
+ break; |
+ case Panel::TITLE_ONLY: |
+ case Panel::MINIMIZED: |
+ if (old_state == Panel::EXPANDED) |
+ IncrementMinimizedPanels(); |
+ break; |
+ default: |
+ NOTREACHED(); |
+ break; |
} |
+ |
+ UpdateBoundsPerExpansionState(panel); |
+} |
+ |
+void PanelStrip::UpdateBoundsPerExpansionState(Panel* panel) { |
+ gfx::Size size = panel->restored_size(); |
+ Panel::ExpansionState expansion_state = panel->expansion_state(); |
switch (expansion_state) { |
case Panel::EXPANDED: |
- if (old_state == Panel::TITLE_ONLY || old_state == Panel::MINIMIZED) |
- DecrementMinimizedPanels(); |
break; |
case Panel::TITLE_ONLY: |
size.set_height(panel->TitleOnlyHeight()); |
- if (old_state == Panel::EXPANDED || old_state == Panel::IN_OVERFLOW) |
- IncrementMinimizedPanels(); |
break; |
case Panel::MINIMIZED: |
size.set_height(Panel::kMinimizedPanelHeight); |
- if (old_state == Panel::EXPANDED || old_state == Panel::IN_OVERFLOW) |
- IncrementMinimizedPanels(); |
- break; |
- case Panel::IN_OVERFLOW: |
- if (old_state == Panel::TITLE_ONLY || old_state == Panel::MINIMIZED) |
- DecrementMinimizedPanels(); |
break; |
default: |
NOTREACHED(); |
@@ -433,16 +465,16 @@ void PanelStrip::OnWindowSizeChanged( |
// Only need to adjust bounds height when panel is expanded. |
gfx::Rect bounds = panel->GetBounds(); |
- Panel::ExpansionState expansion_state = panel->expansion_state(); |
if (new_height != bounds.height() && |
- expansion_state == Panel::EXPANDED) { |
+ panel->strip_owner() == Panel::DOCKED && |
+ panel->expansion_state() == Panel::EXPANDED) { |
bounds.set_y(bounds.bottom() - new_height); |
bounds.set_height(new_height); |
} |
// Only need to adjust width if panel is in the panel strip. |
int delta_x = bounds.width() - new_width; |
- if (delta_x != 0 && expansion_state != Panel::IN_OVERFLOW) { |
+ if (delta_x != 0 && panel->strip_owner() == Panel::DOCKED) { |
bounds.set_width(new_width); |
bounds.set_x(bounds.x() + delta_x); |
} |
@@ -657,7 +689,7 @@ void PanelStrip::Rearrange() { |
// Move panels to overflow in reverse to maintain their order. |
for (size_t overflow_index = panels_.size() - 1; |
overflow_index >= panel_index; --overflow_index) |
- panels_[overflow_index]->SetExpansionState(Panel::IN_OVERFLOW); |
+ panels_[overflow_index]->SetStripOwner(Panel::IN_OVERFLOW); |
} else { |
// Attempt to add more panels from overflow to the strip. |
PanelOverflowStrip* overflow_strip = panel_manager_->panel_overflow_strip(); |
@@ -667,13 +699,14 @@ void PanelStrip::Rearrange() { |
display_area_.x() + overflow_panel->restored_size().width()) { |
// We need to get back to the previous expansion state. |
Panel::ExpansionState expansion_state_to_restore = |
- overflow_panel->old_expansion_state(); |
+ overflow_panel->expansion_state(); |
if (expansion_state_to_restore == Panel::MINIMIZED || |
expansion_state_to_restore == Panel::TITLE_ONLY) { |
expansion_state_to_restore = are_titlebars_up_ ? Panel::TITLE_ONLY |
: Panel::MINIMIZED; |
} |
overflow_panel->SetExpansionState(expansion_state_to_restore); |
+ overflow_panel->SetStripOwner(Panel::DOCKED); |
} |
} |
#endif |
@@ -681,8 +714,8 @@ void PanelStrip::Rearrange() { |
void PanelStrip::DelayedMovePanelToOverflow(Panel* panel) { |
if (panels_in_temporary_layout_.erase(panel)) { |
- DCHECK(panel->has_temporary_layout()); |
- panel->SetExpansionState(Panel::IN_OVERFLOW); |
+ DCHECK(panel->has_temporary_layout()); |
+ panel->SetStripOwner(Panel::IN_OVERFLOW); |
} |
} |