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

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

Issue 9814013: Ash: Update tab strip for new image assets (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 9 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/app/theme/theme_resources_standard.grd ('k') | chrome/browser/ui/views/tabs/tab.cc » ('j') | 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) 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/browser_non_client_frame_view_aura.h" 5 #include "chrome/browser/ui/views/frame/browser_non_client_frame_view_aura.h"
6 6
7 #include "ash/wm/frame_painter.h" 7 #include "ash/wm/frame_painter.h"
8 #include "ash/wm/workspace/frame_maximize_button.h" 8 #include "ash/wm/workspace/frame_maximize_button.h"
9 #include "chrome/browser/themes/theme_service.h" 9 #include "chrome/browser/themes/theme_service.h"
10 #include "chrome/browser/ui/views/avatar_menu_button.h" 10 #include "chrome/browser/ui/views/avatar_menu_button.h"
11 #include "chrome/browser/ui/views/frame/browser_frame.h" 11 #include "chrome/browser/ui/views/frame/browser_frame.h"
12 #include "chrome/browser/ui/views/frame/browser_view.h" 12 #include "chrome/browser/ui/views/frame/browser_view.h"
13 #include "content/public/browser/web_contents.h" 13 #include "content/public/browser/web_contents.h"
14 #include "grit/generated_resources.h" // Accessibility names 14 #include "grit/generated_resources.h" // Accessibility names
15 #include "grit/theme_resources.h" 15 #include "grit/theme_resources.h"
16 #include "grit/theme_resources_standard.h" 16 #include "grit/theme_resources_standard.h"
17 #include "grit/ui_resources.h" 17 #include "grit/ui_resources.h"
18 #include "ui/base/accessibility/accessible_view_state.h" 18 #include "ui/base/accessibility/accessible_view_state.h"
19 #include "ui/base/hit_test.h"
19 #include "ui/base/l10n/l10n_util.h" 20 #include "ui/base/l10n/l10n_util.h"
20 #include "ui/base/resource/resource_bundle.h" 21 #include "ui/base/resource/resource_bundle.h"
21 #include "ui/base/theme_provider.h" 22 #include "ui/base/theme_provider.h"
22 #include "ui/gfx/canvas.h" 23 #include "ui/gfx/canvas.h"
23 #include "ui/views/controls/button/image_button.h" 24 #include "ui/views/controls/button/image_button.h"
24 #include "ui/views/widget/widget.h" 25 #include "ui/views/widget/widget.h"
25 #include "ui/views/widget/widget_delegate.h" 26 #include "ui/views/widget/widget_delegate.h"
26 27
27 namespace { 28 namespace {
28 29
29 // The avatar ends 2 px above the bottom of the tabstrip (which, given the 30 // The avatar ends 2 px above the bottom of the tabstrip (which, given the
30 // way the tabstrip draws its bottom edge, will appear like a 1 px gap to the 31 // way the tabstrip draws its bottom edge, will appear like a 1 px gap to the
31 // user). 32 // user).
32 const int kAvatarBottomSpacing = 2; 33 const int kAvatarBottomSpacing = 2;
33 // There are 2 px on each side of the avatar (between the frame border and 34 // There are 2 px on each side of the avatar (between the frame border and
34 // it on the left, and between it and the tabstrip on the right). 35 // it on the left, and between it and the tabstrip on the right).
35 const int kAvatarSideSpacing = 2; 36 const int kAvatarSideSpacing = 2;
36 // Space between left edge of window and tabstrip. 37 // Space between left edge of window and tabstrip.
37 const int kTabstripLeftSpacing = 4; 38 const int kTabstripLeftSpacing = 4;
38 // Space between right edge of tabstrip and maximize button. 39 // Space between right edge of tabstrip and maximize button.
39 const int kTabstripRightSpacing = 10; 40 const int kTabstripRightSpacing = 10;
40 // Space between top of window and top of tabstrip for restored windows. 41 // Space between top of window and top of tabstrip for restored windows.
41 const int kTabstripTopSpacingRestored = 10; 42 const int kTabstripTopSpacingRestored = 8;
42 // Space between top of window and top of tabstrip for maximized windows. 43 // Space between top of window and top of tabstrip for maximized windows.
43 // Place them flush to the top to make them clickable when the cursor is at 44 // Place them flush to the top to make them clickable when the cursor is at
44 // the screen edge. 45 // the screen edge.
45 const int kTabstripTopSpacingMaximized = 0; 46 const int kTabstripTopSpacingMaximized = 0;
46 // Height of the shadow of the tab images in the tab strip. 47 // Height of the shadow in the tab image, used to ensure clicks in the shadow
47 const int kTabShadowHeight = 1; 48 // area still drag restored windows. This keeps the clickable area large enough
49 // to hit easily.
50 const int kTabShadowHeight = 4;
51 // Height of the shadow of the content area, at the top of the toolbar.
52 const int kContentShadowHeight = 1;
53
48 } // namespace 54 } // namespace
49 55
50 /////////////////////////////////////////////////////////////////////////////// 56 ///////////////////////////////////////////////////////////////////////////////
51 // BrowserNonClientFrameViewAura, public: 57 // BrowserNonClientFrameViewAura, public:
52 58
53 BrowserNonClientFrameViewAura::BrowserNonClientFrameViewAura( 59 BrowserNonClientFrameViewAura::BrowserNonClientFrameViewAura(
54 BrowserFrame* frame, BrowserView* browser_view) 60 BrowserFrame* frame, BrowserView* browser_view)
55 : BrowserNonClientFrameView(frame, browser_view), 61 : BrowserNonClientFrameView(frame, browser_view),
56 maximize_button_(NULL), 62 maximize_button_(NULL),
57 close_button_(NULL), 63 close_button_(NULL),
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 } 132 }
127 133
128 gfx::Rect BrowserNonClientFrameViewAura::GetWindowBoundsForClientBounds( 134 gfx::Rect BrowserNonClientFrameViewAura::GetWindowBoundsForClientBounds(
129 const gfx::Rect& client_bounds) const { 135 const gfx::Rect& client_bounds) const {
130 int top_height = NonClientTopBorderHeight(false); 136 int top_height = NonClientTopBorderHeight(false);
131 return frame_painter_->GetWindowBoundsForClientBounds(top_height, 137 return frame_painter_->GetWindowBoundsForClientBounds(top_height,
132 client_bounds); 138 client_bounds);
133 } 139 }
134 140
135 int BrowserNonClientFrameViewAura::NonClientHitTest(const gfx::Point& point) { 141 int BrowserNonClientFrameViewAura::NonClientHitTest(const gfx::Point& point) {
136 return frame_painter_->NonClientHitTest(this, point); 142 int hit_test = frame_painter_->NonClientHitTest(this, point);
143 // When the window is restored we want a large click target above the tabs
144 // to drag the window, so redirect clicks in the tab's shadow to caption.
145 if (hit_test == HTCLIENT && !frame()->IsMaximized()) {
146 // Convert point to client coordinates.
147 gfx::Point client_point(point);
148 View::ConvertPointToView(this, frame()->client_view(), &client_point);
149 // Report hits in shadow at top of tabstrip as caption.
150 gfx::Rect tabstrip_bounds(browser_view()->tabstrip()->bounds());
151 if (client_point.y() < tabstrip_bounds.y() + kTabShadowHeight)
152 hit_test = HTCAPTION;
153 }
154 return hit_test;
137 } 155 }
138 156
139 void BrowserNonClientFrameViewAura::GetWindowMask(const gfx::Size& size, 157 void BrowserNonClientFrameViewAura::GetWindowMask(const gfx::Size& size,
140 gfx::Path* window_mask) { 158 gfx::Path* window_mask) {
141 // Aura does not use window masks. 159 // Aura does not use window masks.
142 } 160 }
143 161
144 void BrowserNonClientFrameViewAura::ResetWindowControls() { 162 void BrowserNonClientFrameViewAura::ResetWindowControls() {
145 maximize_button_->SetState(views::CustomButton::BS_NORMAL); 163 maximize_button_->SetState(views::CustomButton::BS_NORMAL);
146 // The close button isn't affected by this constraint. 164 // The close button isn't affected by this constraint.
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 } 281 }
264 282
265 void BrowserNonClientFrameViewAura::LayoutAvatar() { 283 void BrowserNonClientFrameViewAura::LayoutAvatar() {
266 DCHECK(avatar_button()); 284 DCHECK(avatar_button());
267 SkBitmap incognito_icon = browser_view()->GetOTRAvatarIcon(); 285 SkBitmap incognito_icon = browser_view()->GetOTRAvatarIcon();
268 286
269 int avatar_bottom = GetHorizontalTabStripVerticalOffset(false) + 287 int avatar_bottom = GetHorizontalTabStripVerticalOffset(false) +
270 browser_view()->GetTabStripHeight() - kAvatarBottomSpacing; 288 browser_view()->GetTabStripHeight() - kAvatarBottomSpacing;
271 int avatar_restored_y = avatar_bottom - incognito_icon.height(); 289 int avatar_restored_y = avatar_bottom - incognito_icon.height();
272 int avatar_y = frame()->IsMaximized() ? 290 int avatar_y = frame()->IsMaximized() ?
273 NonClientTopBorderHeight(false) + kTabShadowHeight: 291 NonClientTopBorderHeight(false) + kContentShadowHeight:
274 avatar_restored_y; 292 avatar_restored_y;
275 gfx::Rect avatar_bounds(kAvatarSideSpacing, 293 gfx::Rect avatar_bounds(kAvatarSideSpacing,
276 avatar_y, 294 avatar_y,
277 incognito_icon.width(), 295 incognito_icon.width(),
278 avatar_bottom - avatar_y); 296 avatar_bottom - avatar_y);
279 avatar_button()->SetBoundsRect(avatar_bounds); 297 avatar_button()->SetBoundsRect(avatar_bounds);
280 } 298 }
281 299
282 void BrowserNonClientFrameViewAura::PaintToolbarBackground( 300 void BrowserNonClientFrameViewAura::PaintToolbarBackground(
283 gfx::Canvas* canvas) { 301 gfx::Canvas* canvas) {
(...skipping 27 matching lines...) Expand all
311 // source y position. If you have to debug this code use an image editor 329 // source y position. If you have to debug this code use an image editor
312 // to paint a diagonal line through the toolbar image and ensure it lines up 330 // to paint a diagonal line through the toolbar image and ensure it lines up
313 // across the tab and toolbar. 331 // across the tab and toolbar.
314 bool restored = !frame()->IsMaximized(); 332 bool restored = !frame()->IsMaximized();
315 canvas->TileImageInt( 333 canvas->TileImageInt(
316 *theme_toolbar, 334 *theme_toolbar,
317 x, bottom_y - GetHorizontalTabStripVerticalOffset(restored), 335 x, bottom_y - GetHorizontalTabStripVerticalOffset(restored),
318 x, bottom_y, 336 x, bottom_y,
319 w, theme_toolbar->height()); 337 w, theme_toolbar->height());
320 338
339 // The content area line has a shadow that extends a couple of pixels above
340 // the toolbar bounds.
341 const int kContentShadowHeight = 2;
321 SkBitmap* toolbar_center = 342 SkBitmap* toolbar_center =
322 tp->GetBitmapNamed(IDR_CONTENT_TOP_CENTER); 343 tp->GetBitmapNamed(IDR_CONTENT_TOP_CENTER);
323 canvas->TileImageInt(*toolbar_center, 344 canvas->TileImageInt(*toolbar_center,
324 0, 0, 345 0, 0,
325 x, y, 346 x, y - kContentShadowHeight,
326 w, split_point); 347 w, split_point + kContentShadowHeight + 1);
327 348
328 // Draw the content/toolbar separator. 349 // Draw the content/toolbar separator.
329 canvas->FillRect(gfx::Rect(x + kClientEdgeThickness, 350 canvas->FillRect(gfx::Rect(x + kClientEdgeThickness,
330 toolbar_bounds.bottom() - kClientEdgeThickness, 351 toolbar_bounds.bottom() - kClientEdgeThickness,
331 w - (2 * kClientEdgeThickness), 352 w - (2 * kClientEdgeThickness),
332 kClientEdgeThickness), 353 kClientEdgeThickness),
333 ThemeService::GetDefaultColor(ThemeService::COLOR_TOOLBAR_SEPARATOR)); 354 ThemeService::GetDefaultColor(ThemeService::COLOR_TOOLBAR_SEPARATOR));
334 } 355 }
335 356
336 const SkBitmap* BrowserNonClientFrameViewAura::GetThemeFrameBitmap() const { 357 const SkBitmap* BrowserNonClientFrameViewAura::GetThemeFrameBitmap() const {
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
382 } 403 }
383 404
384 SkBitmap* BrowserNonClientFrameViewAura::GetCustomBitmap( 405 SkBitmap* BrowserNonClientFrameViewAura::GetCustomBitmap(
385 int bitmap_id, 406 int bitmap_id,
386 int fallback_bitmap_id) const { 407 int fallback_bitmap_id) const {
387 ui::ThemeProvider* tp = GetThemeProvider(); 408 ui::ThemeProvider* tp = GetThemeProvider();
388 if (tp->HasCustomImage(bitmap_id)) 409 if (tp->HasCustomImage(bitmap_id))
389 return tp->GetBitmapNamed(bitmap_id); 410 return tp->GetBitmapNamed(bitmap_id);
390 return tp->GetBitmapNamed(fallback_bitmap_id); 411 return tp->GetBitmapNamed(fallback_bitmap_id);
391 } 412 }
OLDNEW
« no previous file with comments | « chrome/app/theme/theme_resources_standard.grd ('k') | chrome/browser/ui/views/tabs/tab.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698