Skip to content

Fix for issue4977 mac osx #5062

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Sep 15, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions setupext.py
Original file line number Diff line number Diff line change
Expand Up @@ -601,6 +601,7 @@ def get_package_data(self):
'mpl-data/images/*.xpm',
'mpl-data/images/*.svg',
'mpl-data/images/*.gif',
'mpl-data/images/*.pdf',
'mpl-data/images/*.png',
'mpl-data/images/*.ppm',
'mpl-data/example/*.npy',
Expand Down
34 changes: 26 additions & 8 deletions src/_macosx.m
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@
#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
#define COMPILING_FOR_10_6
#endif
#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
#define COMPILING_FOR_10_7
#endif
#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 10100
#define COMPILING_FOR_10_10
#endif
Expand Down Expand Up @@ -4883,9 +4886,12 @@ -(void)save_figure:(id)sender

int i;
NSRect rect;
NSSize size;
NSSize scale;

const float gap = 2;
const int height = 36;
const int imagesize = 24;

const char* basedir;

Expand Down Expand Up @@ -4926,13 +4932,13 @@ -(void)save_figure:(id)sender

NSButton* buttons[7];

NSString* images[7] = {@"home.png",
@"back.png",
@"forward.png",
@"move.png",
@"zoom_to_rect.png",
@"subplots.png",
@"filesave.png"};
NSString* images[7] = {@"home.pdf",
@"back.pdf",
@"forward.pdf",
@"move.pdf",
@"zoom_to_rect.pdf",
@"subplots.pdf",
@"filesave.pdf"};

NSString* tooltips[7] = {@"Reset original view",
@"Back to previous view",
Expand All @@ -4958,20 +4964,32 @@ -(void)save_figure:(id)sender
NSMomentaryLightButton,
NSMomentaryLightButton};

rect.origin.x = 0;
rect.origin.y = 0;
rect.size.width = imagesize;
rect.size.height = imagesize;
#ifdef COMPILING_FOR_10_7
rect = [window convertRectToBacking: rect];
#endif
size = rect.size;
scale.width = imagesize / size.width;
scale.height = imagesize / size.height;

rect.size.width = 32;
rect.size.height = 32;
rect.origin.x = gap;
rect.origin.y = 0.5*(height - rect.size.height);

for (i = 0; i < 7; i++)
{
const NSSize size = {24, 24};
NSString* filename = [dir stringByAppendingPathComponent: images[i]];
NSImage* image = [[NSImage alloc] initWithContentsOfFile: filename];
buttons[i] = [[NSButton alloc] initWithFrame: rect];
[image setSize: size];
[buttons[i] setBezelStyle: NSShadowlessSquareBezelStyle];
[buttons[i] setButtonType: buttontypes[i]];
[buttons[i] setImage: image];
[buttons[i] scaleUnitSquareToSize: scale];
[buttons[i] setImagePosition: NSImageOnly];
[buttons[i] setToolTip: tooltips[i]];
[[window contentView] addSubview: buttons[i]];
Expand Down