From f3cf69c0a1e4529ebfaa2cb0c877019362ef691e Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Tue, 22 Nov 2022 20:21:49 +0300 Subject: [PATCH] [PE] Lock guide/gridline settings --- .../main/app/controller/DocumentHolder.js | 6 +++++ .../main/app/controller/ViewTab.js | 23 +++++++++++++++++-- .../main/app/view/DocumentHolder.js | 9 +++++++- 3 files changed, 35 insertions(+), 3 deletions(-) diff --git a/apps/presentationeditor/main/app/controller/DocumentHolder.js b/apps/presentationeditor/main/app/controller/DocumentHolder.js index 9344c8a9d..2f57edf80 100644 --- a/apps/presentationeditor/main/app/controller/DocumentHolder.js +++ b/apps/presentationeditor/main/app/controller/DocumentHolder.js @@ -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); diff --git a/apps/presentationeditor/main/app/controller/ViewTab.js b/apps/presentationeditor/main/app/controller/ViewTab.js index 459e603f8..57cb07fd2 100644 --- a/apps/presentationeditor/main/app/controller/ViewTab.js +++ b/apps/presentationeditor/main/app/controller/ViewTab.js @@ -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(); } }, diff --git a/apps/presentationeditor/main/app/view/DocumentHolder.js b/apps/presentationeditor/main/app/view/DocumentHolder.js index 2e2ddc638..c498a4d0f 100644 --- a/apps/presentationeditor/main/app/view/DocumentHolder.js +++ b/apps/presentationeditor/main/app/view/DocumentHolder.js @@ -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")); }