Skip to content

Commit

Permalink
Now Icons change dynamically, and other small fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
nodeful committed Jul 24, 2017
1 parent 4026445 commit 0483585
Show file tree
Hide file tree
Showing 43 changed files with 151 additions and 203 deletions.
Binary file modified .DS_Store
Binary file not shown.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.DS_Store
.DS_Store/
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ If you found a bug in eqMac2, please follow these steps to properly report it:
2. Go to [Issues tab](https://github.com/romankisil/eqMac2/issues) and create a new Issue
3. Set the Label (on the right) to Bug or any other appropriate
4. Describe the Bug as much as possible
5. If required upload Screenshots to https://imgur.com and include links in your Issue
5. If possible include some Screenshots

### Contributing your code
1. First, create an Issue with an 'enchancement' or 'bug' label
Expand Down
Binary file modified Source/.DS_Store
Binary file not shown.
7 changes: 6 additions & 1 deletion Source/AppDelegate.mm
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,18 @@ -(void)setupStatusBar{
statusItemView.action = @selector(openEQ); //Open EQ View on Left Click
statusItemView.rightAction = @selector(openSettingsMenu); //Open Settings on Right Click

statusItemView.image = [NSImage imageNamed: [Utilities isDarkMode] ? @"statusItemWhite" : @"statusItemBlack"];
_statusBar = [[NSStatusBar systemStatusBar] statusItemWithLength:NSSquareStatusItemLength];
[_statusBar setView:statusItemView];
[self setStatusItemIcon];
[Utilities executeBlock:^{ [self setStatusItemIcon]; } every:1];
}

-(void)setStatusItemIcon{
statusItemView.image = [NSImage imageNamed: [Utilities isDarkMode] ? @"statusItemLight" : @"statusItemDark"];
}

-(void)applicationDidFinishLaunching:(NSNotification *)notification{

NSNotificationCenter *observer = [NSNotificationCenter defaultCenter];
[observer addObserver:self selector:@selector(changeVolume:) name:@"changeVolume" object:nil];
[observer addObserver:self selector:@selector(quitApplication) name:@"closeApp" object:nil];
Expand Down
Binary file modified Source/Assets/.DS_Store
Binary file not shown.
Binary file modified Source/Assets/Assets/.DS_Store
Binary file not shown.
Binary file removed Source/Assets/Assets/Tutorial/.DS_Store
Binary file not shown.
Binary file removed Source/Assets/Assets/Tutorial/eq.png
Binary file not shown.
Binary file removed Source/Assets/Assets/Tutorial/settings.png
Binary file not shown.
Binary file removed Source/Assets/Assets/Tutorial/statusBar.jpg
Binary file not shown.
Binary file added Source/Assets/Assets/deleteDark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
Binary file added Source/Assets/Assets/exitDark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
Binary file added Source/Assets/Assets/saveDark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
Binary file added Source/Assets/Assets/speakerDark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
File renamed without changes
File renamed without changes
Binary file added Source/Assets/Assets/vol1Dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
Binary file added Source/Assets/Assets/vol2Dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
Binary file added Source/Assets/Assets/vol3Dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
Binary file added Source/Assets/Assets/vol4Dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
2 changes: 1 addition & 1 deletion Source/Common/Constants/Constants.m
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@
NSString * const API_URL = DEBUGGING ? @"http://localhost:3000" : @"https://eqmac-api.bitgapp.com";
NSString * const APP_URL = DEBUGGING ? @"http://localhost:8080/eqmac/" : @"https://bitgapp.com/eqmac/";
NSString * const SUPPORT_URL = DEBUGGING ? @"http://localhost:8080/eqmac/#/donate" : @"https://bitgapp.com/eqmac/#/donate";
NSString * const REPO_ISSUES_URL = @"https://github.com/romankisil/eqMac2/issues";
NSString * const REPO_ISSUES_URL = @"https://github.com/romankisil/eqMac2/blob/master/CONTRIBUTING.md";
Float32 const VOLUME_STEP = 0.065;

1 change: 0 additions & 1 deletion Source/Common/Devices/Devices.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ return err; \
+(AudioDeviceID)getEQMacDeviceID;
+(AudioDeviceID)getBuiltInDeviceID;
+(AudioDeviceID)getVolumeControllerDeviceID;
+(AudioDeviceID)getBalanceControllerDeviceID;

+(void)switchToDeviceWithID:(AudioDeviceID)ID;

Expand Down
32 changes: 9 additions & 23 deletions Source/Common/Devices/Devices.mm
Original file line number Diff line number Diff line change
Expand Up @@ -131,24 +131,7 @@ +(AudioDeviceID)getBuiltInDeviceID{


+(AudioDeviceID)getVolumeControllerDeviceID{
if([EQHost EQEngineExists]){
AudioDeviceID selectedDeviceID = [EQHost getSelectedOutputDeviceID];
if(selectedDeviceID == [self getEQMacDeviceID]){
return [self getBuiltInDeviceID];
}else{
return selectedDeviceID;
}
}else{
return [self getCurrentDeviceID];
}
}

+(AudioDeviceID)getBalanceControllerDeviceID{
if([EQHost EQEngineExists]){
return [EQHost getSelectedOutputDeviceID];
}else{
return [Devices getCurrentDeviceID];
}
return [EQHost EQEngineExists] ? [EQHost getSelectedOutputDeviceID] : [self getCurrentDeviceID];
}

#pragma mark -
Expand Down Expand Up @@ -195,21 +178,25 @@ +(Float32)getVolumeForDevice:(AudioDeviceID)deviceID andChannel:(VOLUME_CHANNEL)
}

+(Float32)getVolumeForDeviceID:(AudioDeviceID)ID{
Float32 volume = 0;
if([self audioDeviceHasMasterVolume:ID]){
return [self getVolumeForDevice:ID andChannel:kChannelMaster];
volume = [self getVolumeForDevice:ID andChannel:kChannelMaster];
}else{
Float32 leftVolume = [self getVolumeForDevice:ID andChannel:kChannelLeft];
Float32 rightVolume = [self getVolumeForDevice:ID andChannel:kChannelRight];
return MAX(rightVolume, leftVolume);
volume = MAX(rightVolume, leftVolume);
}
return volume;
}

+(Float32)getBalanceForDeviceID:(AudioDeviceID)ID{
Float32 volume = [self getVolumeForDeviceID:ID];
Float32 left = [self getVolumeForDevice:ID andChannel:kChannelLeft];
Float32 right = [self getVolumeForDevice:ID andChannel:kChannelRight];
Float32 balance = right - left;
return [Utilities mapValue:balance withInMin:-volume InMax:volume OutMin:-1 OutMax:1];
balance = [Utilities mapValue:balance withInMin:-volume InMax:volume OutMin:-1 OutMax:1];
if(isnan(balance)) balance = 0;
return balance;
}

+(BOOL)getIsMutedForDeviceID:(AudioDeviceID)ID{
Expand Down Expand Up @@ -366,12 +353,11 @@ +(BOOL)audioDeviceHasMasterVolume:(AudioDeviceID)ID{

//PUBLIC
+(void)setVolumeForDevice:(AudioDeviceID)ID to:(Float32)volume{

if([self audioDeviceHasMasterVolume:ID]){
[self setVolumeForDevice:ID andChannel:kChannelMaster to:volume];
}else{
Float32 balance = [self getBalanceForDeviceID:ID];

Float32 leftMultiplier = balance < 0 ? 1 : 1 - balance;
Float32 rightMiltiplier = balance > 0 ? 1 : 1 + balance;
Float32 leftVolume = volume * leftMultiplier;
Expand Down
1 change: 0 additions & 1 deletion Source/Common/Utilities/Utilities.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,4 @@
+(BOOL)appLaunchedBefore;
+ (BOOL)launchOnLogin;
+ (void)setLaunchOnLogin:(BOOL)launchOnLogin;
+(NSImage *)invertedImageFromImage:(NSImage*)image;
@end
72 changes: 0 additions & 72 deletions Source/Common/Utilities/Utilities.m
Original file line number Diff line number Diff line change
Expand Up @@ -242,77 +242,5 @@ +(NSString*)readableDateFromNSDate:(NSDate*)date{
timeStyle:NSDateFormatterFullStyle];
}


+(NSImage *)invertedImageFromImage:(NSImage*)image{
// get width and height as integers, since we'll be using them as
// array subscripts, etc, and this'll save a whole lot of casting
CGSize size = image.size;
int width = size.width;
int height = size.height;

// Create a suitable RGB+alpha bitmap context in BGRA colour space
CGColorSpaceRef colourSpace = CGColorSpaceCreateDeviceRGB();
unsigned char *memoryPool = (unsigned char *)calloc(width*height*4, 1);
CGContextRef context = CGBitmapContextCreate(memoryPool, width, height, 8, width * 4, colourSpace, kCGBitmapByteOrder32Big | kCGImageAlphaPremultipliedLast);
CGColorSpaceRelease(colourSpace);

// draw the current image to the newly created context
NSRect imageRect = NSMakeRect(0, 0, image.size.width, image.size.height);
CGContextDrawImage(context, CGRectMake(0, 0, width, height), [image CGImageForProposedRect:&imageRect context:NULL hints:nil]);

// run through every pixel, a scan line at a time...
for(int y = 0; y < height; y++)
{
// get a pointer to the start of this scan line
unsigned char *linePointer = &memoryPool[y * width * 4];

// step through the pixels one by one...
for(int x = 0; x < width; x++)
{
// get RGB values. We're dealing with premultiplied alpha
// here, so we need to divide by the alpha channel (if it
// isn't zero, of course) to get uninflected RGB. We
// multiply by 255 to keep precision while still using
// integers
int r, g, b;
if(linePointer[3])
{
r = linePointer[0] * 255 / linePointer[3];
g = linePointer[1] * 255 / linePointer[3];
b = linePointer[2] * 255 / linePointer[3];
}
else
r = g = b = 0;

// perform the colour inversion
r = 255 - r;
g = 255 - g;
b = 255 - b;

// multiply by alpha again, divide by 255 to undo the
// scaling before, store the new values and advance
// the pointer we're reading pixel data from
linePointer[0] = r * linePointer[3] / 255;
linePointer[1] = g * linePointer[3] / 255;
linePointer[2] = b * linePointer[3] / 255;
linePointer += 4;
}
}

// get a CG image from the context, wrap that into a
// NSImage
CGImageRef cgImage = CGBitmapContextCreateImage(context);
NSImage *returnImage = [[NSImage alloc] initWithCGImage:cgImage size:size];

// clean up
CGImageRelease(cgImage);
CGContextRelease(context);
free(memoryPool);

// and return
return returnImage;
}


@end

13 changes: 4 additions & 9 deletions Source/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -17,29 +17,24 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>2.0</string>
<string>2.0.1</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>2.0</string>
<string>2.0.1</string>
<key>LSApplicationCategoryType</key>
<string>public.app-category.music</string>
<key>LSMinimumSystemVersion</key>
<string>$(MACOSX_DEPLOYMENT_TARGET)</string>
<key>LSUIElement</key>
<true/>
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
<key>NSHumanReadableCopyright</key>
<string>Copyright © 2015 bitgapp. All rights reserved.</string>
<string>Copyright © 2015-2017 Bitgapp. All rights reserved.</string>
<key>NSMainNibFile</key>
<string>Main</string>
<key>NSPrincipalClass</key>
<string>NSAppEventCatcher</string>
<key>SUFeedURL</key>
<string>https://www.bitgapp.com/eqmac/update/</string>
<string>https://bitgapp.com/eqmac/update.xml</string>
</dict>
</plist>
1 change: 1 addition & 0 deletions Source/Views/EQ/SliderGraphView/SliderGraphView.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

#import <Cocoa/Cocoa.h>
#import <Quartz/Quartz.h>
#import "Utilities.h"

@interface SliderGraphView : NSView

Expand Down
13 changes: 7 additions & 6 deletions Source/Views/EQ/SliderGraphView/SliderGraphView.m
Original file line number Diff line number Diff line change
Expand Up @@ -92,25 +92,25 @@ -(void)drawRect:(NSRect)dirtyRect {

[NSGraphicsContext restoreGraphicsState];

drawingColor = [NSColor whiteColor];
drawingColor = [Utilities isDarkMode] ? [NSColor whiteColor] : [NSColor blackColor];
[drawingColor set];
[graph setLineWidth:sliderBarWidth];
[graph stroke];

drawingColor = [Utilities isDarkMode] ? [NSColor colorWithRed:0.85 green:0.85 blue:0.85 alpha:1] : [NSColor colorWithRed:0.15 green:0.15 blue:0.15 alpha:1];
[drawingColor set];
for(NSBezierPath *bar in sliderBarArray){
drawingColor = [NSColor colorWithRed:0.85 green:0.85 blue:0.85 alpha:1];
[drawingColor set];
[bar fill];
}

[middleLine fill];
NSMutableArray *tempArray = [[NSMutableArray alloc] init];

for(NSBezierPath *knob in knobArray){
drawingColor = [NSColor colorWithRed:0.85 green:0.85 blue:0.85 alpha:1];
drawingColor = [Utilities isDarkMode] ? [NSColor colorWithRed:0.85 green:0.85 blue:0.85 alpha:1] : [NSColor colorWithRed:0.15 green:0.15 blue:0.15 alpha:1];
[drawingColor set];
[knob fill];
drawingColor = [NSColor colorWithRed:0.15 green:0.15 blue:0.15 alpha:1];
drawingColor = [Utilities isDarkMode] ? [NSColor colorWithRed:0.15 green:0.15 blue:0.15 alpha:1] : [NSColor colorWithRed:0.85 green:0.85 blue:0.85 alpha:1];
[drawingColor set];
[knob stroke];
[tempArray addObject:[NSNumber numberWithFloat:[self mapValue:knob.bounds.origin.y inMin:0 inMax:self.bounds.size.height-knobSize outMin:-1 outMax:1]]];
Expand All @@ -126,7 +126,8 @@ -(void)mouseDragged:(NSEvent*)e{
if(point.y > self.bounds.size.height - knobSize/2 || point.y < knobSize/2) return;
NSAffineTransform *transform = [NSAffineTransform transform];
CGPoint knobPos = [[knobArray objectAtIndex:sliderSelected] bounds].origin;
[transform translateXBy: 0 yBy: point.y - (knobPos.y + knobSize/2)];
CGFloat knobPosY = knobPos.y + knobSize/2;
[transform translateXBy: 0 yBy: point.y - knobPosY];
[[knobArray objectAtIndex:sliderSelected] transformUsingAffineTransform: transform];
[self newGraphFromKnobs];
[self postNotification];
Expand Down
5 changes: 5 additions & 0 deletions Source/Views/EQ/eqViewController.mm
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@

@interface eqViewController ()

@property (strong) IBOutlet NSButton *deleteButton;
@property (strong) IBOutlet NSButton *saveButton;

@property (strong) IBOutlet NSView *mockSliderView;
@property (weak) IBOutlet NSComboBox *presetsComboBox;
@property (strong) IBOutlet NSButton *presetsButton;
Expand Down Expand Up @@ -43,6 +46,8 @@ - (void)viewDidLoad {

-(void)viewWillAppear{
[Utilities executeBlock:^{ [self openPresetsDropdown:nil]; } after:0.1];
[_deleteButton setImage:[Utilities isDarkMode] ? [NSImage imageNamed:@"deleteLight"] : [NSImage imageNamed:@"deleteDark"]];
[_saveButton setImage:[Utilities isDarkMode] ? [NSImage imageNamed:@"saveLight"] : [NSImage imageNamed:@"saveDark"]];
}

-(void)viewDidAppear{
Expand Down
2 changes: 2 additions & 0 deletions Source/Views/EQ/eqViewController.xib
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@
<customObject id="-2" userLabel="File's Owner" customClass="eqViewController">
<connections>
<outlet property="_mockSliderView" destination="mxi-4w-muC" id="m0y-7L-vVw"/>
<outlet property="deleteButton" destination="j96-Rt-Axz" id="dCt-H6-I4l"/>
<outlet property="presetsButton" destination="rMA-BB-9m1" id="upR-4H-afm"/>
<outlet property="presetsComboBox" destination="k3c-0m-m56" id="pb5-Mx-iy5"/>
<outlet property="saveButton" destination="D6P-Fd-jYR" id="HEW-X4-pEk"/>
<outlet property="view" destination="l5q-FZ-i9D" id="ASl-08-s8D"/>
</connections>
</customObject>
Expand Down
Loading

0 comments on commit 0483585

Please sign in to comment.