Skip to content

Commit

Permalink
[PDF] Set opacity for annotation
Browse files Browse the repository at this point in the history
  • Loading branch information
JuliaRadzhabova committed Dec 20, 2024
1 parent 8c5ac01 commit d073555
Show file tree
Hide file tree
Showing 6 changed files with 156 additions and 86 deletions.
1 change: 1 addition & 0 deletions apps/common/main/lib/component/ColorButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ define([
(this.options.effects!==undefined) && (config['effects'] = this.options.effects);
(this.options.colorHints!==undefined) && (config['colorHints'] = this.options.colorHints);
(this.options.paletteCls!==undefined) && (config['cls'] = this.options.paletteCls);
(this.options.storageSuffix!==undefined) && (config['storageSuffix'] = this.options.storageSuffix);

this.colorPicker = new Common.UI.ThemeColorPalette(config);
this.colorPicker.on('select', _.bind(this.onColorSelect, this));
Expand Down
6 changes: 6 additions & 0 deletions apps/common/main/lib/util/LocalStorage.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,11 @@ define(['gateway'], function () {
return (value!==null) ? (parseInt(value) != 0) : defValue;
};

var _getItemAsInt = function (name, defValue) {
var value = _getItem(name);
return (value!==null) ? parseInt(value) : defValue || 0;
};

var _getItemExists = function (name) {
var value = _getItem(name);
return value !== null;
Expand All @@ -125,6 +130,7 @@ define(['gateway'], function () {
_storeName = name;
},
getItem: _getItem,
getItemAsInt: _getItemAsInt,
getBool: _getItemAsBool,
setBool: _setItemAsBool,
setItem: _setItem,
Expand Down
30 changes: 17 additions & 13 deletions apps/pdfeditor/main/app/controller/Toolbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -258,23 +258,27 @@ define([

},

onCreateAnnotBar: function(btnStrikeout, mnuStrikeoutColorPicker, btnUnderline, mnuUnderlineColorPicker, btnHighlight, mnuHighlightColorPicker) {
onCreateAnnotBar: function(btnStrikeout, btnUnderline, btnHighlight) {
var toolbar = this.toolbar;
btnStrikeout.currentColor = toolbar.btnStrikeout.currentColor;
btnStrikeout.setColor(btnStrikeout.currentColor);
btnStrikeout.toggle(toolbar.btnStrikeout.pressed, true);

toolbar.btnsStrikeout.push(btnStrikeout);
btnStrikeout.toggle(toolbar.btnStrikeout.pressed, true);
btnStrikeout.setColor(toolbar.btnStrikeout.currentColor);
var mnuStrikeoutColorPicker = toolbar.createPen(btnStrikeout, 'strikeout', true);
toolbar.mnusStrikeoutColorPicker.push(mnuStrikeoutColorPicker);
btnUnderline.currentColor = toolbar.btnUnderline.currentColor;
btnUnderline.setColor(btnUnderline.currentColor);
btnUnderline.toggle(toolbar.btnUnderline.pressed, true);

toolbar.btnsUnderline.push(btnUnderline);
btnUnderline.toggle(toolbar.btnUnderline.pressed, true);
btnUnderline.setColor(toolbar.btnUnderline.currentColor);
var mnuUnderlineColorPicker = toolbar.createPen(btnUnderline, 'underline', true);
toolbar.mnusUnderlineColorPicker.push(mnuUnderlineColorPicker);
btnHighlight.currentColor = toolbar.btnHighlight.currentColor;
btnHighlight.setColor(btnHighlight.currentColor);
btnHighlight.toggle(toolbar.btnHighlight.pressed, true);

toolbar.btnsHighlight.push(btnHighlight);
btnHighlight.toggle(toolbar.btnHighlight.pressed, true);
btnHighlight.setColor(toolbar.btnHighlight.currentColor);
var mnuHighlightColorPicker = toolbar.createPen(btnHighlight, 'highlight', true);
toolbar.mnusHighlightColorPicker.push(mnuHighlightColorPicker);

btnStrikeout.on('click', _.bind(this.onBtnStrikeout, this));
mnuStrikeoutColorPicker.on('select', _.bind(this.onSelectStrikeoutColor, this));
btnUnderline.on('click', _.bind(this.onBtnUnderline, this));
Expand Down Expand Up @@ -937,7 +941,7 @@ define([
var r = strcolor[0] + strcolor[1],
g = strcolor[2] + strcolor[3],
b = strcolor[4] + strcolor[5];
me.api.SetMarkerFormat(me.toolbar.btnStrikeout.options.type, true, 100, parseInt(r, 16), parseInt(g, 16), parseInt(b, 16));
me.api.SetMarkerFormat(me.toolbar.btnStrikeout.options.type, true, Common.Utils.InternalSettings.get("pdfe-annot-opacity-strikeout") , parseInt(r, 16), parseInt(g, 16), parseInt(b, 16));
// me.toolbar.mnuStrikeoutTransparent.setChecked(false, true);
}
Common.NotificationCenter.trigger('edit:complete', me.toolbar, me.toolbar.btnStrikeout);
Expand Down Expand Up @@ -997,7 +1001,7 @@ define([
var r = strcolor[0] + strcolor[1],
g = strcolor[2] + strcolor[3],
b = strcolor[4] + strcolor[5];
me.api.SetMarkerFormat(me.toolbar.btnUnderline.options.type, true, 100, parseInt(r, 16), parseInt(g, 16), parseInt(b, 16));
me.api.SetMarkerFormat(me.toolbar.btnUnderline.options.type, true, Common.Utils.InternalSettings.get("pdfe-annot-opacity-underline"), parseInt(r, 16), parseInt(g, 16), parseInt(b, 16));
// me.toolbar.mnuUnderlineTransparent.setChecked(false, true);
}
Common.NotificationCenter.trigger('edit:complete', me.toolbar, me.toolbar.btnUnderline);
Expand Down Expand Up @@ -1057,7 +1061,7 @@ define([
var r = strcolor[0] + strcolor[1],
g = strcolor[2] + strcolor[3],
b = strcolor[4] + strcolor[5];
me.api.SetMarkerFormat(me.toolbar.btnHighlight.options.type, true, 100, parseInt(r, 16), parseInt(g, 16), parseInt(b, 16));
me.api.SetMarkerFormat(me.toolbar.btnHighlight.options.type, true, Common.Utils.InternalSettings.get("pdfe-annot-opacity-highlight"), parseInt(r, 16), parseInt(g, 16), parseInt(b, 16));
// me.toolbar.mnuHighlightTransparent.setChecked(false, true);
}
Common.NotificationCenter.trigger('edit:complete', me.toolbar, me.toolbar.btnHighlight);
Expand Down
29 changes: 19 additions & 10 deletions apps/pdfeditor/main/app/view/DocumentHolderExt.js
Original file line number Diff line number Diff line change
Expand Up @@ -1491,6 +1491,12 @@ define([], function () {
colorLine: false,
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 All @@ -1502,9 +1508,6 @@ define([], function () {
type: AscPDF.ANNOTATIONS_TYPES.Underline
});
annotBarBtns.push(this.btnUnderline);
this.btnUnderline.setMenu();
this.mnuUnderlineColorPicker = this.btnUnderline.getPicker();
this.btnUnderline.currentColor = this.btnUnderline.color;

this.btnStrikeout = new Common.UI.ButtonColored({
parentEl: $('#annot-bar-strikeout', container),
Expand All @@ -1517,6 +1520,12 @@ define([], function () {
colorLine: false,
colors: config.colors,
color: 'D43230',
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 @@ -1528,9 +1537,6 @@ define([], function () {
type: AscPDF.ANNOTATIONS_TYPES.Strikeout
});
annotBarBtns.push(this.btnStrikeout);
this.btnStrikeout.setMenu();
this.mnuStrikeoutColorPicker = this.btnStrikeout.getPicker();
this.btnStrikeout.currentColor = this.btnStrikeout.color;

this.btnHighlight = new Common.UI.ButtonColored({
parentEl: $('#annot-bar-highlight', container),
Expand All @@ -1540,6 +1546,12 @@ define([], function () {
allowDepress: true,
split: true,
menu: true,
additionalItemsAfter: [
new Common.UI.MenuItem({
template: _.template('<div class="custom-scale" data-stopPropagation="true"></div>'),
stopPropagation: true
})
],
colors: [
'FFFC54', '72F54A', '74F9FD', 'EB51F7', 'A900F9', 'EF8B3A', '7272FF', 'FF63A4', '1DFF92', '03DA18',
'249B01', 'C504D2', '0633D1', 'FFF7A0', 'FF0303', 'FFFFFF', 'D3D3D4', '969696', '606060', '000000'
Expand All @@ -1556,9 +1568,6 @@ define([], function () {
type: AscPDF.ANNOTATIONS_TYPES.Highlight
});
annotBarBtns.push(this.btnHighlight);
this.btnHighlight.setMenu();
this.mnuHighlightColorPicker = this.btnHighlight.getPicker();
this.btnHighlight.currentColor = this.btnHighlight.color;

this.btnEditText = new Common.UI.Button({
parentEl: $('#annot-bar-edit-text', container),
Expand All @@ -1568,7 +1577,7 @@ define([], function () {
hint: this.tipRecognize
});
annotBarBtns.push(this.btnEditText);
this.fireEvent('annotbar:create', [this.btnStrikeout, this.mnuStrikeoutColorPicker, this.btnUnderline, this.mnuUnderlineColorPicker, this.btnHighlight, this.mnuHighlightColorPicker]);
this.fireEvent('annotbar:create', [this.btnStrikeout, this.btnUnderline, this.btnHighlight]);

return container;
};
Expand Down
Loading

0 comments on commit d073555

Please sign in to comment.