swing-ui 0.1.25 → 1.0.3

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 (116) hide show
  1. package/LICENSE +5 -4
  2. package/README.md +144 -7
  3. package/SwingUI.js +2611 -0
  4. package/classes/Arc.js +185 -0
  5. package/classes/Button.js +55 -0
  6. package/classes/CheckBox.js +33 -0
  7. package/classes/CheckBoxMenuItem.js +24 -0
  8. package/classes/ComboBox.js +329 -0
  9. package/classes/ComponentContainer.js +828 -0
  10. package/classes/ContextMenu.js +141 -0
  11. package/classes/DocumentEditor.js +168 -0
  12. package/classes/Ellipse.js +76 -0
  13. package/classes/InternalWindow.js +397 -0
  14. package/classes/InternalWindowContainer.js +93 -0
  15. package/classes/Label.js +52 -0
  16. package/classes/Line.js +105 -0
  17. package/classes/List.js +452 -0
  18. package/classes/MediaPlayer.js +504 -0
  19. package/classes/Menu.js +74 -0
  20. package/classes/MenuBar.js +56 -0
  21. package/classes/MenuItem.js +92 -0
  22. package/classes/Panel.js +50 -0
  23. package/classes/PasswordField.js +47 -0
  24. package/classes/Polygon.js +236 -0
  25. package/classes/Polyline.js +240 -0
  26. package/classes/ProgressBar.js +62 -0
  27. package/classes/RadioButton.js +110 -0
  28. package/classes/RadioButtonMenuItem.js +106 -0
  29. package/classes/Rectangle.js +199 -0
  30. package/classes/ScrollPane.js +53 -0
  31. package/classes/ScrollableComponent.js +141 -0
  32. package/classes/Separator.js +24 -0
  33. package/classes/Shape.js +584 -0
  34. package/classes/ShapeContainer.js +231 -0
  35. package/classes/Slider.js +172 -0
  36. package/classes/Spinner.js +172 -0
  37. package/classes/SplitView.js +82 -0
  38. package/classes/Stroke.js +115 -0
  39. package/classes/Table.js +982 -0
  40. package/classes/Tabs.js +228 -0
  41. package/classes/TextArea.js +125 -0
  42. package/classes/TextComponent.js +207 -0
  43. package/classes/TextField.js +128 -0
  44. package/classes/TextShape.js +123 -0
  45. package/classes/ToggleButton.js +147 -0
  46. package/classes/ToolBar.js +120 -0
  47. package/classes/TrayIcon.js +54 -0
  48. package/classes/Tree.js +569 -0
  49. package/classes/UIComponent.js +2154 -0
  50. package/classes/Window.js +609 -0
  51. package/enums.js +298 -0
  52. package/fonts.conf +32 -0
  53. package/functions.js +254 -0
  54. package/icon.png +0 -0
  55. package/index.js +109 -4
  56. package/jar/gui-11.jar +0 -0
  57. package/jar/lib/flatlaf.jar +0 -0
  58. package/jar/lib/jna.jar +0 -0
  59. package/package.json +58 -33
  60. package/typedefs.js +973 -0
  61. package/types/SwingUI.d.ts +727 -0
  62. package/types/classes/Arc.d.ts +111 -0
  63. package/types/classes/Button.d.ts +38 -0
  64. package/types/classes/CheckBox.d.ts +22 -0
  65. package/types/classes/CheckBoxMenuItem.d.ts +18 -0
  66. package/types/classes/ComboBox.d.ts +172 -0
  67. package/types/classes/ComponentContainer.d.ts +131 -0
  68. package/types/classes/ContextMenu.d.ts +74 -0
  69. package/types/classes/DocumentEditor.d.ts +95 -0
  70. package/types/classes/Ellipse.d.ts +34 -0
  71. package/types/classes/InternalWindow.d.ts +163 -0
  72. package/types/classes/InternalWindowContainer.d.ts +36 -0
  73. package/types/classes/Label.d.ts +33 -0
  74. package/types/classes/Line.d.ts +48 -0
  75. package/types/classes/List.d.ts +223 -0
  76. package/types/classes/MediaPlayer.d.ts +381 -0
  77. package/types/classes/Menu.d.ts +43 -0
  78. package/types/classes/MenuBar.d.ts +26 -0
  79. package/types/classes/MenuItem.d.ts +57 -0
  80. package/types/classes/Panel.d.ts +28 -0
  81. package/types/classes/PasswordField.d.ts +22 -0
  82. package/types/classes/Polygon.d.ts +93 -0
  83. package/types/classes/Polyline.d.ts +96 -0
  84. package/types/classes/ProgressBar.d.ts +36 -0
  85. package/types/classes/RadioButton.d.ts +70 -0
  86. package/types/classes/RadioButtonMenuItem.d.ts +71 -0
  87. package/types/classes/Rectangle.d.ts +82 -0
  88. package/types/classes/ScrollPane.d.ts +23 -0
  89. package/types/classes/ScrollableComponent.d.ts +81 -0
  90. package/types/classes/Separator.d.ts +14 -0
  91. package/types/classes/Shape.d.ts +223 -0
  92. package/types/classes/ShapeContainer.d.ts +92 -0
  93. package/types/classes/Slider.d.ts +107 -0
  94. package/types/classes/Spinner.d.ts +129 -0
  95. package/types/classes/SplitView.d.ts +47 -0
  96. package/types/classes/Stroke.d.ts +99 -0
  97. package/types/classes/Table.d.ts +652 -0
  98. package/types/classes/Tabs.d.ts +118 -0
  99. package/types/classes/TextArea.d.ts +45 -0
  100. package/types/classes/TextComponent.d.ts +136 -0
  101. package/types/classes/TextField.d.ts +94 -0
  102. package/types/classes/TextShape.d.ts +73 -0
  103. package/types/classes/ToggleButton.d.ts +84 -0
  104. package/types/classes/ToolBar.d.ts +82 -0
  105. package/types/classes/TrayIcon.d.ts +43 -0
  106. package/types/classes/Tree.d.ts +354 -0
  107. package/types/classes/UIComponent.d.ts +966 -0
  108. package/types/classes/Window.d.ts +334 -0
  109. package/types/enums.d.ts +437 -0
  110. package/types/functions.d.ts +109 -0
  111. package/types/index.d.ts +188 -0
  112. package/types/typedefs.d.ts +1626 -0
  113. package/ui-process-manager.js +317 -0
  114. package/video-devices-linux.sh +72 -0
  115. package/video-devices-mac.sh +33 -0
  116. package/CHANGES.md +0 -3
@@ -0,0 +1,381 @@
1
+ /**
2
+ * Media player is an audio and video player component capable of playing video & audio files, video & audio live streams, video & audio from URL, and from audio & video capture devices, like microphone, web cam and other video capture devices.
3
+ * It's done with the help of pre-installed FFMPEG, so FFMPEG is required to be installed for this to work. FFMPEG is a free open-source software.
4
+ * @class
5
+ * @global
6
+ * @example <h2>Examples of formats of commonly used objects with media player:</h2>
7
+ *
8
+ * VideoDevice {
9
+ * [name]: string, // Name of the video input device.
10
+ * id: string, // ID if the video input device.
11
+ * [formats]: VideoFormat[],// Available video formats (present only when getting video input devices)
12
+ * [format]: VideoFormat // Chosen video format to use (required when setting a video input device).
13
+ * }
14
+ *
15
+ * VideoFormat {
16
+ * size: string, // Video frame size in pixels
17
+ * pixel_format: string // Frame image encoding coming out of the device (e.g.: "yuyv422")
18
+ * [fps]: number // (required only when setting a video input device)
19
+ * [min_fps]: number, // Minimum available frame rate. For example 7.5 fps.
20
+ * [max_fps]: number, // Maximum available frame rate. For example 30 fps.
21
+ * }
22
+ *
23
+ * AudioDevice {
24
+ * [name]: string, // Name of audio device.
25
+ * id: string, // ID of audio device. (required when setting an audio device).
26
+ * [formats]: AudioFormats[], // Available audio formats (present only when getting audio devices).
27
+ * [format]: AudioFormat, // Audio format to use (required when setting an audio device).
28
+ * }
29
+ *
30
+ * AudioFormat {
31
+ * channels: number, // Audio channels available
32
+ * bits: number, // Bits per sample
33
+ * [rate]: number, // Sample rate in Hz. It's only used for audio input device formats (not output). Set it when setting an audio output device.
34
+ * [encoding]: string // Audio encoding (e.g.: PCM_UNSIGNED, PCM_SIGNED). (Only available in audio output device formats).
35
+ * }
36
+ */
37
+ export class MediaPlayer extends UIComponent {
38
+ /**
39
+ * Enum for media player states.
40
+ *
41
+ * @readonly
42
+ * @enum {number}
43
+ * @property {number} NoMedia - No media loaded.
44
+ * @property {number} Stopped - Media is stopped.
45
+ * @property {number} Playing - Media is playing.
46
+ * @see MediaPlayer#state
47
+ * @example
48
+ * if(player.state === MediaPlayer.State.Playing)
49
+ * {
50
+ * console.log("Player is playing");
51
+ * }
52
+ */
53
+ static readonly State: Readonly<{
54
+ NoMedia: 0;
55
+ Stopped: 1;
56
+ Playing: 2;
57
+ }>;
58
+ /**
59
+ * Enum for video interpolation methods. Used to smooth resized video and reduce pixelation.
60
+ *
61
+ * @readonly
62
+ * @enum {number}
63
+ * @property {number} None - No interpolation applied.
64
+ * @property {number} ByGUI - Interpolation performed by the GUI.
65
+ * @property {number} ByFFMPEG - Interpolation performed by FFMPEG.
66
+ * @example
67
+ * player.interpolation(MediaPlayer.Interpolation.ByFFMPEG);
68
+ */
69
+ static readonly Interpolation: Readonly<{
70
+ None: 0;
71
+ ByGUI: 1;
72
+ ByFFMPEG: 2;
73
+ }>;
74
+ /**
75
+ * Enum for subtitle background styles. Used to enhance subtitle readability over video. Background color can be changed by {@link MediaPlayer#subtitleBackground}
76
+ *
77
+ * @readonly
78
+ * @enum {number}
79
+ * @property {number} None - Subtitles not visible (only sent as a player event).
80
+ * @property {number} Plain - Visible but without a background.
81
+ * @property {number} Shadow - Subtitle has a shadow background. (Default)
82
+ * @property {number} Box - Subtitle is placed inside a solid box.
83
+ * @property {number} RoundBox - Subtitle is placed inside a solid box with rounded corners.
84
+ * @see MediaPlayer#subtitleStyle
85
+ * @see MediaPlayer#subtitleBackground
86
+ * @example
87
+ * player.subtitleStyle(MediaPlayer.SubtitleStyle.Box);
88
+ */
89
+ static readonly SubtitleStyle: Readonly<{
90
+ None: 0;
91
+ Plain: 1;
92
+ Shadow: 2;
93
+ Box: 3;
94
+ RoundBox: 4;
95
+ }>;
96
+ /**
97
+ * Sets the path to ffmpeg executable file, preferably absolute path. Default is `ffmpeg`, and it requires the path to ffmpeg to be added to `Path` environment variable.
98
+ * When setting path, `boolean` is returned whether path is valid and accepted.
99
+ * When getting value, `string` of previously specified or default value is returned.
100
+ *
101
+ * @param {string} [path] - Path to the executable FFMPEG file. Default path is "ffmpeg".
102
+ * @return {boolean|string} Returns `string` path when getting, or `boolean` when setting. `boolean` indicates if specified path was accepted (if it exists).
103
+ */
104
+ static ffmpegPath(...args: any[]): boolean | string;
105
+ /**
106
+ * Initializes the MediaPlayer UI component.
107
+ * @see VideoDevice
108
+ * @see AudioDevice
109
+ * @see VideoFormat
110
+ * @see AudioFormat
111
+ */
112
+ constructor();
113
+ /**
114
+ * Sets a path of a local media file as a new media source. Resets player and overrides previously set source.
115
+ *
116
+ * @param {string} path - Path to media file.
117
+ * @param {number} [videoStream] - If the media file has more than one video stream, specify which one to use. Default is 0. For audio-only files this is ignored.
118
+ * @param {number} [audioStream] - If the media file has more than one audio stream (such as multiple languages), specify which one to use. Default is 0. For media without audio stream this is ignored.
119
+ * @param {number|string|null} [subtitleStream=null] - Index of a subtitle stream or a subtitles file path. Default is `null` for no subtitles.
120
+ * @return {MediaPlayer} Returns `this` component instance.
121
+ */
122
+ setFile(path: string, videoStream?: number, audioStream?: number, subtitleStream?: number | string | null): MediaPlayer;
123
+ /**
124
+ * Sets URL of the media source. Resets player and overrides previously set source.
125
+ *
126
+ * @param {string} url - URL of media.
127
+ * @param {number} [videoStream] - If the media has more than one video stream, specify which one to use. Default is 0. For audio-only files this is ignored.
128
+ * @param {number} [audioStream] - If the media has more than one audio stream (such as multiple languages), specify which one to use. Default is 0. For media without audio stream this is ignored.
129
+ * @param {number|null} [subtitleStream=null] - Index of a subtitle stream. There may be multiple streams in case of multiple languages. Default is NULL for no subtitles.
130
+ * @param {string|null} [format] - Recommended to set for live video streams, such as web cam stream. This value is set as "-input_format" option for FFMPEG command. For example: mjpeg, rtsp, flv, mpegts, hls, http, https, srt or icecast.
131
+ * @param {boolean} [lowLatency] - Set to TRUE to use ffmpeg options for low latency for live video streams (ffmpeg options such as low buffering).
132
+ * @return {MediaPlayer} Returns `this` component instance.
133
+ */
134
+ setURL(url: string, videoStream?: number, audioStream?: number, subtitleStream?: number | null, format?: string | null, lowLatency?: boolean): MediaPlayer;
135
+ /**
136
+ * Sets video device and audio device to use as video and audio source. Resets player and overrides previously set source.
137
+ * To get a list of available devices and their details getters {@link MediaPlayer#videoInputDevices} and {@link MediaPlayer#audioInputDevices} can be used.
138
+ *
139
+ * @param {VideoDevice|null} videoDevice - Video device object (camera or video capture card). Set to `null` to omit video device.
140
+ * @param {AudioDevice|null} [audioDevice=undefined] - Audio device object (microphone, audio capture card or system audio). Omit or set to `null` to omit audio device.
141
+ * @return {MediaPlayer} Returns `this` component instance.
142
+ */
143
+ setInputDevice(videoDevice: VideoDevice | null, audioDevice?: AudioDevice | null): MediaPlayer;
144
+ /**
145
+ * Sets or gets current playing time in seconds. Decimal points are allowed (e.g. player.seek(165.43); ).
146
+ *
147
+ * @param {number} [seconds] - Sets seek time in seconds. Two decimal points allowed for more precision.
148
+ * @return {MediaPlayer} Returns `this` component instance.
149
+ */
150
+ seek(...args: any[]): MediaPlayer;
151
+ /**
152
+ * Makes the media player start media playback (assuming that media was previously specified using setFile(), setURL() or setInputDevice() functions).
153
+ *
154
+ * @return {MediaPlayer} Returns `this` component instance.
155
+ */
156
+ play(): MediaPlayer;
157
+ /**
158
+ * Makes media player pause the playback.
159
+ *
160
+ * @return {MediaPlayer} Returns `this` component instance.
161
+ */
162
+ pause(): MediaPlayer;
163
+ /**
164
+ * Makes media player stop the playback. Seek time resets to 0, so play() function would start the playback from beginning.
165
+ *
166
+ * @return {MediaPlayer} Returns `this` component instance.
167
+ */
168
+ stop(): MediaPlayer;
169
+ /**
170
+ * Sets or get whether video frame should be resized to fit the media player component.
171
+ *
172
+ * @param {boolean} [fit] - `true` to resize video to fit player component, `false` to use actual resolution of the video.
173
+ * @returns {boolean|MediaPlayer} Returns `this` component instance if setting, `boolean` if getting.
174
+ */
175
+ fit(...args: any[]): boolean | MediaPlayer;
176
+ /**
177
+ * Sets or get hardware acceleration setting for ffmpeg video decoding.
178
+ * To get a list of supported hardware acceleration options use `hardwareAccelerations` getter property.
179
+ *
180
+ * @param {string} [hwaccel] - `-hwaccel` option value for FFMPEG. Default is "auto". `null` or "none" to disable hardware acceleration.
181
+ * @returns {string|MediaPlayer} Returns `this` component instance if setting, `string` if getting.
182
+ */
183
+ hardwareAcceleration(...args: any[]): string | MediaPlayer;
184
+ /**
185
+ * Gets a list of supported hardware acceleration options that can be used by FFMPEG on this system.
186
+ * Returns an array of supported hardware accelerations that can be used to decode a video by FFMPEG.
187
+ * @readonly
188
+ * @type {string[]}
189
+ */
190
+ readonly get hardwareAccelerations(): string[];
191
+ /**
192
+ * Gets an array of enabled video input devices (such as WebCam or video capture device) with an array of accepted video formats (size and frame rate).
193
+ * Returns an array of objects that contain information about each video input device recognized by FFMPEG.
194
+ * NOTE: On linux it is recommended to have `v4l2-utils` installed for fast video devices lookup, otherwise alternative method take a lot longer to complete and may return less video formats and FPS options.
195
+ *
196
+ * @readonly
197
+ * @type {VideoDevice[]}
198
+ * @see VideoDevice
199
+ */
200
+ readonly get videoInputDevices(): VideoDevice[];
201
+ /**
202
+ * Gets an array of enabled audio input devices (such as microphone, system sound) with an array of accepted audio formats (sample rate, bit depth, and amount of channels).
203
+ * Returns an array of objects that contain information about each audio input device recognized by FFMPEG.
204
+ *
205
+ * @readonly
206
+ * @type {AudioDevice[]}
207
+ * @see AudioDevice
208
+ */
209
+ readonly get audioInputDevices(): AudioDevice[];
210
+ /**
211
+ * Gets a list of output audio devices (such as speaker, bluetooth headphones, etc.) and their accepted audio formats.
212
+ * These devices may be specified to be used while playing video or audio.
213
+ * Returns an array of objects that contain information about each audio output device recognized by FFMPEG.
214
+ *
215
+ * @readonly
216
+ * @type {AudioDevice[]}
217
+ * @see AudioDevice
218
+ */
219
+ readonly get audioOutputDevices(): AudioDevice[];
220
+ /**
221
+ * Sets or gets a current audio output device. To obtain a list of devices you can use "audioOutputDevices" getter property (e.g. player.audioOutputDevices), which returns a list of devices with their ID and formats.
222
+ * Device name or ID may be passed, but name is preferred, because when devices are added or removed, their ID may change, because it's just an index of the list of devices (enumerator), but names are unique.
223
+ *
224
+ * @param {string} [name] - Audio output device name (or ID) obtained from {@link AudioDevice} object using `{@link MediaPlayer#audioOutputDevices}` getter.
225
+ * @return {MediaPlayer|string} Returns `this` component instance when setting, otherwise current audio output device info as an `object`.
226
+ * @see AudioDevice
227
+ * @see MediaPlayer#audioOutputDevice
228
+ * @example <h2>Getting a list of devices and setting first one:</h2>
229
+ * const player = new MediaPlayer();
230
+ * const _devices = player.audioOutputDevices;
231
+ *
232
+ * player.audioOutputDevice(_devices[0].name);
233
+ *
234
+ */
235
+ audioOutputDevice(...args: any[]): MediaPlayer | string;
236
+ /**
237
+ * Registers, unregisters, and gets an Array of event handlers for the MediaPlayer.
238
+ *
239
+ * @param {function(PlayerEvent):any} [callback] - Handler function receiving {@link PlayerEvent} object. Pass `null` to unregister all handler callbacks.
240
+ * @param {boolean} [remove] - Set to `true` to unregister the handler function.
241
+ * @return {MediaPlayer|function[]} Returns `this` component instance if adding or removing the handler, otherwise returns an array of added handler functions.
242
+ * @see PlayerEvent
243
+ * @see Media
244
+ * @see VideoStream
245
+ * @see AudioStream
246
+ * @see SubtitleStream
247
+ * @example
248
+ * // Example of PlayerEvent object
249
+ * PlayerEvent {
250
+ * type: string, // One of: `loadstart`, `loadedmetadata`, `seeking`, `timeupdate`, `play`, `stop`.
251
+ * mediaType: string, // The type of media that is set to play in the player. One of: `File`, `InputDevice`, `URL`.
252
+ * media: Media, // A Media formatted object that contains details about loaded media.
253
+ * currentTime: number, // Current play time.
254
+ * duration: number, // Duration of the media in seconds. When event type is `timeupdate`.
255
+ * reason: string, // Reason for stopping: `Pause`, `EndOfMediaFile`
256
+ * }
257
+ *
258
+ * // Example of a VideoStream object
259
+ * VideoStream {
260
+ * sampleWidth: number,
261
+ * sampleHeight: number,
262
+ * width: number,
263
+ * height: number,
264
+ * pixelAspectRatio: string,
265
+ * displayAspectRatio: string,
266
+ * frameRate: number,
267
+ * codec: string,
268
+ * pixelFormat: string,
269
+ * progressive: boolean,
270
+ * default: boolean
271
+ * }
272
+ *
273
+ * // Example of a AudioStream object
274
+ * AudioStream {
275
+ * sampleRate: number,
276
+ * channels: number,
277
+ * bitDepth: number,
278
+ * codec: string,
279
+ * default: boolean
280
+ * }
281
+ *
282
+ * // Example of a SubtitleStream object
283
+ * SubtitleStream {
284
+ * language: string,
285
+ * codec: string,
286
+ * default: boolean
287
+ * }
288
+ */
289
+ onPlayerEvents(callback?: (arg0: PlayerEvent) => any, ...args: any[]): MediaPlayer | Function[];
290
+ /**
291
+ * Gets the current state of the media player component. The returned value corresponds to {@link MediaPlayer#State}.
292
+ *
293
+ * @readonly
294
+ * @see MediaPlayer#State
295
+ * @type {MediaPlayer.State}
296
+ */
297
+ readonly get state(): Readonly<{
298
+ NoMedia: 0;
299
+ Stopped: 1;
300
+ Playing: 2;
301
+ }>;
302
+ /**
303
+ * Sets or gets the method how smoothing is done when video is resized.
304
+ * `ByGUI` means that video frames are smoothed out while drawing on the player component in GUI.
305
+ * `ByFFMPEG` means that ffmpeg will resize video to the size of the component before sending it to GUI. When component is resized while video is playing, the video will have to stop and then start again at the same position.
306
+ * `None` means that video will not be smoothed, and when it's resized, it will look pixelated.
307
+ *
308
+ * @param {MediaPlayer.Interpolation} [interpolation] - Specifies a method of smoothing video when it's displayed in not it's original size. Options: MediaPlayer.Interpolation.[None|ByGUI|ByFFMPEG]
309
+ * @return {MediaPlayer.Interpolation|MediaPlayer} When setting value an instance of `this` object is returned, otherwise a current value is returned.
310
+ */
311
+ interpolation(...args: any[]): Readonly<{
312
+ None: 0;
313
+ ByGUI: 1;
314
+ ByFFMPEG: 2;
315
+ }> | MediaPlayer;
316
+ /**
317
+ * Sets or gets whether to show visualizer for audio-only streams (when no video stream is present, such as when playing music).
318
+ *
319
+ * @param {boolean} enable - Use or not use visualizer for audio-only streams.
320
+ * @return {boolean|MediaPlayer} When setting value an instance of `this` object is returned, otherwise a current value is returned.
321
+ */
322
+ visualizer(...args: any[]): boolean | MediaPlayer;
323
+ /**
324
+ * Sets or get value if media should be looping. Valid values are `true`, `false`, or a positive integer how many times it should be looped.
325
+ * The stream continues even though video or audio repeats, after first iteration current time stops updating because it would show time of the
326
+ * total playback, not the current media time. If you need correct media progress time, implement your own loop by starting video again when it stops.
327
+ *
328
+ * @param {boolean|number} [loop] - Loop or not to loop `boolean`, or a `number` how many times to loop.
329
+ * @return {boolean|number|MediaPlayer} When setting a value, an instance of `this` object is returned; otherwise a current value is returned.
330
+ */
331
+ loop(...args: any[]): boolean | number | MediaPlayer;
332
+ /**
333
+ * Sets or gets the mute state of the media player audio. If muted, it will produce silence instead of provided sound.
334
+ * Its only used if audio stream is present.
335
+ *
336
+ * @param {boolean} mute - `true` to mute, `false` to unmute.
337
+ * @return {boolean|MediaPlayer} When setting value an instance of `this` object is returned, otherwise a current value is returned.
338
+ */
339
+ mute(...args: any[]): boolean | MediaPlayer;
340
+ /**
341
+ * Sets or gets the background color of subtitles text. The background is used for improved readability when video colors are similar to colors of subtitles text.
342
+ *
343
+ * @param {String} [color] - Color string (e.g.: "#000000" or "00000000"). Supports alpha channel for setting transparency.
344
+ * @return {String|MediaPlayer} If called without parameters, the instance of the MediaPlayer component is returned, otherwise current value is returned.
345
+ * @see MediaPlayer#subtitleStyle
346
+ */
347
+ subtitleBackground(...args: any[]): string | MediaPlayer;
348
+ /**
349
+ * Sets or gets the style of the subtitles. When `None`, subtitles are not visible. The background is used for improved readability when video colors are similar to colors of subtitles text.
350
+ *
351
+ * @param {MediaPlayer.SubtitleStyle} [style] - Style of the subtitle, or `None` to make it not visible. It's still sent as a `PlayerEvent`.
352
+ * @return {MediaPlayer.SubtitleStyle|MediaPlayer} If called without parameters, the instance of the MediaPlayer component is returned, otherwise current value is returned.
353
+ * @see MediaPlayer#SubtitleStyle
354
+ * @see MediaPlayer#subtitleBackground
355
+ * @see PlayerEvent
356
+ */
357
+ subtitleStyle(...args: any[]): Readonly<{
358
+ None: 0;
359
+ Plain: 1;
360
+ Shadow: 2;
361
+ Box: 3;
362
+ RoundBox: 4;
363
+ }> | MediaPlayer;
364
+ /**
365
+ * Sets video filters to be applied to the video video by FFMPEG. If one of preset filters is not enough, feel free to set a `custom` filter (any ffmpeg video filter that is compatible with -vf option).
366
+ *
367
+ * @param {VideoFilters|null} filters - A VideoFilters object. Check out `VideoFilters` type definition for details. Set to `null` to clear previously set video filters.
368
+ * @returns {MediaPlayer} Returns this MediaPlayer instance for chaining.
369
+ * @see VideoFilters
370
+ */
371
+ videoFilters(filters: VideoFilters | null): MediaPlayer;
372
+ /**
373
+ * Sets or gets component opacity float value between 0 and 1 inclusive.
374
+ *
375
+ * @param {number} [opacity] - A number between 0 and 1 inclusive.
376
+ * @return {number|this} If `opacity` argument is provided, `this` component is returned, otherwise opacity `number` is returned.
377
+ */
378
+ opacity(...args: any[]): number | this;
379
+ #private;
380
+ }
381
+ import { UIComponent } from "./UIComponent.js";
@@ -0,0 +1,43 @@
1
+ /**
2
+ * Menu UI component is used to create menus in a menu bar or create a submenu in context menu. It extends MenuItem class.
3
+ * Menu object can be added to MenuBar, ContextMenu, or another Menu object to create a submenu.
4
+ * @class
5
+ * @global
6
+ * @extends MenuItem
7
+ */
8
+ export class Menu extends MenuItem {
9
+ /**
10
+ * Registers, unregisters and gets a list of handler functions for the menu popup events (when the menu becomes expended and collapsed).
11
+ *
12
+ * @param {function(PopupEvent):any|null} [callback] - Event handler function that receives a {@link PopupEvent} as an argument. Pass `null` to unregister all registered callbacks.
13
+ * @param {boolean} [remove] - Set to `true` to unregister the handler function.
14
+ * @return {function[]|ComboBox} Returns an array of registered handler functions if arguments are omitted, otherwise returns `this` component instance.
15
+ * @see PopupEvent
16
+ * @example
17
+ * mainForm.mainMenuBar = new MenuBar();
18
+ * let handler = function(e){console.log(e);}
19
+ * mainForm.fileMenu = new Menu("File").addTo(mainForm.mainMenuBar).onPopupEvents(handler);
20
+ *
21
+ * // event Object format:
22
+ * const e = {
23
+ * target: object, // The component that triggered the event.
24
+ * type: string, // `show`, `hide`, `cancel`.
25
+ * invoker: Object // UI Component that invoked the popup, or `null` if it was invoked programmatically.
26
+ * x: number, // X position relative to invoker. Only present when invoker is not `null`.
27
+ * y: number, // Y position relative to invoker. Only present when invoker is not `null`.
28
+ * screenX: number, // X position relative to default screen.
29
+ * screenY: number, // Y position relative to default screen.
30
+ * interactive: boolean, // Indicates if the popup was triggered by user's interaction (not programmatically).
31
+ * };
32
+ */
33
+ onPopupEvents(callback?: (arg0: PopupEvent) => any | null, ...args: any[]): Function[] | ComboBox;
34
+ /**
35
+ * Adds a child component to this container component. Overrides UIComponent.addChild() to validate components being added.
36
+ *
37
+ * @param {Object} component - UI Component that can be a child of this component.
38
+ * @param {...any} [data_or_index] - Argument to pass index at which to insert the child. By default component is added to the end.
39
+ * @returns {this}
40
+ */
41
+ addChild(component: Object, ...data: any[]): this;
42
+ }
43
+ import { MenuItem } from "./MenuItem.js";
@@ -0,0 +1,26 @@
1
+ /**
2
+ * MenuBar UI component is used to create a menu bar at the top of the application. It extends UIComponent class.
3
+ *
4
+ * Menu bar can be added to Window in two ways, by setting the MenuBar as the Window's main menu bar using window.menuBar(menuBar) method, or adding the MenuBar object as any other UI component using menuBar.addTo(window) or window.addChild(menuBar).
5
+ *
6
+ * Using window.menuBar(menuBar) automatically positions and resizes the menu bar to Window's width and in MacOS it uses it as the main menu bar shows at the top menu bar of the operating system.
7
+ *
8
+ * Adding the menu bar as a regular UI component to Window will keep the menu inside the Window and you will have to resize it by setting the desired width (and optionally height).
9
+ *
10
+ * Only Menu objects can be added to MenuBar.
11
+ *
12
+ * Extends {@link ComponentContainer}, which extends {@link UIComponent}.
13
+ * @class
14
+ * @global
15
+ */
16
+ export class MenuBar extends ComponentContainer {
17
+ /**
18
+ * Adds a child menu component to this menu bar. Overrides UIComponent.addChild() to validate components being added.
19
+ *
20
+ * @param {Object} component - UI Component that can be a child of this component.
21
+ * @param {...any} [index] - Argument to pass index at which to insert the child. By default component is added to the end.
22
+ * @returns {this} Returns an instance of `this` component.
23
+ */
24
+ addChild(component: Object, ...data: any[]): this;
25
+ }
26
+ import { ComponentContainer } from "./ComponentContainer.js";
@@ -0,0 +1,57 @@
1
+ /**
2
+ * Menu item UI component that extends UIComponent class.
3
+ * This class is extended by Menu, CheckBoxMenuItem, and RadioButtonMenuItem.
4
+ * For more methods and properties for this component or sub-components check UIComponent class.
5
+ * @class
6
+ * @global
7
+ */
8
+ export class MenuItem extends UIComponent {
9
+ /**
10
+ * Constructor for Menu, MenuItem, CheckBoxMenuItem, and RadioButtonMenuItem.
11
+ *
12
+ * @param {string} [text] - Text displayed in the menu item
13
+ */
14
+ constructor(...args: any[]);
15
+ /**
16
+ * Sets keyboard shortcut (accelerator) to menu item type of components: MenuItem, CheckBoxMenuItem, RadioButtonMenuItem. See examples below. Allows to activate the menu item action using specified keyboard key combination on keyboard. This shortcut is usually display in the right side of the mnu item's text.
17
+ *
18
+ * @param {string} keys - Key combination as a string. See example how to construct it.
19
+ * @returns String Description of keyboard shortcut
20
+ * @example
21
+ * Modifiers: CTRL|CONTROL|SHIFT|ALT|ALTGRAPH|META
22
+ *
23
+ * Keys: A-Z|0-9|NUMPAD[0-9]|SPACE|INSERT|ESCAPE|F[1-24]|TAB|ADD|SUBTRACT|DELETE|BACK_SPACE|BACK_SLASH|
24
+ * BRACELEFT|BRACERIGHT|OPEN_BRACKET|CLOSE_BRACKET|SEMICOLON|COMMA|CAPS_LOCK|BACK_QUOTE|MINUS|PERIOD|
25
+ * UP|DOWN|RIGHT|LEFT|MULTIPLY|DIVIDE|NUM_LOCK|HOME|END|PAGE_UP|PAGE_DOWN|PAUSE|SCROLL_LOCK|WINDOWS|
26
+ * CONTEXT_MENU|DECIMAL|ENTER
27
+ *
28
+ * Example key combinations: CTRL+Q, ALT+F1, CTRL+SHIFT+5, CTRL+N4, META+SHIFT+6, DELETE+SHIFT, SHIFT+UP, CTRL+OPEN_BRACKET, ATL+DOWN
29
+ *
30
+ * menuItem1.accelerator("CTRL+Q");
31
+ * menuItemUP.accelerator("SHIFT+NUMPAD[8]");
32
+ *
33
+ */
34
+ accelerator(...args: any[]): any;
35
+ /**
36
+ * Gets or sets the mnemonic (keyboard shortcut key) for menu item type of components: Menu, MenuItem, CheckBoxMenuItem, RadioButtonMenuItem. It's not same as setting accelerator(...).
37
+ * A mnemonic allows users to activate the menu item using the keyboard (typically Alt + key).<br />
38
+ * NOTE: Not all systems and UIs show underline under mnemonic character. Some systems only show it after Alt key was pressed.
39
+ *
40
+ * @param {number|string|null} [key] - A key code integer or a single ASCII character representing the mnemonic key (case-insensitive). If omitted, acts as a getter. To clear mnemonic, pass `0`, `""`, or `null`.
41
+ * @returns {number|MenuItem} If called without arguments, returns the current mnemonic key code integer. If called with an argument, returns `this` instance object for chaining.
42
+ * @example
43
+ * menuItem.text("Quit").mnemonic("q"); // Makes letter Q to be used as the keyboard shortcut key
44
+ * menuItem.mnemonic(""); // clears the mnemonic
45
+ */
46
+ mnemonic(...args: any[]): number | MenuItem;
47
+ /**
48
+ * Opens this menu item and all of its parent menus or context menu.
49
+ *
50
+ * @param {object} [position] - Example: {x: 100, y: 100}. Use only when root ancestor of this item is ContextMenu, to specify position where to position the ContextMenu.
51
+ * If invoker is specified, then position is relative to position of invoker component, otherwise it's a screen position.
52
+ * @param {object} [invoker] - Used to set invoker if the context menu isn't assigned to any object and you want to be able to get invoker by using "invoker" getter.
53
+ * @return {MenuItem} Returns `this` MenuItem instance.
54
+ */
55
+ open(position?: object, invoker?: object): MenuItem;
56
+ }
57
+ import { UIComponent } from "./UIComponent.js";
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Panel UI component, rectangular UI component that can be used in many different ways:
3
+ * - Container for other components
4
+ * - As a horizontal/vertical line or a rectangle
5
+ * - Container with scroll bars that can contain objects even outside its boundaries.
6
+ * - Background can be set to color, image, and gradient (like in CSS), which opens lots of opportunities, such as animating background, streaming MJPEG video by setting frames as background of the panel sequentially, and more.
7
+ * - As a canvas to draw Shapes or create an interactive game using Shapes drawn on this canvas.
8
+ *
9
+ * Panel class extends ComponentContainer and ShapeContainer, which extend UIComponent
10
+ *
11
+ * NOTE: Add Panel to Tabs, SplitView, or ScrollPane containers before adding child components to the panel to have expected behavior when setting anchors to child components of the Panel.
12
+ * @class
13
+ * @global
14
+ * @see ShapeContainer
15
+ * @see ComponentContainer
16
+ */
17
+ export class Panel extends ShapeContainer {
18
+ _shapes: any[];
19
+ temp_token: undefined;
20
+ /**
21
+ * Sets or gets component opacity float value between 0 and 1 inclusive.
22
+ *
23
+ * @param {number} [opacity] - A number between 0 and 1 inclusive.
24
+ * @return {number|this} If `opacity` argument is provided, `this` component is returned, otherwise opacity `number` is returned.
25
+ */
26
+ opacity(...args: any[]): number | this;
27
+ }
28
+ import { ShapeContainer } from "./ShapeContainer.js";
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Password field is used to type masked text. Use echoChar() method to set a custom mask character.
3
+ * All other methods are inherited from TextComponent and UIComponent.
4
+ * @class
5
+ * @global
6
+ */
7
+ export class PasswordField extends TextComponent {
8
+ /**
9
+ * Sets/Gets a Unicode character to use for masking real characters.
10
+ *
11
+ * Some disk characters to try:
12
+ * const myChar = '\u00B7';
13
+ * const myChar = '\u2022';
14
+ * const myChar = '\u25CF';
15
+ * const myChar = '\u2B24';
16
+ *
17
+ * @param {string} [character] - A one character string character. If the string has more than one character, only first one will be used.
18
+ * @returns {PasswordField|string} Returns an instance of `this` object when setting a value, otherwise current value is returned.
19
+ */
20
+ echoChar(...args: any[]): PasswordField | string;
21
+ }
22
+ import { TextComponent } from "./TextComponent.js";
@@ -0,0 +1,93 @@
1
+ /**
2
+ * Polygon is a shape with multiple corners at specified points. Each point is an X and Y coordinate relative to the shapes X and Y position.
3
+ *
4
+ * Polygon extends {@link Shape} class.
5
+ *
6
+ * @class
7
+ * @global
8
+ * @see Shape
9
+ */
10
+ export class Polygon extends Shape {
11
+ /**
12
+ * Creates an instance of Polygon shape object.
13
+ *
14
+ * @param {Stroke} [stroke] - A border of the shape.
15
+ * @param {string|null} [background] - Color, gradient, or image background, similar to CSS. Use an empty string to remove the background.
16
+ * @param {number} [opacity] - Opacity of the shape (0 to 1).
17
+ * @param {number} [x] - Horizontal position from the left edge.
18
+ * @param {number} [y] - Vertical position from the top edge.
19
+ * @param {Point[]} [_points=[]] - An array of `Point` objects that represent each corner of the shape [{x:number,y:number}, ...]. For example a simple start has 10 points.
20
+ */
21
+ constructor(stroke?: Stroke, background?: string | null, opacity?: number, x?: number, y?: number, _points?: Point[]);
22
+ _points: any[];
23
+ /**
24
+ * Adds a point to the Polygon as a last point or at a specified index.
25
+ *
26
+ * @param {Point} point - A {@link Point} formatted object with X and Y coordinates (e.g., {x: 20, y:30});
27
+ * @param {number} [insertAt=undefined] - If specified, the point will be added at this position; otherwise at the end.
28
+ * @returns {Polygon} Returns this Polygon shape object for chaining.
29
+ * @see Point
30
+ * @example <h2>Adding a point to the end of the points array:</h2>
31
+ * polygon.addPoint({x:20, y:30});
32
+ *
33
+ * @example <h2>Adding a point at a specified index:</h2>
34
+ * polygon.addPoint({x:30, y:60}, 0); // adds a point the beginning of points array
35
+ */
36
+ addPoint(point: Point, insertAt?: number): Polygon;
37
+ /**
38
+ * Removes a point from the Polygon at a specified index.
39
+ *
40
+ * @param {number} index - Index of the point to return.
41
+ * @returns {{x:number, y:number}|null} Returns the deleted point or `null` of there was no point at specified index.
42
+ */
43
+ removePoint(index: number): {
44
+ x: number;
45
+ y: number;
46
+ } | null;
47
+ /**
48
+ * Sets or gets a point of the Polygon {x:number, y:number} at a specified index.
49
+ *
50
+ * @param {number} index - Index of the existing point to update.
51
+ * @param {Point|number} [point_or_x=undefined] - New point object or X coordinate of the new point.
52
+ * @param {number} [y=undefined] - Y coordinate of the new point.
53
+ * @returns {Point|null|Polygon} When getting a point, returns a point object or `undefined` when a point at specified index doesn't exist. When setting the point, returns this Polygon or throws an Error.
54
+ * @see Point
55
+ * @example <h2>Updating a point at index 3:</h2>
56
+ * polygon.point(3, 50, 80); // x = 50, y = 80
57
+ *
58
+ * // or...
59
+ *
60
+ * polygon.point(3, {x:50, y:80});
61
+ *
62
+ * @example <h2>Getting a point at index 3:</h2>
63
+ * let p = polygon.point(3);
64
+ */
65
+ point(index: number, point_or_x?: Point | number, y?: number): Point | null | Polygon;
66
+ /**
67
+ * Sets an array of new points, or get an array of existing point.
68
+ *
69
+ * @param {Point[]} [points] - An array of new point objects [{x:number, y:number}, ...]. Omit to get current point.
70
+ * @returns {Point[]|Polygon} When called without arguments, returns current points; otherwise returns this Polygon for method chaining.
71
+ * @see Point
72
+ * @example <h2>Getting existing points as an Array:</h2>
73
+ * let _points = polygon.points(); // -> array of objects
74
+ *
75
+ * @example <h2>Setting a new array of points:</h2>
76
+ * polygon.points({
77
+ * {x:10, y:10},
78
+ * {x:40, y:10},
79
+ * {x:60, y:60},
80
+ * {x:30, y:60},
81
+ * {x:10, y:10}
82
+ * });
83
+ */
84
+ points(...args: any[]): Point[] | Polygon;
85
+ /**
86
+ * Returns a JSON object that contains this shape properties. It may be converted back to this shape.
87
+ *
88
+ * @param {string} [include="all"] - Specified what to include. "all" is default. Valid values are: "all", "stroke", "background", "points", "basic".
89
+ * @return {object} Returns an object containing this shape's properties.
90
+ */
91
+ toObject(include?: string): object;
92
+ }
93
+ import { Shape } from "./Shape.js";