Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulian Eisel <eiseljulian@gmail.com>2018-04-21 20:30:56 +0300
committerJulian Eisel <eiseljulian@gmail.com>2018-04-21 20:47:27 +0300
commit9a35ad752e845129aa756778e7f502a5057b92bf (patch)
tree4204481b02f643ecf572cd5c9e6e2df8418471f4
parent9ba84342fb6835dd3add1f12c698654d3d79a90e (diff)
Cleanup: Get rid of context in editor 'new' callback
Requiring context means we can't easily create new editors to replace deprecated ones in versioning code. Think it's reasonable to give editors access to scene and area data for their initial setup though. They mostly need it for setting "the view", as in, scrolling values. Also did minor cleanup in top-bar creation function.
-rw-r--r--source/blender/blenkernel/BKE_screen.h5
-rw-r--r--source/blender/editors/screen/area.c2
-rw-r--r--source/blender/editors/screen/screen_edit.c49
-rw-r--r--source/blender/editors/space_action/space_action.c4
-rw-r--r--source/blender/editors/space_api/spacetypes.c2
-rw-r--r--source/blender/editors/space_buttons/space_buttons.c2
-rw-r--r--source/blender/editors/space_clip/space_clip.c18
-rw-r--r--source/blender/editors/space_console/space_console.c2
-rw-r--r--source/blender/editors/space_file/space_file.c2
-rw-r--r--source/blender/editors/space_graph/space_graph.c3
-rw-r--r--source/blender/editors/space_image/space_image.c2
-rw-r--r--source/blender/editors/space_info/space_info.c2
-rw-r--r--source/blender/editors/space_nla/space_nla.c4
-rw-r--r--source/blender/editors/space_node/space_node.c2
-rw-r--r--source/blender/editors/space_outliner/space_outliner.c2
-rw-r--r--source/blender/editors/space_script/space_script.c2
-rw-r--r--source/blender/editors/space_sequencer/space_sequencer.c3
-rw-r--r--source/blender/editors/space_text/space_text.c2
-rw-r--r--source/blender/editors/space_topbar/space_topbar.c2
-rw-r--r--source/blender/editors/space_userpref/space_userpref.c2
-rw-r--r--source/blender/editors/space_view3d/space_view3d.c3
21 files changed, 61 insertions, 54 deletions
diff --git a/source/blender/blenkernel/BKE_screen.h b/source/blender/blenkernel/BKE_screen.h
index 2a25120ba8d..2736833a5ca 100644
--- a/source/blender/blenkernel/BKE_screen.h
+++ b/source/blender/blenkernel/BKE_screen.h
@@ -77,8 +77,9 @@ typedef struct SpaceType {
int spaceid; /* unique space identifier */
int iconid; /* icon lookup for menus */
- /* initial allocation, after this WM will call init() too */
- struct SpaceLink *(*new)(const struct bContext *C);
+ /* Initial allocation, after this WM will call init() too. Some editors need
+ * area and scene data (e.g. frame range) to set their initial scrolling. */
+ struct SpaceLink *(*new)(const struct ScrArea *, const struct Scene *);
/* not free spacelink itself */
void (*free)(struct SpaceLink *);
diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c
index e4c48a83565..2d058c7c0bf 100644
--- a/source/blender/editors/screen/area.c
+++ b/source/blender/editors/screen/area.c
@@ -1838,7 +1838,7 @@ void ED_area_newspace(bContext *C, ScrArea *sa, int type, const bool skip_ar_exi
else {
/* new space */
if (st) {
- sl = st->new(C);
+ sl = st->new(sa, CTX_data_scene(C));
BLI_addhead(&sa->spacedata, sl);
/* swap regions */
diff --git a/source/blender/editors/screen/screen_edit.c b/source/blender/editors/screen/screen_edit.c
index 6a27964165d..00bff69cd02 100644
--- a/source/blender/editors/screen/screen_edit.c
+++ b/source/blender/editors/screen/screen_edit.c
@@ -1117,27 +1117,42 @@ int ED_screen_area_active(const bContext *C)
return 0;
}
+/**
+ * Add an area and geometry (screen-edges and -vertices) for it to \a area_map,
+ * with coordinates/dimensions matching \a rect.
+ */
+static ScrArea *screen_area_create_with_geometry(
+ ScrAreaMap *area_map, const rcti *rect,
+ short headertype, short spacetype)
+{
+ ScrVert *bottom_left = screen_addvert_ex(area_map, rect->xmin, rect->ymin);
+ ScrVert *top_left = screen_addvert_ex(area_map, rect->xmin, rect->ymax);
+ ScrVert *top_right = screen_addvert_ex(area_map, rect->xmax, rect->ymax);
+ ScrVert *bottom_right = screen_addvert_ex(area_map, rect->xmax, rect->ymin);
+
+ screen_addedge_ex(area_map, bottom_left, top_left);
+ screen_addedge_ex(area_map, top_left, top_right);
+ screen_addedge_ex(area_map, top_right, bottom_right);
+ screen_addedge_ex(area_map, bottom_right, bottom_left);
+
+ return screen_addarea_ex(area_map, bottom_left, top_left, top_right, bottom_right, headertype, spacetype);
+}
+
void ED_screen_global_topbar_area_create(wmWindow *win, const bScreen *screen)
{
if (screen->temp == 0) {
- SpaceType *st = BKE_spacetype_from_id(SPACE_TOPBAR);
- SpaceLink *sl = st->new(NULL);
- ScrArea *sa;
const short size_y = 2.25 * HEADERY;
- const int minx = 0, maxx = WM_window_pixels_x(win) - 1;
- const int maxy = WM_window_pixels_y(win) - 1, miny = maxy - size_y;
-
- ScrVert *bottom_left = screen_addvert_ex(&win->global_areas, minx, miny);
- ScrVert *top_left = screen_addvert_ex(&win->global_areas, minx, maxy);
- ScrVert *top_right = screen_addvert_ex(&win->global_areas, maxx, maxy);
- ScrVert *bottom_right = screen_addvert_ex(&win->global_areas, maxx, miny);
- screen_addedge_ex(&win->global_areas, bottom_left, top_left);
- screen_addedge_ex(&win->global_areas, top_left, top_right);
- screen_addedge_ex(&win->global_areas, top_right, bottom_right);
- screen_addedge_ex(&win->global_areas, bottom_right, bottom_left);
-
- sa = screen_addarea_ex(&win->global_areas, bottom_left, top_left, top_right, bottom_right,
- HEADERTOP, SPACE_TOPBAR);
+ SpaceType *st;
+ SpaceLink *sl;
+ ScrArea *sa;
+ rcti rect;
+
+ BLI_rcti_init(&rect, 0, WM_window_pixels_x(win) - 1, 0, WM_window_pixels_y(win) - 1);
+ rect.ymin = rect.ymax - size_y;
+
+ sa = screen_area_create_with_geometry(&win->global_areas, &rect, HEADERTOP, SPACE_TOPBAR);
+ st = BKE_spacetype_from_id(SPACE_TOPBAR);
+ sl = st->new(sa, WM_window_get_active_scene(win));
sa->regionbase = sl->regionbase;
/* Data specific to global areas. */
diff --git a/source/blender/editors/space_action/space_action.c b/source/blender/editors/space_action/space_action.c
index b68300e0d52..f749cce69e3 100644
--- a/source/blender/editors/space_action/space_action.c
+++ b/source/blender/editors/space_action/space_action.c
@@ -92,10 +92,8 @@ ARegion *action_has_buttons_region(ScrArea *sa)
/* ******************** default callbacks for action space ***************** */
-static SpaceLink *action_new(const bContext *C)
+static SpaceLink *action_new(const ScrArea *sa, const Scene *scene)
{
- Scene *scene = CTX_data_scene(C);
- ScrArea *sa = CTX_wm_area(C);
SpaceAction *saction;
ARegion *ar;
diff --git a/source/blender/editors/space_api/spacetypes.c b/source/blender/editors/space_api/spacetypes.c
index 6c53aa62378..12f16f1fe42 100644
--- a/source/blender/editors/space_api/spacetypes.c
+++ b/source/blender/editors/space_api/spacetypes.c
@@ -280,7 +280,7 @@ void ED_region_draw_cb_draw(const bContext *C, ARegion *ar, int type)
void ED_spacetype_xxx(void);
/* allocate and init some vars */
-static SpaceLink *xxx_new(const bContext *UNUSED(C))
+static SpaceLink *xxx_new(const ScrArea *UNUSED(sa), const Scene *UNUSED(scene))
{
return NULL;
}
diff --git a/source/blender/editors/space_buttons/space_buttons.c b/source/blender/editors/space_buttons/space_buttons.c
index 179780bf517..d3fab82f7ff 100644
--- a/source/blender/editors/space_buttons/space_buttons.c
+++ b/source/blender/editors/space_buttons/space_buttons.c
@@ -52,7 +52,7 @@
/* ******************** default callbacks for buttons space ***************** */
-static SpaceLink *buttons_new(const bContext *UNUSED(C))
+static SpaceLink *buttons_new(const ScrArea *UNUSED(area), const Scene *UNUSED(scene))
{
ARegion *ar;
SpaceButs *sbuts;
diff --git a/source/blender/editors/space_clip/space_clip.c b/source/blender/editors/space_clip/space_clip.c
index ba9684411b3..f043280e43c 100644
--- a/source/blender/editors/space_clip/space_clip.c
+++ b/source/blender/editors/space_clip/space_clip.c
@@ -75,12 +75,8 @@
#include "clip_intern.h" /* own include */
-static void init_preview_region(const bContext *C, ARegion *ar)
+static void init_preview_region(const Scene *scene, const ScrArea *sa, const SpaceClip *sc, ARegion *ar)
{
- Scene *scene = CTX_data_scene(C);
- ScrArea *sa = CTX_wm_area(C);
- SpaceClip *sc = CTX_wm_space_clip(C);
-
ar->regiontype = RGN_TYPE_PREVIEW;
ar->alignment = RGN_ALIGN_TOP;
ar->flag |= RGN_FLAG_HIDDEN;
@@ -138,15 +134,17 @@ static void init_preview_region(const bContext *C, ARegion *ar)
static void reinit_preview_region(const bContext *C, ARegion *ar)
{
+ Scene *scene = CTX_data_scene(C);
+ ScrArea *sa = CTX_wm_area(C);
SpaceClip *sc = CTX_wm_space_clip(C);
if (sc->view == SC_VIEW_DOPESHEET) {
if ((ar->v2d.flag & V2D_VIEWSYNC_AREA_VERTICAL) == 0)
- init_preview_region(C, ar);
+ init_preview_region(scene, sa, sc, ar);
}
else {
if (ar->v2d.flag & V2D_VIEWSYNC_AREA_VERTICAL)
- init_preview_region(C, ar);
+ init_preview_region(scene, sa, sc, ar);
}
}
@@ -168,7 +166,7 @@ static ARegion *ED_clip_has_preview_region(const bContext *C, ScrArea *sa)
arnew = MEM_callocN(sizeof(ARegion), "clip preview region");
BLI_insertlinkbefore(&sa->regionbase, ar, arnew);
- init_preview_region(C, arnew);
+ init_preview_region(CTX_data_scene(C), sa, CTX_wm_space_clip(C), arnew);
return arnew;
}
@@ -228,7 +226,7 @@ static void clip_scopes_check_gpencil_change(ScrArea *sa)
/* ******************** default callbacks for clip space ***************** */
-static SpaceLink *clip_new(const bContext *C)
+static SpaceLink *clip_new(const ScrArea *sa, const Scene *scene)
{
ARegion *ar;
SpaceClip *sc;
@@ -286,7 +284,7 @@ static SpaceLink *clip_new(const bContext *C)
ar = MEM_callocN(sizeof(ARegion), "preview for clip");
BLI_addtail(&sc->regionbase, ar);
- init_preview_region(C, ar);
+ init_preview_region(scene, sa, sc, ar);
/* main region */
ar = MEM_callocN(sizeof(ARegion), "main region for clip");
diff --git a/source/blender/editors/space_console/space_console.c b/source/blender/editors/space_console/space_console.c
index 9a2f4b5d431..c49df387707 100644
--- a/source/blender/editors/space_console/space_console.c
+++ b/source/blender/editors/space_console/space_console.c
@@ -52,7 +52,7 @@
/* ******************** default callbacks for console space ***************** */
-static SpaceLink *console_new(const bContext *UNUSED(C))
+static SpaceLink *console_new(const ScrArea *UNUSED(area), const Scene *UNUSED(scene))
{
ARegion *ar;
SpaceConsole *sconsole;
diff --git a/source/blender/editors/space_file/space_file.c b/source/blender/editors/space_file/space_file.c
index 61ea4961f3e..40707d5add7 100644
--- a/source/blender/editors/space_file/space_file.c
+++ b/source/blender/editors/space_file/space_file.c
@@ -68,7 +68,7 @@
/* ******************** default callbacks for file space ***************** */
-static SpaceLink *file_new(const bContext *UNUSED(C))
+static SpaceLink *file_new(const ScrArea *UNUSED(area), const Scene *UNUSED(scene))
{
ARegion *ar;
SpaceFile *sfile;
diff --git a/source/blender/editors/space_graph/space_graph.c b/source/blender/editors/space_graph/space_graph.c
index b09de2470a2..381cb1d9e6e 100644
--- a/source/blender/editors/space_graph/space_graph.c
+++ b/source/blender/editors/space_graph/space_graph.c
@@ -95,9 +95,8 @@ ARegion *graph_has_buttons_region(ScrArea *sa)
/* ******************** default callbacks for ipo space ***************** */
-static SpaceLink *graph_new(const bContext *C)
+static SpaceLink *graph_new(const ScrArea *UNUSED(sa), const Scene *scene)
{
- Scene *scene = CTX_data_scene(C);
ARegion *ar;
SpaceIpo *sipo;
diff --git a/source/blender/editors/space_image/space_image.c b/source/blender/editors/space_image/space_image.c
index 38a850568fd..bfbf51487ad 100644
--- a/source/blender/editors/space_image/space_image.c
+++ b/source/blender/editors/space_image/space_image.c
@@ -162,7 +162,7 @@ ARegion *image_has_tools_region(ScrArea *sa)
/* ******************** default callbacks for image space ***************** */
-static SpaceLink *image_new(const bContext *UNUSED(C))
+static SpaceLink *image_new(const ScrArea *UNUSED(area), const Scene *UNUSED(scene))
{
ARegion *ar;
SpaceImage *simage;
diff --git a/source/blender/editors/space_info/space_info.c b/source/blender/editors/space_info/space_info.c
index b13152883c3..96a0a1ed3ec 100644
--- a/source/blender/editors/space_info/space_info.c
+++ b/source/blender/editors/space_info/space_info.c
@@ -63,7 +63,7 @@
/* ******************** default callbacks for info space ***************** */
-static SpaceLink *info_new(const bContext *UNUSED(C))
+static SpaceLink *info_new(const ScrArea *UNUSED(area), const Scene *UNUSED(scene))
{
ARegion *ar;
SpaceInfo *sinfo;
diff --git a/source/blender/editors/space_nla/space_nla.c b/source/blender/editors/space_nla/space_nla.c
index bf831f16108..616d85f7d9d 100644
--- a/source/blender/editors/space_nla/space_nla.c
+++ b/source/blender/editors/space_nla/space_nla.c
@@ -94,10 +94,8 @@ ARegion *nla_has_buttons_region(ScrArea *sa)
/* ******************** default callbacks for nla space ***************** */
-static SpaceLink *nla_new(const bContext *C)
+static SpaceLink *nla_new(const ScrArea *sa, const Scene *scene)
{
- Scene *scene = CTX_data_scene(C);
- ScrArea *sa = CTX_wm_area(C);
ARegion *ar;
SpaceNla *snla;
diff --git a/source/blender/editors/space_node/space_node.c b/source/blender/editors/space_node/space_node.c
index a6a178b570d..a5f96ee04d6 100644
--- a/source/blender/editors/space_node/space_node.c
+++ b/source/blender/editors/space_node/space_node.c
@@ -291,7 +291,7 @@ ARegion *node_has_tools_region(ScrArea *sa)
/* ******************** default callbacks for node space ***************** */
-static SpaceLink *node_new(const bContext *UNUSED(C))
+static SpaceLink *node_new(const ScrArea *UNUSED(area), const Scene *UNUSED(scene))
{
ARegion *ar;
SpaceNode *snode;
diff --git a/source/blender/editors/space_outliner/space_outliner.c b/source/blender/editors/space_outliner/space_outliner.c
index 1529e6143c3..a0bdb53d398 100644
--- a/source/blender/editors/space_outliner/space_outliner.c
+++ b/source/blender/editors/space_outliner/space_outliner.c
@@ -479,7 +479,7 @@ static void outliner_header_region_listener(
/* ******************** default callbacks for outliner space ***************** */
-static SpaceLink *outliner_new(const bContext *UNUSED(C))
+static SpaceLink *outliner_new(const ScrArea *UNUSED(area), const Scene *UNUSED(scene))
{
ARegion *ar;
SpaceOops *soutliner;
diff --git a/source/blender/editors/space_script/space_script.c b/source/blender/editors/space_script/space_script.c
index fb8de02d3bd..767db745c33 100644
--- a/source/blender/editors/space_script/space_script.c
+++ b/source/blender/editors/space_script/space_script.c
@@ -62,7 +62,7 @@
/* ******************** default callbacks for script space ***************** */
-static SpaceLink *script_new(const bContext *UNUSED(C))
+static SpaceLink *script_new(const ScrArea *UNUSED(area), const Scene *UNUSED(scene))
{
ARegion *ar;
SpaceScript *sscript;
diff --git a/source/blender/editors/space_sequencer/space_sequencer.c b/source/blender/editors/space_sequencer/space_sequencer.c
index a8344a1fbd0..4e78e056093 100644
--- a/source/blender/editors/space_sequencer/space_sequencer.c
+++ b/source/blender/editors/space_sequencer/space_sequencer.c
@@ -113,9 +113,8 @@ static ARegion *sequencer_find_region(ScrArea *sa, short type)
/* ******************** default callbacks for sequencer space ***************** */
-static SpaceLink *sequencer_new(const bContext *C)
+static SpaceLink *sequencer_new(const ScrArea *UNUSED(sa), const Scene *scene)
{
- Scene *scene = CTX_data_scene(C);
ARegion *ar;
SpaceSeq *sseq;
diff --git a/source/blender/editors/space_text/space_text.c b/source/blender/editors/space_text/space_text.c
index 539fe1c53bd..c0324908b60 100644
--- a/source/blender/editors/space_text/space_text.c
+++ b/source/blender/editors/space_text/space_text.c
@@ -62,7 +62,7 @@
/* ******************** default callbacks for text space ***************** */
-static SpaceLink *text_new(const bContext *UNUSED(C))
+static SpaceLink *text_new(const ScrArea *UNUSED(area), const Scene *UNUSED(scene))
{
ARegion *ar;
SpaceText *stext;
diff --git a/source/blender/editors/space_topbar/space_topbar.c b/source/blender/editors/space_topbar/space_topbar.c
index 35858a927fe..0a6ec0e7aa0 100644
--- a/source/blender/editors/space_topbar/space_topbar.c
+++ b/source/blender/editors/space_topbar/space_topbar.c
@@ -56,7 +56,7 @@
/* ******************** default callbacks for topbar space ***************** */
-static SpaceLink *topbar_new(const bContext *UNUSED(C))
+static SpaceLink *topbar_new(const ScrArea *UNUSED(area), const Scene *UNUSED(scene))
{
ARegion *ar;
SpaceTopBar *stopbar;
diff --git a/source/blender/editors/space_userpref/space_userpref.c b/source/blender/editors/space_userpref/space_userpref.c
index f640fe63f93..8e569c3b16e 100644
--- a/source/blender/editors/space_userpref/space_userpref.c
+++ b/source/blender/editors/space_userpref/space_userpref.c
@@ -51,7 +51,7 @@
/* ******************** default callbacks for userpref space ***************** */
-static SpaceLink *userpref_new(const bContext *UNUSED(C))
+static SpaceLink *userpref_new(const ScrArea *UNUSED(area), const Scene *UNUSED(scene))
{
ARegion *ar;
SpaceUserPref *spref;
diff --git a/source/blender/editors/space_view3d/space_view3d.c b/source/blender/editors/space_view3d/space_view3d.c
index 8f9bc603d2b..e8de9b80fb3 100644
--- a/source/blender/editors/space_view3d/space_view3d.c
+++ b/source/blender/editors/space_view3d/space_view3d.c
@@ -325,9 +325,8 @@ void ED_view3d_shade_update(Main *bmain, View3D *v3d, ScrArea *sa)
/* ******************** default callbacks for view3d space ***************** */
-static SpaceLink *view3d_new(const bContext *C)
+static SpaceLink *view3d_new(const ScrArea *UNUSED(sa), const Scene *scene)
{
- Scene *scene = CTX_data_scene(C);
ARegion *ar;
View3D *v3d;
RegionView3D *rv3d;