motion-popup 1.0 → 1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 956fa4f7b20fe96de2493b8e49229b05c25e171c
4
- data.tar.gz: 8df7870f25b784728a4794c8d60a6db51f742cb6
3
+ metadata.gz: 349ce4caca5297442f1cc5ac456014bed902d675
4
+ data.tar.gz: c84ee1a83b3a418bba6c418f62f5f10db592191a
5
5
  SHA512:
6
- metadata.gz: 61cc869b3b688cb2c3f7e6ea51dd27aa86c51e9331dae9ca713313639308eed8ed1fc214db582b8cbde1e195757ef20f3faaa72329e100f67aecaed5e400a534
7
- data.tar.gz: 1919d1f5bb96c7324fc7ee81312e91ac0fa370f2e115aba0faffaaf7adc436b5867132137c868ea3345344eaa02356dfa953f9fb92bc2e6cf3760470829d0f15
6
+ metadata.gz: 97d15f49142a7c34851d5d03948cfbc3db544078097e0d9d7a2550e35ac775bae0a0fec6ad9796b64153e5af6e58b4efb352cb4175c6256edb465b54ea02b657
7
+ data.tar.gz: 69bb1a03c380fc4c9fdde64f7bc1e00ed854fda9dbbe8ea6c26b4e3f9da3f5fc5ea7e25ff586108f154709942aa17ec639b6a5a0582fe90ce4d53ed99bd1947f
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # motion-popup
2
2
 
3
- Customisable fancy popup window for your Mac OS X status bar apps
3
+ Customisable fancy popup windows for your Mac OS X apps
4
4
 
5
5
  ## Requirements
6
6
 
@@ -60,6 +60,20 @@ For example, you can set the window as the delegate for your status menu item, a
60
60
 
61
61
  This handles updating the windows position to sit under the menu item, with the arrow pointer directly in the middle. The window itself handles hiding itself when it loses focus, and ensuring the toggle then allows it to be reshown when the menu is clicked again.
62
62
 
63
+ For a free floating window, you can specify a frame - for example, for a centered popup window, you can call:
64
+
65
+ ```ruby
66
+ @window.toggleWithFrame(CGRectMake(0, 0, 0, 0))
67
+ @window.center
68
+ ```
69
+
70
+ You can also turn off the arrow on the window when you create it, if it's not needed:
71
+
72
+ ```ruby
73
+ @window = Motion::Popup::Panel.alloc.initPopup(POPUP_WIDTH, POPUP_HEIGHT)
74
+ @window.arrow = false
75
+ ```
76
+
63
77
  ## Contributors
64
78
 
65
79
  * Elliott Draper
@@ -13,12 +13,18 @@ class Motion::Popup::Background < NSView
13
13
  end
14
14
 
15
15
  def drawRect(rect)
16
- return unless @arrow_x
17
16
  content_rect = NSInsetRect(self.bounds, self.line_thickness, self.line_thickness)
18
17
  path = NSBezierPath.bezierPath
19
18
 
20
- path.moveToPoint(NSMakePoint(@arrow_x, NSMaxY(content_rect)))
21
- path.lineToPoint(NSMakePoint(@arrow_x + self.arrow_width / 2, NSMaxY(content_rect) - self.arrow_height))
19
+ top_left_corner = NSMakePoint(NSMinX(content_rect), NSMaxY(content_rect) - self.arrow_height)
20
+
21
+ path.moveToPoint(NSMakePoint(top_left_corner.x + self.corner_radius, top_left_corner.y))
22
+
23
+ if @arrow_x
24
+ path.lineToPoint(NSMakePoint(@arrow_x - self.arrow_width / 2, NSMaxY(content_rect) - self.arrow_height))
25
+ path.lineToPoint(NSMakePoint(@arrow_x, NSMaxY(content_rect)))
26
+ path.lineToPoint(NSMakePoint(@arrow_x + self.arrow_width / 2, NSMaxY(content_rect) - self.arrow_height))
27
+ end
22
28
  path.lineToPoint(NSMakePoint(NSMaxX(content_rect) - self.corner_radius, NSMaxY(content_rect) - self.arrow_height))
23
29
 
24
30
  top_right_corner = NSMakePoint(NSMaxX(content_rect), NSMaxY(content_rect) - self.arrow_height)
@@ -35,10 +41,10 @@ class Motion::Popup::Background < NSView
35
41
 
36
42
  path.lineToPoint(NSMakePoint(NSMinX(content_rect), NSMaxY(content_rect) - self.arrow_height - self.corner_radius))
37
43
 
38
- top_left_corner = NSMakePoint(NSMinX(content_rect), NSMaxY(content_rect) - self.arrow_height)
44
+
39
45
  path.curveToPoint(NSMakePoint(NSMinX(content_rect) + self.corner_radius, NSMaxY(content_rect) - self.arrow_height), controlPoint1: top_left_corner, controlPoint2: top_left_corner)
40
46
 
41
- path.lineToPoint(NSMakePoint(@arrow_x - self.arrow_width / 2, NSMaxY(content_rect) - self.arrow_height))
47
+
42
48
  path.closePath
43
49
 
44
50
  NSColor.whiteColor.setFill
@@ -1,5 +1,5 @@
1
1
  class Motion::Popup::Panel < NSPanel
2
- attr_accessor :background
2
+ attr_accessor :background, :arrow
3
3
 
4
4
  def initPopup(width, height)
5
5
  self.initWithContentRect([[0, 0], [width, height]],
@@ -14,19 +14,25 @@ class Motion::Popup::Panel < NSPanel
14
14
  self.background = Motion::Popup::Background.alloc.initWithFrame(self.frame)
15
15
  self.setContentView(self.background)
16
16
 
17
+ self.arrow = true
18
+
17
19
  self
18
20
  end
19
21
 
20
22
  def toggle
23
+ self.toggleWithFrame(NSApp.currentEvent.window.frame)
24
+ end
25
+
26
+ def toggleWithFrame(frame)
21
27
  if self.isVisible
22
28
  self.orderOut(false)
23
29
  else
24
- event_frame = NSApp.currentEvent.window.frame
30
+ event_frame = frame
25
31
  window_frame = self.frame
26
32
  window_top_left_position = CGPointMake(event_frame.origin.x + (event_frame.size.width / 2) - (window_frame.size.width / 2), event_frame.origin.y)
27
33
  self.setFrameTopLeftPoint(window_top_left_position)
28
34
 
29
- self.background.setArrowX(window_frame.size.width / 2)
35
+ self.background.setArrowX(window_frame.size.width / 2) if self.arrow
30
36
 
31
37
  NSApp.activateIgnoringOtherApps(true)
32
38
  self.makeKeyAndOrderFront(self)
@@ -1,5 +1,5 @@
1
1
  module Motion
2
2
  module Popup
3
- VERSION = 1.0
3
+ VERSION = 1.1
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: motion-popup
3
3
  version: !ruby/object:Gem::Version
4
- version: '1.0'
4
+ version: '1.1'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Elliott Draper