55
66import * as vscode from 'vscode' ;
77import * as nls from 'vscode-nls' ;
8- import { Disposable } from './dispose ' ;
8+ import { PreviewStatusBarEntry } from './statusBarEntry ' ;
99
1010const localize = nls . loadMessageBundle ( ) ;
1111
1212const selectZoomLevelCommandId = '_imagePreview.selectZoomLevel' ;
1313
1414export type Scale = number | 'fit' ;
1515
16- export class ZoomStatusBarEntry extends Disposable {
17- private readonly _entry : vscode . StatusBarItem ;
16+ export class ZoomStatusBarEntry extends PreviewStatusBarEntry {
1817
1918 private readonly _onDidChangeScale = this . _register ( new vscode . EventEmitter < { scale : Scale } > ( ) ) ;
2019 public readonly onDidChangeScale = this . _onDidChangeScale . event ;
2120
22- private _showOwner : string | undefined ;
23-
2421 constructor ( ) {
25- super ( ) ;
26- this . _entry = this . _register ( vscode . window . createStatusBarItem ( {
22+ super ( {
2723 id : 'imagePreview.zoom' ,
2824 name : localize ( 'zoomStatusBar.name' , "Image Zoom" ) ,
2925 alignment : vscode . StatusBarAlignment . Right ,
3026 priority : 102 /* to the left of editor size entry (101) */ ,
31- } ) ) ;
27+ } ) ;
3228
3329 this . _register ( vscode . commands . registerCommand ( selectZoomLevelCommandId , async ( ) => {
3430 type MyPickItem = vscode . QuickPickItem & { scale : Scale } ;
@@ -47,20 +43,11 @@ export class ZoomStatusBarEntry extends Disposable {
4743 }
4844 } ) ) ;
4945
50- this . _entry . command = selectZoomLevelCommandId ;
46+ this . entry . command = selectZoomLevelCommandId ;
5147 }
5248
5349 public show ( owner : string , scale : Scale ) {
54- this . _showOwner = owner ;
55- this . _entry . text = this . zoomLabel ( scale ) ;
56- this . _entry . show ( ) ;
57- }
58-
59- public hide ( owner : string ) {
60- if ( owner === this . _showOwner ) {
61- this . _entry . hide ( ) ;
62- this . _showOwner = undefined ;
63- }
50+ this . showItem ( owner , this . zoomLabel ( scale ) ) ;
6451 }
6552
6653 private zoomLabel ( scale : Scale ) : string {
0 commit comments