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

Unified 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, 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/panels/panel_browser_frame_view.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/panels/panel_browser_frame_view.cc
diff --git a/chrome/browser/ui/panels/panel_browser_frame_view.cc b/chrome/browser/ui/panels/panel_browser_frame_view.cc
index 2ebdb6499b14949e48b6785a8fea0cf74ba0cad3..cec192cb600826ed9b81d83828e8be355285be0c 100644
--- a/chrome/browser/ui/panels/panel_browser_frame_view.cc
+++ b/chrome/browser/ui/panels/panel_browser_frame_view.cc
@@ -468,38 +468,63 @@ gfx::Size PanelBrowserFrameView::GetMinimumSize() {
}
void PanelBrowserFrameView::Layout() {
+ // Check if the width is only enough to show only the icon, or both icon
+ // and title. Hide corresponding controls accordingly.
+ bool show_close_button = true;
+ bool show_settings_button = true;
+ bool show_title_label = true;
+ if (width() <= IconOnlyWidth()) {
Dmitry Titov 2011/12/01 02:28:11 Seems both branches of this if are intended for OV
+ show_close_button = false;
+ show_settings_button = false;
+ show_title_label = false;
+ } else if (panel_browser_view_->panel()->expansion_state() ==
+ Panel::IN_OVERFLOW) {
+ show_close_button = true;
prasadt 2011/12/01 04:04:46 This is already true.
+ show_settings_button = false;
+ }
+ close_button_->SetVisible(show_close_button);
+ settings_button_->SetVisible(show_settings_button);
+ title_label_->SetVisible(show_title_label);
+ if (!show_title_label)
+ return;
prasadt 2011/12/01 04:04:46 A comment why you return here?
+
// Cancel the settings button animation if the layout of titlebar is being
// updated.
if (settings_button_animator_.get() && settings_button_animator_->IsShowing())
settings_button_animator_->Reset();
// Layout the close button.
- gfx::Size close_button_size = close_button_->GetPreferredSize();
- close_button_->SetBounds(
- width() - kBorderThickness - kCloseButtonAndBorderSpacing -
- close_button_size.width(),
- (NonClientTopBorderHeight() - close_button_size.height()) / 2,
- close_button_size.width(),
- close_button_size.height());
-
- // Layout the settings button.
- gfx::Size settings_button_size = settings_button_->GetPreferredSize();
- settings_button_->SetBounds(
- close_button_->x() - kSettingsButtonAndCloseButtonSpacing -
+ int right = width();
+ if (show_close_button) {
+ gfx::Size close_button_size = close_button_->GetPreferredSize();
+ close_button_->SetBounds(
+ width() - kBorderThickness - kCloseButtonAndBorderSpacing -
+ close_button_size.width(),
+ (NonClientTopBorderHeight() - close_button_size.height()) / 2,
+ close_button_size.width(),
+ close_button_size.height());
+
+ // Layout the settings button.
+ if (show_settings_button) {
+ gfx::Size settings_button_size = settings_button_->GetPreferredSize();
+ settings_button_->SetBounds(
+ close_button_->x() - kSettingsButtonAndCloseButtonSpacing -
+ settings_button_size.width(),
+ (NonClientTopBorderHeight() - settings_button_size.height()) / 2,
settings_button_size.width(),
- (NonClientTopBorderHeight() - settings_button_size.height()) / 2,
- settings_button_size.width(),
- settings_button_size.height());
-
- // Trace the full bounds and zero-size bounds for animation purpose.
- settings_button_full_bounds_ = settings_button_->bounds();
- settings_button_zero_bounds_.SetRect(
- settings_button_full_bounds_.x() +
- settings_button_full_bounds_.width() / 2,
- settings_button_full_bounds_.y() +
- settings_button_full_bounds_.height() / 2,
- 0,
- 0);
+ settings_button_size.height());
+
+ // Trace the full bounds and zero-size bounds for animation purpose.
+ settings_button_full_bounds_ = settings_button_->bounds();
+ settings_button_zero_bounds_.SetRect(
+ settings_button_full_bounds_.x() +
+ settings_button_full_bounds_.width() / 2,
+ settings_button_full_bounds_.y() +
+ settings_button_full_bounds_.height() / 2,
+ 0,
+ 0);
+ }
+ }
// Layout the icon.
int icon_y = (NonClientTopBorderHeight() - kIconSize) / 2;
@@ -515,7 +540,7 @@ void PanelBrowserFrameView::Layout() {
title_label_->SetBounds(
title_x,
icon_y + ((kIconSize - title_height - 1) / 2),
- std::max(0, settings_button_->x() - kTitleSpacing - title_x),
+ std::max(0, right - kTitleSpacing - title_x),
title_height);
// Calculate the client area bounds.
@@ -629,6 +654,14 @@ gfx::Size PanelBrowserFrameView::NonClientAreaSize() const {
NonClientTopBorderHeight() + NonClientBorderThickness());
}
+int PanelBrowserFrameView::IconOnlyWidth() const {
+ return kBorderThickness * 2 + kIconAndBorderSpacing * 2 + kIconSize;
+}
+
+gfx::Size PanelBrowserFrameView::IconifiedSize() const {
+ return gfx::Size(IconOnlyWidth(), NonClientTopBorderHeight());
+}
+
bool PanelBrowserFrameView::UsingDefaultTheme() const {
ThemeService* theme_service = ThemeServiceFactory::GetForProfile(
panel_browser_view_->panel()->browser()->profile());
@@ -792,6 +825,10 @@ void PanelBrowserFrameView::OnMouseEnterOrLeaveWindow(bool mouse_entered) {
void PanelBrowserFrameView::UpdateSettingsButtonVisibility(
bool focused, bool cursor_in_view) {
+ // The settings button is not shown in the overflow state.
+ if (panel_browser_view_->panel()->expansion_state() == Panel::IN_OVERFLOW)
prasadt 2011/12/01 04:04:46 Assert is_settings_button_visible_ is false?
+ return;
+
bool is_settings_button_visible = focused || cursor_in_view;
if (is_settings_button_visible_ == is_settings_button_visible)
return;
« 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