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 |
|
37 |
|
38 | addItem(options: IRankedMenu.IItemOptions): Menu.IItem;
|
39 | |
40 |
|
41 |
|
42 | readonly items: ReadonlyArray<Menu.IItem>;
|
43 | |
44 |
|
45 |
|
46 |
|
47 |
|
48 | readonly menu: Menu;
|
49 | |
50 |
|
51 |
|
52 | readonly rank?: number;
|
53 | }
|
54 |
|
55 |
|
56 |
|
57 | export declare namespace IRankedMenu {
|
58 | |
59 |
|
60 |
|
61 | const DEFAULT_RANK = 100;
|
62 | |
63 |
|
64 |
|
65 | interface IItemOptions extends Menu.IItemOptions {
|
66 | |
67 |
|
68 |
|
69 | rank?: number;
|
70 | }
|
71 | |
72 |
|
73 |
|
74 | interface IOptions extends Menu.IOptions {
|
75 | |
76 |
|
77 |
|
78 |
|
79 |
|
80 |
|
81 | includeSeparators?: boolean;
|
82 | |
83 |
|
84 |
|
85 | rank?: number;
|
86 | }
|
87 | }
|
88 |
|
89 |
|
90 |
|
91 | export declare class RankedMenu extends Menu implements IRankedMenu {
|
92 | |
93 |
|
94 |
|
95 |
|
96 |
|
97 | constructor(options: IRankedMenu.IOptions);
|
98 | /**
|
99 | * The underlying Lumino menu.
|
100 | *
|
101 | * @deprecated since v3.1
|
102 | * RankMenu inherits from Menu since v3.1
|
103 | */
|
104 | get menu(): Menu;
|
105 | /**
|
106 | * Menu rank.
|
107 | */
|
108 | get rank(): number | undefined;
|
109 | /**
|
110 | * Add a group of menu items specific to a particular
|
111 | * plugin.
|
112 | *
|
113 | * The rank can be set for all items in the group using the
|
114 | * function argument or per item.
|
115 | *
|
116 | * @param items - the list of menu items to add.
|
117 | * @param rank - the default rank in the menu in which to insert the group.
|
118 | * @returns Disposable of the group
|
119 | */
|
120 | addGroup(items: IRankedMenu.IItemOptions[], rank?: number): IDisposable;
|
121 | /**
|
122 | * Add a menu item to the end of the menu.
|
123 | *
|
124 | * @param options - The options for creating the menu item.
|
125 | *
|
126 | * @returns The menu item added to the menu.
|
127 | */
|
128 | addItem(options: IRankedMenu.IItemOptions): IDisposableMenuItem;
|
129 | /**
|
130 | * Remove all menu items from the menu.
|
131 | */
|
132 | clearItems(): void;
|
133 | /**
|
134 | * Dispose of the resources held by the menu.
|
135 | */
|
136 | dispose(): void;
|
137 | /**
|
138 | * Get the rank of the item at index.
|
139 | *
|
140 | * @param index Item index.
|
141 | * @returns Rank of the item.
|
142 | */
|
143 | getRankAt(index: number): number;
|
144 | /**
|
145 | * Insert a menu item into the menu at the specified index.
|
146 | *
|
147 | * @param index - The index at which to insert the item.
|
148 | *
|
149 | * @param options - The options for creating the menu item.
|
150 | *
|
151 | * @returns The menu item added to the menu.
|
152 | *
|
153 | * #### Notes
|
154 | * The index will be clamped to the bounds of the items.
|
155 | */
|
156 | insertItem(index: number, options: IRankedMenu.IItemOptions): IDisposableMenuItem;
|
157 | /**
|
158 | * Remove the item at a given index from the menu.
|
159 | *
|
160 | * @param index - The index of the item to remove.
|
161 | *
|
162 | * #### Notes
|
163 | * This is a no-op if the index is out of range.
|
164 | */
|
165 | removeItemAt(index: number): void;
|
166 | private _includeSeparators;
|
167 | private _rank;
|
168 | private _ranks;
|
169 | }
|