Adium

Changeset 15034

Show
Ignore:
Timestamp:
01/22/2006 01:49:00 AM (3 years ago)
Author:
evands
Message:

Patch from poisonousinsect which allows selection of transparency for custom message style background colors and allows styles to use a DefaultBackgroundIsTransparent key to declare their backgrounds as transparent. Thanks :)

I also fixed a control dimming issue with the custom background controls in the Message preferences.

Closes #131

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/Plugins/Dual Window Interface/AIMessageViewController.m

    r14844 r15034  
    273273        [controllerView_messages setFrame:[scrollView_messages documentVisibleRect]]; 
    274274        [[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 
    275280        [controllerView_messages setNextResponder:textView_outgoing]; 
    276281} 
  • trunk/Plugins/Dual Window Interface/AIMessageWindowController.m

    r14671 r15034  
    8989                //Load our window 
    9090                myWindow = [self window]; 
    91                  
     91 
     92                //Disable the optimization for opaque windows since ours might not be 
     93                [myWindow setOpaque:NO]; 
     94 
    9295                //Tab hiding suppression (used to force tab bars visible when a drag is occuring) 
    9396                tabBarIsVisible = YES; 
     
    298301         
    299302        [inTabViewItem setContainer:self]; 
    300  
     303         
    301304        if (!silent) [[adium interfaceController] chatDidOpen:[inTabViewItem chat]]; 
    302305} 
  • trunk/Plugins/WebKit Message View/AIWebKitMessageViewController.m

    r14669 r15034  
    336336        [webView setDraggingDelegate:self]; 
    337337        [webView setMaintainsBackForwardList:NO]; 
    338          
     338 
    339339        if (!draggedTypes) { 
    340340                draggedTypes = [[NSArray alloc] initWithObjects: 
     
    425425                [messageStyle setCustomBackgroundColor:nil]; 
    426426        } 
    427          
     427        [webView setDrawsBackground:![[self messageStyle] isBackgroundTransparent]]; 
     428 
    428429        //Update webview font settings 
    429430        NSString        *fontFamily = [prefDict objectForKey:[plugin styleSpecificKey:@"FontFamily" forStyle:activeStyle]]; 
  • trunk/Plugins/WebKit Message View/AIWebkitMessageViewStyle.h

    r11318 r15034  
    5858        //Style settings 
    5959        BOOL                            allowsCustomBackground; 
     60        BOOL                            transparentDefaultBackground; 
    6061        BOOL                            allowsUserIcons; 
    6162        BOOL                            usingCustomBaseHTML; 
     
    8990//Settings 
    9091- (BOOL)allowsCustomBackground; 
     92- (BOOL)isBackgroundTransparent; 
    9193- (NSString *)defaultFontFamily; 
    9294- (NSNumber *)defaultFontSize; 
  • trunk/Plugins/WebKit Message View/AIWebkitMessageViewStyle.m

    r14625 r15034  
    9292                //Style flags 
    9393                allowsCustomBackground = ![[styleBundle objectForInfoDictionaryKey:@"DisableCustomBackground"] boolValue]; 
     94                transparentDefaultBackground = [[styleBundle objectForInfoDictionaryKey:@"DefaultBackgroundIsTransparent"] boolValue]; 
     95 
    9496                combineConsecutive = ![[styleBundle objectForInfoDictionaryKey:@"DisableCombineConsecutive"] boolValue]; 
    9597 
     
    156158{ 
    157159        return allowsCustomBackground; 
     160} 
     161 
     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)); 
    158170} 
    159171 
     
    10241036                                } 
    10251037                                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]]; 
    10271041                                } 
    10281042                        } 
  • trunk/Plugins/WebKit Message View/ESWebKitMessageViewPreferences.m

    r14712 r15034  
    108108        //Observe preference changes and set our initial preferences 
    109109        [[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]; 
     113         
     114        [self configureControlDimming]; 
    110115} 
    111116 
     
    115120- (void)viewWillClose 
    116121{ 
     122        //Hide the alpha component 
     123        [[NSColorPanel sharedColorPanel] setShowsAlpha:NO]; 
     124         
    117125        [[adium notificationCenter] removeObserver:self]; 
    118126        [[adium preferenceController] unregisterPreferenceObserver:self]; 
     
    256264                                                                                                  group:PREF_GROUP_WEBKIT_MESSAGE_DISPLAY]; 
    257265                } 
    258         } 
     266                 
     267                [self configureControlDimming]; 
     268        } 
     269
     270 
     271- (void)configureControlDimming 
     272
     273        BOOL customBackground = [checkBox_useCustomBackground state]; 
     274        [popUp_backgroundImageType setEnabled:customBackground]; 
     275        [imageView_backgroundImage setEnabled:customBackground]; 
     276        [colorWell_customBackgroundColor setEnabled:customBackground]; 
    259277} 
    260278 
     
    576594                                                                                          message:message 
    577595                                                                                        autoreply:[[messageDict objectForKey:@"Autoreply"] boolValue]]; 
    578                          
     596 
    579597                        //AIContentMessage won't know whether the message is outgoing unless we tell it since neither our source 
    580598                        //nor our destination are AIAccount objects. 
  • trunk/Plugins/WebKit Message View/ESWebView.h

    r9455 r15034  
    2121        BOOL    allowsDragAndDrop; 
    2222        BOOL    shouldForwardEvents; 
     23        BOOL    transparentBackground; 
    2324} 
     25 
     26- (void)setDrawsBackground:(BOOL)flag; 
     27- (BOOL)drawsBackground; 
    2428 
    2529- (void)setFontFamily:(NSString *)familyName; 
  • trunk/Plugins/WebKit Message View/ESWebView.m

    r12662 r15034  
    1717#import "ESWebView.h" 
    1818 
     19@interface WebView (PRIVATE) 
     20- (void)setDrawsBackground:(BOOL)flag; 
     21- (BOOL)drawsBackground; 
     22@end 
     23 
    1924@interface ESWebView (PRIVATE) 
    2025- (void)forwardSelector:(SEL)selector withObject:(id)object; 
     
    2530- (id)initWithFrame:(NSRect)frameRect frameName:(NSString *)frameName groupName:(NSString *)groupName 
    2631{ 
    27         [super initWithFrame:frameRect frameName:frameName groupName:groupName]; 
    28  
    29         draggingDelegate = nil; 
    30         allowsDragAndDrop = YES; 
    31         shouldForwardEvents = YES; 
    32  
     32        if ((self = [super initWithFrame:frameRect frameName:frameName groupName:groupName])) { 
     33                draggingDelegate = nil; 
     34                allowsDragAndDrop = YES; 
     35                shouldForwardEvents = YES; 
     36                transparentBackground = (![self drawsBackground]); 
     37        } 
     38         
    3339        return self; 
    3440} 
     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 
    3572//Font Family ---------------------------------------------------------------------------------------------------------- 
    3673#pragma mark Font Family