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

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

Issue 8762017: Support painting panel in iconified mode on Windows. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years 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_frame_view.h ('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_browser_frame_view.h" 5 #include "chrome/browser/ui/panels/panel_browser_frame_view.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/utf_string_conversions.h" 9 #include "base/utf_string_conversions.h"
10 #include "chrome/browser/themes/theme_service.h" 10 #include "chrome/browser/themes/theme_service.h"
(...skipping 450 matching lines...) Expand 10 before | Expand all | Expand 10 after
461 } 461 }
462 462
463 gfx::Size PanelBrowserFrameView::GetMinimumSize() { 463 gfx::Size PanelBrowserFrameView::GetMinimumSize() {
464 // This makes the panel be able to shrink to very small, like 4-pixel lines. 464 // This makes the panel be able to shrink to very small, like 4-pixel lines.
465 // Since the panel cannot be resized by the user, we do not need to enforce 465 // Since the panel cannot be resized by the user, we do not need to enforce
466 // the minimum size. 466 // the minimum size.
467 return gfx::Size(); 467 return gfx::Size();
468 } 468 }
469 469
470 void PanelBrowserFrameView::Layout() { 470 void PanelBrowserFrameView::Layout() {
471 // Check if the width is only enough to show only the icon, or both icon
472 // and title. Hide corresponding controls accordingly.
473 bool show_close_button = true;
474 bool show_settings_button = true;
475 bool show_title_label = true;
476 if (width() <= IconOnlyWidth()) {
Dmitry Titov 2011/12/01 02:28:11 Seems both branches of this if are intended for OV
477 show_close_button = false;
478 show_settings_button = false;
479 show_title_label = false;
480 } else if (panel_browser_view_->panel()->expansion_state() ==
481 Panel::IN_OVERFLOW) {
482 show_close_button = true;
prasadt 2011/12/01 04:04:46 This is already true.
483 show_settings_button = false;
484 }
485 close_button_->SetVisible(show_close_button);
486 settings_button_->SetVisible(show_settings_button);
487 title_label_->SetVisible(show_title_label);
488 if (!show_title_label)
489 return;
prasadt 2011/12/01 04:04:46 A comment why you return here?
490
471 // Cancel the settings button animation if the layout of titlebar is being 491 // Cancel the settings button animation if the layout of titlebar is being
472 // updated. 492 // updated.
473 if (settings_button_animator_.get() && settings_button_animator_->IsShowing()) 493 if (settings_button_animator_.get() && settings_button_animator_->IsShowing())
474 settings_button_animator_->Reset(); 494 settings_button_animator_->Reset();
475 495
476 // Layout the close button. 496 // Layout the close button.
477 gfx::Size close_button_size = close_button_->GetPreferredSize(); 497 int right = width();
478 close_button_->SetBounds( 498 if (show_close_button) {
479 width() - kBorderThickness - kCloseButtonAndBorderSpacing - 499 gfx::Size close_button_size = close_button_->GetPreferredSize();
480 close_button_size.width(), 500 close_button_->SetBounds(
481 (NonClientTopBorderHeight() - close_button_size.height()) / 2, 501 width() - kBorderThickness - kCloseButtonAndBorderSpacing -
482 close_button_size.width(), 502 close_button_size.width(),
483 close_button_size.height()); 503 (NonClientTopBorderHeight() - close_button_size.height()) / 2,
504 close_button_size.width(),
505 close_button_size.height());
484 506
485 // Layout the settings button. 507 // Layout the settings button.
486 gfx::Size settings_button_size = settings_button_->GetPreferredSize(); 508 if (show_settings_button) {
487 settings_button_->SetBounds( 509 gfx::Size settings_button_size = settings_button_->GetPreferredSize();
488 close_button_->x() - kSettingsButtonAndCloseButtonSpacing - 510 settings_button_->SetBounds(
511 close_button_->x() - kSettingsButtonAndCloseButtonSpacing -
512 settings_button_size.width(),
513 (NonClientTopBorderHeight() - settings_button_size.height()) / 2,
489 settings_button_size.width(), 514 settings_button_size.width(),
490 (NonClientTopBorderHeight() - settings_button_size.height()) / 2, 515 settings_button_size.height());
491 settings_button_size.width(),
492 settings_button_size.height());
493 516
494 // Trace the full bounds and zero-size bounds for animation purpose. 517 // Trace the full bounds and zero-size bounds for animation purpose.
495 settings_button_full_bounds_ = settings_button_->bounds(); 518 settings_button_full_bounds_ = settings_button_->bounds();
496 settings_button_zero_bounds_.SetRect( 519 settings_button_zero_bounds_.SetRect(
497 settings_button_full_bounds_.x() + 520 settings_button_full_bounds_.x() +
498 settings_button_full_bounds_.width() / 2, 521 settings_button_full_bounds_.width() / 2,
499 settings_button_full_bounds_.y() + 522 settings_button_full_bounds_.y() +
500 settings_button_full_bounds_.height() / 2, 523 settings_button_full_bounds_.height() / 2,
501 0, 524 0,
502 0); 525 0);
526 }
527 }
503 528
504 // Layout the icon. 529 // Layout the icon.
505 int icon_y = (NonClientTopBorderHeight() - kIconSize) / 2; 530 int icon_y = (NonClientTopBorderHeight() - kIconSize) / 2;
506 title_icon_->SetBounds( 531 title_icon_->SetBounds(
507 kBorderThickness + kIconAndBorderSpacing, 532 kBorderThickness + kIconAndBorderSpacing,
508 icon_y, 533 icon_y,
509 kIconSize, 534 kIconSize,
510 kIconSize); 535 kIconSize);
511 536
512 // Layout the title. 537 // Layout the title.
513 int title_x = title_icon_->bounds().right() + kTitleSpacing; 538 int title_x = title_icon_->bounds().right() + kTitleSpacing;
514 int title_height = BrowserFrame::GetTitleFont().GetHeight(); 539 int title_height = BrowserFrame::GetTitleFont().GetHeight();
515 title_label_->SetBounds( 540 title_label_->SetBounds(
516 title_x, 541 title_x,
517 icon_y + ((kIconSize - title_height - 1) / 2), 542 icon_y + ((kIconSize - title_height - 1) / 2),
518 std::max(0, settings_button_->x() - kTitleSpacing - title_x), 543 std::max(0, right - kTitleSpacing - title_x),
519 title_height); 544 title_height);
520 545
521 // Calculate the client area bounds. 546 // Calculate the client area bounds.
522 int top_height = NonClientTopBorderHeight(); 547 int top_height = NonClientTopBorderHeight();
523 int border_thickness = NonClientBorderThickness(); 548 int border_thickness = NonClientBorderThickness();
524 client_view_bounds_.SetRect( 549 client_view_bounds_.SetRect(
525 border_thickness, 550 border_thickness,
526 top_height, 551 top_height,
527 std::max(0, width() - (2 * border_thickness)), 552 std::max(0, width() - (2 * border_thickness)),
528 std::max(0, height() - top_height - border_thickness)); 553 std::max(0, height() - top_height - border_thickness));
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
622 647
623 int PanelBrowserFrameView::NonClientTopBorderHeight() const { 648 int PanelBrowserFrameView::NonClientTopBorderHeight() const {
624 return kBorderThickness + kTitlebarHeight + kPanelClientEdgeThickness; 649 return kBorderThickness + kTitlebarHeight + kPanelClientEdgeThickness;
625 } 650 }
626 651
627 gfx::Size PanelBrowserFrameView::NonClientAreaSize() const { 652 gfx::Size PanelBrowserFrameView::NonClientAreaSize() const {
628 return gfx::Size(NonClientBorderThickness() * 2, 653 return gfx::Size(NonClientBorderThickness() * 2,
629 NonClientTopBorderHeight() + NonClientBorderThickness()); 654 NonClientTopBorderHeight() + NonClientBorderThickness());
630 } 655 }
631 656
657 int PanelBrowserFrameView::IconOnlyWidth() const {
658 return kBorderThickness * 2 + kIconAndBorderSpacing * 2 + kIconSize;
659 }
660
661 gfx::Size PanelBrowserFrameView::IconifiedSize() const {
662 return gfx::Size(IconOnlyWidth(), NonClientTopBorderHeight());
663 }
664
632 bool PanelBrowserFrameView::UsingDefaultTheme() const { 665 bool PanelBrowserFrameView::UsingDefaultTheme() const {
633 ThemeService* theme_service = ThemeServiceFactory::GetForProfile( 666 ThemeService* theme_service = ThemeServiceFactory::GetForProfile(
634 panel_browser_view_->panel()->browser()->profile()); 667 panel_browser_view_->panel()->browser()->profile());
635 return theme_service->UsingDefaultTheme(); 668 return theme_service->UsingDefaultTheme();
636 } 669 }
637 670
638 SkColor PanelBrowserFrameView::GetDefaultTitleColor( 671 SkColor PanelBrowserFrameView::GetDefaultTitleColor(
639 PaintState paint_state) const { 672 PaintState paint_state) const {
640 switch (paint_state) { 673 switch (paint_state) {
641 case PAINT_AS_INACTIVE: 674 case PAINT_AS_INACTIVE:
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
785 void PanelBrowserFrameView::OnMouseEnterOrLeaveWindow(bool mouse_entered) { 818 void PanelBrowserFrameView::OnMouseEnterOrLeaveWindow(bool mouse_entered) {
786 // Panel might be closed when we still watch the mouse event. 819 // Panel might be closed when we still watch the mouse event.
787 if (!panel_browser_view_->panel()) 820 if (!panel_browser_view_->panel())
788 return; 821 return;
789 UpdateSettingsButtonVisibility(panel_browser_view_->focused(), 822 UpdateSettingsButtonVisibility(panel_browser_view_->focused(),
790 mouse_entered); 823 mouse_entered);
791 } 824 }
792 825
793 void PanelBrowserFrameView::UpdateSettingsButtonVisibility( 826 void PanelBrowserFrameView::UpdateSettingsButtonVisibility(
794 bool focused, bool cursor_in_view) { 827 bool focused, bool cursor_in_view) {
828 // The settings button is not shown in the overflow state.
829 if (panel_browser_view_->panel()->expansion_state() == Panel::IN_OVERFLOW)
prasadt 2011/12/01 04:04:46 Assert is_settings_button_visible_ is false?
830 return;
831
795 bool is_settings_button_visible = focused || cursor_in_view; 832 bool is_settings_button_visible = focused || cursor_in_view;
796 if (is_settings_button_visible_ == is_settings_button_visible) 833 if (is_settings_button_visible_ == is_settings_button_visible)
797 return; 834 return;
798 is_settings_button_visible_ = is_settings_button_visible; 835 is_settings_button_visible_ = is_settings_button_visible;
799 836
800 // Even if we're hidng the settings button, we still make it visible for the 837 // Even if we're hidng the settings button, we still make it visible for the
801 // time period that the animation is running. 838 // time period that the animation is running.
802 settings_button_->SetVisible(true); 839 settings_button_->SetVisible(true);
803 840
804 if (settings_button_animator_.get()) { 841 if (settings_button_animator_.get()) {
(...skipping 19 matching lines...) Expand all
824 861
825 settings_menu_model_.reset( 862 settings_menu_model_.reset(
826 new PanelSettingsMenuModel(panel_browser_view_->panel())); 863 new PanelSettingsMenuModel(panel_browser_view_->panel()));
827 settings_menu_adapter_.reset( 864 settings_menu_adapter_.reset(
828 new views::MenuModelAdapter(settings_menu_model_.get())); 865 new views::MenuModelAdapter(settings_menu_model_.get()));
829 settings_menu_ = new views::MenuItemView(settings_menu_adapter_.get()); 866 settings_menu_ = new views::MenuItemView(settings_menu_adapter_.get());
830 settings_menu_adapter_->BuildMenu(settings_menu_); 867 settings_menu_adapter_->BuildMenu(settings_menu_);
831 settings_menu_runner_.reset(new views::MenuRunner(settings_menu_)); 868 settings_menu_runner_.reset(new views::MenuRunner(settings_menu_));
832 return true; 869 return true;
833 } 870 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/panels/panel_browser_frame_view.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698