SonyWWS / ATF

Authoring Tools Framework (ATF) is a set of C#/.NET components for making tools on Windows. ATF has been in continuous development in Sony Computer Entertainment's (SCE) Worldwide Studios central tools group since early 2005. ATF has been used by most SCE first party studios to make many custom tools such as Naughty Dog’s level editor and shader editor for The Last of Us, Guerrilla Games’ sequence editor for Killzone games (including the Killzone: Shadow Fall PS4 launch title), an animation blending tool at Santa Monica Studio, a level editor at Bend Studio, a visual state machine editor for Quantic Dream, sound editing tools, and many others.
Apache License 2.0
1.89k stars 262 forks source link

isReadOnly parameter cannot by dynamic with defined editor #69

Open nrvllrgrs opened 7 years ago

nrvllrgrs commented 7 years ago

I added a toolbar option that allows the player to toggle read-only functionality. That is to say, while in Read-Only mode, the user cannot edit the property grid, trees, lists, etc. But while not in Read-Only mode, the user can has access to the aforementioned functionality.

That said, if AttributePropertyDescriptor uses a custom editor then it remains in the default Read-Only state. I extended CustomTypeDescriptorNodeAdapter where the properties are not cacheable, but the problem remains. Any suggestions how to resolve this issue?

abeckus commented 7 years ago

A simpler approach is to create a DomNodeAdapter and register it at root node. Then have the DomNodeAdapter to monitor all changes and when the Read-only mode is on reject the changes by throwing InvalidTransactionException(). For reference take a look at public class CurveLimitValidator : DomNodeAdapter in DomTreeEditor sample. Also take a look at DomValidators.

Alan

nrvllrgrs commented 7 years ago

That may work but that seems contrary to ATF's behavior. That's the equivalent of the Cut, Copy, Paste, Delete buttons always enabled and then a dialog appears if you try to before an invalid action. If the action is invalid, then those buttons are disabled.

JimHume commented 6 years ago

Another option is to implement ICommandClient and IInitializable in your editor or form. This will ensure that CanDoCommand(object commandTag) , DoCommand(object commandTag), and UpdateCommand(object commandTag) will be called when the user interface is rendered.

By adding custom logic in those methods, the return value can be set to true or false for any command based on the current state of your IDocument or application.