Sha256: 916c051a9ef3834b419c2d5b8afcee3f5fa90c836c3583ec8f9682e956bfc817

Contents?: true

Size: 944 Bytes

Versions: 3

Compression:

Stored size: 944 Bytes

Contents

# @provides MotionKit::WindowLayout
# @provides MotionKit::NSWindowLayout
# @requires MotionKit::TreeLayout
module MotionKit
  class WindowLayout < TreeLayout

    # A more sensible name for the window that is created.
    def window
      self.view
    end

    # platform specific default root view
    def default_root
      # child WindowLayout classes can return *their* NSView subclass from self.nsview_class
      view_class = self.class.targets || NSWindow
      view_class.alloc.initWithContentRect([[0, 0], [0, 0]],
        styleMask: NSTitledWindowMask | NSClosableWindowMask | NSMiniaturizableWindowMask | NSResizableWindowMask,
        backing: NSBackingStoreBuffered,
        defer: false)
    end

    def add_child(subview)
      target.contentView.addSubview(subview)
    end

    def remove_child(subview)
      subview.removeFromSuperview
    end

  end

  class NSWindowLayout < WindowLayout
    targets NSWindow
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
motion-kit-0.11.2 lib/motion-kit-osx/layouts/nswindow_layout.rb
motion-kit-0.11.1 lib/motion-kit-osx/layouts/nswindow_layout.rb
motion-kit-0.11.0 lib/motion-kit-osx/layouts/nswindow_layout.rb