Sha256: 3bc2c35b7d0bf666088f95c0e308889b1a6a368a12c0ee6e502868c426275ef5
Contents?: true
Size: 1.38 KB
Versions: 2
Compression:
Stored size: 1.38 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) unless options.nil? 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 = self.alloc.initWithFrame(bounds) opengl_view.setAutoresizingMask(options[:auto_resize_mask]) opengl_view.resize_to_superview = bounds_provided opengl_view 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 unless @resize_to_superview and superview.nil? self.frame = superview.bounds 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.0.0 | motion/joybox-osx/configuration/gl_view.rb |
joybox-0.0.6 | motion/joybox-osx/configuration/gl_view.rb |