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

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: Fix trybot 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 (panel_browser_view_->panel()->expansion_state() == Panel::IN_OVERFLOW) {
477 if (width() <= IconOnlyWidth()) {
478 show_close_button = false;
479 show_settings_button = false;
480 show_title_label = false;
481 } else {
482 show_settings_button = false;
483 }
484 }
485 close_button_->SetVisible(show_close_button);
486 settings_button_->SetVisible(show_settings_button);
487 title_label_->SetVisible(show_title_label);
488
471 // Cancel the settings button animation if the layout of titlebar is being 489 // Cancel the settings button animation if the layout of titlebar is being
472 // updated. 490 // updated.
473 if (settings_button_animator_.get() && settings_button_animator_->IsShowing()) 491 if (settings_button_animator_.get() && settings_button_animator_->IsShowing())
474 settings_button_animator_->Reset(); 492 settings_button_animator_->Reset();
475 493
476 // Layout the close button. 494 // Layout the close button.
477 gfx::Size close_button_size = close_button_->GetPreferredSize(); 495 int right = width();
478 close_button_->SetBounds( 496 if (show_close_button) {
479 width() - kBorderThickness - kCloseButtonAndBorderSpacing - 497 gfx::Size close_button_size = close_button_->GetPreferredSize();
480 close_button_size.width(), 498 close_button_->SetBounds(
481 (NonClientTopBorderHeight() - close_button_size.height()) / 2, 499 width() - kBorderThickness - kCloseButtonAndBorderSpacing -
482 close_button_size.width(), 500 close_button_size.width(),
483 close_button_size.height()); 501 (NonClientTopBorderHeight() - close_button_size.height()) / 2,
502 close_button_size.width(),
503 close_button_size.height());
504 right = close_button_->x();
484 505
485 // Layout the settings button. 506 // Layout the settings button.
486 gfx::Size settings_button_size = settings_button_->GetPreferredSize(); 507 if (show_settings_button) {
487 settings_button_->SetBounds( 508 gfx::Size settings_button_size = settings_button_->GetPreferredSize();
488 close_button_->x() - kSettingsButtonAndCloseButtonSpacing - 509 settings_button_->SetBounds(
510 close_button_->x() - kSettingsButtonAndCloseButtonSpacing -
511 settings_button_size.width(),
512 (NonClientTopBorderHeight() - settings_button_size.height()) / 2,
489 settings_button_size.width(), 513 settings_button_size.width(),
490 (NonClientTopBorderHeight() - settings_button_size.height()) / 2, 514 settings_button_size.height());
491 settings_button_size.width(), 515 right = settings_button_->x();
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 if (show_title_label) {
514 int title_height = BrowserFrame::GetTitleFont().GetHeight(); 539 int title_x = title_icon_->bounds().right() + kTitleSpacing;
515 title_label_->SetBounds( 540 int title_height = BrowserFrame::GetTitleFont().GetHeight();
516 title_x, 541 title_label_->SetBounds(
517 icon_y + ((kIconSize - title_height - 1) / 2), 542 title_x,
518 std::max(0, settings_button_->x() - kTitleSpacing - title_x), 543 icon_y + ((kIconSize - title_height - 1) / 2),
519 title_height); 544 std::max(0, right - kTitleSpacing - title_x),
545 title_height);
546 }
520 547
521 // Calculate the client area bounds. 548 // Calculate the client area bounds.
522 int top_height = NonClientTopBorderHeight(); 549 int top_height = NonClientTopBorderHeight();
523 int border_thickness = NonClientBorderThickness(); 550 int border_thickness = NonClientBorderThickness();
524 client_view_bounds_.SetRect( 551 client_view_bounds_.SetRect(
525 border_thickness, 552 border_thickness,
526 top_height, 553 top_height,
527 std::max(0, width() - (2 * border_thickness)), 554 std::max(0, width() - (2 * border_thickness)),
528 std::max(0, height() - top_height - border_thickness)); 555 std::max(0, height() - top_height - border_thickness));
529 } 556 }
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
622 649
623 int PanelBrowserFrameView::NonClientTopBorderHeight() const { 650 int PanelBrowserFrameView::NonClientTopBorderHeight() const {
624 return kBorderThickness + kTitlebarHeight + kPanelClientEdgeThickness; 651 return kBorderThickness + kTitlebarHeight + kPanelClientEdgeThickness;
625 } 652 }
626 653
627 gfx::Size PanelBrowserFrameView::NonClientAreaSize() const { 654 gfx::Size PanelBrowserFrameView::NonClientAreaSize() const {
628 return gfx::Size(NonClientBorderThickness() * 2, 655 return gfx::Size(NonClientBorderThickness() * 2,
629 NonClientTopBorderHeight() + NonClientBorderThickness()); 656 NonClientTopBorderHeight() + NonClientBorderThickness());
630 } 657 }
631 658
659 int PanelBrowserFrameView::IconOnlyWidth() const {
660 return kBorderThickness * 2 + kIconAndBorderSpacing * 2 + kIconSize;
661 }
662
663 gfx::Size PanelBrowserFrameView::IconifiedSize() const {
664 return gfx::Size(IconOnlyWidth(), NonClientTopBorderHeight());
665 }
666
632 bool PanelBrowserFrameView::UsingDefaultTheme() const { 667 bool PanelBrowserFrameView::UsingDefaultTheme() const {
633 ThemeService* theme_service = ThemeServiceFactory::GetForProfile( 668 ThemeService* theme_service = ThemeServiceFactory::GetForProfile(
634 panel_browser_view_->panel()->browser()->profile()); 669 panel_browser_view_->panel()->browser()->profile());
635 return theme_service->UsingDefaultTheme(); 670 return theme_service->UsingDefaultTheme();
636 } 671 }
637 672
638 SkColor PanelBrowserFrameView::GetDefaultTitleColor( 673 SkColor PanelBrowserFrameView::GetDefaultTitleColor(
639 PaintState paint_state) const { 674 PaintState paint_state) const {
640 switch (paint_state) { 675 switch (paint_state) {
641 case PAINT_AS_INACTIVE: 676 case PAINT_AS_INACTIVE:
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
785 void PanelBrowserFrameView::OnMouseEnterOrLeaveWindow(bool mouse_entered) { 820 void PanelBrowserFrameView::OnMouseEnterOrLeaveWindow(bool mouse_entered) {
786 // Panel might be closed when we still watch the mouse event. 821 // Panel might be closed when we still watch the mouse event.
787 if (!panel_browser_view_->panel()) 822 if (!panel_browser_view_->panel())
788 return; 823 return;
789 UpdateSettingsButtonVisibility(panel_browser_view_->focused(), 824 UpdateSettingsButtonVisibility(panel_browser_view_->focused(),
790 mouse_entered); 825 mouse_entered);
791 } 826 }
792 827
793 void PanelBrowserFrameView::UpdateSettingsButtonVisibility( 828 void PanelBrowserFrameView::UpdateSettingsButtonVisibility(
794 bool focused, bool cursor_in_view) { 829 bool focused, bool cursor_in_view) {
830 // The settings button is not shown in the overflow state.
831 if (panel_browser_view_->panel()->expansion_state() == Panel::IN_OVERFLOW)
832 return;
833
795 bool is_settings_button_visible = focused || cursor_in_view; 834 bool is_settings_button_visible = focused || cursor_in_view;
796 if (is_settings_button_visible_ == is_settings_button_visible) 835 if (is_settings_button_visible_ == is_settings_button_visible)
797 return; 836 return;
798 is_settings_button_visible_ = is_settings_button_visible; 837 is_settings_button_visible_ = is_settings_button_visible;
799 838
800 // Even if we're hidng the settings button, we still make it visible for the 839 // Even if we're hidng the settings button, we still make it visible for the
801 // time period that the animation is running. 840 // time period that the animation is running.
802 settings_button_->SetVisible(true); 841 settings_button_->SetVisible(true);
803 842
804 if (settings_button_animator_.get()) { 843 if (settings_button_animator_.get()) {
(...skipping 19 matching lines...) Expand all
824 863
825 settings_menu_model_.reset( 864 settings_menu_model_.reset(
826 new PanelSettingsMenuModel(panel_browser_view_->panel())); 865 new PanelSettingsMenuModel(panel_browser_view_->panel()));
827 settings_menu_adapter_.reset( 866 settings_menu_adapter_.reset(
828 new views::MenuModelAdapter(settings_menu_model_.get())); 867 new views::MenuModelAdapter(settings_menu_model_.get()));
829 settings_menu_ = new views::MenuItemView(settings_menu_adapter_.get()); 868 settings_menu_ = new views::MenuItemView(settings_menu_adapter_.get());
830 settings_menu_adapter_->BuildMenu(settings_menu_); 869 settings_menu_adapter_->BuildMenu(settings_menu_);
831 settings_menu_runner_.reset(new views::MenuRunner(settings_menu_)); 870 settings_menu_runner_.reset(new views::MenuRunner(settings_menu_));
832 return true; 871 return true;
833 } 872 }
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