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_manager.h" | 5 #include "chrome/browser/ui/panels/panel_manager.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
11 #include "base/message_loop.h" | 11 #include "base/message_loop.h" |
12 #include "chrome/browser/ui/browser.h" | 12 #include "chrome/browser/ui/browser.h" |
| 13 #include "chrome/browser/ui/browser_list.h" |
13 #include "chrome/browser/ui/window_sizer.h" | 14 #include "chrome/browser/ui/window_sizer.h" |
14 | 15 |
15 namespace { | 16 namespace { |
16 // Invalid panel index. | 17 // Invalid panel index. |
17 const size_t kInvalidPanelIndex = static_cast<size_t>(-1); | 18 const size_t kInvalidPanelIndex = static_cast<size_t>(-1); |
18 | 19 |
19 // Default width and height of a panel. | 20 // Default width and height of a panel. |
20 const int kPanelDefaultWidth = 240; | 21 const int kPanelDefaultWidth = 240; |
21 const int kPanelDefaultHeight = 290; | 22 const int kPanelDefaultHeight = 290; |
22 | 23 |
(...skipping 493 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
516 int bottom = adjusted_work_area_.bottom(); | 517 int bottom = adjusted_work_area_.bottom(); |
517 if (expansion_state == Panel::MINIMIZED && | 518 if (expansion_state == Panel::MINIMIZED && |
518 auto_hiding_desktop_bar_->IsEnabled(AutoHidingDesktopBar::ALIGN_BOTTOM)) { | 519 auto_hiding_desktop_bar_->IsEnabled(AutoHidingDesktopBar::ALIGN_BOTTOM)) { |
519 bottom += auto_hiding_desktop_bar_->GetThickness( | 520 bottom += auto_hiding_desktop_bar_->GetThickness( |
520 AutoHidingDesktopBar::ALIGN_BOTTOM); | 521 AutoHidingDesktopBar::ALIGN_BOTTOM); |
521 } | 522 } |
522 | 523 |
523 return bottom; | 524 return bottom; |
524 } | 525 } |
525 | 526 |
| 527 BrowserWindow* PanelManager::GetNextBrowserWindowToActivate( |
| 528 Panel* panel) const { |
| 529 // Find the last active browser window that is not minimized. |
| 530 BrowserList::const_reverse_iterator iter = BrowserList::begin_last_active(); |
| 531 BrowserList::const_reverse_iterator end = BrowserList::end_last_active(); |
| 532 for (; (iter != end); ++iter) { |
| 533 Browser* browser = *iter; |
| 534 if (panel->browser() != browser && !browser->window()->IsMinimized()) |
| 535 return browser->window(); |
| 536 } |
| 537 |
| 538 return NULL; |
| 539 } |
| 540 |
526 void PanelManager::OnMouseMove(const gfx::Point& mouse_position) { | 541 void PanelManager::OnMouseMove(const gfx::Point& mouse_position) { |
527 bool bring_up_titlebars = ShouldBringUpTitlebars(mouse_position.x(), | 542 bool bring_up_titlebars = ShouldBringUpTitlebars(mouse_position.x(), |
528 mouse_position.y()); | 543 mouse_position.y()); |
529 if (are_titlebars_up_ == bring_up_titlebars) | 544 if (are_titlebars_up_ == bring_up_titlebars) |
530 return; | 545 return; |
531 are_titlebars_up_ = bring_up_titlebars; | 546 are_titlebars_up_ = bring_up_titlebars; |
532 BringUpOrDownTitlebars(bring_up_titlebars); | 547 BringUpOrDownTitlebars(bring_up_titlebars); |
533 } | 548 } |
534 | 549 |
535 void PanelManager::OnAutoHidingDesktopBarThicknessChanged() { | 550 void PanelManager::OnAutoHidingDesktopBarThicknessChanged() { |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
597 Panel* panel = *iter; | 612 Panel* panel = *iter; |
598 // A panel can at most grow to take over all the available space that is | 613 // A panel can at most grow to take over all the available space that is |
599 // returned by GetRightMostAvailablePosition. | 614 // returned by GetRightMostAvailablePosition. |
600 int width_can_grow_to = | 615 int width_can_grow_to = |
601 panel->GetBounds().width() + GetRightMostAvailablePosition(); | 616 panel->GetBounds().width() + GetRightMostAvailablePosition(); |
602 panel->SetMaxSize(gfx::Size( | 617 panel->SetMaxSize(gfx::Size( |
603 std::min(width_can_grow_to, GetMaxPanelWidth()), | 618 std::min(width_can_grow_to, GetMaxPanelWidth()), |
604 GetMaxPanelHeight())); | 619 GetMaxPanelHeight())); |
605 } | 620 } |
606 } | 621 } |
OLD | NEW |