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 /source/blender/editors/screen
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.
Diffstat (limited to 'source/blender/editors/screen')
-rw-r--r--source/blender/editors/screen/area.c2
-rw-r--r--source/blender/editors/screen/screen_edit.c49
2 files changed, 33 insertions, 18 deletions
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. */