-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
263 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,3 +17,4 @@ nbproject | |
sparkle/release | ||
sparkle/release/* | ||
sparkle/config/dsa_priv.pem | ||
*.dat* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
GIT | ||
remote: [email protected]:kyan/kyan_jukebox_websocket_lib.git | ||
revision: 93fe1c35e8065ee8710c59648f287b3fdc1963ed | ||
revision: f702e1268351d140d8c7ee7ba6b587ade0cfeaa3 | ||
specs: | ||
kyan_jukebox (0.1.6) | ||
kyan_jukebox (0.1.9) | ||
|
||
GEM | ||
remote: https://rubygems.org/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
class AlbumArtView < NSImageView | ||
|
||
def init | ||
super.tap do |v| | ||
v.setTranslatesAutoresizingMaskIntoConstraints(false) | ||
v.setEditable(false) | ||
v.setImageScaling(NSImageScaleAxesIndependently) | ||
|
||
@vote_view = VoteView.new | ||
v.addSubview(@vote_view) | ||
|
||
@vote_slider_in_progress = false | ||
|
||
slidein_vote_view | ||
end | ||
end | ||
|
||
def slidein_vote_view | ||
return if @vote_slider_in_progress | ||
|
||
new_frame = @vote_view.frame | ||
new_frame.origin.x += VOTE_VIEW_W | ||
|
||
@vote_slider_in_progress = true | ||
NSAnimationContext.beginGrouping | ||
NSAnimationContext.currentContext.setCompletionHandler( | ||
lambda do | ||
timer = NSTimer.scheduledTimerWithTimeInterval( | ||
5.0, | ||
target:self, | ||
selector:'slideout_vote_view', | ||
userInfo:nil, | ||
repeats: false | ||
) | ||
NSRunLoop.mainRunLoop.addTimer(timer, forMode:NSRunLoopCommonModes) | ||
end | ||
) | ||
NSAnimationContext.currentContext.setDuration(0.5) | ||
@vote_view.animator.setFrame(new_frame) | ||
NSAnimationContext.endGrouping | ||
end | ||
|
||
def slideout_vote_view | ||
new_frame = @vote_view.frame | ||
new_frame.origin.x -= VOTE_VIEW_W | ||
|
||
NSAnimationContext.beginGrouping | ||
NSAnimationContext.currentContext.setCompletionHandler( | ||
lambda do | ||
@vote_slider_in_progress = false | ||
end | ||
) | ||
NSAnimationContext.currentContext.setDuration(0.5) | ||
@vote_view.animator.setFrame(new_frame) | ||
NSAnimationContext.endGrouping | ||
end | ||
|
||
def handle_vote(score, rating) | ||
@vote_view.do_vote(score, rating) | ||
slidein_vote_view | ||
end | ||
|
||
def drawRect(dirtyRect) | ||
super dirtyRect | ||
|
||
@vote_view.removeFromSuperview | ||
addSubview(@vote_view, positioned:NSWindowAbove, relativeTo:nil) | ||
end | ||
|
||
def mouseEntered(event) | ||
slidein_vote_view | ||
end | ||
|
||
def updateTrackingAreas | ||
if @trackingArea != nil | ||
removeTrackingArea(@trackingArea) | ||
end | ||
|
||
@trackingArea = NSTrackingArea.alloc.initWithRect( | ||
[[0,frame.size.height-VOTE_VIEW_H],[VOTE_VIEW_W,frame.size.height]], | ||
options:NSTrackingMouseEnteredAndExited | NSTrackingActiveAlways, | ||
owner:self, | ||
userInfo:nil | ||
) | ||
|
||
addTrackingArea(@trackingArea) | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
class VoteView < NSView | ||
|
||
def init | ||
super.tap do |v| | ||
v.frame = [[0-VOTE_VIEW_W,50-VOTE_VIEW_H],[VOTE_VIEW_W,VOTE_VIEW_H]] | ||
|
||
@label = NSTextField.new.tap do |txt| | ||
txt.setEditable(false) | ||
txt.frame = [[3,2],[20,14]] | ||
txt.setSelectable(false) | ||
txt.setBezeled(false) | ||
txt.setDrawsBackground(false) | ||
txt.setAlignment(NSCenterTextAlignment) | ||
end | ||
|
||
v.addSubview(@label) | ||
end | ||
end | ||
|
||
def do_vote(score, rating) | ||
# grey | ||
bg_col = NSColor.colorWithCalibratedRed(0.227, green:0.251, blue:0.337, alpha:0.8) | ||
fg_col = NSColor.whiteColor | ||
|
||
if score.nil? | ||
score = "#" | ||
# lightgrey | ||
bg_col = NSColor.colorWithCalibratedRed(0.7, green:0.7, blue:0.7, alpha:0.8) | ||
fg_col = NSColor.whiteColor | ||
else | ||
# green | ||
if score > 0 | ||
bg_col = NSColor.colorWithCalibratedRed(0, green:0.93, blue:0, alpha:0.8) | ||
fg_col = NSColor.blackColor | ||
end | ||
|
||
# red | ||
if score < 0 | ||
bg_col = NSColor.colorWithCalibratedRed(0.9, green:0.4, blue:0.3, alpha:0.8) | ||
fg_col = NSColor.blackColor | ||
end | ||
end | ||
|
||
txt = score.to_s.attrd({ | ||
'NSFont' => NSFont.fontWithName("Helvetica Bold", size:10), | ||
'NSColor' => fg_col | ||
}) | ||
@label.setAttributedStringValue(txt) | ||
@bg_color = bg_col | ||
end | ||
|
||
def drawRect(dirtyRect) | ||
draw_backing if @bg_color | ||
|
||
super dirtyRect | ||
end | ||
|
||
def draw_backing | ||
radius = 15.0 | ||
|
||
path = NSBezierPath.bezierPath | ||
path.moveToPoint([0,0]) | ||
path.lineToPoint([VOTE_VIEW_W-radius,0]) | ||
path.curveToPoint([VOTE_VIEW_W,0+radius], controlPoint1:[VOTE_VIEW_W,0], controlPoint2:[VOTE_VIEW_W,0]) | ||
path.lineToPoint([VOTE_VIEW_W,VOTE_VIEW_H]) | ||
path.lineToPoint([0,VOTE_VIEW_H]) | ||
path.lineToPoint([0,0]) | ||
@bg_color.setFill | ||
path.fill | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.