Ticket #131: transparentWebview.3.diff
| File transparentWebview.3.diff, 9.0 kB (added by poisonousinsect, 3 years ago) |
|---|
-
Plugins/WebKit
old new 20 20 id draggingDelegate; 21 21 BOOL allowsDragAndDrop; 22 22 BOOL shouldForwardEvents; 23 BOOL transparentBackground; 23 24 } 24 25 26 - (void)setDrawsBackground:(BOOL)flag; 27 - (BOOL)drawsBackground; 28 25 29 - (void)setFontFamily:(NSString *)familyName; 26 30 - (NSString *)fontFamily; 27 31 - (void)setDraggingDelegate:(id)inDelegate; -
Plugins/WebKit
old new 107 107 108 108 //Observe preference changes and set our initial preferences 109 109 [[adium preferenceController] registerPreferenceObserver:self forGroup:PREF_GROUP_WEBKIT_MESSAGE_DISPLAY]; 110 111 //Allow the alpha component to be set for our background color 112 [[NSColorPanel sharedColorPanel] setShowsAlpha:YES]; 110 113 } 111 114 112 115 /*! … … 114 117 */ 115 118 - (void)viewWillClose 116 119 { 120 //Hide the alpha component 121 [[NSColorPanel sharedColorPanel] setShowsAlpha:NO]; 122 117 123 [[adium notificationCenter] removeObserver:self]; 118 124 [[adium preferenceController] unregisterPreferenceObserver:self]; 119 125 [previewListObjectsDict release]; previewListObjectsDict = nil; -
Plugins/WebKit
old new 16 16 17 17 #import "ESWebView.h" 18 18 19 @interface WebView (PRIVATE) 20 - (void)setDrawsBackground:(BOOL)flag; 21 - (BOOL)drawsBackground; 22 @end 23 19 24 @interface ESWebView (PRIVATE) 20 25 - (void)forwardSelector:(SEL)selector withObject:(id)object; 21 26 @end … … 29 34 draggingDelegate = nil; 30 35 allowsDragAndDrop = YES; 31 36 shouldForwardEvents = YES; 37 transparentBackground = (![self drawsBackground]); 32 38 33 39 return self; 34 40 } 41 42 - (void)drawRect:(NSRect)rect 43 { 44 [super drawRect:rect]; 45 46 //Only reset the shadow if we're transparent 47 if (transparentBackground) { 48 //This happens after the next run loop to ensure that we invalidate the shadow after all of our subviews have drawn 49 [[self window] performSelector:@selector(invalidateShadow) 50 withObject:nil 51 afterDelay:0 52 inModes:[NSArray arrayWithObjects:NSDefaultRunLoopMode, NSEventTrackingRunLoopMode, nil]]; 53 } 54 } 55 56 //Background Drawing --------------------------------------------------------------------------------------------------- 57 #pragma mark Background Drawing 58 - (void)setDrawsBackground:(BOOL)flag 59 { 60 if ([super respondsToSelector:@selector(setDrawsBackground:)]) { 61 [super setDrawsBackground:flag]; 62 transparentBackground = !flag; 63 } 64 } 65 - (BOOL)drawsBackground 66 { 67 BOOL flag = YES; 68 if ([super respondsToSelector:@selector(drawsBackground)]) flag = [super drawsBackground]; 69 return flag; 70 } 71 35 72 //Font Family ---------------------------------------------------------------------------------------------------------- 36 73 #pragma mark Font Family 37 74 - (void)setFontFamily:(NSString *)familyName … … 182 219 } 183 220 184 221 @end 222 223 @implementation WebDynamicScrollBarsView (ScrollBarHack) 224 /* 225 * This is a heck of a lot of effort just to get it to always show the vertical scroll bar. 226 * Unfortunately, just calling -setAutohidesScrollers: and -setHasVerticalScroller: doesn't work 227 * because the WebView resets them. Not only that, but an always visible vertical scroller might 228 * not be an improvement anyway, although most Apple apps imply that it's correct (for example, Mail). 229 * 230 * Ultimately, the code is here, but feel free to remove it. 231 */ 232 - (void)tile 233 { 234 [super tile]; 235 [[self verticalScroller] setHidden:NO]; 236 237 float scrollerWidth = NSWidth([[self verticalScroller] frame]); 238 [[self verticalScroller] setFrame:NSMakeRect(NSWidth([self bounds]) - scrollerWidth, 0, scrollerWidth, NSHeight([self bounds]))]; 239 240 NSRect clipViewFrame = [[self contentView] frame]; 241 clipViewFrame.size.width = NSMinX([[self verticalScroller] frame]); 242 [[self contentView] setFrame:clipViewFrame]; 243 } 244 @end -
Plugins/WebKit
old new 335 335 [webView setUIDelegate:self]; 336 336 [webView setDraggingDelegate:self]; 337 337 [webView setMaintainsBackForwardList:NO]; 338 338 339 339 if (!draggedTypes) { 340 340 draggedTypes = [[NSArray alloc] initWithObjects: 341 341 NSFilenamesPboardType, … … 424 424 } else { 425 425 [messageStyle setCustomBackgroundColor:nil]; 426 426 } 427 427 [webView setDrawsBackground:![[self messageStyle] isBackgroundTransparent]]; 428 428 429 //Update webview font settings 429 430 NSString *fontFamily = [prefDict objectForKey:[plugin styleSpecificKey:@"FontFamily" forStyle:activeStyle]]; 430 431 [webView setFontFamily:(fontFamily ? fontFamily : [messageStyle defaultFontFamily])]; -
Plugins/WebKit
old new 57 57 58 58 //Style settings 59 59 BOOL allowsCustomBackground; 60 BOOL transparentDefaultBackground; 60 61 BOOL allowsUserIcons; 61 62 BOOL usingCustomBaseHTML; 62 63 … … 88 89 89 90 //Settings 90 91 - (BOOL)allowsCustomBackground; 92 - (BOOL)isBackgroundTransparent; 91 93 - (NSString *)defaultFontFamily; 92 94 - (NSNumber *)defaultFontSize; 93 95 - (BOOL)hasHeader; -
Plugins/WebKit
old new 91 91 92 92 //Style flags 93 93 allowsCustomBackground = ![[styleBundle objectForInfoDictionaryKey:@"DisableCustomBackground"] boolValue]; 94 transparentDefaultBackground = [[styleBundle objectForInfoDictionaryKey:@"DefaultBackgroundIsTransparent"] boolValue]; 95 94 96 combineConsecutive = ![[styleBundle objectForInfoDictionaryKey:@"DisableCombineConsecutive"] boolValue]; 95 97 96 98 NSNumber *tmpNum = [styleBundle objectForInfoDictionaryKey:@"ShowsUserIcons"]; … … 158 160 } 159 161 160 162 /*! 163 * @breif Style has a transparent background 164 */ 165 - (BOOL)isBackgroundTransparent 166 { 167 //Our custom background is only transparent if the user has set a custom color with an alpha component less than 1.0 168 return ((!customBackgroundColor && transparentDefaultBackground) || 169 (customBackgroundColor && [customBackgroundColor alphaComponent] < 0.99)); 170 } 171 172 /*! 161 173 * @brief Style supports user icons 162 174 */ 163 175 - (BOOL)allowsUserIcons … … 1023 1035 } 1024 1036 } 1025 1037 if (customBackgroundColor) { 1026 [bodyTag appendString:[NSString stringWithFormat:@"background-color: #%@; ", [customBackgroundColor hexString]]]; 1038 float red, green, blue, alpha; 1039 [customBackgroundColor getRed:&red green:&green blue:&blue alpha:&alpha]; 1040 [bodyTag appendString:[NSString stringWithFormat:@"background-color: rgba(%i, %i, %i, %f); ", (int)(red * 255.0), (int)(green * 255.0), (int)(blue * 255.0), alpha]]; 1027 1041 } 1028 1042 } 1029 1043 -
Plugins/Dual
old new 88 88 89 89 //Load our window 90 90 myWindow = [self window]; 91 91 92 //Disable the optimization for opaque windows since ours might not be 93 [myWindow setOpaque:NO]; 94 92 95 //Tab hiding suppression (used to force tab bars visible when a drag is occuring) 93 96 tabBarIsVisible = YES; 94 97 supressHiding = NO; … … 297 300 } 298 301 299 302 [inTabViewItem setContainer:self]; 300 303 301 304 if (!silent) [[adium interfaceController] chatDidOpen:[inTabViewItem chat]]; 302 305 } 303 306 -
Plugins/Dual
old new 272 272 //scrollView_messages is originally a placeholder; replace it with controllerView_messages 273 273 [controllerView_messages setFrame:[scrollView_messages documentVisibleRect]]; 274 274 [[customView_messages superview] replaceSubview:customView_messages with:controllerView_messages]; 275 276 //This is what draws our transparent background 277 //Technically, it could be set in MessageView.nib, too 278 [scrollView_messages setBackgroundColor:[NSColor clearColor]]; 279 275 280 [controllerView_messages setNextResponder:textView_outgoing]; 276 281 } 277 282