glimmer-dsl-libui 0.4.20 → 0.4.21

Sign up to get free protection for your applications and to get access to all the features.
Files changed (116) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +5 -0
  3. data/LICENSE.txt +1 -1
  4. data/README.md +38 -22
  5. data/VERSION +1 -1
  6. data/bin/girb_runner.rb +1 -1
  7. data/examples/area_based_custom_controls.rb +7 -3
  8. data/examples/snake/model/game.rb +18 -1
  9. data/examples/snake.rb +6 -2
  10. data/examples/snake2.rb +6 -2
  11. data/examples/tetris/model/block.rb +1 -1
  12. data/examples/tetris/model/game.rb +1 -1
  13. data/examples/tetris/model/past_game.rb +1 -1
  14. data/examples/tetris/model/tetromino.rb +1 -1
  15. data/examples/tetris.rb +1 -1
  16. data/examples/tic_tac_toe/board.rb +1 -1
  17. data/examples/tic_tac_toe/cell.rb +1 -1
  18. data/glimmer-dsl-libui.gemspec +0 -0
  19. data/lib/glimmer/dsl/libui/bind_expression.rb +1 -1
  20. data/lib/glimmer/dsl/libui/control_expression.rb +1 -1
  21. data/lib/glimmer/dsl/libui/data_binding_expression.rb +1 -1
  22. data/lib/glimmer/dsl/libui/dsl.rb +1 -1
  23. data/lib/glimmer/dsl/libui/file_expression.rb +1 -1
  24. data/lib/glimmer/dsl/libui/listener_expression.rb +1 -1
  25. data/lib/glimmer/dsl/libui/observe_expression.rb +1 -1
  26. data/lib/glimmer/dsl/libui/open_file_expression.rb +1 -1
  27. data/lib/glimmer/dsl/libui/operation_expression.rb +1 -1
  28. data/lib/glimmer/dsl/libui/property_expression.rb +1 -1
  29. data/lib/glimmer/dsl/libui/save_file_expression.rb +1 -1
  30. data/lib/glimmer/dsl/libui/shape_expression.rb +1 -1
  31. data/lib/glimmer/dsl/libui/shine_data_binding_expression.rb +1 -1
  32. data/lib/glimmer/dsl/libui/string_expression.rb +1 -1
  33. data/lib/glimmer/dsl/libui/tab_item_expression.rb +1 -1
  34. data/lib/glimmer/fiddle_consumer.rb +1 -1
  35. data/lib/glimmer/libui/attributed_string.rb +1 -1
  36. data/lib/glimmer/libui/control_proxy/area_proxy/scrolling_area_proxy.rb +1 -1
  37. data/lib/glimmer/libui/control_proxy/area_proxy.rb +1 -1
  38. data/lib/glimmer/libui/control_proxy/box/horizontal_box_proxy.rb +1 -1
  39. data/lib/glimmer/libui/control_proxy/box/vertical_box_proxy.rb +1 -1
  40. data/lib/glimmer/libui/control_proxy/box.rb +1 -1
  41. data/lib/glimmer/libui/control_proxy/button_proxy.rb +1 -1
  42. data/lib/glimmer/libui/control_proxy/checkbox_proxy.rb +1 -1
  43. data/lib/glimmer/libui/control_proxy/color_button_proxy.rb +1 -1
  44. data/lib/glimmer/libui/control_proxy/column/background_color_column_proxy.rb +1 -1
  45. data/lib/glimmer/libui/control_proxy/column/button_column_proxy.rb +1 -1
  46. data/lib/glimmer/libui/control_proxy/column/checkbox_column_proxy.rb +1 -1
  47. data/lib/glimmer/libui/control_proxy/column/checkbox_text_color_column_proxy.rb +1 -1
  48. data/lib/glimmer/libui/control_proxy/column/checkbox_text_column_proxy.rb +1 -1
  49. data/lib/glimmer/libui/control_proxy/column/image_column_proxy.rb +1 -1
  50. data/lib/glimmer/libui/control_proxy/column/image_text_color_column_proxy.rb +1 -1
  51. data/lib/glimmer/libui/control_proxy/column/image_text_column_proxy.rb +1 -1
  52. data/lib/glimmer/libui/control_proxy/column/progress_bar_column_proxy.rb +1 -1
  53. data/lib/glimmer/libui/control_proxy/column/text_color_column_proxy.rb +1 -1
  54. data/lib/glimmer/libui/control_proxy/column/text_column_proxy.rb +1 -1
  55. data/lib/glimmer/libui/control_proxy/column.rb +1 -1
  56. data/lib/glimmer/libui/control_proxy/combobox_proxy.rb +1 -1
  57. data/lib/glimmer/libui/control_proxy/date_time_picker_proxy/date_picker_proxy.rb +1 -1
  58. data/lib/glimmer/libui/control_proxy/date_time_picker_proxy/time_picker_proxy.rb +1 -1
  59. data/lib/glimmer/libui/control_proxy/date_time_picker_proxy.rb +1 -1
  60. data/lib/glimmer/libui/control_proxy/dual_column.rb +1 -1
  61. data/lib/glimmer/libui/control_proxy/editable_column.rb +1 -1
  62. data/lib/glimmer/libui/control_proxy/editable_combobox_proxy.rb +1 -1
  63. data/lib/glimmer/libui/control_proxy/enableable_column.rb +1 -1
  64. data/lib/glimmer/libui/control_proxy/entry_proxy/password_entry_proxy.rb +1 -1
  65. data/lib/glimmer/libui/control_proxy/entry_proxy/search_entry_proxy.rb +1 -1
  66. data/lib/glimmer/libui/control_proxy/entry_proxy.rb +1 -1
  67. data/lib/glimmer/libui/control_proxy/font_button_proxy.rb +1 -1
  68. data/lib/glimmer/libui/control_proxy/form_proxy.rb +1 -1
  69. data/lib/glimmer/libui/control_proxy/grid_proxy.rb +1 -1
  70. data/lib/glimmer/libui/control_proxy/group_proxy.rb +1 -1
  71. data/lib/glimmer/libui/control_proxy/image_part_proxy.rb +1 -1
  72. data/lib/glimmer/libui/control_proxy/image_proxy.rb +1 -1
  73. data/lib/glimmer/libui/control_proxy/label_proxy.rb +1 -1
  74. data/lib/glimmer/libui/control_proxy/matrix_proxy.rb +1 -1
  75. data/lib/glimmer/libui/control_proxy/menu_item_proxy/about_menu_item_proxy.rb +1 -1
  76. data/lib/glimmer/libui/control_proxy/menu_item_proxy/check_menu_item_proxy.rb +1 -1
  77. data/lib/glimmer/libui/control_proxy/menu_item_proxy/preferences_menu_item_proxy.rb +1 -1
  78. data/lib/glimmer/libui/control_proxy/menu_item_proxy/quit_menu_item_proxy.rb +1 -1
  79. data/lib/glimmer/libui/control_proxy/menu_item_proxy/radio_menu_item_proxy.rb +1 -1
  80. data/lib/glimmer/libui/control_proxy/menu_item_proxy/separator_menu_item_proxy.rb +1 -1
  81. data/lib/glimmer/libui/control_proxy/menu_item_proxy.rb +1 -1
  82. data/lib/glimmer/libui/control_proxy/menu_proxy.rb +1 -1
  83. data/lib/glimmer/libui/control_proxy/message_box/msg_box_error_proxy.rb +1 -1
  84. data/lib/glimmer/libui/control_proxy/message_box/msg_box_proxy.rb +1 -1
  85. data/lib/glimmer/libui/control_proxy/message_box.rb +1 -1
  86. data/lib/glimmer/libui/control_proxy/multiline_entry_proxy/non_wrapping_multiline_entry_proxy.rb +1 -1
  87. data/lib/glimmer/libui/control_proxy/multiline_entry_proxy.rb +1 -1
  88. data/lib/glimmer/libui/control_proxy/open_type_features_proxy.rb +1 -1
  89. data/lib/glimmer/libui/control_proxy/open_type_tag_proxy.rb +1 -1
  90. data/lib/glimmer/libui/control_proxy/path_proxy.rb +1 -1
  91. data/lib/glimmer/libui/control_proxy/radio_buttons_proxy.rb +1 -1
  92. data/lib/glimmer/libui/control_proxy/slider_proxy.rb +1 -1
  93. data/lib/glimmer/libui/control_proxy/spinbox_proxy.rb +1 -1
  94. data/lib/glimmer/libui/control_proxy/tab_item_proxy.rb +1 -1
  95. data/lib/glimmer/libui/control_proxy/table_proxy.rb +1 -1
  96. data/lib/glimmer/libui/control_proxy/text_proxy.rb +1 -1
  97. data/lib/glimmer/libui/control_proxy/transformable.rb +1 -1
  98. data/lib/glimmer/libui/control_proxy/triple_column.rb +1 -1
  99. data/lib/glimmer/libui/control_proxy/window_proxy.rb +1 -1
  100. data/lib/glimmer/libui/control_proxy.rb +1 -1
  101. data/lib/glimmer/libui/data_bindable.rb +1 -1
  102. data/lib/glimmer/libui/parent.rb +1 -1
  103. data/lib/glimmer/libui/shape/arc.rb +1 -1
  104. data/lib/glimmer/libui/shape/bezier.rb +1 -1
  105. data/lib/glimmer/libui/shape/circle.rb +1 -1
  106. data/lib/glimmer/libui/shape/figure.rb +1 -1
  107. data/lib/glimmer/libui/shape/line.rb +1 -1
  108. data/lib/glimmer/libui/shape/polybezier.rb +1 -1
  109. data/lib/glimmer/libui/shape/polygon.rb +1 -1
  110. data/lib/glimmer/libui/shape/polyline.rb +1 -1
  111. data/lib/glimmer/libui/shape/rectangle.rb +1 -1
  112. data/lib/glimmer/libui/shape/square.rb +1 -1
  113. data/lib/glimmer/libui/shape.rb +1 -1
  114. data/lib/glimmer/libui.rb +1 -1
  115. data/lib/glimmer-dsl-libui.rb +1 -1
  116. metadata +4 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 594b6127dd134d82d6f91dd4856aadb841ecceb04a8e9b34741d940212956997
4
- data.tar.gz: efe2aa6e53ea80b58c1a1a12351c67e476e5ec3170aba680573d2f963680ccba
3
+ metadata.gz: 659e2536562c00af0982adb20c0bd5a808efc6e541d14b2aa49f27e6587fcdd8
4
+ data.tar.gz: 67e757172d34f71143693367dcf6ce7923be978f8acb759ddb895b6fd4a0686b
5
5
  SHA512:
6
- metadata.gz: 8d21fba0daf5a73da1b7d31aac00d492508d92ceda522751a3908b7b3c794368286e7d971aa525322a08d91f48e11b71ad9c838393de65e12c4fc5f8133b5e6f
7
- data.tar.gz: 2e448728ad41a976a169e5913e941cad523c5f897849ccacc82eb9d1ae2c75e002b8c9c5a933b9642d2845d263ed252a2e4826e29a0d18467b5e6bae63b51f8e
6
+ metadata.gz: 7ee798767c387417d3dfba823a6514430f342bdeeaefb68008aef0fc239fe9b063ed9138e8d3163dee0b7e6cdc7bc7dc453d34521b854db358c9c12512dee56e
7
+ data.tar.gz: 7aea1219101dc352a01723834970638c51a57c00253ec345ad98bf4db98f0afa35f9b044ad6d3bc5de33c512839fa89e3ca701ae0a2b95f045f8f166e9b0ea57
data/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # Change Log
2
2
 
3
+ ## 0.4.21
4
+
5
+ - Pause via spacebar in examples/snake.rb (all versions)
6
+ - Upgrade to glimmer 2.5.5
7
+
3
8
  ## 0.4.20
4
9
 
5
10
  - New examples/area_based_custom_controls.rb
data/LICENSE.txt CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2021 Andy Maleh
1
+ Copyright (c) 2021-2022 Andy Maleh
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
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.4.20
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.4.21
2
2
  ## Prerequisite-Free Ruby Desktop Development GUI Library
3
3
  [![Gem Version](https://badge.fury.io/rb/glimmer-dsl-libui.svg)](http://badge.fury.io/rb/glimmer-dsl-libui)
4
4
  [![Join the chat at https://gitter.im/AndyObtiva/glimmer](https://badges.gitter.im/AndyObtiva/glimmer.svg)](https://gitter.im/AndyObtiva/glimmer?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
@@ -22,6 +22,8 @@ The main trade-off in using [Glimmer DSL for LibUI](https://rubygems.org/gems/gl
22
22
  - [Far Future Plan] Scaffolding for new custom controls, apps, and gems
23
23
  - [Far Future Plan] Native-Executable packaging on Mac, Windows, and Linux.
24
24
 
25
+ Note that currently, [LibUI](https://github.com/kojix2/LibUI) only includes x86_64 binaries out of the box, but there are plans to include ARM64/AARCH64 binaries too in the future.
26
+
25
27
  Hello, World!
26
28
 
27
29
  ```ruby
@@ -320,9 +322,11 @@ Mac | Windows | Linux
320
322
 
321
323
  [Check Out Many More Examples Over Here!](#examples)
322
324
 
323
- Mac | Windows | Linux
324
- ----|---------|------
325
- ![glimmer-dsl-libui-mac-tetris.png](images/glimmer-dsl-libui-mac-tetris.png) | ![glimmer-dsl-libui-windows-tetris.png](images/glimmer-dsl-libui-windows-tetris.png) | ![glimmer-dsl-libui-linux-tetris.png](images/glimmer-dsl-libui-linux-tetris.png)
325
+ ![glimmer-dsl-libui-mac-snake.gif](images/glimmer-dsl-libui-mac-snake.gif)
326
+
327
+ ![glimmer-dsl-libui-mac-color-the-circles.gif](images/glimmer-dsl-libui-mac-color-the-circles.gif)
328
+
329
+ ![glimmer-dsl-libui-mac-tetris.gif](images/glimmer-dsl-libui-mac-tetris.gif)
326
330
 
327
331
  NOTE: [Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) is 100% feature-complete and in beta mode (though the C [libui](https://github.com/andlabs/libui) is still mid-alpha). Please help make better by contributing, adopting for small or low risk projects, and providing feedback. The more feedback and issues you report the better.
328
332
 
@@ -507,7 +511,7 @@ gem install glimmer-dsl-libui
507
511
  Or install via Bundler `Gemfile`:
508
512
 
509
513
  ```ruby
510
- gem 'glimmer-dsl-libui', '~> 0.4.20'
514
+ gem 'glimmer-dsl-libui', '~> 0.4.21'
511
515
  ```
512
516
 
513
517
  Test that installation worked by running the [Meta-Example](#examples):
@@ -8642,14 +8646,14 @@ class AreaBasedCustomControls
8642
8646
  def initialize
8643
8647
  self.label_width = 335
8644
8648
  self.label_height = 50
8645
- self.label_font_descriptor = {family: OS.linux? ? 'Bitstream Vera Sans Mono' : 'Courier New', size: 16, weight: :bold, italic: :italic}
8649
+ self.label_font_descriptor = {family: OS.linux? ? 'Monospace Bold Italic' : 'Courier New', size: 16, weight: :bold, italic: :italic}
8646
8650
  self.label_text_color = :red
8647
8651
  self.label_background_fill = :yellow
8648
8652
  self.label_border_stroke = :limegreen
8649
8653
 
8650
- self.button_width = 130
8654
+ self.button_width = 150
8651
8655
  self.button_height = 50
8652
- self.button_font_descriptor = {family: OS.linux? ? 'Bitstream Vera Sans Mono' : 'Courier New', size: 36, weight: :bold, italic: :italic}
8656
+ self.button_font_descriptor = {family: OS.linux? ? 'Monospace Bold Italic' : 'Courier New', size: 36, weight: OS.linux? ? :normal : :bold, italic: :italic}
8653
8657
  self.button_text_color = :green
8654
8658
  self.button_background_fill = :yellow
8655
8659
  self.button_border_stroke = :limegreen
@@ -8657,7 +8661,7 @@ class AreaBasedCustomControls
8657
8661
 
8658
8662
  def rebuild_text_label
8659
8663
  @text_label.destroy
8660
- @text_label_vertical_box.content { # re-open vertical box content and shove in a new button
8664
+ @text_label_vertical_box.content { # re-open vertical box content and shove in a new label
8661
8665
  @text_label = text_label('This is a text label.',
8662
8666
  width: label_width, height: label_height, font_descriptor: label_font_descriptor,
8663
8667
  background_fill: label_background_fill, text_color: label_text_color, border_stroke: label_border_stroke,
@@ -8687,8 +8691,8 @@ class AreaBasedCustomControls
8687
8691
  tab_item('Text Label') {
8688
8692
  @text_label_vertical_box = vertical_box {
8689
8693
  vertical_box {
8690
- text_label('Text Label Construction Form:', width: 250, height: 30, font_descriptor: {size: 16, weight: :bold}, text_x: 0, text_y: 0)
8691
-
8694
+ text_label('Text Label Form:', width: 385, height: 30, background_fill: OS.windows? ? :white : {a: 0}, border_stroke: OS.windows? ? :white : {a: 0}, font_descriptor: {size: 16, weight: :bold}, text_x: 0, text_y: OS.windows? ? 0 : 5)
8695
+
8692
8696
  horizontal_box {
8693
8697
  label('Width')
8694
8698
  spinbox(1, 1000) {
@@ -8756,7 +8760,7 @@ class AreaBasedCustomControls
8756
8760
  tab_item('Push Button') {
8757
8761
  @push_button_vertical_box = vertical_box {
8758
8762
  vertical_box {
8759
- text_label('Push Button Construction Form:', width: 250, height: 30, font_descriptor: {size: 16, weight: :bold}, text_x: 0, text_y: 0)
8763
+ text_label('Push Button Form:', width: 385, height: 30, background_fill: OS.windows? ? :white : {a: 0}, border_stroke: OS.windows? ? :white : {a: 0}, font_descriptor: {size: 16, weight: :bold}, text_x: 0, text_y: OS.windows? ? 0 : 5)
8760
8764
 
8761
8765
  horizontal_box {
8762
8766
  label('Width')
@@ -8835,6 +8839,10 @@ class AreaBasedCustomControls
8835
8839
  # background_fill can accept a single color or gradient stops just as per `fill` property in README.
8836
8840
  # border_stroke is transparent by default.
8837
8841
  # border_stroke can accept thickness and dashes in addition to color just as per `stroke` property in README.
8842
+ # text_x and text_y are the offset of the label text in relation to its top-left corner.
8843
+ # When text_x, text_y are left nil, the text is automatically centered in the label area.
8844
+ # Sometimes, the centering calculation is not perfect due to using a custom font, so
8845
+ # in that case, pass in text_x, and text_y manually.
8838
8846
  def text_label(label_text,
8839
8847
  width: 80, height: 30, font_descriptor: {},
8840
8848
  background_fill: {a: 0}, text_color: :black, border_stroke: {a: 0},
@@ -8848,8 +8856,8 @@ class AreaBasedCustomControls
8848
8856
  stroke border_stroke
8849
8857
  }
8850
8858
 
8851
- text_height = (font_descriptor[:size] || 12) * 0.75
8852
- text_width = (text_height * label_text.size) * 0.75
8859
+ text_height = (font_descriptor[:size] || 12) * (OS.mac? ? 0.75 : 1.35)
8860
+ text_width = (text_height * label_text.size) * (OS.mac? ? 0.75 : 0.60)
8853
8861
  text_x ||= (width - text_width) / 2.0
8854
8862
  text_y ||= (height - 4 - text_height) / 2.0
8855
8863
  text(text_x, text_y, width) {
@@ -8869,10 +8877,10 @@ class AreaBasedCustomControls
8869
8877
  # background_fill can accept a single color or gradient stops just as per `fill` property in README.
8870
8878
  # border_stroke is black by default.
8871
8879
  # border_stroke can accept thickness and dashes in addition to color just as per `stroke` property in README.
8872
- # text_x and text_y are the offset of the button text in releation to its top-left corner
8880
+ # text_x and text_y are the offset of the button text in relation to its top-left corner.
8873
8881
  # When text_x, text_y are left nil, the text is automatically centered in the button area.
8874
8882
  # Sometimes, the centering calculation is not perfect due to using a custom font, so
8875
- # in that case, pass in text_x, and text_y manually
8883
+ # in that case, pass in text_x, and text_y manually.
8876
8884
  #
8877
8885
  # reuses the text_label custom control
8878
8886
  def push_button(button_text,
@@ -9360,7 +9368,7 @@ class Snake
9360
9368
  end
9361
9369
 
9362
9370
  Glimmer::LibUI.timer(SNAKE_MOVE_DELAY) do
9363
- unless @game.over?
9371
+ unless @game.paused? || @game.over?
9364
9372
  process_queued_keypress
9365
9373
  @game.snake.move
9366
9374
  end
@@ -9401,7 +9409,11 @@ class Snake
9401
9409
  }
9402
9410
 
9403
9411
  on_key_up do |area_key_event|
9404
- @keypress_queue << area_key_event[:ext_key]
9412
+ if area_key_event[:key] == ' '
9413
+ @game.toggle_pause
9414
+ else
9415
+ @keypress_queue << area_key_event[:ext_key]
9416
+ end
9405
9417
  end
9406
9418
  }
9407
9419
  end
@@ -9460,7 +9472,7 @@ class Snake
9460
9472
  end
9461
9473
 
9462
9474
  Glimmer::LibUI.timer(SNAKE_MOVE_DELAY) do
9463
- unless @game.over?
9475
+ unless @game.paused? || @game.over?
9464
9476
  process_queued_keypress
9465
9477
  @game.snake.move
9466
9478
  end
@@ -9503,7 +9515,11 @@ class Snake
9503
9515
  }
9504
9516
 
9505
9517
  on_key_up do |area_key_event|
9506
- @keypress_queue << area_key_event[:ext_key]
9518
+ if area_key_event[:key] == ' '
9519
+ @game.toggle_pause
9520
+ else
9521
+ @keypress_queue << area_key_event[:ext_key]
9522
+ end
9507
9523
  end
9508
9524
  }
9509
9525
  end
@@ -9904,7 +9920,7 @@ class Tetris
9904
9920
 
9905
9921
  def show_about_dialog
9906
9922
  Glimmer::LibUI.queue_main do
9907
- msg_box('About', 'Glimmer Tetris - Glimmer DSL for LibUI Example - Copyright (c) 2021 Andy Maleh')
9923
+ msg_box('About', 'Glimmer Tetris - Glimmer DSL for LibUI Example - Copyright (c) 2021-2022 Andy Maleh')
9908
9924
  end
9909
9925
  end
9910
9926
  end
@@ -10473,7 +10489,7 @@ Note that the latest development sometimes takes place in the [development](http
10473
10489
 
10474
10490
  [MIT](LICENSE.txt)
10475
10491
 
10476
- Copyright (c) 2021 Andy Maleh
10492
+ Copyright (c) 2021-2022 Andy Maleh
10477
10493
 
10478
10494
  --
10479
10495
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.4.20
1
+ 0.4.21
data/bin/girb_runner.rb CHANGED
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2020-2021 Andy Maleh
1
+ # Copyright (c) 2021-2022 Andy Maleh
2
2
  #
3
3
  # Permission is hereby granted, free of charge, to any person obtaining
4
4
  # a copy of this software and associated documentation files (the
@@ -28,7 +28,7 @@ class AreaBasedCustomControls
28
28
 
29
29
  def rebuild_text_label
30
30
  @text_label.destroy
31
- @text_label_vertical_box.content { # re-open vertical box content and shove in a new button
31
+ @text_label_vertical_box.content { # re-open vertical box content and shove in a new label
32
32
  @text_label = text_label('This is a text label.',
33
33
  width: label_width, height: label_height, font_descriptor: label_font_descriptor,
34
34
  background_fill: label_background_fill, text_color: label_text_color, border_stroke: label_border_stroke,
@@ -206,6 +206,10 @@ class AreaBasedCustomControls
206
206
  # background_fill can accept a single color or gradient stops just as per `fill` property in README.
207
207
  # border_stroke is transparent by default.
208
208
  # border_stroke can accept thickness and dashes in addition to color just as per `stroke` property in README.
209
+ # text_x and text_y are the offset of the label text in relation to its top-left corner.
210
+ # When text_x, text_y are left nil, the text is automatically centered in the label area.
211
+ # Sometimes, the centering calculation is not perfect due to using a custom font, so
212
+ # in that case, pass in text_x, and text_y manually.
209
213
  def text_label(label_text,
210
214
  width: 80, height: 30, font_descriptor: {},
211
215
  background_fill: {a: 0}, text_color: :black, border_stroke: {a: 0},
@@ -240,10 +244,10 @@ class AreaBasedCustomControls
240
244
  # background_fill can accept a single color or gradient stops just as per `fill` property in README.
241
245
  # border_stroke is black by default.
242
246
  # border_stroke can accept thickness and dashes in addition to color just as per `stroke` property in README.
243
- # text_x and text_y are the offset of the button text in releation to its top-left corner
247
+ # text_x and text_y are the offset of the button text in relation to its top-left corner.
244
248
  # When text_x, text_y are left nil, the text is automatically centered in the button area.
245
249
  # Sometimes, the centering calculation is not perfect due to using a custom font, so
246
- # in that case, pass in text_x, and text_y manually
250
+ # in that case, pass in text_x, and text_y manually.
247
251
  #
248
252
  # reuses the text_label custom control
249
253
  def push_button(button_text,
@@ -11,8 +11,9 @@ class Snake
11
11
  FILE_HIGH_SCORE = File.expand_path(File.join(Dir.home, '.glimmer-snake'))
12
12
 
13
13
  attr_reader :width, :height
14
- attr_accessor :snake, :apple, :over, :score, :high_score
14
+ attr_accessor :snake, :apple, :over, :score, :high_score, :paused
15
15
  alias over? over
16
+ alias paused? paused
16
17
 
17
18
  def initialize(width = WIDTH_DEFAULT, height = HEIGHT_DEFAULT)
18
19
  @width = width
@@ -42,6 +43,22 @@ class Snake
42
43
  self.apple.generate
43
44
  end
44
45
 
46
+ def pause
47
+ self.paused = true
48
+ end
49
+
50
+ def resume
51
+ self.paused = false
52
+ end
53
+
54
+ def toggle_pause
55
+ unless paused?
56
+ pause
57
+ else
58
+ resume
59
+ end
60
+ end
61
+
45
62
  # inspect is overridden to prevent printing very long stack traces
46
63
  def inspect
47
64
  "#{super[0, 75]}... >"
data/examples/snake.rb CHANGED
@@ -32,7 +32,7 @@ class Snake
32
32
  end
33
33
 
34
34
  Glimmer::LibUI.timer(SNAKE_MOVE_DELAY) do
35
- unless @game.over?
35
+ unless @game.paused? || @game.over?
36
36
  process_queued_keypress
37
37
  @game.snake.move
38
38
  end
@@ -73,7 +73,11 @@ class Snake
73
73
  }
74
74
 
75
75
  on_key_up do |area_key_event|
76
- @keypress_queue << area_key_event[:ext_key]
76
+ if area_key_event[:key] == ' '
77
+ @game.toggle_pause
78
+ else
79
+ @keypress_queue << area_key_event[:ext_key]
80
+ end
77
81
  end
78
82
  }
79
83
  end
data/examples/snake2.rb CHANGED
@@ -40,7 +40,7 @@ class Snake
40
40
  end
41
41
 
42
42
  Glimmer::LibUI.timer(SNAKE_MOVE_DELAY) do
43
- unless @game.over?
43
+ unless @game.paused? || @game.over?
44
44
  process_queued_keypress
45
45
  @game.snake.move
46
46
  end
@@ -83,7 +83,11 @@ class Snake
83
83
  }
84
84
 
85
85
  on_key_up do |area_key_event|
86
- @keypress_queue << area_key_event[:ext_key]
86
+ if area_key_event[:key] == ' '
87
+ @game.toggle_pause
88
+ else
89
+ @keypress_queue << area_key_event[:ext_key]
90
+ end
87
91
  end
88
92
  }
89
93
  end
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2007-2021 Andy Maleh
1
+ # Copyright (c) 2021-2022 Andy Maleh
2
2
  #
3
3
  # Permission is hereby granted, free of charge, to any person obtaining
4
4
  # a copy of this software and associated documentation files (the
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2007-2021 Andy Maleh
1
+ # Copyright (c) 2021-2022 Andy Maleh
2
2
  #
3
3
  # Permission is hereby granted, free of charge, to any person obtaining
4
4
  # a copy of this software and associated documentation files (the
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2007-2021 Andy Maleh
1
+ # Copyright (c) 2021-2022 Andy Maleh
2
2
  #
3
3
  # Permission is hereby granted, free of charge, to any person obtaining
4
4
  # a copy of this software and associated documentation files (the
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2007-2021 Andy Maleh
1
+ # Copyright (c) 2021-2022 Andy Maleh
2
2
  #
3
3
  # Permission is hereby granted, free of charge, to any person obtaining
4
4
  # a copy of this software and associated documentation files (the
data/examples/tetris.rb CHANGED
@@ -360,7 +360,7 @@ class Tetris
360
360
 
361
361
  def show_about_dialog
362
362
  Glimmer::LibUI.queue_main do
363
- msg_box('About', 'Glimmer Tetris - Glimmer DSL for LibUI Example - Copyright (c) 2021 Andy Maleh')
363
+ msg_box('About', 'Glimmer Tetris - Glimmer DSL for LibUI Example - Copyright (c) 2021-2022 Andy Maleh')
364
364
  end
365
365
  end
366
366
  end
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2007-2021 Andy Maleh
1
+ # Copyright (c) 2021-2022 Andy Maleh
2
2
  #
3
3
  # Permission is hereby granted, free of charge, to any person obtaining
4
4
  # a copy of this software and associated documentation files (the
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2007-2021 Andy Maleh
1
+ # Copyright (c) 2021-2022 Andy Maleh
2
2
  #
3
3
  # Permission is hereby granted, free of charge, to any person obtaining
4
4
  # a copy of this software and associated documentation files (the
Binary file
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2021 Andy Maleh
1
+ # Copyright (c) 2021-2022 Andy Maleh
2
2
  #
3
3
  # Permission is hereby granted, free of charge, to any person obtaining
4
4
  # a copy of this software and associated documentation files (the
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2021 Andy Maleh
1
+ # Copyright (c) 2021-2022 Andy Maleh
2
2
  #
3
3
  # Permission is hereby granted, free of charge, to any person obtaining
4
4
  # a copy of this software and associated documentation files (the
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2021 Andy Maleh
1
+ # Copyright (c) 2021-2022 Andy Maleh
2
2
  #
3
3
  # Permission is hereby granted, free of charge, to any person obtaining
4
4
  # a copy of this software and associated documentation files (the
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2021 Andy Maleh
1
+ # Copyright (c) 2021-2022 Andy Maleh
2
2
  #
3
3
  # Permission is hereby granted, free of charge, to any person obtaining
4
4
  # a copy of this software and associated documentation files (the
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2021 Andy Maleh
1
+ # Copyright (c) 2021-2022 Andy Maleh
2
2
  #
3
3
  # Permission is hereby granted, free of charge, to any person obtaining
4
4
  # a copy of this software and associated documentation files (the
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2021 Andy Maleh
1
+ # Copyright (c) 2021-2022 Andy Maleh
2
2
  #
3
3
  # Permission is hereby granted, free of charge, to any person obtaining
4
4
  # a copy of this software and associated documentation files (the
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2021 Andy Maleh
1
+ # Copyright (c) 2021-2022 Andy Maleh
2
2
  #
3
3
  # Permission is hereby granted, free of charge, to any person obtaining
4
4
  # a copy of this software and associated documentation files (the
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2021 Andy Maleh
1
+ # Copyright (c) 2021-2022 Andy Maleh
2
2
  #
3
3
  # Permission is hereby granted, free of charge, to any person obtaining
4
4
  # a copy of this software and associated documentation files (the
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2021 Andy Maleh
1
+ # Copyright (c) 2021-2022 Andy Maleh
2
2
  #
3
3
  # Permission is hereby granted, free of charge, to any person obtaining
4
4
  # a copy of this software and associated documentation files (the
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2021 Andy Maleh
1
+ # Copyright (c) 2021-2022 Andy Maleh
2
2
  #
3
3
  # Permission is hereby granted, free of charge, to any person obtaining
4
4
  # a copy of this software and associated documentation files (the
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2021 Andy Maleh
1
+ # Copyright (c) 2021-2022 Andy Maleh
2
2
  #
3
3
  # Permission is hereby granted, free of charge, to any person obtaining
4
4
  # a copy of this software and associated documentation files (the
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2021 Andy Maleh
1
+ # Copyright (c) 2021-2022 Andy Maleh
2
2
  #
3
3
  # Permission is hereby granted, free of charge, to any person obtaining
4
4
  # a copy of this software and associated documentation files (the
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2021 Andy Maleh
1
+ # Copyright (c) 2021-2022 Andy Maleh
2
2
  #
3
3
  # Permission is hereby granted, free of charge, to any person obtaining
4
4
  # a copy of this software and associated documentation files (the
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2021 Andy Maleh
1
+ # Copyright (c) 2021-2022 Andy Maleh
2
2
  #
3
3
  # Permission is hereby granted, free of charge, to any person obtaining
4
4
  # a copy of this software and associated documentation files (the
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2021 Andy Maleh
1
+ # Copyright (c) 2021-2022 Andy Maleh
2
2
  #
3
3
  # Permission is hereby granted, free of charge, to any person obtaining
4
4
  # a copy of this software and associated documentation files (the
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2021 Andy Maleh
1
+ # Copyright (c) 2021-2022 Andy Maleh
2
2
  #
3
3
  # Permission is hereby granted, free of charge, to any person obtaining
4
4
  # a copy of this software and associated documentation files (the
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2021 Andy Maleh
1
+ # Copyright (c) 2021-2022 Andy Maleh
2
2
  #
3
3
  # Permission is hereby granted, free of charge, to any person obtaining
4
4
  # a copy of this software and associated documentation files (the
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2021 Andy Maleh
1
+ # Copyright (c) 2021-2022 Andy Maleh
2
2
  #
3
3
  # Permission is hereby granted, free of charge, to any person obtaining
4
4
  # a copy of this software and associated documentation files (the
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2021 Andy Maleh
1
+ # Copyright (c) 2021-2022 Andy Maleh
2
2
  #
3
3
  # Permission is hereby granted, free of charge, to any person obtaining
4
4
  # a copy of this software and associated documentation files (the
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2021 Andy Maleh
1
+ # Copyright (c) 2021-2022 Andy Maleh
2
2
  #
3
3
  # Permission is hereby granted, free of charge, to any person obtaining
4
4
  # a copy of this software and associated documentation files (the
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2021 Andy Maleh
1
+ # Copyright (c) 2021-2022 Andy Maleh
2
2
  #
3
3
  # Permission is hereby granted, free of charge, to any person obtaining
4
4
  # a copy of this software and associated documentation files (the
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2021 Andy Maleh
1
+ # Copyright (c) 2021-2022 Andy Maleh
2
2
  #
3
3
  # Permission is hereby granted, free of charge, to any person obtaining
4
4
  # a copy of this software and associated documentation files (the
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2021 Andy Maleh
1
+ # Copyright (c) 2021-2022 Andy Maleh
2
2
  #
3
3
  # Permission is hereby granted, free of charge, to any person obtaining
4
4
  # a copy of this software and associated documentation files (the
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2021 Andy Maleh
1
+ # Copyright (c) 2021-2022 Andy Maleh
2
2
  #
3
3
  # Permission is hereby granted, free of charge, to any person obtaining
4
4
  # a copy of this software and associated documentation files (the
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2021 Andy Maleh
1
+ # Copyright (c) 2021-2022 Andy Maleh
2
2
  #
3
3
  # Permission is hereby granted, free of charge, to any person obtaining
4
4
  # a copy of this software and associated documentation files (the
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2021 Andy Maleh
1
+ # Copyright (c) 2021-2022 Andy Maleh
2
2
  #
3
3
  # Permission is hereby granted, free of charge, to any person obtaining
4
4
  # a copy of this software and associated documentation files (the
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2021 Andy Maleh
1
+ # Copyright (c) 2021-2022 Andy Maleh
2
2
  #
3
3
  # Permission is hereby granted, free of charge, to any person obtaining
4
4
  # a copy of this software and associated documentation files (the
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2021 Andy Maleh
1
+ # Copyright (c) 2021-2022 Andy Maleh
2
2
  #
3
3
  # Permission is hereby granted, free of charge, to any person obtaining
4
4
  # a copy of this software and associated documentation files (the
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2021 Andy Maleh
1
+ # Copyright (c) 2021-2022 Andy Maleh
2
2
  #
3
3
  # Permission is hereby granted, free of charge, to any person obtaining
4
4
  # a copy of this software and associated documentation files (the
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2021 Andy Maleh
1
+ # Copyright (c) 2021-2022 Andy Maleh
2
2
  #
3
3
  # Permission is hereby granted, free of charge, to any person obtaining
4
4
  # a copy of this software and associated documentation files (the
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2021 Andy Maleh
1
+ # Copyright (c) 2021-2022 Andy Maleh
2
2
  #
3
3
  # Permission is hereby granted, free of charge, to any person obtaining
4
4
  # a copy of this software and associated documentation files (the
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2021 Andy Maleh
1
+ # Copyright (c) 2021-2022 Andy Maleh
2
2
  #
3
3
  # Permission is hereby granted, free of charge, to any person obtaining
4
4
  # a copy of this software and associated documentation files (the
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2021 Andy Maleh
1
+ # Copyright (c) 2021-2022 Andy Maleh
2
2
  #
3
3
  # Permission is hereby granted, free of charge, to any person obtaining
4
4
  # a copy of this software and associated documentation files (the