Chromium Code Reviews| 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/10 20:34:27
Nit: Simpler:
// Exclude avatar region, if pres
Alexei Svitkine (slow)
2012/07/10 20:51:47
That doesn't work, since that would be adding (ava
Peter Kasting
2012/07/10 22:47:11
Look carefully: I'm insetting by width(), not by r
| |
| 226 NonClientBorderThickness() + kTabStripIndent; | 226 // Adjust tab strip bounds to make room for the avatar. |
| 227 | 227 const int right = bounds.right(); |
| 228 int maximized_spacing = kNewTabCaptionMaximizedSpacing; | 228 bounds.set_x(avatar_bounds_.right() + kAvatarRightSpacing); |
| 229 int tabstrip_width = | 229 bounds.set_width(right - bounds.x()); |
| 230 (minimize_button_ ? minimize_button_->x() : width()) - tabstrip_x - | 230 } |
| 231 (frame()->IsMaximized() ? | 231 return bounds; |
| 232 maximized_spacing : kNewTabCaptionRestoredSpacing); | |
| 233 return gfx::Rect(tabstrip_x, GetHorizontalTabStripVerticalOffset(false), | |
| 234 std::max(0, tabstrip_width), tabstrip->GetPreferredSize().height()); | |
| 235 } | 232 } |
| 236 | 233 |
| 237 int OpaqueBrowserFrameView::GetHorizontalTabStripVerticalOffset( | 234 int OpaqueBrowserFrameView::GetHorizontalTabStripVerticalOffset( |
| 238 bool restored) const { | 235 bool restored) const { |
| 239 return NonClientTopBorderHeight(restored) + ((!restored && | 236 return NonClientTopBorderHeight(restored) + ((!restored && |
| 240 (frame()->IsMaximized() || | 237 (frame()->IsMaximized() || |
| 241 frame()->IsFullscreen())) ? | 238 frame()->IsFullscreen())) ? |
| 242 0 : kNonClientRestoredExtraThickness); | 239 0 : kNonClientRestoredExtraThickness); |
| 243 } | 240 } |
| 244 | 241 |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 260 (IconSize() + kTitleLogoSpacing) : 0); | 257 (IconSize() + kTitleLogoSpacing) : 0); |
| 261 #if !defined(OS_CHROMEOS) | 258 #if !defined(OS_CHROMEOS) |
| 262 if (ShouldAddDefaultCaptionButtons()) { | 259 if (ShouldAddDefaultCaptionButtons()) { |
| 263 min_titlebar_width += | 260 min_titlebar_width += |
| 264 minimize_button_->GetMinimumSize().width() + | 261 minimize_button_->GetMinimumSize().width() + |
| 265 restore_button_->GetMinimumSize().width() + | 262 restore_button_->GetMinimumSize().width() + |
| 266 close_button_->GetMinimumSize().width(); | 263 close_button_->GetMinimumSize().width(); |
| 267 } | 264 } |
| 268 #endif | 265 #endif |
| 269 min_size.set_width(std::max(min_size.width(), min_titlebar_width)); | 266 min_size.set_width(std::max(min_size.width(), min_titlebar_width)); |
| 267 | |
| 268 // Ensure that the minimum width is enough to hold a minimum width tab strip | |
| 269 // and avatar icon at their usual insets. | |
| 270 if (browser_view()->IsTabStripVisible()) { | |
| 271 TabStrip* tabstrip = browser_view()->tabstrip(); | |
| 272 const int min_tabstrip_width = tabstrip->GetMinimumSize().width(); | |
| 273 const int min_tabstrip_area_width = | |
| 274 width() - GetBoundsForTabStripAndAvatarArea(tabstrip).width() + | |
| 275 min_tabstrip_width + browser_view()->GetOTRAvatarIcon().width(); | |
|
Peter Kasting
2012/07/10 20:34:27
Don't you also need kAvatarRightSpacing in here?
Alexei Svitkine (slow)
2012/07/10 20:51:47
You're right. Done.
| |
| 276 min_size.set_width(std::max(min_tabstrip_area_width, min_size.width())); | |
|
Peter Kasting
2012/07/10 20:34:27
Tiny nit: For consistency with the max() call abov
Alexei Svitkine (slow)
2012/07/10 20:51:47
Done.
| |
| 277 } | |
| 278 | |
| 270 return min_size; | 279 return min_size; |
| 271 } | 280 } |
| 272 | 281 |
| 273 /////////////////////////////////////////////////////////////////////////////// | 282 /////////////////////////////////////////////////////////////////////////////// |
| 274 // OpaqueBrowserFrameView, views::NonClientFrameView implementation: | 283 // OpaqueBrowserFrameView, views::NonClientFrameView implementation: |
| 275 | 284 |
| 276 gfx::Rect OpaqueBrowserFrameView::GetBoundsForClientView() const { | 285 gfx::Rect OpaqueBrowserFrameView::GetBoundsForClientView() const { |
| 277 return client_view_bounds_; | 286 return client_view_bounds_; |
| 278 } | 287 } |
| 279 | 288 |
| (...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 560 y = unavailable_px_at_top + (NonClientTopBorderHeight(false) - | 569 y = unavailable_px_at_top + (NonClientTopBorderHeight(false) - |
| 561 unavailable_px_at_top - size - TitlebarBottomThickness(false) + 1) / 2; | 570 unavailable_px_at_top - size - TitlebarBottomThickness(false) + 1) / 2; |
| 562 } else { | 571 } else { |
| 563 // For "browser mode" windows, we use the native positioning, which is just | 572 // For "browser mode" windows, we use the native positioning, which is just |
| 564 // below the top frame border. | 573 // below the top frame border. |
| 565 y = frame_thickness; | 574 y = frame_thickness; |
| 566 } | 575 } |
| 567 return gfx::Rect(frame_thickness + kIconLeftSpacing, y, size, size); | 576 return gfx::Rect(frame_thickness + kIconLeftSpacing, y, size, size); |
| 568 } | 577 } |
| 569 | 578 |
| 579 gfx::Rect OpaqueBrowserFrameView::GetBoundsForTabStripAndAvatarArea( | |
| 580 views::View* tabstrip) const { | |
| 581 const int available_width = | |
|
Peter Kasting
2012/07/10 20:34:27
Nit: OK to drop parens on these next two statement
Alexei Svitkine (slow)
2012/07/10 20:51:47
Done.
| |
| 582 (minimize_button_ ? minimize_button_->x() : width()); | |
| 583 const int caption_spacing = (frame()->IsMaximized() ? | |
| 584 kNewTabCaptionMaximizedSpacing : kNewTabCaptionRestoredSpacing); | |
| 585 const int tabstrip_x = NonClientBorderThickness() + kTabStripIndent; | |
| 586 const int tabstrip_width = available_width - tabstrip_x - caption_spacing; | |
| 587 return gfx::Rect(tabstrip_x, GetHorizontalTabStripVerticalOffset(false), | |
| 588 std::max(0, tabstrip_width), | |
|
Peter Kasting
2012/07/10 20:34:27
Nit: Also OK to indent 4 and combine next line wit
Alexei Svitkine (slow)
2012/07/10 20:51:47
I feel that ends up being a bit too crowded in thi
| |
| 589 tabstrip->GetPreferredSize().height()); | |
| 590 } | |
| 591 | |
| 570 void OpaqueBrowserFrameView::PaintRestoredFrameBorder(gfx::Canvas* canvas) { | 592 void OpaqueBrowserFrameView::PaintRestoredFrameBorder(gfx::Canvas* canvas) { |
| 571 frame_background_->set_frame_color(GetFrameColor()); | 593 frame_background_->set_frame_color(GetFrameColor()); |
| 572 frame_background_->set_theme_image(GetFrameImage()); | 594 frame_background_->set_theme_image(GetFrameImage()); |
| 573 frame_background_->set_theme_overlay_image(GetFrameOverlayImage()); | 595 frame_background_->set_theme_overlay_image(GetFrameOverlayImage()); |
| 574 frame_background_->set_top_area_height(GetTopAreaHeight()); | 596 frame_background_->set_top_area_height(GetTopAreaHeight()); |
| 575 | 597 |
| 576 ui::ThemeProvider* tp = GetThemeProvider(); | 598 ui::ThemeProvider* tp = GetThemeProvider(); |
| 577 frame_background_->SetSideImages( | 599 frame_background_->SetSideImages( |
| 578 tp->GetImageSkiaNamed(IDR_WINDOW_LEFT_SIDE), | 600 tp->GetImageSkiaNamed(IDR_WINDOW_LEFT_SIDE), |
| 579 tp->GetImageSkiaNamed(IDR_WINDOW_TOP_CENTER), | 601 tp->GetImageSkiaNamed(IDR_WINDOW_TOP_CENTER), |
| (...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1007 | 1029 |
| 1008 gfx::Rect OpaqueBrowserFrameView::CalculateClientAreaBounds(int width, | 1030 gfx::Rect OpaqueBrowserFrameView::CalculateClientAreaBounds(int width, |
| 1009 int height) const { | 1031 int height) const { |
| 1010 int top_height = NonClientTopBorderHeight(false); | 1032 int top_height = NonClientTopBorderHeight(false); |
| 1011 int border_thickness = NonClientBorderThickness(); | 1033 int border_thickness = NonClientBorderThickness(); |
| 1012 return gfx::Rect(border_thickness, top_height, | 1034 return gfx::Rect(border_thickness, top_height, |
| 1013 std::max(0, width - (2 * border_thickness)), | 1035 std::max(0, width - (2 * border_thickness)), |
| 1014 std::max(0, height - GetReservedHeight() - | 1036 std::max(0, height - GetReservedHeight() - |
| 1015 top_height - border_thickness)); | 1037 top_height - border_thickness)); |
| 1016 } | 1038 } |
| OLD | NEW |