| 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_collection.h" | 5 #include "chrome/browser/ui/panels/docked_panel_collection.h" |
| 6 | 6 |
| 7 #include <math.h> | 7 #include <math.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 // screen. | 25 // screen. |
| 26 const int kPanelCollectionLeftMargin = 6; | 26 const int kPanelCollectionLeftMargin = 6; |
| 27 const int kPanelCollectionRightMargin = 24; | 27 const int kPanelCollectionRightMargin = 24; |
| 28 | 28 |
| 29 // Occasionally some system, like Windows, might not bring up or down the bottom | 29 // Occasionally some system, like Windows, might not bring up or down the bottom |
| 30 // bar when the mouse enters or leaves the bottom screen area. This is the | 30 // bar when the mouse enters or leaves the bottom screen area. This is the |
| 31 // maximum time we will wait for the bottom bar visibility change notification. | 31 // maximum time we will wait for the bottom bar visibility change notification. |
| 32 // After the time expires, we bring up/down the titlebars as planned. | 32 // After the time expires, we bring up/down the titlebars as planned. |
| 33 const int kMaxDelayWaitForBottomBarVisibilityChangeMs = 1000; | 33 const int kMaxDelayWaitForBottomBarVisibilityChangeMs = 1000; |
| 34 | 34 |
| 35 // See usage below. | |
| 36 #if defined(TOOLKIT_GTK) | |
| 37 const int kDelayBeforeCollapsingFromTitleOnlyStateMs = 2000; | |
| 38 #else | |
| 39 const int kDelayBeforeCollapsingFromTitleOnlyStateMs = 0; | |
| 40 #endif | |
| 41 | |
| 42 // After focus changed, one panel lost active status, another got it, | 35 // After focus changed, one panel lost active status, another got it, |
| 43 // we refresh layout with a delay. | 36 // we refresh layout with a delay. |
| 44 const int kRefreshLayoutAfterActivePanelChangeDelayMs = 600; // arbitrary | 37 const int kRefreshLayoutAfterActivePanelChangeDelayMs = 600; // arbitrary |
| 45 | 38 |
| 46 // As we refresh panel positions, some or all panels may move. We make sure | 39 // As we refresh panel positions, some or all panels may move. We make sure |
| 47 // we do not animate too many panels at once as this tends to perform poorly. | 40 // we do not animate too many panels at once as this tends to perform poorly. |
| 48 const int kNumPanelsToAnimateSimultaneously = 3; | 41 const int kNumPanelsToAnimateSimultaneously = 3; |
| 49 | 42 |
| 50 } // namespace | 43 } // namespace |
| 51 | 44 |
| (...skipping 478 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 530 : DisplaySettingsProvider::DESKTOP_BAR_HIDDEN)) { | 523 : DisplaySettingsProvider::DESKTOP_BAR_HIDDEN)) { |
| 531 // Occasionally some system, like Windows, might not bring up or down the | 524 // Occasionally some system, like Windows, might not bring up or down the |
| 532 // bottom bar when the mouse enters or leaves the bottom screen area. | 525 // bottom bar when the mouse enters or leaves the bottom screen area. |
| 533 // Thus, we schedule a delayed task to do the work if we do not receive | 526 // Thus, we schedule a delayed task to do the work if we do not receive |
| 534 // the bottom bar visibility change notification within a certain period | 527 // the bottom bar visibility change notification within a certain period |
| 535 // of time. | 528 // of time. |
| 536 task_delay_ms = kMaxDelayWaitForBottomBarVisibilityChangeMs; | 529 task_delay_ms = kMaxDelayWaitForBottomBarVisibilityChangeMs; |
| 537 } | 530 } |
| 538 } | 531 } |
| 539 | 532 |
| 540 // On some OSes, the interaction with native Taskbars/Docks may be improved | |
| 541 // if the panels do not go back to minimized state too fast. For example, | |
| 542 // with a taskbar in auto-hide mode, the taskbar will cover the panel in | |
| 543 // title-only mode which appears on hover. Leaving it up for a little longer | |
| 544 // would allow the user to be able to click on it. | |
| 545 // | |
| 546 // Currently, no platforms use both delays. | |
| 547 DCHECK(task_delay_ms == 0 || | |
| 548 kDelayBeforeCollapsingFromTitleOnlyStateMs == 0); | |
| 549 if (!bring_up && task_delay_ms == 0) { | |
| 550 task_delay_ms = kDelayBeforeCollapsingFromTitleOnlyStateMs; | |
| 551 } | |
| 552 | |
| 553 // OnAutoHidingDesktopBarVisibilityChanged will handle this. | 533 // OnAutoHidingDesktopBarVisibilityChanged will handle this. |
| 554 delayed_titlebar_action_ = bring_up ? BRING_UP : BRING_DOWN; | 534 delayed_titlebar_action_ = bring_up ? BRING_UP : BRING_DOWN; |
| 555 | 535 |
| 556 // If user moves the mouse in and out of mouse tracking area, we might have | 536 // If user moves the mouse in and out of mouse tracking area, we might have |
| 557 // previously posted but not yet dispatched task in the queue. New action | 537 // previously posted but not yet dispatched task in the queue. New action |
| 558 // should always 'reset' the delays so cancel any tasks that haven't run yet | 538 // should always 'reset' the delays so cancel any tasks that haven't run yet |
| 559 // and post a new one. | 539 // and post a new one. |
| 560 titlebar_action_factory_.InvalidateWeakPtrs(); | 540 titlebar_action_factory_.InvalidateWeakPtrs(); |
| 561 base::MessageLoop::current()->PostDelayedTask( | 541 base::MessageLoop::current()->PostDelayedTask( |
| 562 FROM_HERE, | 542 FROM_HERE, |
| (...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 790 const gfx::Rect& requested_bounds) const { | 770 const gfx::Rect& requested_bounds) const { |
| 791 gfx::Rect initial_bounds = requested_bounds; | 771 gfx::Rect initial_bounds = requested_bounds; |
| 792 initial_bounds.set_origin( | 772 initial_bounds.set_origin( |
| 793 GetDefaultPositionForPanel(requested_bounds.size())); | 773 GetDefaultPositionForPanel(requested_bounds.size())); |
| 794 return initial_bounds; | 774 return initial_bounds; |
| 795 } | 775 } |
| 796 | 776 |
| 797 bool DockedPanelCollection::HasPanel(Panel* panel) const { | 777 bool DockedPanelCollection::HasPanel(Panel* panel) const { |
| 798 return find(panels_.begin(), panels_.end(), panel) != panels_.end(); | 778 return find(panels_.begin(), panels_.end(), panel) != panels_.end(); |
| 799 } | 779 } |
| OLD | NEW |