Commit: 2b5050a4cdfbb075d360fd39433acea07432c60b
Author: Campbell Barton
Date:   Wed Jun 20 20:05:19 2018 +0200
Branches: blender2.8
https://developer.blender.org/rB2b5050a4cdfbb075d360fd39433acea07432c60b

UI: expose Timeline as a space type

See: T54744

===================================================================

M       release/scripts/startup/bl_ui/space_dopesheet.py
M       source/blender/editors/space_action/space_action.c
M       source/blender/makesdna/DNA_action_types.h
M       source/blender/makesrna/RNA_enum_types.h
M       source/blender/makesrna/intern/rna_space.c

===================================================================

diff --git a/release/scripts/startup/bl_ui/space_dopesheet.py 
b/release/scripts/startup/bl_ui/space_dopesheet.py
index a238e81d868..defe05b412e 100644
--- a/release/scripts/startup/bl_ui/space_dopesheet.py
+++ b/release/scripts/startup/bl_ui/space_dopesheet.py
@@ -119,13 +119,11 @@ class DOPESHEET_HT_header(Header):
         row = layout.row(align=True)
         row.template_header()
 
-        # XXX: perhaps our mode menu can be retired eventually when we get 
editor submodes in the main menu?
-        layout.prop(st, "mode", text="")
-
         if st.mode == 'TIMELINE':
             TIME_MT_editor_menus.draw_collapsible(context, layout)
             TIME_HT_editor_buttons.draw_header(context, layout)
         else:
+            layout.prop(st, "ui_mode", text="")
             DOPESHEET_MT_editor_menus.draw_collapsible(context, layout)
             DOPESHEET_HT_editor_buttons.draw_header(context, layout)
 
diff --git a/source/blender/editors/space_action/space_action.c 
b/source/blender/editors/space_action/space_action.c
index 527e382ec1e..03ab60d554c 100644
--- a/source/blender/editors/space_action/space_action.c
+++ b/source/blender/editors/space_action/space_action.c
@@ -47,6 +47,8 @@
 #include "BKE_screen.h"
 
 #include "RNA_access.h"
+#include "RNA_define.h"
+#include "RNA_enum_types.h"
 
 #include "WM_api.h"
 #include "WM_types.h"
@@ -835,6 +837,37 @@ static void action_id_remap(ScrArea *UNUSED(sa), SpaceLink 
*slink, ID *old_id, I
 
 }
 
+/**
+ * \note Used for splitting out a subset of modes is more involved,
+ * The previous non-timeline mode is stored so switching back to the
+ * dope-sheet doesn't always reset the sub-mode.
+ */
+static int action_space_subtype_get(ScrArea *sa)
+{
+       SpaceAction *sact = sa->spacedata.first;
+       return sact->mode == SACTCONT_TIMELINE ? SACTCONT_TIMELINE : 
SACTCONT_DOPESHEET;
+}
+
+static void action_space_subtype_set(ScrArea *sa, int value)
+{
+       SpaceAction *sact = sa->spacedata.first;
+       if (value == SACTCONT_TIMELINE) {
+               if (sact->mode != SACTCONT_TIMELINE) {
+                       sact->mode_prev = sact->mode;
+               }
+               sact->mode = value;
+       }
+       else {
+               sact->mode = sact->mode_prev;
+       }
+}
+
+static void action_space_subtype_item_extend(
+        bContext *UNUSED(C), EnumPropertyItem **item, int *totitem)
+{
+       RNA_enum_items_add(item, totitem, rna_enum_space_action_mode_items);
+}
+
 /* only called once, from space/spacetypes.c */
 void ED_spacetype_action(void)
 {
@@ -853,6 +886,9 @@ void ED_spacetype_action(void)
        st->listener = action_listener;
        st->refresh = action_refresh;
        st->id_remap = action_id_remap;
+       st->space_subtype_item_extend = action_space_subtype_item_extend;
+       st->space_subtype_get = action_space_subtype_get;
+       st->space_subtype_set = action_space_subtype_set;
 
        /* regions: main window */
        art = MEM_callocN(sizeof(ARegionType), "spacetype action region");
diff --git a/source/blender/makesdna/DNA_action_types.h 
b/source/blender/makesdna/DNA_action_types.h
index dac96b6ce5a..b20765ae187 100644
--- a/source/blender/makesdna/DNA_action_types.h
+++ b/source/blender/makesdna/DNA_action_types.h
@@ -687,12 +687,16 @@ typedef struct SpaceAction {
        bAction     *action;        /* the currently active action */
        bDopeSheet ads;             /* the currently active context (when not 
showing action) */
 
-       char mode, autosnap;        /* mode: editing context; autosnap: 
automatic keyframe snapping mode   */
-       short flag;                 /* flag: bitmapped settings; */
        float timeslide;            /* for Time-Slide transform mode drawing - 
current frame? */
 
-       int cache_display;          /* (eTimeline_Cache_Flag) */
-       int pad;
+       short flag;
+       /* Editing context */
+       char mode;
+       /* Storage for sub-space types. */
+       char mode_prev;
+       char autosnap;              /* automatic keyframe snapping mode   */
+       char cache_display;         /* (eTimeline_Cache_Flag) */
+       char _pad1[6];
 } SpaceAction;
 
 /* SpaceAction flag */
diff --git a/source/blender/makesrna/RNA_enum_types.h 
b/source/blender/makesrna/RNA_enum_types.h
index cb82ab8a88f..b4edc0dc99d 100644
--- a/source/blender/makesrna/RNA_enum_types.h
+++ b/source/blender/makesrna/RNA_enum_types.h
@@ -58,6 +58,7 @@ extern const EnumPropertyItem 
rna_enum_mesh_delimit_mode_items[];
 extern const EnumPropertyItem rna_enum_space_graph_mode_items[];
 extern const EnumPropertyItem rna_enum_space_type_items[];
 extern const EnumPropertyItem rna_enum_space_image_mode_items[];
+extern const EnumPropertyItem rna_enum_space_action_mode_items[];
 extern const EnumPropertyItem rna_enum_region_type_items[];
 extern const EnumPropertyItem rna_enum_object_modifier_type_items[];
 extern const EnumPropertyItem rna_enum_constraint_type_items[];
diff --git a/source/blender/makesrna/intern/rna_space.c 
b/source/blender/makesrna/intern/rna_space.c
index 5b1800e808c..635560e88ce 100644
--- a/source/blender/makesrna/intern/rna_space.c
+++ b/source/blender/makesrna/intern/rna_space.c
@@ -79,8 +79,8 @@ const EnumPropertyItem rna_enum_space_type_items[] = {
        /* Animation */
        {0, "", ICON_NONE, "Animation", ""},
        //{SPACE_ACTION, "TIMELINE", ICON_TIME, "Timeline", "Timeline and 
playback controls (NOTE: Switch to 'Timeline' mode)"}, /* XXX */
-       {SPACE_IPO, "GRAPH_EDITOR", ICON_IPO, "Graph Editor", "Edit drivers and 
keyframe interpolation"},
        {SPACE_ACTION, "DOPESHEET_EDITOR", ICON_ACTION, "Dope Sheet", "Adjust 
timing of keyframes"},
+       {SPACE_IPO, "GRAPH_EDITOR", ICON_IPO, "Graph Editor", "Edit drivers and 
keyframe interpolation"},
        {SPACE_NLA, "NLA_EDITOR", ICON_NLA, "NLA Editor", "Combine and layer 
Actions"},
 
        /* Scripting */
@@ -113,6 +113,59 @@ const EnumPropertyItem rna_enum_space_graph_mode_items[] = 
{
        {0, NULL, 0, NULL, NULL}
 };
 
+#define SACT_ITEM_DOPESHEET \
+       {SACTCONT_DOPESHEET, "DOPESHEET", ICON_ACTION, "Dope Sheet", "Edit all 
keyframes in scene"}
+#define SACT_ITEM_TIMELINE \
+       {SACTCONT_TIMELINE, "TIMELINE", ICON_TIME, "Timeline", "Timeline and 
playback controls"}
+#define SACT_ITEM_ACTION \
+       {SACTCONT_ACTION, "ACTION", ICON_OBJECT_DATA, "Action Editor", "Edit 
keyframes in active object's Object-level action"}
+#define SACT_ITEM_SHAPEKEY \
+       {SACTCONT_SHAPEKEY, "SHAPEKEY", ICON_SHAPEKEY_DATA, "Shape Key Editor", 
"Edit keyframes in active object's Shape Keys action"}
+#define SACT_ITEM_GPENCIL \
+       {SACTCONT_GPENCIL, "GPENCIL", ICON_GREASEPENCIL, "Grease Pencil", "Edit 
timings for all Grease Pencil sketches in file"}
+#define SACT_ITEM_MASK \
+       {SACTCONT_MASK, "MASK", ICON_MOD_MASK, "Mask", "Edit timings for Mask 
Editor splines"}
+#define SACT_ITEM_CACHEFILE \
+       {SACTCONT_CACHEFILE, "CACHEFILE", ICON_FILE, "Cache File", "Edit 
timings for Cache File data-blocks"}
+
+#ifndef RNA_RUNTIME
+/* XXX: action-editor is currently for object-level only actions, so show that 
using object-icon hint */
+static EnumPropertyItem rna_enum_space_action_mode_all_items[] = {
+       SACT_ITEM_DOPESHEET,
+       SACT_ITEM_TIMELINE,
+       SACT_ITEM_ACTION,
+       SACT_ITEM_SHAPEKEY,
+       SACT_ITEM_GPENCIL,
+       SACT_ITEM_MASK,
+       SACT_ITEM_CACHEFILE,
+       {0, NULL, 0, NULL, NULL}
+};
+static EnumPropertyItem rna_enum_space_action_ui_mode_items[] = {
+       SACT_ITEM_DOPESHEET,
+       /* SACT_ITEM_TIMELINE, */
+       SACT_ITEM_ACTION,
+       SACT_ITEM_SHAPEKEY,
+       SACT_ITEM_GPENCIL,
+       SACT_ITEM_MASK,
+       SACT_ITEM_CACHEFILE,
+       {0, NULL, 0, NULL, NULL}
+};
+#endif
+/* expose as ui_mode */
+const EnumPropertyItem rna_enum_space_action_mode_items[] = {
+       SACT_ITEM_DOPESHEET,
+       SACT_ITEM_TIMELINE,
+       {0, NULL, 0, NULL, NULL}
+};
+
+#undef SACT_ITEM_DOPESHEET
+#undef SACT_ITEM_TIMELINE
+#undef SACT_ITEM_ACTION
+#undef SACT_ITEM_SHAPEKEY
+#undef SACT_ITEM_GPENCIL
+#undef SACT_ITEM_MASK
+#undef SACT_ITEM_CACHEFILE
+
 const EnumPropertyItem rna_enum_space_image_mode_items[] = {
        {SI_MODE_VIEW, "VIEW", ICON_FILE_IMAGE, "View", "View the image and UV 
edit in mesh editmode"},
        {SI_MODE_PAINT, "PAINT", ICON_TPAINT_HLT, "Paint", "2D image painting 
mode"},
@@ -3542,19 +3595,6 @@ static void rna_def_space_dopesheet(BlenderRNA *brna)
        StructRNA *srna;
        PropertyRNA *prop;
 
-       /* XXX: action-editor is currently for object-level only actions, so 
show that using object-icon hint */
-       static EnumPropertyItem mode_items[] = {
-               {SACTCONT_TIMELINE, "TIMELINE", ICON_TIME, "Timeline", 
"Timeline and playback controls"},
-               {SACTCONT_DOPESHEET, "DOPESHEET", ICON_OOPS, "Dope Sheet", 
"Edit all keyframes in scene"},
-               {SACTCONT_ACTION, "ACTION", ICON_OBJECT_DATA, "Action Editor", 
"Edit keyframes in active object's Object-level action"},
-               {SACTCONT_SHAPEKEY, "SHAPEKEY", ICON_SHAPEKEY_DATA, "Shape Key 
Editor", "Edit keyframes in active object's Shape Keys action"},
-               {SACTCONT_GPENCIL, "GPENCIL", ICON_GREASEPENCIL, "Grease 
Pencil", "Edit timings for all Grease Pencil sketches in file"},
-               {SACTCONT_MASK, "MASK", ICON_MOD_MASK, "Mask", "Edit timings 
for Mask Editor splines"},
-               {SACTCONT_CACHEFILE, "CACHEFILE", ICON_FILE, "Cache File", 
"Edit timings for Cache File data-blocks"},
-               {0, NULL, 0, NULL, NULL}
-       };
-
-
        srna = RNA_def_struct(brna, "SpaceDopeSheetEditor", "Space");
        RNA_def_struct_sdna(srna, "SpaceAction");
        RNA_def_struct_ui_text(srna, "Space Dope Sheet Editor", "Dope Sheet 
space data");
@@ -3568,10 +3608,17 @@ static void rna_def_space_dopesheet(BlenderRNA *brna)
        RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
        RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, 
"rna_SpaceDopeSheetEditor_action_update");
 
-       /* mode */
+       /* mode (hidden in the UI, see 'ui_mode') */
        prop = RNA_def_property(srna, "mode", PROP_ENUM, PROP_NONE);
        RNA_def_property_enum_sdna(prop, NULL, "mode");
-       RNA_def_property_enum_items(prop, mode_items);
+       RNA_def_property_enum_items(prop, rna_enum_space_action_mode_all_items);
+       RNA_def_property_ui_text(prop, "Mode", "Editing context being 
displayed");
+       RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
+       RNA_def_property_update(prop, NC_SPACE | ND_SPACE_DOPESHEET, 
"rna_SpaceDopeSheetEditor_mode_update");
+
+       prop = RNA_def_property(srna, "ui_mode", PROP_ENUM, PROP_NONE);
+       RNA_def_property_enum_sdna(prop, NULL, "mode");
+       RNA_def_property_enum_items(prop, rna_enum_space_action_ui_mode_items);
        RNA_def_property_ui_text(prop, "Mode", "Editing context being 
displayed");
        RNA_def_property_flag(prop, PROP_CONTE

@@ Diff output truncated at 10240 characters. @@

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to