1 | import { IDisposable } from '@lumino/disposable';
|
2 | import { Menu } from '@lumino/widgets';
|
3 |
|
4 |
|
5 |
|
6 | export interface IDisposableMenuItem extends IDisposable, Menu.IItem {
|
7 | }
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 | export interface IRankedMenu extends IDisposable {
|
17 | |
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 |
|
26 |
|
27 |
|
28 | addGroup(items: Menu.IItemOptions[], rank?: number): IDisposable;
|
29 | |
30 |
|
31 |
|
32 |
|
33 |
|
34 |
|
35 |
|
36 | addItem(options: IRankedMenu.IItemOptions): IDisposable;
|
37 | |
38 |
|
39 |
|
40 | readonly items: ReadonlyArray<Menu.IItem>;
|
41 | |
42 |
|
43 |
|
44 | readonly rank?: number;
|
45 | }
|
46 |
|
47 |
|
48 |
|
49 | export declare namespace IRankedMenu {
|
50 | |
51 |
|
52 |
|
53 | const DEFAULT_RANK = 100;
|
54 | |
55 |
|
56 |
|
57 | interface IItemOptions extends Menu.IItemOptions {
|
58 | |
59 |
|
60 |
|
61 | rank?: number;
|
62 | }
|
63 | |
64 |
|
65 |
|
66 | interface IOptions extends Menu.IOptions {
|
67 | |
68 |
|
69 |
|
70 |
|
71 |
|
72 |
|
73 | includeSeparators?: boolean;
|
74 | |
75 |
|
76 |
|
77 | rank?: number;
|
78 | }
|
79 | }
|
80 |
|
81 |
|
82 |
|
83 | export declare class RankedMenu extends Menu implements IRankedMenu {
|
84 | |
85 |
|
86 |
|
87 |
|
88 |
|
89 | constructor(options: IRankedMenu.IOptions);
|
90 | /**
|
91 | * Menu rank.
|
92 | */
|
93 | get rank(): number | undefined;
|
94 | /**
|
95 | * Add a group of menu items specific to a particular
|
96 | * plugin.
|
97 | *
|
98 | * The rank can be set for all items in the group using the
|
99 | * function argument or per item.
|
100 | *
|
101 | * @param items - the list of menu items to add.
|
102 | * @param rank - the default rank in the menu in which to insert the group.
|
103 | * @returns Disposable of the group
|
104 | */
|
105 | addGroup(items: IRankedMenu.IItemOptions[], rank?: number): IDisposable;
|
106 | /**
|
107 | * Add a menu item to the end of the menu.
|
108 | *
|
109 | * @param options - The options for creating the menu item.
|
110 | *
|
111 | * @returns The menu item added to the menu.
|
112 | */
|
113 | addItem(options: IRankedMenu.IItemOptions): IDisposableMenuItem;
|
114 | /**
|
115 | * Remove all menu items from the menu.
|
116 | */
|
117 | clearItems(): void;
|
118 | /**
|
119 | * Dispose of the resources held by the menu.
|
120 | */
|
121 | dispose(): void;
|
122 | /**
|
123 | * Get the rank of the item at index.
|
124 | *
|
125 | * @param index Item index.
|
126 | * @returns Rank of the item.
|
127 | */
|
128 | getRankAt(index: number): number;
|
129 | /**
|
130 | * Insert a menu item into the menu at the specified index.
|
131 | *
|
132 | * @param index - The index at which to insert the item.
|
133 | *
|
134 | * @param options - The options for creating the menu item.
|
135 | *
|
136 | * @returns The menu item added to the menu.
|
137 | *
|
138 | * #### Notes
|
139 | * The index will be clamped to the bounds of the items.
|
140 | */
|
141 | insertItem(index: number, options: IRankedMenu.IItemOptions): IDisposableMenuItem;
|
142 | /**
|
143 | * Remove the item at a given index from the menu.
|
144 | *
|
145 | * @param index - The index of the item to remove.
|
146 | *
|
147 | * #### Notes
|
148 | * This is a no-op if the index is out of range.
|
149 | */
|
150 | removeItemAt(index: number): void;
|
151 | private _includeSeparators;
|
152 | private _rank;
|
153 | private _ranks;
|
154 | }
|