Debian Codegraph @

packages/datagrid/src/asynccellrenderer.ts

raw
1 // Copyright (c) Jupyter Development Team.
2 // Distributed under the terms of the Modified BSD License.
3 /*-----------------------------------------------------------------------------
4 | Copyright (c) 2014-2023, Lumino Contributors
5 |
6 | Distributed under the terms of the BSD 3-Clause License.
7 |
8 | The full license is in the file LICENSE, distributed with this software.
9 |----------------------------------------------------------------------------*/
10
11 import { CellRenderer } from './cellrenderer';
12 import { GraphicsContext } from './graphicscontext';
13
14 /**
15 * An object which renders the cells of a data grid asynchronously.
16 *
17 * #### Notes
18 * For performance reason, the datagrid only paints cells synchronously,
19 * though if your cell renderer inherits from AsyncCellRenderer, you will
20 * be able to do some asynchronous work prior to painting the cell.
21 * See `ImageRenderer` for an example of an asynchronous renderer.
22 */
23 export abstract class AsyncCellRenderer extends CellRenderer {
24 /**
25 * Whether the renderer is ready or not for that specific config.
26 * If it's not ready, the datagrid will paint the placeholder using `paintPlaceholder`.
27 * If it's ready, the datagrid will paint the cell synchronously using `paint`.
28 *
29 * @param config - The configuration data for the cell.
30 *
31 * @returns Whether the renderer is ready for this config or not.
32 */
33 abstract isReady(config: CellRenderer.CellConfig): boolean;
34
35 /**
36 * Do any asynchronous work prior to painting this cell config.
37 *
38 * @param config - The configuration data for the cell.
39 */
40 abstract load(config: CellRenderer.CellConfig): Promise<void>;
41
42 /**
43 * Paint the placeholder for a cell, waiting for the renderer to be ready.
44 *
45 * @param gc - The graphics context to use for drawing.
46 *
47 * @param config - The configuration data for the cell.
48 */
49 abstract paintPlaceholder(
50 gc: GraphicsContext,
51 config: CellRenderer.CellConfig
52 ): void;
53 }