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 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 // platforms. http://crbug.com/105073 | 135 // platforms. http://crbug.com/105073 |
136 #if defined(OS_WIN) | 136 #if defined(OS_WIN) |
137 if (x < display_area_.x()) { | 137 if (x < display_area_.x()) { |
138 x = display_area_.x(); | 138 x = display_area_.x(); |
139 panel->set_has_temporary_layout(true); | 139 panel->set_has_temporary_layout(true); |
140 MessageLoop::current()->PostDelayedTask( | 140 MessageLoop::current()->PostDelayedTask( |
141 FROM_HERE, | 141 FROM_HERE, |
142 base::Bind(&PanelStrip::DelayedMovePanelToOverflow, | 142 base::Bind(&PanelStrip::DelayedMovePanelToOverflow, |
143 base::Unretained(this), | 143 base::Unretained(this), |
144 panel), | 144 panel), |
145 kMoveNewPanelToOverflowDelayMilliseconds); | 145 PanelManager::AdjustTimeInterval( |
| 146 kMoveNewPanelToOverflowDelayMilliseconds)); |
146 } | 147 } |
147 #endif | 148 #endif |
148 panel->Initialize(gfx::Rect(x, y, width, height)); | 149 panel->Initialize(gfx::Rect(x, y, width, height)); |
149 } | 150 } |
150 | 151 |
151 panels_.push_back(panel); | 152 panels_.push_back(panel); |
152 } | 153 } |
153 | 154 |
154 int PanelStrip::GetMaxPanelWidth() const { | 155 int PanelStrip::GetMaxPanelWidth() const { |
155 return static_cast<int>(display_area_.width() * kPanelMaxWidthFactor); | 156 return static_cast<int>(display_area_.width() * kPanelMaxWidthFactor); |
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
491 // Thus, we schedule a delayed task to do the work if we do not receive | 492 // Thus, we schedule a delayed task to do the work if we do not receive |
492 // the bottom bar visibility change notification within a certain period | 493 // the bottom bar visibility change notification within a certain period |
493 // of time. | 494 // of time. |
494 task_delay_milliseconds = | 495 task_delay_milliseconds = |
495 kMaxMillisecondsWaitForBottomBarVisibilityChange; | 496 kMaxMillisecondsWaitForBottomBarVisibilityChange; |
496 } | 497 } |
497 } | 498 } |
498 | 499 |
499 // On some OSes, the interaction with native Taskbars/Docks may be improved | 500 // On some OSes, the interaction with native Taskbars/Docks may be improved |
500 // if the panels do not go back to minimized state too fast. For example, | 501 // if the panels do not go back to minimized state too fast. For example, |
501 // it makes it possible to hit the titlebar on OSX if Dock has Magnifying | 502 // with a taskbar in auto-hide mode, the taskbar will cover the panel in |
502 // enabled - the panels stay up for a while after Dock magnification effect | 503 // title-only mode which appears on hover. Leaving it up for a little longer |
503 // stops covering the panels. | 504 // would allow the user to be able to click on it. |
504 // | |
505 // Another example would be taskbar in auto-hide mode on Linux. In this mode | |
506 // taskbar will cover the panel in title hover mode, leaving it up for a few | |
507 // seconds would allow the user to be able to click on it. | |
508 // | 505 // |
509 // Currently, no platforms use both delays. | 506 // Currently, no platforms use both delays. |
510 DCHECK(task_delay_milliseconds == 0); | 507 DCHECK(task_delay_milliseconds == 0); |
511 if (!bring_up) | 508 if (!bring_up) |
512 task_delay_milliseconds = kMillisecondsBeforeCollapsingFromTitleOnlyState; | 509 task_delay_milliseconds = kMillisecondsBeforeCollapsingFromTitleOnlyState; |
513 | 510 |
514 // OnAutoHidingDesktopBarVisibilityChanged will handle this. | 511 // OnAutoHidingDesktopBarVisibilityChanged will handle this. |
515 delayed_titlebar_action_ = bring_up ? BRING_UP : BRING_DOWN; | 512 delayed_titlebar_action_ = bring_up ? BRING_UP : BRING_DOWN; |
516 | 513 |
517 // If user moves the mouse in and out of mouse tracking area, we might have | 514 // If user moves the mouse in and out of mouse tracking area, we might have |
518 // previously posted but not yet dispatched task in the queue. New action | 515 // previously posted but not yet dispatched task in the queue. New action |
519 // should always 'reset' the delays so cancel any tasks that haven't run yet | 516 // should always 'reset' the delays so cancel any tasks that haven't run yet |
520 // and post a new one. | 517 // and post a new one. |
521 titlebar_action_factory_.InvalidateWeakPtrs(); | 518 titlebar_action_factory_.InvalidateWeakPtrs(); |
522 MessageLoop::current()->PostDelayedTask( | 519 MessageLoop::current()->PostDelayedTask( |
523 FROM_HERE, | 520 FROM_HERE, |
524 base::Bind(&PanelStrip::DelayedBringUpOrDownTitlebarsCheck, | 521 base::Bind(&PanelStrip::DelayedBringUpOrDownTitlebarsCheck, |
525 titlebar_action_factory_.GetWeakPtr()), | 522 titlebar_action_factory_.GetWeakPtr()), |
526 task_delay_milliseconds); | 523 PanelManager::AdjustTimeInterval(task_delay_milliseconds)); |
527 } | 524 } |
528 | 525 |
529 void PanelStrip::DelayedBringUpOrDownTitlebarsCheck() { | 526 void PanelStrip::DelayedBringUpOrDownTitlebarsCheck() { |
530 // Task was already processed or cancelled - bail out. | 527 // Task was already processed or cancelled - bail out. |
531 if (delayed_titlebar_action_ == NO_ACTION) | 528 if (delayed_titlebar_action_ == NO_ACTION) |
532 return; | 529 return; |
533 | 530 |
534 bool need_to_bring_up_titlebars = (delayed_titlebar_action_ == BRING_UP); | 531 bool need_to_bring_up_titlebars = (delayed_titlebar_action_ == BRING_UP); |
535 | 532 |
536 delayed_titlebar_action_ = NO_ACTION; | 533 delayed_titlebar_action_ = NO_ACTION; |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
675 | 672 |
676 // Start from the bottom to avoid reshuffling. | 673 // Start from the bottom to avoid reshuffling. |
677 for (Panels::reverse_iterator iter = panels_copy.rbegin(); | 674 for (Panels::reverse_iterator iter = panels_copy.rbegin(); |
678 iter != panels_copy.rend(); ++iter) | 675 iter != panels_copy.rend(); ++iter) |
679 (*iter)->Close(); | 676 (*iter)->Close(); |
680 } | 677 } |
681 | 678 |
682 bool PanelStrip::is_dragging_panel() const { | 679 bool PanelStrip::is_dragging_panel() const { |
683 return dragging_panel_index_ != kInvalidPanelIndex; | 680 return dragging_panel_index_ != kInvalidPanelIndex; |
684 } | 681 } |
OLD | NEW |