Class: Motion::Popup::Panel
- Inherits:
-
NSPanel
- Object
- NSPanel
- Motion::Popup::Panel
- Defined in:
- lib/motion/popup/panel.rb
Instance Attribute Summary collapse
-
#arrow ⇒ Object
Returns the value of attribute arrow.
-
#background ⇒ Object
Returns the value of attribute background.
Instance Method Summary collapse
- #canBecomeKeyWindow ⇒ Object
- #initPopup(width, height) ⇒ Object
- #toggle ⇒ Object
- #toggleWithFrame(frame) ⇒ Object
- #windowDidResignKey(sender) ⇒ Object
Instance Attribute Details
#arrow ⇒ Object
Returns the value of attribute arrow.
2 3 4 |
# File 'lib/motion/popup/panel.rb', line 2 def arrow @arrow end |
#background ⇒ Object
Returns the value of attribute background.
2 3 4 |
# File 'lib/motion/popup/panel.rb', line 2 def background @background end |
Instance Method Details
#canBecomeKeyWindow ⇒ Object
42 43 44 |
# File 'lib/motion/popup/panel.rb', line 42 def canBecomeKeyWindow true end |
#initPopup(width, height) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/motion/popup/panel.rb', line 4 def initPopup(width, height) self.initWithContentRect([[0, 0], [width, height]], styleMask: NSBorderlessWindowMask, backing: NSBackingStoreBuffered, defer: false) self.title = NSBundle.mainBundle.infoDictionary['CFBundleName'] self.delegate = self self.setBackgroundColor(NSColor.clearColor) self.setOpaque(false) self.background = Motion::Popup::Background.alloc.initWithFrame(self.frame) self.setContentView(self.background) self.arrow = true self end |
#toggle ⇒ Object
22 23 24 |
# File 'lib/motion/popup/panel.rb', line 22 def toggle self.toggleWithFrame(NSApp.currentEvent.window.frame) end |
#toggleWithFrame(frame) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/motion/popup/panel.rb', line 26 def toggleWithFrame(frame) if self.isVisible self.orderOut(false) else event_frame = frame window_frame = self.frame window_top_left_position = CGPointMake(event_frame.origin.x + (event_frame.size.width / 2) - (window_frame.size.width / 2), event_frame.origin.y) self.setFrameTopLeftPoint(window_top_left_position) self.background.setArrowX(window_frame.size.width / 2) if self.arrow NSApp.activateIgnoringOtherApps(true) self.makeKeyAndOrderFront(self) end end |
#windowDidResignKey(sender) ⇒ Object
46 47 48 |
# File 'lib/motion/popup/panel.rb', line 46 def windowDidResignKey(sender) self.orderOut(false) end |