swing-ui 1.1.0 → 1.1.1
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.
- package/classes/Shape.js +8 -0
- package/classes/ShapeContainer.js +11 -10
- package/icon.png +0 -0
- package/jar/gui-11.jar +0 -0
- package/package.json +1 -1
- package/types/SwingUI.d.ts +11 -0
- package/types/classes/ShapeContainer.d.ts +4 -3
package/classes/Shape.js
CHANGED
|
@@ -52,15 +52,16 @@ export class ShapeContainer extends ComponentContainer
|
|
|
52
52
|
if(!(args[0][i] instanceof Shape)) throw new TypeError(`Invalid "shape" at index ${i} in the array argument passed to Panel.shapes(shapes).`);
|
|
53
53
|
});
|
|
54
54
|
|
|
55
|
-
|
|
56
|
-
|
|
55
|
+
if(Array.isArray(this._shapes)) this._shapes.forEach(shape => shape.setParent(null) );
|
|
56
|
+
this._shapes = [...args[0]];
|
|
57
57
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
58
|
+
const _objects = [];
|
|
59
|
+
this._shapes.forEach(shape => {
|
|
60
|
+
shape.setParent(this);
|
|
61
|
+
_objects.push(shape.toObject("all"));
|
|
62
|
+
});
|
|
62
63
|
|
|
63
|
-
|
|
64
|
+
this.property('set_shapes', [_objects])
|
|
64
65
|
}
|
|
65
66
|
|
|
66
67
|
return this;
|
|
@@ -144,7 +145,7 @@ export class ShapeContainer extends ComponentContainer
|
|
|
144
145
|
* Removes a specified Shape, then the removed Shape is returned.
|
|
145
146
|
*
|
|
146
147
|
* @param {number|Shape} index_or_shape - Shape or index of the Shape to be removed.
|
|
147
|
-
* @return {Shape|
|
|
148
|
+
* @return {Shape|null} Returns removed Shape, or `null` in case when index is invalid or out of bounds.
|
|
148
149
|
* @see Shape#remove
|
|
149
150
|
*/
|
|
150
151
|
removeShape(index)
|
|
@@ -156,12 +157,12 @@ export class ShapeContainer extends ComponentContainer
|
|
|
156
157
|
{
|
|
157
158
|
shape = index;
|
|
158
159
|
index = this._shapes.indexOf(index);
|
|
159
|
-
if(index < 0) return
|
|
160
|
+
if(index < 0) return null;
|
|
160
161
|
}
|
|
161
162
|
else
|
|
162
163
|
{
|
|
163
164
|
shape = this._shapes[index];
|
|
164
|
-
if(shape === undefined) return
|
|
165
|
+
if(shape === undefined) return null;
|
|
165
166
|
}
|
|
166
167
|
|
|
167
168
|
if(shape.parent === this) // remove shape parent first, then come back
|
package/icon.png
CHANGED
|
Binary file
|
package/jar/gui-11.jar
CHANGED
|
Binary file
|
package/package.json
CHANGED
package/types/SwingUI.d.ts
CHANGED
|
@@ -729,5 +729,16 @@ export class SwingUI {
|
|
|
729
729
|
* @see SwingUI#exit
|
|
730
730
|
*/
|
|
731
731
|
onExit(callback?: (arg0: Object) => any | null | undefined, remove?: boolean): SwingUI | Function[];
|
|
732
|
+
/**
|
|
733
|
+
* Registers, unregisters and retrieves event handler for event emitted by changes to screens on the computer, such as connecting a screen, disconnecting a screen, or changes to screen resolution.
|
|
734
|
+
*
|
|
735
|
+
* @param {function(Object):any|null|undefined} [callback] - Function to handle the event, `null` to remove all handlers, or omit to retrieve an array of handlers.
|
|
736
|
+
* @param {boolean} remove - Removed the callback from this event
|
|
737
|
+
* @return {SwingUI|function[]} If called without parameters, an array of registered callbacks is returned; otherwise `this` instance of SwingUI class is returned.
|
|
738
|
+
* @example <h2>Registering screens change event handler:</h2>
|
|
739
|
+
* ui.onScreensChange(e => {console.log(e.screens});
|
|
740
|
+
* @see ui#screens
|
|
741
|
+
*/
|
|
742
|
+
onScreensChange(callback?: (arg0: Object) => any | null | undefined, remove?: boolean): SwingUI | Function[];
|
|
732
743
|
#private;
|
|
733
744
|
}
|
|
@@ -20,7 +20,8 @@ export class ShapeContainer extends ComponentContainer {
|
|
|
20
20
|
* @throws {TypeError} When one of passed array elements is not of Shape type.
|
|
21
21
|
* @see Shape
|
|
22
22
|
*/
|
|
23
|
-
shapes(...args: any[]):
|
|
23
|
+
shapes(...args: any[]): any[] | this;
|
|
24
|
+
_shapes: any[] | undefined;
|
|
24
25
|
/**
|
|
25
26
|
* Gets a Shape at a specified index.
|
|
26
27
|
*
|
|
@@ -51,10 +52,10 @@ export class ShapeContainer extends ComponentContainer {
|
|
|
51
52
|
* Removes a specified Shape, then the removed Shape is returned.
|
|
52
53
|
*
|
|
53
54
|
* @param {number|Shape} index_or_shape - Shape or index of the Shape to be removed.
|
|
54
|
-
* @return {Shape|
|
|
55
|
+
* @return {Shape|null} Returns removed Shape, or `null` in case when index is invalid or out of bounds.
|
|
55
56
|
* @see Shape#remove
|
|
56
57
|
*/
|
|
57
|
-
removeShape(index: any): Shape |
|
|
58
|
+
removeShape(index: any): Shape | null;
|
|
58
59
|
/**
|
|
59
60
|
* Registers, unregisters and gets a list of handler functions for Shape events (such as when mouse enters, leaves, mouse button clicks, etc.).
|
|
60
61
|
*
|