Skip to content

Commit

Permalink
Merge pull request pixmeo#54 from aglv/develop
Browse files Browse the repository at this point in the history
A couple fixes
  • Loading branch information
rossetantoine committed Nov 12, 2014
2 parents 7b273d7 + 564cda6 commit 6639eb8
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 23 deletions.
4 changes: 2 additions & 2 deletions ROI.m
Original file line number Diff line number Diff line change
Expand Up @@ -2019,8 +2019,8 @@ - (long) clickInROI:(NSPoint) pt :(float) offsetx :(float) offsety :(float) scal
// else
{
bitmap = [[NSBitmapImageRep alloc] initWithData:[layerImage TIFFRepresentation]];
width = [layerImage size].width;
height = [layerImage size].height;
width = bitmap.pixelsWide;
height = bitmap.pixelsHigh;
}

// base vectors of the layer image coordinate system
Expand Down
2 changes: 1 addition & 1 deletion nitrogen/Sources/N2Layout.mm
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ @implementation N2Layout
-(id)initWithView:(N2View*)view controlSize:(NSControlSize)size {
self = [super init];
_view = view;
[view setLayout:self];
[view setN2layout:self];
[self setEnabled:YES];

switch (_controlSize = size) {
Expand Down
20 changes: 11 additions & 9 deletions nitrogen/Sources/N2StepsView.mm
Original file line number Diff line number Diff line change
Expand Up @@ -43,20 +43,22 @@ -(void)awakeFromNib {
for (N2Step* step in [_steps content])
[self stepsDidAddStep:[NSNotification notificationWithName:N2StepsDidAddStepNotification object:_steps userInfo:[NSDictionary dictionaryWithObject:step forKey:N2StepsNotificationStep]]];

[[self layout] layOut];
[[self n2layout] layOut];
}

-(void)setForeColor:(NSColor*)color {
if (_foreColor) [_foreColor release];
_foreColor = [color retain];
for (N2StepView* view in [self subviews])
[[[view titleCell] attributes] setValue:[self foreColor] forKey:NSForegroundColorAttributeName];
if ([view isKindOfClass:[N2StepView class]])
[[[view titleCell] attributes] setValue:[self foreColor] forKey:NSForegroundColorAttributeName];
}

-(void)setControlSize:(NSControlSize)controlSize {
_controlSize = controlSize;
for (N2StepView* view in [self subviews])
[[[view titleCell] attributes] setValue:[NSFont labelFontOfSize:[NSFont systemFontSizeForControlSize:controlSize]] forKey:NSFontAttributeName];
if ([view isKindOfClass:[N2StepView class]])
[[[view titleCell] attributes] setValue:[NSFont labelFontOfSize:[NSFont systemFontSizeForControlSize:controlSize]] forKey:NSFontAttributeName];
}

-(void)dealloc {
Expand Down Expand Up @@ -109,7 +111,7 @@ -(void)stepsDidAddStep:(NSNotification*)notification {
[view setPostsFrameChangedNotifications:YES];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(stepViewFrameDidChange:) name:NSViewFrameDidChangeNotification object:view];

[(N2ColumnLayout*)_layout appendRow:[NSArray arrayWithObject:view]];
[(N2ColumnLayout*)_n2layout appendRow:[NSArray arrayWithObject:view]];

[self layOut];
}
Expand All @@ -130,23 +132,23 @@ -(void)stepsWillRemoveStep:(NSNotification*)notification {
[[NSNotificationCenter defaultCenter] removeObserver:self name:NSViewFrameDidChangeNotification object:view];
[view removeFromSuperview];

[[self layout] layOut];
[[self n2layout] layOut];
}

-(void)stepViewFrameDidChange:(NSNotification*)notification {
[[self layout] layOut];
[[self n2layout] layOut];
}

-(void)layOut {
[_layout layOut];
[_n2layout layOut];
}

-(NSSize)optimalSize {
return n2::ceil([_layout optimalSize]);
return n2::ceil([_n2layout optimalSize]);
}

-(NSSize)optimalSizeForWidth:(CGFloat)width {
return n2::ceil([_layout optimalSizeForWidth:width]);
return n2::ceil([_n2layout optimalSizeForWidth:width]);
}

@end
4 changes: 2 additions & 2 deletions nitrogen/Sources/N2View.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ extern NSString* N2ViewBoundsSizeDidChangeNotificationOldBoundsSize;
@interface N2View : NSView {
NSControlSize _controlSize;
NSSize _minSize, _maxSize;
N2Layout* _layout;
N2Layout* _n2layout;
NSColor* _foreColor;
NSColor* _backColor;
}

@property NSControlSize controlSize;
@property NSSize minSize, maxSize;
@property(retain) N2Layout* layout;
@property(retain) N2Layout* n2layout;
@property(nonatomic, retain) NSColor* foreColor;
@property(nonatomic, retain) NSColor* backColor;

Expand Down
18 changes: 9 additions & 9 deletions nitrogen/Sources/N2View.mm
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@
NSString* N2ViewBoundsSizeDidChangeNotificationOldBoundsSize = @"oldBoundsSize";

@implementation N2View
@synthesize controlSize = _controlSize, minSize = _minSize, maxSize = _maxSize, layout = _layout, foreColor = _foreColor, backColor = _backColor;
@synthesize controlSize = _controlSize, minSize = _minSize, maxSize = _maxSize, n2layout = _n2layout, foreColor = _foreColor, backColor = _backColor;


-(void)dealloc {
[self setForeColor:NULL];
[self setBackColor:NULL];
[self setLayout:NULL];
[self setN2layout:NULL];
[super dealloc];
}

Expand All @@ -35,7 +35,7 @@ -(void)resizeSubviews {
}

-(void)resizeSubviewsWithOldSize:(NSSize)oldBoundsSize {
[_layout layOut];
[_n2layout layOut];
[[NSNotificationCenter defaultCenter] postNotification:[NSNotification notificationWithName:N2ViewBoundsSizeDidChangeNotification object:self userInfo:[NSDictionary dictionaryWithObject:[NSValue valueWithSize:oldBoundsSize] forKey:N2ViewBoundsSizeDidChangeNotificationOldBoundsSize]]];
}

Expand All @@ -53,11 +53,11 @@ -(void)formatSubview:(NSView*)view {
view = self;

for (NSView* subview in [view subviews])
if (![subview isKindOfClass:[N2View class]] || [(N2View*)subview layout] == NULL)
if (![subview isKindOfClass:[N2View class]] || [(N2View*)subview n2layout] == NULL)
[self formatSubview:subview];
if ([view respondsToSelector:@selector(additionalSubviews)])
for (NSView* subview in [view performSelector:@selector(additionalSubviews)])
if (![subview isKindOfClass:[N2View class]] || [(N2View*)subview layout] == NULL)
if (![subview isKindOfClass:[N2View class]] || [(N2View*)subview n2layout] == NULL)
[self formatSubview:subview];
}

Expand All @@ -84,14 +84,14 @@ -(void)setForeColor:(NSColor*)color {
}*/

-(NSSize)optimalSize {
if (_layout)
return n2::ceil([_layout optimalSize]);
if (_n2layout)
return n2::ceil([_n2layout optimalSize]);
else return [self frame].size;
}

-(NSSize)optimalSizeForWidth:(CGFloat)width {
if (_layout)
return n2::ceil([_layout optimalSizeForWidth:width]);
if (_n2layout)
return n2::ceil([_n2layout optimalSizeForWidth:width]);
else return [self frame].size;
}

Expand Down

0 comments on commit 6639eb8

Please sign in to comment.