[Bf-blender-cvs] [876c73c9af2] blender2.8: Cleanup: Move logic for initialising a new Drivers editor into its own function

Joshua Leung noreply at git.blender.org
Thu Jun 21 07:56:52 CEST 2018


Commit: 876c73c9af223a807f97b463c32e8b6e190983e8
Author: Joshua Leung
Date:   Thu Jun 21 16:57:59 2018 +1200
Branches: blender2.8
https://developer.blender.org/rB876c73c9af223a807f97b463c32e8b6e190983e8

Cleanup: Move logic for initialising a new Drivers editor into its own function

This shouldn't really be part of the windowmanager code. Pulling it out
now, so that we can reuse in RNA when switching display modes,
(and perhaps other places later)

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

M	source/blender/editors/include/ED_anim_api.h
M	source/blender/editors/space_graph/graph_utils.c
M	source/blender/windowmanager/intern/wm_window.c

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

diff --git a/source/blender/editors/include/ED_anim_api.h b/source/blender/editors/include/ED_anim_api.h
index 943191c8892..fee336ea768 100644
--- a/source/blender/editors/include/ED_anim_api.h
+++ b/source/blender/editors/include/ED_anim_api.h
@@ -690,6 +690,7 @@ void ANIM_list_elem_update(struct Main *bmain, struct Scene *scene, bAnimListEle
 void ANIM_sync_animchannels_to_data(const struct bContext *C);
 
 void ANIM_center_frame(struct bContext *C, int smooth_viewtx);
+
 /* ************************************************* */
 /* OPERATORS */
 
@@ -716,6 +717,10 @@ void ED_animedit_unlink_action(struct bContext *C, struct ID *id,
                                struct AnimData *adt, struct bAction *act,
                                struct ReportList *reports, bool force_delete);
 
+
+/* Drivers Editor - Utility to set up UI correctly */
+void ED_drivers_editor_init(struct bContext *C, struct ScrArea *sa);
+
 /* ************************************************ */
 
 #endif /* __ED_ANIM_API_H__ */
diff --git a/source/blender/editors/space_graph/graph_utils.c b/source/blender/editors/space_graph/graph_utils.c
index f55a5511e2d..e543111e662 100644
--- a/source/blender/editors/space_graph/graph_utils.c
+++ b/source/blender/editors/space_graph/graph_utils.c
@@ -44,16 +44,61 @@
 
 #include "BKE_context.h"
 #include "BKE_fcurve.h"
+#include "BKE_screen.h"
 
 
 #include "WM_api.h"
 
 
 #include "ED_anim_api.h"
+#include "ED_screen.h"
+#include "UI_interface.h"
 
 
 #include "graph_intern.h"   // own include
 
+/* ************************************************************** */
+/* Set Up Drivers Editor */
+
+/* Set up UI configuration for Drivers Editor */
+/* NOTE: Currently called from windowmanager (new drivers editor window) and RNA (mode switching) */
+void ED_drivers_editor_init(bContext *C, ScrArea *sa)
+{
+	SpaceIpo *sipo = (SpaceIpo *)sa->spacedata.first;
+
+	/* Set mode */
+	sipo->mode = SIPO_MODE_DRIVERS;
+
+	/* Show Properties Region (or else the settings can't be edited) */
+	ARegion *ar_props = BKE_area_find_region_type(sa, RGN_TYPE_UI);
+	if (ar_props) {
+		UI_panel_category_active_set(ar_props, "Drivers");
+
+		ar_props->flag &= ~RGN_FLAG_HIDDEN;
+		/* XXX: Adjust width of this too? */
+
+		ED_region_visibility_change_update(C, ar_props);
+	}
+	else {
+		printf("%s: Couldn't find properties region for Drivers Editor - %p\n", __func__, sa);
+	}
+
+	/* Adjust framing in graph region */
+	/* TODO: Have a way of not resetting this every time?
+	 * (e.g. So that switching back and forth between editors doesn't keep jumping?)
+	 */
+	ARegion *ar_main = BKE_area_find_region_type(sa, RGN_TYPE_WINDOW);
+	if (ar_main) {
+		/* XXX: Ideally we recenter based on the range instead... */
+		ar_main->v2d.tot.xmin = -2.0f;
+		ar_main->v2d.tot.ymin = -2.0f;
+		ar_main->v2d.tot.xmax = 2.0f;
+		ar_main->v2d.tot.ymax = 2.0f;
+
+		ar_main->v2d.cur = ar_main->v2d.tot;
+	}
+}
+
 /* ************************************************************** */
 /* Active F-Curve */
 
diff --git a/source/blender/windowmanager/intern/wm_window.c b/source/blender/windowmanager/intern/wm_window.c
index 076514cd73f..5d4e52dad77 100644
--- a/source/blender/windowmanager/intern/wm_window.c
+++ b/source/blender/windowmanager/intern/wm_window.c
@@ -70,6 +70,7 @@
 #include "wm_window.h"
 #include "wm_event_system.h"
 
+#include "ED_anim_api.h"
 #include "ED_scene.h"
 #include "ED_screen.h"
 #include "ED_fileselect.h"
@@ -953,30 +954,7 @@ wmWindow *WM_window_open_temp(bContext *C, int x, int y, int sizex, int sizey, i
 
 	/* do additional setup for specific editor type */
 	if (type == WM_WINDOW_DRIVERS) {
-		/* Configure editor - mode, tabs, framing */
-		SpaceIpo *sipo = (SpaceIpo *)sa->spacedata.first;
-		sipo->mode = SIPO_MODE_DRIVERS;
-
-		ARegion *ar_props = BKE_area_find_region_type(sa, RGN_TYPE_UI);
-		if (ar_props) {
-			UI_panel_category_active_set(ar_props, "Drivers");
-
-			ar_props->flag &= ~RGN_FLAG_HIDDEN;
-			/* XXX: Adjust width of this too? */
-
-			ED_region_visibility_change_update(C, ar_props);
-		}
-
-		ARegion *ar_main = BKE_area_find_region_type(sa, RGN_TYPE_WINDOW);
-		if (ar_main) {
-			/* XXX: Ideally we recenter based on the range instead... */
-			ar_main->v2d.tot.xmin = -2.0f;
-			ar_main->v2d.tot.ymin = -2.0f;
-			ar_main->v2d.tot.xmax = 2.0f;
-			ar_main->v2d.tot.ymax = 2.0f;
-
-			ar_main->v2d.cur = ar_main->v2d.tot;
-		}
+		ED_drivers_editor_init(C, sa);
 	}
 
 	if (sa->spacetype == SPACE_IMAGE)



More information about the Bf-blender-cvs mailing list