utility function to find the biggest area: BKE_screen_find_big_area(...), was being done with static functions that were copied about.
This commit is contained in:
@@ -34,22 +34,23 @@
|
||||
*/
|
||||
|
||||
struct ARegion;
|
||||
struct Header;
|
||||
struct ListBase;
|
||||
struct Menu;
|
||||
struct Panel;
|
||||
struct Scene;
|
||||
struct ScrArea;
|
||||
struct SpaceType;
|
||||
struct View3D;
|
||||
struct bContext;
|
||||
struct bContextDataResult;
|
||||
struct bScreen;
|
||||
struct ListBase;
|
||||
struct Panel;
|
||||
struct Header;
|
||||
struct Menu;
|
||||
struct ScrArea;
|
||||
struct SpaceType;
|
||||
struct Scene;
|
||||
struct uiLayout;
|
||||
struct uiMenuItem;
|
||||
struct wmKeyConfig;
|
||||
struct wmNotifier;
|
||||
struct wmWindow;
|
||||
struct wmWindowManager;
|
||||
struct wmKeyConfig;
|
||||
struct uiLayout;
|
||||
struct uiMenuItem;
|
||||
|
||||
#include "RNA_types.h"
|
||||
|
||||
@@ -239,6 +240,7 @@ void BKE_area_region_free(struct SpaceType *st, struct ARegion *ar);
|
||||
void BKE_screen_area_free(struct ScrArea *sa);
|
||||
|
||||
struct ARegion *BKE_area_find_region_type(struct ScrArea *sa, int type);
|
||||
struct ScrArea *BKE_screen_find_big_area(struct bScreen *sc, const int spacetype, const short min);
|
||||
|
||||
void BKE_screen_view3d_sync(struct View3D *v3d, struct Scene *scene);
|
||||
void BKE_screen_view3d_scene_sync(struct bScreen *sc);
|
||||
|
||||
@@ -351,6 +351,29 @@ ARegion *BKE_area_find_region_type(ScrArea *sa, int type)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* note, using this function is generally a last resort, you really want to be
|
||||
* using the context when you can - campbell
|
||||
* -1 for any type */
|
||||
struct ScrArea *BKE_screen_find_big_area(struct bScreen *sc, const int spacetype, const short min)
|
||||
{
|
||||
ScrArea *sa, *big= NULL;
|
||||
int size, maxsize= 0;
|
||||
|
||||
for(sa= sc->areabase.first; sa; sa= sa->next) {
|
||||
if ((spacetype == -1) || sa->spacetype == spacetype) {
|
||||
if (min >= sa->winx && min >= sa->winy) {
|
||||
size= sa->winx*sa->winy;
|
||||
if (size > maxsize) {
|
||||
maxsize= size;
|
||||
big= sa;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return big;
|
||||
}
|
||||
|
||||
void BKE_screen_view3d_sync(struct View3D *v3d, struct Scene *scene)
|
||||
{
|
||||
int bit;
|
||||
|
||||
@@ -43,6 +43,7 @@
|
||||
#include "BLI_utildefines.h"
|
||||
|
||||
#include "BKE_context.h"
|
||||
#include "BKE_screen.h"
|
||||
#include "BKE_global.h"
|
||||
#include "BKE_text.h" /* for UI_OT_reports_to_text */
|
||||
#include "BKE_report.h"
|
||||
@@ -577,24 +578,6 @@ void UI_editsource_active_but_test(uiBut *but)
|
||||
|
||||
/* editsource operator component */
|
||||
|
||||
static ScrArea *biggest_text_view(bContext *C)
|
||||
{
|
||||
bScreen *sc= CTX_wm_screen(C);
|
||||
ScrArea *sa, *big= NULL;
|
||||
int size, maxsize= 0;
|
||||
|
||||
for(sa= sc->areabase.first; sa; sa= sa->next) {
|
||||
if(sa->spacetype==SPACE_TEXT) {
|
||||
size= sa->winx * sa->winy;
|
||||
if(size > maxsize) {
|
||||
maxsize= size;
|
||||
big= sa;
|
||||
}
|
||||
}
|
||||
}
|
||||
return big;
|
||||
}
|
||||
|
||||
static int editsource_text_edit(bContext *C, wmOperator *op,
|
||||
char filepath[240], int line)
|
||||
{
|
||||
@@ -619,7 +602,7 @@ static int editsource_text_edit(bContext *C, wmOperator *op,
|
||||
else {
|
||||
/* naughty!, find text area to set, not good behavior
|
||||
* but since this is a dev tool lets allow it - campbell */
|
||||
ScrArea *sa= biggest_text_view(C);
|
||||
ScrArea *sa= BKE_screen_find_big_area(CTX_wm_screen(C), SPACE_TEXT, 0);
|
||||
if(sa) {
|
||||
SpaceText *st= sa->spacedata.first;
|
||||
st->text= text;
|
||||
|
||||
@@ -54,6 +54,7 @@
|
||||
#include "BLI_math_geom.h"
|
||||
|
||||
#include "BKE_blender.h"
|
||||
#include "BKE_screen.h"
|
||||
#include "BKE_context.h"
|
||||
#include "BKE_global.h"
|
||||
#include "BKE_image.h"
|
||||
@@ -1202,24 +1203,6 @@ static int thread_break(void *UNUSED(arg))
|
||||
return G.afbreek;
|
||||
}
|
||||
|
||||
static ScrArea *biggest_image_area(bScreen *screen)
|
||||
{
|
||||
ScrArea *sa, *big= NULL;
|
||||
int size, maxsize= 0;
|
||||
|
||||
for(sa= screen->areabase.first; sa; sa= sa->next) {
|
||||
if(sa->spacetype==SPACE_IMAGE) {
|
||||
size= sa->winx*sa->winy;
|
||||
if(sa->winx > 10 && sa->winy > 10 && size > maxsize) {
|
||||
maxsize= size;
|
||||
big= sa;
|
||||
}
|
||||
}
|
||||
}
|
||||
return big;
|
||||
}
|
||||
|
||||
|
||||
typedef struct BakeRender {
|
||||
Render *re;
|
||||
Main *main;
|
||||
@@ -1270,7 +1253,7 @@ static void init_bake_internal(BakeRender *bkr, bContext *C)
|
||||
/* get editmode results */
|
||||
ED_object_exit_editmode(C, 0); /* 0 = does not exit editmode */
|
||||
|
||||
bkr->sa= biggest_image_area(CTX_wm_screen(C)); /* can be NULL */
|
||||
bkr->sa= BKE_screen_find_big_area(CTX_wm_screen(C), SPACE_IMAGE, 10); /* can be NULL */
|
||||
bkr->main= CTX_data_main(C);
|
||||
bkr->scene= scene;
|
||||
bkr->actob= (scene->r.bake_flag & R_BAKE_TO_ACTIVE) ? OBACT : NULL;
|
||||
|
||||
@@ -58,6 +58,7 @@
|
||||
|
||||
/* returns biggest area that is not uv/image editor. Note that it uses buttons */
|
||||
/* window as the last possible alternative. */
|
||||
/* would use BKE_screen_find_big_area(...) but this is too specific */
|
||||
static ScrArea *biggest_non_image_area(bContext *C)
|
||||
{
|
||||
bScreen *sc= CTX_wm_screen(C);
|
||||
@@ -85,22 +86,6 @@ static ScrArea *biggest_non_image_area(bContext *C)
|
||||
return big;
|
||||
}
|
||||
|
||||
static ScrArea *biggest_area(bContext *C)
|
||||
{
|
||||
bScreen *sc= CTX_wm_screen(C);
|
||||
ScrArea *sa, *big= NULL;
|
||||
int size, maxsize= 0;
|
||||
|
||||
for(sa= sc->areabase.first; sa; sa= sa->next) {
|
||||
size= sa->winx*sa->winy;
|
||||
if(size > maxsize) {
|
||||
maxsize= size;
|
||||
big= sa;
|
||||
}
|
||||
}
|
||||
return big;
|
||||
}
|
||||
|
||||
static ScrArea *find_area_showing_r_result(bContext *C, wmWindow **win)
|
||||
{
|
||||
wmWindowManager *wm= CTX_wm_manager(C);
|
||||
@@ -206,7 +191,7 @@ void render_view_open(bContext *C, int mx, int my)
|
||||
}
|
||||
else {
|
||||
/* use any area of decent size */
|
||||
sa= biggest_area(C);
|
||||
sa= BKE_screen_find_big_area(CTX_wm_screen(C), -1, 0);
|
||||
if(sa->spacetype!=SPACE_IMAGE) {
|
||||
// XXX newspace(sa, SPACE_IMAGE);
|
||||
sima= sa->spacedata.first;
|
||||
|
||||
@@ -212,24 +212,6 @@ void WM_init_splash(bContext *C)
|
||||
}
|
||||
}
|
||||
|
||||
static ScrArea *biggest_view3d(bContext *C)
|
||||
{
|
||||
bScreen *sc= CTX_wm_screen(C);
|
||||
ScrArea *sa, *big= NULL;
|
||||
int size, maxsize= 0;
|
||||
|
||||
for(sa= sc->areabase.first; sa; sa= sa->next) {
|
||||
if(sa->spacetype==SPACE_VIEW3D) {
|
||||
size= sa->winx * sa->winy;
|
||||
if(size > maxsize) {
|
||||
maxsize= size;
|
||||
big= sa;
|
||||
}
|
||||
}
|
||||
}
|
||||
return big;
|
||||
}
|
||||
|
||||
int WM_init_game(bContext *C)
|
||||
{
|
||||
wmWindowManager *wm= CTX_wm_manager(C);
|
||||
@@ -252,7 +234,7 @@ int WM_init_game(bContext *C)
|
||||
if(win)
|
||||
CTX_wm_window_set(C, win);
|
||||
|
||||
sa = biggest_view3d(C);
|
||||
sa = BKE_screen_find_big_area(CTX_wm_screen(C), SPACE_VIEW3D, 0);
|
||||
ar= BKE_area_find_region_type(sa, RGN_TYPE_WINDOW);
|
||||
|
||||
// if we have a valid 3D view
|
||||
|
||||
Reference in New Issue
Block a user