Chromium Code Reviews| 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 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 133 height = max_panel_height; | 133 height = max_panel_height; |
| 134 | 134 |
| 135 panel->set_restored_size(gfx::Size(width, height)); | 135 panel->set_restored_size(gfx::Size(width, height)); |
| 136 int x = GetRightMostAvailablePosition() - width; | 136 int x = GetRightMostAvailablePosition() - width; |
| 137 int y = display_area_.bottom() - height; | 137 int y = display_area_.bottom() - height; |
| 138 | 138 |
| 139 // Keep panel visible in the strip even if overlap would occur. | 139 // Keep panel visible in the strip even if overlap would occur. |
| 140 // Panel is moved to overflow from the strip after a delay. | 140 // Panel is moved to overflow from the strip after a delay. |
| 141 // TODO(jianli): remove the guard when overflow support is enabled on other | 141 // TODO(jianli): remove the guard when overflow support is enabled on other |
| 142 // platforms. http://crbug.com/105073 | 142 // platforms. http://crbug.com/105073 |
| 143 #if defined(OS_WIN) | 143 #if defined(OS_WIN) || defined(OS_MACOSX) |
| 144 if (x < display_area_.x()) { | 144 if (x < display_area_.x()) { |
| 145 x = display_area_.x(); | 145 x = display_area_.x(); |
| 146 panel->set_has_temporary_layout(true); | 146 panel->set_has_temporary_layout(true); |
| 147 panel->set_draggable(false); | 147 panel->set_draggable(false); |
| 148 MessageLoop::current()->PostDelayedTask( | 148 MessageLoop::current()->PostDelayedTask( |
| 149 FROM_HERE, | 149 FROM_HERE, |
| 150 base::Bind(&DockedPanelStrip::DelayedMovePanelToOverflow, | 150 base::Bind(&DockedPanelStrip::DelayedMovePanelToOverflow, |
| 151 base::Unretained(this), | 151 base::Unretained(this), |
| 152 panel), | 152 panel), |
| 153 base::TimeDelta::FromMilliseconds(PanelManager::AdjustTimeInterval( | 153 base::TimeDelta::FromMilliseconds(PanelManager::AdjustTimeInterval( |
| 154 kMoveNewPanelToOverflowDelayMs))); | 154 kMoveNewPanelToOverflowDelayMs))); |
| 155 } | 155 } |
| 156 #endif | 156 #endif |
| 157 panel->Initialize(gfx::Rect(x, y, width, height)); | 157 panel->Initialize(gfx::Rect(x, y, width, height)); |
| 158 } | 158 } |
| 159 | 159 |
| 160 panel->ApplyVisualStyleForStrip(DOCKED_STRIP); | |
| 161 | |
| 160 if (panel->has_temporary_layout()) | 162 if (panel->has_temporary_layout()) |
| 161 panels_in_temporary_layout_.insert(panel); | 163 panels_in_temporary_layout_.insert(panel); |
| 162 else | 164 else |
| 163 panels_.push_back(panel); | 165 panels_.push_back(panel); |
| 164 } | 166 } |
| 165 | 167 |
| 166 int DockedPanelStrip::GetMaxPanelWidth() const { | 168 int DockedPanelStrip::GetMaxPanelWidth() const { |
| 167 return static_cast<int>(display_area_.width() * kPanelMaxWidthFactor); | 169 return static_cast<int>(display_area_.width() * kPanelMaxWidthFactor); |
| 168 } | 170 } |
| 169 | 171 |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 354 | 356 |
| 355 dragging_panel_index_ = kInvalidPanelIndex; | 357 dragging_panel_index_ = kInvalidPanelIndex; |
| 356 | 358 |
| 357 DelayedRemove(); | 359 DelayedRemove(); |
| 358 } | 360 } |
| 359 | 361 |
| 360 void DockedPanelStrip::OnPanelExpansionStateChanged(Panel* panel) { | 362 void DockedPanelStrip::OnPanelExpansionStateChanged(Panel* panel) { |
| 361 gfx::Size size = panel->restored_size(); | 363 gfx::Size size = panel->restored_size(); |
| 362 Panel::ExpansionState expansion_state = panel->expansion_state(); | 364 Panel::ExpansionState expansion_state = panel->expansion_state(); |
| 363 Panel::ExpansionState old_state = panel->old_expansion_state(); | 365 Panel::ExpansionState old_state = panel->old_expansion_state(); |
| 364 if (old_state == Panel::IN_OVERFLOW) { | 366 if (old_state == Panel::IN_OVERFLOW) { |
|
jennb
2012/02/07 00:15:31
Note that we do a lot of adjustments for a state c
Dmitry Titov
2012/02/07 00:28:26
I think we'll change this soon because going from
jennb
2012/02/07 00:50:31
The plan is to have Panel::MoveToStrip(new_strip).
| |
| 365 panel_manager_->overflow_strip()->Remove(panel); | 367 panel_manager_->overflow_strip()->Remove(panel); |
| 366 AddPanel(panel); | 368 AddPanel(panel); |
| 367 panel->SetAppIconVisibility(true); | 369 panel->SetAppIconVisibility(true); |
| 368 panel->set_draggable(true); | 370 panel->set_draggable(true); |
| 369 } | 371 } |
| 370 switch (expansion_state) { | 372 switch (expansion_state) { |
| 371 case Panel::EXPANDED: | 373 case Panel::EXPANDED: |
| 372 if (old_state == Panel::TITLE_ONLY || old_state == Panel::MINIMIZED) | 374 if (old_state == Panel::TITLE_ONLY || old_state == Panel::MINIMIZED) |
| 373 DecrementMinimizedPanels(); | 375 DecrementMinimizedPanels(); |
| 374 break; | 376 break; |
| (...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 646 int rightmost_position = StartingRightPosition(); | 648 int rightmost_position = StartingRightPosition(); |
| 647 | 649 |
| 648 size_t panel_index = 0; | 650 size_t panel_index = 0; |
| 649 for (; panel_index < panels_.size(); ++panel_index) { | 651 for (; panel_index < panels_.size(); ++panel_index) { |
| 650 Panel* panel = panels_[panel_index]; | 652 Panel* panel = panels_[panel_index]; |
| 651 gfx::Rect new_bounds(panel->GetBounds()); | 653 gfx::Rect new_bounds(panel->GetBounds()); |
| 652 int x = rightmost_position - new_bounds.width(); | 654 int x = rightmost_position - new_bounds.width(); |
| 653 | 655 |
| 654 // TODO(jianli): remove the guard when overflow support is enabled on other | 656 // TODO(jianli): remove the guard when overflow support is enabled on other |
| 655 // platforms. http://crbug.com/105073 | 657 // platforms. http://crbug.com/105073 |
| 656 #if defined(OS_WIN) | 658 #if defined(OS_WIN) || defined(OS_MACOSX) |
| 657 if (x < display_area_.x()) | 659 if (x < display_area_.x()) |
| 658 break; | 660 break; |
| 659 #endif | 661 #endif |
| 660 | 662 |
| 661 new_bounds.set_x(x); | 663 new_bounds.set_x(x); |
| 662 new_bounds.set_y( | 664 new_bounds.set_y( |
| 663 GetBottomPositionForExpansionState(panel->expansion_state()) - | 665 GetBottomPositionForExpansionState(panel->expansion_state()) - |
| 664 new_bounds.height()); | 666 new_bounds.height()); |
| 665 panel->SetPanelBounds(new_bounds); | 667 panel->SetPanelBounds(new_bounds); |
| 666 | 668 |
| 667 rightmost_position = new_bounds.x() - kPanelsHorizontalSpacing; | 669 rightmost_position = new_bounds.x() - kPanelsHorizontalSpacing; |
| 668 } | 670 } |
| 669 | 671 |
| 670 // TODO(jianli): remove the guard when overflow support is enabled on other | 672 // TODO(jianli): remove the guard when overflow support is enabled on other |
| 671 // platforms. http://crbug.com/105073 | 673 // platforms. http://crbug.com/105073 |
| 672 #if defined(OS_WIN) | 674 #if defined(OS_WIN) || defined(OS_MACOSX) |
| 673 // Add/remove panels from/to overflow. A change in work area or the | 675 // Add/remove panels from/to overflow. A change in work area or the |
| 674 // resize/removal of a panel may affect how many panels fit in the strip. | 676 // resize/removal of a panel may affect how many panels fit in the strip. |
| 675 if (panel_index < panels_.size()) { | 677 if (panel_index < panels_.size()) { |
| 676 // Move panels to overflow in reverse to maintain their order. | 678 // Move panels to overflow in reverse to maintain their order. |
| 677 for (size_t overflow_index = panels_.size() - 1; | 679 for (size_t overflow_index = panels_.size() - 1; |
| 678 overflow_index >= panel_index; --overflow_index) | 680 overflow_index >= panel_index; --overflow_index) |
| 679 panels_[overflow_index]->SetExpansionState(Panel::IN_OVERFLOW); | 681 panels_[overflow_index]->SetExpansionState(Panel::IN_OVERFLOW); |
| 680 } else { | 682 } else { |
| 681 // Attempt to add more panels from overflow to the strip. | 683 // Attempt to add more panels from overflow to the strip. |
| 682 OverflowPanelStrip* overflow_strip = panel_manager_->overflow_strip(); | 684 OverflowPanelStrip* overflow_strip = panel_manager_->overflow_strip(); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 715 | 717 |
| 716 // Start from the bottom to avoid reshuffling. | 718 // Start from the bottom to avoid reshuffling. |
| 717 for (Panels::reverse_iterator iter = panels_copy.rbegin(); | 719 for (Panels::reverse_iterator iter = panels_copy.rbegin(); |
| 718 iter != panels_copy.rend(); ++iter) | 720 iter != panels_copy.rend(); ++iter) |
| 719 (*iter)->Close(); | 721 (*iter)->Close(); |
| 720 } | 722 } |
| 721 | 723 |
| 722 bool DockedPanelStrip::is_dragging_panel() const { | 724 bool DockedPanelStrip::is_dragging_panel() const { |
| 723 return dragging_panel_index_ != kInvalidPanelIndex; | 725 return dragging_panel_index_ != kInvalidPanelIndex; |
| 724 } | 726 } |
| OLD | NEW |