[Bf-blender-cvs] [81c302b] master: Action Editor: Initial support for a Properties Region

Joshua Leung noreply at git.blender.org
Sun May 8 15:11:29 CEST 2016


Commit: 81c302bbff48b391b7f62ef7db233e9c7bd2adb2
Author: Joshua Leung
Date:   Sun May 8 14:38:30 2016 +1200
Branches: master
https://developer.blender.org/rB81c302bbff48b391b7f62ef7db233e9c7bd2adb2

Action Editor: Initial support for a Properties Region

This commit adds some of the initial support for a properties region in the
Action Editor. There are currently no panels to display, as there is still
a lot of work required to port over the required internal architecture to
support the panels seen in the Graph Editor.

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

M	release/scripts/startup/bl_ui/space_dopesheet.py
M	source/blender/blenloader/intern/versioning_270.c
M	source/blender/editors/space_action/CMakeLists.txt
A	source/blender/editors/space_action/action_buttons.c
M	source/blender/editors/space_action/action_intern.h
M	source/blender/editors/space_action/action_ops.c
M	source/blender/editors/space_action/space_action.c

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

diff --git a/release/scripts/startup/bl_ui/space_dopesheet.py b/release/scripts/startup/bl_ui/space_dopesheet.py
index af40f1f..0eeba5b 100644
--- a/release/scripts/startup/bl_ui/space_dopesheet.py
+++ b/release/scripts/startup/bl_ui/space_dopesheet.py
@@ -207,6 +207,9 @@ class DOPESHEET_MT_view(Menu):
 
         st = context.space_data
 
+        layout.operator("action.properties", icon='MENU_PANEL')
+        layout.separator()
+
         layout.prop(st, "use_realtime_update")
         layout.prop(st, "show_frame_indicator")
         layout.prop(st, "show_sliders")
diff --git a/source/blender/blenloader/intern/versioning_270.c b/source/blender/blenloader/intern/versioning_270.c
index f7d208a..efd167d 100644
--- a/source/blender/blenloader/intern/versioning_270.c
+++ b/source/blender/blenloader/intern/versioning_270.c
@@ -137,6 +137,30 @@ static void do_version_constraints_stretch_to_limits(ListBase *lb)
 	}
 }
 
+static void do_version_action_editor_properties_region(ListBase *regionbase)
+{
+	ARegion *ar;
+	
+	for (ar = regionbase->first; ar; ar = ar->next) {
+		if (ar->regiontype == RGN_TYPE_UI) {
+			/* already exists */
+			return;
+		}
+		else if (ar->regiontype == RGN_TYPE_WINDOW) {
+			/* add new region here */
+			ARegion *arnew = MEM_callocN(sizeof(ARegion), "buttons for action");
+			
+			BLI_insertlinkbefore(regionbase, ar, arnew);
+			
+			arnew->regiontype = RGN_TYPE_UI;
+			arnew->alignment = RGN_ALIGN_RIGHT;
+			arnew->flag = RGN_FLAG_HIDDEN;
+			
+			return;
+		}
+	}
+}
+
 void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main)
 {
 	if (!MAIN_VERSION_ATLEAST(main, 270, 0)) {
@@ -1109,5 +1133,22 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main)
 			SEQ_END
 		}
 
+		/* Adding "Properties" region to DopeSheet */
+		for (bScreen *screen = main->screen.first; screen; screen = screen->id.next) {
+			for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
+				/* handle pushed-back space data first */
+				for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
+					if (sl->spacetype == SPACE_ACTION) {
+						SpaceAction *saction = (SpaceAction *)sl;
+						do_version_action_editor_properties_region(&saction->regionbase);
+					}
+				}
+				
+				/* active spacedata info must be handled too... */
+				if (sa->spacetype == SPACE_ACTION) {
+					do_version_action_editor_properties_region(&sa->regionbase);
+				}
+			}
+		}
 	}
 }
diff --git a/source/blender/editors/space_action/CMakeLists.txt b/source/blender/editors/space_action/CMakeLists.txt
index 839071d..24c3ee9 100644
--- a/source/blender/editors/space_action/CMakeLists.txt
+++ b/source/blender/editors/space_action/CMakeLists.txt
@@ -36,6 +36,7 @@ set(INC_SYS
 )
 
 set(SRC
+	action_buttons.c
 	action_data.c
 	action_draw.c
 	action_edit.c
diff --git a/source/blender/editors/space_action/action_buttons.c b/source/blender/editors/space_action/action_buttons.c
new file mode 100644
index 0000000..a3112f1
--- /dev/null
+++ b/source/blender/editors/space_action/action_buttons.c
@@ -0,0 +1,132 @@
+/*
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version. 
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2016 Blender Foundation.
+ * All rights reserved.
+ *
+ * 
+ * Contributor(s): Blender Foundation, Joshua Leung
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file blender/editors/space_action/action_buttons.c
+ *  \ingroup spaction
+ */
+
+
+#include <string.h>
+#include <stdio.h>
+#include <math.h>
+#include <float.h>
+
+#include "DNA_anim_types.h"
+#include "DNA_object_types.h"
+#include "DNA_scene_types.h"
+
+#include "MEM_guardedalloc.h"
+
+#include "BLI_math.h"
+#include "BLI_blenlib.h"
+#include "BLI_utildefines.h"
+
+#include "BLT_translation.h"
+
+#include "BKE_context.h"
+#include "BKE_curve.h"
+#include "BKE_depsgraph.h"
+#include "BKE_fcurve.h"
+#include "BKE_main.h"
+#include "BKE_global.h"
+#include "BKE_screen.h"
+#include "BKE_unit.h"
+
+
+#include "WM_api.h"
+#include "WM_types.h"
+
+#include "RNA_access.h"
+
+#include "ED_anim_api.h"
+#include "ED_keyframing.h"
+#include "ED_screen.h"
+
+#include "UI_interface.h"
+#include "UI_resources.h"
+
+#include "action_intern.h"   // own include
+
+/* ******************* action editor space & buttons ************** */
+
+/* ******************* general ******************************** */
+
+void action_buttons_register(ARegionType *art)
+{
+#if 0
+	PanelType *pt;
+	
+	// TODO: AnimData / Actions List
+	
+	pt = MEM_callocN(sizeof(PanelType), "spacetype action panel properties");
+	strcpy(pt->idname, "ACTION_PT_properties");
+	strcpy(pt->label, N_("Active F-Curve"));
+	strcpy(pt->translation_context, BLT_I18NCONTEXT_DEFAULT_BPYRNA);
+	pt->draw = action_anim_panel_properties;
+	pt->poll = action_anim_panel_poll;
+	BLI_addtail(&art->paneltypes, pt);
+	
+	pt = MEM_callocN(sizeof(PanelType), "spacetype action panel properties");
+	strcpy(pt->idname, "ACTION_PT_key_properties");
+	strcpy(pt->label, N_("Active Keyframe"));
+	strcpy(pt->translation_context, BLT_I18NCONTEXT_DEFAULT_BPYRNA);
+	pt->draw = action_anim_panel_key_properties;
+	pt->poll = action_anim_panel_poll;
+	BLI_addtail(&art->paneltypes, pt);
+	
+	pt = MEM_callocN(sizeof(PanelType), "spacetype action panel modifiers");
+	strcpy(pt->idname, "ACTION_PT_modifiers");
+	strcpy(pt->label, N_("Modifiers"));
+	strcpy(pt->translation_context, BLT_I18NCONTEXT_DEFAULT_BPYRNA);
+	pt->draw = action_anim_panel_modifiers;
+	pt->poll = action_anim_panel_poll;
+	BLI_addtail(&art->paneltypes, pt);
+#endif
+}
+
+static int action_properties_toggle_exec(bContext *C, wmOperator *UNUSED(op))
+{
+	ScrArea *sa = CTX_wm_area(C);
+	ARegion *ar = action_has_buttons_region(sa);
+	
+	if (ar)
+		ED_region_toggle_hidden(C, ar);
+
+	return OPERATOR_FINISHED;
+}
+
+void ACTION_OT_properties(wmOperatorType *ot)
+{
+	ot->name = "Properties";
+	ot->idname = "ACTION_OT_properties";
+	ot->description = "Toggle display properties panel";
+	
+	ot->exec = action_properties_toggle_exec;
+	ot->poll = ED_operator_action_active;
+
+	/* flags */
+	ot->flag = 0;
+}
diff --git a/source/blender/editors/space_action/action_intern.h b/source/blender/editors/space_action/action_intern.h
index 17f1f40..50e10e7 100644
--- a/source/blender/editors/space_action/action_intern.h
+++ b/source/blender/editors/space_action/action_intern.h
@@ -34,11 +34,21 @@
 struct bContext;
 struct bAnimContext;
 struct SpaceAction;
+struct ScrArea;
 struct ARegion;
+struct ARegionType;
 struct wmOperatorType;
 
 /* internal exports only */
 
+/* **************************************** */
+/* space_action.c / action_buttons.c */
+
+struct ARegion *action_has_buttons_region(struct ScrArea *sa);
+
+void action_buttons_register(struct ARegionType *art);
+void ACTION_OT_properties(struct wmOperatorType *ot);
+
 /* ***************************************** */
 /* action_draw.c */
 void draw_channel_names(struct bContext *C, struct bAnimContext *ac, struct ARegion *ar); 
diff --git a/source/blender/editors/space_action/action_ops.c b/source/blender/editors/space_action/action_ops.c
index 59b147c..f69f994 100644
--- a/source/blender/editors/space_action/action_ops.c
+++ b/source/blender/editors/space_action/action_ops.c
@@ -51,6 +51,9 @@
 
 void action_operatortypes(void)
 {
+	/* view */
+	WM_operatortype_append(ACTION_OT_properties);
+	
 	/* keyframes */
 	/* selection */
 	WM_operatortype_append(ACTION_OT_clickselect);
@@ -257,6 +260,13 @@ void action_keymap(wmKeyConfig *keyconf)
 {
 	wmKeyMap *keymap;
 	
+	/* keymap for all regions */
+	keymap = WM_keymap_find(keyconf, "Dopesheet Generic", SPACE_ACTION, 0);
+	
+	/* region management... */
+	WM_keymap_add_item(keymap, "ACTION_OT_properties", NKEY, KM_PRESS, 0, 0);
+	
+	
 	/* channels */
 	/* Channels are not directly handled by the Action Editor module, but are inherited from the Animation module. 
 	 * All the relevant operations, keymaps, drawing, etc. can therefore all be found in that module instead, as these
diff --git a/source/blender/editors/space_action/space_action.c b/source/blender/editors/space_action/space_action.c
index 53c5a00..6024010 100644
--- a/source/blender/editors/space_action/space_action.c
+++ b/source/blender/editors/space_action/space_action.c
@@ -59,6 +59,32 @@
 
 #include "action_intern.h"  /* own include */
 
+/* ******************** manage regions ********************* */
+
+ARegion *action_has_buttons_region(ScrArea *sa)
+{
+	ARegion *ar, *arnew;
+	
+	ar = BKE_area_find_region_type(sa, RGN_TYPE_UI);
+	if (ar) return ar;
+	
+	/* add subdiv level; after main */
+	ar = BKE_area_find_region_type(sa, RGN_TYPE_WINDOW);
+	
+	/* is error! */
+	if (ar == NULL) return NULL;
+	
+	arnew = MEM_callocN(sizeof(ARegion), "buttons for action");
+	
+	BLI_insertlinkafter(&sa->regionbase, ar, arnew);
+	arnew->regiontype = RGN_TYPE_UI;
+	arnew->alignment = RGN_ALIGN_RIGHT;
+	
+	arnew->flag = RGN_FLAG_HIDDEN;
+	
+	return arnew;
+}
+
 /* ******************** default callbacks for action space ***************** */
 
 static SpaceLink *action_new(const bContext *C)
@@ -93,6 +119,14 @@ static SpaceLink *action_new(const bContext *C)
 	ar->v2d.scroll = V2D_SCROLL_BOTTOM;
 	ar->v2d.flag = V2D_VIEWSYNC_AREA_VERTICAL;
 	
+	/* ui buttons */
+	ar = MEM_callocN(sizeof(ARegion), "buttons region for action");
+	
+	BLI_addtail(&saction->regionbase, ar);
+	ar->regiontype = RGN_TYPE_UI;
+	ar->alignment = RGN_ALIGN_RIGHT;
+	ar->flag = RGN_FLAG_HIDDEN;
+	
 	/* main region */
 	ar = MEM_callocN(sizeof(ARegion), "main region for action");
 	
@@ 

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list