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

Side by Side Diff: chrome/browser/ui/views/frame/opaque_browser_frame_view.cc

Issue 10821002: Makes the min window size include the OTR image and caption buttons on (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Cleanup Created 8 years, 5 months 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 return gfx::Rect(); 223 return gfx::Rect();
224 224
225 gfx::Rect bounds = GetBoundsForTabStripAndAvatarArea(tabstrip); 225 gfx::Rect bounds = GetBoundsForTabStripAndAvatarArea(tabstrip);
226 const int space_left_of_tabstrip = browser_view()->ShouldShowAvatar() ? 226 const int space_left_of_tabstrip = browser_view()->ShouldShowAvatar() ?
227 (kAvatarLeftSpacing + avatar_bounds_.width() + kAvatarRightSpacing) : 227 (kAvatarLeftSpacing + avatar_bounds_.width() + kAvatarRightSpacing) :
228 kTabStripIndent; 228 kTabStripIndent;
229 bounds.Inset(space_left_of_tabstrip, 0, 0, 0); 229 bounds.Inset(space_left_of_tabstrip, 0, 0, 0);
230 return bounds; 230 return bounds;
231 } 231 }
232 232
233 int OpaqueBrowserFrameView::GetHorizontalTabStripVerticalOffset( 233 BrowserNonClientFrameView::TabStripInsets
234 bool restored) const { 234 OpaqueBrowserFrameView::GetTabStripInsets(bool restored) const {
235 return NonClientTopBorderHeight(restored) + ((!restored && 235 int top = NonClientTopBorderHeight(restored) + ((!restored &&
236 (frame()->IsMaximized() || 236 (frame()->IsMaximized() ||
237 frame()->IsFullscreen())) ? 237 frame()->IsFullscreen())) ?
238 0 : kNonClientRestoredExtraThickness); 238 0 : kNonClientRestoredExtraThickness);
239 // TODO: include OTR and caption.
240 return TabStripInsets(top, 0, 0);
239 } 241 }
240 242
241 void OpaqueBrowserFrameView::UpdateThrobber(bool running) { 243 void OpaqueBrowserFrameView::UpdateThrobber(bool running) {
242 if (window_icon_) 244 if (window_icon_)
243 window_icon_->Update(); 245 window_icon_->Update();
244 } 246 }
245 247
246 gfx::Size OpaqueBrowserFrameView::GetMinimumSize() { 248 gfx::Size OpaqueBrowserFrameView::GetMinimumSize() {
247 gfx::Size min_size(browser_view()->GetMinimumSize()); 249 gfx::Size min_size(browser_view()->GetMinimumSize());
248 int border_thickness = NonClientBorderThickness(); 250 int border_thickness = NonClientBorderThickness();
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after
577 } 579 }
578 580
579 gfx::Rect OpaqueBrowserFrameView::GetBoundsForTabStripAndAvatarArea( 581 gfx::Rect OpaqueBrowserFrameView::GetBoundsForTabStripAndAvatarArea(
580 views::View* tabstrip) const { 582 views::View* tabstrip) const {
581 const int available_width = 583 const int available_width =
582 minimize_button_ ? minimize_button_->x() : width(); 584 minimize_button_ ? minimize_button_->x() : width();
583 const int caption_spacing = frame()->IsMaximized() ? 585 const int caption_spacing = frame()->IsMaximized() ?
584 kNewTabCaptionMaximizedSpacing : kNewTabCaptionRestoredSpacing; 586 kNewTabCaptionMaximizedSpacing : kNewTabCaptionRestoredSpacing;
585 const int tabstrip_x = NonClientBorderThickness(); 587 const int tabstrip_x = NonClientBorderThickness();
586 const int tabstrip_width = available_width - tabstrip_x - caption_spacing; 588 const int tabstrip_width = available_width - tabstrip_x - caption_spacing;
587 return gfx::Rect(tabstrip_x, GetHorizontalTabStripVerticalOffset(false), 589 return gfx::Rect(tabstrip_x, GetTabStripInsets(false).top,
588 std::max(0, tabstrip_width), 590 std::max(0, tabstrip_width),
589 tabstrip->GetPreferredSize().height()); 591 tabstrip->GetPreferredSize().height());
590 } 592 }
591 593
592 void OpaqueBrowserFrameView::PaintRestoredFrameBorder(gfx::Canvas* canvas) { 594 void OpaqueBrowserFrameView::PaintRestoredFrameBorder(gfx::Canvas* canvas) {
593 frame_background_->set_frame_color(GetFrameColor()); 595 frame_background_->set_frame_color(GetFrameColor());
594 frame_background_->set_theme_image(GetFrameImage()); 596 frame_background_->set_theme_image(GetFrameImage());
595 frame_background_->set_theme_overlay_image(GetFrameOverlayImage()); 597 frame_background_->set_theme_overlay_image(GetFrameOverlayImage());
596 frame_background_->set_top_area_height(GetTopAreaHeight()); 598 frame_background_->set_top_area_height(GetTopAreaHeight());
597 599
(...skipping 18 matching lines...) Expand all
616 618
617 void OpaqueBrowserFrameView::PaintMaximizedFrameBorder(gfx::Canvas* canvas) { 619 void OpaqueBrowserFrameView::PaintMaximizedFrameBorder(gfx::Canvas* canvas) {
618 frame_background_->set_frame_color(GetFrameColor()); 620 frame_background_->set_frame_color(GetFrameColor());
619 frame_background_->set_theme_image(GetFrameImage()); 621 frame_background_->set_theme_image(GetFrameImage());
620 frame_background_->set_theme_overlay_image(GetFrameOverlayImage()); 622 frame_background_->set_theme_overlay_image(GetFrameOverlayImage());
621 frame_background_->set_top_area_height(GetTopAreaHeight()); 623 frame_background_->set_top_area_height(GetTopAreaHeight());
622 624
623 // Theme frame must be aligned with the tabstrip as if we were 625 // Theme frame must be aligned with the tabstrip as if we were
624 // in restored mode. Note that the top of the tabstrip is 626 // in restored mode. Note that the top of the tabstrip is
625 // kTabstripTopShadowThickness px off the top of the screen. 627 // kTabstripTopShadowThickness px off the top of the screen.
626 int theme_background_y = -(GetHorizontalTabStripVerticalOffset(true) + 628 int theme_background_y = -(GetTabStripInsets(true).top +
627 kTabstripTopShadowThickness); 629 kTabstripTopShadowThickness);
628 frame_background_->set_theme_background_y(theme_background_y); 630 frame_background_->set_theme_background_y(theme_background_y);
629 631
630 frame_background_->PaintMaximized(canvas, this); 632 frame_background_->PaintMaximized(canvas, this);
631 633
632 // TODO(jamescook): Migrate this into FrameBackground. 634 // TODO(jamescook): Migrate this into FrameBackground.
633 if (!browser_view()->IsToolbarVisible()) { 635 if (!browser_view()->IsToolbarVisible()) {
634 // There's no toolbar to edge the frame border, so we need to draw a bottom 636 // There's no toolbar to edge the frame border, so we need to draw a bottom
635 // edge. The graphic we use for this has a built in client edge, so we clip 637 // edge. The graphic we use for this has a built in client edge, so we clip
636 // it off the bottom. 638 // it off the bottom.
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
702 gfx::ImageSkia* theme_toolbar = browser_view()->GetToolbarBackgroundImage( 704 gfx::ImageSkia* theme_toolbar = browser_view()->GetToolbarBackgroundImage(
703 browser_view()->browser()->search_model()->mode().mode); 705 browser_view()->browser()->search_model()->mode().mode);
704 706
705 // Paint the bottom rect. 707 // Paint the bottom rect.
706 canvas->FillRect(gfx::Rect(x, bottom_y, w, bottom_edge_height), 708 canvas->FillRect(gfx::Rect(x, bottom_y, w, bottom_edge_height),
707 background_color); 709 background_color);
708 710
709 // Tile the toolbar image starting at the frame edge on the left and where the 711 // Tile the toolbar image starting at the frame edge on the left and where the
710 // horizontal tabstrip is (or would be) on the top. 712 // horizontal tabstrip is (or would be) on the top.
711 canvas->TileImageInt(*theme_toolbar, x, 713 canvas->TileImageInt(*theme_toolbar, x,
712 bottom_y - GetHorizontalTabStripVerticalOffset(false), x, 714 bottom_y - GetTabStripInsets(false).top, x,
713 bottom_y, w, theme_toolbar->height()); 715 bottom_y, w, theme_toolbar->height());
714 716
715 // Draw rounded corners for the tab. 717 // Draw rounded corners for the tab.
716 gfx::ImageSkia* toolbar_left_mask = 718 gfx::ImageSkia* toolbar_left_mask =
717 tp->GetImageSkiaNamed(IDR_CONTENT_TOP_LEFT_CORNER_MASK); 719 tp->GetImageSkiaNamed(IDR_CONTENT_TOP_LEFT_CORNER_MASK);
718 gfx::ImageSkia* toolbar_right_mask = 720 gfx::ImageSkia* toolbar_right_mask =
719 tp->GetImageSkiaNamed(IDR_CONTENT_TOP_RIGHT_CORNER_MASK); 721 tp->GetImageSkiaNamed(IDR_CONTENT_TOP_RIGHT_CORNER_MASK);
720 722
721 // We mask out the corners by using the DestinationIn transfer mode, 723 // We mask out the corners by using the DestinationIn transfer mode,
722 // which keeps the RGB pixels from the destination and the alpha from 724 // which keeps the RGB pixels from the destination and the alpha from
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after
1006 title_height); 1008 title_height);
1007 } 1009 }
1008 } 1010 }
1009 1011
1010 void OpaqueBrowserFrameView::LayoutAvatar() { 1012 void OpaqueBrowserFrameView::LayoutAvatar() {
1011 // Even though the avatar is used for both incognito and profiles we always 1013 // Even though the avatar is used for both incognito and profiles we always
1012 // use the incognito icon to layout the avatar button. The profile icon 1014 // use the incognito icon to layout the avatar button. The profile icon
1013 // can be customized so we can't depend on its size to perform layout. 1015 // can be customized so we can't depend on its size to perform layout.
1014 gfx::ImageSkia incognito_icon = browser_view()->GetOTRAvatarIcon(); 1016 gfx::ImageSkia incognito_icon = browser_view()->GetOTRAvatarIcon();
1015 1017
1016 int avatar_bottom = GetHorizontalTabStripVerticalOffset(false) + 1018 int avatar_bottom = GetTabStripInsets(false).top +
1017 browser_view()->GetTabStripHeight() - kAvatarBottomSpacing; 1019 browser_view()->GetTabStripHeight() - kAvatarBottomSpacing;
1018 int avatar_restored_y = avatar_bottom - incognito_icon.height(); 1020 int avatar_restored_y = avatar_bottom - incognito_icon.height();
1019 int avatar_y = frame()->IsMaximized() ? 1021 int avatar_y = frame()->IsMaximized() ?
1020 (NonClientTopBorderHeight(false) + kTabstripTopShadowThickness) : 1022 (NonClientTopBorderHeight(false) + kTabstripTopShadowThickness) :
1021 avatar_restored_y; 1023 avatar_restored_y;
1022 avatar_bounds_.SetRect(NonClientBorderThickness() + kAvatarLeftSpacing, 1024 avatar_bounds_.SetRect(NonClientBorderThickness() + kAvatarLeftSpacing,
1023 avatar_y, incognito_icon.width(), 1025 avatar_y, incognito_icon.width(),
1024 browser_view()->ShouldShowAvatar() ? (avatar_bottom - avatar_y) : 0); 1026 browser_view()->ShouldShowAvatar() ? (avatar_bottom - avatar_y) : 0);
1025 1027
1026 if (avatar_button()) 1028 if (avatar_button())
1027 avatar_button()->SetBoundsRect(avatar_bounds_); 1029 avatar_button()->SetBoundsRect(avatar_bounds_);
1028 } 1030 }
1029 1031
1030 gfx::Rect OpaqueBrowserFrameView::CalculateClientAreaBounds(int width, 1032 gfx::Rect OpaqueBrowserFrameView::CalculateClientAreaBounds(int width,
1031 int height) const { 1033 int height) const {
1032 int top_height = NonClientTopBorderHeight(false); 1034 int top_height = NonClientTopBorderHeight(false);
1033 int border_thickness = NonClientBorderThickness(); 1035 int border_thickness = NonClientBorderThickness();
1034 return gfx::Rect(border_thickness, top_height, 1036 return gfx::Rect(border_thickness, top_height,
1035 std::max(0, width - (2 * border_thickness)), 1037 std::max(0, width - (2 * border_thickness)),
1036 std::max(0, height - GetReservedHeight() - 1038 std::max(0, height - GetReservedHeight() -
1037 top_height - border_thickness)); 1039 top_height - border_thickness));
1038 } 1040 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/frame/opaque_browser_frame_view.h ('k') | chrome/browser/ui/views/frame/popup_non_client_frame_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698