public
Fork of Caged/gitnub
Description: A Gitk-like application written in RubyCocoa that looks like it belongs on a Mac. See the wiki for downloads and screenshots.
Homepage: http://alternateidea.com
Clone URL: git://github.com/dustin/gitnub.git
Search Repo:
gitnub / VisualizationView.rb
100644 51 lines (40 sloc) 1.058 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#
# VisualizationView.rb
# GitNub
#
# Created by Justin Palmer on 4/12/08.
# Copyright (c) 2008 Active Reload, LLC. All rights reserved.
#
 
require 'osx/cocoa'
 
class VisualizationView < OSX::NSView
  ib_outlet :application_controller
  
  def initWithFrame(frame)
    super_initWithFrame(frame)
    # Initialization code here.
    return self
  end
  
  def awakeFromNib
    @repo ||= @application_controller.repo
  end
  
  def isFlipped
    true
  end
  
  def drawRect(rect)
    points = []
    context = NSGraphicsContext.currentContext
    NSColor.darkGrayColor.set
    NSRectFill(self.bounds)
    
    path = NSBezierPath.bezierPath
    path.lineWidth = 2
    
    path.moveToPoint([100, 100])
    @repo.commits(:master, 50, 0).each_with_index do |commit, index|
      point = [((index + 1) * 25), 100]
      #path.lineToPoint([25 * index, 100])
      path.appendBezierPathWithOvalInRect(NSMakeRect(point[0] + 75, point[1], 10, 10))
    end
    
    NSColor.blackColor.set
    path.fill
    
    NSColor.whiteColor.set
    path.stroke
  end
 
end