scarpe 0.4.0 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (91) hide show
  1. checksums.yaml +4 -4
  2. data/.cursor/rules/commit-style-preferences.mdc +72 -0
  3. data/.cursor/rules/component_context.mdc +82 -0
  4. data/.cursor/rules/debug-failed-tests.mdc +100 -0
  5. data/.cursor/rules/display_service_context.mdc +80 -0
  6. data/.cursor/rules/event_handling_context.mdc +100 -0
  7. data/.cursor/rules/git-pager-handling.mdc +64 -0
  8. data/.cursor/rules/lacci-context.mdc +52 -0
  9. data/.cursor/rules/scarpe_design_context.mdc +46 -0
  10. data/.cursor/rules/shoes_compatibility_context.mdc +75 -0
  11. data/.cursor/rules/timeout_context.mdc +78 -0
  12. data/.cursor/rules/update_lacci_and_wv.mdc +8 -0
  13. data/.cursor/rules/what_is_scarpe.mdc +22 -0
  14. data/.cursor/rules/writing-new-rules.mdc +73 -0
  15. data/CHANGELOG.md +10 -1
  16. data/CLAUDE.md +223 -0
  17. data/Gemfile +0 -1
  18. data/Gemfile.lock +78 -58
  19. data/README.md +4 -7
  20. data/Rakefile +17 -25
  21. data/docs/SCARPE_FEATURES.md +38 -0
  22. data/docs/_config.yml +13 -0
  23. data/docs/calzini_components_and_updates.md +78 -0
  24. data/docs/display_service_separation.md +39 -0
  25. data/docs/documentation.md +43 -0
  26. data/docs/event_loops.md +66 -0
  27. data/docs/image.png +0 -0
  28. data/docs/index.md +118 -0
  29. data/docs/lacci.md +121 -0
  30. data/docs/scarpe_shoes_incompatibilities.md +71 -0
  31. data/docs/shoes_and_display_events.md +55 -0
  32. data/docs/shoes_implementations.md +79 -0
  33. data/docs/static/manual.md +5 -0
  34. data/docs/static/scarpe-logo.png +0 -0
  35. data/docs/timeouts_and_handlers.md +66 -0
  36. data/docs/web_archaeology.md +76 -0
  37. data/examples/background_with_image.rb +14 -5
  38. data/examples/bloopsaphone/working/feepogram.rb +1 -1
  39. data/examples/bloopsaphone/working/le_dance_des_rubis.rb +135 -0
  40. data/examples/bloopsaphone/working/pixel_dreams_in_ruby.rb +131 -0
  41. data/examples/bloopsaphone/working/type_rebellion.rb +157 -0
  42. data/examples/border.rb +1 -1
  43. data/examples/internal_link_navigation.rb +19 -0
  44. data/examples/page_navigation_single_app.rb +42 -0
  45. data/examples/shoes_subclass_app.rb +25 -0
  46. data/examples/url_routing_example.rb +67 -0
  47. data/lacci/Gemfile +0 -2
  48. data/lacci/Gemfile.lock +4 -32
  49. data/lacci/lacci.gemspec +1 -1
  50. data/lacci/lib/lacci/version.rb +1 -1
  51. data/lacci/lib/scarpe/niente/app.rb +12 -1
  52. data/lacci/lib/scarpe/niente/shoes_spec.rb +4 -5
  53. data/lacci/lib/scarpe/niente.rb +1 -0
  54. data/lacci/lib/shoes/app.rb +166 -61
  55. data/lacci/lib/shoes/constants.rb +1 -0
  56. data/lacci/lib/shoes/drawable.rb +35 -19
  57. data/lacci/lib/shoes/drawables/arc.rb +2 -2
  58. data/lacci/lib/shoes/drawables/arrow.rb +2 -2
  59. data/lacci/lib/shoes/drawables/border.rb +1 -1
  60. data/lacci/lib/shoes/drawables/button.rb +1 -1
  61. data/lacci/lib/shoes/drawables/edit_line.rb +1 -1
  62. data/lacci/lib/shoes/drawables/flow.rb +1 -1
  63. data/lacci/lib/shoes/drawables/line.rb +2 -2
  64. data/lacci/lib/shoes/drawables/link.rb +11 -1
  65. data/lacci/lib/shoes/drawables/oval.rb +2 -2
  66. data/lacci/lib/shoes/drawables/rect.rb +2 -2
  67. data/lacci/lib/shoes/drawables/shape.rb +2 -2
  68. data/lacci/lib/shoes/drawables/slot.rb +5 -3
  69. data/lacci/lib/shoes/drawables/stack.rb +1 -1
  70. data/lacci/lib/shoes/drawables/star.rb +1 -1
  71. data/lacci/lib/shoes/drawables/widget.rb +1 -1
  72. data/lacci/lib/shoes.rb +94 -17
  73. data/lacci/test/test_margin_helper.rb +1 -1
  74. data/lacci/test/test_niente_test_infra.rb +14 -0
  75. data/lacci/test/test_shoes_errors.rb +15 -13
  76. data/lib/scarpe/assets.rb +2 -1
  77. data/lib/scarpe/shoes_spec.rb +2 -1
  78. data/lib/scarpe/version.rb +1 -1
  79. data/lib/scarpe/wv/edit_line.rb +2 -2
  80. data/lib/scarpe/wv.rb +8 -1
  81. data/scarpe-components/Gemfile +0 -2
  82. data/scarpe-components/Gemfile.lock +4 -34
  83. data/scarpe-components/lib/scarpe/components/calzini/misc.rb +10 -2
  84. data/scarpe-components/lib/scarpe/components/calzini/para.rb +6 -1
  85. data/scarpe-components/lib/scarpe/components/calzini/slots.rb +2 -0
  86. data/scarpe-components/lib/scarpe/components/port_helpers.rb +30 -0
  87. data/scarpe-components/lib/scarpe/components/version.rb +1 -1
  88. data/scarpe-components/scarpe-components.gemspec +1 -1
  89. data/scarpe-components/test/test_port_helpers.rb +12 -0
  90. metadata +60 -22
  91. data/.rubocop.yml +0 -94
@@ -0,0 +1,55 @@
1
+ ---
2
+ layout: default
3
+ title: shoes and display events
4
+ ---
5
+
6
+ # Shoes and Display Events
7
+
8
+ This document covers how Scarpe handles events and display updates in relation to the original Shoes implementation.
9
+
10
+ ## Event Handling
11
+
12
+ Scarpe implements event handling in a way that maintains compatibility with Shoes while providing modern features:
13
+
14
+ 1. **Event Types**
15
+ - Mouse events (click, hover, etc.)
16
+ - Keyboard events
17
+ - Window events
18
+ - Custom events
19
+
20
+ 2. **Event Flow**
21
+ - Events are captured in the display service
22
+ - Processed through the event loop
23
+ - Dispatched to appropriate handlers
24
+
25
+ ## Synchronous vs Asynchronous
26
+
27
+ Scarpe supports both synchronous and asynchronous event handling:
28
+
29
+ ### Synchronous Events
30
+ - Direct user interactions
31
+ - Immediate UI updates
32
+ - Traditional Shoes-style callbacks
33
+
34
+ ### Asynchronous Events
35
+ - Background operations
36
+ - Network requests
37
+ - Long-running computations
38
+
39
+ ## Display Updates
40
+
41
+ Display updates in Scarpe follow a specific pattern:
42
+
43
+ 1. State changes trigger update events
44
+ 2. Updates are batched when possible
45
+ 3. Changes are applied atomically
46
+ 4. The display service reflects changes efficiently
47
+
48
+ ## Compatibility Notes
49
+
50
+ While maintaining compatibility with Shoes, Scarpe introduces some modern improvements:
51
+
52
+ - Better event queueing
53
+ - More efficient update batching
54
+ - Enhanced error handling
55
+ - Improved async support
@@ -0,0 +1,79 @@
1
+ ---
2
+ layout: default
3
+ title: shoes implementations
4
+ ---
5
+
6
+ # Shoes Implementations
7
+
8
+ This document covers various Shoes implementations and how Scarpe relates to them.
9
+
10
+ ## Historical Implementations
11
+
12
+ 1. **Original Shoes**
13
+ - Written in C/Ruby
14
+ - Created by _why the lucky stiff
15
+ - Native GUI implementation
16
+
17
+ 2. **Green Shoes**
18
+ - Pure Ruby implementation
19
+ - GTK+ based
20
+ - Simplified architecture
21
+
22
+ 3. **Purple Shoes**
23
+ - Windows-specific version
24
+ - WinForms based
25
+ - Limited platform support
26
+
27
+ ## Modern Implementations
28
+
29
+ 1. **Scarpe**
30
+ - Web-based implementation
31
+ - Modern architecture
32
+ - Enhanced features
33
+
34
+ 2. **Other Current Projects**
35
+ - Various community efforts
36
+ - Different approach focuses
37
+ - Platform-specific versions
38
+
39
+ ## Implementation Comparisons
40
+
41
+ Key differences between implementations:
42
+
43
+ 1. **Architecture**
44
+ - Display handling
45
+ - Event systems
46
+ - State management
47
+
48
+ 2. **Features**
49
+ - UI components
50
+ - Drawing capabilities
51
+ - Platform integration
52
+
53
+ ## Learning from History
54
+
55
+ Lessons from previous implementations:
56
+
57
+ 1. **What Worked**
58
+ - Simple API design
59
+ - Flexible layouts
60
+ - Ruby-like syntax
61
+
62
+ 2. **What Needed Improvement**
63
+ - Event handling
64
+ - State management
65
+ - Cross-platform support
66
+
67
+ ## Future Directions
68
+
69
+ Areas for continued development:
70
+
71
+ 1. **Modern Features**
72
+ - Better async support
73
+ - Enhanced components
74
+ - Improved tooling
75
+
76
+ 2. **Community Focus**
77
+ - Documentation
78
+ - Examples
79
+ - Learning resources
@@ -1,3 +1,8 @@
1
+ ---
2
+ layout: default
3
+ title: The Shoes Manual
4
+ ---
5
+
1
6
  # Hello!
2
7
 
3
8
  Shoes is a tiny graphics toolkit. It's simple and straightforward. Shoes was
Binary file
@@ -0,0 +1,66 @@
1
+ ---
2
+ layout: default
3
+ title: timeouts and handlers
4
+ ---
5
+
6
+ # Timeouts and Handlers
7
+
8
+ This document explains how Scarpe manages timeouts and event handlers within its cooperative evented approach.
9
+
10
+ ## Timeout Management
11
+
12
+ Scarpe implements timeouts with these key considerations:
13
+
14
+ 1. **Cooperative Nature**
15
+ - Timeouts don't interrupt execution
16
+ - They're processed when the event loop is ready
17
+ - Timing is approximate, not exact
18
+
19
+ 2. **Implementation**
20
+ ```ruby
21
+ def after(milliseconds, &block)
22
+ register_timeout(Time.now + (milliseconds / 1000.0), block)
23
+ end
24
+ ```
25
+
26
+ ## Event Handlers
27
+
28
+ Event handlers in Scarpe follow these principles:
29
+
30
+ 1. **Registration**
31
+ - Handlers are registered with specific events
32
+ - Multiple handlers can exist per event
33
+ - Order of execution is preserved
34
+
35
+ 2. **Execution**
36
+ - Handlers run in the main event loop
37
+ - They should be non-blocking when possible
38
+ - Long operations should be broken up
39
+
40
+ ## Restrictions
41
+
42
+ The cooperative approach has some important restrictions:
43
+
44
+ 1. **No Preemption**
45
+ - Long-running handlers block other events
46
+ - Timeouts may be delayed
47
+ - UI updates wait for handlers to complete
48
+
49
+ 2. **Best Practices**
50
+ - Keep handlers short
51
+ - Use async for long operations
52
+ - Break up complex tasks
53
+
54
+ ## Error Handling
55
+
56
+ Handlers include error management:
57
+
58
+ 1. **Exception Catching**
59
+ - Errors don't crash the event loop
60
+ - Exceptions are logged appropriately
61
+ - Error handlers can be registered
62
+
63
+ 2. **Recovery**
64
+ - System can recover from handler errors
65
+ - State remains consistent
66
+ - Other handlers continue to work
@@ -0,0 +1,76 @@
1
+ ---
2
+ layout: default
3
+ title: web archaeology
4
+ ---
5
+
6
+ # Web Archaeology
7
+
8
+ This document catalogs various online sources of Shoes-related information, preserving important historical context.
9
+
10
+ ## Historical Sources
11
+
12
+ 1. **_why's Work**
13
+ - Original Shoes documentation
14
+ - Blog posts and tutorials
15
+ - Code examples and demos
16
+
17
+ 2. **Community Resources**
18
+ - Early forum discussions
19
+ - Mailing list archives
20
+ - Wiki pages
21
+
22
+ ## Code Archives
23
+
24
+ Important code repositories:
25
+
26
+ 1. **Original Shoes**
27
+ - GitHub mirrors
28
+ - Historical versions
29
+ - Community forks
30
+
31
+ 2. **Related Projects**
32
+ - Green Shoes
33
+ - Purple Shoes
34
+ - Other implementations
35
+
36
+ ## Documentation Archives
37
+
38
+ Preserved documentation:
39
+
40
+ 1. **Official Docs**
41
+ - Original manuals
42
+ - Tutorial content
43
+ - API references
44
+
45
+ 2. **Community Guides**
46
+ - Blog posts
47
+ - Tutorials
48
+ - Example collections
49
+
50
+ ## Learning Resources
51
+
52
+ Educational materials:
53
+
54
+ 1. **Tutorials**
55
+ - Getting started guides
56
+ - Advanced topics
57
+ - Example applications
58
+
59
+ 2. **Reference Materials**
60
+ - API documentation
61
+ - Design principles
62
+ - Best practices
63
+
64
+ ## Historical Context
65
+
66
+ Understanding Shoes' evolution:
67
+
68
+ 1. **Timeline**
69
+ - Key developments
70
+ - Major releases
71
+ - Community milestones
72
+
73
+ 2. **Impact**
74
+ - Influence on Ruby
75
+ - GUI development
76
+ - Community growth
@@ -1,16 +1,25 @@
1
1
  Shoes.app do
2
2
 
3
- stack width:100, height:100 do
4
- background "docs/static/avatar.png"
5
- border blue ,strokewidth: 4
3
+ # Local file (path relative to this script)
4
+ stack width: 100, height: 100 do
5
+ background "../docs/static/avatar.png"
6
+ border blue, strokewidth: 4
6
7
  end
7
8
 
8
- stack width:100, height:100 do
9
+ # Solid color
10
+ stack width: 100, height: 100 do
9
11
  background red
10
12
  end
11
13
 
12
- stack width:100, height:100 do
14
+ # RGBA string
15
+ stack width: 100, height: 100 do
13
16
  background "rgba(255,200,0,255)"
14
17
  end
15
18
 
19
+ # Remote URL
20
+ stack width: 100, height: 100 do
21
+ background "http://shoesrb.com/manual/static/shoes-icon.png"
22
+ border green, strokewidth: 4
23
+ end
24
+
16
25
  end
@@ -58,7 +58,7 @@ class Feepogram
58
58
  @tracks.each do |sound_name, notes|
59
59
  bloops.tune @sounds[sound_name], notes
60
60
 
61
- #puts "#{sound_name}: #{notes.gsub(/\s+/, ' ')}"
61
+ puts "#{sound_name}: #{notes.gsub(/\s+/, ' ')}"
62
62
  end
63
63
 
64
64
  bloops.play
@@ -0,0 +1,135 @@
1
+ require_relative 'feepogram'
2
+
3
+ bloops = Bloops.new
4
+ bloops.tempo = 280
5
+
6
+ song = Feepogram.new(bloops) do
7
+ # Define our instruments
8
+ sound :kick, Bloops::SINE do |s|
9
+ s.volume = 0.9
10
+ s.punch = 0.4
11
+ s.sustain = 0.1
12
+ s.decay = 0.2
13
+ end
14
+
15
+ sound :snare, Bloops::NOISE do |s|
16
+ s.volume = 0.8
17
+ s.punch = 0.2
18
+ s.sustain = 0.05
19
+ s.decay = 0.25
20
+ end
21
+
22
+ sound :hat, Bloops::NOISE do |s|
23
+ s.volume = 0.4
24
+ s.punch = 0.1
25
+ s.sustain = 0.02
26
+ s.decay = 0.1
27
+ end
28
+
29
+ sound :synth_bass, Bloops::SAWTOOTH do |s|
30
+ s.volume = 0.7
31
+ s.sustain = 0.3
32
+ s.decay = 0.1
33
+ s.slide = 0.2
34
+ end
35
+
36
+ sound :lead, Bloops::SQUARE do |s|
37
+ s.volume = 0.6
38
+ s.punch = 0.3
39
+ s.sustain = 0.4
40
+ s.decay = 0.2
41
+ end
42
+
43
+ sound :pad, Bloops::SINE do |s|
44
+ s.volume = 0.5
45
+ s.sustain = 1.0
46
+ s.decay = 0.5
47
+ end
48
+
49
+ # Helper methods for our patterns
50
+ def basic_beat
51
+ kick " c 4 4 c 4 4 c 4 " * 4
52
+ snare " 4 4 c 4 4 4 c 4 " * 4
53
+ hat " c5 " * 32
54
+ end
55
+
56
+ def bass_line_a
57
+ synth_bass %{
58
+ c2 4 e2 4 f2 4 g2 4
59
+ c2 4 e2 4 f2 4 g2 4
60
+ a1 4 c2 4 d2 4 e2 4
61
+ f2 4 e2 4 d2 4 c2 4
62
+ }
63
+ end
64
+
65
+ def lead_melody_a
66
+ lead %{
67
+ 4 c4 e4 g4 4 c5 g4 e4
68
+ 4 c4 f4 a4 4 c5 a4 f4
69
+ 4 e4 g4 c5 4 e5 c5 g4
70
+ 4 d4 f4 a4 4 d5 a4 f4
71
+ }
72
+ end
73
+
74
+ def ambient_pad
75
+ pad %{
76
+ 1:c4 1:c4
77
+ 1:f4 1:f4
78
+ 1:g4 1:g4
79
+ 1:e4 1:e4
80
+ }
81
+ end
82
+
83
+ # Structure our song
84
+ def intro
85
+ 2.times do
86
+ phrase do
87
+ basic_beat
88
+ bass_line_a
89
+ end
90
+ end
91
+ end
92
+
93
+ def verse
94
+ 2.times do
95
+ phrase do
96
+ basic_beat
97
+ bass_line_a
98
+ lead_melody_a
99
+ end
100
+ end
101
+ end
102
+
103
+ def bridge
104
+ phrase do
105
+ kick " c 4 4 4 " * 8
106
+ snare " 4 4 c 4 " * 8
107
+ hat " c5 " * 16
108
+ ambient_pad
109
+ end
110
+ end
111
+
112
+ def outro
113
+ phrase do
114
+ basic_beat
115
+ bass_line_a
116
+ lead_melody_a
117
+ ambient_pad
118
+ end
119
+
120
+ phrase do
121
+ kick "c"
122
+ synth_bass "c2"
123
+ pad "1:c4"
124
+ end
125
+ end
126
+
127
+ # Play the composition
128
+ intro
129
+ verse
130
+ bridge
131
+ verse
132
+ outro
133
+ end
134
+
135
+ song.play
@@ -0,0 +1,131 @@
1
+ require_relative 'feepogram'
2
+
3
+ bloops = Bloops.new
4
+ bloops.tempo = 160 # Slower tempo for dreamy feel
5
+
6
+ song = Feepogram.new(bloops) do
7
+ # Soft percussion
8
+ sound :soft_kick, Bloops::SINE do |s|
9
+ s.volume = 0.3
10
+ s.punch = 0.15
11
+ s.sustain = 0.1
12
+ s.decay = 0.3
13
+ end
14
+
15
+ sound :chimes, Bloops::SINE do |s|
16
+ s.volume = 0.35
17
+ s.punch = 0.1
18
+ s.sustain = 0.8
19
+ s.decay = 0.6
20
+ s.slide = 0.1
21
+ end
22
+
23
+ # Main melody instrument
24
+ sound :crystal, Bloops::SQUARE do |s|
25
+ s.volume = 0.45
26
+ s.punch = 0.1
27
+ s.sustain = 0.4
28
+ s.decay = 0.3
29
+ s.phase = 0.3
30
+ end
31
+
32
+ # Sparkly accent notes
33
+ sound :sparkle, Bloops::SQUARE do |s|
34
+ s.volume = 0.25
35
+ s.punch = 0.1
36
+ s.sustain = 0.1
37
+ s.decay = 0.4
38
+ s.phase = 0.2
39
+ s.lpf = 0.6
40
+ end
41
+
42
+ # Warm bass pad
43
+ sound :dream_pad, Bloops::SINE do |s|
44
+ s.volume = 0.25
45
+ s.sustain = 0.6
46
+ s.decay = 0.4
47
+ s.slide = 0.1
48
+ s.lpf = 0.4
49
+ end
50
+
51
+ def gentle_rhythm
52
+ soft_kick " c 4 4 4 " * 8
53
+ chimes " 4 c6 4 c6 " * 4
54
+ end
55
+
56
+ def dream_bass
57
+ dream_pad %{
58
+ 2:c3 2:g3
59
+ 2:a3 2:e3
60
+ 2:f3 2:c3
61
+ 2:g3 2:e3
62
+ }
63
+ end
64
+
65
+ def main_melody
66
+ crystal %{
67
+ c5 4 g5 4 e5 4 c6 g5
68
+ a5 4 e5 4 c5 4 g5 4
69
+ f5 4 c6 4 a5 4 f5 e5
70
+ g5 4 e5 4 c5 4 4 4
71
+ }
72
+ end
73
+
74
+ def sparkle_accent
75
+ sparkle %{
76
+ 4 4 c7 4 4 4 e7 4
77
+ 4 4 g6 4 4 4 c7 4
78
+ 4 4 a6 4 4 4 f7 4
79
+ 4 4 e7 4 4 4 g6 4
80
+ }
81
+ end
82
+
83
+ def title_theme
84
+ phrase do
85
+ dream_bass
86
+ gentle_rhythm
87
+ end
88
+
89
+ phrase do
90
+ dream_bass
91
+ gentle_rhythm
92
+ main_melody
93
+ end
94
+
95
+ phrase do
96
+ dream_bass
97
+ gentle_rhythm
98
+ main_melody
99
+ sparkle_accent
100
+ end
101
+ end
102
+
103
+ def peaceful_bridge
104
+ phrase do
105
+ dream_pad %{
106
+ 4:c4 4:e4
107
+ 4:f4 4:g4
108
+ }
109
+ sparkle " c6 e6 g6 c7 " * 4
110
+ end
111
+ end
112
+
113
+ def outro_fade
114
+ phrase do
115
+ dream_bass
116
+ crystal %{
117
+ c6 g5 e5 c5
118
+ 4 4 4 4
119
+ }
120
+ sparkle " c7 g6 e6 c6 "
121
+ end
122
+ end
123
+
124
+ # The composition
125
+ 2.times { title_theme }
126
+ peaceful_bridge
127
+ title_theme
128
+ outro_fade
129
+ end
130
+
131
+ song.play