Skip to content

Commit

Permalink
further whitespace fixes 2
Browse files Browse the repository at this point in the history
  • Loading branch information
danomatika committed Mar 14, 2016
1 parent c5ecdac commit 7c33e51
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 83 deletions.
24 changes: 12 additions & 12 deletions src/classes/Util.m
Expand Up @@ -172,17 +172,17 @@ + (NSArray *)whichFilenames:(NSArray *)filenames existInDirectory:(NSString *)di
// http://stackoverflow.com/questions/2765537/how-do-i-use-the-nsstring-draw-functionality-to-create-a-uiimage-from-text#2768081
+ (UIImage *)imageFromString:(NSString *)string withFont:(UIFont*)font {

CGSize size = [string sizeWithFont:font];
CGSize size = [string sizeWithFont:font];
UIGraphicsBeginImageContextWithOptions(size, NO, 0.0);

// draw in context, you can use also drawInRect:withFont:
[string drawAtPoint:CGPointMake(0.0, 0.0) withFont:font];
// draw in context, you can use also drawInRect:withFont:
[string drawAtPoint:CGPointMake(0.0, 0.0) withFont:font];

// transfer image
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
// transfer image
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();

return image;
return image;
}

+ (UIImage *)image:(UIImage *)image withTint:(UIColor *)tint {
Expand Down Expand Up @@ -233,11 +233,11 @@ + (void)unregisterFont:(NSString *)fontPath {

+ (id)parseJSONFromFile:(NSString *)path {
NSError *error;
id data = [NSJSONSerialization JSONObjectWithData:[NSData dataWithContentsOfFile:path] options:0 error:&error];
if(!data) {
DDLogError(@"Util: parsing JSON from %@ failed: %@", path, error.debugDescription);
}
return data;
id data = [NSJSONSerialization JSONObjectWithData:[NSData dataWithContentsOfFile:path] options:0 error:&error];
if(!data) {
DDLogError(@"Util: parsing JSON from %@ failed: %@", path, error.debugDescription);
}
return data;
}

@end
Expand Down
80 changes: 40 additions & 40 deletions src/gui/iem/Slider.m
Expand Up @@ -145,18 +145,18 @@ - (void)setValue:(float)value{
double g;
if(isReversed) {
value = CLAMP(value, self.maxValue, self.minValue);
}
else {
}
else {
value = CLAMP(value, self.minValue, self.maxValue);
}
}
[super setValue:value];

if(self.log) { // float to pos
g = log(value / self.minValue) / sizeConvFactor;
g = log(value / self.minValue) / sizeConvFactor;
}
else {
g = (value - self.minValue) / sizeConvFactor;
}
else {
g = (value - self.minValue) / sizeConvFactor;
}
_controlValue = (int)(100.0*g + 0.49999);
controlPos = _controlValue;
}
Expand All @@ -167,14 +167,14 @@ - (void)setControlValue:(int)controlValue {

double g;
if(self.log) { // pos to float
g = self.minValue * exp(sizeConvFactor * (double)(controlValue) * 0.01);
}
g = self.minValue * exp(sizeConvFactor * (double)(controlValue) * 0.01);
}
else {
g = (double)(controlValue) * 0.01 * sizeConvFactor + self.minValue;
g = (double)(controlValue) * 0.01 * sizeConvFactor + self.minValue;
}

if((g < 1.0e-10) && (g > -1.0e-10)) {
g = 0.0;
if((g < 1.0e-10) && (g > -1.0e-10)) {
g = 0.0;
}
[super setValue:g];
}
Expand Down Expand Up @@ -212,8 +212,8 @@ - (NSString *)type {

// from g_hslider.c & g_vslider.c
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch *touch = [touches anyObject];
CGPoint pos = [touch locationInView:self];
UITouch *touch = [touches anyObject];
CGPoint pos = [touch locationInView:self];

if([touches count] > 1) {
isOneFinger = NO;
Expand Down Expand Up @@ -248,8 +248,8 @@ - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {

// from g_hslider.c & g_vslider.c
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch *touch = [touches anyObject];
CGPoint pos = [touch locationInView:self];
UITouch *touch = [touches anyObject];
CGPoint pos = [touch locationInView:self];

if(self.orientation == WidgetOrientationHorizontal) {
float delta = (pos.x - prevPos) / self.gui.scaleX;
Expand Down Expand Up @@ -389,8 +389,8 @@ - (void)checkSize {
size = CGRectGetHeight(self.originalFrame);
}

if(size < IEM_SL_MINSIZE) {
size = IEM_SL_MINSIZE;
if(size < IEM_SL_MINSIZE) {
size = IEM_SL_MINSIZE;
if(self.orientation == WidgetOrientationHorizontal) {
self.originalFrame = CGRectMake(
self.originalFrame.origin.x, self.originalFrame.origin.y,
Expand All @@ -404,40 +404,40 @@ - (void)checkSize {
}

centerValue = (size-1) * 50;
if(self.controlValue > (size * 100 - 100)) {
self.controlValue = size * 100 - 100;
}
if(self.log) {
if(self.controlValue > (size * 100 - 100)) {
self.controlValue = size * 100 - 100;
}
if(self.log) {
sizeConvFactor = log(self.maxValue / self.minValue) / (double)(size - 1);
}
}
else {
sizeConvFactor = (self.maxValue - self.minValue) / (double)(size - 1);
sizeConvFactor = (self.maxValue - self.minValue) / (double)(size - 1);
}
}

// from g_hslider.c & g_vslider.c
- (void)checkMinAndMax {
if(self.log) {
if((self.minValue == 0.0) && (self.maxValue == 0.0)) {
if((self.minValue == 0.0) && (self.maxValue == 0.0)) {
self.maxValue = 1.0;
}
if(self.maxValue > 0.0) {
if(self.minValue <= 0.0) {
self.minValue = 0.01 * self.maxValue;
if(self.maxValue > 0.0) {
if(self.minValue <= 0.0) {
self.minValue = 0.01 * self.maxValue;
}
}
else {
if(self.minValue > 0.0) {
self.maxValue = 0.01 * self.minValue;
}
else {
if(self.minValue > 0.0) {
self.maxValue = 0.01 * self.minValue;
}
}
}
}
}

if(self.minValue > self.maxValue) {
isReversed = YES;
if(self.minValue > self.maxValue) {
isReversed = YES;
}
else {
isReversed = NO;
else {
isReversed = NO;
}

float size = CGRectGetWidth(self.originalFrame);
Expand All @@ -447,9 +447,9 @@ - (void)checkMinAndMax {

if(self.log) {
sizeConvFactor = log(self.maxValue / self.minValue) / (double)(size - 1);
}
}
else {
sizeConvFactor = (self.maxValue - self.minValue) / (double)(size - 1);
sizeConvFactor = (self.maxValue - self.minValue) / (double)(size - 1);
}
}

Expand Down
62 changes: 31 additions & 31 deletions src/gui/iem/VUMeter.m
Expand Up @@ -75,7 +75,7 @@ - (void)drawRect:(CGRect)rect {
CGSize charSize = [@"0" sizeWithFont:self.label.font]; // assumes monospace font
int yOffset = charSize.height / 2;

CGContextRef context = UIGraphicsGetCurrentContext();
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextTranslateCTM(context, 0.5, 0.5); // snap to nearest pixel
CGContextSetLineWidth(context, 1.0);

Expand All @@ -93,15 +93,15 @@ - (void)drawRect:(CGRect)rect {
CGContextStrokeRect(context, meterRect);

// from g_vumeter.c
int w4 = CGRectGetWidth(self.originalFrame) / 4,
quad1 = ceil(w4 * self.gui.scaleX);
int quad3 = floor((CGRectGetWidth(self.originalFrame) - w4) * self.gui.scaleX),
end = floor((CGRectGetWidth(self.originalFrame) + 2) * self.gui.scaleX);
int k1 = ledSize + 1, k2 = IEM_VU_STEPS + 1, k3 = k1 / 2;
int yyy, i, k4 = -k3;
int w4 = CGRectGetWidth(self.originalFrame) / 4,
quad1 = ceil(w4 * self.gui.scaleX);
int quad3 = floor((CGRectGetWidth(self.originalFrame) - w4) * self.gui.scaleX),
end = floor((CGRectGetWidth(self.originalFrame) + 2) * self.gui.scaleX);
int k1 = ledSize + 1, k2 = IEM_VU_STEPS + 1, k3 = k1 / 2;
int yyy, i, k4 = -k3;

for(i = 1; i <= IEM_VU_STEPS; ++i) {
yyy = round(((k4 + k1 * (k2 - i)) * self.gui.scaleX) + yOffset);
yyy = round(((k4 + k1 * (k2 - i)) * self.gui.scaleX) + yOffset);

// fat line for overlap since spacing between is not pixel perfect when scaling
CGContextSetLineWidth(context, ceil((ledSize + (i < IEM_VU_STEPS ? 2 : 1)) * self.gui.scaleX));
Expand All @@ -124,7 +124,7 @@ - (void)drawRect:(CGRect)rect {
}

// scale
if(((i + 2) & 3) && self.showScale) {
if(((i + 2) & 3) && self.showScale) {
yyy = round((k1 * (k2 - i)) * self.gui.scaleX);
NSString * vuString = [NSString stringWithUTF8String:iemgui_vu_scale_str[i]];
if(vuString.length > 0) {
Expand Down Expand Up @@ -177,35 +177,35 @@ - (void)reshape {
#pragma mark Overridden Getters / Setters

- (void)setValue:(float)f {
int i;
int i;
if(f <= IEM_VU_MINDB) {
rmsLed = 0;
}
}
else if(f >= IEM_VU_MAXDB) {
rmsLed = IEM_VU_STEPS;
}
}
else {
i = (int)(2.0 * (f + IEM_VU_OFFSET));
rmsLed = iemgui_vu_db2i[i];
}
i = (int)((100.0 * f) + 10000.5);
[super setValue:(0.01 * (i - 10000))];
i = (int)(2.0 * (f + IEM_VU_OFFSET));
rmsLed = iemgui_vu_db2i[i];
}
i = (int)((100.0 * f) + 10000.5);
[super setValue:(0.01 * (i - 10000))];
}

- (void)setPeakValue:(float)peakValue {
int i;
if(peakValue <= IEM_VU_MINDB) {
peakLed = 0;
int i;
if(peakValue <= IEM_VU_MINDB) {
peakLed = 0;
}
else if(peakValue >= IEM_VU_MAXDB) {
peakLed = IEM_VU_STEPS;
else if(peakValue >= IEM_VU_MAXDB) {
peakLed = IEM_VU_STEPS;
}
else {
i = (int)(2.0 * (peakValue + IEM_VU_OFFSET));
peakLed = iemgui_vu_db2i[i];
}
else {
i = (int)(2.0 * (peakValue + IEM_VU_OFFSET));
peakLed = iemgui_vu_db2i[i];
}
i = (int)(100.0 * peakValue + 10000.5);
_peakValue = 0.01 * (i - 10000);
i = (int)(100.0 * peakValue + 10000.5);
_peakValue = 0.01 * (i - 10000);
// doesn't call setNeedsDisplay,
// rms & peak values come in pairs so only redisplay once when setting rms
}
Expand Down Expand Up @@ -294,10 +294,10 @@ - (BOOL)receiveEditMessage:(NSString *)message withArguments:(NSArray *)argument
// from g_vumeter.c
- (void)checkHeight {
int n = CGRectGetHeight(self.originalFrame) / IEM_VU_STEPS;
if(n < IEM_VU_MINSIZE) {
n = IEM_VU_MINSIZE;
if(n < IEM_VU_MINSIZE) {
n = IEM_VU_MINSIZE;
}
ledSize = n-1;
ledSize = n-1;
CGRect frame = self.originalFrame;
frame.size.height = IEM_VU_STEPS * n;
self.originalFrame = frame;
Expand Down

0 comments on commit 7c33e51

Please sign in to comment.