sugarcube 1.7.0 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +17 -1
- data/lib/all/sugarcube/log.rb +57 -0
- data/lib/{sugarcube → all/sugarcube}/look_in.rb +1 -6
- data/lib/{sugarcube-legacy → all/sugarcube-legacy}/activesupport.rb +1 -4
- data/lib/{sugarcube-numbers → all/sugarcube-numbers}/fixnum.rb +3 -3
- data/lib/{sugarcube-numbers/nsnumber.rb → all/sugarcube-numbers/numeric.rb} +1 -19
- data/lib/{sugarcube-numbers → all/sugarcube-numbers}/time.rb +2 -2
- data/lib/{sugarcube-unholy → all/sugarcube-unholy}/ivar.rb +0 -0
- data/lib/cocoa/sugarcube/log.rb +8 -0
- data/lib/{sugarcube-animations → cocoa/sugarcube-animations}/caanimation.rb +0 -0
- data/lib/{sugarcube-animations → cocoa/sugarcube-animations}/calayer.rb +0 -0
- data/lib/{sugarcube-anonymous → cocoa/sugarcube-anonymous}/anonymous.rb +0 -0
- data/lib/{sugarcube-anonymous → cocoa/sugarcube-anonymous}/anonymous_array.rb +0 -0
- data/lib/{sugarcube-attributedstring → cocoa/sugarcube-attributedstring}/nsattributedstring.rb +0 -0
- data/lib/{sugarcube-awesome → cocoa/sugarcube-awesome}/awesome_exts.rb +0 -0
- data/lib/{sugarcube-uikit → cocoa/sugarcube-cocoakit}/calayer.rb +0 -0
- data/lib/cocoa/sugarcube-cocoakit/frameable.rb +50 -0
- data/lib/{sugarcube-corelocation → cocoa/sugarcube-corelocation}/core_location.rb +0 -0
- data/lib/{sugarcube-files → cocoa/sugarcube-files}/nsarray.rb +0 -0
- data/lib/{sugarcube-files → cocoa/sugarcube-files}/nsdata.rb +0 -0
- data/lib/{sugarcube-files → cocoa/sugarcube-files}/nsdictionary.rb +0 -0
- data/lib/{sugarcube-files → cocoa/sugarcube-files}/nsstring.rb +0 -0
- data/lib/cocoa/sugarcube-files/nsstring_deprecated.rb +45 -0
- data/lib/{sugarcube-foundation → cocoa/sugarcube-foundation}/nsarray.rb +0 -0
- data/lib/{sugarcube-foundation → cocoa/sugarcube-foundation}/nsindexpath.rb +0 -0
- data/lib/{sugarcube-foundation → cocoa/sugarcube-foundation}/nsindexset.rb +0 -0
- data/lib/{sugarcube-foundation → cocoa/sugarcube-foundation}/nsorderedset.rb +0 -0
- data/lib/{sugarcube-foundation → cocoa/sugarcube-foundation}/nsset.rb +1 -0
- data/lib/{sugarcube-foundation → cocoa/sugarcube-foundation}/nsstring.rb +0 -0
- data/lib/{sugarcube-foundation → cocoa/sugarcube-foundation}/nsurl.rb +0 -0
- data/lib/{sugarcube-indexpath → cocoa/sugarcube-indexpath}/indexpath.rb +0 -0
- data/lib/{sugarcube-localized → cocoa/sugarcube-localized}/nserror.rb +0 -0
- data/lib/{sugarcube-localized → cocoa/sugarcube-localized}/nsstring.rb +0 -0
- data/lib/{sugarcube-notifications → cocoa/sugarcube-notifications}/notifications.rb +8 -8
- data/lib/{sugarcube-nscoder → cocoa/sugarcube-nscoder}/nscoder.rb +0 -0
- data/lib/{sugarcube-nsdata → cocoa/sugarcube-nsdata}/nsdata.rb +0 -9
- data/lib/{sugarcube-nsdata → cocoa/sugarcube-nsdata}/nsstring.rb +0 -0
- data/lib/{sugarcube-nsdata → cocoa/sugarcube-nsdata}/nsurl.rb +0 -0
- data/lib/{sugarcube-nsdate → cocoa/sugarcube-nsdate}/date_parser.rb +0 -0
- data/lib/{sugarcube-nsdate → cocoa/sugarcube-nsdate}/fixnum.rb +0 -0
- data/lib/{sugarcube-nsdate → cocoa/sugarcube-nsdate}/nsdate.rb +0 -0
- data/lib/{sugarcube-nsdate → cocoa/sugarcube-nsdate}/nsdate_delta.rb +0 -0
- data/lib/{sugarcube-nsdate → cocoa/sugarcube-nsdate}/nsnumber.rb +0 -0
- data/lib/{sugarcube-nsdate → cocoa/sugarcube-nsdate}/nsstring.rb +0 -0
- data/lib/{sugarcube-nsuserdefaults → cocoa/sugarcube-nsuserdefaults}/nsuserdefaults.rb +0 -0
- data/lib/cocoa/sugarcube-numbers/nsnumber.rb +10 -0
- data/lib/{sugarcube-numbers → cocoa/sugarcube-numbers}/nsstring.rb +0 -0
- data/lib/{sugarcube-pointer → cocoa/sugarcube-pointer}/nsarray.rb +0 -0
- data/lib/cocoa/sugarcube-repl/kernel.rb +161 -0
- data/lib/cocoa/sugarcube-repl/repl.rb +330 -0
- data/lib/cocoa/sugarcube-spritekit/sknode.rb +11 -0
- data/lib/{sugarcube-timer → cocoa/sugarcube-timer}/timer.rb +0 -0
- data/lib/{sugarcube-to_s → cocoa/sugarcube-to_s}/nserror.rb +1 -1
- data/lib/{sugarcube-to_s → cocoa/sugarcube-to_s}/nsindexpath.rb +0 -0
- data/lib/{sugarcube-to_s → cocoa/sugarcube-to_s}/nslayoutconstraint.rb +0 -0
- data/lib/{sugarcube-to_s → cocoa/sugarcube-to_s}/nsnotification.rb +1 -1
- data/lib/{sugarcube-to_s → cocoa/sugarcube-to_s}/nsset.rb +0 -0
- data/lib/{sugarcube-to_s → cocoa/sugarcube-to_s}/nsurl.rb +1 -1
- data/lib/{sugarcube → ios/sugarcube}/sugarcube_cleanup.rb +0 -0
- data/lib/{sugarcube-568 → ios/sugarcube-568}/uiimage.rb +0 -0
- data/lib/{sugarcube-animations → ios/sugarcube-animations}/animation_chain.rb +0 -0
- data/lib/{sugarcube-animations → ios/sugarcube-animations}/uiview.rb +3 -10
- data/lib/ios/sugarcube-color/fixnum.rb +30 -0
- data/lib/{sugarcube-color → ios/sugarcube-color}/nsarray.rb +5 -1
- data/lib/{sugarcube-color → ios/sugarcube-color}/nsstring.rb +5 -1
- data/lib/{sugarcube-color → ios/sugarcube-color}/symbol.rb +10 -2
- data/lib/{sugarcube-color → ios/sugarcube-color}/uicolor.rb +5 -9
- data/lib/{sugarcube-color → ios/sugarcube-color}/uiimage.rb +5 -1
- data/lib/{sugarcube-constants → ios/sugarcube-constants}/symbol.rb +3 -10
- data/lib/{sugarcube-coregraphics → ios/sugarcube-coregraphics}/core_graphics.rb +0 -0
- data/lib/{sugarcube-events → ios/sugarcube-events}/uicontrol.rb +0 -0
- data/lib/{sugarcube-events → ios/sugarcube-events}/uitextview.rb +0 -0
- data/lib/{sugarcube-factories → ios/sugarcube-factories}/nserror.rb +1 -1
- data/lib/{sugarcube-factories → ios/sugarcube-factories}/uiactionsheet.rb +0 -0
- data/lib/{sugarcube-factories/uiactivityindicator.rb → ios/sugarcube-factories/uiactivityindicatorview.rb} +0 -0
- data/lib/{sugarcube-factories → ios/sugarcube-factories}/uialertview.rb +0 -0
- data/lib/{sugarcube-factories → ios/sugarcube-factories}/uibarbuttonitem.rb +7 -2
- data/lib/{sugarcube-factories → ios/sugarcube-factories}/uibutton.rb +10 -0
- data/lib/{sugarcube-factories → ios/sugarcube-factories}/uisegmentedcontrol.rb +0 -0
- data/lib/{sugarcube-factories → ios/sugarcube-factories}/uitabbaritem.rb +0 -0
- data/lib/{sugarcube-factories → ios/sugarcube-factories}/uitableview.rb +0 -0
- data/lib/{sugarcube-factories → ios/sugarcube-factories}/uitableviewcell.rb +0 -0
- data/lib/{sugarcube-gestures → ios/sugarcube-gestures}/gestures.rb +0 -0
- data/lib/{sugarcube-image → ios/sugarcube-image}/cicolor.rb +0 -0
- data/lib/{sugarcube-image → ios/sugarcube-image}/cifilter.rb +0 -0
- data/lib/{sugarcube-image → ios/sugarcube-image}/ciimage.rb +0 -0
- data/lib/{sugarcube-image → ios/sugarcube-image}/uicolor.rb +0 -0
- data/lib/{sugarcube-image → ios/sugarcube-image}/uiimage.rb +0 -0
- data/lib/{sugarcube-modal → ios/sugarcube-modal}/modal.rb +2 -1
- data/lib/ios/sugarcube-nsdata/nsdata.rb +12 -0
- data/lib/{sugarcube-nsdata → ios/sugarcube-nsdata}/uiimage.rb +0 -0
- data/lib/ios/sugarcube-numbers/nsnumber.rb +14 -0
- data/lib/{sugarcube-pipes → ios/sugarcube-pipes}/pipes.rb +4 -4
- data/lib/ios/sugarcube-repl/repl.rb +112 -0
- data/lib/ios/sugarcube-spritekit/constants.rb +3 -0
- data/lib/{sugarcube-to_s → ios/sugarcube-to_s}/uicolor.rb +0 -0
- data/lib/{sugarcube-to_s → ios/sugarcube-to_s}/uievent.rb +14 -14
- data/lib/{sugarcube-to_s → ios/sugarcube-to_s}/uilabel.rb +1 -1
- data/lib/{sugarcube-to_s → ios/sugarcube-to_s}/uitextfield.rb +1 -1
- data/lib/ios/sugarcube-to_s/uitouch.rb +20 -0
- data/lib/{sugarcube-to_s → ios/sugarcube-to_s}/uiview.rb +7 -3
- data/lib/{sugarcube-to_s → ios/sugarcube-to_s}/uiviewcontroller.rb +0 -0
- data/lib/ios/sugarcube-uikit/frameable.rb +7 -0
- data/lib/{sugarcube-uikit → ios/sugarcube-uikit}/nsattributedstring.rb +0 -0
- data/lib/{sugarcube-uikit → ios/sugarcube-uikit}/nsstring.rb +6 -6
- data/lib/{sugarcube-uikit → ios/sugarcube-uikit}/symbol.rb +0 -0
- data/lib/{sugarcube-uikit → ios/sugarcube-uikit}/uifont.rb +0 -0
- data/lib/{sugarcube-uikit → ios/sugarcube-uikit}/uiimage.rb +0 -0
- data/lib/{sugarcube-uikit → ios/sugarcube-uikit}/uilabel.rb +0 -0
- data/lib/{sugarcube-uikit → ios/sugarcube-uikit}/uipickerview.rb +0 -0
- data/lib/{sugarcube-uikit → ios/sugarcube-uikit}/uiview.rb +12 -70
- data/lib/{sugarcube-uikit → ios/sugarcube-uikit}/uiviewcontroller.rb +0 -0
- data/lib/{sugarcube-uikit → ios/sugarcube-uikit}/uiwebview.rb +0 -0
- data/lib/osx/sugarcube-animations/nsview.rb +117 -0
- data/lib/osx/sugarcube-appkit/frameable.rb +11 -0
- data/lib/osx/sugarcube-appkit/nsstring.rb +45 -0
- data/lib/osx/sugarcube-appkit/nsview.rb +75 -0
- data/lib/osx/sugarcube-color/fixnum.rb +30 -0
- data/lib/osx/sugarcube-color/nsarray.rb +22 -0
- data/lib/osx/sugarcube-color/nscolor.rb +218 -0
- data/lib/osx/sugarcube-color/nsimage.rb +21 -0
- data/lib/osx/sugarcube-color/nsstring.rb +24 -0
- data/lib/osx/sugarcube-color/symbol.rb +241 -0
- data/lib/osx/sugarcube-constants/symbol.rb +186 -0
- data/lib/osx/sugarcube-nsdata/nsdata.rb +8 -0
- data/lib/osx/sugarcube-nsdata/nsimage.rb +26 -0
- data/lib/osx/sugarcube-numbers/nsnumber.rb +14 -0
- data/lib/osx/sugarcube-repl/repl.rb +96 -0
- data/lib/osx/sugarcube-spritekit/constants.rb +3 -0
- data/lib/osx/sugarcube-to_s/nscolor.rb +34 -0
- data/lib/osx/sugarcube-to_s/nsview.rb +30 -0
- data/lib/sugarcube-568.rb +4 -1
- data/lib/sugarcube-all.rb +18 -5
- data/lib/sugarcube-animations.rb +6 -1
- data/lib/sugarcube-anonymous.rb +3 -1
- data/lib/{sugarcube-uifont.rb → sugarcube-appkit.rb} +7 -1
- data/lib/sugarcube-attributedstring.rb +3 -1
- data/lib/sugarcube-awesome.rb +3 -1
- data/lib/sugarcube-classic.rb +15 -5
- data/lib/sugarcube-color.rb +3 -1
- data/lib/sugarcube-common.rb +16 -5
- data/lib/sugarcube-constants.rb +3 -1
- data/lib/sugarcube-core.rb +11 -4
- data/lib/sugarcube-coregraphics.rb +3 -1
- data/lib/sugarcube-corelocation.rb +3 -1
- data/lib/sugarcube-events.rb +3 -1
- data/lib/sugarcube-factories.rb +3 -1
- data/lib/sugarcube-files.rb +3 -1
- data/lib/sugarcube-foundation.rb +3 -1
- data/lib/sugarcube-gestures.rb +4 -1
- data/lib/sugarcube-image.rb +3 -1
- data/lib/sugarcube-indexpath.rb +3 -1
- data/lib/sugarcube-legacy.rb +12 -1
- data/lib/sugarcube-localized.rb +3 -1
- data/lib/sugarcube-modal.rb +4 -1
- data/lib/sugarcube-notifications.rb +3 -1
- data/lib/sugarcube-nscoder.rb +3 -1
- data/lib/sugarcube-nsdata.rb +6 -1
- data/lib/sugarcube-nsdate.rb +7 -3
- data/lib/sugarcube-nsuserdefaults.rb +3 -1
- data/lib/sugarcube-numbers.rb +9 -1
- data/lib/sugarcube-pipes.rb +3 -1
- data/lib/sugarcube-pointer.rb +3 -1
- data/lib/sugarcube-repl.rb +9 -1
- data/lib/{sugarcube-resources.rb → sugarcube-spritekit.rb} +8 -1
- data/lib/sugarcube-timer.rb +7 -3
- data/lib/sugarcube-to_s.rb +9 -1
- data/lib/sugarcube-uikit.rb +7 -1
- data/lib/sugarcube-unholy.rb +3 -1
- data/lib/sugarcube.rb +19 -1
- data/lib/{sugarcube/version.rb → version.rb} +1 -1
- data/spec/{anonymous_spec.rb → all/anonymous_spec.rb} +3 -3
- data/spec/{caanimation_spec.rb → cocoa/caanimation_spec.rb} +0 -0
- data/spec/{calayer_spec.rb → cocoa/calayer_spec.rb} +0 -0
- data/spec/{nsarray_files_spec.rb → cocoa/nsarray_files_spec.rb} +0 -0
- data/spec/{nsdata_files_spec.rb → cocoa/nsdata_files_spec.rb} +0 -0
- data/spec/{nsdictionary_files_spec.rb → cocoa/nsdictionary_files_spec.rb} +0 -0
- data/spec/{568_spec.rb → ios/568_spec.rb} +2 -0
- data/spec/{animation_chain_spec.rb → ios/animation_chain_spec.rb} +0 -0
- data/spec/{color_components_spec.rb → ios/color_components_spec.rb} +0 -0
- data/spec/{color_other_representations_spec.rb → ios/color_other_representations_spec.rb} +0 -0
- data/spec/{color_spec.rb → ios/color_spec.rb} +38 -12
- data/spec/{core_graphics_spec.rb → ios/core_graphics_spec.rb} +0 -0
- data/spec/{core_location_spec.rb → ios/core_location_spec.rb} +0 -0
- data/spec/{date_parser_spec.rb → ios/date_parser_spec.rb} +0 -0
- data/spec/ios/factories_spec.rb +159 -0
- data/spec/{fixnum_spec.rb → ios/fixnum_spec.rb} +0 -0
- data/spec/ios/frameable_spec.rb +106 -0
- data/spec/{image_cifilters_spec.rb → ios/image_cifilters_spec.rb} +0 -0
- data/spec/{image_color_at_spec.rb → ios/image_color_at_spec.rb} +0 -0
- data/spec/{image_scale_spec.rb → ios/image_scale_spec.rb} +0 -0
- data/spec/{image_uiimage_filters_spec.rb → ios/image_uiimage_filters_spec.rb} +0 -0
- data/spec/{notification_spec.rb → ios/notification_spec.rb} +0 -0
- data/spec/{nsarray_spec.rb → ios/nsarray_spec.rb} +0 -0
- data/spec/{nsattributedstring_spec.rb → ios/nsattributedstring_spec.rb} +5 -5
- data/spec/{nscoder_spec.rb → ios/nscoder_spec.rb} +0 -0
- data/spec/{nsdata_spec.rb → ios/nsdata_spec.rb} +0 -0
- data/spec/{nsdate_delta_spec.rb → ios/nsdate_delta_spec.rb} +0 -0
- data/spec/{nsdate_spec.rb → ios/nsdate_spec.rb} +2 -2
- data/spec/{nsdate_upto_spec.rb → ios/nsdate_upto_spec.rb} +2 -2
- data/spec/{nsorderedset_spec.rb → ios/nsorderedset_spec.rb} +0 -0
- data/spec/{nsset_spec.rb → ios/nsset_spec.rb} +0 -0
- data/spec/{nsstring_files_spec.rb → ios/nsstring_files_spec.rb} +7 -0
- data/spec/{nsstring_spec.rb → ios/nsstring_spec.rb} +4 -4
- data/spec/{nsstring_timezone_spec.rb → ios/nsstring_timezone_spec.rb} +0 -0
- data/spec/{nsurl_spec.rb → ios/nsurl_spec.rb} +3 -3
- data/spec/{numeric_spec.rb → ios/numeric_spec.rb} +0 -0
- data/spec/{pipes_spec.rb → ios/pipes_spec.rb} +0 -0
- data/spec/{symbol_constants_spec.rb → ios/symbol_constants_spec.rb} +33 -24
- data/spec/{symbol_uicolor_spec.rb → ios/symbol_uicolor_spec.rb} +6 -1
- data/spec/{symbol_uifont_spec.rb → ios/symbol_uifont_spec.rb} +5 -5
- data/spec/{timer_spec.rb → ios/timer_spec.rb} +0 -0
- data/spec/{uiactionsheet_spec.rb → ios/uiactionsheet_spec.rb} +0 -0
- data/spec/{uialertview_spec.rb → ios/uialertview_spec.rb} +0 -0
- data/spec/{uibarbuttonitem_spec.rb → ios/uibarbuttonitem_spec.rb} +0 -0
- data/spec/{uicolor_spec.rb → ios/uicolor_spec.rb} +0 -0
- data/spec/{uicontrol_spec.rb → ios/uicontrol_spec.rb} +2 -2
- data/spec/{uiimage_spec.rb → ios/uiimage_spec.rb} +0 -0
- data/spec/{uilabel_spec.rb → ios/uilabel_spec.rb} +0 -0
- data/spec/{uitabbaritem_spec.rb → ios/uitabbaritem_spec.rb} +0 -0
- data/spec/{uitableviewcell_spec.rb → ios/uitableviewcell_spec.rb} +4 -4
- data/spec/{uiview_animation_spec.rb → ios/uiview_animation_spec.rb} +0 -0
- data/spec/{uiview_animation_tumble_spec.rb → ios/uiview_animation_tumble_spec.rb} +0 -0
- data/spec/{uiview_attr_updates_spec.rb → ios/uiview_attr_updates_spec.rb} +0 -0
- data/spec/{uiview_spec.rb → ios/uiview_spec.rb} +15 -45
- data/spec/{uiviewcontroller_spec.rb → ios/uiviewcontroller_spec.rb} +0 -0
- data/spec/{uiwebview_spec.rb → ios/uiwebview_spec.rb} +0 -0
- data/spec/{unholy_spec.rb → ios/unholy_spec.rb} +0 -0
- data/spec/osx/color_components_spec.rb +33 -0
- data/spec/osx/color_other_representations_spec.rb +58 -0
- data/spec/osx/color_spec.rb +123 -0
- data/spec/osx/nsview_spec.rb +114 -0
- data/spec/osx/symbol_constants_spec.rb +188 -0
- metadata +262 -246
- data/.gitignore +0 -5
- data/.travis.yml +0 -7
- data/.yardopts +0 -1
- data/Gemfile +0 -7
- data/Gemfile.lock +0 -16
- data/LICENSE +0 -26
- data/Rakefile +0 -12
- data/app/animation_chain_controller.rb +0 -12
- data/app/app_delegate.rb +0 -27
- data/app/uicontrol_controller.rb +0 -49
- data/lib/sugarcube/adjust.rb +0 -425
- data/lib/sugarcube-color/fixnum.rb +0 -22
- data/lib/sugarcube-files/nsstring_deprecated.rb +0 -45
- data/lib/sugarcube-legacy/log.rb +0 -45
- data/lib/sugarcube-legacy/symbol.rb +0 -219
- data/lib/sugarcube-osx/adjust.rb +0 -373
- data/lib/sugarcube-repl/repl.rb +0 -90
- data/lib/sugarcube-to_s/uitouch.rb +0 -20
- data/resources/Default-568h@2x.png +0 -0
- data/resources/Default.png +0 -0
- data/resources/Default@2x.png +0 -0
- data/resources/en.lproj/Localizable.strings +0 -1
- data/resources/little_square.png +0 -0
- data/resources/little_square@2x.png +0 -0
- data/resources/tall-568h@2x.png +0 -0
- data/resources/tall.png +0 -0
- data/resources/tall@2x.png +0 -0
- data/runtests +0 -3
- data/spec/sugarcube_legacy.rb +0 -59
- 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,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,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,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
|
-
|
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
|
-
|
14
|
-
unless
|
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
|