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

Side by Side Diff: chrome/browser/ui/cocoa/tabs/tab_strip_controller.mm

Issue 12648004: Audio indicator: Mac UI (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: " Created 7 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
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 #import "chrome/browser/ui/cocoa/tabs/tab_strip_controller.h" 5 #import "chrome/browser/ui/cocoa/tabs/tab_strip_controller.h"
6 6
7 #import <QuartzCore/QuartzCore.h> 7 #import <QuartzCore/QuartzCore.h>
8 8
9 #include <cmath> 9 #include <cmath>
10 #include <limits> 10 #include <limits>
(...skipping 19 matching lines...) Expand all
30 #include "chrome/browser/ui/browser.h" 30 #include "chrome/browser/ui/browser.h"
31 #include "chrome/browser/ui/browser_navigator.h" 31 #include "chrome/browser/ui/browser_navigator.h"
32 #include "chrome/browser/ui/browser_tabstrip.h" 32 #include "chrome/browser/ui/browser_tabstrip.h"
33 #import "chrome/browser/ui/cocoa/browser_window_controller.h" 33 #import "chrome/browser/ui/cocoa/browser_window_controller.h"
34 #import "chrome/browser/ui/cocoa/constrained_window/constrained_window_sheet_con troller.h" 34 #import "chrome/browser/ui/cocoa/constrained_window/constrained_window_sheet_con troller.h"
35 #include "chrome/browser/ui/cocoa/drag_util.h" 35 #include "chrome/browser/ui/cocoa/drag_util.h"
36 #import "chrome/browser/ui/cocoa/image_button_cell.h" 36 #import "chrome/browser/ui/cocoa/image_button_cell.h"
37 #import "chrome/browser/ui/cocoa/new_tab_button.h" 37 #import "chrome/browser/ui/cocoa/new_tab_button.h"
38 #import "chrome/browser/ui/cocoa/tab_contents/favicon_util_mac.h" 38 #import "chrome/browser/ui/cocoa/tab_contents/favicon_util_mac.h"
39 #import "chrome/browser/ui/cocoa/tab_contents/tab_contents_controller.h" 39 #import "chrome/browser/ui/cocoa/tab_contents/tab_contents_controller.h"
40 #import "chrome/browser/ui/cocoa/tabs/tab_audio_indicator_view_mac.h"
40 #import "chrome/browser/ui/cocoa/tabs/tab_controller.h" 41 #import "chrome/browser/ui/cocoa/tabs/tab_controller.h"
41 #import "chrome/browser/ui/cocoa/tabs/tab_projecting_image_view.h" 42 #import "chrome/browser/ui/cocoa/tabs/tab_projecting_image_view.h"
42 #import "chrome/browser/ui/cocoa/tabs/tab_strip_drag_controller.h" 43 #import "chrome/browser/ui/cocoa/tabs/tab_strip_drag_controller.h"
43 #import "chrome/browser/ui/cocoa/tabs/tab_strip_model_observer_bridge.h" 44 #import "chrome/browser/ui/cocoa/tabs/tab_strip_model_observer_bridge.h"
44 #import "chrome/browser/ui/cocoa/tabs/tab_strip_view.h" 45 #import "chrome/browser/ui/cocoa/tabs/tab_strip_view.h"
45 #import "chrome/browser/ui/cocoa/tabs/tab_view.h" 46 #import "chrome/browser/ui/cocoa/tabs/tab_view.h"
46 #import "chrome/browser/ui/cocoa/tabs/throbber_view.h" 47 #import "chrome/browser/ui/cocoa/tabs/throbber_view.h"
47 #import "chrome/browser/ui/cocoa/tabs/throbbing_image_view.h" 48 #import "chrome/browser/ui/cocoa/tabs/throbbing_image_view.h"
48 #import "chrome/browser/ui/cocoa/tracking_area.h" 49 #import "chrome/browser/ui/cocoa/tracking_area.h"
49 #include "chrome/browser/ui/find_bar/find_bar.h" 50 #include "chrome/browser/ui/find_bar/find_bar.h"
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 // The amount by which the profile menu button is offset (from tab tabs or new 105 // The amount by which the profile menu button is offset (from tab tabs or new
105 // tab button). 106 // tab button).
106 const CGFloat kProfileMenuButtonOffset = 6.0; 107 const CGFloat kProfileMenuButtonOffset = 6.0;
107 108
108 // The width and height of the icon + glow for projecting mode. 109 // The width and height of the icon + glow for projecting mode.
109 const CGFloat kProjectingIconWidthAndHeight = 32.0; 110 const CGFloat kProjectingIconWidthAndHeight = 32.0;
110 111
111 // Throbbing duration on webrtc "this web page is watching you" favicon overlay. 112 // Throbbing duration on webrtc "this web page is watching you" favicon overlay.
112 const int kRecordingDurationMs = 1000; 113 const int kRecordingDurationMs = 1000;
113 114
114 // Throbbing duration on audio playing animation.
115 const int kAudioPlayingDurationMs = 2000;
116
117 // Helper class for doing NSAnimationContext calls that takes a bool to disable 115 // Helper class for doing NSAnimationContext calls that takes a bool to disable
118 // all the work. Useful for code that wants to conditionally animate. 116 // all the work. Useful for code that wants to conditionally animate.
119 class ScopedNSAnimationContextGroup { 117 class ScopedNSAnimationContextGroup {
120 public: 118 public:
121 explicit ScopedNSAnimationContextGroup(bool animate) 119 explicit ScopedNSAnimationContextGroup(bool animate)
122 : animate_(animate) { 120 : animate_(animate) {
123 if (animate_) { 121 if (animate_) {
124 [NSAnimationContext beginGrouping]; 122 [NSAnimationContext beginGrouping];
125 } 123 }
126 } 124 }
(...skipping 1441 matching lines...) Expand 10 before | Expand all | Expand 10 after
1568 // While loading, this function is called repeatedly with the same state. 1566 // While loading, this function is called repeatedly with the same state.
1569 // To avoid expensive unnecessary view manipulation, only make changes when 1567 // To avoid expensive unnecessary view manipulation, only make changes when
1570 // the state is actually changing. When loading is complete (kTabDone), 1568 // the state is actually changing. When loading is complete (kTabDone),
1571 // every call to this function is significant. 1569 // every call to this function is significant.
1572 if (newState == kTabDone || oldState != newState || 1570 if (newState == kTabDone || oldState != newState ||
1573 oldHasIcon != newHasIcon) { 1571 oldHasIcon != newHasIcon) {
1574 NSView* iconView = nil; 1572 NSView* iconView = nil;
1575 if (newHasIcon) { 1573 if (newHasIcon) {
1576 if (newState == kTabDone) { 1574 if (newState == kTabDone) {
1577 NSImageView* imageView = [self iconImageViewForContents:contents]; 1575 NSImageView* imageView = [self iconImageViewForContents:contents];
1576 TabAudioIndicatorViewMac* tabAudioIndicatorViewMac =
1577 base::mac::ObjCCast<TabAudioIndicatorViewMac>(
1578 [tabController iconView]);
1578 1579
1579 ui::ThemeProvider* theme = [[tabStripView_ window] themeProvider]; 1580 ui::ThemeProvider* theme = [[tabStripView_ window] themeProvider];
1580 if (theme && [tabController projecting]) { 1581 if (theme && [tabController projecting]) {
1581 NSImage* projectorGlow = 1582 NSImage* projectorGlow =
1582 theme->GetNSImageNamed(IDR_TAB_CAPTURE_GLOW, true); 1583 theme->GetNSImageNamed(IDR_TAB_CAPTURE_GLOW, true);
1583 NSImage* projector = theme->GetNSImageNamed(IDR_TAB_CAPTURE, true); 1584 NSImage* projector = theme->GetNSImageNamed(IDR_TAB_CAPTURE, true);
1584 1585
1585 NSRect frame = NSMakeRect(0, 1586 NSRect frame = NSMakeRect(0,
1586 0, 1587 0,
1587 kProjectingIconWidthAndHeight, 1588 kProjectingIconWidthAndHeight,
(...skipping 12 matching lines...) Expand all
1600 NSRect frame = 1601 NSRect frame =
1601 NSMakeRect(0, 0, kIconWidthAndHeight, kIconWidthAndHeight); 1602 NSMakeRect(0, 0, kIconWidthAndHeight, kIconWidthAndHeight);
1602 ThrobbingImageView* recordingView = 1603 ThrobbingImageView* recordingView =
1603 [[[ThrobbingImageView alloc] initWithFrame:frame 1604 [[[ThrobbingImageView alloc] initWithFrame:frame
1604 backgroundImage:[imageView image] 1605 backgroundImage:[imageView image]
1605 throbImage:recording 1606 throbImage:recording
1606 durationMS:kRecordingDurationMs] 1607 durationMS:kRecordingDurationMs]
1607 autorelease]; 1608 autorelease];
1608 1609
1609 iconView = recordingView; 1610 iconView = recordingView;
1610 } else if (theme && chrome::IsPlayingAudio(contents)) { 1611 } else if (chrome::IsPlayingAudio(contents) ||
1611 NSImage* audioImage = 1612 [tabAudioIndicatorViewMac isAnimating]) {
1612 theme->GetNSImageNamed(IDR_AUDIO_ANIMATION, true); 1613 if (!tabAudioIndicatorViewMac) {
1613 NSRect frame = 1614 NSRect frame =
1614 NSMakeRect(0, 0, kIconWidthAndHeight, kIconWidthAndHeight); 1615 NSMakeRect(0, 0, kIconWidthAndHeight, kIconWidthAndHeight);
1615 ThrobbingImageView* equalizerFaviconView = 1616 tabAudioIndicatorViewMac = [[[TabAudioIndicatorViewMac alloc]
1616 [[[ThrobbingImageView alloc] 1617 initWithFrame:frame] autorelease];
1617 initWithFrame:frame 1618 }
1618 backgroundImage:[imageView image] 1619 [tabAudioIndicatorViewMac
1619 throbImage:audioImage 1620 setIsPlayingAudio:chrome::IsPlayingAudio(contents)];
1620 durationMS:kAudioPlayingDurationMs] autorelease]; 1621 [tabAudioIndicatorViewMac setBackgroundImage:[imageView image]];
1621 [equalizerFaviconView setTweenType:ui::Tween::LINEAR]; 1622 iconView = tabAudioIndicatorViewMac;
1622
1623 iconView = equalizerFaviconView;
1624 } else { 1623 } else {
1625 iconView = imageView; 1624 iconView = imageView;
1626 } 1625 }
1627 } else if (newState == kTabCrashed) { 1626 } else if (newState == kTabCrashed) {
1628 NSImage* oldImage = [[self iconImageViewForContents:contents] image]; 1627 NSImage* oldImage = [[self iconImageViewForContents:contents] image];
1629 NSRect frame = 1628 NSRect frame =
1630 NSMakeRect(0, 0, kIconWidthAndHeight, kIconWidthAndHeight); 1629 NSMakeRect(0, 0, kIconWidthAndHeight, kIconWidthAndHeight);
1631 iconView = [ThrobberView toastThrobberViewWithFrame:frame 1630 iconView = [ThrobberView toastThrobberViewWithFrame:frame
1632 beforeImage:oldImage 1631 beforeImage:oldImage
1633 afterImage:sadFaviconImage]; 1632 afterImage:sadFaviconImage];
(...skipping 615 matching lines...) Expand 10 before | Expand all | Expand 10 after
2249 NSView* GetSheetParentViewForWebContents(WebContents* web_contents) { 2248 NSView* GetSheetParentViewForWebContents(WebContents* web_contents) {
2250 // View hierarchy of the contents view: 2249 // View hierarchy of the contents view:
2251 // NSView -- switchView, same for all tabs 2250 // NSView -- switchView, same for all tabs
2252 // +- NSView -- TabContentsController's view 2251 // +- NSView -- TabContentsController's view
2253 // +- TabContentsViewCocoa 2252 // +- TabContentsViewCocoa
2254 // 2253 //
2255 // Changing it? Do not forget to modify 2254 // Changing it? Do not forget to modify
2256 // -[TabStripController swapInTabAtIndex:] too. 2255 // -[TabStripController swapInTabAtIndex:] too.
2257 return [web_contents->GetView()->GetNativeView() superview]; 2256 return [web_contents->GetView()->GetNativeView() superview];
2258 } 2257 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698