Chromium Code Reviews| 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 45b39a9e178d9c88b07cd926bab88d90aa423949..7ee0fe15247f7d884c6689fe046cf3af2b954307 100644 |
| --- a/chrome/browser/ui/panels/panel_browser_frame_view.cc |
| +++ b/chrome/browser/ui/panels/panel_browser_frame_view.cc |
| @@ -312,6 +312,7 @@ PanelBrowserFrameView::PanelBrowserFrameView(BrowserFrame* frame, |
| restore_button_resources.hover_image); |
| restore_button_->SetTooltipText(restore_button_resources.tooltip_text); |
| restore_button_->SetAccessibleName(restore_button_resources.tooltip_text); |
| + restore_button_->SetVisible(false); // only visible when panel is minimized |
| AddChildView(restore_button_); |
| title_icon_ = new TabIconView(this); |
| @@ -465,38 +466,22 @@ void PanelBrowserFrameView::Layout() { |
| if (!panel_strip) |
| return; |
| - // Check if the width is only enough to show only the icon, or both icon |
| - // and title. Hide corresponding controls accordingly. |
| - // TODO(aburago) Make sure the close button is always visible even if the |
| - // panel is too narrow. |
| - bool show_close_button = true; |
| - bool show_title_label = true; |
| - bool show_restore_button = panel->CanRestore(); |
| - bool show_minimize_button = panel->CanMinimize(); |
| - |
| - close_button_->SetVisible(show_close_button); |
| - minimize_button_->SetVisible(show_minimize_button); |
| - restore_button_->SetVisible(show_restore_button); |
| - title_label_->SetVisible(show_title_label); |
| - |
| // Layout the close button. |
| int right = width(); |
| - if (show_close_button) { |
| - gfx::Size close_button_size = close_button_->GetPreferredSize(); |
| - close_button_->SetBounds( |
| - width() - NonClientBorderThickness() - kCloseButtonAndBorderSpacing - |
| - close_button_size.width(), |
| - (NonClientTopBorderHeight() - close_button_size.height()) / 2, |
| - close_button_size.width(), |
| - close_button_size.height()); |
| - right = close_button_->x(); |
| - } |
| + gfx::Size close_button_size = close_button_->GetPreferredSize(); |
| + close_button_->SetBounds( |
| + width() - NonClientBorderThickness() - kCloseButtonAndBorderSpacing - |
| + close_button_size.width(), |
| + (NonClientTopBorderHeight() - close_button_size.height()) / 2, |
| + close_button_size.width(), |
| + close_button_size.height()); |
| + right = close_button_->x(); |
| // Layout the minimize/restore button. |
| views::ImageButton* minimize_or_restore_button = NULL; |
| - if (show_minimize_button) |
| + if (minimize_button_->visible()) |
| minimize_or_restore_button = minimize_button_; |
| - else if (show_restore_button) |
| + else if (restore_button_->visible()) |
| minimize_or_restore_button = restore_button_; |
| if (minimize_or_restore_button) { |
| gfx::Size button_size = minimize_or_restore_button->GetPreferredSize(); |
| @@ -517,15 +502,13 @@ void PanelBrowserFrameView::Layout() { |
| kIconSize); |
| // Layout the title. |
| - if (show_title_label) { |
| - int title_x = title_icon_->bounds().right() + kTitleSpacing; |
| - int title_height = BrowserFrame::GetTitleFont().GetHeight(); |
| - title_label_->SetBounds( |
| - title_x, |
| - icon_y + ((kIconSize - title_height - 1) / 2), |
| - std::max(0, right - kTitleSpacing - title_x), |
| - title_height); |
| - } |
| + int title_x = title_icon_->bounds().right() + kTitleSpacing; |
| + int title_height = BrowserFrame::GetTitleFont().GetHeight(); |
| + title_label_->SetBounds( |
| + title_x, |
| + icon_y + ((kIconSize - title_height - 1) / 2), |
| + std::max(0, right - kTitleSpacing - title_x), |
| + title_height); |
| // Calculate the client area bounds. |
| int top_height = NonClientTopBorderHeight(); |
| @@ -811,6 +794,13 @@ void PanelBrowserFrameView::UpdateTitleBar() { |
| title_label_->SetText(GetTitleText()); |
| } |
| +void PanelBrowserFrameView::UpdateTitleBarMinimizeRestoreButtonVisibility() { |
| + Panel* panel = panel_browser_view_->panel(); |
| + minimize_button_->SetVisible(panel->CanMinimize()); |
| + restore_button_->SetVisible(panel->CanRestore()); |
| + Layout(); |
|
Dmitry Titov
2012/05/02 03:23:08
Maybe we should layout both buttons in Layout() me
jennb
2012/05/02 19:10:35
Done.
|
| +} |
| + |
| bool PanelBrowserFrameView::CanResize() const { |
| return panel_browser_view_->panel()->CanResizeByMouse() != |
| panel::NOT_RESIZABLE; |