OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/views/frame/opaque_browser_frame_view.h" | 5 #include "chrome/browser/ui/views/frame/opaque_browser_frame_view.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
214 } | 214 } |
215 | 215 |
216 /////////////////////////////////////////////////////////////////////////////// | 216 /////////////////////////////////////////////////////////////////////////////// |
217 // OpaqueBrowserFrameView, BrowserNonClientFrameView implementation: | 217 // OpaqueBrowserFrameView, BrowserNonClientFrameView implementation: |
218 | 218 |
219 gfx::Rect OpaqueBrowserFrameView::GetBoundsForTabStrip( | 219 gfx::Rect OpaqueBrowserFrameView::GetBoundsForTabStrip( |
220 views::View* tabstrip) const { | 220 views::View* tabstrip) const { |
221 if (!tabstrip) | 221 if (!tabstrip) |
222 return gfx::Rect(); | 222 return gfx::Rect(); |
223 | 223 |
224 int tabstrip_x = browser_view()->ShouldShowAvatar() ? | 224 gfx::Rect bounds = GetBoundsForTabStripAndAvatarArea(tabstrip); |
225 (avatar_bounds_.right() + kAvatarRightSpacing) : | 225 const int space_left_of_tabstrip = browser_view()->ShouldShowAvatar() ? |
226 NonClientBorderThickness() + kTabStripIndent; | 226 (kAvatarLeftSpacing + avatar_bounds_.width() + kAvatarRightSpacing) : |
227 | 227 kTabStripIndent; |
228 int maximized_spacing = kNewTabCaptionMaximizedSpacing; | 228 bounds.Inset(space_left_of_tabstrip, 0, 0, 0); |
229 int tabstrip_width = | 229 return bounds; |
230 (minimize_button_ ? minimize_button_->x() : width()) - tabstrip_x - | |
231 (frame()->IsMaximized() ? | |
232 maximized_spacing : kNewTabCaptionRestoredSpacing); | |
233 return gfx::Rect(tabstrip_x, GetHorizontalTabStripVerticalOffset(false), | |
234 std::max(0, tabstrip_width), tabstrip->GetPreferredSize().height()); | |
235 } | 230 } |
236 | 231 |
237 int OpaqueBrowserFrameView::GetHorizontalTabStripVerticalOffset( | 232 int OpaqueBrowserFrameView::GetHorizontalTabStripVerticalOffset( |
238 bool restored) const { | 233 bool restored) const { |
239 return NonClientTopBorderHeight(restored) + ((!restored && | 234 return NonClientTopBorderHeight(restored) + ((!restored && |
240 (frame()->IsMaximized() || | 235 (frame()->IsMaximized() || |
241 frame()->IsFullscreen())) ? | 236 frame()->IsFullscreen())) ? |
242 0 : kNonClientRestoredExtraThickness); | 237 0 : kNonClientRestoredExtraThickness); |
243 } | 238 } |
244 | 239 |
(...skipping 15 matching lines...) Expand all Loading... |
260 (IconSize() + kTitleLogoSpacing) : 0); | 255 (IconSize() + kTitleLogoSpacing) : 0); |
261 #if !defined(OS_CHROMEOS) | 256 #if !defined(OS_CHROMEOS) |
262 if (ShouldAddDefaultCaptionButtons()) { | 257 if (ShouldAddDefaultCaptionButtons()) { |
263 min_titlebar_width += | 258 min_titlebar_width += |
264 minimize_button_->GetMinimumSize().width() + | 259 minimize_button_->GetMinimumSize().width() + |
265 restore_button_->GetMinimumSize().width() + | 260 restore_button_->GetMinimumSize().width() + |
266 close_button_->GetMinimumSize().width(); | 261 close_button_->GetMinimumSize().width(); |
267 } | 262 } |
268 #endif | 263 #endif |
269 min_size.set_width(std::max(min_size.width(), min_titlebar_width)); | 264 min_size.set_width(std::max(min_size.width(), min_titlebar_width)); |
| 265 |
| 266 // Ensure that the minimum width is enough to hold a minimum width tab strip |
| 267 // and avatar icon at their usual insets. |
| 268 if (browser_view()->IsTabStripVisible()) { |
| 269 TabStrip* tabstrip = browser_view()->tabstrip(); |
| 270 const int min_tabstrip_width = tabstrip->GetMinimumSize().width(); |
| 271 const int min_tabstrip_area_width = |
| 272 width() - GetBoundsForTabStripAndAvatarArea(tabstrip).width() + |
| 273 min_tabstrip_width + browser_view()->GetOTRAvatarIcon().width() + |
| 274 kAvatarLeftSpacing + kAvatarRightSpacing; |
| 275 min_size.set_width(std::max(min_size.width(), min_tabstrip_area_width)); |
| 276 } |
| 277 |
270 return min_size; | 278 return min_size; |
271 } | 279 } |
272 | 280 |
273 /////////////////////////////////////////////////////////////////////////////// | 281 /////////////////////////////////////////////////////////////////////////////// |
274 // OpaqueBrowserFrameView, views::NonClientFrameView implementation: | 282 // OpaqueBrowserFrameView, views::NonClientFrameView implementation: |
275 | 283 |
276 gfx::Rect OpaqueBrowserFrameView::GetBoundsForClientView() const { | 284 gfx::Rect OpaqueBrowserFrameView::GetBoundsForClientView() const { |
277 return client_view_bounds_; | 285 return client_view_bounds_; |
278 } | 286 } |
279 | 287 |
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
560 y = unavailable_px_at_top + (NonClientTopBorderHeight(false) - | 568 y = unavailable_px_at_top + (NonClientTopBorderHeight(false) - |
561 unavailable_px_at_top - size - TitlebarBottomThickness(false) + 1) / 2; | 569 unavailable_px_at_top - size - TitlebarBottomThickness(false) + 1) / 2; |
562 } else { | 570 } else { |
563 // For "browser mode" windows, we use the native positioning, which is just | 571 // For "browser mode" windows, we use the native positioning, which is just |
564 // below the top frame border. | 572 // below the top frame border. |
565 y = frame_thickness; | 573 y = frame_thickness; |
566 } | 574 } |
567 return gfx::Rect(frame_thickness + kIconLeftSpacing, y, size, size); | 575 return gfx::Rect(frame_thickness + kIconLeftSpacing, y, size, size); |
568 } | 576 } |
569 | 577 |
| 578 gfx::Rect OpaqueBrowserFrameView::GetBoundsForTabStripAndAvatarArea( |
| 579 views::View* tabstrip) const { |
| 580 const int available_width = |
| 581 minimize_button_ ? minimize_button_->x() : width(); |
| 582 const int caption_spacing = frame()->IsMaximized() ? |
| 583 kNewTabCaptionMaximizedSpacing : kNewTabCaptionRestoredSpacing; |
| 584 const int tabstrip_x = NonClientBorderThickness(); |
| 585 const int tabstrip_width = available_width - tabstrip_x - caption_spacing; |
| 586 return gfx::Rect(tabstrip_x, GetHorizontalTabStripVerticalOffset(false), |
| 587 std::max(0, tabstrip_width), |
| 588 tabstrip->GetPreferredSize().height()); |
| 589 } |
| 590 |
570 void OpaqueBrowserFrameView::PaintRestoredFrameBorder(gfx::Canvas* canvas) { | 591 void OpaqueBrowserFrameView::PaintRestoredFrameBorder(gfx::Canvas* canvas) { |
571 frame_background_->set_frame_color(GetFrameColor()); | 592 frame_background_->set_frame_color(GetFrameColor()); |
572 frame_background_->set_theme_image(GetFrameImage()); | 593 frame_background_->set_theme_image(GetFrameImage()); |
573 frame_background_->set_theme_overlay_image(GetFrameOverlayImage()); | 594 frame_background_->set_theme_overlay_image(GetFrameOverlayImage()); |
574 frame_background_->set_top_area_height(GetTopAreaHeight()); | 595 frame_background_->set_top_area_height(GetTopAreaHeight()); |
575 | 596 |
576 ui::ThemeProvider* tp = GetThemeProvider(); | 597 ui::ThemeProvider* tp = GetThemeProvider(); |
577 frame_background_->SetSideImages( | 598 frame_background_->SetSideImages( |
578 tp->GetImageSkiaNamed(IDR_WINDOW_LEFT_SIDE), | 599 tp->GetImageSkiaNamed(IDR_WINDOW_LEFT_SIDE), |
579 tp->GetImageSkiaNamed(IDR_WINDOW_TOP_CENTER), | 600 tp->GetImageSkiaNamed(IDR_WINDOW_TOP_CENTER), |
(...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1007 | 1028 |
1008 gfx::Rect OpaqueBrowserFrameView::CalculateClientAreaBounds(int width, | 1029 gfx::Rect OpaqueBrowserFrameView::CalculateClientAreaBounds(int width, |
1009 int height) const { | 1030 int height) const { |
1010 int top_height = NonClientTopBorderHeight(false); | 1031 int top_height = NonClientTopBorderHeight(false); |
1011 int border_thickness = NonClientBorderThickness(); | 1032 int border_thickness = NonClientBorderThickness(); |
1012 return gfx::Rect(border_thickness, top_height, | 1033 return gfx::Rect(border_thickness, top_height, |
1013 std::max(0, width - (2 * border_thickness)), | 1034 std::max(0, width - (2 * border_thickness)), |
1014 std::max(0, height - GetReservedHeight() - | 1035 std::max(0, height - GetReservedHeight() - |
1015 top_height - border_thickness)); | 1036 top_height - border_thickness)); |
1016 } | 1037 } |
OLD | NEW |