glimmer-dsl-libui 0.4.20 → 0.5.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (117) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +24 -0
  3. data/LICENSE.txt +1 -1
  4. data/README.md +144 -55
  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/color_the_circles.rb +1 -1
  9. data/examples/snake/model/game.rb +18 -1
  10. data/examples/snake.rb +6 -2
  11. data/examples/snake2.rb +6 -2
  12. data/examples/tetris/model/block.rb +1 -1
  13. data/examples/tetris/model/game.rb +26 -24
  14. data/examples/tetris/model/past_game.rb +1 -1
  15. data/examples/tetris/model/tetromino.rb +1 -1
  16. data/examples/tetris.rb +51 -20
  17. data/examples/tic_tac_toe/board.rb +1 -1
  18. data/examples/tic_tac_toe/cell.rb +1 -1
  19. data/glimmer-dsl-libui.gemspec +0 -0
  20. data/lib/glimmer/dsl/libui/bind_expression.rb +1 -1
  21. data/lib/glimmer/dsl/libui/control_expression.rb +1 -1
  22. data/lib/glimmer/dsl/libui/data_binding_expression.rb +1 -1
  23. data/lib/glimmer/dsl/libui/dsl.rb +1 -1
  24. data/lib/glimmer/dsl/libui/file_expression.rb +1 -1
  25. data/lib/glimmer/dsl/libui/listener_expression.rb +1 -1
  26. data/lib/glimmer/dsl/libui/observe_expression.rb +1 -1
  27. data/lib/glimmer/dsl/libui/open_file_expression.rb +1 -1
  28. data/lib/glimmer/dsl/libui/operation_expression.rb +1 -1
  29. data/lib/glimmer/dsl/libui/property_expression.rb +1 -1
  30. data/lib/glimmer/dsl/libui/save_file_expression.rb +1 -1
  31. data/lib/glimmer/dsl/libui/shape_expression.rb +1 -1
  32. data/lib/glimmer/dsl/libui/shine_data_binding_expression.rb +1 -1
  33. data/lib/glimmer/dsl/libui/string_expression.rb +1 -1
  34. data/lib/glimmer/dsl/libui/tab_item_expression.rb +1 -1
  35. data/lib/glimmer/fiddle_consumer.rb +1 -1
  36. data/lib/glimmer/libui/attributed_string.rb +1 -1
  37. data/lib/glimmer/libui/control_proxy/area_proxy/scrolling_area_proxy.rb +1 -1
  38. data/lib/glimmer/libui/control_proxy/area_proxy.rb +1 -1
  39. data/lib/glimmer/libui/control_proxy/box/horizontal_box_proxy.rb +1 -1
  40. data/lib/glimmer/libui/control_proxy/box/vertical_box_proxy.rb +1 -1
  41. data/lib/glimmer/libui/control_proxy/box.rb +1 -1
  42. data/lib/glimmer/libui/control_proxy/button_proxy.rb +1 -1
  43. data/lib/glimmer/libui/control_proxy/checkbox_proxy.rb +1 -1
  44. data/lib/glimmer/libui/control_proxy/color_button_proxy.rb +1 -1
  45. data/lib/glimmer/libui/control_proxy/column/background_color_column_proxy.rb +1 -1
  46. data/lib/glimmer/libui/control_proxy/column/button_column_proxy.rb +1 -1
  47. data/lib/glimmer/libui/control_proxy/column/checkbox_column_proxy.rb +1 -1
  48. data/lib/glimmer/libui/control_proxy/column/checkbox_text_color_column_proxy.rb +1 -1
  49. data/lib/glimmer/libui/control_proxy/column/checkbox_text_column_proxy.rb +1 -1
  50. data/lib/glimmer/libui/control_proxy/column/image_column_proxy.rb +1 -1
  51. data/lib/glimmer/libui/control_proxy/column/image_text_color_column_proxy.rb +1 -1
  52. data/lib/glimmer/libui/control_proxy/column/image_text_column_proxy.rb +1 -1
  53. data/lib/glimmer/libui/control_proxy/column/progress_bar_column_proxy.rb +1 -1
  54. data/lib/glimmer/libui/control_proxy/column/text_color_column_proxy.rb +1 -1
  55. data/lib/glimmer/libui/control_proxy/column/text_column_proxy.rb +1 -1
  56. data/lib/glimmer/libui/control_proxy/column.rb +1 -1
  57. data/lib/glimmer/libui/control_proxy/combobox_proxy.rb +1 -1
  58. data/lib/glimmer/libui/control_proxy/date_time_picker_proxy/date_picker_proxy.rb +1 -1
  59. data/lib/glimmer/libui/control_proxy/date_time_picker_proxy/time_picker_proxy.rb +1 -1
  60. data/lib/glimmer/libui/control_proxy/date_time_picker_proxy.rb +1 -1
  61. data/lib/glimmer/libui/control_proxy/dual_column.rb +1 -1
  62. data/lib/glimmer/libui/control_proxy/editable_column.rb +1 -1
  63. data/lib/glimmer/libui/control_proxy/editable_combobox_proxy.rb +1 -1
  64. data/lib/glimmer/libui/control_proxy/enableable_column.rb +1 -1
  65. data/lib/glimmer/libui/control_proxy/entry_proxy/password_entry_proxy.rb +1 -1
  66. data/lib/glimmer/libui/control_proxy/entry_proxy/search_entry_proxy.rb +1 -1
  67. data/lib/glimmer/libui/control_proxy/entry_proxy.rb +1 -1
  68. data/lib/glimmer/libui/control_proxy/font_button_proxy.rb +1 -1
  69. data/lib/glimmer/libui/control_proxy/form_proxy.rb +1 -1
  70. data/lib/glimmer/libui/control_proxy/grid_proxy.rb +1 -1
  71. data/lib/glimmer/libui/control_proxy/group_proxy.rb +1 -1
  72. data/lib/glimmer/libui/control_proxy/image_part_proxy.rb +1 -1
  73. data/lib/glimmer/libui/control_proxy/image_proxy.rb +1 -1
  74. data/lib/glimmer/libui/control_proxy/label_proxy.rb +1 -1
  75. data/lib/glimmer/libui/control_proxy/matrix_proxy.rb +1 -1
  76. data/lib/glimmer/libui/control_proxy/menu_item_proxy/about_menu_item_proxy.rb +1 -1
  77. data/lib/glimmer/libui/control_proxy/menu_item_proxy/check_menu_item_proxy.rb +1 -1
  78. data/lib/glimmer/libui/control_proxy/menu_item_proxy/preferences_menu_item_proxy.rb +1 -1
  79. data/lib/glimmer/libui/control_proxy/menu_item_proxy/quit_menu_item_proxy.rb +1 -1
  80. data/lib/glimmer/libui/control_proxy/menu_item_proxy/radio_menu_item_proxy.rb +1 -1
  81. data/lib/glimmer/libui/control_proxy/menu_item_proxy/separator_menu_item_proxy.rb +1 -1
  82. data/lib/glimmer/libui/control_proxy/menu_item_proxy.rb +1 -1
  83. data/lib/glimmer/libui/control_proxy/menu_proxy.rb +1 -1
  84. data/lib/glimmer/libui/control_proxy/message_box/msg_box_error_proxy.rb +1 -1
  85. data/lib/glimmer/libui/control_proxy/message_box/msg_box_proxy.rb +1 -1
  86. data/lib/glimmer/libui/control_proxy/message_box.rb +1 -1
  87. data/lib/glimmer/libui/control_proxy/multiline_entry_proxy/non_wrapping_multiline_entry_proxy.rb +1 -1
  88. data/lib/glimmer/libui/control_proxy/multiline_entry_proxy.rb +1 -1
  89. data/lib/glimmer/libui/control_proxy/open_type_features_proxy.rb +1 -1
  90. data/lib/glimmer/libui/control_proxy/open_type_tag_proxy.rb +1 -1
  91. data/lib/glimmer/libui/control_proxy/path_proxy.rb +1 -1
  92. data/lib/glimmer/libui/control_proxy/radio_buttons_proxy.rb +1 -1
  93. data/lib/glimmer/libui/control_proxy/slider_proxy.rb +1 -1
  94. data/lib/glimmer/libui/control_proxy/spinbox_proxy.rb +1 -1
  95. data/lib/glimmer/libui/control_proxy/tab_item_proxy.rb +1 -1
  96. data/lib/glimmer/libui/control_proxy/table_proxy.rb +1 -1
  97. data/lib/glimmer/libui/control_proxy/text_proxy.rb +1 -1
  98. data/lib/glimmer/libui/control_proxy/transformable.rb +1 -1
  99. data/lib/glimmer/libui/control_proxy/triple_column.rb +1 -1
  100. data/lib/glimmer/libui/control_proxy/window_proxy.rb +1 -1
  101. data/lib/glimmer/libui/control_proxy.rb +1 -1
  102. data/lib/glimmer/libui/data_bindable.rb +1 -1
  103. data/lib/glimmer/libui/parent.rb +1 -1
  104. data/lib/glimmer/libui/shape/arc.rb +18 -1
  105. data/lib/glimmer/libui/shape/bezier.rb +1 -1
  106. data/lib/glimmer/libui/shape/circle.rb +8 -3
  107. data/lib/glimmer/libui/shape/figure.rb +1 -1
  108. data/lib/glimmer/libui/shape/line.rb +1 -1
  109. data/lib/glimmer/libui/shape/polybezier.rb +1 -1
  110. data/lib/glimmer/libui/shape/polygon.rb +1 -1
  111. data/lib/glimmer/libui/shape/polyline.rb +1 -1
  112. data/lib/glimmer/libui/shape/rectangle.rb +8 -3
  113. data/lib/glimmer/libui/shape/square.rb +10 -3
  114. data/lib/glimmer/libui/shape.rb +41 -1
  115. data/lib/glimmer/libui.rb +1 -1
  116. data/lib/glimmer-dsl-libui.rb +2 -1
  117. metadata +27 -12
@@ -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
@@ -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
@@ -44,6 +44,23 @@ module Glimmer
44
44
  end
45
45
  super
46
46
  end
47
+
48
+ def perfect_shape
49
+ perfect_shape_dependencies = [x_center, y_center, radius, start_angle, sweep, is_negative]
50
+ if perfect_shape_dependencies != @perfect_shape_dependencies
51
+ x_center, y_center, radius, start_angle, sweep, is_negative = @perfect_shape_dependencies = perfect_shape_dependencies
52
+ sign = is_negative ? 1 : -1
53
+ start = is_negative ? (360 - start_angle) : -1*start_angle
54
+ extent = is_negative ? (360 - sweep) : -1*sweep
55
+ @perfect_shape = PerfectShape::Arc.new(
56
+ type: :open,
57
+ center_x: x_center, center_y: y_center,
58
+ radius_x: radius, radius_y: radius,
59
+ start: start, extent: extent
60
+ )
61
+ end
62
+ @perfect_shape
63
+ end
47
64
  end
48
65
  end
49
66
  end
@@ -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
@@ -45,8 +45,13 @@ module Glimmer
45
45
  super
46
46
  end
47
47
 
48
- def include?(x, y)
49
- (x - x_center)**2 + (y - y_center)**2 < radius**2
48
+ def perfect_shape
49
+ perfect_shape_dependencies = [x_center, y_center, radius]
50
+ if perfect_shape_dependencies != @perfect_shape_dependencies
51
+ x_center, y_center, radius = @perfect_shape_dependencies = perfect_shape_dependencies
52
+ @perfect_shape = PerfectShape::Circle.new(center_x: x_center, center_y: y_center, radius: radius)
53
+ end
54
+ @perfect_shape
50
55
  end
51
56
  end
52
57
  end
@@ -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
@@ -33,8 +33,13 @@ module Glimmer
33
33
  super
34
34
  end
35
35
 
36
- def include?(x, y)
37
- x.between?(self.x, self.x + width) && y.between?(self.y, self.y + height)
36
+ def perfect_shape
37
+ perfect_shape_dependencies = [x, y, width, height]
38
+ if perfect_shape_dependencies != @perfect_shape_dependencies
39
+ x, y, width, height = @perfect_shape_dependencies = perfect_shape_dependencies
40
+ @perfect_shape = PerfectShape::Rectangle.new(x: x, y: y, width: width, height: height)
41
+ end
42
+ @perfect_shape
38
43
  end
39
44
  end
40
45
  end
@@ -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
@@ -33,8 +33,15 @@ module Glimmer
33
33
  super
34
34
  end
35
35
 
36
- def include?(x, y)
37
- x.between?(self.x, self.x + length) && y.between?(self.y, self.y + length)
36
+ # TODO look into refactoring/unifying code with Rectangle
37
+
38
+ def perfect_shape
39
+ perfect_shape_dependencies = [x, y, length]
40
+ if perfect_shape_dependencies != @perfect_shape_dependencies
41
+ @perfect_shape_dependencies = perfect_shape_dependencies
42
+ @perfect_shape = PerfectShape::Square.new(x: @perfect_shape_dependencies[0], y: @perfect_shape_dependencies[1], length: @perfect_shape_dependencies[2])
43
+ end
44
+ @perfect_shape
38
45
  end
39
46
  end
40
47
  end
@@ -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
@@ -145,6 +145,46 @@ module Glimmer
145
145
  end
146
146
  alias transform= transform
147
147
  alias set_transform transform
148
+
149
+ # Returns if shape contains point on the inside when outline is false (default)
150
+ # or if point is on the outline when outline is true
151
+ # distance_tolerance is used when outline is true to enable a fuzz factor in
152
+ # determining if a point lies on the outline (e.g. makes it easier to select
153
+ # a shape by mouse)
154
+ def contain?(*point, outline: false, distance_tolerance: 0)
155
+ perfect_shape&.contain?(*point, outline: outline, distance_tolerance: distance_tolerance)
156
+ end
157
+
158
+ # Returns if shape includes point on the inside when filled
159
+ # or if shape includes point on the outline when stroked
160
+ def include?(*point)
161
+ if fill.empty?
162
+ contain?(*point, outline: true, distance_tolerance: ((stroke[:thickness] || 1) - 1))
163
+ else
164
+ contain?(*point)
165
+ end
166
+ end
167
+
168
+ # Returns bounding box Array consisting of
169
+ # [minx, miny, width, height]
170
+ def bounding_box
171
+ perfect_shape_bounding_box = perfect_shape&.bounding_box
172
+ return if perfect_shape_bounding_box.nil?
173
+ [
174
+ perfect_shape_bounding_box.x,
175
+ perfect_shape_bounding_box.y,
176
+ perfect_shape_bounding_box.width,
177
+ perfect_shape_bounding_box.height,
178
+ ]
179
+ end
180
+
181
+ # Returns PerfectShape object matching this shape to enable
182
+ # executing computational geometry algorithms
183
+ #
184
+ # Subclasses must implement
185
+ def perfect_shape
186
+ # No Op
187
+ end
148
188
 
149
189
  def respond_to?(method_name, *args, &block)
150
190
  self.class.parameters.include?(method_name.to_s.sub(/=$/, '').sub(/^set_/, '').to_sym) or
data/lib/glimmer/libui.rb 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
@@ -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
@@ -23,6 +23,7 @@ $LOAD_PATH.unshift(File.expand_path('..', __FILE__))
23
23
 
24
24
  # External requires
25
25
  require 'glimmer'
26
+ require 'perfect-shape'
26
27
  # require 'logging'
27
28
  # require 'puts_debuggerer' if ENV['pd'].to_s.downcase == 'true'
28
29
  # require 'super_module'
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.4.20
4
+ version: 0.5.1
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-01-01 00:00:00.000000000 Z
11
+ date: 2022-02-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: glimmer
@@ -16,14 +16,28 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 2.5.4
19
+ version: 2.6.0
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.5.4
26
+ version: 2.6.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: perfect-shape
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 1.0.1
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 1.0.1
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: os
29
43
  requirement: !ruby/object:Gem::Requirement
@@ -64,14 +78,14 @@ dependencies:
64
78
  requirements:
65
79
  - - "~>"
66
80
  - !ruby/object:Gem::Version
67
- version: 0.0.13
81
+ version: 0.0.14
68
82
  type: :runtime
69
83
  prerelease: false
70
84
  version_requirements: !ruby/object:Gem::Requirement
71
85
  requirements:
72
86
  - - "~>"
73
87
  - !ruby/object:Gem::Version
74
- version: 0.0.13
88
+ version: 0.0.14
75
89
  - !ruby/object:Gem::Dependency
76
90
  name: chunky_png
77
91
  requirement: !ruby/object:Gem::Requirement
@@ -205,12 +219,13 @@ dependencies:
205
219
  - !ruby/object:Gem::Version
206
220
  version: 0.7.0
207
221
  description: Glimmer DSL for LibUI (Prerequisite-Free Ruby Desktop Development GUI
208
- Library) - No need to pre-install any prerequisites. Just install the gem and have
209
- platform-independent native GUI that just works! Glimmer DSL for LibUI aims to provide
210
- declarative DSL syntax that visually maps to GUI control hierarchy, convention over
211
- configuration via smart defaults, automation of low-level details, requiring the
212
- least amount of syntax possible to build GUI, bidirectional data-binding, and custom
213
- keyword support.
222
+ Library) - Winner of Fukuoka Ruby Award Competition 2022 Special Award - No need
223
+ to pre-install any prerequisites. Just install the gem and have platform-independent
224
+ native GUI that just works! Glimmer DSL for LibUI aims to provide declarative DSL
225
+ syntax that visually maps to GUI control hierarchy, convention over configuration
226
+ via smart defaults, automation of low-level details, requiring the least amount
227
+ of syntax possible to build GUI, bidirectional data-binding, and custom keyword
228
+ support.
214
229
  email: andy.am@gmail.com
215
230
  executables:
216
231
  - girb