Sha256: 0b73508fa2a6e19fd950430f74471057bd67e9b828e2c3d0a1f64cad22db1878
Contents?: true
Size: 1.88 KB
Versions: 2
Compression:
Stored size: 1.88 KB
Contents
module Joybox module Configuration class GLView < CCGLView attr_accessor :resize_to_superview def self.defaults { bounds: [[0, 0], [0, 0]], auto_resize_mask: NSViewHeightSizable | NSViewWidthSizable } end def self.new(options) bounds_provided = options.include?(:bounds) options = options.nil? ? defaults : defaults.merge!(options) bounds = options[:bounds] if bounds.class == Hash bounds = [[bounds[:x], bounds[:y]], [bounds[:width], bounds[:height]]] end opengl_view = alloc.initWithFrame(bounds) opengl_view.setAutoresizingMask(options[:auto_resize_mask]) opengl_view.resize_to_superview = !bounds_provided opengl_view end def initWithFrame(frame) if super tracking_options = NSTrackingMouseEnteredAndExited | NSTrackingActiveAlways | NSTrackingInVisibleRect tracking_area = NSTrackingArea.alloc.initWithRect(self.bounds, options: tracking_options, owner: self, userInfo: nil) addTrackingArea(tracking_area) end self end # This method will be called when we insert the view in the content view # of the window. # Setting the frame of the superview will make posible to don't require # the bounds on the setup. # Notes: # => In the case the user provides the bounds in the setup, it will honor # it. def viewDidMoveToSuperview if @resize_to_superview self.frame = superview.bounds unless superview.nil? Joybox.director.originalWinSize = self.frame.size @resize_to_superview = false end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
joybox-1.1.1 | motion/joybox-osx/configuration/gl_view.rb |
joybox-1.1.0 | motion/joybox-osx/configuration/gl_view.rb |