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

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

Issue 18083014: Create new look of the avatar label. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove unneeded code and use fixed font size. Created 7 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/glass_browser_frame_view.h" 5 #include "chrome/browser/ui/views/frame/glass_browser_frame_view.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/prefs/pref_service.h" 8 #include "base/prefs/pref_service.h"
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "chrome/app/chrome_command_ids.h" 10 #include "chrome/app/chrome_command_ids.h"
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 /////////////////////////////////////////////////////////////////////////////// 98 ///////////////////////////////////////////////////////////////////////////////
99 // GlassBrowserFrameView, BrowserNonClientFrameView implementation: 99 // GlassBrowserFrameView, BrowserNonClientFrameView implementation:
100 100
101 gfx::Rect GlassBrowserFrameView::GetBoundsForTabStrip( 101 gfx::Rect GlassBrowserFrameView::GetBoundsForTabStrip(
102 views::View* tabstrip) const { 102 views::View* tabstrip) const {
103 int minimize_button_offset = 103 int minimize_button_offset =
104 std::min(frame()->GetMinimizeButtonOffset(), width()); 104 std::min(frame()->GetMinimizeButtonOffset(), width());
105 int tabstrip_x = browser_view()->ShouldShowAvatar() ? 105 int tabstrip_x = browser_view()->ShouldShowAvatar() ?
106 (avatar_bounds_.right() + kAvatarRightSpacing) : 106 (avatar_bounds_.right() + kAvatarRightSpacing) :
107 NonClientBorderThickness() + kTabStripIndent; 107 NonClientBorderThickness() + kTabStripIndent;
108 if (avatar_label()) {
109 tabstrip_x += avatar_label()->bounds().width() +
110 views::kRelatedControlHorizontalSpacing;
111 }
112 // In RTL languages, we have moved an avatar icon left by the size of window 108 // In RTL languages, we have moved an avatar icon left by the size of window
113 // controls to prevent it from being rendered over them. So, we use its x 109 // controls to prevent it from being rendered over them. So, we use its x
114 // position to move this tab strip left when maximized. Also, we can render 110 // position to move this tab strip left when maximized. Also, we can render
115 // a tab strip until the left end of this window without considering the size 111 // a tab strip until the left end of this window without considering the size
116 // of window controls in RTL languages. 112 // of window controls in RTL languages.
117 if (base::i18n::IsRTL()) { 113 if (base::i18n::IsRTL()) {
118 if (!browser_view()->ShouldShowAvatar() && frame()->IsMaximized()) 114 if (!browser_view()->ShouldShowAvatar() && frame()->IsMaximized())
119 tabstrip_x += avatar_bounds_.x(); 115 tabstrip_x += avatar_bounds_.x();
120 minimize_button_offset = width(); 116 minimize_button_offset = width();
121 } 117 }
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 int GlassBrowserFrameView::NonClientHitTest(const gfx::Point& point) { 198 int GlassBrowserFrameView::NonClientHitTest(const gfx::Point& point) {
203 // If the browser isn't in normal mode, we haven't customized the frame, so 199 // If the browser isn't in normal mode, we haven't customized the frame, so
204 // Windows can figure this out. If the point isn't within our bounds, then 200 // Windows can figure this out. If the point isn't within our bounds, then
205 // it's in the native portion of the frame, so again Windows can figure it 201 // it's in the native portion of the frame, so again Windows can figure it
206 // out. 202 // out.
207 if (!browser_view()->IsBrowserTypeNormal() || !bounds().Contains(point)) 203 if (!browser_view()->IsBrowserTypeNormal() || !bounds().Contains(point))
208 return HTNOWHERE; 204 return HTNOWHERE;
209 205
210 // See if the point is within the avatar menu button or within the avatar 206 // See if the point is within the avatar menu button or within the avatar
211 // label. 207 // label.
212 if ((avatar_button() && 208 if (avatar_button() && avatar_button()->GetMirroredBounds().Contains(point))
213 avatar_button()->GetMirroredBounds().Contains(point)) ||
214 (avatar_label() && avatar_label()->GetMirroredBounds().Contains(point)))
215 return HTCLIENT; 209 return HTCLIENT;
216 210
217 int frame_component = frame()->client_view()->NonClientHitTest(point); 211 int frame_component = frame()->client_view()->NonClientHitTest(point);
218 212
219 // See if we're in the sysmenu region. We still have to check the tabstrip 213 // See if we're in the sysmenu region. We still have to check the tabstrip
220 // first so that clicks in a tab don't get treated as sysmenu clicks. 214 // first so that clicks in a tab don't get treated as sysmenu clicks.
221 int nonclient_border_thickness = NonClientBorderThickness(); 215 int nonclient_border_thickness = NonClientBorderThickness();
222 if (gfx::Rect(nonclient_border_thickness, GetSystemMetrics(SM_CXSIZEFRAME), 216 if (gfx::Rect(nonclient_border_thickness, GetSystemMetrics(SM_CXSIZEFRAME),
223 GetSystemMetrics(SM_CXSMICON), 217 GetSystemMetrics(SM_CXSMICON),
224 GetSystemMetrics(SM_CYSMICON)).Contains(point)) 218 GetSystemMetrics(SM_CYSMICON)).Contains(point))
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
421 int avatar_bottom = GetTabStripInsets(false).top + 415 int avatar_bottom = GetTabStripInsets(false).top +
422 browser_view()->GetTabStripHeight() - kAvatarBottomSpacing; 416 browser_view()->GetTabStripHeight() - kAvatarBottomSpacing;
423 int avatar_restored_y = avatar_bottom - incognito_icon.height(); 417 int avatar_restored_y = avatar_bottom - incognito_icon.height();
424 int avatar_y = frame()->IsMaximized() ? 418 int avatar_y = frame()->IsMaximized() ?
425 (NonClientTopBorderHeight(false) + kTabstripTopShadowThickness) : 419 (NonClientTopBorderHeight(false) + kTabstripTopShadowThickness) :
426 avatar_restored_y; 420 avatar_restored_y;
427 avatar_bounds_.SetRect(avatar_x, avatar_y, incognito_icon.width(), 421 avatar_bounds_.SetRect(avatar_x, avatar_y, incognito_icon.width(),
428 browser_view()->ShouldShowAvatar() ? (avatar_bottom - avatar_y) : 0); 422 browser_view()->ShouldShowAvatar() ? (avatar_bottom - avatar_y) : 0);
429 if (avatar_button()) 423 if (avatar_button())
430 avatar_button()->SetBoundsRect(avatar_bounds_); 424 avatar_button()->SetBoundsRect(avatar_bounds_);
431
432 if (avatar_label()) {
433 gfx::Size size = avatar_label()->GetPreferredSize();
434 int label_height = std::min(avatar_bounds_.height(), size.height());
435 gfx::Rect label_bounds(
436 avatar_bounds_.right() + views::kRelatedControlHorizontalSpacing,
437 avatar_y + (avatar_bounds_.height() - label_height) / 2,
438 size.width(),
439 browser_view()->ShouldShowAvatar() ? size.height() : 0);
440 avatar_label()->SetBoundsRect(label_bounds);
441 }
442 } 425 }
443 426
444 void GlassBrowserFrameView::LayoutClientView() { 427 void GlassBrowserFrameView::LayoutClientView() {
445 client_view_bounds_ = CalculateClientAreaBounds(width(), height()); 428 client_view_bounds_ = CalculateClientAreaBounds(width(), height());
446 } 429 }
447 430
448 gfx::Insets GlassBrowserFrameView::GetClientAreaInsets() const { 431 gfx::Insets GlassBrowserFrameView::GetClientAreaInsets() const {
449 if (!browser_view()->IsTabStripVisible()) 432 if (!browser_view()->IsTabStripVisible())
450 return gfx::Insets(); 433 return gfx::Insets();
451 434
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
529 static bool initialized = false; 512 static bool initialized = false;
530 if (!initialized) { 513 if (!initialized) {
531 for (int i = 0; i < kThrobberIconCount; ++i) { 514 for (int i = 0; i < kThrobberIconCount; ++i) {
532 throbber_icons_[i] = 515 throbber_icons_[i] =
533 ui::LoadThemeIconFromResourcesDataDLL(IDI_THROBBER_01 + i); 516 ui::LoadThemeIconFromResourcesDataDLL(IDI_THROBBER_01 + i);
534 DCHECK(throbber_icons_[i]); 517 DCHECK(throbber_icons_[i]);
535 } 518 }
536 initialized = true; 519 initialized = true;
537 } 520 }
538 } 521 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698