sketchup-api-stubs 0.7.4 → 0.7.8

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 (151) hide show
  1. checksums.yaml +4 -4
  2. data/lib/sketchup-api-stubs/sketchup.rb +148 -145
  3. data/lib/sketchup-api-stubs/stubs/{array.rb → Array.rb} +741 -741
  4. data/lib/sketchup-api-stubs/stubs/Geom/BoundingBox.rb +322 -318
  5. data/lib/sketchup-api-stubs/stubs/Geom/Bounds2d.rb +172 -172
  6. data/lib/sketchup-api-stubs/stubs/Geom/LatLong.rb +126 -126
  7. data/lib/sketchup-api-stubs/stubs/Geom/OrientedBounds2d.rb +102 -102
  8. data/lib/sketchup-api-stubs/stubs/Geom/Point2d.rb +400 -400
  9. data/lib/sketchup-api-stubs/stubs/Geom/Point3d.rb +661 -661
  10. data/lib/sketchup-api-stubs/stubs/Geom/PolygonMesh.rb +523 -492
  11. data/lib/sketchup-api-stubs/stubs/Geom/Transformation.rb +478 -478
  12. data/lib/sketchup-api-stubs/stubs/Geom/Transformation2d.rb +263 -263
  13. data/lib/sketchup-api-stubs/stubs/Geom/UTM.rb +141 -141
  14. data/lib/sketchup-api-stubs/stubs/Geom/Vector2d.rb +522 -522
  15. data/lib/sketchup-api-stubs/stubs/Geom/Vector3d.rb +693 -691
  16. data/lib/sketchup-api-stubs/stubs/{geom.rb → Geom.rb} +351 -348
  17. data/lib/sketchup-api-stubs/stubs/{languagehandler.rb → LanguageHandler.rb} +93 -92
  18. data/lib/sketchup-api-stubs/stubs/Layout/AngularDimension.rb +595 -573
  19. data/lib/sketchup-api-stubs/stubs/Layout/AutoTextDefinition.rb +698 -411
  20. data/lib/sketchup-api-stubs/stubs/Layout/AutoTextDefinitions.rb +183 -174
  21. data/lib/sketchup-api-stubs/stubs/Layout/ConnectionPoint.rb +70 -70
  22. data/lib/sketchup-api-stubs/stubs/Layout/Document.rb +516 -514
  23. data/lib/sketchup-api-stubs/stubs/Layout/Ellipse.rb +29 -29
  24. data/lib/sketchup-api-stubs/stubs/Layout/Entities.rb +148 -143
  25. data/lib/sketchup-api-stubs/stubs/Layout/Entity.rb +353 -353
  26. data/lib/sketchup-api-stubs/stubs/Layout/FormattedText.rb +354 -349
  27. data/lib/sketchup-api-stubs/stubs/Layout/Grid.rb +311 -311
  28. data/lib/sketchup-api-stubs/stubs/Layout/Group.rb +261 -261
  29. data/lib/sketchup-api-stubs/stubs/Layout/Image.rb +91 -91
  30. data/lib/sketchup-api-stubs/stubs/Layout/Label.rb +370 -371
  31. data/lib/sketchup-api-stubs/stubs/Layout/Layer.rb +218 -218
  32. data/lib/sketchup-api-stubs/stubs/Layout/LayerInstance.rb +128 -128
  33. data/lib/sketchup-api-stubs/stubs/Layout/Layers.rb +225 -220
  34. data/lib/sketchup-api-stubs/stubs/Layout/LinearDimension.rb +567 -567
  35. data/lib/sketchup-api-stubs/stubs/Layout/LockedEntityError.rb +10 -10
  36. data/lib/sketchup-api-stubs/stubs/Layout/LockedLayerError.rb +11 -11
  37. data/lib/sketchup-api-stubs/stubs/Layout/Page.rb +183 -183
  38. data/lib/sketchup-api-stubs/stubs/Layout/PageInfo.rb +387 -387
  39. data/lib/sketchup-api-stubs/stubs/Layout/Pages.rb +209 -204
  40. data/lib/sketchup-api-stubs/stubs/Layout/Path.rb +344 -344
  41. data/lib/sketchup-api-stubs/stubs/Layout/Rectangle.rb +174 -174
  42. data/lib/sketchup-api-stubs/stubs/Layout/SketchUpModel.rb +692 -694
  43. data/lib/sketchup-api-stubs/stubs/Layout/Style.rb +1519 -1519
  44. data/lib/sketchup-api-stubs/stubs/Layout/Table.rb +290 -290
  45. data/lib/sketchup-api-stubs/stubs/Layout/TableCell.rb +149 -149
  46. data/lib/sketchup-api-stubs/stubs/Layout/TableColumn.rb +139 -139
  47. data/lib/sketchup-api-stubs/stubs/Layout/TableRow.rb +135 -135
  48. data/lib/sketchup-api-stubs/stubs/Layout.rb +25 -25
  49. data/lib/sketchup-api-stubs/stubs/{length.rb → Length.rb} +278 -278
  50. data/lib/sketchup-api-stubs/stubs/{numeric.rb → Numeric.rb} +249 -249
  51. data/lib/sketchup-api-stubs/stubs/Sketchup/Animation.rb +144 -140
  52. data/lib/sketchup-api-stubs/stubs/Sketchup/AppObserver.rb +169 -157
  53. data/lib/sketchup-api-stubs/stubs/Sketchup/ArcCurve.rb +209 -209
  54. data/lib/sketchup-api-stubs/stubs/Sketchup/AttributeDictionaries.rb +152 -152
  55. data/lib/sketchup-api-stubs/stubs/Sketchup/AttributeDictionary.rb +286 -281
  56. data/lib/sketchup-api-stubs/stubs/Sketchup/Axes.rb +149 -149
  57. data/lib/sketchup-api-stubs/stubs/Sketchup/Behavior.rb +302 -328
  58. data/lib/sketchup-api-stubs/stubs/Sketchup/Camera.rb +478 -577
  59. data/lib/sketchup-api-stubs/stubs/Sketchup/ClassificationSchema.rb +63 -63
  60. data/lib/sketchup-api-stubs/stubs/Sketchup/Classifications.rb +122 -122
  61. data/lib/sketchup-api-stubs/stubs/Sketchup/Color.rb +294 -281
  62. data/lib/sketchup-api-stubs/stubs/Sketchup/ComponentDefinition.rb +619 -562
  63. data/lib/sketchup-api-stubs/stubs/Sketchup/ComponentInstance.rb +593 -593
  64. data/lib/sketchup-api-stubs/stubs/Sketchup/Console.rb +76 -76
  65. data/lib/sketchup-api-stubs/stubs/Sketchup/ConstructionLine.rb +257 -257
  66. data/lib/sketchup-api-stubs/stubs/Sketchup/ConstructionPoint.rb +32 -32
  67. data/lib/sketchup-api-stubs/stubs/Sketchup/Curve.rb +201 -194
  68. data/lib/sketchup-api-stubs/stubs/Sketchup/DefinitionList.rb +426 -329
  69. data/lib/sketchup-api-stubs/stubs/Sketchup/DefinitionObserver.rb +74 -72
  70. data/lib/sketchup-api-stubs/stubs/Sketchup/DefinitionsObserver.rb +104 -102
  71. data/lib/sketchup-api-stubs/stubs/Sketchup/Dimension.rb +165 -165
  72. data/lib/sketchup-api-stubs/stubs/Sketchup/DimensionLinear.rb +306 -312
  73. data/lib/sketchup-api-stubs/stubs/Sketchup/DimensionObserver.rb +42 -38
  74. data/lib/sketchup-api-stubs/stubs/Sketchup/DimensionRadial.rb +87 -87
  75. data/lib/sketchup-api-stubs/stubs/Sketchup/Drawingelement.rb +396 -390
  76. data/lib/sketchup-api-stubs/stubs/Sketchup/Edge.rb +502 -508
  77. data/lib/sketchup-api-stubs/stubs/Sketchup/EdgeUse.rb +211 -211
  78. data/lib/sketchup-api-stubs/stubs/Sketchup/Entities.rb +1205 -1119
  79. data/lib/sketchup-api-stubs/stubs/Sketchup/EntitiesBuilder.rb +272 -0
  80. data/lib/sketchup-api-stubs/stubs/Sketchup/EntitiesObserver.rb +127 -125
  81. data/lib/sketchup-api-stubs/stubs/Sketchup/Entity.rb +545 -544
  82. data/lib/sketchup-api-stubs/stubs/Sketchup/EntityObserver.rb +60 -59
  83. data/lib/sketchup-api-stubs/stubs/Sketchup/ExtensionsManager.rb +126 -125
  84. data/lib/sketchup-api-stubs/stubs/Sketchup/Face.rb +937 -750
  85. data/lib/sketchup-api-stubs/stubs/Sketchup/FrameChangeObserver.rb +104 -104
  86. data/lib/sketchup-api-stubs/stubs/Sketchup/Group.rb +750 -697
  87. data/lib/sketchup-api-stubs/stubs/Sketchup/Http/Request.rb +292 -285
  88. data/lib/sketchup-api-stubs/stubs/Sketchup/Http/Response.rb +62 -62
  89. data/lib/sketchup-api-stubs/stubs/Sketchup/Http.rb +27 -27
  90. data/lib/sketchup-api-stubs/stubs/Sketchup/Image.rb +468 -409
  91. data/lib/sketchup-api-stubs/stubs/Sketchup/ImageRep.rb +266 -226
  92. data/lib/sketchup-api-stubs/stubs/Sketchup/Importer.rb +189 -190
  93. data/lib/sketchup-api-stubs/stubs/Sketchup/InputPoint.rb +407 -393
  94. data/lib/sketchup-api-stubs/stubs/Sketchup/InstanceObserver.rb +84 -82
  95. data/lib/sketchup-api-stubs/stubs/Sketchup/InstancePath.rb +306 -303
  96. data/lib/sketchup-api-stubs/stubs/Sketchup/Layer.rb +326 -285
  97. data/lib/sketchup-api-stubs/stubs/Sketchup/LayerFolder.rb +422 -0
  98. data/lib/sketchup-api-stubs/stubs/Sketchup/Layers.rb +427 -244
  99. data/lib/sketchup-api-stubs/stubs/Sketchup/LayersObserver.rb +249 -136
  100. data/lib/sketchup-api-stubs/stubs/Sketchup/Licensing/ExtensionLicense.rb +86 -86
  101. data/lib/sketchup-api-stubs/stubs/Sketchup/Licensing.rb +48 -48
  102. data/lib/sketchup-api-stubs/stubs/Sketchup/LineStyle.rb +24 -24
  103. data/lib/sketchup-api-stubs/stubs/Sketchup/LineStyles.rb +112 -112
  104. data/lib/sketchup-api-stubs/stubs/Sketchup/Loop.rb +137 -137
  105. data/lib/sketchup-api-stubs/stubs/Sketchup/Material.rb +414 -416
  106. data/lib/sketchup-api-stubs/stubs/Sketchup/Materials.rb +318 -311
  107. data/lib/sketchup-api-stubs/stubs/Sketchup/MaterialsObserver.rb +142 -141
  108. data/lib/sketchup-api-stubs/stubs/Sketchup/Menu.rb +93 -95
  109. data/lib/sketchup-api-stubs/stubs/Sketchup/Model.rb +1651 -1638
  110. data/lib/sketchup-api-stubs/stubs/Sketchup/ModelObserver.rb +357 -356
  111. data/lib/sketchup-api-stubs/stubs/Sketchup/OptionsManager.rb +131 -132
  112. data/lib/sketchup-api-stubs/stubs/Sketchup/OptionsProvider.rb +284 -284
  113. data/lib/sketchup-api-stubs/stubs/Sketchup/OptionsProviderObserver.rb +58 -58
  114. data/lib/sketchup-api-stubs/stubs/Sketchup/Page.rb +797 -770
  115. data/lib/sketchup-api-stubs/stubs/Sketchup/Pages.rb +363 -353
  116. data/lib/sketchup-api-stubs/stubs/Sketchup/PagesObserver.rb +77 -76
  117. data/lib/sketchup-api-stubs/stubs/Sketchup/PickHelper.rb +477 -456
  118. data/lib/sketchup-api-stubs/stubs/Sketchup/RegionalSettings.rb +43 -43
  119. data/lib/sketchup-api-stubs/stubs/Sketchup/RenderingOptions.rb +364 -364
  120. data/lib/sketchup-api-stubs/stubs/Sketchup/RenderingOptionsObserver.rb +45 -44
  121. data/lib/sketchup-api-stubs/stubs/Sketchup/SectionPlane.rb +150 -150
  122. data/lib/sketchup-api-stubs/stubs/Sketchup/Selection.rb +459 -454
  123. data/lib/sketchup-api-stubs/stubs/Sketchup/SelectionObserver.rb +115 -115
  124. data/lib/sketchup-api-stubs/stubs/Sketchup/Set.rb +212 -212
  125. data/lib/sketchup-api-stubs/stubs/Sketchup/ShadowInfo.rb +260 -257
  126. data/lib/sketchup-api-stubs/stubs/Sketchup/ShadowInfoObserver.rb +59 -57
  127. data/lib/sketchup-api-stubs/stubs/Sketchup/Skp.rb +40 -0
  128. data/lib/sketchup-api-stubs/stubs/Sketchup/Style.rb +69 -69
  129. data/lib/sketchup-api-stubs/stubs/Sketchup/Styles.rb +217 -211
  130. data/lib/sketchup-api-stubs/stubs/Sketchup/Text.rb +262 -262
  131. data/lib/sketchup-api-stubs/stubs/Sketchup/Texture.rb +217 -225
  132. data/lib/sketchup-api-stubs/stubs/Sketchup/TextureWriter.rb +237 -237
  133. data/lib/sketchup-api-stubs/stubs/Sketchup/Tool.rb +837 -829
  134. data/lib/sketchup-api-stubs/stubs/Sketchup/Tools.rb +132 -132
  135. data/lib/sketchup-api-stubs/stubs/Sketchup/ToolsObserver.rb +156 -154
  136. data/lib/sketchup-api-stubs/stubs/Sketchup/UVHelper.rb +75 -61
  137. data/lib/sketchup-api-stubs/stubs/Sketchup/Vertex.rb +142 -142
  138. data/lib/sketchup-api-stubs/stubs/Sketchup/View.rb +1317 -1301
  139. data/lib/sketchup-api-stubs/stubs/Sketchup/ViewObserver.rb +45 -43
  140. data/lib/sketchup-api-stubs/stubs/{sketchup.rb → Sketchup.rb} +1360 -1310
  141. data/lib/sketchup-api-stubs/stubs/{sketchupextension.rb → SketchupExtension.rb} +353 -353
  142. data/lib/sketchup-api-stubs/stubs/{string.rb → String.rb} +24 -24
  143. data/lib/sketchup-api-stubs/stubs/UI/Command.rb +389 -310
  144. data/lib/sketchup-api-stubs/stubs/UI/HtmlDialog.rb +496 -356
  145. data/lib/sketchup-api-stubs/stubs/UI/Notification.rb +269 -229
  146. data/lib/sketchup-api-stubs/stubs/UI/Toolbar.rb +240 -240
  147. data/lib/sketchup-api-stubs/stubs/UI/WebDialog.rb +635 -633
  148. data/lib/sketchup-api-stubs/stubs/{ui.rb → UI.rb} +683 -667
  149. data/lib/sketchup-api-stubs/stubs/_top_level.rb +311 -311
  150. data/lib/sketchup-api-stubs.rb +1 -1
  151. metadata +15 -12
@@ -1,356 +1,496 @@
1
- # Copyright:: Copyright 2020 Trimble Inc.
2
- # License:: The MIT License (MIT)
3
-
4
- # The Ruby HtmlDialog class allows you to create and interact with HTML dialog
5
- # boxes from Ruby. This is the best way to generate complex, embedded UIs
6
- # inside SketchUp, but it does generally require HTML and JavaScript expertise.
7
- #
8
- # If your goal is to simple display a website to your users, consider using
9
- # {UI#openURL}, which will show them a web page in their default browser rather
10
- # than inside a dialog in SketchUp.
11
- #
12
- # The left, top, width, height etc. dimensions of the dialog are in logical
13
- # units. This means you provide the units as if they where on a monitor with
14
- # "normal" DPI. The units given will be multiplied by the same factor as
15
- # returned by {UI.scale_factor}.
16
- #
17
- # @version SketchUp 2017
18
- class UI::HtmlDialog
19
-
20
- # Constants
21
-
22
- STYLE_DIALOG = nil # Stub value.
23
- STYLE_UTILITY = nil # Stub value.
24
- STYLE_WINDOW = nil # Stub value.
25
-
26
- # Instance Methods
27
-
28
- # The {#add_action_callback} method establishes a Ruby callback method that your
29
- # html dialog can call to perform some function.
30
- #
31
- # Use the +sketchup.callback_method_name+ to invoke the callback method from your
32
- # html dialog. Your JavaScript in the html dialog will invoke the callback with
33
- # the same number of arguments.
34
- #
35
- # The call is asynchronous. JavaScript call might return before Ruby callback
36
- # even called. Use +onCompleted+ callback to get notified for completion.
37
- #
38
- # Basic types such as booleans, numbers, strings, arrays and hashes are
39
- # automatically converted between Ruby and JavaScript.
40
- #
41
- # @example Ruby Code
42
- # dialog.add_action_callback("say") { |action_context, param1, param2|
43
- # puts "JavaScript said #{param1} and #{param2}"
44
- # }
45
- #
46
- # @example JavaScript
47
- # sketchup.say('Hello World', 42);
48
- #
49
- # @example JavaScript with callback
50
- # sketchup.say('Hello World', 42, {
51
- # onCompleted: function() {
52
- # console.log('Ruby side done.');
53
- # }
54
- # });
55
- #
56
- # @note When an HtmlDialog is closed, all callbacks to that instance are
57
- # cleared. Re-attach them if you need to open the dialog again.
58
- #
59
- # @param [String] callback_name
60
- # The name of the callback method to be
61
- # invoked from the html dialog.
62
- #
63
- # @return [Boolean] true if action added successfully, false
64
- # otherwise.
65
- #
66
- # @version SketchUp 2017
67
- #
68
- # @yield [action_context, ...]
69
- #
70
- # @yieldparam [Object] action_context
71
- # action_context Currently unused.
72
- #
73
- # @yieldparam [Object] ...
74
- # The parameters sent from JavaScript.
75
- def add_action_callback(callback_name)
76
- end
77
-
78
- # The {#bring_to_front} method is used to bring the window to the front,
79
- # putting it on top of other windows even if its minimized.
80
- #
81
- # @example
82
- # dialog.bring_to_front
83
- #
84
- # @return [nil]
85
- #
86
- # @version SketchUp 2017
87
- def bring_to_front
88
- end
89
-
90
- # The {#center} method is used to center the HtmlDialog relative to the active
91
- # model window. If there is no active model window, this function doesn't do
92
- # anything.
93
- #
94
- # @example
95
- # dialog.center
96
- #
97
- # @return [true]
98
- #
99
- # @version SketchUp 2017
100
- def center
101
- end
102
-
103
- # The {#close} method is used to close a dialog box.
104
- #
105
- # @example
106
- # dialog.close
107
- #
108
- # @return [nil]
109
- #
110
- # @version SketchUp 2017
111
- def close
112
- end
113
-
114
- # The {#execute_script} method is used to execute a JavaScript string on the
115
- # html dialog asynchronously.
116
- #
117
- # @example
118
- # js_command = "document.getElementById('id').innerHTML = '<b>Hi!</b>'"
119
- # dialog.execute_script(js_command)
120
- #
121
- # @param [String] script
122
- # The JavaScript script to execute on the HtmlDialog.
123
- #
124
- # @return [nil]
125
- #
126
- # @version SketchUp 2017
127
- def execute_script(script)
128
- end
129
-
130
- # The new method is used to create a new HtmlDialog.
131
- #
132
- # The +properties+ hash accepts an optional key +style+ where the value is
133
- # one of:
134
- #
135
- # [+UI::HtmlDialog::STYLE_DIALOG+] HtmlDialog stays at the top of SketchUp.
136
- #
137
- # [+UI::HtmlDialog::STYLE_WINDOW+] HtmlDialog can go behind SketchUp and
138
- # doesn't disappear when SketchUp looses
139
- # focus.
140
- #
141
- # [+UI::HtmlDialog::STYLE_UTILITY+] HtmlDialog is shown with small titlebar
142
- # and stays on top of SketchUp.
143
- #
144
- # @example
145
- # dialog = UI::HtmlDialog.new(
146
- # {
147
- # :dialog_title => "Dialog Example",
148
- # :preferences_key => "com.sample.plugin",
149
- # :scrollable => true,
150
- # :resizable => true,
151
- # :width => 600,
152
- # :height => 400,
153
- # :left => 100,
154
- # :top => 100,
155
- # :min_width => 50,
156
- # :min_height => 50,
157
- # :max_width =>1000,
158
- # :max_height => 1000,
159
- # :style => UI::HtmlDialog::STYLE_DIALOG
160
- # })
161
- # dialog.set_url("http://www.sketchup.com")
162
- # dialog.show
163
- #
164
- # @note Prior to SketchUp 2019 the +:width+ and +:height+ provided is ignored
165
- # if a +:preference_key+ is also present. To work around this bug on older
166
- # versions use {#set_size} after you initialize the dialog.
167
- #
168
- # @option properties [String] :dialog_title
169
- #
170
- # @option properties [String] :preferences_key
171
- #
172
- # @option properties [Boolean] :scrollable
173
- #
174
- # @option properties [Boolean] :resizable (true)
175
- #
176
- # @option properties [Integer] :width (250)
177
- #
178
- # @option properties [Integer] :height (250)
179
- #
180
- # @option properties [Integer] :left (0)
181
- #
182
- # @option properties [Integer] :top (0)
183
- #
184
- # @option properties [Integer] :min_width (0)
185
- #
186
- # @option properties [Integer] :min_height (0)
187
- #
188
- # @option properties [Integer] :max_width (-1)
189
- #
190
- # @option properties [Integer] :max_height (-1)
191
- #
192
- # @option properties [Integer] :style (UI::HtmlDialog::STYLE_DIALOG)
193
- #
194
- # @param [Hash] properties
195
- # A hash containing the initial properties of
196
- # the newly created dialog.
197
- #
198
- # @return [HtmlDialog]
199
- #
200
- # @version SketchUp 2017
201
- def initialize(properties)
202
- end
203
-
204
- # The {#set_can_close} method is used to attach a block that is executed just
205
- # before closing, this block has to return a boolean, if the block returns
206
- # false the close will be canceled.
207
- #
208
- # @example
209
- # dialog.set_can_close { false }
210
- #
211
- # @return [Boolean]
212
- #
213
- # @version SketchUp 2017
214
- #
215
- # @yieldreturn [Boolean] Return a boolean to indicate if the dialogs should
216
- # close.
217
- def set_can_close
218
- end
219
-
220
- # The {#set_file} method is used to identify a local HTML file to display in the
221
- # HtmlDialog.
222
- #
223
- # @example
224
- # dialog.set_file("c:/mypage.html")
225
- #
226
- # @param [String] filename
227
- # The filename for the HtmlDialog file (HTML file)
228
- #
229
- # @return [nil]
230
- #
231
- # @version SketchUp 2017
232
- def set_file(filename)
233
- end
234
-
235
- # The {#set_html} method is used to load a HtmlDialog with a string of provided
236
- # HTML.
237
- #
238
- # @example
239
- # html = '<b>Hello world!</b>'
240
- # dialog.set_html(html)
241
- #
242
- # @param [String] html_string
243
- # A string of valid html to display in your
244
- # HtmlDialog.
245
- #
246
- # @return [nil]
247
- #
248
- # @version SketchUp 2017
249
- def set_html(html_string)
250
- end
251
-
252
- # The {#set_on_closed} method is used to attach a block that will be
253
- # executed when a dialog is already in the process of closing, do any last
254
- # minute operations within this block such as saving the current state.
255
- #
256
- # @example
257
- # dialog.set_on_closed { save_selection }
258
- #
259
- # @return [Boolean]
260
- #
261
- # @version SketchUp 2017
262
- def set_on_closed
263
- end
264
-
265
- # The {#set_position} method is used to set the position of the HtmlDialog
266
- # relative to the screen, in pixels.
267
- #
268
- # @example
269
- # dialog.set_position(100, 50)
270
- #
271
- # @param [Integer] left
272
- # The number of pixels from the left.
273
- #
274
- # @param [Integer] top
275
- # The number of pixels from the top of the screen.
276
- #
277
- # @return [true]
278
- #
279
- # @version SketchUp 2017
280
- def set_position(left, top)
281
- end
282
-
283
- # The {#set_size} method is used to set the size of the HtmlDialog, in pixels.
284
- #
285
- # @example
286
- # dialog.set_size(320, 240)
287
- #
288
- # @param [Integer] width
289
- # Width of the HtmlDialog.
290
- #
291
- # @param [Integer] height
292
- # Height of the HtmlDialog.
293
- #
294
- # @return [true]
295
- #
296
- # @version SketchUp 2017
297
- def set_size(width, height)
298
- end
299
-
300
- # The {#set_url} method is used to load a HtmlDialog with the content at a
301
- # specific URL. This method allows you to load web sites in a HtmlDialog.
302
- #
303
- # @example
304
- # dialog.set_url("http://www.sketchup.com")
305
- #
306
- # @param [String] url
307
- # The URL for a specific web site.
308
- #
309
- # @return [nil]
310
- #
311
- # @version SketchUp 2017
312
- def set_url(url)
313
- end
314
-
315
- # The {#show} method is used to display a non-modal dialog box.
316
- #
317
- # @example
318
- # dialog.show
319
- #
320
- # @return [nil]
321
- #
322
- # @version SketchUp 2017
323
- def show
324
- end
325
-
326
- # The {#show_modal} method is used to display a modal dialog box.
327
- #
328
- # @example
329
- # dialog.show_modal
330
- #
331
- # @return [nil]
332
- #
333
- # @version SketchUp 2017
334
- def show_modal
335
- end
336
-
337
- # The {#visible?} method is useful to tell if the dialog is shown and still
338
- # alive, if the dialog is minimized or not visible on the screen this will
339
- # still return +true+.
340
- #
341
- # @example
342
- # if dialog.visible?
343
- # dialog.bring_to_front
344
- # else
345
- # dialog = UI::HtmlDialog.new
346
- # dialog.set_url("http://www.sketchup.com")
347
- # dialog.show
348
- # end
349
- #
350
- # @return [Boolean] Returns true if the dialog is open.
351
- #
352
- # @version SketchUp 2017
353
- def visible?
354
- end
355
-
356
- end
1
+ # Copyright:: Copyright 2022 Trimble Inc.
2
+ # License:: The MIT License (MIT)
3
+
4
+ # The Ruby HtmlDialog class allows you to create and interact with HTML dialog
5
+ # boxes from Ruby. This is the best way to generate complex, embedded UIs
6
+ # inside SketchUp, but it does generally require HTML and JavaScript expertise.
7
+ #
8
+ # If your goal is to simple display a website to your users, consider using
9
+ # {UI#openURL}, which will show them a web page in their default browser rather
10
+ # than inside a dialog in SketchUp.
11
+ #
12
+ # The left, top, width, height etc. dimensions of the dialog are in logical
13
+ # units. This means you provide the units as if they where on a monitor with
14
+ # "normal" DPI. The units given will be multiplied by the same factor as
15
+ # returned by {UI.scale_factor}.
16
+ #
17
+ # For usage examples, including how to migrate from the old WebDialog class,
18
+ # see https://github.com/SketchUp/htmldialog-examples.
19
+ # You may use the {https://sketchup.github.io/modus-for-sketchup-extensions Trimble Modus}
20
+ # framework for a look and feel of your dialog that matches that of SketchUp's dialogs.
21
+ #
22
+ # HtmlDialog uses the following versions of CEF (Chromium Embedded Framework):
23
+ #
24
+ # [SketchUp 2021.1]
25
+ # CEF 88
26
+ # [SketchUp 2019.0]
27
+ # CEF 64
28
+ # [SketchUp 2018.0]
29
+ # CEF 56
30
+ # [SketchUp 2017.0]
31
+ # CEF 52
32
+ #
33
+ # @version SketchUp 2017
34
+ class UI::HtmlDialog
35
+
36
+ # Constants
37
+
38
+ CEF_VERSION = nil # Stub value.
39
+
40
+ CHROME_VERSION = nil # Stub value.
41
+
42
+ STYLE_DIALOG = nil # Stub value.
43
+ STYLE_UTILITY = nil # Stub value.
44
+ STYLE_WINDOW = nil # Stub value.
45
+
46
+ # Instance Methods
47
+
48
+ # The {#add_action_callback} method establishes a Ruby callback method that your
49
+ # html dialog can call to perform some function.
50
+ #
51
+ # Use the +sketchup.callback_method_name+ to invoke the callback method from your
52
+ # html dialog. Your JavaScript in the html dialog will invoke the callback with
53
+ # the same number of arguments.
54
+ #
55
+ # The call is asynchronous. JavaScript call might return before Ruby callback
56
+ # even called. Use +onCompleted+ callback to get notified for completion.
57
+ #
58
+ # Basic types such as booleans, numbers, strings, arrays and hashes are
59
+ # automatically converted between Ruby and JavaScript.
60
+ #
61
+ # @example Ruby Code
62
+ # dialog.add_action_callback("say") { |action_context, param1, param2|
63
+ # puts "JavaScript said #{param1} and #{param2}"
64
+ # }
65
+ #
66
+ # @example JavaScript
67
+ # sketchup.say('Hello World', 42);
68
+ #
69
+ # @example JavaScript with callback
70
+ # sketchup.say('Hello World', 42, {
71
+ # onCompleted: function() {
72
+ # console.log('Ruby side done.');
73
+ # }
74
+ # });
75
+ #
76
+ # @note When an HtmlDialog is closed, all callbacks to that instance are
77
+ # cleared. Re-attach them if you need to open the dialog again.
78
+ #
79
+ # @param [String] callback_name
80
+ # The name of the callback method to be
81
+ # invoked from the html dialog.
82
+ #
83
+ # @return [Boolean] true if action added successfully, false
84
+ # otherwise.
85
+ #
86
+ # @version SketchUp 2017
87
+ #
88
+ # @yield [action_context, ...]
89
+ #
90
+ # @yieldparam [Object] action_context
91
+ # action_context Currently unused.
92
+ #
93
+ # @yieldparam [Object] ...
94
+ # The parameters sent from JavaScript.
95
+ def add_action_callback(callback_name)
96
+ end
97
+
98
+ # The {#bring_to_front} method is used to bring the window to the front,
99
+ # putting it on top of other windows even if its minimized.
100
+ #
101
+ # @bug Prior to SketchUp 2021.1, on Mac, the focus the was not being set
102
+ # on the {UI::HtmlDialog}.
103
+ #
104
+ # @example
105
+ # dialog.bring_to_front
106
+ #
107
+ # @return [nil]
108
+ #
109
+ # @see Sketchup.focus
110
+ #
111
+ # @version SketchUp 2017
112
+ def bring_to_front
113
+ end
114
+
115
+ # The {#center} method is used to center the HtmlDialog relative to the active
116
+ # model window. If there is no active model window, this function doesn't do
117
+ # anything.
118
+ #
119
+ # @example
120
+ # dialog.center
121
+ #
122
+ # @return [true] This always return true, never false.
123
+ #
124
+ # @version SketchUp 2017
125
+ def center
126
+ end
127
+
128
+ # The {#close} method is used to close a dialog box.
129
+ #
130
+ # @example
131
+ # dialog.close
132
+ #
133
+ # @return [nil]
134
+ #
135
+ # @version SketchUp 2017
136
+ def close
137
+ end
138
+
139
+ # The {#execute_script} method is used to execute a JavaScript string on the
140
+ # html dialog asynchronously.
141
+ #
142
+ # @example
143
+ # js_command = "document.getElementById('id').innerHTML = '<b>Hi!</b>'"
144
+ # dialog.execute_script(js_command)
145
+ #
146
+ # @param [String] script
147
+ # The JavaScript script to execute on the HtmlDialog.
148
+ #
149
+ # @return [nil]
150
+ #
151
+ # @version SketchUp 2017
152
+ def execute_script(script)
153
+ end
154
+
155
+ # The {#get_content_size} method is used to get the content size of the HtmlDialog, in logical
156
+ # pixels.
157
+ #
158
+ # @example
159
+ # width, height = dialog.get_content_size
160
+ #
161
+ # @return [Array(Integer, Integer), nil] Content width and height of the HtmlDialog.
162
+ # A nil value is returned if the HtmlDialog
163
+ # is not visible.
164
+ #
165
+ # @version SketchUp 2021.1
166
+ def get_content_size
167
+ end
168
+
169
+ # The {#get_position} method is used to get the position of the HtmlDialog
170
+ # relative to the screen, in logical pixels.
171
+ #
172
+ # @example
173
+ # left, top = dialog.get_position
174
+ #
175
+ # @return [Array(Integer, Integer), nil] Left and top position of the dialog.
176
+ # A nil value is returned if the HtmlDialog
177
+ # is not visible.
178
+ #
179
+ # @version SketchUp 2021.1
180
+ def get_position
181
+ end
182
+
183
+ # The {#get_size} method is used to get the outer frame size of the HtmlDialog, in logical pixels.
184
+ #
185
+ # @example
186
+ # width, height = dialog.get_size
187
+ #
188
+ # @return [Array(Integer, Integer), nil] Outer frame width and height of the HtmlDialog.
189
+ # A nil value is returned if the HtmlDialog
190
+ # is not visible.
191
+ #
192
+ # @version SketchUp 2021.1
193
+ def get_size
194
+ end
195
+
196
+ # The new method is used to create a new HtmlDialog.
197
+ #
198
+ # In SketchUp 2021.1 +use_content_size+ was added.
199
+ # When set to +true+, +width+, +height+, +min_width+,
200
+ # +max width+, +min_height+, +max_height+ will represent the size of the
201
+ # content area of the window. This excludes the titlebar and the window frame.
202
+ # When +use_content_size+ is set to +false+ (the default value),
203
+ # the size dimensions will represent the outer frame size.
204
+ #
205
+ # The +properties+ hash accepts an optional key +style+ where the value is
206
+ # one of:
207
+ #
208
+ # [+UI::HtmlDialog::STYLE_DIALOG+] HtmlDialog stays at the top of SketchUp.
209
+ #
210
+ # [+UI::HtmlDialog::STYLE_WINDOW+] HtmlDialog can go behind SketchUp and
211
+ # doesn't disappear when SketchUp looses
212
+ # focus.
213
+ #
214
+ # [+UI::HtmlDialog::STYLE_UTILITY+] HtmlDialog is shown with small titlebar
215
+ # and stays on top of SketchUp.
216
+ #
217
+ # @bug Prior to SketchUp 2019 the +:width+ and +:height+ provided is ignored
218
+ # if a +:preference_key+ is also present. To work around this bug on older
219
+ # versions use {#set_size} after you initialize the dialog.
220
+ #
221
+ # @bug SketchUp 2022.0 fixed a bug where position was set incorrectly when
222
+ # +use_content_size+ was set to +true+.
223
+ #
224
+ # @bug SketchUp 2022.0 fixed a bug where +max_height+ and +max_width+ were swapped
225
+ # when +use_content_size+ was set to +true+.
226
+ #
227
+ # @bug SketchUp 2022.0 fixed a bug where +use_content_size+ was not persisted (when
228
+ # +preferences_key+ is set).
229
+ #
230
+ # @bug SketchUp 2022.0 fixed a bug on Mac where size and position of the
231
+ # HtmlDialog were not persisted when SketchUp was closed without first
232
+ # closing the HtmlDialog window.
233
+ #
234
+ # @example With options Hash
235
+ # dialog = UI::HtmlDialog.new(
236
+ # {
237
+ # :dialog_title => "Dialog Example",
238
+ # :preferences_key => "com.sample.plugin",
239
+ # :scrollable => true,
240
+ # :resizable => true,
241
+ # :width => 600,
242
+ # :height => 400,
243
+ # :left => 100,
244
+ # :top => 100,
245
+ # :min_width => 50,
246
+ # :min_height => 50,
247
+ # :max_width =>1000,
248
+ # :max_height => 1000,
249
+ # :style => UI::HtmlDialog::STYLE_DIALOG
250
+ # })
251
+ # dialog.set_url("http://www.sketchup.com")
252
+ # dialog.show
253
+ #
254
+ # @example With keyword style argument
255
+ # dialog = UI::HtmlDialog.new(
256
+ # dialog_title: "Dialog Example",
257
+ # preferences_key: "my_name_my_extension_my_dialog",
258
+ # scrollable: true,
259
+ # resizable: true,
260
+ # width: 600,
261
+ # height: 400,
262
+ # left: 100,
263
+ # top: 100,
264
+ # min_width: 50,
265
+ # min_height: 50,
266
+ # max_width: 1000,
267
+ # max_height: 1000,
268
+ # style: UI::HtmlDialog::STYLE_DIALOG
269
+ # )
270
+ # dialog.set_url("https://www.sketchup.com")
271
+ # dialog.show
272
+ #
273
+ # @note Prefix +preference_key+ with something unique to your extension.
274
+ #
275
+ # @note If there is no reference kept to the HtmlDialog object, the window
276
+ # will close once the garbage collection runs. This behavior can be confusing
277
+ # in trivial test code but is usually not a concern in real life scenarios.
278
+ # Typically a persistent reference, e.g. an instance variable, should be kept
279
+ # to bring the dialog to front, rather than creating a duplicate, if the user
280
+ # should request it a second time.
281
+ #
282
+ # @option properties [String] :dialog_title
283
+ #
284
+ # @option properties [String] :preferences_key
285
+ #
286
+ # @option properties [Boolean] :scrollable
287
+ #
288
+ # @option properties [Boolean] :resizable (true)
289
+ #
290
+ # @option properties [Boolean] :use_content_size (false)
291
+ #
292
+ # @option properties [Integer] :width (250)
293
+ #
294
+ # @option properties [Integer] :height (250)
295
+ #
296
+ # @option properties [Integer] :left (0)
297
+ #
298
+ # @option properties [Integer] :top (0)
299
+ #
300
+ # @option properties [Integer] :min_width (0)
301
+ #
302
+ # @option properties [Integer] :min_height (0)
303
+ #
304
+ # @option properties [Integer] :max_width (-1)
305
+ #
306
+ # @option properties [Integer] :max_height (-1)
307
+ #
308
+ # @option properties [Integer] :style (UI::HtmlDialog::STYLE_DIALOG)
309
+ #
310
+ # @param [Hash] properties
311
+ # A hash containing the initial properties of
312
+ # the newly created dialog.
313
+ #
314
+ # @return [HtmlDialog]
315
+ #
316
+ # @version SketchUp 2017
317
+ def initialize(properties)
318
+ end
319
+
320
+ # The {#set_can_close} method is used to attach a block that is executed just
321
+ # before closing, this block has to return a boolean, if the block returns
322
+ # false the close will be canceled.
323
+ #
324
+ # @example
325
+ # dialog.set_can_close { false }
326
+ #
327
+ # @return [Boolean]
328
+ #
329
+ # @version SketchUp 2017
330
+ #
331
+ # @yieldreturn [Boolean] Return a boolean to indicate if the dialogs should
332
+ # close.
333
+ def set_can_close
334
+ end
335
+
336
+ # The {#set_content_size} method is used to set the content size of the HtmlDialog, in logical
337
+ # pixels.
338
+ #
339
+ # @example
340
+ # dialog.set_content_size(600, 400)
341
+ #
342
+ # @param [Integer] width
343
+ # Content width of the HtmlDialog.
344
+ #
345
+ # @param [Integer] height
346
+ # Content height of the HtmlDialog.
347
+ #
348
+ # @return [nil]
349
+ #
350
+ # @version SketchUp 2021.1
351
+ def set_content_size(width, height)
352
+ end
353
+
354
+ # The {#set_file} method is used to identify a local HTML file to display in the
355
+ # HtmlDialog.
356
+ #
357
+ # @example
358
+ # dialog.set_file("c:/mypage.html")
359
+ #
360
+ # @param [String] filename
361
+ # The filename for the HtmlDialog file (HTML file)
362
+ #
363
+ # @return [nil]
364
+ #
365
+ # @version SketchUp 2017
366
+ def set_file(filename)
367
+ end
368
+
369
+ # The {#set_html} method is used to load a HtmlDialog with a string of provided
370
+ # HTML.
371
+ #
372
+ # @example
373
+ # html = '<b>Hello world!</b>'
374
+ # dialog.set_html(html)
375
+ #
376
+ # @param [String] html_string
377
+ # A string of valid html to display in your
378
+ # HtmlDialog.
379
+ #
380
+ # @return [nil]
381
+ #
382
+ # @version SketchUp 2017
383
+ def set_html(html_string)
384
+ end
385
+
386
+ # The {#set_on_closed} method is used to attach a block that will be
387
+ # executed when a dialog is already in the process of closing, do any last
388
+ # minute operations within this block such as saving the current state.
389
+ #
390
+ # @example
391
+ # dialog.set_on_closed { save_selection }
392
+ #
393
+ # @return [Boolean]
394
+ #
395
+ # @version SketchUp 2017
396
+ def set_on_closed
397
+ end
398
+
399
+ # The {#set_position} method is used to set the position of the HtmlDialog
400
+ # relative to the screen, in pixels.
401
+ #
402
+ # @bug Prior to SketchUp 2021.1, on Windows, calling this method incorrectly
403
+ # set the focus on the {UI::HtmlDialog}.
404
+ #
405
+ # @example
406
+ # dialog.set_position(100, 50)
407
+ #
408
+ # @param [Integer] left
409
+ # The number of pixels from the left.
410
+ #
411
+ # @param [Integer] top
412
+ # The number of pixels from the top of the screen.
413
+ #
414
+ # @return [true] This always return true, never false.
415
+ #
416
+ # @version SketchUp 2017
417
+ def set_position(left, top)
418
+ end
419
+
420
+ # The {#set_size} method is used to set the outer frame size of the HtmlDialog, in pixels.
421
+ #
422
+ # @bug Prior to SketchUp 2021.1, on Windows, calling this method incorrectly
423
+ # set the focus on the {UI::HtmlDialog}.
424
+ #
425
+ # @example
426
+ # dialog.set_size(320, 240)
427
+ #
428
+ # @param [Integer] width
429
+ # Outer frame width of the HtmlDialog.
430
+ #
431
+ # @param [Integer] height
432
+ # Outer frame height of the HtmlDialog.
433
+ #
434
+ # @return [true] This always return true, never false.
435
+ #
436
+ # @version SketchUp 2017
437
+ def set_size(width, height)
438
+ end
439
+
440
+ # The {#set_url} method is used to load a HtmlDialog with the content at a
441
+ # specific URL. This method allows you to load web sites in a HtmlDialog.
442
+ #
443
+ # @example
444
+ # dialog.set_url("https://www.sketchup.com")
445
+ #
446
+ # @param [String] url
447
+ # The URL for a specific web site.
448
+ #
449
+ # @return [nil]
450
+ #
451
+ # @version SketchUp 2017
452
+ def set_url(url)
453
+ end
454
+
455
+ # The {#show} method is used to display a non-modal dialog box.
456
+ #
457
+ # @example
458
+ # dialog.show
459
+ #
460
+ # @return [nil]
461
+ #
462
+ # @version SketchUp 2017
463
+ def show
464
+ end
465
+
466
+ # The {#show_modal} method is used to display a modal dialog box.
467
+ #
468
+ # @example
469
+ # dialog.show_modal
470
+ #
471
+ # @return [nil]
472
+ #
473
+ # @version SketchUp 2017
474
+ def show_modal
475
+ end
476
+
477
+ # The {#visible?} method is useful to tell if the dialog is shown and still
478
+ # alive, if the dialog is minimized or not visible on the screen this will
479
+ # still return +true+.
480
+ #
481
+ # @example
482
+ # if dialog.visible?
483
+ # dialog.bring_to_front
484
+ # else
485
+ # dialog = UI::HtmlDialog.new
486
+ # dialog.set_url("https://www.sketchup.com")
487
+ # dialog.show
488
+ # end
489
+ #
490
+ # @return [Boolean] Returns true if the dialog is open.
491
+ #
492
+ # @version SketchUp 2017
493
+ def visible?
494
+ end
495
+
496
+ end