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

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

Issue 115838: Shift maximized mode tabstrip up by 1 px to avoid empty pixel at screen top.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 11 years, 7 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
« no previous file with comments | « chrome/browser/views/frame/glass_browser_frame_view.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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/views/frame/opaque_browser_frame_view.h" 5 #include "chrome/browser/views/frame/opaque_browser_frame_view.h"
6 6
7 #include "app/gfx/canvas.h" 7 #include "app/gfx/canvas.h"
8 #include "app/gfx/font.h" 8 #include "app/gfx/font.h"
9 #include "app/gfx/path.h" 9 #include "app/gfx/path.h"
10 #include "app/l10n_util.h" 10 #include "app/l10n_util.h"
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 // In maximized mode, the OTR avatar starts 2 px below the top of the screen, so 77 // In maximized mode, the OTR avatar starts 2 px below the top of the screen, so
78 // that it doesn't extend into the "3D edge" portion of the titlebar. 78 // that it doesn't extend into the "3D edge" portion of the titlebar.
79 const int kOTRMaximizedTopSpacing = 2; 79 const int kOTRMaximizedTopSpacing = 2;
80 // The OTR avatar ends 2 px above the bottom of the tabstrip (which, given the 80 // The OTR avatar ends 2 px above the bottom of the tabstrip (which, given the
81 // way the tabstrip draws its bottom edge, will appear like a 1 px gap to the 81 // way the tabstrip draws its bottom edge, will appear like a 1 px gap to the
82 // user). 82 // user).
83 const int kOTRBottomSpacing = 2; 83 const int kOTRBottomSpacing = 2;
84 // There are 2 px on each side of the OTR avatar (between the frame border and 84 // There are 2 px on each side of the OTR avatar (between the frame border and
85 // it on the left, and between it and the tabstrip on the right). 85 // it on the left, and between it and the tabstrip on the right).
86 const int kOTRSideSpacing = 2; 86 const int kOTRSideSpacing = 2;
87 // The top 1 px of the tabstrip is shadow; in maximized mode we push this off
88 // the top of the screen so the tabs appear flush against the screen edge.
89 const int kTabstripTopShadowThickness = 1;
87 // In restored mode, the New Tab button isn't at the same height as the caption 90 // In restored mode, the New Tab button isn't at the same height as the caption
88 // buttons, but the space will look cluttered if it actually slides under them, 91 // buttons, but the space will look cluttered if it actually slides under them,
89 // so we stop it when the gap between the two is down to 5 px. 92 // so we stop it when the gap between the two is down to 5 px.
90 const int kNewTabCaptionRestoredSpacing = 5; 93 const int kNewTabCaptionRestoredSpacing = 5;
91 // In maximized mode, where the New Tab button and the caption buttons are at 94 // In maximized mode, where the New Tab button and the caption buttons are at
92 // similar vertical coordinates, we need to reserve a larger, 16 px gap to avoid 95 // similar vertical coordinates, we need to reserve a larger, 16 px gap to avoid
93 // looking too cluttered. 96 // looking too cluttered.
94 const int kNewTabCaptionMaximizedSpacing = 16; 97 const int kNewTabCaptionMaximizedSpacing = 16;
95 // When there's a distributor logo, we leave a 7 px gap between it and the 98 // When there's a distributor logo, we leave a 7 px gap between it and the
96 // caption buttons. 99 // caption buttons.
97 const int kLogoCaptionSpacing = 7; 100 const int kLogoCaptionSpacing = 7;
98 // The caption buttons are always drawn 1 px down from the visible top of the
99 // window (the true top in restored mode, or the top of the screen in maximized
100 // mode).
101 const int kCaptionTopSpacing = 1;
102 } 101 }
103 102
104 /////////////////////////////////////////////////////////////////////////////// 103 ///////////////////////////////////////////////////////////////////////////////
105 // OpaqueBrowserFrameView, public: 104 // OpaqueBrowserFrameView, public:
106 105
107 OpaqueBrowserFrameView::OpaqueBrowserFrameView(BrowserFrame* frame, 106 OpaqueBrowserFrameView::OpaqueBrowserFrameView(BrowserFrame* frame,
108 BrowserView* browser_view) 107 BrowserView* browser_view)
109 : BrowserNonClientFrameView(), 108 : BrowserNonClientFrameView(),
110 minimize_button_(new views::ImageButton(this)), 109 minimize_button_(new views::ImageButton(this)),
111 maximize_button_(new views::ImageButton(this)), 110 maximize_button_(new views::ImageButton(this)),
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after
447 return FrameBorderThickness() + 446 return FrameBorderThickness() +
448 ((window->IsMaximized() || window->IsFullscreen()) ? 447 ((window->IsMaximized() || window->IsFullscreen()) ?
449 0 : kClientEdgeThickness); 448 0 : kClientEdgeThickness);
450 } 449 }
451 450
452 int OpaqueBrowserFrameView::NonClientTopBorderHeight() const { 451 int OpaqueBrowserFrameView::NonClientTopBorderHeight() const {
453 views::Window* window = frame_->GetWindow(); 452 views::Window* window = frame_->GetWindow();
454 if (window->GetDelegate()->ShouldShowWindowTitle()) 453 if (window->GetDelegate()->ShouldShowWindowTitle())
455 return TitleCoordinates(NULL, NULL); 454 return TitleCoordinates(NULL, NULL);
456 455
456 if (browser_view_->IsTabStripVisible() && window->IsMaximized())
457 return FrameBorderThickness() - kTabstripTopShadowThickness;
458
457 return FrameBorderThickness() + 459 return FrameBorderThickness() +
458 ((window->IsMaximized() || window->IsFullscreen()) ? 460 ((window->IsMaximized() || window->IsFullscreen()) ?
459 0 : kNonClientRestoredExtraThickness); 461 0 : kNonClientRestoredExtraThickness);
460 } 462 }
461 463
462 int OpaqueBrowserFrameView::UnavailablePixelsAtBottomOfNonClientHeight() const { 464 int OpaqueBrowserFrameView::UnavailablePixelsAtBottomOfNonClientHeight() const {
463 // Tricky: When a toolbar is edging the titlebar, it not only draws its own 465 // Tricky: When a toolbar is edging the titlebar, it not only draws its own
464 // shadow and client edge, but an extra, light "shadow" pixel as well, which 466 // shadow and client edge, but an extra, light "shadow" pixel as well, which
465 // is treated as available space. Thus the nonclient area actually _fails_ to 467 // is treated as available space. Thus the nonclient area actually _fails_ to
466 // include some available pixels, leading to a negative number here. 468 // include some available pixels, leading to a negative number here.
(...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after
833 client_area_top, left->width(), client_area_height); 835 client_area_top, left->width(), client_area_height);
834 } 836 }
835 837
836 void OpaqueBrowserFrameView::LayoutWindowControls() { 838 void OpaqueBrowserFrameView::LayoutWindowControls() {
837 close_button_->SetImageAlignment(views::ImageButton::ALIGN_LEFT, 839 close_button_->SetImageAlignment(views::ImageButton::ALIGN_LEFT,
838 views::ImageButton::ALIGN_BOTTOM); 840 views::ImageButton::ALIGN_BOTTOM);
839 // Maximized buttons start at window top so that even if their images aren't 841 // Maximized buttons start at window top so that even if their images aren't
840 // drawn flush with the screen edge, they still obey Fitts' Law. 842 // drawn flush with the screen edge, they still obey Fitts' Law.
841 bool is_maximized = frame_->GetWindow()->IsMaximized(); 843 bool is_maximized = frame_->GetWindow()->IsMaximized();
842 int frame_thickness = FrameBorderThickness(); 844 int frame_thickness = FrameBorderThickness();
843 int caption_y = is_maximized ? frame_thickness : kCaptionTopSpacing; 845 int caption_y = is_maximized ? frame_thickness : kFrameShadowThickness;
844 int top_extra_height = is_maximized ? kCaptionTopSpacing : 0;
845 // There should always be the same number of non-shadow pixels visible to the 846 // There should always be the same number of non-shadow pixels visible to the
846 // side of the caption buttons. In maximized mode we extend the rightmost 847 // side of the caption buttons. In maximized mode we extend the rightmost
847 // button to the screen corner to obey Fitts' Law. 848 // button to the screen corner to obey Fitts' Law.
848 int right_extra_width = is_maximized ? 849 int right_extra_width = is_maximized ?
849 (kFrameBorderThickness - kFrameShadowThickness) : 0; 850 (kFrameBorderThickness - kFrameShadowThickness) : 0;
850 gfx::Size close_button_size = close_button_->GetPreferredSize(); 851 gfx::Size close_button_size = close_button_->GetPreferredSize();
851 close_button_->SetBounds(width() - close_button_size.width() - 852 close_button_->SetBounds(width() - close_button_size.width() -
852 right_extra_width - frame_thickness, caption_y, 853 right_extra_width - frame_thickness, caption_y,
853 close_button_size.width() + right_extra_width, 854 close_button_size.width() + right_extra_width,
854 close_button_size.height() + top_extra_height); 855 close_button_size.height());
855 856
856 // When the window is restored, we show a maximized button; otherwise, we show 857 // When the window is restored, we show a maximized button; otherwise, we show
857 // a restore button. 858 // a restore button.
858 bool is_restored = !is_maximized && !frame_->GetWindow()->IsMinimized(); 859 bool is_restored = !is_maximized && !frame_->GetWindow()->IsMinimized();
859 views::ImageButton* invisible_button = is_restored ? 860 views::ImageButton* invisible_button = is_restored ?
860 restore_button_ : maximize_button_; 861 restore_button_ : maximize_button_;
861 invisible_button->SetVisible(false); 862 invisible_button->SetVisible(false);
862 863
863 views::ImageButton* visible_button = is_restored ? 864 views::ImageButton* visible_button = is_restored ?
864 maximize_button_ : restore_button_; 865 maximize_button_ : restore_button_;
865 visible_button->SetVisible(true); 866 visible_button->SetVisible(true);
866 visible_button->SetImageAlignment(views::ImageButton::ALIGN_LEFT, 867 visible_button->SetImageAlignment(views::ImageButton::ALIGN_LEFT,
867 views::ImageButton::ALIGN_BOTTOM); 868 views::ImageButton::ALIGN_BOTTOM);
868 gfx::Size visible_button_size = visible_button->GetPreferredSize(); 869 gfx::Size visible_button_size = visible_button->GetPreferredSize();
869 visible_button->SetBounds(close_button_->x() - visible_button_size.width(), 870 visible_button->SetBounds(close_button_->x() - visible_button_size.width(),
870 caption_y, visible_button_size.width(), 871 caption_y, visible_button_size.width(),
871 visible_button_size.height() + top_extra_height); 872 visible_button_size.height());
872 873
873 minimize_button_->SetVisible(true); 874 minimize_button_->SetVisible(true);
874 minimize_button_->SetImageAlignment(views::ImageButton::ALIGN_LEFT, 875 minimize_button_->SetImageAlignment(views::ImageButton::ALIGN_LEFT,
875 views::ImageButton::ALIGN_BOTTOM); 876 views::ImageButton::ALIGN_BOTTOM);
876 gfx::Size minimize_button_size = minimize_button_->GetPreferredSize(); 877 gfx::Size minimize_button_size = minimize_button_->GetPreferredSize();
877 minimize_button_->SetBounds( 878 minimize_button_->SetBounds(
878 visible_button->x() - minimize_button_size.width(), caption_y, 879 visible_button->x() - minimize_button_size.width(), caption_y,
879 minimize_button_size.width(), 880 minimize_button_size.width(),
880 minimize_button_size.height() + top_extra_height); 881 minimize_button_size.height());
881 } 882 }
882 883
883 void OpaqueBrowserFrameView::LayoutDistributorLogo() { 884 void OpaqueBrowserFrameView::LayoutDistributorLogo() {
884 // Always lay out the logo, even when it's not present, so we can lay out the 885 // Always lay out the logo, even when it's not present, so we can lay out the
885 // window title based on its position. 886 // window title based on its position.
886 if (distributor_logo_ && browser_view_->ShouldShowDistributorLogo()) { 887 if (distributor_logo_ && browser_view_->ShouldShowDistributorLogo()) {
887 logo_bounds_.SetRect(minimize_button_->x() - distributor_logo_->width() - 888 logo_bounds_.SetRect(minimize_button_->x() - distributor_logo_->width() -
888 kLogoCaptionSpacing, TopResizeHeight(), distributor_logo_->width(), 889 kLogoCaptionSpacing, TopResizeHeight(), distributor_logo_->width(),
889 distributor_logo_->height()); 890 distributor_logo_->height());
890 } else { 891 } else {
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
979 if (!initialized) { 980 if (!initialized) {
980 #if defined(OS_WIN) 981 #if defined(OS_WIN)
981 title_font_ = new gfx::Font(win_util::GetWindowTitleFont()); 982 title_font_ = new gfx::Font(win_util::GetWindowTitleFont());
982 #else 983 #else
983 NOTIMPLEMENTED(); 984 NOTIMPLEMENTED();
984 title_font_ = new gfx::Font(); 985 title_font_ = new gfx::Font();
985 #endif 986 #endif
986 initialized = true; 987 initialized = true;
987 } 988 }
988 } 989 }
OLDNEW
« no previous file with comments | « chrome/browser/views/frame/glass_browser_frame_view.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698