[PE] Lock guide/gridline settings

This commit is contained in:
Julia Radzhabova 2022-11-22 20:21:49 +03:00
parent 453a353eba
commit f3cf69c0a1
3 changed files with 35 additions and 3 deletions

View file

@ -223,6 +223,8 @@ define([
me.api.asc_registerCallback('asc_onTrackGuide', _.bind(me.onTrackGuide, me));
me.api.asc_registerCallback('asc_onShowMathTrack', _.bind(me.onShowMathTrack, me));
me.api.asc_registerCallback('asc_onHideMathTrack', _.bind(me.onHideMathTrack, me));
me.api.asc_registerCallback('asc_onLockViewProps', _.bind(me.onLockViewProps, me, true));
me.api.asc_registerCallback('asc_onUnLockViewProps', _.bind(me.onLockViewProps, me, false));
}
me.api.asc_registerCallback('asc_onCoAuthoringDisconnect', _.bind(me.onCoAuthoringDisconnect, me));
Common.NotificationCenter.on('api:disconnect', _.bind(me.onCoAuthoringDisconnect, me));
@ -2396,6 +2398,10 @@ define([
}
},
onLockViewProps: function(lock) {
this.documentHolder && (this.documentHolder._state.viewPropsLock = lock);
},
SetDisabled: function(state) {
this._isDisabled = state;
this.documentHolder.SetDisabled(state);

View file

@ -61,7 +61,8 @@ define([
this._state = {
zoom_type: undefined,
zoom_percent: undefined,
unitsChanged: true
unitsChanged: true,
lock_viewProps: false
};
Common.NotificationCenter.on('uitheme:changed', this.onThemeChanged.bind(this));
Common.NotificationCenter.on('document:ready', _.bind(this.onDocumentReady, this));
@ -75,6 +76,8 @@ define([
this.api.asc_registerCallback('asc_onNotesShow', _.bind(this.onNotesShow, this));
this.api.asc_registerCallback('asc_onCoAuthoringDisconnect', _.bind(this.onCoAuthoringDisconnect, this));
Common.NotificationCenter.on('api:disconnect', _.bind(this.onCoAuthoringDisconnect, this));
this.api.asc_registerCallback('asc_onLockViewProps', _.bind(this.onLockViewProps, this, true));
this.api.asc_registerCallback('asc_onUnLockViewProps', _.bind(this.onLockViewProps, this, false));
}
return this;
},
@ -254,7 +257,10 @@ define([
onGuidesAfterShow: function() {
if (this.view) {
this.view.btnGuides.menu.items[6].setDisabled(!this.api.asc_canClearGuides());
this.view.btnGuides.menu.items[2].setDisabled(this._state.lock_viewProps); // add v guides
this.view.btnGuides.menu.items[3].setDisabled(this._state.lock_viewProps); // add h guides
this.view.btnGuides.menu.items[6].setDisabled(this._state.lock_viewProps || !this.api.asc_canClearGuides()); // clear guides
this.view.btnGuides.menu.items[0].setChecked(this.api.asc_getShowGuides(), true);
this.view.btnGuides.menu.items[5].setChecked(this.api.asc_getShowSmartGuides(), true);
}
@ -350,7 +356,20 @@ define([
item.setChecked(true);
else
item.setChecked(false);
item.setDisabled(this._state.lock_viewProps);
}
menu.items[1].setDisabled(this._state.lock_viewProps); // snap to grid
menu.items[items.length-1].setDisabled(this._state.lock_viewProps); // custom
}
},
onLockViewProps: function(lock) {
this._state.lock_viewProps = lock;
if (this.view) {
if (this.view.btnGridlines && (typeof this.view.btnGridlines.menu === 'object') && this.view.btnGridlines.menu.isVisible())
this.onGridlinesAfterShow();
if (this.view.btnGuides && (typeof this.view.btnGuides.menu === 'object') && this.view.btnGuides.menu.isVisible())
this.onGuidesAfterShow();
}
},

View file

@ -1033,7 +1033,11 @@ define([
me.mnuGuides.menu.items[4].setVisible(!!value.guideId);
me.mnuGuides.menu.items[4].options.guideId = value.guideId;
me.mnuGuides.menu.items[6].setChecked(me.api.asc_getShowSmartGuides(), true);
me.mnuGuides.menu.items[7].setDisabled(!me.api.asc_canClearGuides());
me.mnuGuides.menu.items[2].setDisabled(me._state.viewPropsLock);
me.mnuGuides.menu.items[3].setDisabled(me._state.viewPropsLock);
me.mnuGuides.menu.items[4].setDisabled(me._state.viewPropsLock);
me.mnuGuides.menu.items[7].setDisabled(me._state.viewPropsLock || !me.api.asc_canClearGuides());
me.mnuGridlines.menu.items[0].setChecked(me.api.asc_getShowGridlines(), true);
me.mnuGridlines.menu.items[1].setChecked(me.api.asc_getSnapToGrid(), true);
@ -1066,7 +1070,10 @@ define([
item.setChecked(true);
else
item.setChecked(false);
item.setDisabled(me._state.viewPropsLock);
}
me.mnuGridlines.menu.items[1].setDisabled(me._state.viewPropsLock);
me.mnuGridlines.menu.items[items.length-1].setDisabled(me._state.viewPropsLock);
me.mnuRulers.setChecked(!Common.Utils.InternalSettings.get("pe-hidden-rulers"));
}