| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/panel_strip.h" | 5 #include "chrome/browser/ui/panels/panel_strip.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 | 94 |
| 95 if (panel->initialized()) { | 95 if (panel->initialized()) { |
| 96 // Bump panels in the strip to make room for this panel. | 96 // Bump panels in the strip to make room for this panel. |
| 97 int x; | 97 int x; |
| 98 while ((x = GetRightMostAvailablePosition() - width) < display_area_.x()) { | 98 while ((x = GetRightMostAvailablePosition() - width) < display_area_.x()) { |
| 99 DCHECK(!panels_.empty()); | 99 DCHECK(!panels_.empty()); |
| 100 MovePanelToOverflow(panels_.back(), false); | 100 MovePanelToOverflow(panels_.back(), false); |
| 101 } | 101 } |
| 102 int y = display_area_.bottom() - height; | 102 int y = display_area_.bottom() - height; |
| 103 panel->SetPanelBounds(gfx::Rect(x, y, width, height)); | 103 panel->SetPanelBounds(gfx::Rect(x, y, width, height)); |
| 104 panel->SetExpansionState(Panel::EXPANDED); |
| 104 } else { | 105 } else { |
| 105 // Initialize the newly created panel. Does not bump any panels from strip. | 106 // Initialize the newly created panel. Does not bump any panels from strip. |
| 106 if (height == 0 && width == 0) { | 107 if (height == 0 && width == 0) { |
| 107 // Auto resizable is enabled only if no initial size is provided. | 108 // Auto resizable is enabled only if no initial size is provided. |
| 108 panel->SetAutoResizable(true); | 109 panel->SetAutoResizable(true); |
| 109 } else { | 110 } else { |
| 110 if (height == 0) | 111 if (height == 0) |
| 111 height = width / kPanelDefaultWidthToHeightRatio; | 112 height = width / kPanelDefaultWidthToHeightRatio; |
| 112 if (width == 0) | 113 if (width == 0) |
| 113 width = height * kPanelDefaultWidthToHeightRatio; | 114 width = height * kPanelDefaultWidthToHeightRatio; |
| (...skipping 28 matching lines...) Expand all Loading... |
| 142 base::Bind(&PanelStrip::MovePanelToOverflow, | 143 base::Bind(&PanelStrip::MovePanelToOverflow, |
| 143 base::Unretained(this), | 144 base::Unretained(this), |
| 144 panel, | 145 panel, |
| 145 true), // new panel | 146 true), // new panel |
| 146 delay_ms); | 147 delay_ms); |
| 147 } | 148 } |
| 148 #endif | 149 #endif |
| 149 panel->Initialize(gfx::Rect(x, y, width, height)); | 150 panel->Initialize(gfx::Rect(x, y, width, height)); |
| 150 } | 151 } |
| 151 | 152 |
| 153 DCHECK(panel->expansion_state() == Panel::EXPANDED); |
| 152 panels_.push_back(panel); | 154 panels_.push_back(panel); |
| 153 } | 155 } |
| 154 | 156 |
| 155 int PanelStrip::GetMaxPanelWidth() const { | 157 int PanelStrip::GetMaxPanelWidth() const { |
| 156 return static_cast<int>(display_area_.width() * kPanelMaxWidthFactor); | 158 return static_cast<int>(display_area_.width() * kPanelMaxWidthFactor); |
| 157 } | 159 } |
| 158 | 160 |
| 159 int PanelStrip::GetMaxPanelHeight() const { | 161 int PanelStrip::GetMaxPanelHeight() const { |
| 160 return display_area_.height(); | 162 return display_area_.height(); |
| 161 } | 163 } |
| (...skipping 489 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 651 | 653 |
| 652 // Start from the bottom to avoid reshuffling. | 654 // Start from the bottom to avoid reshuffling. |
| 653 for (Panels::reverse_iterator iter = panels_copy.rbegin(); | 655 for (Panels::reverse_iterator iter = panels_copy.rbegin(); |
| 654 iter != panels_copy.rend(); ++iter) | 656 iter != panels_copy.rend(); ++iter) |
| 655 (*iter)->Close(); | 657 (*iter)->Close(); |
| 656 } | 658 } |
| 657 | 659 |
| 658 bool PanelStrip::is_dragging_panel() const { | 660 bool PanelStrip::is_dragging_panel() const { |
| 659 return dragging_panel_index_ != kInvalidPanelIndex; | 661 return dragging_panel_index_ != kInvalidPanelIndex; |
| 660 } | 662 } |
| OLD | NEW |