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 536 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
547 } | 547 } |
548 | 548 |
549 // OnAutoHidingDesktopBarVisibilityChanged will handle this. | 549 // OnAutoHidingDesktopBarVisibilityChanged will handle this. |
550 delayed_titlebar_action_ = bring_up ? BRING_UP : BRING_DOWN; | 550 delayed_titlebar_action_ = bring_up ? BRING_UP : BRING_DOWN; |
551 | 551 |
552 // If user moves the mouse in and out of mouse tracking area, we might have | 552 // If user moves the mouse in and out of mouse tracking area, we might have |
553 // previously posted but not yet dispatched task in the queue. New action | 553 // previously posted but not yet dispatched task in the queue. New action |
554 // should always 'reset' the delays so cancel any tasks that haven't run yet | 554 // should always 'reset' the delays so cancel any tasks that haven't run yet |
555 // and post a new one. | 555 // and post a new one. |
556 titlebar_action_factory_.InvalidateWeakPtrs(); | 556 titlebar_action_factory_.InvalidateWeakPtrs(); |
557 MessageLoop::current()->PostDelayedTask( | 557 base::MessageLoop::current()->PostDelayedTask( |
558 FROM_HERE, | 558 FROM_HERE, |
559 base::Bind(&DockedPanelCollection::DelayedBringUpOrDownTitlebarsCheck, | 559 base::Bind(&DockedPanelCollection::DelayedBringUpOrDownTitlebarsCheck, |
560 titlebar_action_factory_.GetWeakPtr()), | 560 titlebar_action_factory_.GetWeakPtr()), |
561 base::TimeDelta::FromMilliseconds( | 561 base::TimeDelta::FromMilliseconds( |
562 PanelManager::AdjustTimeInterval(task_delay_ms))); | 562 PanelManager::AdjustTimeInterval(task_delay_ms))); |
563 } | 563 } |
564 | 564 |
565 void DockedPanelCollection::DelayedBringUpOrDownTitlebarsCheck() { | 565 void DockedPanelCollection::DelayedBringUpOrDownTitlebarsCheck() { |
566 // Task was already processed or cancelled - bail out. | 566 // Task was already processed or cancelled - bail out. |
567 if (delayed_titlebar_action_ == NO_ACTION) | 567 if (delayed_titlebar_action_ == NO_ACTION) |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
762 panel->set_attention_mode(Panel::USE_PANEL_ATTENTION); | 762 panel->set_attention_mode(Panel::USE_PANEL_ATTENTION); |
763 panel->SetAlwaysOnTop(true); | 763 panel->SetAlwaysOnTop(true); |
764 panel->ShowShadow(true); | 764 panel->ShowShadow(true); |
765 panel->EnableResizeByMouse(true); | 765 panel->EnableResizeByMouse(true); |
766 panel->UpdateMinimizeRestoreButtonVisibility(); | 766 panel->UpdateMinimizeRestoreButtonVisibility(); |
767 panel->SetWindowCornerStyle(panel::TOP_ROUNDED); | 767 panel->SetWindowCornerStyle(panel::TOP_ROUNDED); |
768 } | 768 } |
769 | 769 |
770 void DockedPanelCollection::ScheduleLayoutRefresh() { | 770 void DockedPanelCollection::ScheduleLayoutRefresh() { |
771 refresh_action_factory_.InvalidateWeakPtrs(); | 771 refresh_action_factory_.InvalidateWeakPtrs(); |
772 MessageLoop::current()->PostDelayedTask(FROM_HERE, | 772 base::MessageLoop::current()->PostDelayedTask( |
| 773 FROM_HERE, |
773 base::Bind(&DockedPanelCollection::RefreshLayout, | 774 base::Bind(&DockedPanelCollection::RefreshLayout, |
774 refresh_action_factory_.GetWeakPtr()), | 775 refresh_action_factory_.GetWeakPtr()), |
775 base::TimeDelta::FromMilliseconds(PanelManager::AdjustTimeInterval( | 776 base::TimeDelta::FromMilliseconds(PanelManager::AdjustTimeInterval( |
776 kRefreshLayoutAfterActivePanelChangeDelayMs))); | 777 kRefreshLayoutAfterActivePanelChangeDelayMs))); |
777 } | 778 } |
778 | 779 |
779 void DockedPanelCollection::OnPanelActiveStateChanged(Panel* panel) { | 780 void DockedPanelCollection::OnPanelActiveStateChanged(Panel* panel) { |
780 // Refresh layout, but wait till active states settle. | 781 // Refresh layout, but wait till active states settle. |
781 // This lets us avoid refreshing too many times when one panel loses | 782 // This lets us avoid refreshing too many times when one panel loses |
782 // focus and another gains it. | 783 // focus and another gains it. |
783 ScheduleLayoutRefresh(); | 784 ScheduleLayoutRefresh(); |
784 } | 785 } |
785 | 786 |
786 gfx::Rect DockedPanelCollection::GetInitialPanelBounds( | 787 gfx::Rect DockedPanelCollection::GetInitialPanelBounds( |
787 const gfx::Rect& requested_bounds) const { | 788 const gfx::Rect& requested_bounds) const { |
788 gfx::Rect initial_bounds = requested_bounds; | 789 gfx::Rect initial_bounds = requested_bounds; |
789 initial_bounds.set_origin( | 790 initial_bounds.set_origin( |
790 GetDefaultPositionForPanel(requested_bounds.size())); | 791 GetDefaultPositionForPanel(requested_bounds.size())); |
791 return initial_bounds; | 792 return initial_bounds; |
792 } | 793 } |
793 | 794 |
794 bool DockedPanelCollection::HasPanel(Panel* panel) const { | 795 bool DockedPanelCollection::HasPanel(Panel* panel) const { |
795 return find(panels_.begin(), panels_.end(), panel) != panels_.end(); | 796 return find(panels_.begin(), panels_.end(), panel) != panels_.end(); |
796 } | 797 } |
OLD | NEW |