slint-ui 0.3.0 → 0.3.2

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/LICENSE.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Slint License
2
2
 
3
3
  Slint is available under either a [commercial license](LICENSES/LicenseRef-Slint-commercial.md)
4
- or at your choice under [GPL 3.0](LICENSES/GPL-3.0-only.txt).
4
+ or [GNU GPLv3](LICENSES/GPL-3.0-only.txt), at your choice.
5
5
 
6
6
  Third party licenses listed in the `LICENSES` folder also apply to parts of the product.
@@ -1,6 +1,280 @@
1
- ## The Slint Commercial License
1
+ # Slint Software License Agreement
2
2
 
3
- Slint is offered under a commercial license. Please contact info@slint-ui.com if you're interested.
3
+ Version 1.2
4
4
 
5
- See also the [Licensing FAQ](https://github.com/slint-ui/slint/blob/master/FAQ.md#licensing) online
6
- or find the same information in `FAQ.md` in the top level of your slint repository checkout.
5
+ Copyright © 2022 SixtyFPS GmbH <https://slint-ui.com/imprint.html>
6
+
7
+ SixtyFPS GmbH with offices at Oranienburger Str. 44, 16540 Hohen Neuendorf,
8
+ Germany (**SixtyFPS**, **us**, **we** or **our**) grants a license to the
9
+ software (**Licensed Software**), as specified herein, subject to the Terms and
10
+ Conditions of this Slint Software License Agreement (**Agreement**).
11
+
12
+ By using the Licensed Software, **you** agree to be bound by this Agreement.
13
+ **If you do not agree, do not use the Licensed Software.** If you are accessing
14
+ and using the Licensed Software on behalf of a company (such as your employer)
15
+ or other legal entity, you represent and warrant that you have the authority to
16
+ bind that company or other legal entity to this Agreement. In that case, **you**
17
+ and **your** will refer to that company or other legal entity.
18
+
19
+ Each Party to this Agreement may be referred to herein individually as a
20
+ **Party** or collectively as the **Parties**.
21
+
22
+ ## Licensed Software
23
+
24
+ The Licensed Software includes
25
+
26
+ 1. Slint compiler tool to translate Slint Design Markup Language files to Rust
27
+ (last stable Rust version at the time of licensed Slint version) and C++
28
+ (second last C++ version at the time of licensed Slint version),
29
+
30
+ 2. Slint run-time library that can render interactive user-interfaces and
31
+ provides Rust and C++ APIs (as per above versioning) to control the
32
+ interfaces,
33
+
34
+ 3. API Documentation for Slint and reference documentation for Slint Design
35
+ Markup Language, and
36
+
37
+ 4. Source code of Slint.
38
+
39
+ ## Terms and Conditions
40
+
41
+ 1. The Licensed Software is protected by copyright laws and international
42
+ copyright treaties, as well as other intellectual property laws and
43
+ treaties. The Licensed Software is licensed, not sold.
44
+
45
+ 2. The Licensed Software may provide links to third Party libraries or code
46
+ (collectively **Third Party Libraries**) to implement various functions.
47
+ Third Party Libraries do not comprise part of the Licensed Software. In some
48
+ cases, access to Third Party Libraries may be included along with the
49
+ Licensed Software delivery as a convenience for development and testing
50
+ only. You acknowledge:
51
+
52
+ 1. that some Third-Party Libraries may require additional licensing of
53
+ copyright and/or patents from the owners of such, and
54
+
55
+ 2. that distribution of any of the Licensed Software referencing any portion
56
+ of a Third-Party Library may require appropriate licensing from such
57
+ third parties. All such Third Party Libraries, along with applicable
58
+ copyright notices and licenses, will be listed and made available to
59
+ you.
60
+
61
+ 3. As part of the license grant, a Slint Software License Certificate
62
+ (**License Certificate**) will be issued containing details of
63
+
64
+ 1. the license grant,
65
+
66
+ 2. the permitted scope of your use of the Licensed Software, and
67
+
68
+ 3. your contact details.
69
+
70
+ In case of any changes or deviations to the information noted in the License
71
+ Certificate, you are obliged to notify us in writing, not later than 7 days
72
+ after any such change or deviation has occured.
73
+
74
+ 4. The Term of this Agreement shall begin on the date mentioned in the License
75
+ Certificate (**Effective Date**) and shall continue unless terminated
76
+ earlier as herein provided (**Term**).
77
+
78
+ 5. New releases of the Licensed Software (**Updates**) will be made available
79
+ to you for the period (**Maintenance Period**) specified in the License
80
+ Certificate. Such Updates may be bound by additional license terms. You
81
+ consent to any such additional license terms, without which you may not
82
+ install, copy, or otherwise use such Updates.
83
+
84
+ 6. The Licensed Software is to be used exclusively with your software
85
+ products (**Products**) specified in the License Certificate.
86
+
87
+ 7. We grant you a perpetual, non-exclusive, non-transferable right to use the
88
+ Licensed Software, including making modifications, for the sole purposes of
89
+ designing, developing, and testing your Products during the Term. The number
90
+ of **Users** using the Licensed Software to design, develop and test your
91
+ Products is limited to the amount of **User Seats** specified in the License
92
+ Certificate. For clarity, each unique User is counted as one User Seat.
93
+
94
+ 8. We grant you a perpetual, non-exclusive, non-transferable right to reproduce
95
+ and distribute the object code form of the Licensed Software, including any
96
+ modifications made to the Licensed Software, during the Term. Such
97
+ distributions is permitted only with your Products and limited to the amount
98
+ of **Distributions** specified in the License Certificate.
99
+
100
+ 9. The license grants are conditional on the full and timely payment of all
101
+ applicable **Fees**; if said Fees are not paid in full and by their due
102
+ date, the license shall not be granted and your Products shall be deemed as
103
+ made in breach of the Agreement ex tunc.
104
+
105
+ 10. Clause 9 above shall not apply if the license has been granted to you under
106
+ the **Ambassador** program. Instead, the license grants shall be conditional
107
+ on the fullfilment of the obligations as specified herein. If said
108
+ obligations are not fulfilled, the license shall not be granted and your
109
+ Products shall be deemed as made in breach of the Agreement ex tunc. The
110
+ obligations are as follows:
111
+
112
+ 1. Showcase: You grant us the right to use your name, logo and your
113
+ Products in our marketing materials,
114
+
115
+ 2. Spread the word: You will include reasonably visible notices in the
116
+ documentation, marketing materials and social media channels related to
117
+ your Products that such were built with the Licensed Software,
118
+
119
+ 3. Give feedback: You agree to provide relevant feedback that would
120
+ help us improve the Licensed Software. We may use any such
121
+ feedback in testimonials.
122
+
123
+ 11. The Fees and any other charges under this Agreement shall be paid by
124
+ you no later than thirty (30) days from the date of the applicable
125
+ invoice from us. A late payment charge of the lower of (a) one percent
126
+ per month; or (b) the interest rate stipulated by applicable law, shall be
127
+ charged on any unpaid balances that remain past due and which have not been
128
+ disputed by you in good faith.
129
+
130
+ 12. The Fees and any other charges payable under this Agreement are gross
131
+ amounts but exclusive of any value added tax, use tax, sales tax,
132
+ withholding tax and other taxes, duties or tariffs levied directly for the
133
+ sale, delivery or use of the Licensed Software pursuant to any applicable
134
+ law.
135
+
136
+ 13. The Parties also agree to all of the following conditions:
137
+
138
+ 1. You may not remove or alter any copyright, trademark or other
139
+ proprietary rights notice contained in any portion of the Licensed
140
+ Software,
141
+
142
+ 2. Your Products may not compete with the Licensed Software,
143
+
144
+ 3. You will indemnify and hold us, our affiliated companies and our
145
+ suppliers, harmless from and against any claims or liabilities
146
+ arising out of the use, reproduction or distribution of your
147
+ Products, except as set out in clause 13.4. immediately below,
148
+
149
+ 4. We shall indemnify and hold you harmless from and against any
150
+ claims from third parties alleging that the use of the Licensed Software
151
+ as set out in this Agreement infringes or will infringe such third
152
+ parties intellectual property rights or other rights,
153
+
154
+ 5. A Party shall promptly notify the other Party if it receives a claim that
155
+ the other Party shall or may be obliged to indemnify. The Parties shall
156
+ promptly give each other information and other assistance needed for
157
+ handling the claim. The Indemnifying Party may, at its cost and in its
158
+ sole discretion, take control of the defense of such claim, including
159
+ the conduct of any litigation or arbitration and the negotiation of any
160
+ settlement, in which case the indemnifying Party shall not compromise or
161
+ settle or otherwise dispose of the claim, in whole or in part, where
162
+ such compromise or settlement or disposal would require any admission or
163
+ stipulation which would reasonably be expected to have an adverse effect
164
+ on the commercial reputation of the indemnified Party, without the prior
165
+ written consent of the indemnified Party. Where the indemnifying Party
166
+ has not taken control of the defense of the claim, the indemnified Party
167
+ shall not compromise or settle or fail adequately to defend or otherwise
168
+ dispose of a claim, in whole or in part, without the written consent of
169
+ the indemnifying Party, such consent not to be unreasonably withheld or
170
+ delayed.
171
+
172
+ 14. The Licensed Software is licensed to you "as is". To the maximum extent
173
+ permitted by applicable law, we on behalf of us and our suppliers,
174
+ disclaim all warranties and conditions, either express or implied,
175
+ including, but not limited to, any implied warranties of merchantability or
176
+ fitness for a particular purpose, title and non-infringement with regard to
177
+ the Licensed Software. The warranty disclaimer in the foregoing
178
+ notwithstanding, you may have specific legal rights which may vary from
179
+ state/jurisdiction to state/jurisdiction; as far as legally permissible, you
180
+ waive any such legal rights vis-à-vis us.
181
+
182
+ 15. We shall not under any circumstances be liable to you based on failure of
183
+ the Licensed Software if the failure resulted from your changing of the
184
+ Licensed Software, from your accident, abuse or misapplication, nor shall
185
+ we except in case of gross negligence or willful misconduct be
186
+ liable for special damages, punitive or exemplary damages, damages for loss
187
+ of profits or interruption of business or for loss or corruption of data,
188
+ nor shall any award of damages exceed the total amount you paid to us in
189
+ connection with this Agreement.
190
+
191
+ 16. Each Party shall hold Confidential Information of the other Party, its
192
+ customers, and licensors in confidence, and without written permission from
193
+ will not disclose to any person or use for its own benefit, any such
194
+ information. **Confidential Information** includes without limitation the
195
+ terms of this Agreement, computer software programs developed or licensed by
196
+ the Parties, including all documentation and methods or concepts utilized
197
+ therein, all adaptations and modifications thereto and derivative works
198
+ thereof, and related materials and information. Confidential Information
199
+ also includes any other information identified by either Party, its
200
+ licensors, or customers as proprietary or confidential, or which would
201
+ reasonably be understood under the circumstances to be confidential. All
202
+ Confidential Information shall remain the sole property of each respective
203
+ Party. Information will not be considered to be Confidential Information if
204
+
205
+ 1. available to the public other than by a breach of this Agreement;
206
+
207
+ 2. rightfully received from a third Party not in breach of any obligation of
208
+ confidentiality;
209
+
210
+ 3. independently developed by a Party without access to Confidential
211
+ Information of the other Party;
212
+
213
+ 4. known to the other Party at the time of disclosure;
214
+
215
+ 5. produced in compliance with applicable law or a court order, provided the
216
+ other Party is given notice and opportunity to intervene; or
217
+
218
+ 6. it does not constitute a trade secret and more than five (5) years have
219
+ elapsed from the date of disclosure. In addition to any other rights or
220
+ remedies available, each Party shall be entitled to enforcement of such
221
+ obligations by court injunction.
222
+
223
+ 17. During the Term, an independent, certified auditor on our behalf, may, upon
224
+ its reasonable request, with 30 (thirty) days written notice, and at its
225
+ sole expense, examine your books and records solely with respect to your use
226
+ of the Licensed Software. Any such audit shall be conducted during regular
227
+ business hours at your facilities and shall not unreasonably interfere with
228
+ your business activities. Our auditor shall not remove, copy, or
229
+ redistribute any electronic material during the course of an audit. If an
230
+ audit reveals that you are using the Licensed Software in a way that is in
231
+ material violation of the terms of this Agreement, then you shall pay us
232
+ reasonable costs of conducting the audit. Our auditor shall only be allowed
233
+ to report violations of the terms of this Agreement, with a copy to you. You
234
+ shall be provided the right to provide comments to the report before it is
235
+ finalized.
236
+
237
+ 18. If you materially breach this Agreement, we will provide a 60 (sixty) days
238
+ written notice to you during which any such breach(es) may be cured, failing
239
+ which we will terminate the agreement. You undertake to pay a contractual
240
+ penalty for each case of negligent breach of this Agreement of EUR 10000
241
+ (ten thousand euros), which shall not be subject to a judicial right of
242
+ reduction. We shall in any case be free to assert any further damage/loss or
243
+ other claims. The amount of contractual penalty shall be offset against
244
+ claims for damages, if any.
245
+
246
+ 19. You may terminate this Agreement at any time for any reason upon 90 (ninety)
247
+ days notice to us and upon payment of all applicable fees and contractual
248
+ penalties, if any, in connection with the use of the Licensed Software.
249
+
250
+ 20. Both Parties shall comply with all applicable laws and regulations relating
251
+ to the Licensed Software in the countries in which the Parties use or modify
252
+ the Licensed Software.
253
+
254
+ 21. All notices and communications between the Parties shall be in writing and
255
+ shall be deemed given when received. For avoidance of doubt, email is
256
+ considered a written form of communication.
257
+
258
+ 22. This Agreement shall be construed, interpreted and governed by the laws of
259
+ the Federal Republic of Germany.
260
+
261
+ 23. No term or condition contained in your purchase order will apply unless
262
+ expressly accepted by us in writing.
263
+
264
+ 24. You may assign this Agreement, in whole or in part (whether by operation of
265
+ law or otherwise), with prior consent from us, which shall not be
266
+ unreasonably withheld or delayed. We may assign this Agreement or any of its
267
+ rights hereunder or delegate any of its obligations hereunder with prior
268
+ notice to you. Any attempt to assign this Agreement other than in accordance
269
+ with this provision shall be null and void.
270
+
271
+ 25. This Agreement constitutes the complete agreement between the Parties and
272
+ supersedes all prior or contemporaneous discussions, representations, and
273
+ proposals, written or oral, with respect to the subject matters discussed
274
+ herein. No modification of this Agreement will be effective unless contained
275
+ in a written document executed by an authorized representative of each
276
+ Party. If any provision of the Agreement is found void or unenforceable, the
277
+ remainder will remain valid and enforceable according to its terms. If any
278
+ remedy provided is determined to have failed for its essential purpose, all
279
+ limitations of liability and exclusions of damages set forth in this
280
+ Agreement shall remain in effect.
package/README.md CHANGED
@@ -41,7 +41,7 @@ let main = new ui.Main();
41
41
  main.run();
42
42
  ```
43
43
 
44
- See [/examples/printerdemo/node](/examples/printerdemo/node) for a full example.
44
+ See [/examples/todo/node](/examples/todo/node) for a full example.
45
45
 
46
46
  ## API Overview
47
47
 
package/lib/index.ts CHANGED
@@ -67,6 +67,7 @@ interface Size {
67
67
  interface SlintWindow {
68
68
  show(): void;
69
69
  hide(): void;
70
+ is_visible: boolean;
70
71
  logical_position: Point;
71
72
  physical_position: Point;
72
73
  logical_size: Size;
@@ -89,6 +90,9 @@ class WindowAPI implements SlintWindow {
89
90
  hide(): void {
90
91
  this.impl.hide();
91
92
  }
93
+ get is_visible(): boolean {
94
+ return this.impl.get_is_visible();
95
+ }
92
96
  get logical_position(): Point {
93
97
  return this.impl.get_logical_position();
94
98
  }
package/native/Cargo.toml CHANGED
@@ -3,7 +3,7 @@
3
3
 
4
4
  [package]
5
5
  name = "slint-node"
6
- version = "0.3.0"
6
+ version = "0.3.2"
7
7
  authors = ["Slint Developers <info@slint-ui.com>"]
8
8
  edition = "2021"
9
9
  build = "build.rs"
@@ -20,9 +20,9 @@ crate-type = ["cdylib"]
20
20
  name = "slint_node_native"
21
21
 
22
22
  [dependencies]
23
- i-slint-compiler = { version = "=0.3.0"}
24
- i-slint-core = { version = "=0.3.0"}
25
- slint-interpreter = { version = "=0.3.0", features = ["display-diagnostics"] }
23
+ i-slint-compiler = { version = "=0.3.2"}
24
+ i-slint-core = { version = "=0.3.2"}
25
+ slint-interpreter = { version = "=0.3.2", features = ["display-diagnostics"] }
26
26
 
27
27
  vtable = { version = "0.1.6"}
28
28
 
package/native/lib.rs CHANGED
@@ -166,6 +166,7 @@ fn to_eval_value<'cx>(
166
166
  | Type::Angle
167
167
  | Type::PhysicalLength
168
168
  | Type::LogicalLength
169
+ | Type::Rem
169
170
  | Type::Percent
170
171
  | Type::UnitProduct(_) => {
171
172
  Ok(Value::Number(val.downcast_or_throw::<JsNumber, _>(cx)?.value()))
@@ -228,13 +229,10 @@ fn to_eval_value<'cx>(
228
229
  | Type::Void
229
230
  | Type::InferredProperty
230
231
  | Type::InferredCallback
231
- | Type::Builtin(_)
232
- | Type::Native(_)
233
232
  | Type::Function { .. }
234
233
  | Type::Model
235
234
  | Type::Callback { .. }
236
235
  | Type::Easing
237
- | Type::Component(_)
238
236
  | Type::PathData
239
237
  | Type::LayoutCache
240
238
  | Type::ElementReference => cx.throw_error("Cannot convert to a Slint property value"),
@@ -504,6 +502,13 @@ declare_types! {
504
502
  Ok(JsUndefined::new().as_value(&mut cx))
505
503
  }
506
504
 
505
+ method get_is_visible(mut cx) {
506
+ let this = cx.this();
507
+ let window = cx.borrow(&this, |x| x.0.as_ref().cloned());
508
+ let window_adapter = window.ok_or(()).or_else(|()| cx.throw_error("Invalid type"))?;
509
+ Ok(JsBoolean::new(&mut cx, window_adapter.window().is_visible()).as_value(&mut cx))
510
+ }
511
+
507
512
  method get_logical_position(mut cx) {
508
513
  let this = cx.this();
509
514
  let window = cx.borrow(&this, |x| x.0.as_ref().cloned());
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "slint-ui",
3
- "version": "0.3.0",
3
+ "version": "0.3.2",
4
4
  "homepage": "https://github.com/slint-ui/slint",
5
5
  "license": "SEE LICENSE IN LICENSE.md",
6
6
  "repository": {
package/dist/index.d.ts DELETED
@@ -1,164 +0,0 @@
1
- /**
2
- * @hidden
3
- */
4
- declare function load_native_lib(): any;
5
- /**
6
- * @hidden
7
- */
8
- declare let native: any;
9
- /**
10
- * @hidden
11
- */
12
- declare class Component {
13
- protected comp: any;
14
- constructor(comp: any);
15
- run(): void;
16
- show(): void;
17
- hide(): void;
18
- get window(): SlintWindow;
19
- send_mouse_click(x: number, y: number): void;
20
- send_keyboard_string_sequence(s: String): void;
21
- }
22
- interface Point {
23
- x: Number;
24
- y: Number;
25
- }
26
- interface Size {
27
- width: Number;
28
- height: Number;
29
- }
30
- interface SlintWindow {
31
- show(): void;
32
- hide(): void;
33
- position: Point;
34
- size: Size;
35
- }
36
- /**
37
- * @hidden
38
- */
39
- declare class WindowAPI implements SlintWindow {
40
- protected impl: any;
41
- constructor(impl: any);
42
- show(): void;
43
- hide(): void;
44
- get position(): Point;
45
- set position(pos: Point);
46
- get size(): Size;
47
- set size(size: Size);
48
- }
49
- /**
50
- * @hidden
51
- */
52
- interface Callback {
53
- (): any;
54
- setHandler(cb: any): void;
55
- }
56
- /**
57
- * ModelPeer is the interface that the run-time implements. An instance is
58
- * set on dynamic Model<T> instances and can be used to notify the run-time
59
- * of changes in the structure or data of the model.
60
- */
61
- interface ModelPeer {
62
- /**
63
- * Call this function from our own model to notify that fields of data
64
- * in the specified row have changed.
65
- * @argument row
66
- */
67
- rowDataChanged(row: number): void;
68
- /**
69
- * Call this function from your own model to notify that one or multiple
70
- * rows were added to the model, starting at the specified row.
71
- * @param row
72
- * @param count
73
- */
74
- rowAdded(row: number, count: number): void;
75
- /**
76
- * Call this function from your own model to notify that one or multiple
77
- * rows were removed from the model, starting at the specified row.
78
- * @param row
79
- * @param count
80
- */
81
- rowRemoved(row: number, count: number): void;
82
- /**
83
- * Call this function from your own model to notify that the model has been
84
- * changed and everything must be reloaded
85
- */
86
- reset(): void;
87
- }
88
- /**
89
- * Model<T> is the interface for feeding dynamic data into
90
- * `.slint` views.
91
- *
92
- * A model is organized like a table with rows of data. The
93
- * fields of the data type T behave like columns.
94
- */
95
- interface Model<T> {
96
- /**
97
- * Implementations of this function must return the current number of rows.
98
- */
99
- rowCount(): number;
100
- /**
101
- * Implementations of this function must return the data at the specified row.
102
- * @param row
103
- */
104
- rowData(row: number): T;
105
- /**
106
- * Implementations of this function must store the provided data parameter
107
- * in the model at the specified row.
108
- * @param row
109
- * @param data
110
- */
111
- setRowData(row: number, data: T): void;
112
- /**
113
- * This public member is set by the run-time and implementation must use this
114
- * to notify the run-time of changes in the model.
115
- */
116
- notify: ModelPeer;
117
- }
118
- /**
119
- * @hidden
120
- */
121
- declare class NullPeer implements ModelPeer {
122
- rowDataChanged(row: number): void;
123
- rowAdded(row: number, count: number): void;
124
- rowRemoved(row: number, count: number): void;
125
- reset(): void;
126
- }
127
- /**
128
- * ArrayModel wraps a JavaScript array for use in `.slint` views. The underlying
129
- * array can be modified with the [[ArrayModel.push]] and [[ArrayModel.remove]] methods.
130
- */
131
- declare class ArrayModel<T> implements Model<T> {
132
- /**
133
- * @hidden
134
- */
135
- private a;
136
- notify: ModelPeer;
137
- /**
138
- * Creates a new ArrayModel.
139
- *
140
- * @param arr
141
- */
142
- constructor(arr: Array<T>);
143
- rowCount(): number;
144
- rowData(row: number): T;
145
- setRowData(row: number, data: T): void;
146
- /**
147
- * Pushes new values to the array that's backing the model and notifies
148
- * the run-time about the added rows.
149
- * @param values
150
- */
151
- push(...values: T[]): void;
152
- /**
153
- * Removes the specified number of element from the array that's backing
154
- * the model, starting at the specified index. This is equivalent to calling
155
- * Array.slice() on the array and notifying the run-time about the removed
156
- * rows.
157
- * @param index
158
- * @param size
159
- */
160
- remove(index: number, size: number): void;
161
- get length(): number;
162
- values(): IterableIterator<T>;
163
- entries(): IterableIterator<[number, T]>;
164
- }
package/dist/index.js DELETED
@@ -1,169 +0,0 @@
1
- "use strict";
2
- // Copyright © SixtyFPS GmbH <info@slint-ui.com>
3
- // SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-commercial
4
- // Load the native library with `process.dlopen` instead of with `require`.
5
- // This is only done for autotest that do not require nom or neon_cli to
6
- // copy the lib to its right place
7
- /**
8
- * @hidden
9
- */
10
- function load_native_lib() {
11
- const os = require('os');
12
- process.dlopen(module, process.env.SLINT_NODE_NATIVE_LIB, os.constants.dlopen.RTLD_NOW);
13
- return module.exports;
14
- }
15
- /**
16
- * @hidden
17
- */
18
- let native = !process.env.SLINT_NODE_NATIVE_LIB ? require('../native/index.node') : load_native_lib();
19
- /**
20
- * @hidden
21
- */
22
- class Component {
23
- constructor(comp) {
24
- this.comp = comp;
25
- }
26
- run() {
27
- this.comp.run();
28
- }
29
- show() {
30
- this.window.show();
31
- }
32
- hide() {
33
- this.window.hide();
34
- }
35
- get window() {
36
- return new WindowAPI(this.comp.window());
37
- }
38
- send_mouse_click(x, y) {
39
- this.comp.send_mouse_click(x, y);
40
- }
41
- send_keyboard_string_sequence(s) {
42
- this.comp.send_keyboard_string_sequence(s);
43
- }
44
- }
45
- /**
46
- * @hidden
47
- */
48
- class WindowAPI {
49
- constructor(impl) {
50
- this.impl = impl;
51
- }
52
- show() {
53
- this.impl.show();
54
- }
55
- hide() {
56
- this.impl.hide();
57
- }
58
- get position() {
59
- return this.impl.get_position();
60
- }
61
- set position(pos) {
62
- this.impl.set_position(pos);
63
- }
64
- get size() {
65
- return this.impl.get_size();
66
- }
67
- set size(size) {
68
- this.impl.set_size(size);
69
- }
70
- }
71
- require.extensions['.60'] = require.extensions['.slint'] =
72
- function (module, filename) {
73
- var c = native.load(filename);
74
- module.exports[c.name().replace(/-/g, '_')] = function (init_properties) {
75
- let comp = c.create(init_properties);
76
- let ret = new Component(comp);
77
- c.properties().forEach((x) => {
78
- Object.defineProperty(ret, x.replace(/-/g, '_'), {
79
- get() { return comp.get_property(x); },
80
- set(newValue) { comp.set_property(x, newValue); },
81
- enumerable: true,
82
- });
83
- });
84
- c.callbacks().forEach((x) => {
85
- Object.defineProperty(ret, x.replace(/-/g, '_'), {
86
- get() {
87
- let callback = function () { return comp.invoke_callback(x, [...arguments]); };
88
- callback.setHandler = function (callback) { comp.connect_callback(x, callback); };
89
- return callback;
90
- },
91
- enumerable: true,
92
- });
93
- });
94
- return ret;
95
- };
96
- };
97
- /**
98
- * @hidden
99
- */
100
- class NullPeer {
101
- rowDataChanged(row) { }
102
- rowAdded(row, count) { }
103
- rowRemoved(row, count) { }
104
- reset() { }
105
- }
106
- /**
107
- * ArrayModel wraps a JavaScript array for use in `.slint` views. The underlying
108
- * array can be modified with the [[ArrayModel.push]] and [[ArrayModel.remove]] methods.
109
- */
110
- class ArrayModel {
111
- /**
112
- * Creates a new ArrayModel.
113
- *
114
- * @param arr
115
- */
116
- constructor(arr) {
117
- this.a = arr;
118
- this.notify = new NullPeer();
119
- }
120
- rowCount() {
121
- return this.a.length;
122
- }
123
- rowData(row) {
124
- return this.a[row];
125
- }
126
- setRowData(row, data) {
127
- this.a[row] = data;
128
- this.notify.rowDataChanged(row);
129
- }
130
- /**
131
- * Pushes new values to the array that's backing the model and notifies
132
- * the run-time about the added rows.
133
- * @param values
134
- */
135
- push(...values) {
136
- let size = this.a.length;
137
- Array.prototype.push.apply(this.a, values);
138
- this.notify.rowAdded(size, arguments.length);
139
- }
140
- // FIXME: should this be named splice and have the splice api?
141
- /**
142
- * Removes the specified number of element from the array that's backing
143
- * the model, starting at the specified index. This is equivalent to calling
144
- * Array.slice() on the array and notifying the run-time about the removed
145
- * rows.
146
- * @param index
147
- * @param size
148
- */
149
- remove(index, size) {
150
- let r = this.a.splice(index, size);
151
- this.notify.rowRemoved(index, size);
152
- }
153
- get length() {
154
- return this.a.length;
155
- }
156
- values() {
157
- return this.a.values();
158
- }
159
- entries() {
160
- return this.a.entries();
161
- }
162
- }
163
- module.exports = {
164
- private_api: native,
165
- ArrayModel: ArrayModel,
166
- Timer: {
167
- singleShot: native.singleshot_timer,
168
- },
169
- };