Sha256: d4add1cf8d832b8345e130ec1e4fc0bb1f398795f536b6b294d9d0ff7c4838ac

Contents?: true

Size: 1.07 KB

Versions: 5

Compression:

Stored size: 1.07 KB

Contents

# @provides MotionKit::Layout
# @provides MotionKit::NSViewLayout
# @requires MotionKit::ViewLayout
module MotionKit
  class Layout < ViewLayout

    # platform specific default root view
    def default_root
      # child Layout classes will return *their* NSView subclass from self.targets
      view_class = self.class.targets || MotionKit.default_view_class
      view_class.alloc.initWithFrame([[0, 0], [0, 0]])
    end

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

    def remove_child(subview)
      subview.removeFromSuperview
    end

    # NSViews AND CALayers are updated
    def reapply!(root=nil)
      if root.is_a?(CALayer)
        @layout_state = :reapply
        MotionKit.find_all_layers(root) do |layer|
          call_style_method(layer, layer.motion_kit_id) if layer.motion_kit_id
        end
        @layout_state = :initial
      else
        root ||= self.view
        if root.layer
          reapply!(root.layer)
        end
        super(root)
      end

      return self
    end

  end

  class NSViewLayout < Layout
    targets NSView
  end

end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
motion-kit-0.9.4 lib/motion-kit-osx/layouts/nsview_layout.rb
motion-kit-0.9.3 lib/motion-kit-osx/layouts/nsview_layout.rb
motion-kit-0.9.2 lib/motion-kit-osx/layouts/nsview_layout.rb
motion-kit-0.9.1 lib/motion-kit-osx/layouts/nsview_layout.rb
motion-kit-0.9.0 lib/motion-kit-osx/layouts/nsview_layout.rb