motion-kit 0.11.2 → 0.12.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (36) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +15 -12
  3. data/lib/motion-kit-cocoa/constraints/{constraints_layout.rb → constraints_helpers.rb} +2 -2
  4. data/lib/motion-kit-cocoa/layouts/{cagradientlayer_layout.rb → cagradientlayer_helpers.rb} +3 -3
  5. data/lib/motion-kit-cocoa/layouts/{calayer_layout.rb → calayer_helpers.rb} +2 -2
  6. data/lib/motion-kit-cocoa/layouts/sugarcube_compat.rb +1 -1
  7. data/lib/motion-kit-ios/deprecated.rb +31 -0
  8. data/lib/motion-kit-ios/layouts/{constraints_layout.rb → constraints_helpers.rb} +2 -2
  9. data/lib/motion-kit-ios/layouts/{uibutton_layout.rb → uibutton_helpers.rb} +3 -3
  10. data/lib/motion-kit-ios/layouts/{uiview_layout.rb → uiview_helpers.rb} +2 -2
  11. data/lib/motion-kit-ios/layouts/uiview_layout_autoresizing.rb +2 -2
  12. data/lib/motion-kit-ios/layouts/uiview_layout_constraints.rb +2 -2
  13. data/lib/motion-kit-ios/layouts/uiview_layout_frame.rb +2 -2
  14. data/lib/motion-kit-ios/layouts/uiview_layout_gradient.rb +2 -2
  15. data/lib/motion-kit-osx/deprecated.rb +52 -0
  16. data/lib/motion-kit-osx/layouts/{constraints_layout.rb → constraints_helpers.rb} +2 -2
  17. data/lib/motion-kit-osx/layouts/nsmenu_extensions.rb +2 -2
  18. data/lib/motion-kit-osx/layouts/{nsmenu_layout.rb → nsmenu_helpers.rb} +2 -2
  19. data/lib/motion-kit-osx/layouts/nsmenuitem_extensions.rb +2 -2
  20. data/lib/motion-kit-osx/layouts/{nstablecolumn_layout.rb → nstablecolumn_helpers.rb} +2 -2
  21. data/lib/motion-kit-osx/layouts/{nstableview_layout.rb → nstableview_helpers.rb} +3 -3
  22. data/lib/motion-kit-osx/layouts/{nsview_layout.rb → nsview_helpers.rb} +2 -2
  23. data/lib/motion-kit-osx/layouts/nsview_layout_autoresizing.rb +2 -2
  24. data/lib/motion-kit-osx/layouts/nsview_layout_constraints.rb +2 -2
  25. data/lib/motion-kit-osx/layouts/nsview_layout_frame.rb +2 -2
  26. data/lib/motion-kit-osx/layouts/nswindow_frame.rb +2 -2
  27. data/lib/motion-kit-osx/layouts/{nswindow_layout.rb → nswindow_helpers.rb} +2 -2
  28. data/lib/motion-kit/layouts/base_layout.rb +1 -1
  29. data/lib/motion-kit/version.rb +1 -1
  30. data/spec/ios/layer_layout_spec.rb +3 -3
  31. data/spec/ios/layout_extensions_spec.rb +1 -1
  32. data/spec/osx/constraints_helpers/simple_constraints_spec.rb +166 -159
  33. data/spec/osx/menu_extensions_spec.rb +2 -2
  34. data/spec/osx/{constraints_helpers/table_view_spec.rb → table_view_spec.rb} +1 -1
  35. metadata +17 -17
  36. data/spec/osx/constraints_helper_spec.rb +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 178a4a8d53c639db16f7d73765521a9ee5b220b5
4
- data.tar.gz: bd48860c5baff3f5ee0543c28426b6c2d63e09f5
3
+ metadata.gz: 1027d089bb3ce6aafe9f4f55d152a6e3c22a4511
4
+ data.tar.gz: 7e6b2b1bca51e2d3e0aae3d71a2adb76cf31c768
5
5
  SHA512:
6
- metadata.gz: b8b0dd1b76e3875e5aa86dddf9d2e56862b3f5954e7ef33413ad430750a0b3a0565e56355597c9428ac5d322d17c593c48d009a157a6adff10ec1c01567a3706
7
- data.tar.gz: 368ac319ec7994a9a7623ea6c4149c61372f9f087041cc77b6f4b2830f1d1a1d176b467e59fe7bef026c393fddc51ad064b53b18865a4ef6b907b670f991ba0e
6
+ metadata.gz: f45d382fbffb1edea0cf1f4f53ca14344d997de32441319a4978d428fecf5721fe32f51e67c37437e28f335b932ab3ee3747059e6c269ec1f96df15f5bf032c2
7
+ data.tar.gz: 02332a86a6625fa6175423524e4bc94865a34c2d7da9a39318699edd144dea3e54893276c38331680e736ba64c67280a68284aa4852fdb31baaf99f2f8edf3b5
data/README.md CHANGED
@@ -354,7 +354,7 @@ that take multiple arguments. Those can get "helper" methods.
354
354
  # title on a UIButton
355
355
  def login_button_style
356
356
  title 'Press me'
357
- # this gets delegated to UIButtonLayout#title(title), which in turn calls
357
+ # this gets delegated to UIButtonHelpers#title(title), which in turn calls
358
358
  # button.setTitle(title, forState: UIControlStateNormal)
359
359
  end
360
360
  ```
@@ -383,15 +383,18 @@ Introspection and method_missing add a little overhead to your code, but in our
383
383
  benchmarking it is insignificant and undetectable. Let us know if you find any
384
384
  performance issues.
385
385
 
386
- You can easily add your own helpers to MotionKit's existing Layout classes. They
387
- are all named consistenly, e.g. `MotionKit::UIViewLayout`, e.g.
388
- `MotionKit::UILabelLayout`. Just open up these classes and hack away.
386
+ You can easily add your own helpers to MotionKit. They
387
+ are all named consistenly, e.g. `MotionKit::UIViewHelpers`, e.g.
388
+ `MotionKit::UILabelHelpers`. You just need to specify the "target class" that
389
+ your helper class is meant to work with. Each class can only have *one helper
390
+ class*.
389
391
 
390
392
  ```ruby
391
393
  module MotionKit
392
394
  # these helpers will only be applied to instances of UILabel and UILabel
393
395
  # subclasses
394
- class UILabelLayout
396
+ class UILabelHelpers < UIViewHelpers
397
+ targets UILabel
395
398
 
396
399
  # style methods can accept any number of arguments, and a block. The current
397
400
  # view should be referred to via the method `target`
@@ -426,19 +429,19 @@ end
426
429
 
427
430
  For your own custom classes, or when you want to write
428
431
  helper methods for a built-in class, you will need to write a class that
429
- "`targets`" that class. This will be a subclass of `MK::UIViewLayout`; it looks
432
+ "`targets`" that class. This will be a subclass of `MK::UIViewHelpers`; it looks
430
433
  and *feels* like a `MK::Layout` subclass, but these classes are used to extend
431
434
  the MotionKit DSL, and should not be instantiated or used to build layouts.
432
435
 
433
436
  Again, to be clear: you should be subclassing `MK::Layout` when you build your
434
- controller layouts, and you should write a subclass of `MK::UIViewLayout` *only*
437
+ controller layouts, and you should write a subclass of `MK::UIViewHelpers` *only*
435
438
  when you are adding extensions to the MotionKit DSL.
436
439
 
437
440
  ```ruby
438
- # Be sure to extend an existing Layout class, otherwise you'll lose a lot of
439
- # functionality. Often this will be `MK::UIViewLayout` on iOS and
440
- # `MK::NSViewLayout` on OS X.
441
- class CustomLayout < MK::UIViewLayout
441
+ # Be sure to extend an existing Helpers class, otherwise you'll lose a lot of
442
+ # functionality. Often this will be `MK::UIViewHelpers` on iOS and
443
+ # `MK::NSViewHelpers` on OS X.
444
+ class CustomViewHelpers < MK::UIViewHelpers
442
445
  targets CustomView
443
446
 
444
447
  def fore_color(value)
@@ -707,7 +710,7 @@ view, you need to use a separate method that is called after the view hierarchy
707
710
  is created.
708
711
 
709
712
  ```ruby
710
- class MainLayout < UIViewLayout
713
+ class MainLayout < MK::Layout
711
714
 
712
715
  def layout
713
716
  add UILabel, :label do
@@ -1,8 +1,8 @@
1
- # @provides MotionKit::ConstraintsLayout
1
+ # @provides MotionKit::ConstraintsHelpers
2
2
  # @requires MotionKit::BaseLayout
3
3
  # @requires MotionKit::ConstraintsTarget
4
4
  module MotionKit
5
- class ConstraintsLayout < BaseLayout
5
+ class ConstraintsHelpers < BaseLayout
6
6
  targets ConstraintsTarget
7
7
 
8
8
  # A more sensible name for the constraint that is created.
@@ -1,8 +1,8 @@
1
- # @provides MotionKit::CAGradientLayerLayout
2
- # @requires MotionKit::CALayerLayout
1
+ # @provides MotionKit::CAGradientLayerHelpers
2
+ # @requires MotionKit::CALayerHelpers
3
3
  # @requires MotionKit::TreeLayout
4
4
  module MotionKit
5
- class CAGradientLayerLayout < CALayerLayout
5
+ class CAGradientLayerHelpers < CALayerHelpers
6
6
  targets CAGradientLayer
7
7
 
8
8
  def colors(values)
@@ -1,7 +1,7 @@
1
- # @provides MotionKit::CALayerLayout
1
+ # @provides MotionKit::CALayerHelpers
2
2
  # @requires MotionKit::TreeLayout
3
3
  module MotionKit
4
- class CALayerLayout < TreeLayout
4
+ class CALayerHelpers < TreeLayout
5
5
  targets CALayer
6
6
 
7
7
  # platform specific default root view
@@ -1,5 +1,5 @@
1
1
  # These methods are defined in SugarCube's REPL helpers, but we want them to be
2
- # delegated to either `UIViewLayout#frame` or `CALayer#setFrame`
2
+ # delegated to either `UIViewHelpers#frame` or `CALayer#setFrame`
3
3
  #
4
4
  # @requires MotionKit::BaseLayout
5
5
  module MotionKit
@@ -0,0 +1,31 @@
1
+ # @requires MotionKit::UIViewHelpers
2
+ # @requires MotionKit::UIButtonHelpers
3
+ # @requires MotionKit::CALayerHelpers
4
+ # @requires MotionKit::CAGradientLayerHelpers
5
+ module MotionKit
6
+
7
+ class UIViewLayout < UIViewHelpers
8
+ def self.inherited(subclass)
9
+ NSLog("Sorry! MotionKit changed. UIViewLayout is now UIViewHelpers. Update #{subclass} to extend from UIViewHelpers.")
10
+ end
11
+ end
12
+
13
+ class UIButtonLayout < UIButtonHelpers
14
+ def self.inherited(subclass)
15
+ NSLog("Sorry! MotionKit changed. UIButtonLayout is now UIButtonHelpers. Update #{subclass} to extend from UIButtonHelpers.")
16
+ end
17
+ end
18
+
19
+ class CALayerLayout < CALayerHelpers
20
+ def self.inherited(subclass)
21
+ NSLog("Sorry! MotionKit changed. CALayerLayout is now CALayerHelpers. Update #{subclass} to extend from CALayerHelpers.")
22
+ end
23
+ end
24
+
25
+ class CAGradientLayerLayout < CAGradientLayerHelpers
26
+ def self.inherited(subclass)
27
+ NSLog("Sorry! MotionKit changed. CAGradientLayerLayout is now CAGradientLayerHelpers. Update #{subclass} to extend from CAGradientLayerHelpers.")
28
+ end
29
+ end
30
+
31
+ end
@@ -1,6 +1,6 @@
1
- # @requires MotionKit::UIViewLayout
1
+ # @requires MotionKit::UIViewHelpers
2
2
  module MotionKit
3
- class UIViewLayout
3
+ class UIViewHelpers
4
4
 
5
5
  def content_compression_resistance_priority(value, for_axis: axis)
6
6
  axis = Constraint.axis_lookup(axis)
@@ -1,7 +1,7 @@
1
- # @provides MotionKit::UIButtonLayout
2
- # @requires MotionKit::UIViewLayout
1
+ # @provides MotionKit::UIButtonHelpers
2
+ # @requires MotionKit::UIViewHelpers
3
3
  module MotionKit
4
- class UIButtonLayout < UIViewLayout
4
+ class UIButtonHelpers < UIViewHelpers
5
5
  targets UIButton
6
6
 
7
7
  def title(value)
@@ -1,5 +1,5 @@
1
1
  # @provides MotionKit::Layout
2
- # @provides MotionKit::UIViewLayout
2
+ # @provides MotionKit::UIViewHelpers
3
3
  # @requires MotionKit::TreeLayout
4
4
  module MotionKit
5
5
  class Layout < TreeLayout
@@ -21,7 +21,7 @@ module MotionKit
21
21
 
22
22
  end
23
23
 
24
- class UIViewLayout < Layout
24
+ class UIViewHelpers < Layout
25
25
  targets UIView
26
26
  end
27
27
 
@@ -1,6 +1,6 @@
1
- # @requires MotionKit::UIViewLayout
1
+ # @requires MotionKit::UIViewHelpers
2
2
  module MotionKit
3
- class UIViewLayout
3
+ class UIViewHelpers
4
4
 
5
5
  def autoresizing_mask(*values)
6
6
  value = 0
@@ -1,6 +1,6 @@
1
- # @requires MotionKit::UIViewLayout
1
+ # @requires MotionKit::UIViewHelpers
2
2
  module MotionKit
3
- class UIViewLayout
3
+ class UIViewHelpers
4
4
 
5
5
  def constraints(add_to_view=nil, &block)
6
6
  add_to_view ||= target
@@ -1,6 +1,6 @@
1
- # @requires MotionKit::UIViewLayout
1
+ # @requires MotionKit::UIViewHelpers
2
2
  module MotionKit
3
- class UIViewLayout
3
+ class UIViewHelpers
4
4
 
5
5
  def x(value)
6
6
  f = target.frame
@@ -1,6 +1,6 @@
1
- # @requires MotionKit::UIViewLayout
1
+ # @requires MotionKit::UIViewHelpers
2
2
  module MotionKit
3
- class UIViewLayout
3
+ class UIViewHelpers
4
4
 
5
5
  # gradient colors:
6
6
  def gradient(&block)
@@ -0,0 +1,52 @@
1
+ # @requires MotionKit::NSWindowHelpers
2
+ # @requires MotionKit::NSViewHelpers
3
+ # @requires MotionKit::NSTableViewHelpers
4
+ # @requires MotionKit::NSTableColumnHelpers
5
+ # @requires MotionKit::NSMenuHelpers
6
+ # @requires MotionKit::CALayerHelpers
7
+ # @requires MotionKit::CAGradientLayerHelpers
8
+ module MotionKit
9
+
10
+ class NSWindowLayout < NSWindowHelpers
11
+ def self.inherited(subclass)
12
+ NSLog("Sorry! MotionKit changed. NSWindowLayout is now NSWindowHelpers. Update #{subclass} to extend from NSWindowHelpers.")
13
+ end
14
+ end
15
+
16
+ class NSViewLayout < NSViewHelpers
17
+ def self.inherited(subclass)
18
+ NSLog("Sorry! MotionKit changed. NSViewLayout is now NSViewHelpers. Update #{subclass} to extend from NSViewHelpers.")
19
+ end
20
+ end
21
+
22
+ class NSTableViewLayout < NSTableViewHelpers
23
+ def self.inherited(subclass)
24
+ NSLog("Sorry! MotionKit changed. NSTableViewLayout is now NSTableViewHelpers. Update #{subclass} to extend from NSTableViewHelpers.")
25
+ end
26
+ end
27
+
28
+ class NSTableColumnLayout < NSTableColumnHelpers
29
+ def self.inherited(subclass)
30
+ NSLog("Sorry! MotionKit changed. NSTableColumnLayout is now NSTableColumnHelpers. Update #{subclass} to extend from NSTableColumnHelpers.")
31
+ end
32
+ end
33
+
34
+ class NSMenuLayout < NSMenuHelpers
35
+ def self.inherited(subclass)
36
+ NSLog("Sorry! MotionKit changed. NSMenuLayout is now NSMenuHelpers. Update #{subclass} to extend from NSMenuHelpers.")
37
+ end
38
+ end
39
+
40
+ class CALayerLayout < CALayerHelpers
41
+ def self.inherited(subclass)
42
+ NSLog("Sorry! MotionKit changed. CALayerLayout is now CALayerHelpers. Update #{subclass} to extend from CALayerHelpers.")
43
+ end
44
+ end
45
+
46
+ class CAGradientLayerLayout < CAGradientLayerHelpers
47
+ def self.inherited(subclass)
48
+ NSLog("Sorry! MotionKit changed. CAGradientLayerLayout is now CAGradientLayerHelpers. Update #{subclass} to extend from CAGradientLayerHelpers.")
49
+ end
50
+ end
51
+
52
+ end
@@ -1,6 +1,6 @@
1
- # @requires MotionKit::NSViewLayout
1
+ # @requires MotionKit::NSViewHelpers
2
2
  module MotionKit
3
- class NSViewLayout
3
+ class NSViewHelpers
4
4
 
5
5
  def content_compression_resistance_priority(value, for_orientation: orientation)
6
6
  orientation = Constraint.orientation_lookup(orientation)
@@ -1,6 +1,6 @@
1
- # @requires MotionKit::NSMenuLayout
1
+ # @requires MotionKit::NSMenuHelpers
2
2
  module MotionKit
3
- class NSMenuLayout
3
+ class NSMenuHelpers
4
4
 
5
5
  # useful when writing menus
6
6
  def app_name
@@ -1,5 +1,5 @@
1
1
  # @provides MotionKit::MenuLayout
2
- # @provides MotionKit::NSMenuLayout
2
+ # @provides MotionKit::NSMenuHelpers
3
3
  # @requires MotionKit::TreeLayout
4
4
  module MotionKit
5
5
  class MenuLayout < TreeLayout
@@ -103,7 +103,7 @@ module MotionKit
103
103
 
104
104
  end
105
105
 
106
- class NSMenuLayout < MenuLayout
106
+ class NSMenuHelpers < MenuLayout
107
107
  targets NSMenu
108
108
  end
109
109
  end
@@ -1,6 +1,6 @@
1
- # @requires MotionKit::NSMenuLayout
1
+ # @requires MotionKit::NSMenuHelpers
2
2
  module MotionKit
3
- class NSMenuLayout
3
+ class NSMenuHelpers
4
4
 
5
5
  ##|
6
6
  ##| These methods are meant to be called on the parent menu item, but
@@ -1,7 +1,7 @@
1
- # @provides MotionKit::NSTableColumnLayout
1
+ # @provides MotionKit::NSTableColumnHelpers
2
2
  # @requires MotionKit::BaseLayout
3
3
  module MotionKit
4
- class NSTableColumnLayout < BaseLayout
4
+ class NSTableColumnHelpers < BaseLayout
5
5
  targets NSTableColumn
6
6
 
7
7
  def title(value)
@@ -1,7 +1,7 @@
1
- # @provides MotionKit::NSTableViewLayout
2
- # @requires MotionKit::NSViewLayout
1
+ # @provides MotionKit::NSTableViewHelpers
2
+ # @requires MotionKit::NSViewHelpers
3
3
  module MotionKit
4
- class NSTableViewLayout < NSViewLayout
4
+ class NSTableViewHelpers < NSViewHelpers
5
5
  targets NSTableView
6
6
 
7
7
  def add_column(column_or_identifier, &block)
@@ -1,5 +1,5 @@
1
1
  # @provides MotionKit::Layout
2
- # @provides MotionKit::NSViewLayout
2
+ # @provides MotionKit::NSViewHelpers
3
3
  # @requires MotionKit::TreeLayout
4
4
  module MotionKit
5
5
  class Layout < TreeLayout
@@ -21,7 +21,7 @@ module MotionKit
21
21
 
22
22
  end
23
23
 
24
- class NSViewLayout < Layout
24
+ class NSViewHelpers < Layout
25
25
  targets NSView
26
26
  end
27
27
 
@@ -1,6 +1,6 @@
1
- # @requires MotionKit::NSViewLayout
1
+ # @requires MotionKit::NSViewHelpers
2
2
  module MotionKit
3
- class NSViewLayout
3
+ class NSViewHelpers
4
4
 
5
5
  def autoresizing_mask(*values)
6
6
  value = 0
@@ -1,6 +1,6 @@
1
- # @requires MotionKit::NSViewLayout
1
+ # @requires MotionKit::NSViewHelpers
2
2
  module MotionKit
3
- class NSViewLayout
3
+ class NSViewHelpers
4
4
 
5
5
  def constraints(add_to_view=nil, &block)
6
6
  add_to_view ||= target
@@ -1,6 +1,6 @@
1
- # @requires MotionKit::NSViewLayout
1
+ # @requires MotionKit::NSViewHelpers
2
2
  module MotionKit
3
- class NSViewLayout
3
+ class NSViewHelpers
4
4
 
5
5
  def _fix_frame_value(value)
6
6
  if value.is_a?(Hash) && value[:relative]
@@ -1,6 +1,6 @@
1
- # @requires MotionKit::NSWindowLayout
1
+ # @requires MotionKit::NSWindowHelpers
2
2
  module MotionKit
3
- class NSWindowLayout
3
+ class NSWindowHelpers
4
4
 
5
5
  def frame(value, autosave_name=nil)
6
6
  retval = target.setFrame(value, display: true)
@@ -1,5 +1,5 @@
1
1
  # @provides MotionKit::WindowLayout
2
- # @provides MotionKit::NSWindowLayout
2
+ # @provides MotionKit::NSWindowHelpers
3
3
  # @requires MotionKit::TreeLayout
4
4
  module MotionKit
5
5
  class WindowLayout < TreeLayout
@@ -29,7 +29,7 @@ module MotionKit
29
29
 
30
30
  end
31
31
 
32
- class NSWindowLayout < WindowLayout
32
+ class NSWindowHelpers < WindowLayout
33
33
  targets NSWindow
34
34
  end
35
35
 
@@ -84,7 +84,7 @@ module MotionKit
84
84
  # # passing a block to a method that returns an object. That object becomes
85
85
  # # the new context.
86
86
  # layer do
87
- # # self is now a CALayerLayout instance
87
+ # # target is now a CALayer, and methods are delegated to CALayerHelpers
88
88
  # corner_radius 5
89
89
  # end
90
90
  # end