clogs 0.1.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.
data/lib/clogs.rb ADDED
@@ -0,0 +1,92 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "shoes"
4
+
5
+ require_relative "clogs/log"
6
+
7
+ # Lacci expects a logging implementation to be plugged in before any Shoes
8
+ # object is built.
9
+ Shoes::Log.instance = Clogs::Log.new
10
+ Shoes::Log.configure_logger(ENV["SCARPE_DEBUG"] ? Shoes::Log::DEFAULT_DEBUG_LOG_CONFIG : Shoes::Log::DEFAULT_LOG_CONFIG)
11
+
12
+ require_relative "clogs/version"
13
+ require_relative "clogs/ui"
14
+ require_relative "clogs/style"
15
+ require_relative "clogs/painter"
16
+ require_relative "clogs/text"
17
+ require_relative "clogs/paragraph"
18
+ require_relative "clogs/canvas"
19
+ require_relative "clogs/clipboard"
20
+ require_relative "clogs/dialogs"
21
+ require_relative "clogs/drawable"
22
+
23
+ # Clogs: Shoes, worn over libui.
24
+ #
25
+ # Shoes is _why the lucky stiff's tiny Ruby GUI toolkit. Clogs implements the
26
+ # Shoes drawing and layout model on top of libui, a small cross-platform native
27
+ # widget library, so Shoes programs run on plain CRuby -- no browser engine, no
28
+ # JVM, one small native dependency.
29
+ #
30
+ # The Shoes API itself comes from Lacci, the display-independent half of
31
+ # Scarpe. Clogs is a Lacci *display service*: Lacci owns the DSL and the
32
+ # drawable tree, Clogs owns the pixels. Run an app with:
33
+ #
34
+ # SCARPE_DISPLAY_SERVICE=clogs ruby my_app.rb
35
+ #
36
+ # or simply `require "clogs"` before `Shoes.app`.
37
+ module Clogs
38
+ class << self
39
+ # libui takes a font *family* name and resolves it per platform.
40
+ def default_font_family
41
+ @default_font_family ||= case RUBY_PLATFORM
42
+ when /darwin/ then "Helvetica"
43
+ when /mingw|mswin/ then "Segoe UI"
44
+ else "Sans"
45
+ end
46
+ end
47
+
48
+ attr_writer :default_font_family
49
+
50
+ def default_font_size
51
+ @default_font_size ||= 14
52
+ end
53
+
54
+ attr_writer :default_font_size
55
+
56
+ def monospace_font_family
57
+ @monospace_font_family ||= case RUBY_PLATFORM
58
+ when /darwin/ then "Monaco"
59
+ when /mingw|mswin/ then "Consolas"
60
+ else "Monospace"
61
+ end
62
+ end
63
+
64
+ attr_writer :monospace_font_family
65
+ end
66
+ end
67
+
68
+ require_relative "clogs/drawables/slot"
69
+ require_relative "clogs/drawables/text"
70
+ require_relative "clogs/drawables/shapes"
71
+ require_relative "clogs/drawables/controls"
72
+ require_relative "clogs/drawables/image"
73
+ require_relative "clogs/drawables/misc"
74
+ require_relative "clogs/app"
75
+ require_relative "clogs/display_service"
76
+ require_relative "clogs/lacci_compat"
77
+
78
+ Shoes::DisplayService.set_display_service_class(Clogs::DisplayService)
79
+
80
+ # Lacci 0.5.0's builtins (`ask`, `confirm`, `ask_open_file`, ...) always return
81
+ # nil: there is no channel for a display service to answer. Shoes programs very
82
+ # much expect an answer, so Clogs supplies one. Newer Lacci versions have their
83
+ # own response mechanism, and we leave those alone.
84
+ unless Shoes::DisplayService.respond_to?(:consume_builtin_response)
85
+ module Shoes::Builtins
86
+ def shoes_builtin(cmd_name, *args)
87
+ Clogs::App.builtin_response = nil
88
+ Shoes::DisplayService.dispatch_event("builtin", nil, cmd_name, args)
89
+ Clogs::App.builtin_response
90
+ end
91
+ end
92
+ end
metadata ADDED
@@ -0,0 +1,109 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: clogs
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Hackety Hack contributors
8
+ bindir: bin
9
+ cert_chain: []
10
+ date: 1980-01-02 00:00:00.000000000 Z
11
+ dependencies:
12
+ - !ruby/object:Gem::Dependency
13
+ name: lacci
14
+ requirement: !ruby/object:Gem::Requirement
15
+ requirements:
16
+ - - ">="
17
+ - !ruby/object:Gem::Version
18
+ version: 0.5.0
19
+ type: :runtime
20
+ prerelease: false
21
+ version_requirements: !ruby/object:Gem::Requirement
22
+ requirements:
23
+ - - ">="
24
+ - !ruby/object:Gem::Version
25
+ version: 0.5.0
26
+ - !ruby/object:Gem::Dependency
27
+ name: libui
28
+ requirement: !ruby/object:Gem::Requirement
29
+ requirements:
30
+ - - "~>"
31
+ - !ruby/object:Gem::Version
32
+ version: '0.2'
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - "~>"
38
+ - !ruby/object:Gem::Version
39
+ version: '0.2'
40
+ - !ruby/object:Gem::Dependency
41
+ name: chunky_png
42
+ requirement: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - "~>"
45
+ - !ruby/object:Gem::Version
46
+ version: '1.4'
47
+ type: :runtime
48
+ prerelease: false
49
+ version_requirements: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - "~>"
52
+ - !ruby/object:Gem::Version
53
+ version: '1.4'
54
+ description: |
55
+ Clogs runs Shoes programs on plain CRuby using libui, a small
56
+ cross-platform native widget library. It implements the Shoes drawing and
57
+ layout model as a display service for Lacci, the display-independent half
58
+ of Scarpe, so it needs neither a browser engine nor a JVM.
59
+ executables: []
60
+ extensions: []
61
+ extra_rdoc_files: []
62
+ files:
63
+ - README.md
64
+ - examples/kitchen_sink.rb
65
+ - lib/clogs.rb
66
+ - lib/clogs/app.rb
67
+ - lib/clogs/canvas.rb
68
+ - lib/clogs/clipboard.rb
69
+ - lib/clogs/dialogs.rb
70
+ - lib/clogs/display_service.rb
71
+ - lib/clogs/drawable.rb
72
+ - lib/clogs/drawables/controls.rb
73
+ - lib/clogs/drawables/image.rb
74
+ - lib/clogs/drawables/misc.rb
75
+ - lib/clogs/drawables/shapes.rb
76
+ - lib/clogs/drawables/slot.rb
77
+ - lib/clogs/drawables/text.rb
78
+ - lib/clogs/lacci_compat.rb
79
+ - lib/clogs/log.rb
80
+ - lib/clogs/painter.rb
81
+ - lib/clogs/paragraph.rb
82
+ - lib/clogs/style.rb
83
+ - lib/clogs/text.rb
84
+ - lib/clogs/ui.rb
85
+ - lib/clogs/version.rb
86
+ homepage: https://github.com/largo/hacketyhack
87
+ licenses:
88
+ - MIT
89
+ metadata:
90
+ homepage_uri: https://github.com/largo/hacketyhack
91
+ source_code_uri: https://github.com/largo/hacketyhack/tree/main/clogs
92
+ rdoc_options: []
93
+ require_paths:
94
+ - lib
95
+ required_ruby_version: !ruby/object:Gem::Requirement
96
+ requirements:
97
+ - - ">="
98
+ - !ruby/object:Gem::Version
99
+ version: 3.2.0
100
+ required_rubygems_version: !ruby/object:Gem::Requirement
101
+ requirements:
102
+ - - ">="
103
+ - !ruby/object:Gem::Version
104
+ version: '0'
105
+ requirements: []
106
+ rubygems_version: 3.6.7
107
+ specification_version: 4
108
+ summary: 'Shoes, worn over libui: a native display service for the Shoes GUI DSL'
109
+ test_files: []