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

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

Issue 2616523004: Layout avatar button
Patch Set: More stuff Created 3 years, 11 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
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/glass_browser_frame_view.h" 5 #include "chrome/browser/ui/views/frame/glass_browser_frame_view.h"
6 6
7 #include <dwmapi.h> 7 #include <dwmapi.h>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/win/windows_version.h" 10 #include "base/win/windows_version.h"
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 namespace { 42 namespace {
43 // Thickness of the frame edge between the non-client area and the web content. 43 // Thickness of the frame edge between the non-client area and the web content.
44 const int kClientBorderThickness = 3; 44 const int kClientBorderThickness = 3;
45 // Besides the frame border, there's empty space atop the window in restored 45 // Besides the frame border, there's empty space atop the window in restored
46 // mode, to use to drag the window around. 46 // mode, to use to drag the window around.
47 const int kNonClientRestoredExtraThickness = 11; 47 const int kNonClientRestoredExtraThickness = 11;
48 // At the window corners the resize area is not actually bigger, but the 16 48 // At the window corners the resize area is not actually bigger, but the 16
49 // pixels at the end of the top and bottom edges trigger diagonal resizing. 49 // pixels at the end of the top and bottom edges trigger diagonal resizing.
50 const int kResizeCornerWidth = 16; 50 const int kResizeCornerWidth = 16;
51 // How far the profile switcher button is from the left of the minimize button. 51 // How far the profile switcher button is from the left of the minimize button.
52 const int kProfileSwitcherButtonOffset = 5; 52 const int kProfileSwitcherButtonOffset = 1;
53 // The content edge images have a shadow built into them. 53 // The content edge images have a shadow built into them.
54 const int kContentEdgeShadowThickness = 2; 54 const int kContentEdgeShadowThickness = 2;
55 // In restored mode, the New Tab button isn't at the same height as the caption 55 // In restored mode, the New Tab button isn't at the same height as the caption
56 // buttons, but the space will look cluttered if it actually slides under them, 56 // buttons, but the space will look cluttered if it actually slides under them,
57 // so we stop it when the gap between the two is down to 5 px. 57 // so we stop it when the gap between the two is down to 5 px.
58 const int kNewTabCaptionRestoredSpacing = 5; 58 const int kNewTabCaptionRestoredSpacing = 5;
59 // In maximized mode, where the New Tab button and the caption buttons are at 59 // In maximized mode, where the New Tab button and the caption buttons are at
60 // similar vertical coordinates, we need to reserve a larger, 16 px gap to avoid 60 // similar vertical coordinates, we need to reserve a larger, 16 px gap to avoid
61 // looking too cluttered. 61 // looking too cluttered.
62 const int kNewTabCaptionMaximizedSpacing = 16; 62 const int kNewTabCaptionMaximizedSpacing = 16;
63 // Height of the profile switcher button. Same as the height of the Windows 7/8 63 // Minimum and maximux width of the profile switcher button.
64 // caption buttons. 64 const int kProfileSwitcherButtonMinWidth = 48;
65 // TODO(bsep): Windows 10 caption buttons look very different and we would like 65 const int kProfileSwictherButtonMaxWidth = 96;
66 // the profile switcher button to match on that platform.
67 const int kProfileSwitcherButtonHeight = 20;
68 // There is a small one-pixel strip right above the caption buttons in which the 66 // There is a small one-pixel strip right above the caption buttons in which the
69 // resize border "peeks" through. 67 // resize border "peeks" through.
70 const int kCaptionButtonTopInset = 1; 68 const int kCaptionButtonTopInset = 1;
71 69
72 // Converts the |image| to a Windows icon and returns the corresponding HICON 70 // Converts the |image| to a Windows icon and returns the corresponding HICON
73 // handle. |image| is resized to desired |width| and |height| if needed. 71 // handle. |image| is resized to desired |width| and |height| if needed.
74 base::win::ScopedHICON CreateHICONFromSkBitmapSizedTo( 72 base::win::ScopedHICON CreateHICONFromSkBitmapSizedTo(
75 const gfx::ImageSkia& image, 73 const gfx::ImageSkia& image,
76 int width, 74 int width,
77 int height) { 75 int height) {
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 : kNewTabCaptionRestoredSpacing); 145 : kNewTabCaptionRestoredSpacing);
148 146
149 // The profile switcher button is optionally displayed to the left of the 147 // The profile switcher button is optionally displayed to the left of the
150 // minimize button. 148 // minimize button.
151 if (profile_switcher_.view()) { 149 if (profile_switcher_.view()) {
152 const int old_end_x = end_x; 150 const int old_end_x = end_x;
153 end_x -= profile_switcher_.view()->width() + kProfileSwitcherButtonOffset; 151 end_x -= profile_switcher_.view()->width() + kProfileSwitcherButtonOffset;
154 152
155 // In non-maximized mode, allow the new tab button to slide completely 153 // In non-maximized mode, allow the new tab button to slide completely
156 // under the profile switcher button. 154 // under the profile switcher button.
157 if (!IsMaximized()) { 155 //if (!IsMaximized()) {
158 end_x = std::min(end_x + GetLayoutSize(NEW_TAB_BUTTON).width() + 156 // end_x = std::min(end_x + GetLayoutSize(NEW_TAB_BUTTON).width() +
159 kNewTabCaptionRestoredSpacing, 157 // kNewTabCaptionRestoredSpacing,
160 old_end_x); 158 // old_end_x);
161 } 159 //}
162 } 160 }
163 } 161 }
164 return gfx::Rect(x, TopAreaHeight(false), std::max(0, end_x - x), 162 return gfx::Rect(x, TopAreaHeight(false), std::max(0, end_x - x),
165 tabstrip->GetPreferredSize().height()); 163 tabstrip->GetPreferredSize().height());
166 } 164 }
167 165
168 int GlassBrowserFrameView::GetTopInset(bool restored) const { 166 int GlassBrowserFrameView::GetTopInset(bool restored) const {
169 return GetClientAreaInsets(restored).top(); 167 return GetClientAreaInsets(restored).top();
170 } 168 }
171 169
(...skipping 538 matching lines...) Expand 10 before | Expand all | Expand 10 after
710 color); 708 color);
711 side.set_x(right); 709 side.set_x(right);
712 canvas->FillRect(side, color); 710 canvas->FillRect(side, color);
713 } 711 }
714 712
715 void GlassBrowserFrameView::LayoutProfileSwitcher() { 713 void GlassBrowserFrameView::LayoutProfileSwitcher() {
716 DCHECK(browser_view()->IsRegularOrGuestSession()); 714 DCHECK(browser_view()->IsRegularOrGuestSession());
717 if (!profile_switcher_.view()) 715 if (!profile_switcher_.view())
718 return; 716 return;
719 717
720 gfx::Size label_size = profile_switcher_.view()->GetPreferredSize(); 718 gfx::Size button_size = profile_switcher_.view()->GetPreferredSize();
719 int button_width = std::min(std::max(button_size.width(), kProfileSwitcherButt onMinWidth), kProfileSwictherButtonMaxWidth);
721 720
722 int button_x; 721 int button_x;
723 if (CaptionButtonsOnLeadingEdge()) { 722 if (CaptionButtonsOnLeadingEdge()) {
724 button_x = width() - frame()->GetMinimizeButtonOffset() + 723 button_x = width() - frame()->GetMinimizeButtonOffset() +
725 kProfileSwitcherButtonOffset; 724 kProfileSwitcherButtonOffset;
726 } else { 725 } else {
727 button_x = 726 button_x = MinimizeButtonX() - kProfileSwitcherButtonOffset - button_width;
728 MinimizeButtonX() - kProfileSwitcherButtonOffset - label_size.width();
729 } 727 }
730 728
731 int button_y = WindowTopY(); 729 int button_y = WindowTopY();
730 int button_height = frame()->GetMinimizeButtonHeight();
732 if (IsMaximized()) { 731 if (IsMaximized()) {
733 // In maximized mode the caption buttons appear only 19 pixels high, but 732 // In maximized mode the caption buttons appear only 19 pixels high, but
734 // their contents are aligned as if they were 20 pixels high and extended 733 // their contents are aligned as if they were 20 pixels high and extended
735 // 1 pixel off the top of the screen. We position the profile switcher 734 // 1 pixel off the top of the screen. We position the profile switcher
736 // button the same way to match. 735 // button the same way to match.
737 button_y -= 1; 736 button_height -= 3;
738 } 737 }
739 profile_switcher_.view()->SetBounds(button_x, button_y, label_size.width(), 738
740 kProfileSwitcherButtonHeight); 739 profile_switcher_.view()->SetBounds(button_x, button_y, button_width, button_h eight);
740 //if (browser_view()->tabstrip()) {
741 // LOG(ERROR) << "tabstrip->GetPreferredSize(): " << browser_view()->tabstrip ()->GetPreferredSize().ToString();
742 // gfx::Rect tabstrip_bounds = GetBoundsForTabStrip(browser_view()->tabstrip( ));
743 // LOG(ERROR) << "tabstrip_bounds: " << tabstrip_bounds.ToString() << " - max _x" << browser_view()->tabstrip()->max_x();
744 // LOG(ERROR) << "Profile Swicther Bounds: " << profile_switcher_.view()->Get MirroredBounds().ToString();
745 // LOG(ERROR) << "--------";
746 // if (browser_view()->tabstrip()->max_x() >= button_x) {
747 // profile_switcher_.view()->SetBounds(button_x, button_y, button_width, 19 );
748 // }
749 // }
750 LOG(ERROR) << "Minimize Button Bounds: " << minimize_button_->GetMirroredBound s().ToString();
751 LOG(ERROR) << "Profile Swicther Bounds: " << profile_switcher_.view()->GetMirr oredBounds().ToString();
741 } 752 }
742 753
743 void GlassBrowserFrameView::LayoutIncognitoIcon() { 754 void GlassBrowserFrameView::LayoutIncognitoIcon() {
744 const gfx::Size size(GetIncognitoAvatarIcon().size()); 755 const gfx::Size size(GetIncognitoAvatarIcon().size());
745 int x = ClientBorderThickness(false); 756 int x = ClientBorderThickness(false);
746 // In RTL, the icon needs to start after the caption buttons. 757 // In RTL, the icon needs to start after the caption buttons.
747 if (CaptionButtonsOnLeadingEdge()) { 758 if (CaptionButtonsOnLeadingEdge()) {
748 x = width() - frame()->GetMinimizeButtonOffset() + 759 x = width() - frame()->GetMinimizeButtonOffset() +
749 (profile_switcher_.view() ? (profile_switcher_.view()->width() + 760 (profile_switcher_.view() ? (profile_switcher_.view()->width() +
750 kProfileSwitcherButtonOffset) 761 kProfileSwitcherButtonOffset)
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
912 static bool initialized = false; 923 static bool initialized = false;
913 if (!initialized) { 924 if (!initialized) {
914 for (int i = 0; i < kThrobberIconCount; ++i) { 925 for (int i = 0; i < kThrobberIconCount; ++i) {
915 throbber_icons_[i] = 926 throbber_icons_[i] =
916 ui::LoadThemeIconFromResourcesDataDLL(IDI_THROBBER_01 + i); 927 ui::LoadThemeIconFromResourcesDataDLL(IDI_THROBBER_01 + i);
917 DCHECK(throbber_icons_[i]); 928 DCHECK(throbber_icons_[i]);
918 } 929 }
919 initialized = true; 930 initialized = true;
920 } 931 }
921 } 932 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698