File tree 4 files changed +32
-3
lines changed
4 files changed +32
-3
lines changed Original file line number Diff line number Diff line change @@ -402,7 +402,7 @@ const PDFViewerApplication = {
402
402
} else {
403
403
eventBus = new EventBus ( ) ;
404
404
}
405
- this . eventBus = eventBus ;
405
+ this . eventBus = this . preferences . eventBus = eventBus ;
406
406
407
407
this . overlayManager = new OverlayManager ( ) ;
408
408
@@ -569,7 +569,11 @@ const PDFViewerApplication = {
569
569
await this . _nimbusDataPromise
570
570
) ;
571
571
} else {
572
- this . toolbar = new Toolbar ( appConfig . toolbar , eventBus ) ;
572
+ this . toolbar = new Toolbar (
573
+ appConfig . toolbar ,
574
+ eventBus ,
575
+ AppOptions . get ( "toolbarDensity" )
576
+ ) ;
573
577
}
574
578
}
575
579
Original file line number Diff line number Diff line change @@ -95,6 +95,12 @@ const defaultOptions = {
95
95
value : true ,
96
96
kind : OptionKind . BROWSER ,
97
97
} ,
98
+ toolbarDensity : {
99
+ /** @type {number } */
100
+ // 0 = "normal", 1 = "compact", 2 = "touch"
101
+ value : 0 ,
102
+ kind : OptionKind . BROWSER ,
103
+ } ,
98
104
99
105
annotationEditorMode : {
100
106
/** @type {number } */
Original file line number Diff line number Diff line change @@ -37,6 +37,8 @@ class BasePreferences {
37
37
38
38
#initializedPromise = null ;
39
39
40
+ static #eventToDispatch = new Set ( [ "toolbarDensity" ] ) ;
41
+
40
42
constructor ( ) {
41
43
if ( this . constructor === BasePreferences ) {
42
44
throw new Error ( "Cannot initialize BasePreferences." ) ;
@@ -73,6 +75,10 @@ class BasePreferences {
73
75
}
74
76
}
75
77
) ;
78
+
79
+ if ( typeof PDFJSDev !== "undefined" && PDFJSDev . test ( "MOZCENTRAL" ) ) {
80
+ this . eventBus = null ;
81
+ }
76
82
}
77
83
78
84
/**
@@ -113,6 +119,9 @@ class BasePreferences {
113
119
return ; // Invalid preference.
114
120
}
115
121
AppOptions . set ( name , value ) ;
122
+ if ( this . eventBus && BasePreferences . #eventToDispatch. has ( name ) ) {
123
+ this . eventBus . dispatch ( name . toLowerCase ( ) , { source : this , value } ) ;
124
+ }
116
125
}
117
126
118
127
/**
Original file line number Diff line number Diff line change @@ -50,8 +50,13 @@ class Toolbar {
50
50
/**
51
51
* @param {ToolbarOptions } options
52
52
* @param {EventBus } eventBus
53
+ * @param {number } toolbarDensity - The toolbar density value.
54
+ * The possible values are:
55
+ * - 0 (default) - The regular toolbar size.
56
+ * - 1 (compact) - The small toolbar size.
57
+ * - 2 (touch) - The large toolbar size.
53
58
*/
54
- constructor ( options , eventBus ) {
59
+ constructor ( options , eventBus , toolbarDensity = 0 ) {
55
60
this . #opts = options ;
56
61
this . eventBus = eventBus ;
57
62
const buttons = [
@@ -136,9 +141,14 @@ class Toolbar {
136
141
}
137
142
} ) ;
138
143
144
+ eventBus . _on ( "toolbardensity" , this . #updateToolbarDensity. bind ( this ) ) ;
145
+ this . #updateToolbarDensity( { value : toolbarDensity } ) ;
146
+
139
147
this . reset ( ) ;
140
148
}
141
149
150
+ #updateToolbarDensity( ) { }
151
+
142
152
#setAnnotationEditorUIManager( uiManager , parentContainer ) {
143
153
const colorPicker = new ColorPicker ( { uiManager } ) ;
144
154
uiManager . setMainHighlightColorPicker ( colorPicker ) ;
You can’t perform that action at this time.
0 commit comments