Jan Scheffler | 8ce0cbb | 2021-04-05 20:34:37 | [diff] [blame^] | 1 | // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | /* eslint-disable rulesdir/no_underscored_properties */ |
| 6 | |
| 7 | import {TabbedPane} from './TabbedPane.js'; // eslint-disable-line no-unused-vars |
| 8 | import {ToolbarItem, ToolbarMenuButton} from './Toolbar.js'; // eslint-disable-line no-unused-vars |
| 9 | import {ViewManager} from './ViewManager.js'; |
| 10 | import {VBox, Widget} from './Widget.js'; // eslint-disable-line no-unused-vars |
| 11 | export interface View { |
| 12 | viewId(): string; |
| 13 | |
| 14 | title(): string; |
| 15 | |
| 16 | isCloseable(): boolean; |
| 17 | |
| 18 | isTransient(): boolean; |
| 19 | |
| 20 | toolbarItems(): Promise<ToolbarItem[]>; |
| 21 | |
| 22 | widget(): Promise<Widget>; |
| 23 | |
| 24 | disposeView(): void|Promise<void>; |
| 25 | } |
| 26 | |
| 27 | export class SimpleView extends VBox implements View { |
| 28 | _title: string; |
| 29 | constructor(title: string, isWebComponent?: boolean) { |
| 30 | super(isWebComponent); |
| 31 | this._title = title; |
| 32 | } |
| 33 | |
| 34 | viewId(): string { |
| 35 | return this._title; |
| 36 | } |
| 37 | |
| 38 | title(): string { |
| 39 | return this._title; |
| 40 | } |
| 41 | |
| 42 | isCloseable(): boolean { |
| 43 | return false; |
| 44 | } |
| 45 | |
| 46 | isTransient(): boolean { |
| 47 | return false; |
| 48 | } |
| 49 | |
| 50 | toolbarItems(): Promise<ToolbarItem[]> { |
| 51 | return Promise.resolve([]); |
| 52 | } |
| 53 | |
| 54 | widget(): Promise<Widget> { |
| 55 | return (Promise.resolve(this) as Promise<Widget>); |
| 56 | } |
| 57 | |
| 58 | revealView(): Promise<void> { |
| 59 | return ViewManager.instance().revealView(this); |
| 60 | } |
| 61 | |
| 62 | disposeView(): void { |
| 63 | } |
| 64 | } |
| 65 | |
| 66 | export interface ViewLocation { |
| 67 | appendApplicableItems(locationName: string): void; |
| 68 | appendView(view: View, insertBefore?: View|null): void; |
| 69 | showView(view: View, insertBefore?: View|null, userGesture?: boolean): Promise<void>; |
| 70 | removeView(view: View): void; |
| 71 | widget(): Widget; |
| 72 | } |
| 73 | |
| 74 | export interface TabbedViewLocation extends ViewLocation { |
| 75 | tabbedPane(): TabbedPane; |
| 76 | enableMoreTabsButton(): ToolbarMenuButton; |
| 77 | } |
| 78 | |
| 79 | export interface ViewLocationResolver { |
| 80 | resolveLocation(location: string): ViewLocation|null; |
| 81 | } |