-
Notifications
You must be signed in to change notification settings - Fork 202
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
EMSUSD-717: USD Prefs: "Use Display Color" preferences are maintained when user cancels change #3553
EMSUSD-717: USD Prefs: "Use Display Color" preferences are maintained when user cancels change #3553
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -94,6 +94,10 @@ global proc mayaUsd_PrefUntexturedModeChanged() | |
if (`radioButtonGrp -exists usdPrefUntexturedMode`) { | ||
int $sel = `radioButtonGrp -q -select usdPrefUntexturedMode`; | ||
optionVar -iv mayaUsd_ShowDisplayColorTextureOff ($sel == 2); | ||
|
||
// Set a temporary optionVar saying that we have changed the untextured mode | ||
// so in case user cancels, we can do reset again. | ||
optionVar -transient -iv mayaUsd_PrefUntexturedModeChanged 1; | ||
ogs -reset; | ||
} | ||
} | ||
|
@@ -104,6 +108,13 @@ global proc mayaUsd_PrefInitOptionVars(int $forceFactoryDefault) | |
string $saveLayerFormatArgBinaryOptionPref = `python("import mayaUsd.lib as mlib; mlib.OptionVarTokens.SaveLayerFormatArgBinaryOption")`; | ||
string $confirmExistingFileSaveOptionPref = `python("import mayaUsd.lib as mlib; mlib.OptionVarTokens.ConfirmExistingFileSave")`; | ||
|
||
// Special case for the resetting the untextured mode. | ||
if ($forceFactoryDefault && `optionVar -exists "mayaUsd_ShowDisplayColorTextureOff"`) { | ||
if (`optionVar -q "mayaUsd_ShowDisplayColorTextureOff"`) { | ||
optionVar -transient -iv mayaUsd_PrefUntexturedModeChanged 1; | ||
} | ||
} | ||
|
||
int $mjv = `about -majorVersion`; | ||
if ($mjv <= 2022) { | ||
if ($forceFactoryDefault || !`optionVar -exists mayaUsd_SerializedUsdEditsLocation`) { | ||
|
@@ -155,8 +166,13 @@ global proc mayaUsd_PrefInitOptionVars(int $forceFactoryDefault) | |
-iv mayaUsd_ShowDisplayColorTextureOff false | ||
; | ||
} | ||
// Need to refresh the viewport for display mayaUsd_ShowDisplayColorTextureOff | ||
ogs -reset; | ||
|
||
if ($forceFactoryDefault && `optionVar -q mayaUsd_PrefUntexturedModeChanged`) | ||
{ | ||
// Need to refresh the viewport for display mayaUsd_ShowDisplayColorTextureOff | ||
optionVar -remove mayaUsd_PrefUntexturedModeChanged; | ||
ogs -reset; | ||
} | ||
} | ||
|
||
global proc mayaUsd_PrefCreateTab() | ||
|
@@ -392,10 +408,22 @@ global proc mayaUsd_PrefHoldState(string $mode) | |
}; | ||
prefsHoldOptionVars($prefOptionVars, $mode); | ||
|
||
if ($mode == "remove") { | ||
// Finalize preference changes into MayaUsd. | ||
if ($mode == "save") { | ||
// Preferences dialog was opened, make sure we don't have this transient optionVar. | ||
optionVar -remove mayaUsd_PrefUntexturedModeChanged; | ||
} | ||
|
||
if ($mode == "restore") { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Indentation seems off here.. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry it is a mix of tabs/spaces. I'll fix it. |
||
if (`optionVar -q mayaUsd_PrefUntexturedModeChanged`) { | ||
// Need to refresh the viewport for display mayaUsd_ShowDisplayColorTextureOff | ||
ogs -reset; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we remove the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That is covered by the "restore" case just below. when you click cancel on the prefs dialog this function will be called twice (restore, then remove). When you click save from the prefs dialog it will be called with "remove". |
||
} | ||
} | ||
|
||
if ($mode == "remove") { | ||
optionVar -remove mayaUsd_PrefUntexturedModeChanged; | ||
} | ||
|
||
global string $gPreferenceWindow; | ||
if (`window -exists $gPreferenceWindow`) { | ||
setParent mayaUsd_PrefLayout; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
transient optionvars are not saved when exiting Maya. ogs -reset is not a cheap operation so we should not just call it unless needed (such as when opening the pref dialog we don't need to call it). Use this optionvar to keep track of when the untextured mode pref changes and only call ogs -reset when needed.