glimmer-dsl-libui 0.11.1 → 0.11.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3089dc0655a6c58f1b514e61ee7994ad1e51949ac79556228832fea732302fea
4
- data.tar.gz: edeada4eafa026c2f1f6c4d10d581d8e2c416d87c66f142e9225aa809c72322a
3
+ metadata.gz: 9be2fa52f18acfaf245110441ec7c6d728cffd361f995b71f58a8e9e235c0846
4
+ data.tar.gz: b6f3cd15b385edc1839ff0da45cd22677723f1b8a91d947ad773a23a317f88bf
5
5
  SHA512:
6
- metadata.gz: 1a3b4bb480862eee93488bc703c7a32f4c21e7d7a80c2668f262833d8eed3600d7b6169e2c3670666cb030cd94b547b3055df79289679f87618ff411cc8dc729
7
- data.tar.gz: '0294d1117c0fbfec011f358d2570adb3ea78b95cd656e9b5803467d9eef8e7f9e6e8f615220a1b46c094779b634106ccd31965d00e9dc9365e305d710a5d7c4d'
6
+ metadata.gz: 6f6ad39350772e169b0500fcb727567d884c5fab0f06945eb7e25a20c45322083d70f7b9ad8b636b7dfef12ede12afce87dce480e819567a414ad20dbf77904c
7
+ data.tar.gz: 25eabc97ed6588b7ba74d97bd352bb80a41afbcecb2e4f8d7f26f101753b81062fcfc2503d61292997ee82f856d8a5bc0b3786fd227b8a6f248da36d40a82aac
data/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # Change Log
2
2
 
3
+ ## 0.11.3
4
+
5
+ - Support nesting `on_mouse_*` listeners under `text`
6
+
7
+ ## 0.11.2
8
+
9
+ - Fix issue with getting error when nesting property content under custom controls/shapes/windows (fixes `examples/basic_custom_shape.rb`)
10
+
3
11
  ## 0.11.1
4
12
 
5
13
  - Refactor `examples/dynamic_form.rb`
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # [<img src="https://raw.githubusercontent.com/AndyObtiva/glimmer/master/images/glimmer-logo-hi-res.png" height=85 />](https://github.com/AndyObtiva/glimmer) Glimmer DSL for LibUI 0.11.1
1
+ # [<img src="https://raw.githubusercontent.com/AndyObtiva/glimmer/master/images/glimmer-logo-hi-res.png" height=85 />](https://github.com/AndyObtiva/glimmer) Glimmer DSL for LibUI 0.11.3
2
2
  ## Prerequisite-Free Ruby Desktop Development Cross-Platform Native GUI Library ([Fukuoka Award Winning](http://www.digitalfukuoka.jp/topics/187?locale=ja))
3
3
  ### The Quickest Way From Zero To GUI
4
4
  [![Gem Version](https://badge.fury.io/rb/glimmer-dsl-libui.svg)](http://badge.fury.io/rb/glimmer-dsl-libui)
@@ -431,7 +431,7 @@ gem install glimmer-dsl-libui
431
431
  Or install via Bundler `Gemfile`:
432
432
 
433
433
  ```ruby
434
- gem 'glimmer-dsl-libui', '~> 0.11.1'
434
+ gem 'glimmer-dsl-libui', '~> 0.11.3'
435
435
  ```
436
436
 
437
437
  Test that installation worked by running the [Glimmer Meta-Example](#examples):
@@ -636,6 +636,8 @@ Mac | Windows | Linux
636
636
 
637
637
  Application scaffolding enables automatically generating the directories/files of a new desktop GUI application that follows the MVC architecture and can be packaged as a Ruby gem that includes an executable script for running the app conveniently. It also ensures that software engineers follow the recommended Glimmer DSL for LibUI conventions and best practices. Application Scaffolding greatly improves software engineering productivity when building desktop applications with [Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui).
638
638
 
639
+ Application Scaffolding relies on the [juwelier](https://rubygems.org/gems/juwelier) Ruby gem, which expects having a local Git config (global settings in `~/.gitconfig`) of [`user.name`](https://docs.github.com/en/get-started/getting-started-with-git/setting-your-username-in-git#setting-your-git-username-for-every-repository-on-your-computer), [`user.email`](https://docs.github.com/en/account-and-profile/setting-up-and-managing-your-personal-account-on-github/managing-email-preferences/setting-your-commit-email-address#setting-your-email-address-for-every-repository-on-your-computer), and `github.user`.
640
+
639
641
  Scaffold Glimmer DSL for LibUI application with this command:
640
642
 
641
643
  ```
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.11.1
1
+ 0.11.3
Binary file
@@ -32,8 +32,9 @@ module Glimmer
32
32
  # Follows the Proxy Design Pattern
33
33
  class TextProxy < ControlProxy
34
34
  include Parent
35
+ include PerfectShaped
35
36
  prepend Transformable
36
-
37
+
37
38
  def initialize(keyword, parent, args, &block)
38
39
  @keyword = keyword
39
40
  @parent_proxy = parent
@@ -156,6 +157,69 @@ module Glimmer
156
157
  @draw_text_layout_params
157
158
  end
158
159
 
160
+ def area_proxy
161
+ # TODO eventually reuse this method from Shape
162
+ find_parent_in_ancestors { |parent| parent.nil? || parent.is_a?(ControlProxy::AreaProxy) }
163
+ end
164
+
165
+ def find_parent_in_ancestors(&condition)
166
+ # TODO eventually reuse this method from Shape
167
+ found = self
168
+ until condition.call(found)
169
+ # TODO in the future, support nesting under composite shape where there is parent instead of parent_proxy
170
+ # found = found.respond_to?(:parent_proxy) ? found.parent_proxy : found.parent
171
+ found = found.parent_proxy
172
+ end
173
+ found
174
+ end
175
+
176
+ def can_handle_listener?(listener_name)
177
+ area_proxy.can_handle_listener?(listener_name)
178
+ end
179
+
180
+ def handle_listener(listener_name, &listener)
181
+ area_proxy.handle_listener(listener_name) do |event|
182
+ listener.call(event) if include?(event[:x], event[:y])
183
+ end
184
+ end
185
+
186
+ def perfect_shape
187
+ the_perfect_shape_dependencies = perfect_shape_dependencies
188
+ if the_perfect_shape_dependencies != @perfect_shape_dependencies
189
+ absolute_x, absolute_y, width, height = @perfect_shape_dependencies = the_perfect_shape_dependencies
190
+ @perfect_shape = PerfectShape::Rectangle.new(x: absolute_x, y: absolute_y, width: width, height: height)
191
+ end
192
+ @perfect_shape
193
+ end
194
+
195
+ def perfect_shape_dependencies
196
+ # TODO support absolute_x and absolute_y with relative positioning in the future
197
+ absolute_x = x
198
+ absolute_y = y
199
+ [absolute_x, absolute_y, extent_width, extent_height]
200
+ end
201
+
202
+ def extent_width
203
+ if @extent_width.to_f > 0
204
+ @extent_width
205
+ else
206
+ width
207
+ end
208
+ end
209
+
210
+ def extent_height
211
+ if @extent_height.to_f > 0
212
+ @extent_height
213
+ else
214
+ children_max_size = children.map(&:font).map {|font| font[:size] if font.respond_to?(:[]) }.compact.max
215
+ if children_max_size.to_f > 0
216
+ children_max_size
217
+ else
218
+ @default_font[:size]
219
+ end
220
+ end
221
+ end
222
+
159
223
  private
160
224
 
161
225
  def build_control
@@ -169,6 +233,16 @@ module Glimmer
169
233
  draw_brush.B = (draw_brush_args[:b] || draw_brush_args[:blue]).to_f / 255.0
170
234
  draw_brush.A = (draw_brush_args[:a] || draw_brush_args[:alpha])
171
235
  end
236
+
237
+ def calculate_extents
238
+ # TODO fix implementation once libui binding project responds about this
239
+ # as it always returns 0,0 right now
240
+ extent_width = Fiddle::Pointer.malloc(Fiddle::SIZEOF_DOUBLE*8)
241
+ extent_height = Fiddle::Pointer.malloc(Fiddle::SIZEOF_DOUBLE*8)
242
+ ::LibUI.draw_text_layout_extents(@libui, extent_width, extent_height)
243
+ @extent_width = extent_width[0, Fiddle::SIZEOF_DOUBLE*8].unpack1('i')
244
+ @extent_height = extent_height[0, Fiddle::SIZEOF_DOUBLE*8].unpack1('i')
245
+ end
172
246
  end
173
247
  end
174
248
  end
@@ -104,11 +104,11 @@ module Glimmer
104
104
 
105
105
  def content_size(*args)
106
106
  if args.empty?
107
- width = Fiddle::Pointer.malloc(8)
108
- height = Fiddle::Pointer.malloc(8)
107
+ width = Fiddle::Pointer.malloc(64)
108
+ height = Fiddle::Pointer.malloc(64)
109
109
  ::LibUI.window_content_size(@libui, width, height)
110
- width = width[0, 8].unpack1('i')
111
- height = height[0, 8].unpack1('i')
110
+ width = width[0, 64].unpack1('i')
111
+ height = height[0, 64].unpack1('i')
112
112
  [width, height]
113
113
  else
114
114
  args = args.first if args.size == 1 && args.first.is_a?(Array)
@@ -52,6 +52,16 @@ module Glimmer
52
52
  result ||= can_handle_listener?(method_name)
53
53
  result ||= @body_root.respond_to?(method_name, *args, &block)
54
54
  end
55
+
56
+ # Returns content block if used as an attribute reader (no args)
57
+ # Otherwise, if a block is passed, it adds it as content to this custom control
58
+ def content(&block)
59
+ if block_given?
60
+ Glimmer::DSL::Engine.add_content(self, Glimmer::DSL::Libui::CustomControlExpression.new, self.class.keyword, &block)
61
+ else
62
+ @content
63
+ end
64
+ end
55
65
  end
56
66
 
57
67
  super_module_included do |klass|
@@ -233,16 +243,6 @@ module Glimmer
233
243
  !method(method_name)&.source_location&.first&.include?('glimmer/dsl/engine.rb') and
234
244
  !method(method_name)&.source_location&.first&.include?('glimmer/libui/control_proxy.rb')
235
245
  end
236
-
237
- # Returns content block if used as an attribute reader (no args)
238
- # Otherwise, if a block is passed, it adds it as content to this custom control
239
- def content(&block)
240
- if block_given?
241
- Glimmer::DSL::Engine.add_content(self, Glimmer::DSL::Libui::CustomControlExpression.new, self.class.keyword, &block)
242
- else
243
- @content
244
- end
245
- end
246
246
 
247
247
  private
248
248
 
@@ -52,6 +52,16 @@ module Glimmer
52
52
  result ||= can_handle_listener?(method_name)
53
53
  result ||= @body_root.respond_to?(method_name, *args, &block)
54
54
  end
55
+
56
+ # Returns content block if used as an attribute reader (no args)
57
+ # Otherwise, if a block is passed, it adds it as content to this custom shape
58
+ def content(&block)
59
+ if block_given?
60
+ Glimmer::DSL::Engine.add_content(self, Glimmer::DSL::Libui::CustomShapeExpression.new, self.class.keyword, &block)
61
+ else
62
+ @content
63
+ end
64
+ end
55
65
  end
56
66
 
57
67
  super_module_included do |klass|
@@ -230,16 +240,6 @@ module Glimmer
230
240
  !method(method_name)&.source_location&.first&.include?('glimmer/dsl/engine.rb') and
231
241
  !method(method_name)&.source_location&.first&.include?('glimmer/libui/shape.rb')
232
242
  end
233
-
234
- # Returns content block if used as an attribute reader (no args)
235
- # Otherwise, if a block is passed, it adds it as content to this custom shape
236
- def content(&block)
237
- if block_given?
238
- Glimmer::DSL::Engine.add_content(self, Glimmer::DSL::Libui::CustomShapeExpression.new, self.class.keyword, &block)
239
- else
240
- @content
241
- end
242
- end
243
243
 
244
244
  private
245
245
 
@@ -15,13 +15,14 @@ module Glimmer
15
15
  # determining if a point lies on the outline (e.g. makes it easier to select
16
16
  # a shape by mouse)
17
17
  def contain?(*point, outline: false, distance_tolerance: 0)
18
+ # TODO inverse transform point with `uiDrawMatrixTransformPoint` before checking containment
18
19
  perfect_shape&.contain?(*point, outline: outline, distance_tolerance: distance_tolerance)
19
20
  end
20
21
 
21
22
  # Returns if shape includes point on the inside when filled
22
23
  # or if shape includes point on the outline when stroked
23
24
  def include?(*point)
24
- if fill.empty?
25
+ if respond_to?(:fill) && fill.empty?
25
26
  # TODO check if distance_tolerance should be half the thickness in case it is checked against both sides of out and in
26
27
  contain?(*point, outline: true, distance_tolerance: ((stroke[:thickness] || 1) - 1))
27
28
  else
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.11.1
4
+ version: 0.11.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andy Maleh
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-11-17 00:00:00.000000000 Z
11
+ date: 2023-11-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: glimmer