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 if (browser_view()->ShouldShowAvatar()) { |
Peter Kasting
2012/07/11 19:14:51
Nit: Shorter:
int space_left_of_tabstrip = brow
Alexei Svitkine (slow)
2012/07/11 19:21:41
Done.
| |
226 NonClientBorderThickness() + kTabStripIndent; | 226 // Adjust tab strip bounds to make room for the avatar. |
227 | 227 bounds.Inset(kAvatarLeftSpacing + avatar_bounds_.width() + |
228 int maximized_spacing = kNewTabCaptionMaximizedSpacing; | 228 kAvatarRightSpacing, 0, 0, 0); |
229 int tabstrip_width = | 229 } else { |
230 (minimize_button_ ? minimize_button_->x() : width()) - tabstrip_x - | 230 bounds.Inset(kTabStripIndent, 0, 0, 0); |
231 (frame()->IsMaximized() ? | 231 } |
232 maximized_spacing : kNewTabCaptionRestoredSpacing); | 232 return bounds; |
233 return gfx::Rect(tabstrip_x, GetHorizontalTabStripVerticalOffset(false), | |
234 std::max(0, tabstrip_width), tabstrip->GetPreferredSize().height()); | |
235 } | 233 } |
236 | 234 |
237 int OpaqueBrowserFrameView::GetHorizontalTabStripVerticalOffset( | 235 int OpaqueBrowserFrameView::GetHorizontalTabStripVerticalOffset( |
238 bool restored) const { | 236 bool restored) const { |
239 return NonClientTopBorderHeight(restored) + ((!restored && | 237 return NonClientTopBorderHeight(restored) + ((!restored && |
240 (frame()->IsMaximized() || | 238 (frame()->IsMaximized() || |
241 frame()->IsFullscreen())) ? | 239 frame()->IsFullscreen())) ? |
242 0 : kNonClientRestoredExtraThickness); | 240 0 : kNonClientRestoredExtraThickness); |
243 } | 241 } |
244 | 242 |
(...skipping 15 matching lines...) Expand all Loading... | |
260 (IconSize() + kTitleLogoSpacing) : 0); | 258 (IconSize() + kTitleLogoSpacing) : 0); |
261 #if !defined(OS_CHROMEOS) | 259 #if !defined(OS_CHROMEOS) |
262 if (ShouldAddDefaultCaptionButtons()) { | 260 if (ShouldAddDefaultCaptionButtons()) { |
263 min_titlebar_width += | 261 min_titlebar_width += |
264 minimize_button_->GetMinimumSize().width() + | 262 minimize_button_->GetMinimumSize().width() + |
265 restore_button_->GetMinimumSize().width() + | 263 restore_button_->GetMinimumSize().width() + |
266 close_button_->GetMinimumSize().width(); | 264 close_button_->GetMinimumSize().width(); |
267 } | 265 } |
268 #endif | 266 #endif |
269 min_size.set_width(std::max(min_size.width(), min_titlebar_width)); | 267 min_size.set_width(std::max(min_size.width(), min_titlebar_width)); |
268 | |
269 // Ensure that the minimum width is enough to hold a minimum width tab strip | |
270 // and avatar icon at their usual insets. | |
271 if (browser_view()->IsTabStripVisible()) { | |
272 TabStrip* tabstrip = browser_view()->tabstrip(); | |
273 const int min_tabstrip_width = tabstrip->GetMinimumSize().width(); | |
274 const int min_tabstrip_area_width = | |
275 width() - GetBoundsForTabStripAndAvatarArea(tabstrip).width() + | |
276 min_tabstrip_width + browser_view()->GetOTRAvatarIcon().width() + | |
277 kAvatarLeftSpacing + kAvatarRightSpacing; | |
278 min_size.set_width(std::max(min_size.width(), min_tabstrip_area_width)); | |
279 } | |
280 | |
270 return min_size; | 281 return min_size; |
271 } | 282 } |
272 | 283 |
273 /////////////////////////////////////////////////////////////////////////////// | 284 /////////////////////////////////////////////////////////////////////////////// |
274 // OpaqueBrowserFrameView, views::NonClientFrameView implementation: | 285 // OpaqueBrowserFrameView, views::NonClientFrameView implementation: |
275 | 286 |
276 gfx::Rect OpaqueBrowserFrameView::GetBoundsForClientView() const { | 287 gfx::Rect OpaqueBrowserFrameView::GetBoundsForClientView() const { |
277 return client_view_bounds_; | 288 return client_view_bounds_; |
278 } | 289 } |
279 | 290 |
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
560 y = unavailable_px_at_top + (NonClientTopBorderHeight(false) - | 571 y = unavailable_px_at_top + (NonClientTopBorderHeight(false) - |
561 unavailable_px_at_top - size - TitlebarBottomThickness(false) + 1) / 2; | 572 unavailable_px_at_top - size - TitlebarBottomThickness(false) + 1) / 2; |
562 } else { | 573 } else { |
563 // For "browser mode" windows, we use the native positioning, which is just | 574 // For "browser mode" windows, we use the native positioning, which is just |
564 // below the top frame border. | 575 // below the top frame border. |
565 y = frame_thickness; | 576 y = frame_thickness; |
566 } | 577 } |
567 return gfx::Rect(frame_thickness + kIconLeftSpacing, y, size, size); | 578 return gfx::Rect(frame_thickness + kIconLeftSpacing, y, size, size); |
568 } | 579 } |
569 | 580 |
581 gfx::Rect OpaqueBrowserFrameView::GetBoundsForTabStripAndAvatarArea( | |
582 views::View* tabstrip) const { | |
583 const int available_width = | |
584 minimize_button_ ? minimize_button_->x() : width(); | |
585 const int caption_spacing = frame()->IsMaximized() ? | |
586 kNewTabCaptionMaximizedSpacing : kNewTabCaptionRestoredSpacing; | |
587 const int tabstrip_x = NonClientBorderThickness(); | |
588 const int tabstrip_width = available_width - tabstrip_x - caption_spacing; | |
589 return gfx::Rect(tabstrip_x, GetHorizontalTabStripVerticalOffset(false), | |
590 std::max(0, tabstrip_width), | |
591 tabstrip->GetPreferredSize().height()); | |
592 } | |
593 | |
570 void OpaqueBrowserFrameView::PaintRestoredFrameBorder(gfx::Canvas* canvas) { | 594 void OpaqueBrowserFrameView::PaintRestoredFrameBorder(gfx::Canvas* canvas) { |
571 frame_background_->set_frame_color(GetFrameColor()); | 595 frame_background_->set_frame_color(GetFrameColor()); |
572 frame_background_->set_theme_image(GetFrameImage()); | 596 frame_background_->set_theme_image(GetFrameImage()); |
573 frame_background_->set_theme_overlay_image(GetFrameOverlayImage()); | 597 frame_background_->set_theme_overlay_image(GetFrameOverlayImage()); |
574 frame_background_->set_top_area_height(GetTopAreaHeight()); | 598 frame_background_->set_top_area_height(GetTopAreaHeight()); |
575 | 599 |
576 ui::ThemeProvider* tp = GetThemeProvider(); | 600 ui::ThemeProvider* tp = GetThemeProvider(); |
577 frame_background_->SetSideImages( | 601 frame_background_->SetSideImages( |
578 tp->GetImageSkiaNamed(IDR_WINDOW_LEFT_SIDE), | 602 tp->GetImageSkiaNamed(IDR_WINDOW_LEFT_SIDE), |
579 tp->GetImageSkiaNamed(IDR_WINDOW_TOP_CENTER), | 603 tp->GetImageSkiaNamed(IDR_WINDOW_TOP_CENTER), |
(...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1007 | 1031 |
1008 gfx::Rect OpaqueBrowserFrameView::CalculateClientAreaBounds(int width, | 1032 gfx::Rect OpaqueBrowserFrameView::CalculateClientAreaBounds(int width, |
1009 int height) const { | 1033 int height) const { |
1010 int top_height = NonClientTopBorderHeight(false); | 1034 int top_height = NonClientTopBorderHeight(false); |
1011 int border_thickness = NonClientBorderThickness(); | 1035 int border_thickness = NonClientBorderThickness(); |
1012 return gfx::Rect(border_thickness, top_height, | 1036 return gfx::Rect(border_thickness, top_height, |
1013 std::max(0, width - (2 * border_thickness)), | 1037 std::max(0, width - (2 * border_thickness)), |
1014 std::max(0, height - GetReservedHeight() - | 1038 std::max(0, height - GetReservedHeight() - |
1015 top_height - border_thickness)); | 1039 top_height - border_thickness)); |
1016 } | 1040 } |
OLD | NEW |