Camino only - Bug 390575: Make Tabspose handle mouse clicks. Patch by Jeff Dlouhy <Jeff.Dlouhy@gmail.com>. r=hwaara r=smurph sr=smorgan

This commit is contained in:
stuart.morgan%alumni.case.edu 2007-08-16 17:38:23 +00:00
Родитель 032cb95f5f
Коммит c87a527f66
7 изменённых файлов: 78 добавлений и 20 удалений

Просмотреть файл

@ -52,6 +52,8 @@
BOOL mStatusBarWasHidden;
}
- (void)toggleTabThumbnailGridView;
@end
@interface BrowserContainerView : NSView

Просмотреть файл

@ -155,7 +155,6 @@
}
}
- (void)willRemoveSubview:(NSView *)subview
{
if (subview == mBookmarksToolbar)
@ -201,6 +200,14 @@
mTabThumbnailGridView = nil;
}
- (void)toggleTabThumbnailGridView
{
if ([mTabThumbnailGridView isDescendantOf:self])
[self hideTabThumbnailGridView];
else
[self showTabThumbnailGridView];
}
//
// Temporary, For testing purposes only
//
@ -210,13 +217,7 @@
if ([theEvent modifierFlags] & NSControlKeyMask && NSCommandKeyMask) {
NSString *keystroke = [theEvent charactersIgnoringModifiers];
if ([keystroke isEqualToString:@"t"]) {
if (![mTabThumbnailGridView isDescendantOf:self])
[self showTabThumbnailGridView];
else if ([mTabThumbnailGridView isDescendantOf:self])
[self hideTabThumbnailGridView];
[self toggleTabThumbnailGridView];
return YES;
}
}

Просмотреть файл

@ -264,6 +264,8 @@ typedef enum
- (IBAction)home:(id)aSender;
- (void)stopAllPendingLoads;
- (IBAction)toggleTabThumbnailView:(id)sender;
- (IBAction)reloadWithNewCharset:(NSString*)charset;
- (NSString*)currentCharset;

Просмотреть файл

@ -4887,6 +4887,11 @@ enum BWCOpenDest {
Wallet_Prefill(internalDomWindow);
}
- (IBAction)toggleTabThumbnailView:(id)sender
{
[mContentView toggleTabThumbnailGridView];
}
@end
#pragma mark -

Просмотреть файл

@ -44,6 +44,7 @@
#import "BrowserWindowController.h"
#import "BrowserTabViewItem.h"
#import "BrowserWrapper.h"
#import "NSView+Utils.h"
const int kVerticalPadding = 25;
const int kHorizontalPadding = 25;
@ -56,7 +57,6 @@ static void shadeBackground(CGContextRef context, NSRect rect);
CGColorSpaceRef getTheGreyColorSpace(void);
@interface TabThumbnailGridView (Private)
- (void)removeSubviews;
- (void)updateGridSizeFor:(int)num;
- (void)layoutThumbnails;
- (void)createThumbnailViews;
@ -96,7 +96,7 @@ CGColorSpaceRef getTheGreyColorSpace(void);
{
// Browser wrapper is used here since moving CHBrowserView disconnects needed attributes (i.e. URL)
// The window isn't hooked up yet, so go through the superview
BrowserWindowController* bwc = [[[self superview] window] windowController];
BrowserWindowController* bwc = (BrowserWindowController*)[[[self superview] window] windowController];
BrowserTabView* tabView = [bwc getTabBrowser];
NSArray* openTabs = [tabView tabViewItems];
@ -109,6 +109,8 @@ CGColorSpaceRef getTheGreyColorSpace(void);
if (curThumbView) {
[curThumbView setThumbnail:thumb];
[curThumbView setRepresentedObject:tabViewItem];
[curThumbView setDelegate:self];
[self addSubview:curThumbView];
}
}
@ -116,14 +118,6 @@ CGColorSpaceRef getTheGreyColorSpace(void);
[self layoutThumbnails];
}
- (void)removeSubviews
{
NSEnumerator* subEnum = [[self subviews] objectEnumerator];
ThumbnailView* subview;
while ((subview = [subEnum nextObject]))
[subview removeFromSuperview];
}
//
// Draw the views when it's added to a view
//
@ -132,7 +126,19 @@ CGColorSpaceRef getTheGreyColorSpace(void);
if ([self superview])
[self createThumbnailViews];
else
[self removeSubviews];
[self removeAllSubviews];
}
//
// Change the tab to the selected ThumbnailView
//
- (void)thumbnailViewWasSelected:(ThumbnailView*)selectedView
{
BrowserWindowController* bwc = (BrowserWindowController*)[[self window] windowController];
BrowserTabView* tabView = [bwc getTabBrowser];
[tabView selectTabViewItem:[selectedView representedObject]];
[bwc toggleTabThumbnailView:self];
}
//

Просмотреть файл

@ -46,9 +46,21 @@
//
@interface ThumbnailView : NSView {
NSImage* mThumbnail;
NSImage* mThumbnail;
NSObject* mRepresentedObject;
id mDelegate;
}
- (void)setThumbnail:(NSImage*)image;
- (void)setRepresentedObject:(id)object;
- (id)representedObject;
- (void)setDelegate:(id)delegate;
- (id)delegate;
@end
@interface NSObject (ThumbnailViewDelegate)
- (void)thumbnailViewWasSelected:(ThumbnailView*)selectedView;
@end

Просмотреть файл

@ -60,6 +60,29 @@ const int kShadowPadding = 5;
}
}
- (void)setRepresentedObject:(id)object
{
if (mRepresentedObject != object) {
[mRepresentedObject release];
mRepresentedObject = [object retain];
}
}
- (id)representedObject;
{
return mRepresentedObject;
}
- (void)setDelegate:(id)delegate
{
mDelegate = delegate;
}
- (id)delegate
{
return mDelegate;
}
- (void)drawRect:(NSRect)rect
{
NSShadow* shadow = [[[NSShadow alloc] init] autorelease];
@ -78,9 +101,16 @@ const int kShadowPadding = 5;
}
}
- (void)mouseUp:(NSEvent*)theEvent
{
if ([mDelegate respondsToSelector:@selector(thumbnailViewWasSelected:)])
[mDelegate thumbnailViewWasSelected:self];
}
- (void)dealloc
{
[mThumbnail release];
[mRepresentedObject release];
[super dealloc];
}