Skip to content

Commit

Permalink
[PDF] Change annotation opacity from the quick-access toolbar
Browse files Browse the repository at this point in the history
  • Loading branch information
JuliaRadzhabova committed Dec 20, 2024
1 parent d073555 commit f4a59df
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 3 deletions.
35 changes: 35 additions & 0 deletions apps/pdfeditor/main/app/controller/DocumentHolderExt.js
Original file line number Diff line number Diff line change
Expand Up @@ -869,6 +869,8 @@ define([], function () {
documentHolder.btnAddAnnotComment.on('click', _.bind(this.addComment, this, {isFromSelBar: true}));
documentHolder.mnuStrokeHighlightColorPicker.on('select', _.bind(this.onSelectStrokeColor, this, documentHolder.btnStrokeHighlightColor));
documentHolder.mnuStrokeColorPicker.on('select', _.bind(this.onSelectStrokeColor, this, documentHolder.btnStrokeColor));
documentHolder.btnStrokeColor.menu.on('show:after', _.bind(this.onStrokeShowAfter, this));
documentHolder.btnStrokeHighlightColor.menu.on('show:after', _.bind(this.onStrokeShowAfter, this));
this.api.UpdateInterfaceState();
}

Expand Down Expand Up @@ -2492,6 +2494,39 @@ define([], function () {
this.api.asc_SetStrokeColor(parseInt(r, 16), parseInt(g, 16), parseInt(b, 16));
};

dh.onSetStrokeOpacity = function(sizePicker, direction) {
var val = this.api.asc_GetOpacity();
if (direction === 'up') {
if (val % 10 > 0.1) {
val = Math.ceil(val / 10) * 10;
} else {
val += 10;
}
val = Math.min(100, val);
} else {
if (val % 10 > 0.1) {
val = Math.floor(val / 10) * 10;
} else {
val -= 10
}
val = Math.max(0, val);
}
sizePicker.setValue(val + '%');
this.api.asc_SetOpacity(val);
};

dh.onStrokeShowAfter = function(menu) {
if (!menu.sizePicker) {
menu.sizePicker = new Common.UI.UpDownPicker({
el: menu.cmpEl.find('.custom-scale'),
caption: this.documentHolder.txtOpacity,
minWidth: 40
});
menu.sizePicker.on('click', _.bind(this.onSetStrokeOpacity, this, menu.sizePicker));
}
menu.sizePicker.setValue(this.api.asc_GetOpacity() + '%');
};

dh.applySettings = function() {
!Common.Utils.InternalSettings.get('pdfe-settings-annot-bar') && this.onHideAnnotBar();
};
Expand Down
12 changes: 12 additions & 0 deletions apps/pdfeditor/main/app/view/DocumentHolderExt.js
Original file line number Diff line number Diff line change
Expand Up @@ -1621,6 +1621,12 @@ define([], function () {
'249B01', 'C504D2', '0633D1', 'FFF7A0', 'FF0303', 'FFFFFF', 'D3D3D4', '969696', '606060', '000000'
],
color: 'FFFC54',
additionalItemsAfter: [
new Common.UI.MenuItem({
template: _.template('<div class="custom-scale" data-stopPropagation="true"></div>'),
stopPropagation: true
})
],
dynamiccolors: config.dynamiccolors,
themecolors: config.themecolors,
effects: config.effects,
Expand All @@ -1643,6 +1649,12 @@ define([], function () {
colorLine: 'box',
colors: config.colors,
color: '3D8A44',
additionalItemsAfter: [
new Common.UI.MenuItem({
template: _.template('<div class="custom-scale" data-stopPropagation="true"></div>'),
stopPropagation: true
})
],
dynamiccolors: config.dynamiccolors,
themecolors: config.themecolors,
effects: config.effects,
Expand Down
6 changes: 3 additions & 3 deletions apps/pdfeditor/main/app/view/Toolbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -1439,10 +1439,10 @@ define([
button.currentColor = button.color;
if (opacity) {
var onShowAfter = function(menu) {
if (button.sizePicker) {
button.sizePicker.setValue(Common.Utils.InternalSettings.get("pdfe-annot-opacity-" + id) + '%');
if (menu.sizePicker) {
menu.sizePicker.setValue(Common.Utils.InternalSettings.get("pdfe-annot-opacity-" + id) + '%');
} else {
button.sizePicker = me.createOpacityPicker(id, menu.cmpEl.find('.custom-scale'));
menu.sizePicker = me.createOpacityPicker(id, menu.cmpEl.find('.custom-scale'));
}
};
button.menu.on('show:after', onShowAfter);
Expand Down
1 change: 1 addition & 0 deletions apps/pdfeditor/main/locale/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -1242,6 +1242,7 @@
"PDFE.Views.DocumentHolder.txtWarnUrl": "Clicking this link can be harmful to your device and data.<br>Are you sure you want to continue?",
"PDFE.Views.DocumentHolder.unicodeText": "Unicode",
"PDFE.Views.DocumentHolder.vertAlignText": "Vertical alignment",
"PDFE.Views.DocumentHolder.txtOpacity": "Opacity",
"PDFE.Views.FileMenu.ariaFileMenu": "File menu",
"PDFE.Views.FileMenu.btnBackCaption": "Open File Location",
"PDFE.Views.FileMenu.btnCloseEditor": "Close File",
Expand Down

0 comments on commit f4a59df

Please sign in to comment.