Skip to content
This repository has been archived by the owner on Sep 14, 2023. It is now read-only.

Commit

Permalink
desklabels WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
thesoftwarephilosopher committed Mar 15, 2013
1 parent 94feda6 commit d419bdd
Show file tree
Hide file tree
Showing 6 changed files with 150 additions and 31 deletions.
12 changes: 9 additions & 3 deletions DeskLabels/DeskLabels.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
947520160FFC6D3C0049E92E /* SDGeneralPrefPane.m in Sources */ = {isa = PBXBuildFile; fileRef = 947520150FFC6D3C0049E92E /* SDGeneralPrefPane.m */; };
947520190FFC6D640049E92E /* GeneralPrefPane.xib in Resources */ = {isa = PBXBuildFile; fileRef = 947520180FFC6D640049E92E /* GeneralPrefPane.xib */; };
947D26AE1027921D003B8602 /* DeskLabels.icns in Resources */ = {isa = PBXBuildFile; fileRef = 947D26AD1027921D003B8602 /* DeskLabels.icns */; };
94893CFA16F29C9E00B86AE4 /* SDMoveAroundView.m in Sources */ = {isa = PBXBuildFile; fileRef = 94893CF916F29C9E00B86AE4 /* SDMoveAroundView.m */; };
948E374416DC698B00138A68 /* ScriptingBridge.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 948E374316DC698B00138A68 /* ScriptingBridge.framework */; };
948E374616DC70EA00138A68 /* ArrangeDesktopWindow.xib in Resources */ = {isa = PBXBuildFile; fileRef = 948E374516DC70EA00138A68 /* ArrangeDesktopWindow.xib */; };
948E374916DC710300138A68 /* SDArrangeDesktopWindow.m in Sources */ = {isa = PBXBuildFile; fileRef = 948E374816DC710300138A68 /* SDArrangeDesktopWindow.m */; };
Expand Down Expand Up @@ -156,6 +157,8 @@
947520150FFC6D3C0049E92E /* SDGeneralPrefPane.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = SDGeneralPrefPane.m; path = Source/SDGeneralPrefPane.m; sourceTree = "<group>"; };
947520180FFC6D640049E92E /* GeneralPrefPane.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = GeneralPrefPane.xib; path = XIBs/GeneralPrefPane.xib; sourceTree = "<group>"; };
947D26AD1027921D003B8602 /* DeskLabels.icns */ = {isa = PBXFileReference; lastKnownFileType = image.icns; name = DeskLabels.icns; path = Graphics/DeskLabels.icns; sourceTree = "<group>"; };
94893CF816F29C9E00B86AE4 /* SDMoveAroundView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDMoveAroundView.h; sourceTree = "<group>"; };
94893CF916F29C9E00B86AE4 /* SDMoveAroundView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SDMoveAroundView.m; sourceTree = "<group>"; };
948E374216DC695400138A68 /* Finder.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Finder.h; sourceTree = "<group>"; };
948E374316DC698B00138A68 /* ScriptingBridge.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = ScriptingBridge.framework; path = System/Library/Frameworks/ScriptingBridge.framework; sourceTree = SDKROOT; };
948E374516DC70EA00138A68 /* ArrangeDesktopWindow.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = ArrangeDesktopWindow.xib; sourceTree = "<group>"; };
Expand Down Expand Up @@ -199,6 +202,8 @@
1058C7A0FEA54F0111CA2CBB /* Linked Frameworks */ = {
isa = PBXGroup;
children = (
948E374316DC698B00138A68 /* ScriptingBridge.framework */,
9466B59616C187C9009ECA41 /* ServiceManagement.framework */,
9413C9E80FFA780500BC5D43 /* QuartzCore.framework */,
1058C7A1FEA54F0111CA2CBB /* Cocoa.framework */,
);
Expand Down Expand Up @@ -226,8 +231,7 @@
29B97314FDCFA39411CA2CEA /* DeskNotation */ = {
isa = PBXGroup;
children = (
948E374316DC698B00138A68 /* ScriptingBridge.framework */,
9466B59616C187C9009ECA41 /* ServiceManagement.framework */,
8D1107310486CEB800E47090 /* Info.plist */,
9466B59516C1843C009ECA41 /* DeskLabels.entitlements */,
080E96DDFE201D6D7F000001 /* Classes */,
29B97315FDCFA39411CA2CEA /* Other Sources */,
Expand All @@ -251,7 +255,6 @@
29B97317FDCFA39411CA2CEA /* Resources */ = {
isa = PBXGroup;
children = (
8D1107310486CEB800E47090 /* Info.plist */,
94751FD60FFC65CE0049E92E /* Credits.rtfd */,
94751B1D0FFB02C70049E92E /* Graphics */,
94751D040FFBD6D90049E92E /* XIBs */,
Expand Down Expand Up @@ -363,6 +366,8 @@
948E374816DC710300138A68 /* SDArrangeDesktopWindow.m */,
94A7B3C616E1794800B70A70 /* SDResizeJunkView.h */,
94A7B3C716E1794800B70A70 /* SDResizeJunkView.m */,
94893CF816F29C9E00B86AE4 /* SDMoveAroundView.h */,
94893CF916F29C9E00B86AE4 /* SDMoveAroundView.m */,
);
name = View;
sourceTree = "<group>";
Expand Down Expand Up @@ -496,6 +501,7 @@
948E374916DC710300138A68 /* SDArrangeDesktopWindow.m in Sources */,
948E374C16DC719500138A68 /* SDArrangeDesktopWindowController.m in Sources */,
94A7B3C816E1794800B70A70 /* SDResizeJunkView.m in Sources */,
94893CFA16F29C9E00B86AE4 /* SDMoveAroundView.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down
2 changes: 2 additions & 0 deletions DeskLabels/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,7 @@
<string>MainMenu</string>
<key>NSPrincipalClass</key>
<string>NSApplication</string>
<key>LSUIElement</key>
<true/>
</dict>
</plist>
48 changes: 24 additions & 24 deletions DeskLabels/SDArrangeDesktopWindowController.m
Original file line number Diff line number Diff line change
Expand Up @@ -17,35 +17,35 @@ - (NSString*) windowNibName {
- (void)windowDidLoad {
[super windowDidLoad];

NSMutableArray* apps = [NSMutableArray array];

for (NSRunningApplication* app in [[NSWorkspace sharedWorkspace] runningApplications]) {
if (app.hidden == NO) {
[apps addObject:app];
// [app hide];
}
}

self.apps = apps;

[NSMenu setMenuBarVisible:NO];

[[NSWorkspace sharedWorkspace] hideOtherApplications];

[self performSelector:@selector(finishTheJob) withObject:nil afterDelay:0];
// NSMutableArray* apps = [NSMutableArray array];
//
// for (NSRunningApplication* app in [[NSWorkspace sharedWorkspace] runningApplications]) {
// if (app.hidden == NO) {
// [apps addObject:app];
// // [app hide];
// }
// }
//
// self.apps = apps;
//
// [NSMenu setMenuBarVisible:NO];
//
// [[NSWorkspace sharedWorkspace] hideOtherApplications];
//
// [self performSelector:@selector(finishTheJob) withObject:nil afterDelay:0];
}

- (void) finishTheJob {
[NSApp activateIgnoringOtherApps:YES];
}
//- (void) finishTheJob {
// [NSApp activateIgnoringOtherApps:YES];
//}

- (IBAction) doneArrangingDesktop:(id)sender {
[self close];
[NSMenu setMenuBarVisible:YES];

for (NSRunningApplication* app in self.apps) {
[app unhide];
}
// [NSMenu setMenuBarVisible:YES];
//
// for (NSRunningApplication* app in self.apps) {
// [app unhide];
// }
}

@end
13 changes: 13 additions & 0 deletions DeskLabels/SDMoveAroundView.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//
// SDMoveAroundView.h
// DeskLabels
//
// Created by Steven Degutis on 3/14/13.
//
//

#import <Cocoa/Cocoa.h>

@interface SDMoveAroundView : NSView

@end
33 changes: 33 additions & 0 deletions DeskLabels/SDMoveAroundView.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
//
// SDMoveAroundView.m
// DeskLabels
//
// Created by Steven Degutis on 3/14/13.
//
//

#import "SDMoveAroundView.h"

@implementation SDMoveAroundView

//- (id)initWithFrame:(NSRect)frame
//{
// self = [super initWithFrame:frame];
// if (self) {
// // Initialization code here.
// }
//
// return self;
//}

- (void)drawRect:(NSRect)dirtyRect {
NSRect box = [self bounds];

[[[NSColor whiteColor] colorWithAlphaComponent:0.1] setFill];
[NSBezierPath fillRect:box];

[[[NSColor blackColor] colorWithAlphaComponent:0.4] setFill];
[NSBezierPath strokeRect:box];
}

@end
73 changes: 69 additions & 4 deletions DeskLabels/SDResizeJunkView.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,16 @@

#import "SDResizeJunkView.h"


#import "SDMoveAroundView.h"

@interface SDResizeJunkView ()

@property NSPoint initialPoint;
@property NSPoint currentPoint;

@end

@implementation SDResizeJunkView

- (void) awakeFromNib {
Expand All @@ -17,13 +27,68 @@ - (void) awakeFromNib {
[self setFillColor:[[NSColor blackColor] colorWithAlphaComponent:0.25]];
}

//- (void) drawRect:(NSRect)dirtyRect {
// [[NSColor blackColor] setFill];
// [NSBezierPath fillRect:dirtyRect];
//}
- (NSRect) currentIconsBoxRect {
CGFloat x = MIN(self.initialPoint.x, self.currentPoint.x);
CGFloat y = MIN(self.initialPoint.y, self.currentPoint.y);

CGFloat width = abs(self.initialPoint.x - self.currentPoint.x);
CGFloat height = abs(self.initialPoint.y - self.currentPoint.y);

NSRect box = NSMakeRect(x, y, width, height);
box = NSIntegralRect(box);
box = NSInsetRect(box, 0.5, 0.5);
return box;
}

- (void) drawRect:(NSRect)dirtyRect {
[super drawRect:dirtyRect];

if (NSEqualPoints(self.initialPoint, NSZeroPoint))
return;

NSRect box = [self currentIconsBoxRect];

[[[NSColor whiteColor] colorWithAlphaComponent:0.1] setFill];
[NSBezierPath fillRect:box];

[[[NSColor blackColor] colorWithAlphaComponent:0.4] setFill];
[NSBezierPath strokeRect:box];
}

- (void) resetCursorRects {
[self addCursorRect:[self visibleRect] cursor:[NSCursor crosshairCursor]];
}

- (void) mouseDown:(NSEvent *)theEvent {
NSPoint p = [self convertPoint:[theEvent locationInWindow] fromView:nil];
self.initialPoint = NSMakePoint(round(p.x), round(p.y));

NSLog(@"mouse down");
}

- (void) mouseDragged:(NSEvent *)theEvent {
self.currentPoint = [self convertPoint:[theEvent locationInWindow] fromView:nil];

[self setNeedsDisplay:YES];

NSLog(@"mouse dragged");
}

- (void) mouseUp:(NSEvent *)theEvent {
NSRect box = [self currentIconsBoxRect];

box.origin.x -= 6.0;
box.origin.y -= 6.0;

SDMoveAroundView* moveAroundView = [[SDMoveAroundView alloc] initWithFrame:box];
[self addSubview:moveAroundView];

self.initialPoint = NSZeroPoint;
self.currentPoint = NSZeroPoint;

[self setNeedsDisplay:YES];

NSLog(@"mouse up");
}

@end

0 comments on commit d419bdd

Please sign in to comment.