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

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: tapted 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"
11 #import "base/mac/scoped_nsobject.h" 10 #import "base/mac/scoped_nsobject.h"
12 #import "chrome/browser/themes/theme_properties.h" 11 #import "chrome/browser/themes/theme_properties.h"
13 #import "chrome/browser/themes/theme_service.h" 12 #import "chrome/browser/themes/theme_service.h"
14 #import "chrome/browser/ui/cocoa/rect_path_utils.h" 13 #import "chrome/browser/ui/cocoa/rect_path_utils.h"
15 #import "chrome/browser/ui/cocoa/themed_window.h" 14 #import "chrome/browser/ui/cocoa/themed_window.h"
16 #include "grit/theme_resources.h" 15 #include "grit/theme_resources.h"
17 #import "third_party/google_toolbox_for_mac/src/AppKit/GTMNSColor+Luminance.h" 16 #import "third_party/google_toolbox_for_mac/src/AppKit/GTMNSColor+Luminance.h"
18 #import "ui/base/cocoa/nsgraphics_context_additions.h" 17 #import "ui/base/cocoa/nsgraphics_context_additions.h"
19 #import "ui/base/cocoa/nsview_additions.h" 18 #import "ui/base/cocoa/nsview_additions.h"
20 #include "ui/gfx/scoped_ns_graphics_context_save_gstate_mac.h" 19 #include "ui/gfx/scoped_ns_graphics_context_save_gstate_mac.h"
(...skipping 500 matching lines...) Expand 10 before | Expand all | Expand 10 after
521 innerFrame:&innerFrame 520 innerFrame:&innerFrame
522 innerPath:&innerPath 521 innerPath:&innerPath
523 clipPath:NULL]; 522 clipPath:NULL];
524 523
525 BOOL pressed = ([((NSControl*)[self controlView]) isEnabled] && 524 BOOL pressed = ([((NSControl*)[self controlView]) isEnabled] &&
526 [self isHighlighted]); 525 [self isHighlighted]);
527 NSWindow* window = [controlView window]; 526 NSWindow* window = [controlView window];
528 const ui::ThemeProvider* themeProvider = [window themeProvider]; 527 const ui::ThemeProvider* themeProvider = [window themeProvider];
529 BOOL active = [window isKeyWindow] || [window isMainWindow]; 528 BOOL active = [window isKeyWindow] || [window isMainWindow];
530 529
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 530 // 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 531 // only time we want to draw the inner gradient is if we're highlighted or if
539 // we're drawing the focus ring manually. 532 // we're drawing the focus ring manually.
540 if (([self isBordered] && ![self showsBorderOnlyWhileMouseInside]) || 533 if (([self isBordered] && ![self showsBorderOnlyWhileMouseInside]) ||
541 pressed || 534 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. 535 // When pulsing we want the bookmark to stand out a little more.
547 BOOL showClickedGradient = pressed || 536 BOOL showClickedGradient = pressed ||
548 (pulseState_ == gradient_button_cell::kPulsingContinuous); 537 (pulseState_ == gradient_button_cell::kPulsingContinuous);
549 538
550 [self drawBorderAndFillForTheme:themeProvider 539 [self drawBorderAndFillForTheme:themeProvider
551 controlView:controlView 540 controlView:controlView
552 innerPath:innerPath 541 innerPath:innerPath
553 showClickedGradient:showClickedGradient 542 showClickedGradient:showClickedGradient
554 showHighlightGradient:[self isHighlighted] 543 showHighlightGradient:[self isHighlighted]
555 hoverAlpha:[self hoverAlpha] 544 hoverAlpha:[self hoverAlpha]
(...skipping 11 matching lines...) Expand all
567 NSColor* stroke = themeProvider ? themeProvider->GetNSColor( 556 NSColor* stroke = themeProvider ? themeProvider->GetNSColor(
568 active ? ThemeProperties::COLOR_TOOLBAR_BUTTON_STROKE : 557 active ? ThemeProperties::COLOR_TOOLBAR_BUTTON_STROKE :
569 ThemeProperties::COLOR_TOOLBAR_BUTTON_STROKE_INACTIVE) : 558 ThemeProperties::COLOR_TOOLBAR_BUTTON_STROKE_INACTIVE) :
570 [NSColor blackColor]; 559 [NSColor blackColor];
571 560
572 [[stroke colorWithAlphaComponent:0.2] set]; 561 [[stroke colorWithAlphaComponent:0.2] set];
573 NSRectFillUsingOperation(NSInsetRect(borderRect, 0, 2), 562 NSRectFillUsingOperation(NSInsetRect(borderRect, 0, 2),
574 NSCompositeSourceOver); 563 NSCompositeSourceOver);
575 } 564 }
576 [self drawInteriorWithFrame:innerFrame inView:controlView]; 565 [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 } 566 }
594 567
595 - (void)drawInteriorWithFrame:(NSRect)cellFrame inView:(NSView*)controlView { 568 - (void)drawInteriorWithFrame:(NSRect)cellFrame inView:(NSView*)controlView {
596 const CGFloat lineWidth = [controlView cr_lineWidth]; 569 const CGFloat lineWidth = [controlView cr_lineWidth];
597 570
598 if (shouldTheme_) { 571 if (shouldTheme_) {
599 BOOL isTemplate = [[self image] isTemplate]; 572 BOOL isTemplate = [[self image] isTemplate];
600 573
601 gfx::ScopedNSGraphicsContextSaveGState scopedGState; 574 gfx::ScopedNSGraphicsContextSaveGState scopedGState;
602 575
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
786 options:options 759 options:options
787 owner:self 760 owner:self
788 userInfo:nil]); 761 userInfo:nil]);
789 if (isMouseInside_ != mouseInView) { 762 if (isMouseInside_ != mouseInView) {
790 [self setMouseInside:mouseInView animate:NO]; 763 [self setMouseInside:mouseInView animate:NO];
791 [controlView setNeedsDisplay:YES]; 764 [controlView setNeedsDisplay:YES];
792 } 765 }
793 } 766 }
794 767
795 @end 768 @end
OLDNEW
« no previous file with comments | « chrome/browser/ui/cocoa/exclusive_access_bubble_view.mm ('k') | chrome/browser/ui/cocoa/spinner_view.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698