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

Side by Side Diff: chrome/browser/ui/cocoa/gradient_button_cell.mm

Issue 1917973002: mac: Remove IsOSLion(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 4 years, 8 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/cocoa/gradient_button_cell.h" 5 #include "chrome/browser/ui/cocoa/gradient_button_cell.h"
6 6
7 #include <cmath> 7 #include <cmath>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/mac/mac_util.h" 10 #include "base/mac/mac_util.h"
(...skipping 510 matching lines...) Expand 10 before | Expand all | Expand 10 after
521 innerFrame:&innerFrame 521 innerFrame:&innerFrame
522 innerPath:&innerPath 522 innerPath:&innerPath
523 clipPath:NULL]; 523 clipPath:NULL];
524 524
525 BOOL pressed = ([((NSControl*)[self controlView]) isEnabled] && 525 BOOL pressed = ([((NSControl*)[self controlView]) isEnabled] &&
526 [self isHighlighted]); 526 [self isHighlighted]);
527 NSWindow* window = [controlView window]; 527 NSWindow* window = [controlView window];
528 const ui::ThemeProvider* themeProvider = [window themeProvider]; 528 const ui::ThemeProvider* themeProvider = [window themeProvider];
529 BOOL active = [window isKeyWindow] || [window isMainWindow]; 529 BOOL active = [window isKeyWindow] || [window isMainWindow];
530 530
531 // Draw custom focus ring only if AppKit won't draw one automatically.
532 // The new focus ring APIs became available with 10.7, but did not get
533 // applied to buttons (only editable text fields) until 10.8.
534 BOOL shouldDrawFocusRing = base::mac::IsOSLionOrEarlier() &&
535 [self showsFirstResponder];
536
537 // Stroke the borders and appropriate fill gradient. If we're borderless, the 531 // Stroke the borders and appropriate fill gradient. If we're borderless, the
538 // only time we want to draw the inner gradient is if we're highlighted or if 532 // only time we want to draw the inner gradient is if we're highlighted or if
539 // we're drawing the focus ring manually. 533 // we're drawing the focus ring manually.
540 if (([self isBordered] && ![self showsBorderOnlyWhileMouseInside]) || 534 if (([self isBordered] && ![self showsBorderOnlyWhileMouseInside]) ||
541 pressed || 535 pressed || [self isMouseInside] || [self isContinuousPulsing]) {
542 [self isMouseInside] ||
543 [self isContinuousPulsing] ||
544 shouldDrawFocusRing) {
545
546 // When pulsing we want the bookmark to stand out a little more. 536 // When pulsing we want the bookmark to stand out a little more.
547 BOOL showClickedGradient = pressed || 537 BOOL showClickedGradient = pressed ||
548 (pulseState_ == gradient_button_cell::kPulsingContinuous); 538 (pulseState_ == gradient_button_cell::kPulsingContinuous);
549 539
550 [self drawBorderAndFillForTheme:themeProvider 540 [self drawBorderAndFillForTheme:themeProvider
551 controlView:controlView 541 controlView:controlView
552 innerPath:innerPath 542 innerPath:innerPath
553 showClickedGradient:showClickedGradient 543 showClickedGradient:showClickedGradient
554 showHighlightGradient:[self isHighlighted] 544 showHighlightGradient:[self isHighlighted]
555 hoverAlpha:[self hoverAlpha] 545 hoverAlpha:[self hoverAlpha]
(...skipping 11 matching lines...) Expand all
567 NSColor* stroke = themeProvider ? themeProvider->GetNSColor( 557 NSColor* stroke = themeProvider ? themeProvider->GetNSColor(
568 active ? ThemeProperties::COLOR_TOOLBAR_BUTTON_STROKE : 558 active ? ThemeProperties::COLOR_TOOLBAR_BUTTON_STROKE :
569 ThemeProperties::COLOR_TOOLBAR_BUTTON_STROKE_INACTIVE) : 559 ThemeProperties::COLOR_TOOLBAR_BUTTON_STROKE_INACTIVE) :
570 [NSColor blackColor]; 560 [NSColor blackColor];
571 561
572 [[stroke colorWithAlphaComponent:0.2] set]; 562 [[stroke colorWithAlphaComponent:0.2] set];
573 NSRectFillUsingOperation(NSInsetRect(borderRect, 0, 2), 563 NSRectFillUsingOperation(NSInsetRect(borderRect, 0, 2),
574 NSCompositeSourceOver); 564 NSCompositeSourceOver);
575 } 565 }
576 [self drawInteriorWithFrame:innerFrame inView:controlView]; 566 [self drawInteriorWithFrame:innerFrame inView:controlView];
577
578 if (shouldDrawFocusRing) {
579 gfx::ScopedNSGraphicsContextSaveGState scoped_state;
580 const CGFloat lineWidth = [controlView cr_lineWidth];
581 // insetX = 1.0 is used for the drawing of blue highlight so that this
582 // highlight won't be too near the bookmark toolbar itself, in case we
583 // draw bookmark buttons in bookmark toolbar.
584 rect_path_utils::FrameRectWithInset(rect_path_utils::RoundedCornerAll,
585 NSInsetRect(cellFrame, 0, lineWidth),
586 1.0, // insetX
587 0.0, // insetY
588 3.0, // outerRadius
589 lineWidth * 2, // lineWidth
590 [controlView
591 cr_keyboardFocusIndicatorColor]);
592 }
593 } 567 }
594 568
595 - (void)drawInteriorWithFrame:(NSRect)cellFrame inView:(NSView*)controlView { 569 - (void)drawInteriorWithFrame:(NSRect)cellFrame inView:(NSView*)controlView {
596 const CGFloat lineWidth = [controlView cr_lineWidth]; 570 const CGFloat lineWidth = [controlView cr_lineWidth];
597 571
598 if (shouldTheme_) { 572 if (shouldTheme_) {
599 BOOL isTemplate = [[self image] isTemplate]; 573 BOOL isTemplate = [[self image] isTemplate];
600 574
601 gfx::ScopedNSGraphicsContextSaveGState scopedGState; 575 gfx::ScopedNSGraphicsContextSaveGState scopedGState;
602 576
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
786 options:options 760 options:options
787 owner:self 761 owner:self
788 userInfo:nil]); 762 userInfo:nil]);
789 if (isMouseInside_ != mouseInView) { 763 if (isMouseInside_ != mouseInView) {
790 [self setMouseInside:mouseInView animate:NO]; 764 [self setMouseInside:mouseInView animate:NO];
791 [controlView setNeedsDisplay:YES]; 765 [controlView setNeedsDisplay:YES];
792 } 766 }
793 } 767 }
794 768
795 @end 769 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698