Skip to content

Commit

Permalink
Fix for not setting image position preventing image from being shown #22
Browse files Browse the repository at this point in the history
.
  • Loading branch information
ttveldhuis committed Apr 17, 2018
1 parent 563a8bf commit 3cfaba6
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 10 deletions.
Binary file modified src/debug/resources/lib/libJTouchBar.dylib
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public class TouchBarButton extends TouchBarView {
private String _title;

private Image _image;
private int _imagePosition;
private int _imagePosition = ImagePosition.OVERLAPS;

private Color _bezelColor;

Expand Down
14 changes: 5 additions & 9 deletions src/main/objective-c++/Bridged/JavaTouchBarItem.mm
Original file line number Diff line number Diff line change
Expand Up @@ -200,22 +200,18 @@ -(void) updateButton:(NSButton*)button env:(JNIEnv*)env jTouchBarView:(jobject)j
});

image_t image = JNIContext::CallImageMethod(env, jTouchBarView, "getImage");
int imagePosition = JNIContext::CallIntMethod(env, jTouchBarView, "getImagePosition");

NSImage *nsImage = [JTouchBarUtils getNSImage:image];
if(nsImage != nil) {
dispatch_async(dispatch_get_main_queue(), ^{
[button setImage:nsImage];
[button setImagePosition:(NSCellImagePosition)imagePosition];
});
}

if(button.image != nil) {
int imagePosition = JNIContext::CallIntMethod(env, jTouchBarView, "getImagePosition");
dispatch_async(dispatch_get_main_queue(), ^{
[button setImagePosition:(NSCellImagePosition)imagePosition];
});
}


bool enabled = JNIContext::CallBooleanMethod(env, jTouchBarView, "isEnabled");
[button setEnabled: enabled];
[button setEnabled:enabled];
}

-(void) updateTextField:(NSTextField*)textField env:(JNIEnv*)env jTouchBarView:(jobject)jTouchBarView {
Expand Down
Binary file modified src/release/resources/lib/libJTouchBar.dylib
Binary file not shown.
Binary file not shown.

0 comments on commit 3cfaba6

Please sign in to comment.