sugarcube 1.7.0 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (265) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +17 -1
  3. data/lib/all/sugarcube/log.rb +57 -0
  4. data/lib/{sugarcube → all/sugarcube}/look_in.rb +1 -6
  5. data/lib/{sugarcube-legacy → all/sugarcube-legacy}/activesupport.rb +1 -4
  6. data/lib/{sugarcube-numbers → all/sugarcube-numbers}/fixnum.rb +3 -3
  7. data/lib/{sugarcube-numbers/nsnumber.rb → all/sugarcube-numbers/numeric.rb} +1 -19
  8. data/lib/{sugarcube-numbers → all/sugarcube-numbers}/time.rb +2 -2
  9. data/lib/{sugarcube-unholy → all/sugarcube-unholy}/ivar.rb +0 -0
  10. data/lib/cocoa/sugarcube/log.rb +8 -0
  11. data/lib/{sugarcube-animations → cocoa/sugarcube-animations}/caanimation.rb +0 -0
  12. data/lib/{sugarcube-animations → cocoa/sugarcube-animations}/calayer.rb +0 -0
  13. data/lib/{sugarcube-anonymous → cocoa/sugarcube-anonymous}/anonymous.rb +0 -0
  14. data/lib/{sugarcube-anonymous → cocoa/sugarcube-anonymous}/anonymous_array.rb +0 -0
  15. data/lib/{sugarcube-attributedstring → cocoa/sugarcube-attributedstring}/nsattributedstring.rb +0 -0
  16. data/lib/{sugarcube-awesome → cocoa/sugarcube-awesome}/awesome_exts.rb +0 -0
  17. data/lib/{sugarcube-uikit → cocoa/sugarcube-cocoakit}/calayer.rb +0 -0
  18. data/lib/cocoa/sugarcube-cocoakit/frameable.rb +50 -0
  19. data/lib/{sugarcube-corelocation → cocoa/sugarcube-corelocation}/core_location.rb +0 -0
  20. data/lib/{sugarcube-files → cocoa/sugarcube-files}/nsarray.rb +0 -0
  21. data/lib/{sugarcube-files → cocoa/sugarcube-files}/nsdata.rb +0 -0
  22. data/lib/{sugarcube-files → cocoa/sugarcube-files}/nsdictionary.rb +0 -0
  23. data/lib/{sugarcube-files → cocoa/sugarcube-files}/nsstring.rb +0 -0
  24. data/lib/cocoa/sugarcube-files/nsstring_deprecated.rb +45 -0
  25. data/lib/{sugarcube-foundation → cocoa/sugarcube-foundation}/nsarray.rb +0 -0
  26. data/lib/{sugarcube-foundation → cocoa/sugarcube-foundation}/nsindexpath.rb +0 -0
  27. data/lib/{sugarcube-foundation → cocoa/sugarcube-foundation}/nsindexset.rb +0 -0
  28. data/lib/{sugarcube-foundation → cocoa/sugarcube-foundation}/nsorderedset.rb +0 -0
  29. data/lib/{sugarcube-foundation → cocoa/sugarcube-foundation}/nsset.rb +1 -0
  30. data/lib/{sugarcube-foundation → cocoa/sugarcube-foundation}/nsstring.rb +0 -0
  31. data/lib/{sugarcube-foundation → cocoa/sugarcube-foundation}/nsurl.rb +0 -0
  32. data/lib/{sugarcube-indexpath → cocoa/sugarcube-indexpath}/indexpath.rb +0 -0
  33. data/lib/{sugarcube-localized → cocoa/sugarcube-localized}/nserror.rb +0 -0
  34. data/lib/{sugarcube-localized → cocoa/sugarcube-localized}/nsstring.rb +0 -0
  35. data/lib/{sugarcube-notifications → cocoa/sugarcube-notifications}/notifications.rb +8 -8
  36. data/lib/{sugarcube-nscoder → cocoa/sugarcube-nscoder}/nscoder.rb +0 -0
  37. data/lib/{sugarcube-nsdata → cocoa/sugarcube-nsdata}/nsdata.rb +0 -9
  38. data/lib/{sugarcube-nsdata → cocoa/sugarcube-nsdata}/nsstring.rb +0 -0
  39. data/lib/{sugarcube-nsdata → cocoa/sugarcube-nsdata}/nsurl.rb +0 -0
  40. data/lib/{sugarcube-nsdate → cocoa/sugarcube-nsdate}/date_parser.rb +0 -0
  41. data/lib/{sugarcube-nsdate → cocoa/sugarcube-nsdate}/fixnum.rb +0 -0
  42. data/lib/{sugarcube-nsdate → cocoa/sugarcube-nsdate}/nsdate.rb +0 -0
  43. data/lib/{sugarcube-nsdate → cocoa/sugarcube-nsdate}/nsdate_delta.rb +0 -0
  44. data/lib/{sugarcube-nsdate → cocoa/sugarcube-nsdate}/nsnumber.rb +0 -0
  45. data/lib/{sugarcube-nsdate → cocoa/sugarcube-nsdate}/nsstring.rb +0 -0
  46. data/lib/{sugarcube-nsuserdefaults → cocoa/sugarcube-nsuserdefaults}/nsuserdefaults.rb +0 -0
  47. data/lib/cocoa/sugarcube-numbers/nsnumber.rb +10 -0
  48. data/lib/{sugarcube-numbers → cocoa/sugarcube-numbers}/nsstring.rb +0 -0
  49. data/lib/{sugarcube-pointer → cocoa/sugarcube-pointer}/nsarray.rb +0 -0
  50. data/lib/cocoa/sugarcube-repl/kernel.rb +161 -0
  51. data/lib/cocoa/sugarcube-repl/repl.rb +330 -0
  52. data/lib/cocoa/sugarcube-spritekit/sknode.rb +11 -0
  53. data/lib/{sugarcube-timer → cocoa/sugarcube-timer}/timer.rb +0 -0
  54. data/lib/{sugarcube-to_s → cocoa/sugarcube-to_s}/nserror.rb +1 -1
  55. data/lib/{sugarcube-to_s → cocoa/sugarcube-to_s}/nsindexpath.rb +0 -0
  56. data/lib/{sugarcube-to_s → cocoa/sugarcube-to_s}/nslayoutconstraint.rb +0 -0
  57. data/lib/{sugarcube-to_s → cocoa/sugarcube-to_s}/nsnotification.rb +1 -1
  58. data/lib/{sugarcube-to_s → cocoa/sugarcube-to_s}/nsset.rb +0 -0
  59. data/lib/{sugarcube-to_s → cocoa/sugarcube-to_s}/nsurl.rb +1 -1
  60. data/lib/{sugarcube → ios/sugarcube}/sugarcube_cleanup.rb +0 -0
  61. data/lib/{sugarcube-568 → ios/sugarcube-568}/uiimage.rb +0 -0
  62. data/lib/{sugarcube-animations → ios/sugarcube-animations}/animation_chain.rb +0 -0
  63. data/lib/{sugarcube-animations → ios/sugarcube-animations}/uiview.rb +3 -10
  64. data/lib/ios/sugarcube-color/fixnum.rb +30 -0
  65. data/lib/{sugarcube-color → ios/sugarcube-color}/nsarray.rb +5 -1
  66. data/lib/{sugarcube-color → ios/sugarcube-color}/nsstring.rb +5 -1
  67. data/lib/{sugarcube-color → ios/sugarcube-color}/symbol.rb +10 -2
  68. data/lib/{sugarcube-color → ios/sugarcube-color}/uicolor.rb +5 -9
  69. data/lib/{sugarcube-color → ios/sugarcube-color}/uiimage.rb +5 -1
  70. data/lib/{sugarcube-constants → ios/sugarcube-constants}/symbol.rb +3 -10
  71. data/lib/{sugarcube-coregraphics → ios/sugarcube-coregraphics}/core_graphics.rb +0 -0
  72. data/lib/{sugarcube-events → ios/sugarcube-events}/uicontrol.rb +0 -0
  73. data/lib/{sugarcube-events → ios/sugarcube-events}/uitextview.rb +0 -0
  74. data/lib/{sugarcube-factories → ios/sugarcube-factories}/nserror.rb +1 -1
  75. data/lib/{sugarcube-factories → ios/sugarcube-factories}/uiactionsheet.rb +0 -0
  76. data/lib/{sugarcube-factories/uiactivityindicator.rb → ios/sugarcube-factories/uiactivityindicatorview.rb} +0 -0
  77. data/lib/{sugarcube-factories → ios/sugarcube-factories}/uialertview.rb +0 -0
  78. data/lib/{sugarcube-factories → ios/sugarcube-factories}/uibarbuttonitem.rb +7 -2
  79. data/lib/{sugarcube-factories → ios/sugarcube-factories}/uibutton.rb +10 -0
  80. data/lib/{sugarcube-factories → ios/sugarcube-factories}/uisegmentedcontrol.rb +0 -0
  81. data/lib/{sugarcube-factories → ios/sugarcube-factories}/uitabbaritem.rb +0 -0
  82. data/lib/{sugarcube-factories → ios/sugarcube-factories}/uitableview.rb +0 -0
  83. data/lib/{sugarcube-factories → ios/sugarcube-factories}/uitableviewcell.rb +0 -0
  84. data/lib/{sugarcube-gestures → ios/sugarcube-gestures}/gestures.rb +0 -0
  85. data/lib/{sugarcube-image → ios/sugarcube-image}/cicolor.rb +0 -0
  86. data/lib/{sugarcube-image → ios/sugarcube-image}/cifilter.rb +0 -0
  87. data/lib/{sugarcube-image → ios/sugarcube-image}/ciimage.rb +0 -0
  88. data/lib/{sugarcube-image → ios/sugarcube-image}/uicolor.rb +0 -0
  89. data/lib/{sugarcube-image → ios/sugarcube-image}/uiimage.rb +0 -0
  90. data/lib/{sugarcube-modal → ios/sugarcube-modal}/modal.rb +2 -1
  91. data/lib/ios/sugarcube-nsdata/nsdata.rb +12 -0
  92. data/lib/{sugarcube-nsdata → ios/sugarcube-nsdata}/uiimage.rb +0 -0
  93. data/lib/ios/sugarcube-numbers/nsnumber.rb +14 -0
  94. data/lib/{sugarcube-pipes → ios/sugarcube-pipes}/pipes.rb +4 -4
  95. data/lib/ios/sugarcube-repl/repl.rb +112 -0
  96. data/lib/ios/sugarcube-spritekit/constants.rb +3 -0
  97. data/lib/{sugarcube-to_s → ios/sugarcube-to_s}/uicolor.rb +0 -0
  98. data/lib/{sugarcube-to_s → ios/sugarcube-to_s}/uievent.rb +14 -14
  99. data/lib/{sugarcube-to_s → ios/sugarcube-to_s}/uilabel.rb +1 -1
  100. data/lib/{sugarcube-to_s → ios/sugarcube-to_s}/uitextfield.rb +1 -1
  101. data/lib/ios/sugarcube-to_s/uitouch.rb +20 -0
  102. data/lib/{sugarcube-to_s → ios/sugarcube-to_s}/uiview.rb +7 -3
  103. data/lib/{sugarcube-to_s → ios/sugarcube-to_s}/uiviewcontroller.rb +0 -0
  104. data/lib/ios/sugarcube-uikit/frameable.rb +7 -0
  105. data/lib/{sugarcube-uikit → ios/sugarcube-uikit}/nsattributedstring.rb +0 -0
  106. data/lib/{sugarcube-uikit → ios/sugarcube-uikit}/nsstring.rb +6 -6
  107. data/lib/{sugarcube-uikit → ios/sugarcube-uikit}/symbol.rb +0 -0
  108. data/lib/{sugarcube-uikit → ios/sugarcube-uikit}/uifont.rb +0 -0
  109. data/lib/{sugarcube-uikit → ios/sugarcube-uikit}/uiimage.rb +0 -0
  110. data/lib/{sugarcube-uikit → ios/sugarcube-uikit}/uilabel.rb +0 -0
  111. data/lib/{sugarcube-uikit → ios/sugarcube-uikit}/uipickerview.rb +0 -0
  112. data/lib/{sugarcube-uikit → ios/sugarcube-uikit}/uiview.rb +12 -70
  113. data/lib/{sugarcube-uikit → ios/sugarcube-uikit}/uiviewcontroller.rb +0 -0
  114. data/lib/{sugarcube-uikit → ios/sugarcube-uikit}/uiwebview.rb +0 -0
  115. data/lib/osx/sugarcube-animations/nsview.rb +117 -0
  116. data/lib/osx/sugarcube-appkit/frameable.rb +11 -0
  117. data/lib/osx/sugarcube-appkit/nsstring.rb +45 -0
  118. data/lib/osx/sugarcube-appkit/nsview.rb +75 -0
  119. data/lib/osx/sugarcube-color/fixnum.rb +30 -0
  120. data/lib/osx/sugarcube-color/nsarray.rb +22 -0
  121. data/lib/osx/sugarcube-color/nscolor.rb +218 -0
  122. data/lib/osx/sugarcube-color/nsimage.rb +21 -0
  123. data/lib/osx/sugarcube-color/nsstring.rb +24 -0
  124. data/lib/osx/sugarcube-color/symbol.rb +241 -0
  125. data/lib/osx/sugarcube-constants/symbol.rb +186 -0
  126. data/lib/osx/sugarcube-nsdata/nsdata.rb +8 -0
  127. data/lib/osx/sugarcube-nsdata/nsimage.rb +26 -0
  128. data/lib/osx/sugarcube-numbers/nsnumber.rb +14 -0
  129. data/lib/osx/sugarcube-repl/repl.rb +96 -0
  130. data/lib/osx/sugarcube-spritekit/constants.rb +3 -0
  131. data/lib/osx/sugarcube-to_s/nscolor.rb +34 -0
  132. data/lib/osx/sugarcube-to_s/nsview.rb +30 -0
  133. data/lib/sugarcube-568.rb +4 -1
  134. data/lib/sugarcube-all.rb +18 -5
  135. data/lib/sugarcube-animations.rb +6 -1
  136. data/lib/sugarcube-anonymous.rb +3 -1
  137. data/lib/{sugarcube-uifont.rb → sugarcube-appkit.rb} +7 -1
  138. data/lib/sugarcube-attributedstring.rb +3 -1
  139. data/lib/sugarcube-awesome.rb +3 -1
  140. data/lib/sugarcube-classic.rb +15 -5
  141. data/lib/sugarcube-color.rb +3 -1
  142. data/lib/sugarcube-common.rb +16 -5
  143. data/lib/sugarcube-constants.rb +3 -1
  144. data/lib/sugarcube-core.rb +11 -4
  145. data/lib/sugarcube-coregraphics.rb +3 -1
  146. data/lib/sugarcube-corelocation.rb +3 -1
  147. data/lib/sugarcube-events.rb +3 -1
  148. data/lib/sugarcube-factories.rb +3 -1
  149. data/lib/sugarcube-files.rb +3 -1
  150. data/lib/sugarcube-foundation.rb +3 -1
  151. data/lib/sugarcube-gestures.rb +4 -1
  152. data/lib/sugarcube-image.rb +3 -1
  153. data/lib/sugarcube-indexpath.rb +3 -1
  154. data/lib/sugarcube-legacy.rb +12 -1
  155. data/lib/sugarcube-localized.rb +3 -1
  156. data/lib/sugarcube-modal.rb +4 -1
  157. data/lib/sugarcube-notifications.rb +3 -1
  158. data/lib/sugarcube-nscoder.rb +3 -1
  159. data/lib/sugarcube-nsdata.rb +6 -1
  160. data/lib/sugarcube-nsdate.rb +7 -3
  161. data/lib/sugarcube-nsuserdefaults.rb +3 -1
  162. data/lib/sugarcube-numbers.rb +9 -1
  163. data/lib/sugarcube-pipes.rb +3 -1
  164. data/lib/sugarcube-pointer.rb +3 -1
  165. data/lib/sugarcube-repl.rb +9 -1
  166. data/lib/{sugarcube-resources.rb → sugarcube-spritekit.rb} +8 -1
  167. data/lib/sugarcube-timer.rb +7 -3
  168. data/lib/sugarcube-to_s.rb +9 -1
  169. data/lib/sugarcube-uikit.rb +7 -1
  170. data/lib/sugarcube-unholy.rb +3 -1
  171. data/lib/sugarcube.rb +19 -1
  172. data/lib/{sugarcube/version.rb → version.rb} +1 -1
  173. data/spec/{anonymous_spec.rb → all/anonymous_spec.rb} +3 -3
  174. data/spec/{caanimation_spec.rb → cocoa/caanimation_spec.rb} +0 -0
  175. data/spec/{calayer_spec.rb → cocoa/calayer_spec.rb} +0 -0
  176. data/spec/{nsarray_files_spec.rb → cocoa/nsarray_files_spec.rb} +0 -0
  177. data/spec/{nsdata_files_spec.rb → cocoa/nsdata_files_spec.rb} +0 -0
  178. data/spec/{nsdictionary_files_spec.rb → cocoa/nsdictionary_files_spec.rb} +0 -0
  179. data/spec/{568_spec.rb → ios/568_spec.rb} +2 -0
  180. data/spec/{animation_chain_spec.rb → ios/animation_chain_spec.rb} +0 -0
  181. data/spec/{color_components_spec.rb → ios/color_components_spec.rb} +0 -0
  182. data/spec/{color_other_representations_spec.rb → ios/color_other_representations_spec.rb} +0 -0
  183. data/spec/{color_spec.rb → ios/color_spec.rb} +38 -12
  184. data/spec/{core_graphics_spec.rb → ios/core_graphics_spec.rb} +0 -0
  185. data/spec/{core_location_spec.rb → ios/core_location_spec.rb} +0 -0
  186. data/spec/{date_parser_spec.rb → ios/date_parser_spec.rb} +0 -0
  187. data/spec/ios/factories_spec.rb +159 -0
  188. data/spec/{fixnum_spec.rb → ios/fixnum_spec.rb} +0 -0
  189. data/spec/ios/frameable_spec.rb +106 -0
  190. data/spec/{image_cifilters_spec.rb → ios/image_cifilters_spec.rb} +0 -0
  191. data/spec/{image_color_at_spec.rb → ios/image_color_at_spec.rb} +0 -0
  192. data/spec/{image_scale_spec.rb → ios/image_scale_spec.rb} +0 -0
  193. data/spec/{image_uiimage_filters_spec.rb → ios/image_uiimage_filters_spec.rb} +0 -0
  194. data/spec/{notification_spec.rb → ios/notification_spec.rb} +0 -0
  195. data/spec/{nsarray_spec.rb → ios/nsarray_spec.rb} +0 -0
  196. data/spec/{nsattributedstring_spec.rb → ios/nsattributedstring_spec.rb} +5 -5
  197. data/spec/{nscoder_spec.rb → ios/nscoder_spec.rb} +0 -0
  198. data/spec/{nsdata_spec.rb → ios/nsdata_spec.rb} +0 -0
  199. data/spec/{nsdate_delta_spec.rb → ios/nsdate_delta_spec.rb} +0 -0
  200. data/spec/{nsdate_spec.rb → ios/nsdate_spec.rb} +2 -2
  201. data/spec/{nsdate_upto_spec.rb → ios/nsdate_upto_spec.rb} +2 -2
  202. data/spec/{nsorderedset_spec.rb → ios/nsorderedset_spec.rb} +0 -0
  203. data/spec/{nsset_spec.rb → ios/nsset_spec.rb} +0 -0
  204. data/spec/{nsstring_files_spec.rb → ios/nsstring_files_spec.rb} +7 -0
  205. data/spec/{nsstring_spec.rb → ios/nsstring_spec.rb} +4 -4
  206. data/spec/{nsstring_timezone_spec.rb → ios/nsstring_timezone_spec.rb} +0 -0
  207. data/spec/{nsurl_spec.rb → ios/nsurl_spec.rb} +3 -3
  208. data/spec/{numeric_spec.rb → ios/numeric_spec.rb} +0 -0
  209. data/spec/{pipes_spec.rb → ios/pipes_spec.rb} +0 -0
  210. data/spec/{symbol_constants_spec.rb → ios/symbol_constants_spec.rb} +33 -24
  211. data/spec/{symbol_uicolor_spec.rb → ios/symbol_uicolor_spec.rb} +6 -1
  212. data/spec/{symbol_uifont_spec.rb → ios/symbol_uifont_spec.rb} +5 -5
  213. data/spec/{timer_spec.rb → ios/timer_spec.rb} +0 -0
  214. data/spec/{uiactionsheet_spec.rb → ios/uiactionsheet_spec.rb} +0 -0
  215. data/spec/{uialertview_spec.rb → ios/uialertview_spec.rb} +0 -0
  216. data/spec/{uibarbuttonitem_spec.rb → ios/uibarbuttonitem_spec.rb} +0 -0
  217. data/spec/{uicolor_spec.rb → ios/uicolor_spec.rb} +0 -0
  218. data/spec/{uicontrol_spec.rb → ios/uicontrol_spec.rb} +2 -2
  219. data/spec/{uiimage_spec.rb → ios/uiimage_spec.rb} +0 -0
  220. data/spec/{uilabel_spec.rb → ios/uilabel_spec.rb} +0 -0
  221. data/spec/{uitabbaritem_spec.rb → ios/uitabbaritem_spec.rb} +0 -0
  222. data/spec/{uitableviewcell_spec.rb → ios/uitableviewcell_spec.rb} +4 -4
  223. data/spec/{uiview_animation_spec.rb → ios/uiview_animation_spec.rb} +0 -0
  224. data/spec/{uiview_animation_tumble_spec.rb → ios/uiview_animation_tumble_spec.rb} +0 -0
  225. data/spec/{uiview_attr_updates_spec.rb → ios/uiview_attr_updates_spec.rb} +0 -0
  226. data/spec/{uiview_spec.rb → ios/uiview_spec.rb} +15 -45
  227. data/spec/{uiviewcontroller_spec.rb → ios/uiviewcontroller_spec.rb} +0 -0
  228. data/spec/{uiwebview_spec.rb → ios/uiwebview_spec.rb} +0 -0
  229. data/spec/{unholy_spec.rb → ios/unholy_spec.rb} +0 -0
  230. data/spec/osx/color_components_spec.rb +33 -0
  231. data/spec/osx/color_other_representations_spec.rb +58 -0
  232. data/spec/osx/color_spec.rb +123 -0
  233. data/spec/osx/nsview_spec.rb +114 -0
  234. data/spec/osx/symbol_constants_spec.rb +188 -0
  235. metadata +262 -246
  236. data/.gitignore +0 -5
  237. data/.travis.yml +0 -7
  238. data/.yardopts +0 -1
  239. data/Gemfile +0 -7
  240. data/Gemfile.lock +0 -16
  241. data/LICENSE +0 -26
  242. data/Rakefile +0 -12
  243. data/app/animation_chain_controller.rb +0 -12
  244. data/app/app_delegate.rb +0 -27
  245. data/app/uicontrol_controller.rb +0 -49
  246. data/lib/sugarcube/adjust.rb +0 -425
  247. data/lib/sugarcube-color/fixnum.rb +0 -22
  248. data/lib/sugarcube-files/nsstring_deprecated.rb +0 -45
  249. data/lib/sugarcube-legacy/log.rb +0 -45
  250. data/lib/sugarcube-legacy/symbol.rb +0 -219
  251. data/lib/sugarcube-osx/adjust.rb +0 -373
  252. data/lib/sugarcube-repl/repl.rb +0 -90
  253. data/lib/sugarcube-to_s/uitouch.rb +0 -20
  254. data/resources/Default-568h@2x.png +0 -0
  255. data/resources/Default.png +0 -0
  256. data/resources/Default@2x.png +0 -0
  257. data/resources/en.lproj/Localizable.strings +0 -1
  258. data/resources/little_square.png +0 -0
  259. data/resources/little_square@2x.png +0 -0
  260. data/resources/tall-568h@2x.png +0 -0
  261. data/resources/tall.png +0 -0
  262. data/resources/tall@2x.png +0 -0
  263. data/runtests +0 -3
  264. data/spec/sugarcube_legacy.rb +0 -59
  265. data/sugarcube.gemspec +0 -33
@@ -0,0 +1,241 @@
1
+ class Symbol
2
+ class << self
3
+ attr :nscolors
4
+ attr :css_colors
5
+ attr :css_colors_cache
6
+ end
7
+
8
+ def nscolor(alpha=nil)
9
+ if Symbol.css_colors_cache.has_key? self
10
+ color = Symbol.css_colors_cache[self]
11
+ elsif Symbol.nscolors.has_key? self
12
+ # system colors
13
+ color = NSColor.send(SugarCube.look_in(self, Symbol.nscolors))
14
+ else
15
+ # css colors
16
+ color = SugarCube.look_in(self, Symbol.css_colors).nscolor
17
+ Symbol.css_colors_cache[self] = color
18
+ end
19
+
20
+ if alpha
21
+ color = color.colorWithAlphaComponent(alpha.to_f)
22
+ end
23
+
24
+ color
25
+ end
26
+
27
+ def cgcolor(alpha=nil)
28
+ nscolor(alpha).CGColor
29
+ end
30
+
31
+ def skcolor(alpha=nil)
32
+ nscolor(alpha)
33
+ end
34
+
35
+ @nscolors = {
36
+ black: :blackColor,
37
+ blue: :blueColor,
38
+ brown: :brownColor,
39
+ cyan: :cyanColor,
40
+ dark_gray: :darkGrayColor,
41
+ gray: :grayColor,
42
+ green: :greenColor,
43
+ light_gray: :lightGrayColor,
44
+ magenta: :magentaColor,
45
+ orange: :orangeColor,
46
+ purple: :purpleColor,
47
+ red: :redColor,
48
+ yellow: :yellowColor,
49
+ white: :whiteColor,
50
+ clear: :clearColor,
51
+
52
+ system_control_color: :systemControlColor,
53
+ blue_control_color: :blueControlColor,
54
+ graphite_control_color: :graphiteControlColor,
55
+
56
+ alternate_selected_control_color: :alternateSelectedControlColor,
57
+ alternate_selected_control_text_color: :alternateSelectedControlTextColor,
58
+ control_background_color: :controlBackgroundColor,
59
+ control_color: :controlColor,
60
+ control_highlight_color: :controlHighlightColor,
61
+ control_light_highlight_color: :controlLightHighlightColor,
62
+ control_shadow_color: :controlShadowColor,
63
+ control_dark_shadow_color: :controlDarkShadowColor,
64
+ control_text_color: :controlTextColor,
65
+ disabled_control_text_color: :disabledControlTextColor,
66
+ grid_color: :gridColor,
67
+ header_color: :headerColor,
68
+ header_text_color: :headerTextColor,
69
+ highlight_color: :highlightColor,
70
+ keyboard_focus_indicator_color: :keyboardFocusIndicatorColor,
71
+ knob_color: :knobColor,
72
+ scroll_bar_color: :scrollBarColor,
73
+ secondary_selected_control_color: :secondarySelectedControlColor,
74
+ selected_control_color: :selectedControlColor,
75
+ selected_control_text_color: :selectedControlTextColor,
76
+ selected_menu_item_color: :selectedMenuItemColor,
77
+ selected_menu_item_text_color: :selectedMenuItemTextColor,
78
+ selected_text_background_color: :selectedTextBackgroundColor,
79
+ selected_text_color: :selectedTextColor,
80
+ selected_knob_color: :selectedKnobColor,
81
+ shadow_color: :shadowColor,
82
+ text_background_color: :textBackgroundColor,
83
+ text_color: :textColor,
84
+ window_background_color: :windowBackgroundColor,
85
+ window_frame_color: :windowFrameColor,
86
+ window_frame_text_color: :windowFrameTextColor,
87
+ under_page_background_color: :underPageBackgroundColor,
88
+ }
89
+
90
+ @css_colors_cache = {}
91
+ @css_colors = {
92
+ # for css_name to pick up on these colors, they need to be defined here
93
+ black: 0x000000,
94
+ blue: 0x0000ff,
95
+ brown: 0x996633,
96
+ cyan: 0x00ffff,
97
+ dark_gray: 0x555555,
98
+ gray: 0x808080,
99
+ green: 0x00ff00,
100
+ light_gray:0xaaaaaa,
101
+ magenta: 0xff00ff,
102
+ orange: 0xff8000,
103
+ purple: 0x800080,
104
+ red: 0xff0000,
105
+ yellow: 0xffff00,
106
+ white: 0xffffff,
107
+
108
+ # unlike other places, these do not use snake_case, because they are from
109
+ # the CSS standard names
110
+ aliceblue: 0xf0f8ff,
111
+ antiquewhite: 0xfaebd7,
112
+ aqua: 0x00ffff,
113
+ aquamarine: 0x7fffd4,
114
+ azure: 0xf0ffff,
115
+ babygray: 0x576077,
116
+ beige: 0xf5f5dc,
117
+ bisque: 0xffe4c4,
118
+ blanchedalmond: 0xffebcd,
119
+ blueviolet: 0x8a2be2,
120
+ burlywood: 0xdeb887,
121
+ cadetblue: 0x5f9ea0,
122
+ chartreuse: 0x7fff00,
123
+ chocolate: 0xd2691e,
124
+ colingray: 0x526691,
125
+ coral: 0xff7f50,
126
+ cornflowerblue: 0x6495ed,
127
+ cornsilk: 0xfff8dc,
128
+ crimson: 0xdc143c,
129
+ darkblue: 0x00008b,
130
+ darkcyan: 0x008b8b,
131
+ darkgoldenrod: 0xb8860b,
132
+ darkgreen: 0x006400,
133
+ darkkhaki: 0xbdb76b,
134
+ darkmagenta: 0x8b008b,
135
+ darkolivegreen: 0x556b2f,
136
+ darkorange: 0xff8c00,
137
+ darkorchid: 0x9932cc,
138
+ darkred: 0x8b0000,
139
+ darksalmon: 0xe9967a,
140
+ darkseagreen: 0x8fbc8f,
141
+ darkslateblue: 0x483d8b,
142
+ darkslategray: 0x2f4f4f,
143
+ darkturquoise: 0x00ced1,
144
+ darkviolet: 0x9400d3,
145
+ deeppink: 0xff1493,
146
+ deepskyblue: 0x00bfff,
147
+ dimgray: 0x696969,
148
+ dodgerblue: 0x1e90ff,
149
+ firebrick: 0xb22222,
150
+ floralwhite: 0xfffaf0,
151
+ forestgreen: 0x228b22,
152
+ fuchsia: 0xff00ff,
153
+ gainsboro: 0xdcdcdc,
154
+ ghostwhite: 0xf8f8ff,
155
+ gold: 0xffd700,
156
+ goldenrod: 0xdaa520,
157
+ greenyellow: 0xadff2f,
158
+ honeydew: 0xf0fff0,
159
+ hotpink: 0xff69b4,
160
+ indianred: 0xcd5c5c,
161
+ indigo: 0x4b0082,
162
+ ivory: 0xfffff0,
163
+ khaki: 0xf0e68c,
164
+ lavender: 0xe6e6fa,
165
+ lavenderblush: 0xfff0f5,
166
+ lawngreen: 0x7cfc00,
167
+ lemonchiffon: 0xfffacd,
168
+ lightblue: 0xadd8e6,
169
+ lightcoral: 0xf08080,
170
+ lightcyan: 0xe0ffff,
171
+ lightgoldenrodyellow: 0xfafad2,
172
+ lightgreen: 0x90ee90,
173
+ lightpink: 0xffb6c1,
174
+ lightsalmon: 0xffa07a,
175
+ lightseagreen: 0x20b2aa,
176
+ lightskyblue: 0x87cefa,
177
+ lightslategray: 0x778899,
178
+ lightsteelblue: 0xb0c4de,
179
+ lightyellow: 0xffffe0,
180
+ lime: 0x00ff00,
181
+ limegreen: 0x32cd32,
182
+ linen: 0xfaf0e6,
183
+ maroon: 0x800000,
184
+ mediumaquamarine: 0x66cdaa,
185
+ mediumblue: 0x0000cd,
186
+ mediumorchid: 0xba55d3,
187
+ mediumpurple: 0x9370d8,
188
+ mediumseagreen: 0x3cb371,
189
+ mediumslateblue: 0x7b68ee,
190
+ mediumspringgreen: 0x00fa9a,
191
+ mediumturquoise: 0x48d1cc,
192
+ mediumvioletred: 0xc71585,
193
+ midnightblue: 0x191970,
194
+ mintcream: 0xf5fffa,
195
+ mistyrose: 0xffe4e1,
196
+ moccasin: 0xffe4b5,
197
+ navajowhite: 0xffdead,
198
+ navy: 0x000080,
199
+ oldlace: 0xfdf5e6,
200
+ olive: 0x808000,
201
+ olivedrab: 0x6b8e23,
202
+ orangered: 0xff4500,
203
+ orchid: 0xda70d6,
204
+ palegoldenrod: 0xeee8aa,
205
+ palegreen: 0x98fb98,
206
+ paleturquoise: 0xafeeee,
207
+ palevioletred: 0xd87093,
208
+ papayawhip: 0xffefd5,
209
+ peachpuff: 0xffdab9,
210
+ peru: 0xcd853f,
211
+ pink: 0xffc0cb,
212
+ plum: 0xdda0dd,
213
+ powderblue: 0xb0e0e6,
214
+ rosybrown: 0xbc8f8f,
215
+ royalblue: 0x4169e1,
216
+ saddlebrown: 0x8b4513,
217
+ salmon: 0xfa8072,
218
+ sandybrown: 0xf4a460,
219
+ seagreen: 0x2e8b57,
220
+ seashell: 0xfff5ee,
221
+ sienna: 0xa0522d,
222
+ silver: 0xc0c0c0,
223
+ skyblue: 0x87ceeb,
224
+ slateblue: 0x6a5acd,
225
+ slategray: 0x708090,
226
+ snow: 0xfffafa,
227
+ springgreen: 0x00ff7f,
228
+ steelblue: 0x4682b4,
229
+ tan: 0xd2b48c,
230
+ teal: 0x008080,
231
+ thistle: 0xd8bfd8,
232
+ tomato: 0xff6347,
233
+ torygray: 0x5c5a5d,
234
+ turquoise: 0x40e0d0,
235
+ violet: 0xee82ee,
236
+ wheat: 0xf5deb3,
237
+ whitesmoke: 0xf5f5f5,
238
+ yellowgreen: 0x9acd32,
239
+ }
240
+
241
+ end
@@ -0,0 +1,186 @@
1
+ =begin
2
+ Adds constant lookups to the Symbol class. These methods are prefixed with `ns`
3
+ to make their intent clear, and to provide a little bit of "namespacing"
4
+
5
+ # alignment
6
+ :left.nsalignment => NSLeftTextAlignment
7
+
8
+ # nscolors
9
+ :black.nscolor => NSColor.blackColor
10
+
11
+ You can extend the defaults by adding entries:
12
+
13
+ Symbol.css_colors[:my_color] = 0x123456
14
+
15
+ :my_color.nscolor => NSColor
16
+ =end
17
+ class Symbol
18
+
19
+ def nsautoresizingmask
20
+ SugarCube.look_in(self, Symbol.nsautoresizingmask)
21
+ end
22
+ alias nsautoresizemask nsautoresizingmask
23
+
24
+ def nstextalignment
25
+ SugarCube.look_in(self, Symbol.nstextalignment)
26
+ end
27
+ alias nsalignment nstextalignment
28
+
29
+ def nsdatestyle
30
+ SugarCube.look_in(self, Symbol.nsdatestyle)
31
+ end
32
+ alias nsdateformatterstyle nsdatestyle
33
+
34
+ def nsnumberstyle
35
+ SugarCube.look_in(self, Symbol.nsnumberstyle)
36
+ end
37
+ alias nsnumberformatterstyle nsnumberstyle
38
+
39
+ def nsbuttontype
40
+ SugarCube.look_in(self, Symbol.nsbuttontype)
41
+ end
42
+
43
+ def nsbezelstyle
44
+ SugarCube.look_in(self, Symbol.nsbezelstyle)
45
+ end
46
+
47
+ def nsfocusringtype
48
+ SugarCube.look_in(self, Symbol.nsfocusringtype)
49
+ end
50
+
51
+ def catimingfunction
52
+ SugarCube.look_in(self, Symbol.catimingfunction)
53
+ end
54
+ alias catiming catimingfunction
55
+
56
+ def cglinecap
57
+ SugarCube.look_in(self, Symbol.cglinecap)
58
+ end
59
+ alias cglinecapstyle cglinecap
60
+
61
+ def cglinejoin
62
+ SugarCube.look_in(self, Symbol.cglinejoin)
63
+ end
64
+ alias cglinejoinstyle cglinejoin
65
+
66
+ class << self
67
+ attr :nsautoresizingmask
68
+ attr :nstextalignment
69
+ attr :nsdatestyle
70
+ attr :nsnumberstyle
71
+ attr :nsbuttontype
72
+ attr :nsbezelstyle
73
+ attr :nsfocusringtype
74
+ attr :catimingfunction
75
+ attr :cglinecap
76
+ attr :cglinejoin
77
+ end
78
+
79
+ @nsautoresizingmask = {
80
+ none: NSViewNotSizable,
81
+ flexible_left: NSViewMinXMargin,
82
+ flexible_width: NSViewWidthSizable,
83
+ flexible_right: NSViewMaxXMargin,
84
+ flexible_top: NSViewMaxYMargin,
85
+ flexible_height: NSViewHeightSizable,
86
+ flexible_bottom: NSViewMinYMargin,
87
+ fill: NSViewWidthSizable | NSViewHeightSizable,
88
+ fill_top: NSViewWidthSizable | NSViewMinYMargin,
89
+ fill_bottom: NSViewWidthSizable | NSViewMaxYMargin,
90
+ fill_left: NSViewHeightSizable | NSViewMaxXMargin,
91
+ fill_right: NSViewHeightSizable | NSViewMinXMargin,
92
+ fixed_top_left: NSViewMaxXMargin | NSViewMinYMargin,
93
+ fixed_top_middle: NSViewMinXMargin | NSViewMaxXMargin | NSViewMinYMargin,
94
+ fixed_top_right: NSViewMinXMargin | NSViewMinYMargin,
95
+ fixed_middle_left: NSViewMaxYMargin | NSViewMinYMargin | NSViewMaxXMargin,
96
+ fixed_middle: NSViewMaxYMargin | NSViewMinYMargin | NSViewMinXMargin | NSViewMaxXMargin,
97
+ fixed_middle_right: NSViewMaxYMargin | NSViewMinYMargin | NSViewMinXMargin,
98
+ fixed_bottom_left: NSViewMaxXMargin | NSViewMaxYMargin,
99
+ fixed_bottom_middle: NSViewMinXMargin | NSViewMaxXMargin | NSViewMaxYMargin,
100
+ fixed_bottom_right: NSViewMinXMargin | NSViewMaxYMargin,
101
+ float_horizontal: NSViewMinXMargin | NSViewMaxXMargin,
102
+ float_vertical: NSViewMaxYMargin | NSViewMinYMargin,
103
+ }
104
+
105
+ @nstextalignment = {
106
+ left: NSLeftTextAlignment,
107
+ right: NSRightTextAlignment,
108
+ center: NSCenterTextAlignment,
109
+ }
110
+
111
+ @nsdatestyle = {
112
+ no: NSDateFormatterNoStyle,
113
+ none: NSDateFormatterNoStyle,
114
+ short: NSDateFormatterShortStyle,
115
+ medium: NSDateFormatterMediumStyle,
116
+ long: NSDateFormatterLongStyle,
117
+ full: NSDateFormatterFullStyle,
118
+ }
119
+
120
+ @nsnumberstyle = {
121
+ no: NSNumberFormatterNoStyle,
122
+ none: NSNumberFormatterNoStyle,
123
+ decimal: NSNumberFormatterDecimalStyle,
124
+ currency: NSNumberFormatterCurrencyStyle,
125
+ percent: NSNumberFormatterPercentStyle,
126
+ scientific: NSNumberFormatterScientificStyle,
127
+ spell_out: NSNumberFormatterSpellOutStyle,
128
+ }
129
+
130
+ @nsbuttontype = {
131
+ momentary_light: NSMomentaryLightButton,
132
+ push_on_push_off: NSPushOnPushOffButton,
133
+ toggle: NSToggleButton,
134
+ switch: NSSwitchButton,
135
+ radio: NSRadioButton,
136
+ momentary_change: NSMomentaryChangeButton,
137
+ on_off: NSOnOffButton,
138
+ momentary_push_in: NSMomentaryPushInButton,
139
+ }
140
+
141
+ @nsbezelstyle = {
142
+ rounded: NSRoundedBezelStyle,
143
+ regular_square: NSRegularSquareBezelStyle,
144
+ thick_square: NSThickSquareBezelStyle,
145
+ thicker_square: NSThickerSquareBezelStyle,
146
+ disclosure: NSDisclosureBezelStyle,
147
+ shadowless_square: NSShadowlessSquareBezelStyle,
148
+ circular: NSCircularBezelStyle,
149
+ textured_square: NSTexturedSquareBezelStyle,
150
+ help_button: NSHelpButtonBezelStyle,
151
+ small_square: NSSmallSquareBezelStyle,
152
+ textured_rounded: NSTexturedRoundedBezelStyle,
153
+ round_rect: NSRoundRectBezelStyle,
154
+ recessed: NSRecessedBezelStyle,
155
+ rounded_disclosure: NSRoundedDisclosureBezelStyle,
156
+ inline: NSInlineBezelStyle,
157
+ }
158
+
159
+ @nsfocusringtype = {
160
+ default: NSFocusRingTypeDefault,
161
+ none: NSFocusRingTypeNone,
162
+ exterior: NSFocusRingTypeExterior,
163
+ }
164
+
165
+ @catimingfunction = {
166
+ linear: KCAMediaTimingFunctionLinear,
167
+ ease_in: KCAMediaTimingFunctionEaseIn,
168
+ ease_out: KCAMediaTimingFunctionEaseOut,
169
+ ease_in_out: KCAMediaTimingFunctionEaseInEaseOut,
170
+ ease_in_ease_out: KCAMediaTimingFunctionEaseInEaseOut,
171
+ default: KCAMediaTimingFunctionDefault,
172
+ }
173
+
174
+ @cglinecap = {
175
+ butt: KCGLineCapButt,
176
+ round: KCGLineCapRound,
177
+ square: KCGLineCapSquare,
178
+ }
179
+
180
+ @cglinejoin = {
181
+ miter: KCGLineJoinMiter,
182
+ round: KCGLineJoinRound,
183
+ bevel: KCGLineJoinBevel,
184
+ }
185
+
186
+ end
@@ -0,0 +1,8 @@
1
+ class NSData
2
+
3
+ # @return [NSImage]
4
+ def nsimage
5
+ return NSImage.alloc.initWithData(self)
6
+ end
7
+
8
+ end
@@ -0,0 +1,26 @@
1
+ class NSImage
2
+
3
+ # @return [NSData] an NSData object in an image file format. compression is
4
+ # optional, and only supported on the JPEG formats
5
+ def nsdata(format=:png, compression=0.9)
6
+ self.lockFocus
7
+ bitmap_rep = NSBitmapImageRep.alloc.initWithFocusedViewRect(NSMakeRect(0, 0, self.size.width, self.size.height))
8
+ self.unlockFocus
9
+
10
+ case format
11
+ when :png, :PNG
12
+ return bitmap_rep.representationUsingType(NSPNGFileType, properties: nil)
13
+ when :jpg, :jpeg, :JPG, :JPEG
14
+ return bitmap_rep.representationUsingType(NSJPEGFileType, properties: { NSImageCompressionFactor => compression })
15
+ when :jpg2000, :jpeg2000, :JPG2000, :JPEG2000
16
+ return bitmap_rep.representationUsingType(NSJPEG2000FileType, properties: { NSImageCompressionFactor => compression })
17
+ when :tif, :tiff, :TIF, :TIFF
18
+ return bitmap_rep.representationUsingType(NSTIFFFileType, properties: nil)
19
+ when :gif, :GIF
20
+ return bitmap_rep.representationUsingType(NSGIFFileType, properties: nil)
21
+ when :bmp, :BMP
22
+ return bitmap_rep.representationUsingType(NSBMPFileType, properties: nil)
23
+ end
24
+ end
25
+
26
+ end
@@ -0,0 +1,14 @@
1
+ class NSNumber
2
+
3
+ ##|
4
+ ##| MISC
5
+ ##|
6
+
7
+ # Uses the screen scale to determine how many pixels (converts "pixels" to
8
+ # "points")
9
+ def pixels
10
+ self.to_f / NSScreen.mainScreen.backingScaleFactor
11
+ end
12
+ alias pixel pixels
13
+
14
+ end
@@ -0,0 +1,96 @@
1
+ module SugarCube
2
+ module Repl
3
+ module_function
4
+
5
+ def window(index=nil)
6
+ if index
7
+ NSApplication.sharedApplication.windows[index]
8
+ else
9
+ (
10
+ NSApplication.sharedApplication.keyWindow ||
11
+ NSApplication.sharedApplication.mainWindow ||
12
+ NSApplication.sharedApplication.windows[0]
13
+ )
14
+ end
15
+ end
16
+
17
+ def root
18
+ window.windowController
19
+ end
20
+
21
+ def adjust_init(view)
22
+ if view.is_a?(NSView)
23
+ @sugarcube_restore = {
24
+ frame: SugarCube::Repl.frame,
25
+ }
26
+ end
27
+ end
28
+
29
+ def blink(color=nil)
30
+ return unless check_sugarcube_view
31
+ blinking_view ||= blink_view(color)
32
+
33
+ blinking_view = NSView.alloc.initWithFrame([[0,0], @sugarcube_view.frame.size])
34
+ color = color.uicolor if color.respond_to?(:uicolor)
35
+ blinking_view.backgroundColor = color
36
+ blinking_view.alpha = 0
37
+ if @sugarcube_view.window
38
+ blinking_view.frame = @sugarcube_view.convertRect([[0, 0], @sugarcube_view.frame.size], toView: @sugarcube_view.window)
39
+ @sugarcube_view.window.addSubview(blinking_view)
40
+ else
41
+ @sugarcube_view.addSubview(blinking_view)
42
+ end
43
+
44
+ duration = 0.2
45
+ NSAnimationContext.runAnimationGroup(-> (context) do
46
+ context.duration = duration * 2
47
+ blinking_view.animator.alpha = 1
48
+ end, completionHandler: -> do
49
+ NSAnimationContext.runAnimationGroup(-> (context) do
50
+ context.duration = duration
51
+ blinking_view.animator.alpha = 0
52
+ end, completionHandler: -> do
53
+ NSAnimationContext.runAnimationGroup(-> (context) do
54
+ context.duration = duration
55
+ blinking_view.animator.alpha = 1
56
+ end, completionHandler: -> do
57
+ NSAnimationContext.runAnimationGroup(-> (context) do
58
+ context.duration = duration
59
+ blinking_view.animator.alpha = 0
60
+ end, completionHandler: -> do
61
+ blinking_view.removeFromSuperview
62
+ end)
63
+ end)
64
+ end)
65
+ end)
66
+ end
67
+
68
+ def get_tree_selector(item)
69
+ if item.is_a? NSView
70
+ return :subviews
71
+ elsif item.is_a? NSWindow
72
+ item = item.contentView
73
+ return :subviews
74
+ elsif item.is_a? NSWindowController
75
+ return -> (ctlr) { [ctlr.window] }
76
+ elsif item.is_a? NSViewController
77
+ return -> (ctlr) { [ctlr.view] }
78
+ elsif item.is_a? NSMenu
79
+ return :itemArray
80
+ elsif item.is_a? NSMenuItem
81
+ return -> (menu_item) { [menu_item.menu] }
82
+ else
83
+ nil
84
+ end
85
+ end
86
+
87
+ def draw_tree_item(item)
88
+ if item.is_a? NSView
89
+ item.sugarcube_to_s superview: false
90
+ else
91
+ item.to_s
92
+ end
93
+ end
94
+
95
+ end
96
+ end
@@ -0,0 +1,3 @@
1
+ unless defined?(SKColor)
2
+ SKColor = NSColor
3
+ end
@@ -0,0 +1,34 @@
1
+ class NSColor
2
+
3
+ def to_s
4
+ return super unless self.respond_to?(:alpha)
5
+
6
+ alpha_s = ((alpha || 1) < 1 ? "(#{alpha})" : '')
7
+ system_color = system_name
8
+ return "NSColor.#{system_color}#{alpha_s}" if system_color
9
+
10
+ alpha_s = ((alpha || 1) < 1 ? ", alpha: #{alpha}" : '')
11
+ inside = (css_name && ":#{css_name}") || (hex && "'#{hex}'")
12
+ if inside
13
+ return "NSColor.color(#{inside}#{alpha_s})"
14
+ else
15
+ super
16
+ end
17
+ end
18
+
19
+ def inspect
20
+ return super unless self.respond_to?(:alpha)
21
+
22
+ alpha_s = ((alpha || 1) < 1 ? "(#{alpha})" : '')
23
+ if system_name
24
+ return "NSColor.#{system_name}#{alpha_s}"
25
+ elsif css_name
26
+ return ":#{css_name}.uicolor#{alpha_s}"
27
+ elsif hex
28
+ return "'#{hex}'.uicolor#{alpha_s}"
29
+ else
30
+ super
31
+ end
32
+ end
33
+
34
+ end
@@ -0,0 +1,30 @@
1
+ class NSView
2
+
3
+ def sugarcube_to_s(options={})
4
+ if self.respond_to? :stylename and self.stylename
5
+ suffix = ' stylename: ' + self.stylename.inspect
6
+ else
7
+ suffix = ''
8
+ end
9
+ if options[:inner].is_a? Hash
10
+ inner = ''
11
+ options[:inner].each do |key, value|
12
+ inner += ', ' if inner.length > 0
13
+ inner += "#{key}: #{value.inspect}"
14
+ end
15
+ else
16
+ inner = options[:inner]
17
+ end
18
+
19
+ "#{self.class.to_s}(##{self.object_id.to_s(16)}, [[#{frame.origin.x}, #{frame.origin.y}], [#{frame.size.width}, #{frame.size.height}]]" +
20
+ (inner ? ', ' + inner : '') +
21
+ ')' +
22
+ (options.fetch(:superview, true) && self.superview ? ", child of #{self.superview.class.to_s}(##{self.superview.object_id.to_s(16)})" : '') +
23
+ suffix
24
+ end
25
+
26
+ def to_s
27
+ sugarcube_to_s
28
+ end
29
+
30
+ end
data/lib/sugarcube-568.rb CHANGED
@@ -3,13 +3,16 @@ unless defined?(Motion::Project::Config)
3
3
  end
4
4
 
5
5
 
6
+ require 'sugarcube'
7
+ SugarCube.ios_only!('568')
8
+
6
9
  Motion::Project::App.setup do |app|
7
10
  # scans app.files until it finds app/ (the default)
8
11
  # if found, it inserts just before those files, otherwise it will insert to
9
12
  # the end of the list
10
13
  insert_point = app.files.find_index { |file| file =~ /^(?:\.\/)?app\// } || 0
11
14
 
12
- Dir.glob(File.join(File.dirname(__FILE__), 'sugarcube-568/**/*.rb')).reverse.each do |file|
15
+ Dir.glob(File.join(File.dirname(__FILE__), 'ios/sugarcube-568/**/*.rb')).reverse.each do |file|
13
16
  app.files.insert(insert_point, file)
14
17
  end
15
18
  end
data/lib/sugarcube-all.rb CHANGED
@@ -1,18 +1,31 @@
1
- ignore = [
1
+ require 'sugarcube'
2
+
3
+ exclude = [
2
4
  'sugarcube-all.rb',
3
5
  'sugarcube-common.rb',
4
6
  'sugarcube-classic.rb',
5
- 'sugarcube-osx.rb',
6
7
  'sugarcube-legacy.rb',
7
8
  'sugarcube-uicolor.rb',
8
9
  'sugarcube-uiimage.rb',
9
10
  ]
10
11
 
12
+ if App.template == :ios
13
+ exclude += [
14
+ 'sugarcube-appkit.rb',
15
+ ]
16
+ elsif App.template == :osx
17
+ exclude += [
18
+ 'sugarcube-568.rb',
19
+ 'sugarcube-gestures.rb',
20
+ 'sugarcube-modal.rb',
21
+ 'sugarcube-uikit.rb',
22
+ ]
23
+ end
24
+
11
25
  dirname = File.dirname(__FILE__)
12
26
  Dir.glob(File.join(dirname, '*.rb')).each do |file|
13
- file = File.basename(file)
14
- unless ignore.include? file
15
- file = File.join(dirname, file)
27
+ filename = File.basename(file)
28
+ unless exclude.include? filename
16
29
  require file
17
30
  end
18
31
  end