Sha256: 8aaa55a41448fade6e26d839df50d831c0668919d4d12bc3edcfaeda6ed8e6ae

Contents?: true

Size: 809 Bytes

Versions: 3

Compression:

Stored size: 809 Bytes

Contents

# @requires MotionKit::NSViewLayout
module MotionKit
  class NSViewLayout

    def constraints(add_to_view=nil, &block)
      add_to_view ||= target
      if add_to_view.is_a?(Symbol)
        add_to_view = self.get_view(add_to_view)
      end
      add_to_view.setTranslatesAutoresizingMaskIntoConstraints(false)

      constraints_target = ConstraintsTarget.new(add_to_view)
      deferred(constraints_target) do
        context(constraints_target, &block)
        constraints_target.apply_all_constraints(self, add_to_view)
      end
    end

  end

  class Layout

    def constraints(add_to_view=nil, &block)
      if has_context?
        apply(:constraints, add_to_view, &block)
      else
        context(self.view) do
          constraints(add_to_view, &block)
        end
      end
    end

  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

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