glimmer-dsl-libui 0.5.5 → 0.5.8

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,65 @@
1
+ # Copyright (c) 2021-2022 Andy Maleh
2
+ #
3
+ # Permission is hereby granted, free of charge, to any person obtaining
4
+ # a copy of this software and associated documentation files (the
5
+ # "Software"), to deal in the Software without restriction, including
6
+ # without limitation the rights to use, copy, modify, merge, publish,
7
+ # distribute, sublicense, and/or sell copies of the Software, and to
8
+ # permit persons to whom the Software is furnished to do so, subject to
9
+ # the following conditions:
10
+ #
11
+ # The above copyright notice and this permission notice shall be
12
+ # included in all copies or substantial portions of the Software.
13
+ #
14
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
+
22
+ require 'super_module'
23
+ require 'glimmer/libui/custom_control'
24
+ require 'glimmer/error'
25
+
26
+ module Glimmer
27
+ module LibUI
28
+ module CustomWindow
29
+ include SuperModule
30
+ include Glimmer::LibUI::CustomControl
31
+
32
+ class << self
33
+ def launch(*args, &content)
34
+ launched_custom_shell = send(keyword, *args, &content)
35
+ launched_custom_shell.show
36
+ end
37
+ end
38
+
39
+ def initialize(parent, *swt_constants, options, &content)
40
+ original_logger = Glimmer::Config.logger
41
+ require 'stringio'
42
+ Glimmer::Config.logger = Logger.new(StringIO.new)
43
+ super
44
+ Glimmer::Config.logger = original_logger
45
+ raise Glimmer::Error, 'Invalid custom window body root! Must be a window, another custom window, or a custom control with window as its body root!' unless body_root.is_a?(Glimmer::LibUI::ControlProxy::WindowProxy) || body_root.is_a?(Glimmer::LibUI::CustomWindow) || (body_root.is_a?(Glimmer::LibUI::CustomControl) && body_root.body_root.is_a?(Glimmer::LibUI::ControlProxy::WindowProxy))
46
+ end
47
+
48
+ # Classes may override
49
+ def show
50
+ body_root.show
51
+ end
52
+
53
+ # TODO consider using Forwardable instead
54
+ def destroy
55
+ body_root.destroy
56
+ end
57
+
58
+ def destroying?
59
+ body_root.destroying?
60
+ end
61
+ end
62
+
63
+ Application = CustomWindow
64
+ end
65
+ end
data/lib/glimmer/libui.rb CHANGED
@@ -80,11 +80,9 @@ module Glimmer
80
80
 
81
81
  def hex_to_rgb(value)
82
82
  if value.is_a?(String)
83
- value = "0x#{value[1..-1]}" if value.start_with?('#')
84
- if !value.start_with?('0x')
85
- value = value.chars.map {|char| [char, char]}.flatten.join if value.length == 3
86
- value = "0x#{value}"
87
- end
83
+ value = value[2..-1] if value.start_with?('0x')
84
+ value = value[1..-1] if value.start_with?('#')
85
+ value = value.chars.map {|char| [char, char]}.flatten.join if value.length == 3
88
86
  value = value.to_i(16)
89
87
  end
90
88
  if value.is_a?(Integer)
@@ -0,0 +1,39 @@
1
+ # Copyright (c) 2007-2022 Andy Maleh
2
+ #
3
+ # Permission is hereby granted, free of charge, to any person obtaining
4
+ # a copy of this software and associated documentation files (the
5
+ # "Software"), to deal in the Software without restriction, including
6
+ # without limitation the rights to use, copy, modify, merge, publish,
7
+ # distribute, sublicense, and/or sell copies of the Software, and to
8
+ # permit persons to whom the Software is furnished to do so, subject to
9
+ # the following conditions:
10
+ #
11
+ # The above copyright notice and this permission notice shall be
12
+ # included in all copies or substantial portions of the Software.
13
+ #
14
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
+
22
+ require 'delegate'
23
+
24
+ module Glimmer
25
+ class ProcTracker < DelegateClass(Proc)
26
+ def initialize(proc)
27
+ super(proc)
28
+ end
29
+
30
+ def call(*args)
31
+ __getobj__.call(*args)
32
+ @called = true
33
+ end
34
+
35
+ def called?
36
+ !!@called
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,7 @@
1
+ module Glimmer
2
+ class << self
3
+ def included(klass)
4
+ klass.extend(Glimmer)
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,29 @@
1
+ module Rouge
2
+ module Themes
3
+ # A port of the pastie style from Pygments.
4
+ # See https://bitbucket.org/birkenfeld/pygments-main/src/default/pygments/styles/pastie.py
5
+ class Glimmer < Github
6
+ name 'glimmer'
7
+ style Comment::Single, fg: [106,115,125], italic: true # Also, Comments
8
+ style Keyword::Pseudo, fg: [:dark_red]
9
+ style Keyword, fg: [:blue]
10
+ style Literal::String::Single, fg: [106,115,125] # Also, Comments
11
+ style Literal::String::Double, fg: [0,92,197]
12
+ style Literal::String::Escape, fg: [:red]
13
+ style Literal::Number::Integer, fg: [:blue]
14
+ style Literal::String::Interpol, fg: [:blue]
15
+ style Literal::String::Symbol, fg: [:dark_green]
16
+ style Literal::String, fg: [:dark_blue]
17
+ style Name::Builtin, fg: [215,58,73]
18
+ style Name::Class, fg: [3,47,98]
19
+ style Name::Namespace, fg: [3,47,98]
20
+ style Name::Constant, fg: [0,92,197]
21
+ style Name::Function, fg: [:blue]
22
+ style Name::Variable::Instance, fg: [227,98,9]
23
+ style Name, fg: [111,66,193] #purple
24
+ style Operator, fg: [:red]
25
+ style Punctuation, fg: [:blue]
26
+ style Text, fg: [75, 75, 75]
27
+ end
28
+ end
29
+ end
@@ -37,7 +37,7 @@ require 'libui'
37
37
 
38
38
  # Internal requires
39
39
  # require 'ext/glimmer/config'
40
- # require 'ext/glimmer'
40
+ require 'glimmer-dsl-libui/ext/glimmer'
41
41
  require 'glimmer/dsl/libui/dsl'
42
42
  require 'glimmer/libui'
43
43
  Glimmer::Config.loop_max_count = -1
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: glimmer-dsl-libui
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.5
4
+ version: 0.5.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andy Maleh
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-03-12 00:00:00.000000000 Z
11
+ date: 2022-03-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: glimmer
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 2.6.0
19
+ version: 2.7.1
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 2.6.0
26
+ version: 2.7.1
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: perfect-shape
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -38,6 +38,20 @@ dependencies:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: 1.0.1
41
+ - !ruby/object:Gem::Dependency
42
+ name: super_module
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: 1.4.1
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 1.4.1
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: os
43
57
  requirement: !ruby/object:Gem::Requirement
@@ -114,6 +128,26 @@ dependencies:
114
128
  - - '='
115
129
  - !ruby/object:Gem::Version
116
130
  version: 0.0.11
131
+ - !ruby/object:Gem::Dependency
132
+ name: rouge
133
+ requirement: !ruby/object:Gem::Requirement
134
+ requirements:
135
+ - - ">="
136
+ - !ruby/object:Gem::Version
137
+ version: 3.26.0
138
+ - - "<"
139
+ - !ruby/object:Gem::Version
140
+ version: 4.0.0
141
+ type: :runtime
142
+ prerelease: false
143
+ version_requirements: !ruby/object:Gem::Requirement
144
+ requirements:
145
+ - - ">="
146
+ - !ruby/object:Gem::Version
147
+ version: 3.26.0
148
+ - - "<"
149
+ - !ruby/object:Gem::Version
150
+ version: 4.0.0
117
151
  - !ruby/object:Gem::Dependency
118
152
  name: juwelier
119
153
  requirement: !ruby/object:Gem::Requirement
@@ -251,6 +285,7 @@ files:
251
285
  - examples/basic_area3.rb
252
286
  - examples/basic_area4.rb
253
287
  - examples/basic_button.rb
288
+ - examples/basic_code_area.rb
254
289
  - examples/basic_draw_text.rb
255
290
  - examples/basic_draw_text2.rb
256
291
  - examples/basic_entry.rb
@@ -281,6 +316,7 @@ files:
281
316
  - examples/basic_window.rb
282
317
  - examples/basic_window2.rb
283
318
  - examples/button_counter.rb
319
+ - examples/class_based_custom_controls.rb
284
320
  - examples/color_button.rb
285
321
  - examples/color_button2.rb
286
322
  - examples/color_the_circles.rb
@@ -314,8 +350,8 @@ files:
314
350
  - examples/login4.rb
315
351
  - examples/login5.rb
316
352
  - examples/meta_example.rb
317
- - examples/method_based_custom_keyword.rb
318
- - examples/method_based_custom_keyword2.rb
353
+ - examples/method_based_custom_controls.rb
354
+ - examples/method_based_custom_controls2.rb
319
355
  - examples/midi_player.rb
320
356
  - examples/midi_player2.rb
321
357
  - examples/midi_player3.rb
@@ -343,8 +379,11 @@ files:
343
379
  - icons/blank.png
344
380
  - icons/glimmer.png
345
381
  - lib/glimmer-dsl-libui.rb
382
+ - lib/glimmer-dsl-libui/ext/glimmer.rb
383
+ - lib/glimmer-dsl-libui/ext/rouge/theme/glimmer.rb
346
384
  - lib/glimmer/dsl/libui/bind_expression.rb
347
385
  - lib/glimmer/dsl/libui/control_expression.rb
386
+ - lib/glimmer/dsl/libui/custom_control_expression.rb
348
387
  - lib/glimmer/dsl/libui/data_binding_expression.rb
349
388
  - lib/glimmer/dsl/libui/dsl.rb
350
389
  - lib/glimmer/dsl/libui/file_expression.rb
@@ -426,6 +465,9 @@ files:
426
465
  - lib/glimmer/libui/control_proxy/transformable.rb
427
466
  - lib/glimmer/libui/control_proxy/triple_column.rb
428
467
  - lib/glimmer/libui/control_proxy/window_proxy.rb
468
+ - lib/glimmer/libui/custom_control.rb
469
+ - lib/glimmer/libui/custom_control/code_area.rb
470
+ - lib/glimmer/libui/custom_window.rb
429
471
  - lib/glimmer/libui/data_bindable.rb
430
472
  - lib/glimmer/libui/image_path_renderer.rb
431
473
  - lib/glimmer/libui/parent.rb
@@ -440,6 +482,7 @@ files:
440
482
  - lib/glimmer/libui/shape/polyline.rb
441
483
  - lib/glimmer/libui/shape/rectangle.rb
442
484
  - lib/glimmer/libui/shape/square.rb
485
+ - lib/glimmer/proc_tracker.rb
443
486
  - sounds/AlanWalker-Faded.mid
444
487
  - sounds/AlanWalker-SingMeToSleep.mid
445
488
  - sounds/CalvinHarris-Blame.mid
@@ -466,7 +509,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
466
509
  - !ruby/object:Gem::Version
467
510
  version: '0'
468
511
  requirements: []
469
- rubygems_version: 3.3.1
512
+ rubygems_version: 3.3.6
470
513
  signing_key:
471
514
  specification_version: 4
472
515
  summary: Glimmer DSL for LibUI