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/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 Loading... | |
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 | |
64 // caption buttons. | |
65 // TODO(bsep): Windows 10 caption buttons look very different and we would like | |
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 | 63 // There is a small one-pixel strip right above the caption buttons in which the |
69 // resize border "peeks" through. | 64 // resize border "peeks" through. |
70 const int kCaptionButtonTopInset = 1; | 65 const int kCaptionButtonTopInset = 1; |
71 | 66 |
72 // Converts the |image| to a Windows icon and returns the corresponding HICON | 67 // Converts the |image| to a Windows icon and returns the corresponding HICON |
73 // handle. |image| is resized to desired |width| and |height| if needed. | 68 // handle. |image| is resized to desired |width| and |height| if needed. |
74 base::win::ScopedHICON CreateHICONFromSkBitmapSizedTo( | 69 base::win::ScopedHICON CreateHICONFromSkBitmapSizedTo( |
75 const gfx::ImageSkia& image, | 70 const gfx::ImageSkia& image, |
76 int width, | 71 int width, |
77 int height) { | 72 int height) { |
(...skipping 14 matching lines...) Expand all Loading... | |
92 BrowserView* browser_view) | 87 BrowserView* browser_view) |
93 : BrowserNonClientFrameView(frame, browser_view), | 88 : BrowserNonClientFrameView(frame, browser_view), |
94 window_icon_(nullptr), | 89 window_icon_(nullptr), |
95 window_title_(nullptr), | 90 window_title_(nullptr), |
96 profile_switcher_(this), | 91 profile_switcher_(this), |
97 minimize_button_(nullptr), | 92 minimize_button_(nullptr), |
98 maximize_button_(nullptr), | 93 maximize_button_(nullptr), |
99 restore_button_(nullptr), | 94 restore_button_(nullptr), |
100 close_button_(nullptr), | 95 close_button_(nullptr), |
101 throbber_running_(false), | 96 throbber_running_(false), |
102 throbber_frame_(0) { | 97 throbber_frame_(0), |
98 tab_strip_(nullptr) { | |
103 // We initialize all fields despite some of them being unused in some modes, | 99 // We initialize all fields despite some of them being unused in some modes, |
104 // since it's possible for modes to flip dynamically (e.g. if the user enables | 100 // since it's possible for modes to flip dynamically (e.g. if the user enables |
105 // a high-contrast theme). Throbber icons are only used when ShowSystemIcon() | 101 // a high-contrast theme). Throbber icons are only used when ShowSystemIcon() |
106 // is true. Everything else here is only used when | 102 // is true. Everything else here is only used when |
107 // ShouldCustomDrawSystemTitlebar() is true. | 103 // ShouldCustomDrawSystemTitlebar() is true. |
108 | 104 |
109 if (browser_view->ShouldShowWindowIcon()) { | 105 if (browser_view->ShouldShowWindowIcon()) { |
110 InitThrobberIcons(); | 106 InitThrobberIcons(); |
111 | 107 |
112 window_icon_ = new TabIconView(this, nullptr); | 108 window_icon_ = new TabIconView(this, nullptr); |
(...skipping 12 matching lines...) Expand all Loading... | |
125 AddChildView(window_title_); | 121 AddChildView(window_title_); |
126 } | 122 } |
127 | 123 |
128 minimize_button_ = CreateCaptionButton(VIEW_ID_MINIMIZE_BUTTON); | 124 minimize_button_ = CreateCaptionButton(VIEW_ID_MINIMIZE_BUTTON); |
129 maximize_button_ = CreateCaptionButton(VIEW_ID_MAXIMIZE_BUTTON); | 125 maximize_button_ = CreateCaptionButton(VIEW_ID_MAXIMIZE_BUTTON); |
130 restore_button_ = CreateCaptionButton(VIEW_ID_RESTORE_BUTTON); | 126 restore_button_ = CreateCaptionButton(VIEW_ID_RESTORE_BUTTON); |
131 close_button_ = CreateCaptionButton(VIEW_ID_CLOSE_BUTTON); | 127 close_button_ = CreateCaptionButton(VIEW_ID_CLOSE_BUTTON); |
132 } | 128 } |
133 | 129 |
134 GlassBrowserFrameView::~GlassBrowserFrameView() { | 130 GlassBrowserFrameView::~GlassBrowserFrameView() { |
131 if (tab_strip_) { | |
132 tab_strip_->RemoveObserver(this); | |
133 tab_strip_ = nullptr; | |
134 } | |
135 } | 135 } |
136 | 136 |
137 /////////////////////////////////////////////////////////////////////////////// | 137 /////////////////////////////////////////////////////////////////////////////// |
138 // GlassBrowserFrameView, BrowserNonClientFrameView implementation: | 138 // GlassBrowserFrameView, BrowserNonClientFrameView implementation: |
139 | 139 |
140 gfx::Rect GlassBrowserFrameView::GetBoundsForTabStrip( | 140 gfx::Rect GlassBrowserFrameView::GetBoundsForTabStrip( |
141 views::View* tabstrip) const { | 141 views::View* tabstrip) const { |
142 const int x = incognito_bounds_.right() + kAvatarIconPadding; | 142 const int x = incognito_bounds_.right() + kAvatarIconPadding; |
143 int end_x = width() - ClientBorderThickness(false); | 143 int end_x = width() - ClientBorderThickness(false); |
144 if (!CaptionButtonsOnLeadingEdge()) { | 144 if (!CaptionButtonsOnLeadingEdge()) { |
145 end_x = std::min(MinimizeButtonX(), end_x) - | 145 end_x = std::min(MinimizeButtonX(), end_x) - |
146 (IsMaximized() ? kNewTabCaptionMaximizedSpacing | 146 (IsMaximized() ? kNewTabCaptionMaximizedSpacing |
147 : kNewTabCaptionRestoredSpacing); | 147 : kNewTabCaptionRestoredSpacing); |
148 | 148 |
149 // The profile switcher button is optionally displayed to the left of the | 149 // The profile switcher button is optionally displayed to the left of the |
150 // minimize button. | 150 // minimize button. |
151 if (profile_switcher_.view()) { | 151 views::View* button_view = GetProfileSwitcherView(); |
152 if (button_view) { | |
152 const int old_end_x = end_x; | 153 const int old_end_x = end_x; |
153 end_x -= profile_switcher_.view()->width() + kProfileSwitcherButtonOffset; | 154 end_x -= button_view->width() + kProfileSwitcherButtonOffset; |
154 | 155 |
155 // In non-maximized mode, allow the new tab button to slide completely | 156 // In non-maximized mode, allow the new tab button to slide completely |
156 // under the profile switcher button. | 157 // under the profile switcher button. |
158 // Note that the button should be "cozy" then, even if it's an MD button. | |
157 if (!IsMaximized()) { | 159 if (!IsMaximized()) { |
158 end_x = std::min(end_x + GetLayoutSize(NEW_TAB_BUTTON).width() + | 160 end_x = std::min(end_x + GetLayoutSize(NEW_TAB_BUTTON).width() + |
159 kNewTabCaptionRestoredSpacing, | 161 kNewTabCaptionRestoredSpacing, |
160 old_end_x); | 162 old_end_x); |
161 } | 163 } |
162 } | 164 } |
163 } | 165 } |
164 return gfx::Rect(x, TopAreaHeight(false), std::max(0, end_x - x), | 166 return gfx::Rect(x, TopAreaHeight(false), std::max(0, end_x - x), |
165 tabstrip->GetPreferredSize().height()); | 167 tabstrip->GetPreferredSize().height()); |
166 } | 168 } |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
207 int min_tabstrip_width = tabstrip->GetMinimumSize().width(); | 209 int min_tabstrip_width = tabstrip->GetMinimumSize().width(); |
208 int min_tabstrip_area_width = | 210 int min_tabstrip_area_width = |
209 width() - GetBoundsForTabStrip(tabstrip).width() + min_tabstrip_width; | 211 width() - GetBoundsForTabStrip(tabstrip).width() + min_tabstrip_width; |
210 min_size.set_width(std::max(min_tabstrip_area_width, min_size.width())); | 212 min_size.set_width(std::max(min_tabstrip_area_width, min_size.width())); |
211 } | 213 } |
212 | 214 |
213 return min_size; | 215 return min_size; |
214 } | 216 } |
215 | 217 |
216 views::View* GlassBrowserFrameView::GetProfileSwitcherView() const { | 218 views::View* GlassBrowserFrameView::GetProfileSwitcherView() const { |
217 return profile_switcher_.view(); | 219 return profile_switcher_.button(); |
220 } | |
221 | |
222 void GlassBrowserFrameView::OnBrowserViewInitViewsComplete() { | |
223 DCHECK(browser_view()->tabstrip()); | |
224 DCHECK(!tab_strip_); | |
225 tab_strip_ = browser_view()->tabstrip(); | |
226 tab_strip_->AddObserver(this); | |
218 } | 227 } |
219 | 228 |
220 /////////////////////////////////////////////////////////////////////////////// | 229 /////////////////////////////////////////////////////////////////////////////// |
221 // GlassBrowserFrameView, views::NonClientFrameView implementation: | 230 // GlassBrowserFrameView, views::NonClientFrameView implementation: |
222 | 231 |
223 gfx::Rect GlassBrowserFrameView::GetBoundsForClientView() const { | 232 gfx::Rect GlassBrowserFrameView::GetBoundsForClientView() const { |
224 return client_view_bounds_; | 233 return client_view_bounds_; |
225 } | 234 } |
226 | 235 |
227 gfx::Rect GlassBrowserFrameView::GetWindowBoundsForClientBounds( | 236 gfx::Rect GlassBrowserFrameView::GetWindowBoundsForClientBounds( |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
263 return HTNOWHERE; | 272 return HTNOWHERE; |
264 | 273 |
265 // If the point isn't within our bounds, then it's in the native portion of | 274 // If the point isn't within our bounds, then it's in the native portion of |
266 // the frame so again Windows can figure it out. | 275 // the frame so again Windows can figure it out. |
267 if (!bounds().Contains(point)) | 276 if (!bounds().Contains(point)) |
268 return HTNOWHERE; | 277 return HTNOWHERE; |
269 | 278 |
270 // See if the point is within the incognito icon or the profile switcher menu. | 279 // See if the point is within the incognito icon or the profile switcher menu. |
271 if ((profile_indicator_icon() && | 280 if ((profile_indicator_icon() && |
272 profile_indicator_icon()->GetMirroredBounds().Contains(point)) || | 281 profile_indicator_icon()->GetMirroredBounds().Contains(point)) || |
273 (profile_switcher_.view() && | 282 (GetProfileSwitcherView() && |
274 profile_switcher_.view()->GetMirroredBounds().Contains(point))) | 283 GetProfileSwitcherView()->GetMirroredBounds().Contains(point))) |
275 return HTCLIENT; | 284 return HTCLIENT; |
276 | 285 |
277 int frame_component = frame()->client_view()->NonClientHitTest(point); | 286 int frame_component = frame()->client_view()->NonClientHitTest(point); |
278 | 287 |
279 // See if we're in the sysmenu region. We still have to check the tabstrip | 288 // See if we're in the sysmenu region. We still have to check the tabstrip |
280 // first so that clicks in a tab don't get treated as sysmenu clicks. | 289 // first so that clicks in a tab don't get treated as sysmenu clicks. |
281 int client_border_thickness = ClientBorderThickness(false); | 290 int client_border_thickness = ClientBorderThickness(false); |
282 gfx::Rect sys_menu_region( | 291 gfx::Rect sys_menu_region( |
283 client_border_thickness, | 292 client_border_thickness, |
284 display::win::ScreenWin::GetSystemMetricsInDIP(SM_CYSIZEFRAME), | 293 display::win::ScreenWin::GetSystemMetricsInDIP(SM_CYSIZEFRAME), |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
399 // must be called prior to LayoutProfileSwitcher(). | 408 // must be called prior to LayoutProfileSwitcher(). |
400 LayoutCaptionButtons(); | 409 LayoutCaptionButtons(); |
401 LayoutTitleBar(); | 410 LayoutTitleBar(); |
402 } | 411 } |
403 if (browser_view()->IsRegularOrGuestSession()) | 412 if (browser_view()->IsRegularOrGuestSession()) |
404 LayoutProfileSwitcher(); | 413 LayoutProfileSwitcher(); |
405 LayoutIncognitoIcon(); | 414 LayoutIncognitoIcon(); |
406 LayoutClientView(); | 415 LayoutClientView(); |
407 } | 416 } |
408 | 417 |
418 void GlassBrowserFrameView::ChildPreferredSizeChanged(views::View* child) { | |
419 if (child == profile_switcher_.button()) { | |
420 // Need to layout the root view here so that the line below the tabstrip | |
421 // is re-drawn properly when a profile is added or removed and the avatar | |
422 // button changes between tall and cozy as a result. | |
423 frame()->GetRootView()->Layout(); | |
424 } | |
425 } | |
426 | |
409 /////////////////////////////////////////////////////////////////////////////// | 427 /////////////////////////////////////////////////////////////////////////////// |
410 // GlassBrowserFrameView, protected: | 428 // GlassBrowserFrameView, protected: |
411 | 429 |
412 // BrowserNonClientFrameView: | 430 // BrowserNonClientFrameView: |
413 void GlassBrowserFrameView::UpdateProfileIcons() { | 431 void GlassBrowserFrameView::UpdateProfileIcons() { |
414 if (browser_view()->IsRegularOrGuestSession()) | 432 if (browser_view()->IsRegularOrGuestSession()) |
415 profile_switcher_.Update(AvatarButtonStyle::NATIVE); | 433 profile_switcher_.Update(AvatarButtonStyle::NATIVE); |
416 else | 434 else |
417 UpdateProfileIndicatorIcon(); | 435 UpdateProfileIndicatorIcon(); |
418 } | 436 } |
419 | 437 |
420 /////////////////////////////////////////////////////////////////////////////// | 438 /////////////////////////////////////////////////////////////////////////////// |
421 // GlassBrowserFrameView, private: | 439 // GlassBrowserFrameView, private: |
422 | 440 |
423 // views::NonClientFrameView: | 441 // views::NonClientFrameView: |
424 bool GlassBrowserFrameView::DoesIntersectRect(const views::View* target, | 442 bool GlassBrowserFrameView::DoesIntersectRect(const views::View* target, |
425 const gfx::Rect& rect) const { | 443 const gfx::Rect& rect) const { |
426 if (ShouldCustomDrawSystemTitlebar()) | 444 if (ShouldCustomDrawSystemTitlebar()) |
427 return BrowserNonClientFrameView::DoesIntersectRect(target, rect); | 445 return BrowserNonClientFrameView::DoesIntersectRect(target, rect); |
428 | 446 |
429 // TODO(bsep): This override has "dead zones" where you can't click on the | 447 // TODO(bsep): This override has "dead zones" where you can't click on the |
430 // custom titlebar buttons. It's not clear why it's necessary at all. | 448 // custom titlebar buttons. It's not clear why it's necessary at all. |
431 // Investigate tearing this out. | 449 // Investigate tearing this out. |
432 CHECK_EQ(target, this); | 450 CHECK_EQ(target, this); |
433 bool hit_incognito_icon = | 451 bool hit_incognito_icon = |
434 profile_indicator_icon() && | 452 profile_indicator_icon() && |
435 profile_indicator_icon()->GetMirroredBounds().Intersects(rect); | 453 profile_indicator_icon()->GetMirroredBounds().Intersects(rect); |
436 bool hit_profile_switcher_button = | 454 bool hit_profile_switcher_button = |
437 profile_switcher_.view() && | 455 GetProfileSwitcherView() && |
438 profile_switcher_.view()->GetMirroredBounds().Intersects(rect); | 456 GetProfileSwitcherView()->GetMirroredBounds().Intersects(rect); |
439 return hit_incognito_icon || hit_profile_switcher_button || | 457 return hit_incognito_icon || hit_profile_switcher_button || |
440 !frame()->client_view()->bounds().Intersects(rect); | 458 !frame()->client_view()->bounds().Intersects(rect); |
441 } | 459 } |
442 | 460 |
443 int GlassBrowserFrameView::ClientBorderThickness(bool restored) const { | 461 int GlassBrowserFrameView::ClientBorderThickness(bool restored) const { |
444 // The frame ends abruptly at the 1 pixel window border drawn by Windows 10. | 462 // The frame ends abruptly at the 1 pixel window border drawn by Windows 10. |
445 if (!browser_view()->HasClientEdge()) | 463 if (!browser_view()->HasClientEdge()) |
446 return 0; | 464 return 0; |
447 | 465 |
448 if ((IsMaximized() || frame()->IsFullscreen()) && !restored) | 466 if ((IsMaximized() || frame()->IsFullscreen()) && !restored) |
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
708 gfx::Canvas* canvas) const { | 726 gfx::Canvas* canvas) const { |
709 gfx::Rect side(x - kClientEdgeThickness, y, kClientEdgeThickness, | 727 gfx::Rect side(x - kClientEdgeThickness, y, kClientEdgeThickness, |
710 bottom + kClientEdgeThickness - y); | 728 bottom + kClientEdgeThickness - y); |
711 canvas->FillRect(side, color); | 729 canvas->FillRect(side, color); |
712 canvas->FillRect(gfx::Rect(x, bottom, right - x, kClientEdgeThickness), | 730 canvas->FillRect(gfx::Rect(x, bottom, right - x, kClientEdgeThickness), |
713 color); | 731 color); |
714 side.set_x(right); | 732 side.set_x(right); |
715 canvas->FillRect(side, color); | 733 canvas->FillRect(side, color); |
716 } | 734 } |
717 | 735 |
736 void GlassBrowserFrameView::TabStripMaxXChanged(TabStrip* tab_strip) { | |
737 // May switch between cozy and tall MD avatar button here. | |
738 DCHECK_EQ(tab_strip, tab_strip_); | |
739 ChildPreferredSizeChanged(profile_switcher_.button()); | |
740 } | |
741 | |
742 void GlassBrowserFrameView::TabStripRemovedTabAt(TabStrip* tab_strip, | |
743 int index) { | |
744 // May switch between cozy and tall button here, too. TabStripMaxXChanged | |
745 // is not enough when a tab other than the last tab is closed. | |
746 DCHECK_EQ(tab_strip, tab_strip_); | |
747 ChildPreferredSizeChanged(profile_switcher_.button()); | |
748 } | |
749 | |
750 void GlassBrowserFrameView::TabStripDeleted(TabStrip* tab_strip) { | |
751 DCHECK_EQ(tab_strip, tab_strip_); | |
752 DCHECK(tab_strip_); | |
753 tab_strip_->RemoveObserver(this); | |
754 tab_strip_ = nullptr; | |
755 } | |
756 | |
718 void GlassBrowserFrameView::LayoutProfileSwitcher() { | 757 void GlassBrowserFrameView::LayoutProfileSwitcher() { |
719 DCHECK(browser_view()->IsRegularOrGuestSession()); | 758 DCHECK(browser_view()->IsRegularOrGuestSession()); |
720 if (!profile_switcher_.view()) | 759 |
760 AvatarButton* avatar_button = profile_switcher_.button(); | |
761 if (!avatar_button) | |
721 return; | 762 return; |
722 | 763 |
723 gfx::Size label_size = profile_switcher_.view()->GetPreferredSize(); | 764 gfx::Size button_size = avatar_button->GetPreferredSize(); |
765 int button_width = button_size.width(); | |
766 int button_height = button_size.height(); | |
724 | 767 |
725 int button_x; | 768 int button_x; |
726 if (CaptionButtonsOnLeadingEdge()) { | 769 if (CaptionButtonsOnLeadingEdge()) { |
727 button_x = width() - frame()->GetMinimizeButtonOffset() + | 770 button_x = width() - frame()->GetMinimizeButtonOffset() + |
728 kProfileSwitcherButtonOffset; | 771 kProfileSwitcherButtonOffset; |
729 } else { | 772 } else { |
730 button_x = | 773 button_x = MinimizeButtonX() - kProfileSwitcherButtonOffset - button_width; |
731 MinimizeButtonX() - kProfileSwitcherButtonOffset - label_size.width(); | |
732 } | 774 } |
733 | 775 |
734 int button_y = WindowTopY(); | 776 int button_y = WindowTopY(); |
735 if (IsMaximized()) { | 777 if (IsMaximized()) { |
736 // In maximized mode the caption buttons appear only 19 pixels high, but | 778 // In maximized mode the caption buttons appear only 19 pixels high, but |
737 // their contents are aligned as if they were 20 pixels high and extended | 779 // their contents are aligned as if they were 20 pixels high and extended |
738 // 1 pixel off the top of the screen. We position the profile switcher | 780 // 1 pixel off the top of the screen. We position the profile switcher |
739 // button the same way to match. | 781 // button the same way to match. |
740 button_y -= 1; | 782 button_y -= 1; |
741 } | 783 } |
742 profile_switcher_.view()->SetBounds(button_x, button_y, label_size.width(), | 784 |
743 kProfileSwitcherButtonHeight); | 785 avatar_button->UpdateButtonHeightForPosition(button_x, &button_height); |
Evan Stade
2017/04/28 18:38:29
I would rearrange these calculations slightly. You
emx
2017/05/02 15:17:11
Yes, that simplifies things a lot and now I don't
| |
786 avatar_button->SetBounds(button_x, button_y, button_width, button_height); | |
744 } | 787 } |
745 | 788 |
746 void GlassBrowserFrameView::LayoutIncognitoIcon() { | 789 void GlassBrowserFrameView::LayoutIncognitoIcon() { |
747 const gfx::Size size(GetIncognitoAvatarIcon().size()); | 790 const gfx::Size size(GetIncognitoAvatarIcon().size()); |
748 int x = ClientBorderThickness(false); | 791 int x = ClientBorderThickness(false); |
749 // In RTL, the icon needs to start after the caption buttons. | 792 // In RTL, the icon needs to start after the caption buttons. |
750 if (CaptionButtonsOnLeadingEdge()) { | 793 if (CaptionButtonsOnLeadingEdge()) { |
751 x = width() - frame()->GetMinimizeButtonOffset() + | 794 x = width() - frame()->GetMinimizeButtonOffset() + |
752 (profile_switcher_.view() ? (profile_switcher_.view()->width() + | 795 (GetProfileSwitcherView() ? (GetProfileSwitcherView()->width() + |
753 kProfileSwitcherButtonOffset) | 796 kProfileSwitcherButtonOffset) |
754 : 0); | 797 : 0); |
755 } | 798 } |
756 const int bottom = GetTopInset(false) + browser_view()->GetTabStripHeight() - | 799 const int bottom = GetTopInset(false) + browser_view()->GetTabStripHeight() - |
757 kAvatarIconPadding; | 800 kAvatarIconPadding; |
758 incognito_bounds_.SetRect( | 801 incognito_bounds_.SetRect( |
759 x + (profile_indicator_icon() ? kAvatarIconPadding : 0), | 802 x + (profile_indicator_icon() ? kAvatarIconPadding : 0), |
760 bottom - size.height(), profile_indicator_icon() ? size.width() : 0, | 803 bottom - size.height(), profile_indicator_icon() ? size.width() : 0, |
761 size.height()); | 804 size.height()); |
762 if (profile_indicator_icon()) | 805 if (profile_indicator_icon()) |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
915 static bool initialized = false; | 958 static bool initialized = false; |
916 if (!initialized) { | 959 if (!initialized) { |
917 for (int i = 0; i < kThrobberIconCount; ++i) { | 960 for (int i = 0; i < kThrobberIconCount; ++i) { |
918 throbber_icons_[i] = | 961 throbber_icons_[i] = |
919 ui::LoadThemeIconFromResourcesDataDLL(IDI_THROBBER_01 + i); | 962 ui::LoadThemeIconFromResourcesDataDLL(IDI_THROBBER_01 + i); |
920 DCHECK(throbber_icons_[i]); | 963 DCHECK(throbber_icons_[i]); |
921 } | 964 } |
922 initialized = true; | 965 initialized = true; |
923 } | 966 } |
924 } | 967 } |
OLD | NEW |