@gjsify/canvas2d 0.1.0

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.
@@ -0,0 +1,482 @@
1
+ import GObject from 'gi://GObject';
2
+ import Gdk from 'gi://Gdk?version=4.0';
3
+ import GLib from 'gi://GLib?version=2.0';
4
+ import Gtk from 'gi://Gtk?version=4.0';
5
+ import { HTMLCanvasElement as GjsifyHTMLCanvasElement } from '@gjsify/dom-elements';
6
+ import { CanvasRenderingContext2D } from './canvas-rendering-context-2d.js';
7
+ type Canvas2DReadyCallback = (canvas: globalThis.HTMLCanvasElement, ctx: CanvasRenderingContext2D) => void;
8
+ /**
9
+ * A `Gtk.DrawingArea` subclass that handles Canvas 2D bootstrapping:
10
+ * - Creates an `HTMLCanvasElement` + `CanvasRenderingContext2D` on first draw
11
+ * - Blits the Canvas 2D Cairo.ImageSurface onto the DrawingArea each frame
12
+ * - Fires `onReady()` callbacks with (canvas, ctx) once the context is available
13
+ * - Provides `requestAnimationFrame()` backed by GTK frame clock (vsync)
14
+ * - `installGlobals()` sets `globalThis.requestAnimationFrame` and `globalThis.performance`
15
+ *
16
+ * Usage:
17
+ * ```ts
18
+ * const widget = new Canvas2DWidget();
19
+ * widget.installGlobals(); // sets globalThis.requestAnimationFrame
20
+ * widget.onReady((canvas, ctx) => {
21
+ * ctx.fillStyle = 'red';
22
+ * ctx.fillRect(0, 0, 100, 100);
23
+ * });
24
+ * window.set_child(widget);
25
+ * ```
26
+ */
27
+ export declare const Canvas2DWidget: {
28
+ new (params?: Partial<Gtk.DrawingArea.ConstructorProps>): {
29
+ _canvas: GjsifyHTMLCanvasElement | null;
30
+ _ctx: CanvasRenderingContext2D | null;
31
+ _readyCallbacks: Canvas2DReadyCallback[];
32
+ _tickCallbackId: number | null;
33
+ _frameCallback: FrameRequestCallback | null;
34
+ _timeOrigin: number;
35
+ /** @internal Draw function called by GTK. Blits the Cairo surface to screen. */
36
+ _onDraw(_area: Gtk.DrawingArea, cr: any, width: number, height: number): void;
37
+ /** The HTMLCanvasElement backing this widget. Available after the first draw. */
38
+ get canvas(): globalThis.HTMLCanvasElement | null;
39
+ /** Get the 2D rendering context. Available after the first draw. */
40
+ getContext(_id: "2d"): CanvasRenderingContext2D | null;
41
+ /**
42
+ * Register a callback to be invoked once the Canvas 2D context is ready.
43
+ * If the context is already available, the callback fires synchronously.
44
+ */
45
+ onReady(cb: Canvas2DReadyCallback): void;
46
+ /**
47
+ * Schedules a single animation frame callback, matching the browser `requestAnimationFrame` API.
48
+ * Backed by GTK frame clock (vsync-synced, typically ~60 FPS).
49
+ * Returns 0 (handle — cancel not yet implemented).
50
+ */
51
+ requestAnimationFrame(cb: FrameRequestCallback): number;
52
+ /**
53
+ * Sets browser globals (`requestAnimationFrame`, `performance`) so that
54
+ * browser-targeted code works unchanged on GJS.
55
+ */
56
+ installGlobals(): void;
57
+ get content_height(): number;
58
+ set content_height(val: number);
59
+ get contentHeight(): number;
60
+ set contentHeight(val: number);
61
+ get content_width(): number;
62
+ set content_width(val: number);
63
+ get contentWidth(): number;
64
+ set contentWidth(val: number);
65
+ $signals: Gtk.DrawingArea.SignalSignatures;
66
+ widget: Gtk.Widget;
67
+ _init(...args: any[]): void;
68
+ connect<K extends keyof Gtk.DrawingArea.SignalSignatures>(signal: K, callback: GObject.SignalCallback</*elided*/ any, Gtk.DrawingArea.SignalSignatures[K]>): number;
69
+ connect(signal: string, callback: (...args: any[]) => any): number;
70
+ connect_after<K extends keyof Gtk.DrawingArea.SignalSignatures>(signal: K, callback: GObject.SignalCallback</*elided*/ any, Gtk.DrawingArea.SignalSignatures[K]>): number;
71
+ connect_after(signal: string, callback: (...args: any[]) => any): number;
72
+ emit<K extends keyof Gtk.DrawingArea.SignalSignatures>(signal: K, ...args: GObject.GjsParameters<Gtk.DrawingArea.SignalSignatures[K]> extends [any, ...infer Q] ? Q : never): void;
73
+ emit(signal: string, ...args: any[]): void;
74
+ vfunc_resize(width: number, height: number): void;
75
+ get_content_height(): number;
76
+ get_content_width(): number;
77
+ set_content_height(height: number): void;
78
+ set_content_width(width: number): void;
79
+ set_draw_func(draw_func?: Gtk.DrawingAreaDrawFunc | null): void;
80
+ get accessible_role(): Gtk.AccessibleRole;
81
+ set accessible_role(val: Gtk.AccessibleRole);
82
+ get accessibleRole(): Gtk.AccessibleRole;
83
+ set accessibleRole(val: Gtk.AccessibleRole);
84
+ announce(message: string, priority: Gtk.AccessibleAnnouncementPriority | null): void;
85
+ get_accessible_id(): string | null;
86
+ get_accessible_parent(): Gtk.Accessible | null;
87
+ get_accessible_role(): Gtk.AccessibleRole;
88
+ get_at_context(): Gtk.ATContext;
89
+ get_bounds(): [boolean, number, number, number, number];
90
+ get_first_accessible_child(): Gtk.Accessible | null;
91
+ get_next_accessible_sibling(): Gtk.Accessible | null;
92
+ get_platform_state(state: Gtk.AccessiblePlatformState | null): boolean;
93
+ reset_property(property: Gtk.AccessibleProperty | null): void;
94
+ reset_relation(relation: Gtk.AccessibleRelation | null): void;
95
+ reset_state(state: Gtk.AccessibleState | null): void;
96
+ set_accessible_parent(parent?: Gtk.Accessible | null, next_sibling?: Gtk.Accessible | null): void;
97
+ update_next_accessible_sibling(new_sibling?: Gtk.Accessible | null): void;
98
+ update_platform_state(state: Gtk.AccessiblePlatformState | null): void;
99
+ update_property(properties: Gtk.AccessibleProperty[] | null, values: (GObject.Value | any)[]): void;
100
+ update_relation(relations: Gtk.AccessibleRelation[] | null, values: (GObject.Value | any)[]): void;
101
+ update_state(states: Gtk.AccessibleState[] | null, values: (GObject.Value | any)[]): void;
102
+ vfunc_get_accessible_id(): string | null;
103
+ vfunc_get_accessible_parent(): Gtk.Accessible | null;
104
+ vfunc_get_at_context(): Gtk.ATContext | null;
105
+ vfunc_get_bounds(): [boolean, number, number, number, number];
106
+ vfunc_get_first_accessible_child(): Gtk.Accessible | null;
107
+ vfunc_get_next_accessible_sibling(): Gtk.Accessible | null;
108
+ vfunc_get_platform_state(state: Gtk.AccessiblePlatformState): boolean;
109
+ get_buildable_id(): string | null;
110
+ vfunc_add_child(builder: Gtk.Builder, child: GObject.Object, type?: string | null): void;
111
+ vfunc_custom_finished(builder: Gtk.Builder, child: GObject.Object | null, tagname: string, data?: any | null): void;
112
+ vfunc_custom_tag_end(builder: Gtk.Builder, child: GObject.Object | null, tagname: string, data?: any | null): void;
113
+ vfunc_custom_tag_start(builder: Gtk.Builder, child: GObject.Object | null, tagname: string): [boolean, Gtk.BuildableParser, any];
114
+ vfunc_get_id(): string;
115
+ vfunc_get_internal_child<T = GObject.Object>(builder: Gtk.Builder, childname: string): T;
116
+ vfunc_parser_finished(builder: Gtk.Builder): void;
117
+ vfunc_set_buildable_property(builder: Gtk.Builder, name: string, value: GObject.Value | any): void;
118
+ vfunc_set_id(id: string): void;
119
+ bind_property(source_property: string, target: GObject.Object, target_property: string, flags: GObject.BindingFlags | null): GObject.Binding;
120
+ bind_property_full(source_property: string, target: GObject.Object, target_property: string, flags: GObject.BindingFlags | null, transform_to?: GObject.BindingTransformFunc | null, transform_from?: GObject.BindingTransformFunc | null, notify?: GLib.DestroyNotify | null): GObject.Binding;
121
+ bind_property_full(...args: never[]): any;
122
+ force_floating(): void;
123
+ freeze_notify(): void;
124
+ get_data(key: string): any | null;
125
+ get_property(property_name: string, value: GObject.Value | any): any;
126
+ get_qdata(quark: GLib.Quark): any | null;
127
+ getv(names: string[], values: (GObject.Value | any)[]): void;
128
+ is_floating(): boolean;
129
+ notify(property_name: string): void;
130
+ notify_by_pspec(pspec: GObject.ParamSpec): void;
131
+ ref(): GObject.Object;
132
+ ref_sink(): GObject.Object;
133
+ run_dispose(): void;
134
+ set_data(key: string, data?: any | null): void;
135
+ set_property(property_name: string, value: GObject.Value | any): void;
136
+ steal_data(key: string): any | null;
137
+ steal_qdata(quark: GLib.Quark): any | null;
138
+ thaw_notify(): void;
139
+ unref(): void;
140
+ watch_closure(closure: GObject.Closure): void;
141
+ vfunc_constructed(): void;
142
+ vfunc_dispatch_properties_changed(n_pspecs: number, pspecs: GObject.ParamSpec): void;
143
+ vfunc_dispose(): void;
144
+ vfunc_finalize(): void;
145
+ vfunc_get_property(property_id: number, value: GObject.Value | any, pspec: GObject.ParamSpec): void;
146
+ vfunc_notify(pspec: GObject.ParamSpec): void;
147
+ vfunc_set_property(property_id: number, value: GObject.Value | any, pspec: GObject.ParamSpec): void;
148
+ disconnect(id: number): void;
149
+ set(properties: {
150
+ [key: string]: any;
151
+ }): void;
152
+ block_signal_handler(id: number): void;
153
+ unblock_signal_handler(id: number): void;
154
+ stop_emission_by_name(detailedName: string): void;
155
+ get can_focus(): boolean;
156
+ set can_focus(val: boolean);
157
+ get canFocus(): boolean;
158
+ set canFocus(val: boolean);
159
+ get can_target(): boolean;
160
+ set can_target(val: boolean);
161
+ get canTarget(): boolean;
162
+ set canTarget(val: boolean);
163
+ get css_classes(): string[];
164
+ set css_classes(val: string[]);
165
+ get cssClasses(): string[];
166
+ set cssClasses(val: string[]);
167
+ get css_name(): string;
168
+ get cssName(): string;
169
+ get cursor(): Gdk.Cursor;
170
+ set cursor(val: Gdk.Cursor);
171
+ get focus_on_click(): boolean;
172
+ set focus_on_click(val: boolean);
173
+ get focusOnClick(): boolean;
174
+ set focusOnClick(val: boolean);
175
+ get focusable(): boolean;
176
+ set focusable(val: boolean);
177
+ get halign(): Gtk.Align;
178
+ set halign(val: Gtk.Align);
179
+ get has_default(): boolean;
180
+ get hasDefault(): boolean;
181
+ get has_focus(): boolean;
182
+ get hasFocus(): boolean;
183
+ get has_tooltip(): boolean;
184
+ set has_tooltip(val: boolean);
185
+ get hasTooltip(): boolean;
186
+ set hasTooltip(val: boolean);
187
+ get height_request(): number;
188
+ set height_request(val: number);
189
+ get heightRequest(): number;
190
+ set heightRequest(val: number);
191
+ get hexpand(): boolean;
192
+ set hexpand(val: boolean);
193
+ get hexpand_set(): boolean;
194
+ set hexpand_set(val: boolean);
195
+ get hexpandSet(): boolean;
196
+ set hexpandSet(val: boolean);
197
+ get layout_manager(): Gtk.LayoutManager;
198
+ set layout_manager(val: Gtk.LayoutManager);
199
+ get layoutManager(): Gtk.LayoutManager;
200
+ set layoutManager(val: Gtk.LayoutManager);
201
+ get limit_events(): boolean;
202
+ set limit_events(val: boolean);
203
+ get limitEvents(): boolean;
204
+ set limitEvents(val: boolean);
205
+ get margin_bottom(): number;
206
+ set margin_bottom(val: number);
207
+ get marginBottom(): number;
208
+ set marginBottom(val: number);
209
+ get margin_end(): number;
210
+ set margin_end(val: number);
211
+ get marginEnd(): number;
212
+ set marginEnd(val: number);
213
+ get margin_start(): number;
214
+ set margin_start(val: number);
215
+ get marginStart(): number;
216
+ set marginStart(val: number);
217
+ get margin_top(): number;
218
+ set margin_top(val: number);
219
+ get marginTop(): number;
220
+ set marginTop(val: number);
221
+ get name(): string;
222
+ set name(val: string);
223
+ get opacity(): number;
224
+ set opacity(val: number);
225
+ get overflow(): Gtk.Overflow;
226
+ set overflow(val: Gtk.Overflow);
227
+ get parent(): Gtk.Widget;
228
+ get receives_default(): boolean;
229
+ set receives_default(val: boolean);
230
+ get receivesDefault(): boolean;
231
+ set receivesDefault(val: boolean);
232
+ get root(): Gtk.Root;
233
+ get scale_factor(): number;
234
+ get scaleFactor(): number;
235
+ get sensitive(): boolean;
236
+ set sensitive(val: boolean);
237
+ get tooltip_markup(): string;
238
+ set tooltip_markup(val: string);
239
+ get tooltipMarkup(): string;
240
+ set tooltipMarkup(val: string);
241
+ get tooltip_text(): string;
242
+ set tooltip_text(val: string);
243
+ get tooltipText(): string;
244
+ set tooltipText(val: string);
245
+ get valign(): Gtk.Align;
246
+ set valign(val: Gtk.Align);
247
+ get vexpand(): boolean;
248
+ set vexpand(val: boolean);
249
+ get vexpand_set(): boolean;
250
+ set vexpand_set(val: boolean);
251
+ get vexpandSet(): boolean;
252
+ set vexpandSet(val: boolean);
253
+ get visible(): boolean;
254
+ set visible(val: boolean);
255
+ get width_request(): number;
256
+ set width_request(val: number);
257
+ get widthRequest(): number;
258
+ set widthRequest(val: number);
259
+ vfunc_compute_expand(hexpand_p: boolean, vexpand_p: boolean): void;
260
+ vfunc_contains(x: number, y: number): boolean;
261
+ vfunc_css_changed(change: Gtk.CssStyleChange): void;
262
+ vfunc_direction_changed(previous_direction: Gtk.TextDirection): void;
263
+ vfunc_focus(direction: Gtk.DirectionType): boolean;
264
+ vfunc_get_request_mode(): Gtk.SizeRequestMode;
265
+ vfunc_grab_focus(): boolean;
266
+ vfunc_hide(): void;
267
+ vfunc_keynav_failed(direction: Gtk.DirectionType): boolean;
268
+ vfunc_map(): void;
269
+ vfunc_measure(orientation: Gtk.Orientation, for_size: number): [number, number, number, number];
270
+ vfunc_mnemonic_activate(group_cycling: boolean): boolean;
271
+ vfunc_move_focus(direction: Gtk.DirectionType): void;
272
+ vfunc_query_tooltip(x: number, y: number, keyboard_tooltip: boolean, tooltip: Gtk.Tooltip): boolean;
273
+ vfunc_realize(): void;
274
+ vfunc_root(): void;
275
+ vfunc_set_focus_child(child?: Gtk.Widget | null): void;
276
+ vfunc_show(): void;
277
+ vfunc_size_allocate(width: number, height: number, baseline: number): void;
278
+ vfunc_snapshot(snapshot: Gtk.Snapshot): void;
279
+ vfunc_state_flags_changed(previous_state_flags: Gtk.StateFlags): void;
280
+ vfunc_system_setting_changed(settings: Gtk.SystemSetting): void;
281
+ vfunc_unmap(): void;
282
+ vfunc_unrealize(): void;
283
+ vfunc_unroot(): void;
284
+ action_set_enabled(action_name: string, enabled: boolean): void;
285
+ activate(): boolean;
286
+ activate_action(name: string, args?: GLib.Variant | null): boolean;
287
+ activate_default(): void;
288
+ add_controller(controller: Gtk.EventController): void;
289
+ add_css_class(css_class: string): void;
290
+ add_mnemonic_label(label: Gtk.Widget): void;
291
+ add_tick_callback(callback: Gtk.TickCallback): number;
292
+ allocate(width: number, height: number, baseline: number, transform?: import("@girs/gsk-4.0").default.Transform | null): void;
293
+ child_focus(direction: Gtk.DirectionType | null): boolean;
294
+ compute_bounds(target: Gtk.Widget): [boolean, import("@girs/graphene-1.0").default.Rect];
295
+ compute_expand(orientation: Gtk.Orientation | null): boolean;
296
+ compute_point(target: Gtk.Widget, point: import("@girs/graphene-1.0").default.Point): [boolean, import("@girs/graphene-1.0").default.Point];
297
+ compute_transform(target: Gtk.Widget): [boolean, import("@girs/graphene-1.0").default.Matrix];
298
+ contains(x: number, y: number): boolean;
299
+ create_pango_context(): import("@girs/pango-1.0").default.Context;
300
+ create_pango_layout(text?: string | null): import("@girs/pango-1.0").default.Layout;
301
+ dispose_template(widget_type: GObject.GType): void;
302
+ drag_check_threshold(start_x: number, start_y: number, current_x: number, current_y: number): boolean;
303
+ error_bell(): void;
304
+ get_allocated_baseline(): number;
305
+ get_allocated_height(): number;
306
+ get_allocated_width(): number;
307
+ get_allocation(): Gtk.Allocation;
308
+ get_ancestor(widget_type: GObject.GType): Gtk.Widget | null;
309
+ get_baseline(): number;
310
+ get_can_focus(): boolean;
311
+ get_can_target(): boolean;
312
+ get_child_visible(): boolean;
313
+ get_clipboard(): Gdk.Clipboard;
314
+ get_color(): Gdk.RGBA;
315
+ get_css_classes(): string[];
316
+ get_css_name(): string;
317
+ get_cursor(): Gdk.Cursor | null;
318
+ get_direction(): Gtk.TextDirection;
319
+ get_display(): Gdk.Display;
320
+ get_first_child(): Gtk.Widget | null;
321
+ get_focus_child(): Gtk.Widget | null;
322
+ get_focus_on_click(): boolean;
323
+ get_focusable(): boolean;
324
+ get_font_map(): import("@girs/pango-1.0").default.FontMap | null;
325
+ get_font_options(): import("@girs/gjs/cairo").default.FontOptions | null;
326
+ get_frame_clock(): Gdk.FrameClock | null;
327
+ get_halign(): Gtk.Align;
328
+ get_has_tooltip(): boolean;
329
+ get_height(): number;
330
+ get_hexpand(): boolean;
331
+ get_hexpand_set(): boolean;
332
+ get_last_child(): Gtk.Widget | null;
333
+ get_layout_manager(): Gtk.LayoutManager | null;
334
+ get_limit_events(): boolean;
335
+ get_mapped(): boolean;
336
+ get_margin_bottom(): number;
337
+ get_margin_end(): number;
338
+ get_margin_start(): number;
339
+ get_margin_top(): number;
340
+ get_name(): string;
341
+ get_native(): Gtk.Native | null;
342
+ get_next_sibling(): Gtk.Widget | null;
343
+ get_opacity(): number;
344
+ get_overflow(): Gtk.Overflow;
345
+ get_pango_context(): import("@girs/pango-1.0").default.Context;
346
+ get_parent(): Gtk.Widget | null;
347
+ get_preferred_size(): [Gtk.Requisition | null, Gtk.Requisition | null];
348
+ get_prev_sibling(): Gtk.Widget | null;
349
+ get_primary_clipboard(): Gdk.Clipboard;
350
+ get_realized(): boolean;
351
+ get_receives_default(): boolean;
352
+ get_request_mode(): Gtk.SizeRequestMode;
353
+ get_root(): Gtk.Root | null;
354
+ get_scale_factor(): number;
355
+ get_sensitive(): boolean;
356
+ get_settings(): Gtk.Settings;
357
+ get_size(orientation: Gtk.Orientation | null): number;
358
+ get_size_request(): [number, number];
359
+ get_state_flags(): Gtk.StateFlags;
360
+ get_style_context(): Gtk.StyleContext;
361
+ get_template_child<T = GObject.Object>(widget_type: GObject.GType, name: string): T;
362
+ get_tooltip_markup(): string | null;
363
+ get_tooltip_text(): string | null;
364
+ get_valign(): Gtk.Align;
365
+ get_vexpand(): boolean;
366
+ get_vexpand_set(): boolean;
367
+ get_visible(): boolean;
368
+ get_width(): number;
369
+ grab_focus(): boolean;
370
+ has_css_class(css_class: string): boolean;
371
+ has_visible_focus(): boolean;
372
+ hide(): void;
373
+ in_destruction(): boolean;
374
+ init_template(): void;
375
+ insert_action_group(name: string, group?: import("@girs/gio-2.0").default.ActionGroup | null): void;
376
+ insert_after(parent: Gtk.Widget, previous_sibling?: Gtk.Widget | null): void;
377
+ insert_before(parent: Gtk.Widget, next_sibling?: Gtk.Widget | null): void;
378
+ is_ancestor(ancestor: Gtk.Widget): boolean;
379
+ is_drawable(): boolean;
380
+ is_focus(): boolean;
381
+ is_sensitive(): boolean;
382
+ is_visible(): boolean;
383
+ keynav_failed(direction: Gtk.DirectionType | null): boolean;
384
+ list_mnemonic_labels(): Gtk.Widget[];
385
+ map(): void;
386
+ measure(orientation: Gtk.Orientation | null, for_size: number): [number, number, number, number];
387
+ mnemonic_activate(group_cycling: boolean): boolean;
388
+ observe_children(): import("@girs/gio-2.0").default.ListModel;
389
+ observe_controllers(): import("@girs/gio-2.0").default.ListModel;
390
+ pick(x: number, y: number, flags: Gtk.PickFlags | null): Gtk.Widget | null;
391
+ queue_allocate(): void;
392
+ queue_draw(): void;
393
+ queue_resize(): void;
394
+ realize(): void;
395
+ remove_controller(controller: Gtk.EventController): void;
396
+ remove_css_class(css_class: string): void;
397
+ remove_mnemonic_label(label: Gtk.Widget): void;
398
+ remove_tick_callback(id: number): void;
399
+ set_can_focus(can_focus: boolean): void;
400
+ set_can_target(can_target: boolean): void;
401
+ set_child_visible(child_visible: boolean): void;
402
+ set_css_classes(classes: string[]): void;
403
+ set_cursor(cursor?: Gdk.Cursor | null): void;
404
+ set_cursor_from_name(name?: string | null): void;
405
+ set_direction(dir: Gtk.TextDirection | null): void;
406
+ set_focus_child(child?: Gtk.Widget | null): void;
407
+ set_focus_on_click(focus_on_click: boolean): void;
408
+ set_focusable(focusable: boolean): void;
409
+ set_font_map(font_map?: import("@girs/pango-1.0").default.FontMap | null): void;
410
+ set_font_options(options?: import("@girs/gjs/cairo").default.FontOptions | null): void;
411
+ set_halign(align: Gtk.Align | null): void;
412
+ set_has_tooltip(has_tooltip: boolean): void;
413
+ set_hexpand(expand: boolean): void;
414
+ set_hexpand_set(set: boolean): void;
415
+ set_layout_manager(layout_manager?: Gtk.LayoutManager | null): void;
416
+ set_limit_events(limit_events: boolean): void;
417
+ set_margin_bottom(margin: number): void;
418
+ set_margin_end(margin: number): void;
419
+ set_margin_start(margin: number): void;
420
+ set_margin_top(margin: number): void;
421
+ set_name(name: string): void;
422
+ set_opacity(opacity: number): void;
423
+ set_overflow(overflow: Gtk.Overflow | null): void;
424
+ set_parent(parent: Gtk.Widget): void;
425
+ set_receives_default(receives_default: boolean): void;
426
+ set_sensitive(sensitive: boolean): void;
427
+ set_size_request(width: number, height: number): void;
428
+ set_state_flags(flags: Gtk.StateFlags | null, clear: boolean): void;
429
+ set_tooltip_markup(markup?: string | null): void;
430
+ set_tooltip_text(text?: string | null): void;
431
+ set_valign(align: Gtk.Align | null): void;
432
+ set_vexpand(expand: boolean): void;
433
+ set_vexpand_set(set: boolean): void;
434
+ set_visible(visible: boolean): void;
435
+ should_layout(): boolean;
436
+ show(): void;
437
+ size_allocate(allocation: Gtk.Allocation, baseline: number): void;
438
+ snapshot_child(child: Gtk.Widget, snapshot: Gtk.Snapshot): void;
439
+ translate_coordinates(dest_widget: Gtk.Widget, src_x: number, src_y: number): [boolean, number, number];
440
+ trigger_tooltip_query(): void;
441
+ unmap(): void;
442
+ unparent(): void;
443
+ unrealize(): void;
444
+ unset_state_flags(flags: Gtk.StateFlags | null): void;
445
+ [Symbol.iterator]: () => IterableIterator<Gtk.Widget>;
446
+ };
447
+ $gtype: GObject.GType<Gtk.DrawingArea>;
448
+ "new"(): Gtk.DrawingArea;
449
+ get_default_direction(): Gtk.TextDirection;
450
+ set_default_direction(dir: Gtk.TextDirection): void;
451
+ add_shortcut(shortcut: Gtk.Shortcut): void;
452
+ bind_template_callback_full(callback_name: string, callback_symbol: GObject.Callback): void;
453
+ bind_template_child_full(name: string, internal_child: boolean, struct_offset: number): void;
454
+ get_accessible_role(): Gtk.AccessibleRole;
455
+ get_activate_signal(): number;
456
+ get_css_name(): string;
457
+ get_layout_manager_type(): GObject.GType;
458
+ install_action(action_name: string, parameter_type: string | null, activate: Gtk.WidgetActionActivateFunc): void;
459
+ install_property_action(action_name: string, property_name: string): void;
460
+ query_action(index_: number): [boolean, GObject.GType, string, GLib.VariantType | null, string];
461
+ set_accessible_role(accessible_role: Gtk.AccessibleRole): void;
462
+ set_activate_signal(signal_id: number): void;
463
+ set_activate_signal_from_name(signal_name: string): void;
464
+ set_css_name(name: string): void;
465
+ set_layout_manager_type(type: GObject.GType): void;
466
+ set_template(template_bytes: GLib.Bytes | Uint8Array): void;
467
+ set_template_from_resource(resource_name: string): void;
468
+ set_template_scope(scope: Gtk.BuilderScope): void;
469
+ newv(object_type: GObject.GType, parameters: GObject.Parameter[]): GObject.Object;
470
+ compat_control(what: number, data?: any | null): number;
471
+ interface_find_property(g_iface: GObject.TypeInterface, property_name: string): GObject.ParamSpec;
472
+ interface_install_property(g_iface: GObject.TypeInterface, pspec: GObject.ParamSpec): void;
473
+ interface_list_properties(g_iface: GObject.TypeInterface): GObject.ParamSpec[];
474
+ find_property(property_name: string): GObject.ParamSpec;
475
+ install_properties(pspecs: GObject.ParamSpec[]): void;
476
+ install_property(property_id: number, pspec: GObject.ParamSpec): void;
477
+ list_properties(): GObject.ParamSpec[];
478
+ override_property(property_id: number, name: string): void;
479
+ _classInit(klass: any): any;
480
+ };
481
+ export type Canvas2DWidget = InstanceType<typeof Canvas2DWidget>;
482
+ export {};
@@ -0,0 +1,11 @@
1
+ import Cairo from 'cairo';
2
+ /**
3
+ * CanvasGradient wrapping a Cairo LinearGradient or RadialGradient.
4
+ */
5
+ export declare class CanvasGradient {
6
+ private _pattern;
7
+ constructor(type: 'linear' | 'radial', x0: number, y0: number, x1: number, y1: number, r0?: number, r1?: number);
8
+ addColorStop(offset: number, color: string): void;
9
+ /** @internal Get the underlying Cairo pattern for rendering. */
10
+ _getCairoPattern(): Cairo.LinearGradient | Cairo.RadialGradient;
11
+ }
@@ -0,0 +1,80 @@
1
+ /** A recorded path operation. */
2
+ type PathOp = {
3
+ type: 'moveTo';
4
+ x: number;
5
+ y: number;
6
+ } | {
7
+ type: 'lineTo';
8
+ x: number;
9
+ y: number;
10
+ } | {
11
+ type: 'closePath';
12
+ } | {
13
+ type: 'bezierCurveTo';
14
+ cp1x: number;
15
+ cp1y: number;
16
+ cp2x: number;
17
+ cp2y: number;
18
+ x: number;
19
+ y: number;
20
+ } | {
21
+ type: 'quadraticCurveTo';
22
+ cpx: number;
23
+ cpy: number;
24
+ x: number;
25
+ y: number;
26
+ } | {
27
+ type: 'arc';
28
+ x: number;
29
+ y: number;
30
+ radius: number;
31
+ startAngle: number;
32
+ endAngle: number;
33
+ ccw: boolean;
34
+ } | {
35
+ type: 'ellipse';
36
+ x: number;
37
+ y: number;
38
+ rx: number;
39
+ ry: number;
40
+ rotation: number;
41
+ startAngle: number;
42
+ endAngle: number;
43
+ ccw: boolean;
44
+ } | {
45
+ type: 'rect';
46
+ x: number;
47
+ y: number;
48
+ w: number;
49
+ h: number;
50
+ } | {
51
+ type: 'roundRect';
52
+ x: number;
53
+ y: number;
54
+ w: number;
55
+ h: number;
56
+ radii: number | number[];
57
+ };
58
+ /**
59
+ * Path2D records path operations for later replay on a CanvasRenderingContext2D.
60
+ */
61
+ export declare class Path2D {
62
+ /** @internal Recorded operations */
63
+ _ops: PathOp[];
64
+ constructor(pathOrSvg?: Path2D | string);
65
+ addPath(path: Path2D): void;
66
+ moveTo(x: number, y: number): void;
67
+ lineTo(x: number, y: number): void;
68
+ closePath(): void;
69
+ bezierCurveTo(cp1x: number, cp1y: number, cp2x: number, cp2y: number, x: number, y: number): void;
70
+ quadraticCurveTo(cpx: number, cpy: number, x: number, y: number): void;
71
+ arc(x: number, y: number, radius: number, startAngle: number, endAngle: number, counterclockwise?: boolean): void;
72
+ ellipse(x: number, y: number, radiusX: number, radiusY: number, rotation: number, startAngle: number, endAngle: number, counterclockwise?: boolean): void;
73
+ rect(x: number, y: number, w: number, h: number): void;
74
+ roundRect(x: number, y: number, w: number, h: number, radii?: number | number[]): void;
75
+ /**
76
+ * @internal Replay all recorded path operations onto a Cairo context.
77
+ */
78
+ _replayOnCairo(ctx: import('cairo').default.Context): void;
79
+ }
80
+ export {};
@@ -0,0 +1,12 @@
1
+ import Cairo from 'cairo';
2
+ /**
3
+ * CanvasPattern wrapping a Cairo SurfacePattern.
4
+ */
5
+ export declare class CanvasPattern {
6
+ private _pattern;
7
+ private constructor();
8
+ /** Create a CanvasPattern from a supported image source. Returns null if unsupported. */
9
+ static create(image: any, repetition: string | null): CanvasPattern | null;
10
+ /** @internal Get the underlying Cairo pattern for rendering. */
11
+ _getCairoPattern(): Cairo.SurfacePattern;
12
+ }