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_->display_settings_provider()->is_full_screen()) | 102 if (!panel_manager_->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() && | 131 if (panels_.empty() && !panel_manager_->is_full_screen()) |
132 !panel_manager_->display_settings_provider()->is_full_screen()) | |
133 panel_manager_->mouse_watcher()->RemoveObserver(this); | 132 panel_manager_->mouse_watcher()->RemoveObserver(this); |
134 | 133 |
135 // Update the overflow indicator. If the number of overflow panels fall below | 134 // Update the overflow indicator. If the number of overflow panels fall below |
136 // the maximum visible limit, we do not need the overflow indicator any more. | 135 // the maximum visible limit, we do not need the overflow indicator any more. |
137 if (num_panels() < max_visible_panels_) | 136 if (num_panels() < max_visible_panels_) |
138 overflow_indicator_.reset(); | 137 overflow_indicator_.reset(); |
139 else | 138 else |
140 UpdateOverflowIndicatorCount(); | 139 UpdateOverflowIndicatorCount(); |
141 } | 140 } |
142 | 141 |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
336 return bounds; | 335 return bounds; |
337 } | 336 } |
338 | 337 |
339 void OverflowPanelStrip::OnMouseMove(const gfx::Point& mouse_position) { | 338 void OverflowPanelStrip::OnMouseMove(const gfx::Point& mouse_position) { |
340 bool show_overflow_titles = ShouldShowOverflowTitles(mouse_position); | 339 bool show_overflow_titles = ShouldShowOverflowTitles(mouse_position); |
341 ShowOverflowTitles(show_overflow_titles); | 340 ShowOverflowTitles(show_overflow_titles); |
342 } | 341 } |
343 | 342 |
344 bool OverflowPanelStrip::ShouldShowOverflowTitles( | 343 bool OverflowPanelStrip::ShouldShowOverflowTitles( |
345 const gfx::Point& mouse_position) const { | 344 const gfx::Point& mouse_position) const { |
346 if (panels_.empty() || | 345 if (panels_.empty() || panel_manager_->is_full_screen()) |
347 panel_manager_->display_settings_provider()->is_full_screen()) | |
348 return false; | 346 return false; |
349 | 347 |
350 Panel* top_visible_panel = num_panels() >= max_visible_panels() ? | 348 Panel* top_visible_panel = num_panels() >= max_visible_panels() ? |
351 panels_[max_visible_panels() - 1] : panels_.back(); | 349 panels_[max_visible_panels() - 1] : panels_.back(); |
352 return mouse_position.x() <= display_area_.x() + current_display_width_ && | 350 return mouse_position.x() <= display_area_.x() + current_display_width_ && |
353 top_visible_panel->GetBounds().y() <= mouse_position.y() && | 351 top_visible_panel->GetBounds().y() <= mouse_position.y() && |
354 mouse_position.y() <= display_area_.bottom(); | 352 mouse_position.y() <= display_area_.bottom(); |
355 } | 353 } |
356 | 354 |
357 void OverflowPanelStrip::ShowOverflowTitles(bool show_overflow_titles) { | 355 void OverflowPanelStrip::ShowOverflowTitles(bool show_overflow_titles) { |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
453 panels_[i]->FullScreenModeChanged(is_full_screen); | 451 panels_[i]->FullScreenModeChanged(is_full_screen); |
454 } | 452 } |
455 | 453 |
456 void OverflowPanelStrip::UpdatePanelOnStripChange(Panel* panel) { | 454 void OverflowPanelStrip::UpdatePanelOnStripChange(Panel* panel) { |
457 // Set panel properties for this strip. | 455 // Set panel properties for this strip. |
458 panel->set_attention_mode(Panel::USE_PANEL_ATTENTION); | 456 panel->set_attention_mode(Panel::USE_PANEL_ATTENTION); |
459 panel->SetAppIconVisibility(false); | 457 panel->SetAppIconVisibility(false); |
460 panel->SetAlwaysOnTop(true); | 458 panel->SetAlwaysOnTop(true); |
461 panel->EnableResizeByMouse(false); | 459 panel->EnableResizeByMouse(false); |
462 } | 460 } |
OLD | NEW |