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/overflow_panel_strip.h" | 5 #include "chrome/browser/ui/panels/overflow_panel_strip.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "chrome/browser/ui/panels/panel_manager.h" | 8 #include "chrome/browser/ui/panels/panel_manager.h" |
9 #include "chrome/browser/ui/panels/panel_mouse_watcher.h" | 9 #include "chrome/browser/ui/panels/panel_mouse_watcher.h" |
10 #include "chrome/browser/ui/panels/panel_overflow_indicator.h" | 10 #include "chrome/browser/ui/panels/panel_overflow_indicator.h" |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 if (panel->has_temporary_layout()) { | 92 if (panel->has_temporary_layout()) { |
93 panel->set_has_temporary_layout(false); | 93 panel->set_has_temporary_layout(false); |
94 panels_.push_back(panel); | 94 panels_.push_back(panel); |
95 DoRefresh(panels_.size() - 1, panels_.size() - 1); | 95 DoRefresh(panels_.size() - 1, panels_.size() - 1); |
96 } else { | 96 } else { |
97 panels_.insert(panels_.begin(), panel); | 97 panels_.insert(panels_.begin(), panel); |
98 RefreshLayout(); | 98 RefreshLayout(); |
99 } | 99 } |
100 | 100 |
101 if (num_panels() == 1) { | 101 if (num_panels() == 1) { |
102 if (!panel_manager_->is_full_screen()) | 102 if (!panel_manager_->display_settings_provider()->is_full_screen()) |
103 panel_manager_->mouse_watcher()->AddObserver(this); | 103 panel_manager_->mouse_watcher()->AddObserver(this); |
104 UpdateMaxVisiblePanelsOnHover(); | 104 UpdateMaxVisiblePanelsOnHover(); |
105 } | 105 } |
106 | 106 |
107 // Update the overflow indicator only when the number of overflow panels go | 107 // Update the overflow indicator only when the number of overflow panels go |
108 // beyond the maximum visible limit. | 108 // beyond the maximum visible limit. |
109 if (num_panels() > max_visible_panels_) { | 109 if (num_panels() > max_visible_panels_) { |
110 if (!overflow_indicator_.get()) { | 110 if (!overflow_indicator_.get()) { |
111 overflow_indicator_.reset(PanelOverflowIndicator::Create()); | 111 overflow_indicator_.reset(PanelOverflowIndicator::Create()); |
112 } | 112 } |
113 UpdateOverflowIndicatorCount(); | 113 UpdateOverflowIndicatorCount(); |
114 } | 114 } |
115 } | 115 } |
116 | 116 |
117 void OverflowPanelStrip::RemovePanel(Panel* panel) { | 117 void OverflowPanelStrip::RemovePanel(Panel* panel) { |
118 DCHECK_EQ(this, panel->panel_strip()); | 118 DCHECK_EQ(this, panel->panel_strip()); |
119 panel->SetPanelStrip(NULL); | 119 panel->SetPanelStrip(NULL); |
120 | 120 |
121 size_t index = 0; | 121 size_t index = 0; |
122 Panels::iterator iter = panels_.begin(); | 122 Panels::iterator iter = panels_.begin(); |
123 for (; iter != panels_.end(); ++iter, ++index) | 123 for (; iter != panels_.end(); ++iter, ++index) |
124 if (*iter == panel) | 124 if (*iter == panel) |
125 break; | 125 break; |
126 DCHECK(iter != panels_.end()); | 126 DCHECK(iter != panels_.end()); |
127 | 127 |
128 panels_.erase(iter); | 128 panels_.erase(iter); |
129 DoRefresh(index, panels_.size() - 1); | 129 DoRefresh(index, panels_.size() - 1); |
130 | 130 |
131 if (panels_.empty() && !panel_manager_->is_full_screen()) | 131 if (panels_.empty() && |
| 132 !panel_manager_->display_settings_provider()->is_full_screen()) |
132 panel_manager_->mouse_watcher()->RemoveObserver(this); | 133 panel_manager_->mouse_watcher()->RemoveObserver(this); |
133 | 134 |
134 // Update the overflow indicator. If the number of overflow panels fall below | 135 // Update the overflow indicator. If the number of overflow panels fall below |
135 // the maximum visible limit, we do not need the overflow indicator any more. | 136 // the maximum visible limit, we do not need the overflow indicator any more. |
136 if (num_panels() < max_visible_panels_) | 137 if (num_panels() < max_visible_panels_) |
137 overflow_indicator_.reset(); | 138 overflow_indicator_.reset(); |
138 else | 139 else |
139 UpdateOverflowIndicatorCount(); | 140 UpdateOverflowIndicatorCount(); |
140 } | 141 } |
141 | 142 |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
335 return bounds; | 336 return bounds; |
336 } | 337 } |
337 | 338 |
338 void OverflowPanelStrip::OnMouseMove(const gfx::Point& mouse_position) { | 339 void OverflowPanelStrip::OnMouseMove(const gfx::Point& mouse_position) { |
339 bool show_overflow_titles = ShouldShowOverflowTitles(mouse_position); | 340 bool show_overflow_titles = ShouldShowOverflowTitles(mouse_position); |
340 ShowOverflowTitles(show_overflow_titles); | 341 ShowOverflowTitles(show_overflow_titles); |
341 } | 342 } |
342 | 343 |
343 bool OverflowPanelStrip::ShouldShowOverflowTitles( | 344 bool OverflowPanelStrip::ShouldShowOverflowTitles( |
344 const gfx::Point& mouse_position) const { | 345 const gfx::Point& mouse_position) const { |
345 if (panels_.empty() || panel_manager_->is_full_screen()) | 346 if (panels_.empty() || |
| 347 panel_manager_->display_settings_provider()->is_full_screen()) |
346 return false; | 348 return false; |
347 | 349 |
348 Panel* top_visible_panel = num_panels() >= max_visible_panels() ? | 350 Panel* top_visible_panel = num_panels() >= max_visible_panels() ? |
349 panels_[max_visible_panels() - 1] : panels_.back(); | 351 panels_[max_visible_panels() - 1] : panels_.back(); |
350 return mouse_position.x() <= display_area_.x() + current_display_width_ && | 352 return mouse_position.x() <= display_area_.x() + current_display_width_ && |
351 top_visible_panel->GetBounds().y() <= mouse_position.y() && | 353 top_visible_panel->GetBounds().y() <= mouse_position.y() && |
352 mouse_position.y() <= display_area_.bottom(); | 354 mouse_position.y() <= display_area_.bottom(); |
353 } | 355 } |
354 | 356 |
355 void OverflowPanelStrip::ShowOverflowTitles(bool show_overflow_titles) { | 357 void OverflowPanelStrip::ShowOverflowTitles(bool show_overflow_titles) { |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
451 panels_[i]->FullScreenModeChanged(is_full_screen); | 453 panels_[i]->FullScreenModeChanged(is_full_screen); |
452 } | 454 } |
453 | 455 |
454 void OverflowPanelStrip::UpdatePanelOnStripChange(Panel* panel) { | 456 void OverflowPanelStrip::UpdatePanelOnStripChange(Panel* panel) { |
455 // Set panel properties for this strip. | 457 // Set panel properties for this strip. |
456 panel->set_attention_mode(Panel::USE_PANEL_ATTENTION); | 458 panel->set_attention_mode(Panel::USE_PANEL_ATTENTION); |
457 panel->SetAppIconVisibility(false); | 459 panel->SetAppIconVisibility(false); |
458 panel->SetAlwaysOnTop(true); | 460 panel->SetAlwaysOnTop(true); |
459 panel->EnableResizeByMouse(false); | 461 panel->EnableResizeByMouse(false); |
460 } | 462 } |
OLD | NEW |