blob: a5976750dee682b20348ee91ea2ea71784e86033 [file] [log] [blame]
Deepanjan Roy9d95a252018-08-09 10:10:19 -04001// Copyright (C) 2018 The Android Open Source Project
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
Deepanjan Royabd79aa2018-08-28 07:29:15 -040015let nextPanelId = 0;
16
17export abstract class Panel {
18 // Each panel has a unique string id. This is suitable for use as a mithril
19 // component key.
20 readonly id: string;
21
22 constructor() {
23 this.id = 'panel-id-' + (nextPanelId++).toString();
24 }
25
26 abstract renderCanvas(ctx: CanvasRenderingContext2D): void;
27 abstract updateDom(dom: HTMLElement): void;
28
29 // TODO: If a panel changes its height, we need to call m.redraw. Instead of
30 // getHeight, we can have an setHeight method in the abstract class that does
31 // that redraw call.
32 abstract getHeight(): number;
Deepanjan Roy9d95a252018-08-09 10:10:19 -040033}