| 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..1d738501d21d0d71080b1bf06e581b7fc75125bb 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->layout_state());
|
|
|
| // Always update limits, even for exiting panels, in case the maximums changed
|
| // while panel was out of the strip.
|
| @@ -99,10 +99,13 @@ 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()->SetLayoutState(Panel::IN_OVERFLOW);
|
| }
|
| int y = display_area_.bottom() - height;
|
| panel->SetPanelBounds(gfx::Rect(x, y, width, height));
|
| +
|
| + if (panel->expansion_state() != Panel::EXPANDED)
|
| + IncrementMinimizedPanels();
|
| } else {
|
| // Initialize the newly created panel. Does not bump any panels from strip.
|
| if (height == 0 && width == 0) {
|
| @@ -193,7 +196,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->layout_state() == Panel::DOCKED)
|
| Rearrange();
|
|
|
| return true;
|
| @@ -211,8 +214,7 @@ bool PanelStrip::DoRemove(Panel* panel) {
|
| if (iter == panels_.end())
|
| return false;
|
|
|
| - if (panel->expansion_state() == Panel::TITLE_ONLY ||
|
| - panel->expansion_state() == Panel::MINIMIZED)
|
| + if (panel->expansion_state() != Panel::EXPANDED)
|
| DecrementMinimizedPanels();
|
|
|
| panels_.erase(iter);
|
| @@ -351,34 +353,61 @@ void PanelStrip::EndDragging(bool cancelled) {
|
| DelayedRemove();
|
| }
|
|
|
| -void PanelStrip::OnPanelExpansionStateChanged(Panel* panel) {
|
| +void PanelStrip::OnPanelLayoutStateChanged(Panel* panel,
|
| + Panel::LayoutState old_state) {
|
| + Panel::LayoutState layout_state = panel->layout_state();
|
| + switch (layout_state) {
|
| + case Panel::DOCKED:
|
| + if (old_state == 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_state);
|
| + break;
|
| + default:
|
| + NOTREACHED();
|
| + break;
|
| + }
|
| +}
|
| +
|
| +void PanelStrip::OnPanelExpansionStateChanged(Panel* panel,
|
| + Panel::ExpansionState old_state) {
|
| + DCHECK_EQ(Panel::DOCKED, panel->layout_state());
|
| +
|
| + 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();
|
| - 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 (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();
|
| @@ -431,27 +460,34 @@ void PanelStrip::OnWindowSizeChanged(
|
| if (new_size != panel->restored_size())
|
| panel->set_restored_size(new_size);
|
|
|
| - // Only need to adjust bounds height when panel is expanded.
|
| + Panel::LayoutState layout_state = panel->layout_state();
|
| gfx::Rect bounds = panel->GetBounds();
|
| - Panel::ExpansionState expansion_state = panel->expansion_state();
|
| - if (new_height != bounds.height() &&
|
| - 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) {
|
| - bounds.set_width(new_width);
|
| - bounds.set_x(bounds.x() + delta_x);
|
| - }
|
|
|
| - if (bounds != panel->GetBounds())
|
| - panel->SetPanelBounds(bounds);
|
| + // Only need to update bounds when the panel is docked or detached.
|
| + if (layout_state != Panel::IN_OVERFLOW) {
|
| + // Height is only affected when panel is expanded.
|
| + if (new_height != bounds.height() &&
|
| + panel->expansion_state() == Panel::EXPANDED) {
|
| + bounds.set_y(bounds.bottom() - new_height);
|
| + bounds.set_height(new_height);
|
| + }
|
| +
|
| + if (delta_x != 0) {
|
| + bounds.set_width(new_width);
|
| + bounds.set_x(bounds.x() + delta_x);
|
| + }
|
| +
|
| + if (bounds != panel->GetBounds())
|
| + panel->SetPanelBounds(bounds);
|
| + }
|
|
|
| - // Only need to rearrange if panel's width changed.
|
| - if (delta_x != 0)
|
| + // If the panel is docked, rearrange if panel's width is changed.
|
| + // If the panel is in overflow, rearrange if panel's width is smaller because
|
| + // we might have sufficient space in the docking area to fit the shrunken
|
| + // overflow panel.
|
| + if ((layout_state == Panel::DOCKED && delta_x != 0) ||
|
| + (layout_state == Panel::IN_OVERFLOW && delta_x < 0))
|
| Rearrange();
|
| }
|
|
|
| @@ -657,7 +693,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]->SetLayoutState(Panel::IN_OVERFLOW);
|
| } else {
|
| // Attempt to add more panels from overflow to the strip.
|
| PanelOverflowStrip* overflow_strip = panel_manager_->panel_overflow_strip();
|
| @@ -667,12 +703,12 @@ 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();
|
| - if (expansion_state_to_restore == Panel::MINIMIZED ||
|
| - expansion_state_to_restore == Panel::TITLE_ONLY) {
|
| + overflow_panel->expansion_state();
|
| + if (expansion_state_to_restore != Panel::EXPANDED) {
|
| expansion_state_to_restore = are_titlebars_up_ ? Panel::TITLE_ONLY
|
| : Panel::MINIMIZED;
|
| }
|
| + overflow_panel->SetLayoutState(Panel::DOCKED);
|
| overflow_panel->SetExpansionState(expansion_state_to_restore);
|
| }
|
| }
|
| @@ -681,8 +717,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->SetLayoutState(Panel::IN_OVERFLOW);
|
| }
|
| }
|
|
|
|
|