sketchup-api-stubs 0.7.2 → 0.7.7

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.
Files changed (149) hide show
  1. checksums.yaml +4 -4
  2. data/lib/sketchup-api-stubs/sketchup.rb +3 -1
  3. data/lib/sketchup-api-stubs/stubs/Geom/BoundingBox.rb +15 -11
  4. data/lib/sketchup-api-stubs/stubs/Geom/Bounds2d.rb +5 -5
  5. data/lib/sketchup-api-stubs/stubs/Geom/LatLong.rb +5 -5
  6. data/lib/sketchup-api-stubs/stubs/Geom/OrientedBounds2d.rb +1 -1
  7. data/lib/sketchup-api-stubs/stubs/Geom/Point2d.rb +5 -6
  8. data/lib/sketchup-api-stubs/stubs/Geom/Point3d.rb +18 -18
  9. data/lib/sketchup-api-stubs/stubs/Geom/PolygonMesh.rb +27 -10
  10. data/lib/sketchup-api-stubs/stubs/Geom/Transformation.rb +1 -1
  11. data/lib/sketchup-api-stubs/stubs/Geom/Transformation2d.rb +1 -1
  12. data/lib/sketchup-api-stubs/stubs/Geom/UTM.rb +1 -1
  13. data/lib/sketchup-api-stubs/stubs/Geom/Vector2d.rb +2 -3
  14. data/lib/sketchup-api-stubs/stubs/Geom/Vector3d.rb +4 -4
  15. data/lib/sketchup-api-stubs/stubs/Layout.rb +1 -1
  16. data/lib/sketchup-api-stubs/stubs/Layout/AngularDimension.rb +5 -1
  17. data/lib/sketchup-api-stubs/stubs/Layout/AutoTextDefinition.rb +1 -1
  18. data/lib/sketchup-api-stubs/stubs/Layout/AutoTextDefinitions.rb +7 -14
  19. data/lib/sketchup-api-stubs/stubs/Layout/ConnectionPoint.rb +1 -1
  20. data/lib/sketchup-api-stubs/stubs/Layout/Document.rb +61 -5
  21. data/lib/sketchup-api-stubs/stubs/Layout/Ellipse.rb +1 -1
  22. data/lib/sketchup-api-stubs/stubs/Layout/Entities.rb +7 -14
  23. data/lib/sketchup-api-stubs/stubs/Layout/Entity.rb +1 -1
  24. data/lib/sketchup-api-stubs/stubs/Layout/FormattedText.rb +1 -1
  25. data/lib/sketchup-api-stubs/stubs/Layout/Grid.rb +189 -1
  26. data/lib/sketchup-api-stubs/stubs/Layout/Group.rb +1 -1
  27. data/lib/sketchup-api-stubs/stubs/Layout/Image.rb +9 -4
  28. data/lib/sketchup-api-stubs/stubs/Layout/Label.rb +2 -3
  29. data/lib/sketchup-api-stubs/stubs/Layout/Layer.rb +1 -1
  30. data/lib/sketchup-api-stubs/stubs/Layout/LayerInstance.rb +1 -1
  31. data/lib/sketchup-api-stubs/stubs/Layout/Layers.rb +7 -14
  32. data/lib/sketchup-api-stubs/stubs/Layout/LinearDimension.rb +6 -2
  33. data/lib/sketchup-api-stubs/stubs/Layout/LockedEntityError.rb +1 -1
  34. data/lib/sketchup-api-stubs/stubs/Layout/LockedLayerError.rb +1 -1
  35. data/lib/sketchup-api-stubs/stubs/Layout/Page.rb +1 -1
  36. data/lib/sketchup-api-stubs/stubs/Layout/PageInfo.rb +1 -1
  37. data/lib/sketchup-api-stubs/stubs/Layout/Pages.rb +7 -14
  38. data/lib/sketchup-api-stubs/stubs/Layout/Path.rb +1 -1
  39. data/lib/sketchup-api-stubs/stubs/Layout/Rectangle.rb +1 -1
  40. data/lib/sketchup-api-stubs/stubs/Layout/SketchUpModel.rb +148 -5
  41. data/lib/sketchup-api-stubs/stubs/Layout/Style.rb +1 -1
  42. data/lib/sketchup-api-stubs/stubs/Layout/Table.rb +1 -1
  43. data/lib/sketchup-api-stubs/stubs/Layout/TableCell.rb +1 -1
  44. data/lib/sketchup-api-stubs/stubs/Layout/TableColumn.rb +1 -1
  45. data/lib/sketchup-api-stubs/stubs/Layout/TableRow.rb +1 -1
  46. data/lib/sketchup-api-stubs/stubs/Sketchup/Animation.rb +5 -1
  47. data/lib/sketchup-api-stubs/stubs/Sketchup/AppObserver.rb +4 -4
  48. data/lib/sketchup-api-stubs/stubs/Sketchup/ArcCurve.rb +1 -1
  49. data/lib/sketchup-api-stubs/stubs/Sketchup/AttributeDictionaries.rb +3 -3
  50. data/lib/sketchup-api-stubs/stubs/Sketchup/AttributeDictionary.rb +6 -1
  51. data/lib/sketchup-api-stubs/stubs/Sketchup/Axes.rb +1 -1
  52. data/lib/sketchup-api-stubs/stubs/Sketchup/Behavior.rb +32 -58
  53. data/lib/sketchup-api-stubs/stubs/Sketchup/Camera.rb +110 -209
  54. data/lib/sketchup-api-stubs/stubs/Sketchup/ClassificationSchema.rb +1 -1
  55. data/lib/sketchup-api-stubs/stubs/Sketchup/Classifications.rb +1 -1
  56. data/lib/sketchup-api-stubs/stubs/Sketchup/Color.rb +24 -11
  57. data/lib/sketchup-api-stubs/stubs/Sketchup/ComponentDefinition.rb +24 -9
  58. data/lib/sketchup-api-stubs/stubs/Sketchup/ComponentInstance.rb +58 -57
  59. data/lib/sketchup-api-stubs/stubs/Sketchup/Console.rb +1 -1
  60. data/lib/sketchup-api-stubs/stubs/Sketchup/ConstructionLine.rb +1 -1
  61. data/lib/sketchup-api-stubs/stubs/Sketchup/ConstructionPoint.rb +1 -1
  62. data/lib/sketchup-api-stubs/stubs/Sketchup/Curve.rb +16 -9
  63. data/lib/sketchup-api-stubs/stubs/Sketchup/DefinitionList.rb +135 -39
  64. data/lib/sketchup-api-stubs/stubs/Sketchup/DefinitionObserver.rb +6 -4
  65. data/lib/sketchup-api-stubs/stubs/Sketchup/DefinitionsObserver.rb +6 -4
  66. data/lib/sketchup-api-stubs/stubs/Sketchup/Dimension.rb +1 -1
  67. data/lib/sketchup-api-stubs/stubs/Sketchup/DimensionLinear.rb +3 -9
  68. data/lib/sketchup-api-stubs/stubs/Sketchup/DimensionObserver.rb +5 -1
  69. data/lib/sketchup-api-stubs/stubs/Sketchup/DimensionRadial.rb +1 -1
  70. data/lib/sketchup-api-stubs/stubs/Sketchup/Drawingelement.rb +10 -4
  71. data/lib/sketchup-api-stubs/stubs/Sketchup/Edge.rb +8 -14
  72. data/lib/sketchup-api-stubs/stubs/Sketchup/EdgeUse.rb +1 -1
  73. data/lib/sketchup-api-stubs/stubs/Sketchup/Entities.rb +55 -26
  74. data/lib/sketchup-api-stubs/stubs/Sketchup/EntitiesObserver.rb +6 -4
  75. data/lib/sketchup-api-stubs/stubs/Sketchup/Entity.rb +20 -15
  76. data/lib/sketchup-api-stubs/stubs/Sketchup/EntityObserver.rb +6 -5
  77. data/lib/sketchup-api-stubs/stubs/Sketchup/ExtensionsManager.rb +9 -8
  78. data/lib/sketchup-api-stubs/stubs/Sketchup/Face.rb +232 -65
  79. data/lib/sketchup-api-stubs/stubs/Sketchup/FrameChangeObserver.rb +1 -1
  80. data/lib/sketchup-api-stubs/stubs/Sketchup/Group.rb +98 -45
  81. data/lib/sketchup-api-stubs/stubs/Sketchup/Http.rb +1 -1
  82. data/lib/sketchup-api-stubs/stubs/Sketchup/Http/Request.rb +48 -41
  83. data/lib/sketchup-api-stubs/stubs/Sketchup/Http/Response.rb +7 -7
  84. data/lib/sketchup-api-stubs/stubs/Sketchup/Image.rb +60 -1
  85. data/lib/sketchup-api-stubs/stubs/Sketchup/ImageRep.rb +47 -7
  86. data/lib/sketchup-api-stubs/stubs/Sketchup/Importer.rb +11 -12
  87. data/lib/sketchup-api-stubs/stubs/Sketchup/InputPoint.rb +33 -21
  88. data/lib/sketchup-api-stubs/stubs/Sketchup/InstanceObserver.rb +6 -4
  89. data/lib/sketchup-api-stubs/stubs/Sketchup/InstancePath.rb +5 -2
  90. data/lib/sketchup-api-stubs/stubs/Sketchup/Layer.rb +115 -68
  91. data/lib/sketchup-api-stubs/stubs/Sketchup/LayerFolder.rb +422 -0
  92. data/lib/sketchup-api-stubs/stubs/Sketchup/Layers.rb +225 -29
  93. data/lib/sketchup-api-stubs/stubs/Sketchup/LayersObserver.rb +118 -5
  94. data/lib/sketchup-api-stubs/stubs/Sketchup/Licensing.rb +2 -2
  95. data/lib/sketchup-api-stubs/stubs/Sketchup/Licensing/ExtensionLicense.rb +1 -1
  96. data/lib/sketchup-api-stubs/stubs/Sketchup/LineStyle.rb +1 -1
  97. data/lib/sketchup-api-stubs/stubs/Sketchup/LineStyles.rb +2 -13
  98. data/lib/sketchup-api-stubs/stubs/Sketchup/Loop.rb +1 -1
  99. data/lib/sketchup-api-stubs/stubs/Sketchup/Material.rb +8 -10
  100. data/lib/sketchup-api-stubs/stubs/Sketchup/Materials.rb +16 -9
  101. data/lib/sketchup-api-stubs/stubs/Sketchup/MaterialsObserver.rb +6 -5
  102. data/lib/sketchup-api-stubs/stubs/Sketchup/Menu.rb +9 -11
  103. data/lib/sketchup-api-stubs/stubs/Sketchup/Model.rb +126 -73
  104. data/lib/sketchup-api-stubs/stubs/Sketchup/ModelObserver.rb +5 -4
  105. data/lib/sketchup-api-stubs/stubs/Sketchup/OptionsManager.rb +2 -3
  106. data/lib/sketchup-api-stubs/stubs/Sketchup/OptionsProvider.rb +7 -7
  107. data/lib/sketchup-api-stubs/stubs/Sketchup/OptionsProviderObserver.rb +4 -4
  108. data/lib/sketchup-api-stubs/stubs/Sketchup/Page.rb +143 -40
  109. data/lib/sketchup-api-stubs/stubs/Sketchup/Pages.rb +22 -12
  110. data/lib/sketchup-api-stubs/stubs/Sketchup/PagesObserver.rb +6 -5
  111. data/lib/sketchup-api-stubs/stubs/Sketchup/PickHelper.rb +37 -15
  112. data/lib/sketchup-api-stubs/stubs/Sketchup/RegionalSettings.rb +1 -1
  113. data/lib/sketchup-api-stubs/stubs/Sketchup/RenderingOptions.rb +1 -1
  114. data/lib/sketchup-api-stubs/stubs/Sketchup/RenderingOptionsObserver.rb +5 -4
  115. data/lib/sketchup-api-stubs/stubs/Sketchup/SectionPlane.rb +1 -1
  116. data/lib/sketchup-api-stubs/stubs/Sketchup/Selection.rb +10 -5
  117. data/lib/sketchup-api-stubs/stubs/Sketchup/SelectionObserver.rb +20 -20
  118. data/lib/sketchup-api-stubs/stubs/Sketchup/Set.rb +1 -1
  119. data/lib/sketchup-api-stubs/stubs/Sketchup/ShadowInfo.rb +5 -5
  120. data/lib/sketchup-api-stubs/stubs/Sketchup/ShadowInfoObserver.rb +6 -4
  121. data/lib/sketchup-api-stubs/stubs/Sketchup/Skp.rb +40 -0
  122. data/lib/sketchup-api-stubs/stubs/Sketchup/Style.rb +1 -1
  123. data/lib/sketchup-api-stubs/stubs/Sketchup/Styles.rb +9 -3
  124. data/lib/sketchup-api-stubs/stubs/Sketchup/Text.rb +1 -1
  125. data/lib/sketchup-api-stubs/stubs/Sketchup/Texture.rb +14 -22
  126. data/lib/sketchup-api-stubs/stubs/Sketchup/TextureWriter.rb +1 -1
  127. data/lib/sketchup-api-stubs/stubs/Sketchup/Tool.rb +31 -25
  128. data/lib/sketchup-api-stubs/stubs/Sketchup/Tools.rb +2 -2
  129. data/lib/sketchup-api-stubs/stubs/Sketchup/ToolsObserver.rb +6 -4
  130. data/lib/sketchup-api-stubs/stubs/Sketchup/UVHelper.rb +32 -22
  131. data/lib/sketchup-api-stubs/stubs/Sketchup/Vertex.rb +1 -1
  132. data/lib/sketchup-api-stubs/stubs/Sketchup/View.rb +73 -67
  133. data/lib/sketchup-api-stubs/stubs/Sketchup/ViewObserver.rb +6 -4
  134. data/lib/sketchup-api-stubs/stubs/UI/Command.rb +13 -6
  135. data/lib/sketchup-api-stubs/stubs/UI/HtmlDialog.rb +132 -10
  136. data/lib/sketchup-api-stubs/stubs/UI/Notification.rb +94 -54
  137. data/lib/sketchup-api-stubs/stubs/UI/Toolbar.rb +1 -1
  138. data/lib/sketchup-api-stubs/stubs/UI/WebDialog.rb +3 -3
  139. data/lib/sketchup-api-stubs/stubs/_top_level.rb +3 -1
  140. data/lib/sketchup-api-stubs/stubs/array.rb +1 -1
  141. data/lib/sketchup-api-stubs/stubs/geom.rb +4 -1
  142. data/lib/sketchup-api-stubs/stubs/languagehandler.rb +1 -1
  143. data/lib/sketchup-api-stubs/stubs/length.rb +1 -1
  144. data/lib/sketchup-api-stubs/stubs/numeric.rb +1 -1
  145. data/lib/sketchup-api-stubs/stubs/sketchup.rb +66 -23
  146. data/lib/sketchup-api-stubs/stubs/sketchupextension.rb +1 -1
  147. data/lib/sketchup-api-stubs/stubs/string.rb +1 -1
  148. data/lib/sketchup-api-stubs/stubs/ui.rb +17 -12
  149. metadata +5 -3
@@ -1,9 +1,11 @@
1
- # Copyright:: Copyright 2020 Trimble Inc.
1
+ # Copyright:: Copyright 2021 Trimble Inc.
2
2
  # License:: The MIT License (MIT)
3
3
 
4
- # This observer interface is implemented to react to view events. To implement
5
- # this observer, create a Ruby class of this type, override the desired
6
- # methods, and add an instance of the observer to the view object.
4
+ # This observer interface is implemented to react to view events.
5
+ #
6
+ # @abstract To implement this observer, create a Ruby class of this type,
7
+ # override the desired methods, and add an instance of the observer to the
8
+ # view object.
7
9
  #
8
10
  # @example
9
11
  # # This is an example of an observer that watches tool interactions.
@@ -1,4 +1,4 @@
1
- # Copyright:: Copyright 2020 Trimble Inc.
1
+ # Copyright:: Copyright 2021 Trimble Inc.
2
2
  # License:: The MIT License (MIT)
3
3
 
4
4
  # The Command class is the preferred class for adding tools to the menus and
@@ -87,10 +87,10 @@ class UI::Command
87
87
  end
88
88
 
89
89
  # The large_icon= method is used to identify the icon file for the command's
90
- # large icon. large icons should be 24x24 pixel images for best display
90
+ # large icon. large icons should be 32x32 pixel images for best display
91
91
  # quality.
92
92
  #
93
- # Since SketchUp 2016 it is possible to provide vector images for the cursors.
93
+ # Since SketchUp 2016 it is possible to provide vector images for the command.
94
94
  # SVG format for Windows and PDF format for OS X. Since the vector images scale
95
95
  # for both small and large icon sizes, you may choose to use only one vector
96
96
  # image for both variants.
@@ -150,8 +150,11 @@ class UI::Command
150
150
  end
151
151
 
152
152
  # The {#set_validation_proc} method allows you to change whether the command
153
- # is enabled, checked, etc. based on the user state. For example, you might
154
- # want your command to be disabled unless the user has a current selection.
153
+ # is enabled, checked, etc. For instance, the command toggling a dialog window
154
+ # may be displayed as checked while the dialog is open.
155
+ #
156
+ # @bug On Mac the validation proc isn't called as often as it should. For
157
+ # instance a selection change doesn't trigger it.
155
158
  #
156
159
  # @example
157
160
  # # Create a command object.
@@ -168,6 +171,10 @@ class UI::Command
168
171
  # }
169
172
  # UI.menu("Draw").add_item(cmd)
170
173
  #
174
+ # @note Avoid disabling an command as it often isn't obvious to the user why
175
+ # it is disabled. Prefer keeping the command enabled but show an error
176
+ # message if pressed when it cannot be used.
177
+ #
171
178
  # @return [UI::Command]
172
179
  #
173
180
  # @version SketchUp 6.0
@@ -199,7 +206,7 @@ class UI::Command
199
206
  end
200
207
 
201
208
  # The small_icon= method is used to identify the icon file for the command's
202
- # small icon. Small icons should be 16x16 pixel images for best display
209
+ # small icon. Small icons should be 24x24 pixel images for best display
203
210
  # quality.
204
211
  #
205
212
  # Since SketchUp 2016 it is possible to provide vector images for the cursors.
@@ -1,4 +1,4 @@
1
- # Copyright:: Copyright 2020 Trimble Inc.
1
+ # Copyright:: Copyright 2021 Trimble Inc.
2
2
  # License:: The MIT License (MIT)
3
3
 
4
4
  # The Ruby HtmlDialog class allows you to create and interact with HTML dialog
@@ -14,11 +14,29 @@
14
14
  # "normal" DPI. The units given will be multiplied by the same factor as
15
15
  # returned by {UI.scale_factor}.
16
16
  #
17
+ # For usage examples, including how to migrate from the old WebDialog class,
18
+ # see https://github.com/SketchUp/htmldialog-examples.
19
+ #
20
+ # HtmlDialog uses the following versions of CEF (Chromium Embedded Framework):
21
+ #
22
+ # [SketchUp 2021.1]
23
+ # CEF 88
24
+ # [SketchUp 2019.0]
25
+ # CEF 64
26
+ # [SketchUp 2018.0]
27
+ # CEF 56
28
+ # [SketchUp 2017.0]
29
+ # CEF 52
30
+ #
17
31
  # @version SketchUp 2017
18
32
  class UI::HtmlDialog
19
33
 
20
34
  # Constants
21
35
 
36
+ CEF_VERSION = nil # Stub value.
37
+
38
+ CHROME_VERSION = nil # Stub value.
39
+
22
40
  STYLE_DIALOG = nil # Stub value.
23
41
  STYLE_UTILITY = nil # Stub value.
24
42
  STYLE_WINDOW = nil # Stub value.
@@ -78,11 +96,16 @@ class UI::HtmlDialog
78
96
  # The {#bring_to_front} method is used to bring the window to the front,
79
97
  # putting it on top of other windows even if its minimized.
80
98
  #
99
+ # @bug Prior to SketchUp 2021.1, on Mac, the focus the was not being set
100
+ # on the {UI::HtmlDialog}.
101
+ #
81
102
  # @example
82
103
  # dialog.bring_to_front
83
104
  #
84
105
  # @return [nil]
85
106
  #
107
+ # @see Sketchup.focus
108
+ #
86
109
  # @version SketchUp 2017
87
110
  def bring_to_front
88
111
  end
@@ -94,7 +117,7 @@ class UI::HtmlDialog
94
117
  # @example
95
118
  # dialog.center
96
119
  #
97
- # @return [true]
120
+ # @return [true] This always return true, never false.
98
121
  #
99
122
  # @version SketchUp 2017
100
123
  def center
@@ -127,8 +150,54 @@ class UI::HtmlDialog
127
150
  def execute_script(script)
128
151
  end
129
152
 
153
+ # The {#get_content_size} method is used to get the content size of the HtmlDialog, in logical pixels.
154
+ #
155
+ # @example
156
+ # width, height = dialog.get_content_size
157
+ #
158
+ # @return [Array(Integer, Integer), nil] Content width and height of the HtmlDialog.
159
+ # A nil value is returned if the HtmlDialog
160
+ # is not visible.
161
+ #
162
+ # @version SketchUp 2021.1
163
+ def get_content_size
164
+ end
165
+
166
+ # The {#get_position} method is used to get the position of the HtmlDialog
167
+ # relative to the screen, in logical pixels.
168
+ #
169
+ # @example
170
+ # left, top = dialog.get_position
171
+ #
172
+ # @return [Array(Integer, Integer), nil] Left and top position of the dialog.
173
+ # A nil value is returned if the HtmlDialog
174
+ # is not visible.
175
+ #
176
+ # @version SketchUp 2021.1
177
+ def get_position
178
+ end
179
+
180
+ # The {#get_size} method is used to get the outer frame size of the HtmlDialog, in logical pixels.
181
+ #
182
+ # @example
183
+ # width, height = dialog.get_size
184
+ #
185
+ # @return [Array(Integer, Integer), nil] Outer frame width and height of the HtmlDialog.
186
+ # A nil value is returned if the HtmlDialog
187
+ # is not visible.
188
+ #
189
+ # @version SketchUp 2021.1
190
+ def get_size
191
+ end
192
+
130
193
  # The new method is used to create a new HtmlDialog.
131
194
  #
195
+ # When +use_content_size+ is set to +true+, +width+, +height+, +min_width+,
196
+ # +max width+, +min_height+, +max_height+ will represent the size of the
197
+ # content area of the window. This excludes the titlebar and the window frame.
198
+ # When +use_content_size+ is set to +false+ (the default value),
199
+ # the size dimensions will represent the outer frame size.
200
+ #
132
201
  # The +properties+ hash accepts an optional key +style+ where the value is
133
202
  # one of:
134
203
  #
@@ -141,7 +210,7 @@ class UI::HtmlDialog
141
210
  # [+UI::HtmlDialog::STYLE_UTILITY+] HtmlDialog is shown with small titlebar
142
211
  # and stays on top of SketchUp.
143
212
  #
144
- # @example
213
+ # @example With options Hash
145
214
  # dialog = UI::HtmlDialog.new(
146
215
  # {
147
216
  # :dialog_title => "Dialog Example",
@@ -161,10 +230,38 @@ class UI::HtmlDialog
161
230
  # dialog.set_url("http://www.sketchup.com")
162
231
  # dialog.show
163
232
  #
233
+ # @example With keyword style argument
234
+ # dialog = UI::HtmlDialog.new(
235
+ # dialog_title: "Dialog Example",
236
+ # preferences_key: "my_name_my_extension_my_dialog",
237
+ # scrollable: true,
238
+ # resizable: true,
239
+ # width: 600,
240
+ # height: 400,
241
+ # left: 100,
242
+ # top: 100,
243
+ # min_width: 50,
244
+ # min_height: 50,
245
+ # max_width: 1000,
246
+ # max_height: 1000,
247
+ # style: UI::HtmlDialog::STYLE_DIALOG
248
+ # )
249
+ # dialog.set_url("https://www.sketchup.com")
250
+ # dialog.show
251
+ #
164
252
  # @note Prior to SketchUp 2019 the +:width+ and +:height+ provided is ignored
165
253
  # if a +:preference_key+ is also present. To work around this bug on older
166
254
  # versions use {#set_size} after you initialize the dialog.
167
255
  #
256
+ # @note Prefix +preference_key+ with something unique to your extension.
257
+ #
258
+ # @note If there is no reference kept to the HtmlDialog object, the window
259
+ # will close once the garbage collection runs. This behavior can be confusing
260
+ # in trivial test code but is usually not a concern in real life scenarios.
261
+ # Typically a persistent reference, e.g. an instance variable, should be kept
262
+ # to bring the dialog to front, rather than creating a duplicate, if the user
263
+ # should request it a second time.
264
+ #
168
265
  # @option properties [String] :dialog_title
169
266
  #
170
267
  # @option properties [String] :preferences_key
@@ -173,6 +270,8 @@ class UI::HtmlDialog
173
270
  #
174
271
  # @option properties [Boolean] :resizable (true)
175
272
  #
273
+ # @option properties [Boolean] :use_content_size (false)
274
+ #
176
275
  # @option properties [Integer] :width (250)
177
276
  #
178
277
  # @option properties [Integer] :height (250)
@@ -217,6 +316,23 @@ class UI::HtmlDialog
217
316
  def set_can_close
218
317
  end
219
318
 
319
+ # The {#set_content_size} method is used to set the content size of the HtmlDialog, in logical pixels.
320
+ #
321
+ # @example
322
+ # dialog.set_content_size(600, 400)
323
+ #
324
+ # @param [Integer] width
325
+ # Content width of the HtmlDialog.
326
+ #
327
+ # @param [Integer] height
328
+ # Content height of the HtmlDialog.
329
+ #
330
+ # @return [nil]
331
+ #
332
+ # @version SketchUp 2021.1
333
+ def set_content_size(width, height)
334
+ end
335
+
220
336
  # The {#set_file} method is used to identify a local HTML file to display in the
221
337
  # HtmlDialog.
222
338
  #
@@ -265,6 +381,9 @@ class UI::HtmlDialog
265
381
  # The {#set_position} method is used to set the position of the HtmlDialog
266
382
  # relative to the screen, in pixels.
267
383
  #
384
+ # @bug Prior to SketchUp 2021.1, on Windows, calling this method incorrectly
385
+ # set the focus on the {UI::HtmlDialog}.
386
+ #
268
387
  # @example
269
388
  # dialog.set_position(100, 50)
270
389
  #
@@ -274,24 +393,27 @@ class UI::HtmlDialog
274
393
  # @param [Integer] top
275
394
  # The number of pixels from the top of the screen.
276
395
  #
277
- # @return [true]
396
+ # @return [true] This always return true, never false.
278
397
  #
279
398
  # @version SketchUp 2017
280
399
  def set_position(left, top)
281
400
  end
282
401
 
283
- # The {#set_size} method is used to set the size of the HtmlDialog, in pixels.
402
+ # The {#set_size} method is used to set the outer frame size of the HtmlDialog, in pixels.
403
+ #
404
+ # @bug Prior to SketchUp 2021.1, on Windows, calling this method incorrectly
405
+ # set the focus on the {UI::HtmlDialog}.
284
406
  #
285
407
  # @example
286
408
  # dialog.set_size(320, 240)
287
409
  #
288
410
  # @param [Integer] width
289
- # Width of the HtmlDialog.
411
+ # Outer frame width of the HtmlDialog.
290
412
  #
291
413
  # @param [Integer] height
292
- # Height of the HtmlDialog.
414
+ # Outer frame height of the HtmlDialog.
293
415
  #
294
- # @return [true]
416
+ # @return [true] This always return true, never false.
295
417
  #
296
418
  # @version SketchUp 2017
297
419
  def set_size(width, height)
@@ -301,7 +423,7 @@ class UI::HtmlDialog
301
423
  # specific URL. This method allows you to load web sites in a HtmlDialog.
302
424
  #
303
425
  # @example
304
- # dialog.set_url("http://www.sketchup.com")
426
+ # dialog.set_url("https://www.sketchup.com")
305
427
  #
306
428
  # @param [String] url
307
429
  # The URL for a specific web site.
@@ -343,7 +465,7 @@ class UI::HtmlDialog
343
465
  # dialog.bring_to_front
344
466
  # else
345
467
  # dialog = UI::HtmlDialog.new
346
- # dialog.set_url("http://www.sketchup.com")
468
+ # dialog.set_url("https://www.sketchup.com")
347
469
  # dialog.show
348
470
  # end
349
471
  #
@@ -1,10 +1,26 @@
1
- # Copyright:: Copyright 2020 Trimble Inc.
1
+ # Copyright:: Copyright 2021 Trimble Inc.
2
2
  # License:: The MIT License (MIT)
3
3
 
4
- # UI::Notification objects allows you to show native notifications in the
5
- # desktop, they are positioned in the top right of your screen, they can be
6
- # customized to have a message, icon and accept and/or dismiss buttons with
7
- # callback blocks.
4
+ # {UI::Notification} objects allows you to show native notifications in the
5
+ # desktop. Notifications can have a message, icon and accept and/or dismiss
6
+ # buttons with callback blocks.
7
+ #
8
+ # @example
9
+ # # For consistency, the accept (yes) and the dismiss (no) buttons
10
+ # # are always displayed in the same order.
11
+ # message = "A new version of pizza is available. Install now?"
12
+ # @notification = UI::Notification.new(sketchup_extension, message)
13
+ # @notification.on_accept("Pizza!") { puts "Pizza" }
14
+ # @notification.on_dismiss("No thanks") { puts "No pizza" }
15
+ # @notification.show
16
+ #
17
+ # # The two options are however not treated differently by SketchUp and can
18
+ # # also be used for questions with no strict yes/no answer.
19
+ # message = "Pizza clashes with health. Select which one to keep."
20
+ # @notification = UI::Notification.new(sketchup_extension, message)
21
+ # @notification.on_accept("Pizza") { puts "Pizza" }
22
+ # @notification.on_dismiss("Health") { puts "Salad" }
23
+ # @notification.show
8
24
  #
9
25
  # @version SketchUp 2017
10
26
  class UI::Notification
@@ -15,9 +31,10 @@ class UI::Notification
15
31
  # the file system path.
16
32
  #
17
33
  # @example
18
- # notification = UI::Notification.new(sketchup_extension, "Hello world", "/path/to/icon", "icon Tooltip")
19
- # puts "Icon Name: #{notification.icon_name}"
20
- # notification.show
34
+ # @notification = UI::Notification.new(sketchup_extension, "Hello world", "/path/to/icon",
35
+ # "Icon Tooltip")
36
+ # puts "Icon Name: #{@notification.icon_name}"
37
+ # @notification.show
21
38
  #
22
39
  # @return [String]
23
40
  #
@@ -29,9 +46,9 @@ class UI::Notification
29
46
  # has to be a local filesystem path.
30
47
  #
31
48
  # @example
32
- # notification = UI::Notification.new(sketchup_extension, "Hello world")
33
- # notification.icon_name = "/path/to/icon"
34
- # notification.show
49
+ # @notification = UI::Notification.new(sketchup_extension, "Hello world")
50
+ # @notification.icon_name = "/path/to/icon"
51
+ # @notification.show
35
52
  #
36
53
  # @param [String] icon_name
37
54
  # String providing the icon filesystem path.
@@ -46,9 +63,10 @@ class UI::Notification
46
63
  # the icon.
47
64
  #
48
65
  # @example
49
- # notification = UI::Notification.new(sketchup_extension, "Hello world", "/path/to/icon", "icon Tooltip")
50
- # puts "Tooltip: #{notification.icon_tooltip}"
51
- # notification.show
66
+ # @notification = UI::Notification.new(sketchup_extension, "Hello world", "/path/to/icon",
67
+ # "Icon Tooltip")
68
+ # puts "Tooltip: #{@notification.icon_tooltip}"
69
+ # @notification.show
52
70
  #
53
71
  # @return [String]
54
72
  #
@@ -60,9 +78,9 @@ class UI::Notification
60
78
  # icon.
61
79
  #
62
80
  # @example
63
- # notification = UI::Notification.new(sketchup_extension, "Hello world")
64
- # notification.icon_tooltip = "icon Tooltip"
65
- # notification.show
81
+ # @notification = UI::Notification.new(sketchup_extension, "Hello world")
82
+ # @notification.icon_tooltip = "icon Tooltip"
83
+ # @notification.show
66
84
  #
67
85
  # @param [String] icon_tooltip
68
86
  # String providing the new icon Tooltip.
@@ -73,39 +91,48 @@ class UI::Notification
73
91
  def icon_tooltip=(icon_tooltip)
74
92
  end
75
93
 
76
- # The new method is used to create a new {UI::Notification}.
94
+ # Creates a new {UI::Notification} object.
95
+ #
96
+ # @bug Prior to SketchUp 2018 messages could only be 3 lines long on Windows
97
+ # and 2 lines on Mac. Now the notification expands to fit its content.
77
98
  #
78
- # In order to insert line breaks into the message you need to use +\\r\\n+.
99
+ # @bug Prior to SketchUp 2021.1 SketchUp could crash if the {UI::Notification} object is garbaged
100
+ # collected while it has notifications displayed on the screen. This could happen if the
101
+ # {UI::Notification} object was assigned to a local variable. The local variable would go out of
102
+ # scope and the garbage collector might collect it before the callbacks are invoked.
79
103
  #
80
104
  # @example
81
- # notification = UI::Notification.new(sketchup_extension, "Hello world", "/path/to/icon", "icon Tooltip")
82
- # notification.show
105
+ # @notification = UI::Notification.new(sketchup_extension, "Hello world", "/path/to/icon",
106
+ # "Icon Tooltip")
107
+ # @notification.show
108
+ #
109
+ # @note In order to insert line breaks into the message you need to use +\\r\\n+.
83
110
  #
84
111
  # @param [SketchupExtension] sketchup_extension
85
- # Required sketchup_extension
86
- # to identify the sender.
112
+ # {SketchupExtension} instance used to identify
113
+ # the source of the notification.
87
114
  #
88
115
  # @param [String] message
89
- # Optionally assign the message.
116
+ # Message to display.
90
117
  #
91
118
  # @param [String] icon_name
92
- # Optionally set a path to an image.
119
+ # Path to an icon to display along with the message.
93
120
  #
94
121
  # @param [String] icon_tooltip
95
- # Optionally set an image tooltip.
122
+ # Tooltip for the icon.
96
123
  #
97
124
  # @return [UI::Notification]
98
125
  #
99
126
  # @version SketchUp 2017
100
- def initialize(sketchup_extension, message, icon_name, icon_tooltip)
127
+ def initialize(sketchup_extension, message = nil, icon_name = nil, icon_tooltip = nil)
101
128
  end
102
129
 
103
130
  # Gets the message as string.
104
131
  #
105
132
  # @example
106
- # notification = UI::Notification.new(sketchup_extension)
107
- # puts "This is the current message: #{notification.message}"
108
- # notification.show
133
+ # @notification = UI::Notification.new(sketchup_extension)
134
+ # puts "This is the current message: #{@notification.message}"
135
+ # @notification.show
109
136
  #
110
137
  # @return [String]
111
138
  #
@@ -113,13 +140,16 @@ class UI::Notification
113
140
  def message
114
141
  end
115
142
 
116
- # Sets a new message, notifications are meant for quick & brief messages,
117
- # remember that they are dismissed automatically.
143
+ # Sets a new message. Notifications are meant for quick and brief messages.
144
+ # These message disappear automatically after a short while if they are not
145
+ # interacted with.
118
146
  #
119
147
  # @example
120
- # notification = UI::Notification.new(sketchup_extension)
121
- # notification.message = "Hello world"
122
- # notification.show
148
+ # @notification = UI::Notification.new(sketchup_extension)
149
+ # @notification.message = "Hello world"
150
+ # @notification.show
151
+ #
152
+ # @note In order to insert line breaks into the message you need to use +\\r\\n+.
123
153
  #
124
154
  # @param [String] message
125
155
  # String providing the new message.
@@ -133,12 +163,15 @@ class UI::Notification
133
163
  # Shows a button in the notification with the given title and callback block,
134
164
  # both arguments are required.
135
165
  #
166
+ # @bug Prior to SketchUp 2019 both the accept and dismiss buttons were
167
+ # displayed, even if only one had been implemented.
168
+ #
136
169
  # @example
137
- # notification = UI::Notification.new(sketchup_extension, "Hello world")
138
- # notification.on_accept("Accept") do |notification, title|
170
+ # @notification = UI::Notification.new(sketchup_extension, "Hello world")
171
+ # @notification.on_accept("Accept") do |notification, title|
139
172
  # puts "The user pressed [#{title}] with message #{notification.message}"
140
173
  # end
141
- # notification.show
174
+ # @notification.show
142
175
  #
143
176
  # @param [String] title
144
177
  # Sets the title of the button.
@@ -159,11 +192,11 @@ class UI::Notification
159
192
  # Returns the accept's button title.
160
193
  #
161
194
  # @example
162
- # notification = UI::Notification.new(sketchup_extension, "Hello world")
163
- # notification.on_accept("Accept") do |notification, title|
195
+ # @notification = UI::Notification.new(sketchup_extension, "Hello world")
196
+ # @notification.on_accept("Accept") do |notification, title|
164
197
  # puts "The user pressed #{notification.on_accept_title}"
165
198
  # end
166
- # notification.show
199
+ # @notification.show
167
200
  #
168
201
  # @return [String]
169
202
  #
@@ -171,15 +204,20 @@ class UI::Notification
171
204
  def on_accept_title
172
205
  end
173
206
 
174
- # Shows a button in the notification with the given title and callback block,
175
- # both arguments are required.
207
+ # Shows a button in the notification with the given title and callback block.
208
+ # Both arguments are required. This callback is only called if you press the
209
+ # Dismiss button, not when the time runs out and the notification automatically
210
+ # disappears.
211
+ #
212
+ # @bug Prior to SketchUp 2019 both the accept and dismiss buttons were
213
+ # displayed, even if only one had been implemented.
176
214
  #
177
215
  # @example
178
- # notification = UI::Notification.new(sketchup_extension, "Hello world")
179
- # notification.on_dismiss("Close") do |notification, title|
216
+ # @notification = UI::Notification.new(sketchup_extension, "Hello world")
217
+ # @notification.on_dismiss("Close") do |notification, title|
180
218
  # puts "The user pressed [#{title}] with message #{notification.message}"
181
219
  # end
182
- # notification.show
220
+ # @notification.show
183
221
  #
184
222
  # @param [String] title
185
223
  # Sets the title of the button.
@@ -200,11 +238,11 @@ class UI::Notification
200
238
  # Returns the dismiss's button title.
201
239
  #
202
240
  # @example
203
- # notification = UI::Notification.new(sketchup_extension, "Hello world")
204
- # notification.on_dismiss("Close") do |notification, title|
241
+ # @notification = UI::Notification.new(sketchup_extension, "Hello world")
242
+ # @notification.on_dismiss("Close") do |notification, title|
205
243
  # puts "The user pressed #{notification.on_dismiss_title}"
206
244
  # end
207
- # notification.show
245
+ # @notification.show
208
246
  #
209
247
  # @return [String]
210
248
  #
@@ -212,13 +250,15 @@ class UI::Notification
212
250
  def on_dismiss_title
213
251
  end
214
252
 
215
- # Shows the notification in the top right of the screen, the notifications will
216
- # be ordered from top to bottom if multiple notifications are shown, it will
217
- # automatically be dismissed if no action is taken.
253
+ # Shows the notification. If not interacted with, the notification will
254
+ # disappear without calling any callbacks.
255
+ #
256
+ # @bug If assigned to a local variable SketchUp might crash prior to SketchUp 2021.1.
257
+ # See {#initialize} for more details.
218
258
  #
219
259
  # @example
220
- # notification = UI::Notification.new(sketchup_extension, "Hello world")
221
- # notification.show
260
+ # @notification = UI::Notification.new(sketchup_extension, "Hello world")
261
+ # @notification.show
222
262
  #
223
263
  # @return [Boolean]
224
264
  #