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 +4 -4
- data/README.md +15 -1
- data/lib/motion/popup/background.rb +11 -5
- data/lib/motion/popup/panel.rb +9 -3
- data/lib/motion/popup/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 349ce4caca5297442f1cc5ac456014bed902d675
|
4
|
+
data.tar.gz: c84ee1a83b3a418bba6c418f62f5f10db592191a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
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
|
-
|
21
|
-
|
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
|
-
|
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
|
-
|
47
|
+
|
42
48
|
path.closePath
|
43
49
|
|
44
50
|
NSColor.whiteColor.setFill
|
data/lib/motion/popup/panel.rb
CHANGED
@@ -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 =
|
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)
|
data/lib/motion/popup/version.rb
CHANGED