Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(207)

Side by Side Diff: chrome/browser/ui/panels/panel_manager.cc

Issue 8566034: Align expanded panel to the bottom of screen edge when there is an auto-hiding taskbar (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix test. Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/ui/panels/panel_browser_view_browsertest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/bind.h" 9 #include "base/bind.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after
321 } 321 }
322 322
323 void PanelManager::OnPanelExpansionStateChanged( 323 void PanelManager::OnPanelExpansionStateChanged(
324 Panel::ExpansionState old_state, Panel::ExpansionState new_state) { 324 Panel::ExpansionState old_state, Panel::ExpansionState new_state) {
325 DCHECK_NE(new_state, old_state); 325 DCHECK_NE(new_state, old_state);
326 switch (new_state) { 326 switch (new_state) {
327 case Panel::EXPANDED: 327 case Panel::EXPANDED:
328 DecrementMinimizedPanels(); 328 DecrementMinimizedPanels();
329 break; 329 break;
330 case Panel::MINIMIZED: 330 case Panel::MINIMIZED:
331 case Panel::TITLE_ONLY:
331 if (old_state == Panel::EXPANDED) 332 if (old_state == Panel::EXPANDED)
332 IncrementMinimizedPanels(); 333 IncrementMinimizedPanels();
333 break; 334 break;
334 default: 335 default:
335 break; 336 break;
336 } 337 }
337 } 338 }
338 339
339 void PanelManager::IncrementMinimizedPanels() { 340 void PanelManager::IncrementMinimizedPanels() {
340 if (!mouse_watching_disabled_ && !minimized_panel_count_) 341 if (!mouse_watching_disabled_ && !minimized_panel_count_)
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
517 if (panel->expansion_state() == Panel::TITLE_ONLY) 518 if (panel->expansion_state() == Panel::TITLE_ONLY)
518 panel->SetExpansionState(Panel::MINIMIZED); 519 panel->SetExpansionState(Panel::MINIMIZED);
519 } 520 }
520 } 521 }
521 } 522 }
522 523
523 void PanelManager::AdjustWorkAreaForAutoHidingDesktopBars() { 524 void PanelManager::AdjustWorkAreaForAutoHidingDesktopBars() {
524 // Note that we do not care about the desktop bar aligned to the top edge 525 // Note that we do not care about the desktop bar aligned to the top edge
525 // since panels could not reach so high due to size constraint. 526 // since panels could not reach so high due to size constraint.
526 adjusted_work_area_ = work_area_; 527 adjusted_work_area_ = work_area_;
527 if (auto_hiding_desktop_bar_->IsEnabled(AutoHidingDesktopBar::ALIGN_BOTTOM)) {
528 int space = auto_hiding_desktop_bar_->GetThickness(
529 AutoHidingDesktopBar::ALIGN_BOTTOM);
530 adjusted_work_area_.set_height(adjusted_work_area_.height() - space);
531 }
532 if (auto_hiding_desktop_bar_->IsEnabled(AutoHidingDesktopBar::ALIGN_LEFT)) { 528 if (auto_hiding_desktop_bar_->IsEnabled(AutoHidingDesktopBar::ALIGN_LEFT)) {
533 int space = auto_hiding_desktop_bar_->GetThickness( 529 int space = auto_hiding_desktop_bar_->GetThickness(
534 AutoHidingDesktopBar::ALIGN_LEFT); 530 AutoHidingDesktopBar::ALIGN_LEFT);
535 adjusted_work_area_.set_x(adjusted_work_area_.x() + space); 531 adjusted_work_area_.set_x(adjusted_work_area_.x() + space);
536 adjusted_work_area_.set_width(adjusted_work_area_.width() - space); 532 adjusted_work_area_.set_width(adjusted_work_area_.width() - space);
537 } 533 }
538 if (auto_hiding_desktop_bar_->IsEnabled(AutoHidingDesktopBar::ALIGN_RIGHT)) { 534 if (auto_hiding_desktop_bar_->IsEnabled(AutoHidingDesktopBar::ALIGN_RIGHT)) {
539 int space = auto_hiding_desktop_bar_->GetThickness( 535 int space = auto_hiding_desktop_bar_->GetThickness(
540 AutoHidingDesktopBar::ALIGN_RIGHT); 536 AutoHidingDesktopBar::ALIGN_RIGHT);
541 adjusted_work_area_.set_width(adjusted_work_area_.width() - space); 537 adjusted_work_area_.set_width(adjusted_work_area_.width() - space);
542 } 538 }
543 } 539 }
544 540
545 int PanelManager::GetBottomPositionForExpansionState( 541 int PanelManager::GetBottomPositionForExpansionState(
546 Panel::ExpansionState expansion_state) const { 542 Panel::ExpansionState expansion_state) const {
547 int bottom = adjusted_work_area_.bottom(); 543 int bottom = adjusted_work_area_.bottom();
548 // If there is an auto-hiding desktop bar aligned to the bottom edge, we need 544 // If there is an auto-hiding desktop bar aligned to the bottom edge, we need
549 // to move the minimize panel down to the bottom edge. 545 // to move the title-only panel above the auto-hiding desktop bar.
550 if (expansion_state == Panel::MINIMIZED && 546 if (expansion_state == Panel::TITLE_ONLY &&
551 auto_hiding_desktop_bar_->IsEnabled(AutoHidingDesktopBar::ALIGN_BOTTOM)) { 547 auto_hiding_desktop_bar_->IsEnabled(AutoHidingDesktopBar::ALIGN_BOTTOM)) {
552 bottom += auto_hiding_desktop_bar_->GetThickness( 548 bottom -= auto_hiding_desktop_bar_->GetThickness(
553 AutoHidingDesktopBar::ALIGN_BOTTOM); 549 AutoHidingDesktopBar::ALIGN_BOTTOM);
554 } 550 }
555 551
556 return bottom; 552 return bottom;
557 } 553 }
558 554
559 BrowserWindow* PanelManager::GetNextBrowserWindowToActivate( 555 BrowserWindow* PanelManager::GetNextBrowserWindowToActivate(
560 Panel* panel) const { 556 Panel* panel) const {
561 // Find the last active browser window that is not minimized. 557 // Find the last active browser window that is not minimized.
562 BrowserList::const_reverse_iterator iter = BrowserList::begin_last_active(); 558 BrowserList::const_reverse_iterator iter = BrowserList::begin_last_active();
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
596 DoBringUpOrDownTitlebars(delayed_titlebar_action_ == BRING_UP); 592 DoBringUpOrDownTitlebars(delayed_titlebar_action_ == BRING_UP);
597 delayed_titlebar_action_ = NO_ACTION; 593 delayed_titlebar_action_ = NO_ACTION;
598 } 594 }
599 595
600 void PanelManager::Rearrange(Panels::iterator iter_to_start, 596 void PanelManager::Rearrange(Panels::iterator iter_to_start,
601 int rightmost_position) { 597 int rightmost_position) {
602 for (Panels::iterator iter = iter_to_start; iter != panels_.end(); ++iter) { 598 for (Panels::iterator iter = iter_to_start; iter != panels_.end(); ++iter) {
603 Panel* panel = *iter; 599 Panel* panel = *iter;
604 gfx::Rect new_bounds(panel->GetBounds()); 600 gfx::Rect new_bounds(panel->GetBounds());
605 new_bounds.set_x(rightmost_position - new_bounds.width()); 601 new_bounds.set_x(rightmost_position - new_bounds.width());
606 new_bounds.set_y(adjusted_work_area_.bottom() - new_bounds.height()); 602 new_bounds.set_y(
603 GetBottomPositionForExpansionState(panel->expansion_state()) -
604 new_bounds.height());
607 if (new_bounds != panel->GetBounds()) 605 if (new_bounds != panel->GetBounds())
608 panel->SetPanelBounds(new_bounds); 606 panel->SetPanelBounds(new_bounds);
609 607
610 rightmost_position = new_bounds.x() - kPanelsHorizontalSpacing; 608 rightmost_position = new_bounds.x() - kPanelsHorizontalSpacing;
611 } 609 }
612 } 610 }
613 611
614 void PanelManager::RemoveAll() { 612 void PanelManager::RemoveAll() {
615 // This should not be called when we're in the process of dragging. 613 // This should not be called when we're in the process of dragging.
616 DCHECK(dragging_panel_index_ == kInvalidPanelIndex); 614 DCHECK(dragging_panel_index_ == kInvalidPanelIndex);
617 615
618 // Make a copy of the iterator as closing panels can modify the vector. 616 // Make a copy of the iterator as closing panels can modify the vector.
619 Panels panels_copy = panels_; 617 Panels panels_copy = panels_;
620 618
621 // Start from the bottom to avoid reshuffling. 619 // Start from the bottom to avoid reshuffling.
622 for (Panels::reverse_iterator iter = panels_copy.rbegin(); 620 for (Panels::reverse_iterator iter = panels_copy.rbegin();
623 iter != panels_copy.rend(); ++iter) 621 iter != panels_copy.rend(); ++iter)
624 (*iter)->Close(); 622 (*iter)->Close();
625 } 623 }
626 624
627 bool PanelManager::is_dragging_panel() const { 625 bool PanelManager::is_dragging_panel() const {
628 return dragging_panel_index_ != kInvalidPanelIndex; 626 return dragging_panel_index_ != kInvalidPanelIndex;
629 } 627 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/panels/panel_browser_view_browsertest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698