Sha256: ea9f176d839111b908b70735444fed207a43a0483a21a178939ef8dd7a09c97f

Contents?: true

Size: 811 Bytes

Versions: 15

Compression:

Stored size: 811 Bytes

Contents

# @requires MotionKit::NSViewHelpers
module MotionKit
  class NSViewHelpers

    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

15 entries across 15 versions & 1 rubygems

Version Path
motion-kit-1.1.1 lib/motion-kit-osx/helpers/nsview_constraints_helpers.rb
motion-kit-1.1.0 lib/motion-kit-osx/helpers/nsview_constraints_helpers.rb
motion-kit-1.0.3 lib/motion-kit-osx/helpers/nsview_constraints_helpers.rb
motion-kit-1.0.2 lib/motion-kit-osx/helpers/nsview_constraints_helpers.rb
motion-kit-1.0.1 lib/motion-kit-osx/helpers/nsview_constraints_helpers.rb
motion-kit-1.0.0 lib/motion-kit-osx/helpers/nsview_constraints_helpers.rb
motion-kit-0.18.0 lib/motion-kit-osx/helpers/nsview_constraints_helpers.rb
motion-kit-0.17.0 lib/motion-kit-osx/helpers/nsview_constraints_helpers.rb
motion-kit-0.16.0 lib/motion-kit-osx/helpers/nsview_constraints_helpers.rb
motion-kit-0.15.0 lib/motion-kit-osx/helpers/nsview_constraints_helpers.rb
motion-kit-0.14.2 lib/motion-kit-osx/helpers/nsview_constraints_helpers.rb
motion-kit-0.14.1 lib/motion-kit-osx/helpers/nsview_constraints_helpers.rb
motion-kit-0.14.0 lib/motion-kit-osx/helpers/nsview_constraints_helpers.rb
motion-kit-0.13.0 lib/motion-kit-osx/helpers/nsview_constraints_helpers.rb
motion-kit-0.12.0 lib/motion-kit-osx/layouts/nsview_layout_constraints.rb