Page MenuHome

Possible solution for workspace mode
AbandonedPublic

Authored by Julian Eisel (Severin) on Dec 15 2017, 4:40 PM.

Details

Summary

Basically implements the proposal outlined in this comment.

NOTE: This implementation keeps the mode stored in the object, the workspace takes care for setting it though. Even if we decide to move the mode out of the object, most code here would still be valid. This is just a much more feasible approach that may suit our needs already.
  • The basic rule for setting the workspace mode is: The last active mode that is not object-mode (OB_MODE_OBJECT) becomes the workspace mode. (Therefore the workspace mode must never be OB_MODE_OBJECT.)
  • By default, a new workspace uses edit-mode as workspace mode.
  • When opening old files, the mode of the active object is set for the workspace (or its restore mode if in OB_MODE_OBJECT)
  • Object.restore_mode is deprecated now.

Now, some parts of the design I'm not sure yet. Mainly:

  • The implementation makes the workspace remember if the workspace mode or OB_MODE_OBJECT is active. Pressing TAB toggles between them. However the workspace doesn't try to keep the workspace mode active while only using OB_MODE_OBJECT as fall-back or when the user explicitly sets it. This differes from what I wrote in mentioned comment. Maybe that's better maybe not.
  • If the workspace mode isn't compatible with the currently active object, pressing TAB does nothing. In theory this may make sense, in practice it might be quite annoying though.
  • [Technical] In current Blender, objects can have multiple modes set using bitwise operations. Could we get rid of that?

    Without having investigated this really, I don't understand why we do this. Would appreciate if somebody could explain it to me.

I'm not submitting that for code review really. Just for feedback on the general design approach and the discussion points mentioned above.

Diff Detail

Repository
rB Blender
Branch
temp-workspace_mode
Build Status
Buildable 1051
Build 1051: arc lint + arc unit

Event Timeline

Julian Eisel (Severin) edited the summary of this revision. (Show Details)Dec 15 2017, 4:46 PM
Julian Eisel (Severin) edited the summary of this revision. (Show Details)Dec 15 2017, 4:49 PM

For the records, things discussed via IRC:

Workspace mode when possible

I do think we want to keep the workspace mode active when possible (when changing active object). And this should work regardless of how we change the active object:

  • Select a new object in the outliner
  • Change the active view layer for the workspace
  • Change the active scene for a window

BKE_view_layer_base_select

I believe we should use a notifier for this. We may have two windows, with different workspaces but the same view layer.

obedit / viewlayer change

  • Related to workspace, though not necessarily to this patch
  • Changing view layer while in edit mode keeps the same object in edit mode, even if it's not the active object of the new view layer.

Bug

Add an armature, go to pose mode, tab to object mode, add a new armature, tab. It should go to pose mode yet it goes to edit mode.

Workspace mode when possible

I do think we want to keep the workspace mode active when possible (when changing active object). And this should work regardless of how we change the active object:

  • Select a new object in the outliner
  • Change the active view layer for the workspace
  • Change the active scene for a window

I will add this as separate patch so we can test which behavior works best.

BKE_view_layer_base_select

I believe we should use a notifier for this. We may have two windows, with different workspaces but the same view layer.

For now I added Main * as argument there to ensure all workspaces are updated immediately (rBcfd591e95d7c).

While I agree using notifiers would make sense, I'm unsure if we should do this really:

  • Code that accesses workspace mode data after BKE_view_layer_base_select was called, but before notifiers were handled will fail. It'll need to enforce updating (which might be fine but it's still error prone).
  • The notifiers are currently set really loosely since they mostly matter for redraw. We had to ensure NC_SCENE | ND_OB_ACTIVE notifiers are always added when the active object changes. If we miss a case, the error is really hard to catch.
  • Notifiers will probably be replaced by the new message system. Not sure how that would work in this case though, @Campbell Barton (campbellbarton)?

obedit / viewlayer change

  • Related to workspace, though not necessarily to this patch
  • Changing view layer while in edit mode keeps the same object in edit mode, even if it's not the active object of the new view layer.

We need to find the best way to handle Scene.obedit with the new design. But like you said, not really related to this patch (the error appears in blender2.8 too.

Bug

Add an armature, go to pose mode, tab to object mode, add a new armature, tab. It should go to pose mode yet it goes to edit mode.

Fixed with rB6c7ca77c8f34 (we internally toggle to edit mode for a moment when adding objects, this changes workspace mode too).

  • Fix workspace mode changes to edit-mode when adding objects
  • Fix possible issues when changing active object

Closing since workspaces now store the object mode. rB345c6298e995ea618c34282ba6d7ab5af032f191