Add menuForTabBarView: to delegate protocol

This commit is contained in:
Allan Odgaard
2012-08-25 17:42:13 +02:00
parent 81eda77ee2
commit 19f1909ff3
2 changed files with 13 additions and 3 deletions

View File

@@ -48,6 +48,7 @@ typedef std::tr1::shared_ptr<layout_metrics_t> layout_metrics_ptr;
- (BOOL)tabBarView:(OakTabBarView*)aTabBarView shouldSelectIndex:(NSUInteger)anIndex;
- (void)tabBarView:(OakTabBarView*)aTabBarView didDoubleClickIndex:(NSUInteger)anIndex;
- (void)tabBarViewDidDoubleClick:(OakTabBarView*)aTabBarView;
- (NSMenu*)menuForTabBarView:(OakTabBarView*)aTabBarView;
// Methods sent to the delegate which the tab was dragged from
// When called, the delegate should set up the drag pasteboard using -addTypes:owner: with the data it requires

View File

@@ -73,7 +73,7 @@ struct layout_metrics_t
double minTabSize;
double maxTabSize;
std::vector<layer_t> layers_for (std::string const& layer_id, CGRect const& rect = CGRectZero, int tag = 0, NSString* label = nil, NSString* toolTip = nil, uint32_t requisiteFilter = layer_t::no_requisite) const;
std::vector<layer_t> layers_for (std::string const& layer_id, CGRect const& rect, int tag, NSString* label = nil, NSString* toolTip = nil, uint32_t requisiteFilter = layer_t::no_requisite) const;
static layout_metrics_ptr parse (NSDictionary* dict);
private:
@@ -411,10 +411,10 @@ static id SafeObjectAtIndex (NSArray* array, NSUInteger index)
D(DBF_TabBarView, bug("\n"););
if(!isExpanded)
return [self setLayout:metrics->layers_for("backgroundCollapsed", rect)];
return [self setLayout:metrics->layers_for("backgroundCollapsed", rect, -1)];
std::vector<layer_t> newLayout, selectedTabLayers;
newLayout = metrics->layers_for("background", rect);
newLayout = metrics->layers_for("background", rect, -1);
// ==========
@@ -548,6 +548,15 @@ static id SafeObjectAtIndex (NSArray* array, NSUInteger index)
[NSApp sendAction:@selector(performCloseTab:) to:nil from:self];
}
- (NSMenu*)menuForEvent:(NSEvent*)anEvent
{
NSPoint pos = [self convertPoint:[anEvent locationInWindow] fromView:nil];
tag = [self tagForLayerContainingPoint:pos];
if(tag != NSNotFound && [delegate respondsToSelector:@selector(menuForTabBarView:)])
return [delegate menuForTabBarView:self];
return [super menuForEvent:anEvent];
}
- (void)setSelectedTab:(NSUInteger)anIndex
{
if(selectedTab == anIndex)