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

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

Issue 1461863002: Handle arbitrary heights in GlassBrowserFrameView. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month 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
« no previous file with comments | « no previous file | 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) 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/prefs/pref_service.h" 7 #include "base/prefs/pref_service.h"
8 #include "base/strings/utf_string_conversions.h" 8 #include "base/strings/utf_string_conversions.h"
9 #include "base/win/windows_version.h" 9 #include "base/win/windows_version.h"
10 #include "chrome/app/chrome_command_ids.h" 10 #include "chrome/app/chrome_command_ids.h"
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after
337 // so that the region above the tab's hit-test zone matches) versus the shadow 337 // so that the region above the tab's hit-test zone matches) versus the shadow
338 // thickness. 338 // thickness.
339 const int exclusion = GetLayoutConstant(TAB_TOP_EXCLUSION_HEIGHT); 339 const int exclusion = GetLayoutConstant(TAB_TOP_EXCLUSION_HEIGHT);
340 return (frame()->IsMaximized() && !restored) ? 340 return (frame()->IsMaximized() && !restored) ?
341 (top - GetLayoutInsets(TAB).top() + 1) : 341 (top - GetLayoutInsets(TAB).top() + 1) :
342 (top + kNonClientRestoredExtraThickness - exclusion); 342 (top + kNonClientRestoredExtraThickness - exclusion);
343 } 343 }
344 344
345 void GlassBrowserFrameView::PaintToolbarBackground(gfx::Canvas* canvas) { 345 void GlassBrowserFrameView::PaintToolbarBackground(gfx::Canvas* canvas) {
346 gfx::Rect toolbar_bounds(browser_view()->GetToolbarBounds()); 346 gfx::Rect toolbar_bounds(browser_view()->GetToolbarBounds());
347 if (toolbar_bounds.IsEmpty())
348 return;
347 gfx::Point toolbar_origin(toolbar_bounds.origin()); 349 gfx::Point toolbar_origin(toolbar_bounds.origin());
348 ConvertPointToTarget(browser_view(), this, &toolbar_origin); 350 ConvertPointToTarget(browser_view(), this, &toolbar_origin);
349 toolbar_bounds.set_origin(toolbar_origin); 351 toolbar_bounds.set_origin(toolbar_origin);
350 const int h = toolbar_bounds.height(); 352 const int h = toolbar_bounds.height();
351 ui::ThemeProvider* tp = GetThemeProvider(); 353 ui::ThemeProvider* tp = GetThemeProvider();
352 354
353 // Background. 355 // Background.
354 gfx::ImageSkia* bg = tp->GetImageSkiaNamed(IDR_THEME_TOOLBAR);
355 int x = toolbar_bounds.x(); 356 int x = toolbar_bounds.x();
356 const int y = toolbar_bounds.y(); 357 const int y = toolbar_bounds.y();
357 int w = toolbar_bounds.width(); 358 int w = toolbar_bounds.width();
358 359
359 const int split_point = kContentEdgeShadowThickness; 360 // The top stroke is drawn using the IDR_CONTENT_TOP_XXX images, which overlay
360 const int split_y = 361 // the toolbar. The top 2 px of these images is the actual top stroke +
361 y + (browser_view()->IsTabStripVisible() ? split_point : 0); 362 // shadow, and is partly transparent, so the toolbar background shouldn't be
362 const int bg_y = GetTopInset(false) + Tab::GetYInsetForActiveTabBackground(); 363 // drawn over it.
363 canvas->TileImageInt(*bg, x + GetThemeBackgroundXInset(), split_y - bg_y, x, 364 const int split_point = std::min(kContentEdgeShadowThickness, h);
364 split_y, w, bg->height()); 365 if (h > split_point) {
366 // Tile the toolbar image starting at the frame edge on the left and where
367 // the tabstrip is on the top.
368 const int split_y =
369 y + (browser_view()->IsTabStripVisible() ? split_point : 0);
370 const int bg_y =
371 GetTopInset(false) + Tab::GetYInsetForActiveTabBackground();
372 canvas->TileImageInt(*tp->GetImageSkiaNamed(IDR_THEME_TOOLBAR),
373 x + GetThemeBackgroundXInset(), split_y - bg_y, x,
374 split_y, w, h - split_point);
375 }
365 376
366 if (browser_view()->IsTabStripVisible()) { 377 if (browser_view()->IsTabStripVisible()) {
367 // On Windows 10+ where we don't draw our own window border but rather go 378 // On Windows 10+ where we don't draw our own window border but rather go
368 // right to the system border, the toolbar has no corners or side strokes. 379 // right to the system border, the toolbar has no corners or side strokes.
369 if (base::win::GetVersion() < base::win::VERSION_WIN10) { 380 if (base::win::GetVersion() < base::win::VERSION_WIN10) {
370 // Mask out the corners. 381 // Mask out the corners.
371 gfx::ImageSkia* left = tp->GetImageSkiaNamed(IDR_CONTENT_TOP_LEFT_CORNER); 382 gfx::ImageSkia* left = tp->GetImageSkiaNamed(IDR_CONTENT_TOP_LEFT_CORNER);
372 const int img_w = left->width(); 383 const int img_w = left->width();
373 x -= kContentEdgeShadowThickness; 384 x -= kContentEdgeShadowThickness;
374 SkPaint paint; 385 SkPaint paint;
375 paint.setXfermodeMode(SkXfermode::kDstIn_Mode); 386 paint.setXfermodeMode(SkXfermode::kDstIn_Mode);
376 canvas->DrawImageInt( 387 canvas->DrawImageInt(
377 *tp->GetImageSkiaNamed(IDR_CONTENT_TOP_LEFT_CORNER_MASK), x, y, 388 *tp->GetImageSkiaNamed(IDR_CONTENT_TOP_LEFT_CORNER_MASK), 0, 0, img_w,
378 paint); 389 h, x, y, img_w, h, false, paint);
379 const int right_x = 390 const int right_x =
380 toolbar_bounds.right() + kContentEdgeShadowThickness - img_w; 391 toolbar_bounds.right() + kContentEdgeShadowThickness - img_w;
381 canvas->DrawImageInt( 392 canvas->DrawImageInt(
382 *tp->GetImageSkiaNamed(IDR_CONTENT_TOP_RIGHT_CORNER_MASK), right_x, y, 393 *tp->GetImageSkiaNamed(IDR_CONTENT_TOP_RIGHT_CORNER_MASK), 0, 0,
383 paint); 394 img_w, h, right_x, y, img_w, h, false, paint);
384 395
385 // Corner and side strokes. 396 // Corner and side strokes.
386 canvas->DrawImageInt(*left, x, y); 397 canvas->DrawImageInt(*left, 0, 0, img_w, h, x, y, img_w, h, false);
387 canvas->DrawImageInt(*tp->GetImageSkiaNamed(IDR_CONTENT_TOP_RIGHT_CORNER), 398 canvas->DrawImageInt(*tp->GetImageSkiaNamed(IDR_CONTENT_TOP_RIGHT_CORNER),
388 right_x, y); 399 0, 0, img_w, h, right_x, y, img_w, h, false);
389 400
390 x += img_w; 401 x += img_w;
391 w = right_x - x; 402 w = right_x - x;
392 } 403 }
393 404
394 // Top stroke. 405 // Top stroke.
395 gfx::ImageSkia* toolbar_center = 406 canvas->TileImageInt(*tp->GetImageSkiaNamed(IDR_CONTENT_TOP_CENTER), x, y,
396 tp->GetImageSkiaNamed(IDR_CONTENT_TOP_CENTER); 407 w, split_point);
397 canvas->TileImageInt(*toolbar_center, x, y, w, toolbar_center->height());
398 } 408 }
399 409
400 // Toolbar/content separator. 410 // Toolbar/content separator.
401 const SkColor separator_color = 411 const SkColor separator_color =
402 tp->GetColor(ThemeProperties::COLOR_TOOLBAR_SEPARATOR); 412 tp->GetColor(ThemeProperties::COLOR_TOOLBAR_SEPARATOR);
403 if (ui::MaterialDesignController::IsModeMaterial()) { 413 if (ui::MaterialDesignController::IsModeMaterial()) {
404 toolbar_bounds.Inset(kClientEdgeThickness, 0); 414 toolbar_bounds.Inset(kClientEdgeThickness, 0);
405 BrowserView::Paint1pxHorizontalLine(canvas, separator_color, 415 BrowserView::Paint1pxHorizontalLine(canvas, separator_color,
406 toolbar_bounds); 416 toolbar_bounds);
407 } else { 417 } else {
408 toolbar_bounds.Inset(kClientEdgeThickness, h - kClientEdgeThickness, 418 toolbar_bounds.Inset(kClientEdgeThickness, h - kClientEdgeThickness,
409 kClientEdgeThickness, 0); 419 kClientEdgeThickness, 0);
410 canvas->FillRect(toolbar_bounds, separator_color); 420 canvas->FillRect(toolbar_bounds, separator_color);
411 } 421 }
412 } 422 }
413 423
414 void GlassBrowserFrameView::PaintRestoredClientEdge(gfx::Canvas* canvas) { 424 void GlassBrowserFrameView::PaintRestoredClientEdge(gfx::Canvas* canvas) {
415 ui::ThemeProvider* tp = GetThemeProvider(); 425 ui::ThemeProvider* tp = GetThemeProvider();
416 int y = frame()->client_view()->y(); 426 int y = frame()->client_view()->y();
417 427
418 gfx::Rect client_bounds = CalculateClientAreaBounds(); 428 gfx::Rect client_bounds = CalculateClientAreaBounds();
419 const int x = client_bounds.x(); 429 const int x = client_bounds.x();
420 const int w = client_bounds.width(); 430 const int w = client_bounds.width();
421 const int right = client_bounds.right(); 431 const int right = client_bounds.right();
422 const SkColor toolbar_color = tp->GetColor(ThemeProperties::COLOR_TOOLBAR); 432 const SkColor toolbar_color = tp->GetColor(ThemeProperties::COLOR_TOOLBAR);
423 433
424 // The client edges start below the toolbar upper corner images regardless 434 // The client edges start below the toolbar.
425 // of how tall the toolbar itself is. 435 y += browser_view()->GetToolbarBounds().bottom();
426 y += browser_view()->GetToolbarBounds().y() +
427 tp->GetImageSkiaNamed(IDR_CONTENT_TOP_LEFT_CORNER)->height();
428 436
429 const int bottom = std::max(y, height() - NonClientBorderThickness(false)); 437 const int bottom = std::max(y, height() - NonClientBorderThickness(false));
430 int height = bottom - y; 438 int height = bottom - y;
431 439
432 // Draw the client edge images. 440 // Draw the client edge images.
433 gfx::ImageSkia* right_image = tp->GetImageSkiaNamed(IDR_CONTENT_RIGHT_SIDE); 441 gfx::ImageSkia* right_image = tp->GetImageSkiaNamed(IDR_CONTENT_RIGHT_SIDE);
434 const int img_w = right_image->width(); 442 const int img_w = right_image->width();
435 canvas->TileImageInt(*right_image, right, y, img_w, height); 443 canvas->TileImageInt(*right_image, right, y, img_w, height);
436 canvas->DrawImageInt(*tp->GetImageSkiaNamed(IDR_CONTENT_BOTTOM_RIGHT_CORNER), 444 canvas->DrawImageInt(*tp->GetImageSkiaNamed(IDR_CONTENT_BOTTOM_RIGHT_CORNER),
437 right, bottom); 445 right, bottom);
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
612 static bool initialized = false; 620 static bool initialized = false;
613 if (!initialized) { 621 if (!initialized) {
614 for (int i = 0; i < kThrobberIconCount; ++i) { 622 for (int i = 0; i < kThrobberIconCount; ++i) {
615 throbber_icons_[i] = 623 throbber_icons_[i] =
616 ui::LoadThemeIconFromResourcesDataDLL(IDI_THROBBER_01 + i); 624 ui::LoadThemeIconFromResourcesDataDLL(IDI_THROBBER_01 + i);
617 DCHECK(throbber_icons_[i]); 625 DCHECK(throbber_icons_[i]);
618 } 626 }
619 initialized = true; 627 initialized = true;
620 } 628 }
621 } 629 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698