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:
authorJoseph Eagar <joeedh@gmail.com>2011-02-27 09:19:40 +0300
committerJoseph Eagar <joeedh@gmail.com>2011-02-27 09:19:40 +0300
commitf01261d040be27337db9f9996d648a279c89b7c4 (patch)
treec448230939b3c90d53ce8852dd00925d6052e3a4 /source/blender/editors/screen
parentdcaeda5c4e3a0687251b8511de4f2e8b85ef75c0 (diff)
parent2198cfdb2deec8b2e85e242c74a032f43d0b26ca (diff)
merge with/from trunk at r35190
Diffstat (limited to 'source/blender/editors/screen')
-rw-r--r--source/blender/editors/screen/CMakeLists.txt24
-rw-r--r--source/blender/editors/screen/SConscript6
-rw-r--r--source/blender/editors/screen/area.c212
-rw-r--r--source/blender/editors/screen/glutil.c21
-rw-r--r--source/blender/editors/screen/screen_context.c81
-rw-r--r--source/blender/editors/screen/screen_edit.c171
-rw-r--r--source/blender/editors/screen/screen_intern.h14
-rw-r--r--source/blender/editors/screen/screen_ops.c397
-rw-r--r--source/blender/editors/screen/screendump.c65
9 files changed, 618 insertions, 373 deletions
diff --git a/source/blender/editors/screen/CMakeLists.txt b/source/blender/editors/screen/CMakeLists.txt
index f9b5ceba0e4..5663a9ee750 100644
--- a/source/blender/editors/screen/CMakeLists.txt
+++ b/source/blender/editors/screen/CMakeLists.txt
@@ -19,23 +19,29 @@
#
# ***** END GPL LICENSE BLOCK *****
-FILE(GLOB SRC *.c)
-
-SET(INC
+set(INC
+ ../include
../../blenfont
../../blenkernel
+ ../../blenloader
../../blenlib
../../bmesh
../../imbuf
- ../include
- ../../../../intern/guardedalloc
../../makesdna
../../makesrna
../../windowmanager
+ ../../../../intern/guardedalloc
)
-IF(WIN32)
- SET(INC ${INC} ${PTHREADS_INC})
-ENDIF(WIN32)
+set(SRC
+ area.c
+ glutil.c
+ screen_context.c
+ screen_edit.c
+ screen_ops.c
+ screendump.c
+
+ screen_intern.h
+)
-BLENDERLIB(bf_editor_screen "${SRC}" "${INC}")
+blender_add_lib(bf_editor_screen "${SRC}" "${INC}")
diff --git a/source/blender/editors/screen/SConscript b/source/blender/editors/screen/SConscript
index 5ce15cf5472..6370c9d3153 100644
--- a/source/blender/editors/screen/SConscript
+++ b/source/blender/editors/screen/SConscript
@@ -11,10 +11,10 @@ incs += ' #/intern/guardedalloc #/extern/glew/include'
defs = ''
if env['OURPLATFORM'] == 'linux2':
- cflags='-pthread'
- incs += ' ../../../extern/binreloc/include'
+ cflags='-pthread'
+ incs += ' ../../../extern/binreloc/include'
if env['OURPLATFORM'] in ('win32-vc', 'win32-mingw', 'linuxcross', 'win64-vc'):
- incs += ' ' + env['BF_PTHREADS_INC']
+ incs += ' ' + env['BF_PTHREADS_INC']
env.BlenderLib ( 'bf_editors_screen', sources, Split(incs), Split(defs), libtype=['core'], priority=[105] )
diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c
index 90f9d5683c2..4ddb5d059e4 100644
--- a/source/blender/editors/screen/area.c
+++ b/source/blender/editors/screen/area.c
@@ -1,4 +1,4 @@
-/**
+/*
* $Id$
*
* ***** BEGIN GPL LICENSE BLOCK *****
@@ -36,6 +36,7 @@
#include "BLI_blenlib.h"
#include "BLI_math.h"
#include "BLI_rand.h"
+#include "BLI_utildefines.h"
#include "BKE_context.h"
#include "BKE_global.h"
@@ -144,7 +145,7 @@ void ED_area_do_refresh(bContext *C, ScrArea *sa)
/* based on screen region draw tags, set draw tags in azones, and future region tabs etc */
/* only exported for WM */
-void ED_area_overdraw_flush(bContext *C, ScrArea *sa, ARegion *ar)
+void ED_area_overdraw_flush(ScrArea *sa, ARegion *ar)
{
AZone *az;
@@ -163,31 +164,26 @@ void ED_area_overdraw_flush(bContext *C, ScrArea *sa, ARegion *ar)
static void area_draw_azone(short x1, short y1, short x2, short y2)
{
- float xmin = x1;
- float xmax = x2-2;
- float ymin = y1-1;
- float ymax = y2-3;
-
- float dx= 0.3f*(xmax-xmin);
- float dy= 0.3f*(ymax-ymin);
+ int dx= floor(0.3f*(x2-x1));
+ int dy= floor(0.3f*(y2-y1));
glColor4ub(255, 255, 255, 180);
- fdrawline(xmin, ymax, xmax, ymin);
+ fdrawline(x1, y2, x2, y1);
glColor4ub(255, 255, 255, 130);
- fdrawline(xmin, ymax-dy, xmax-dx, ymin);
+ fdrawline(x1, y2-dy, x2-dx, y1);
glColor4ub(255, 255, 255, 80);
- fdrawline(xmin, ymax-2*dy, xmax-2*dx, ymin);
+ fdrawline(x1, y2-2*dy, x2-2*dx, y1);
glColor4ub(0, 0, 0, 210);
- fdrawline(xmin, ymax+1, xmax+1, ymin);
+ fdrawline(x1, y2+1, x2+1, y1);
glColor4ub(0, 0, 0, 180);
- fdrawline(xmin, ymax-dy+1, xmax-dx+1, ymin);
+ fdrawline(x1, y2-dy+1, x2-dx+1, y1);
glColor4ub(0, 0, 0, 150);
- fdrawline(xmin, ymax-2*dy+1, xmax-2*dx+1, ymin);
+ fdrawline(x1, y2-2*dy+1, x2-2*dx+1, y1);
}
-static void region_draw_azone(ScrArea *sa, AZone *az)
+static void region_draw_azone(AZone *az)
{
GLUquadricObj *qobj = NULL;
short midx = az->x1 + (az->x2 - az->x1)/2;
@@ -247,7 +243,7 @@ void ED_area_overdraw(bContext *C)
if(az->type==AZONE_AREA) {
area_draw_azone(az->x1, az->y1, az->x2, az->y2);
} else if(az->type==AZONE_REGION) {
- region_draw_azone(sa, az);
+ region_draw_azone(az);
}
az->do_draw= 0;
@@ -338,7 +334,7 @@ void ED_region_do_draw(bContext *C, ARegion *ar)
glClear(GL_COLOR_BUFFER_BIT);
UI_ThemeColor(TH_TEXT);
- BLF_draw_default(20, 8, 0.0f, ar->headerstr);
+ BLF_draw_default(20, 8, 0.0f, ar->headerstr, 65535); /* XXX, use real length */
}
else if(at->draw) {
at->draw(C, ar);
@@ -405,6 +401,19 @@ void ED_area_tag_redraw(ScrArea *sa)
ED_region_tag_redraw(ar);
}
+void ED_area_tag_redraw_regiontype(ScrArea *sa, int regiontype)
+{
+ ARegion *ar;
+
+ if(sa) {
+ for(ar= sa->regionbase.first; ar; ar= ar->next) {
+ if(ar->regiontype == regiontype) {
+ ED_region_tag_redraw(ar);
+ }
+ }
+ }
+}
+
void ED_area_tag_refresh(ScrArea *sa)
{
if(sa)
@@ -437,7 +446,6 @@ void ED_area_headerprint(ScrArea *sa, const char *str)
/* ************************************************************ */
-#define AZONESPOT 12
static void area_azone_initialize(ScrArea *sa)
{
AZone *az;
@@ -451,8 +459,8 @@ static void area_azone_initialize(ScrArea *sa)
az->type= AZONE_AREA;
az->x1= sa->totrct.xmin;
az->y1= sa->totrct.ymin;
- az->x2= sa->totrct.xmin + AZONESPOT-1;
- az->y2= sa->totrct.ymin + AZONESPOT-1;
+ az->x2= sa->totrct.xmin + AZONESPOT;
+ az->y2= sa->totrct.ymin + AZONESPOT;
BLI_init_rcti(&az->rect, az->x1, az->x2, az->y1, az->y2);
az= (AZone *)MEM_callocN(sizeof(AZone), "actionzone");
@@ -460,38 +468,40 @@ static void area_azone_initialize(ScrArea *sa)
az->type= AZONE_AREA;
az->x1= sa->totrct.xmax+1;
az->y1= sa->totrct.ymax+1;
- az->x2= sa->totrct.xmax-AZONESPOT+1;
- az->y2= sa->totrct.ymax-AZONESPOT+1;
+ az->x2= sa->totrct.xmax-AZONESPOT;
+ az->y2= sa->totrct.ymax-AZONESPOT;
BLI_init_rcti(&az->rect, az->x1, az->x2, az->y1, az->y2);
}
#define AZONEPAD_EDGE 4
-#define AZONEPAD_ICON 8
+#define AZONEPAD_ICON 9
static void region_azone_edge(AZone *az, ARegion *ar)
{
- if(az->edge=='t') {
- az->x1= ar->winrct.xmin;
- az->y1= ar->winrct.ymax - AZONEPAD_EDGE;
- az->x2= ar->winrct.xmax;
- az->y2= ar->winrct.ymax;
- }
- else if(az->edge=='b') {
- az->x1= ar->winrct.xmin;
- az->y1= ar->winrct.ymin + AZONEPAD_EDGE;
- az->x2= ar->winrct.xmax;
- az->y2= ar->winrct.ymin;
- }
- else if(az->edge=='l') {
- az->x1= ar->winrct.xmin;
- az->y1= ar->winrct.ymin;
- az->x2= ar->winrct.xmin + AZONEPAD_EDGE;
- az->y2= ar->winrct.ymax;
- }
- else { // if(az->edge=='r') {
- az->x1= ar->winrct.xmax;
- az->y1= ar->winrct.ymin;
- az->x2= ar->winrct.xmax - AZONEPAD_EDGE;
- az->y2= ar->winrct.ymax;
+ switch(az->edge) {
+ case AE_TOP_TO_BOTTOMRIGHT:
+ az->x1= ar->winrct.xmin;
+ az->y1= ar->winrct.ymax - AZONEPAD_EDGE;
+ az->x2= ar->winrct.xmax;
+ az->y2= ar->winrct.ymax;
+ break;
+ case AE_BOTTOM_TO_TOPLEFT:
+ az->x1= ar->winrct.xmin;
+ az->y1= ar->winrct.ymin + AZONEPAD_EDGE;
+ az->x2= ar->winrct.xmax;
+ az->y2= ar->winrct.ymin;
+ break;
+ case AE_LEFT_TO_TOPRIGHT:
+ az->x1= ar->winrct.xmin;
+ az->y1= ar->winrct.ymin;
+ az->x2= ar->winrct.xmin + AZONEPAD_EDGE;
+ az->y2= ar->winrct.ymax;
+ break;
+ case AE_RIGHT_TO_TOPLEFT:
+ az->x1= ar->winrct.xmax;
+ az->y1= ar->winrct.ymin;
+ az->x2= ar->winrct.xmax - AZONEPAD_EDGE;
+ az->y2= ar->winrct.ymax;
+ break;
}
BLI_init_rcti(&az->rect, az->x1, az->x2, az->y1, az->y2);
@@ -502,33 +512,38 @@ static void region_azone_icon(ScrArea *sa, AZone *az, ARegion *ar)
AZone *azt;
int tot=0;
+ /* count how many actionzones with along same edge are available.
+ This allows for adding more action zones in the future without
+ having to worry about correct offset */
for(azt= sa->actionzones.first; azt; azt= azt->next) {
if(azt->edge == az->edge) tot++;
}
- if(az->edge=='t') {
- az->x1= ar->winrct.xmax - tot*2*AZONEPAD_ICON;
- az->y1= ar->winrct.ymax + AZONEPAD_ICON;
- az->x2= ar->winrct.xmax - tot*AZONEPAD_ICON;
- az->y2= ar->winrct.ymax + 2*AZONEPAD_ICON;
- }
- else if(az->edge=='b') {
- az->x1= ar->winrct.xmin + AZONEPAD_ICON;
- az->y1= ar->winrct.ymin - 2*AZONEPAD_ICON;
- az->x2= ar->winrct.xmin + 2*AZONEPAD_ICON;
- az->y2= ar->winrct.ymin - AZONEPAD_ICON;
- }
- else if(az->edge=='l') {
- az->x1= ar->winrct.xmin - 2*AZONEPAD_ICON;
- az->y1= ar->winrct.ymax - tot*2*AZONEPAD_ICON;
- az->x2= ar->winrct.xmin - AZONEPAD_ICON;
- az->y2= ar->winrct.ymax - tot*AZONEPAD_ICON;
- }
- else { // if(az->edge=='r') {
- az->x1= ar->winrct.xmax + AZONEPAD_ICON;
- az->y1= ar->winrct.ymax - tot*2*AZONEPAD_ICON;
- az->x2= ar->winrct.xmax + 2*AZONEPAD_ICON;
- az->y2= ar->winrct.ymax - tot*AZONEPAD_ICON;
+ switch(az->edge) {
+ case AE_TOP_TO_BOTTOMRIGHT:
+ az->x1= ar->winrct.xmax - tot*2*AZONEPAD_ICON;
+ az->y1= ar->winrct.ymax + AZONEPAD_ICON;
+ az->x2= ar->winrct.xmax - tot*AZONEPAD_ICON;
+ az->y2= ar->winrct.ymax + 2*AZONEPAD_ICON;
+ break;
+ case AE_BOTTOM_TO_TOPLEFT:
+ az->x1= ar->winrct.xmin + AZONEPAD_ICON;
+ az->y1= ar->winrct.ymin - 2*AZONEPAD_ICON;
+ az->x2= ar->winrct.xmin + 2*AZONEPAD_ICON;
+ az->y2= ar->winrct.ymin - AZONEPAD_ICON;
+ break;
+ case AE_LEFT_TO_TOPRIGHT:
+ az->x1= ar->winrct.xmin - 2*AZONEPAD_ICON;
+ az->y1= ar->winrct.ymax - tot*2*AZONEPAD_ICON;
+ az->x2= ar->winrct.xmin - AZONEPAD_ICON;
+ az->y2= ar->winrct.ymax - tot*AZONEPAD_ICON;
+ break;
+ case AE_RIGHT_TO_TOPLEFT:
+ az->x1= ar->winrct.xmax + AZONEPAD_ICON;
+ az->y1= ar->winrct.ymax - tot*2*AZONEPAD_ICON;
+ az->x2= ar->winrct.xmax + 2*AZONEPAD_ICON;
+ az->y2= ar->winrct.ymax - tot*AZONEPAD_ICON;
+ break;
}
BLI_init_rcti(&az->rect, az->x1, az->x2, az->y1, az->y2);
@@ -537,22 +552,21 @@ static void region_azone_icon(ScrArea *sa, AZone *az, ARegion *ar)
for(azt= sa->actionzones.first; azt; azt= azt->next) {
if(az!=azt) {
if( ABS(az->x1-azt->x1) < 2 && ABS(az->y1-azt->y1) < 2) {
- if(az->edge=='t' || az->edge=='b') {
+ if(az->edge==AE_TOP_TO_BOTTOMRIGHT || az->edge==AE_BOTTOM_TO_TOPLEFT) {
az->x1+= AZONESPOT;
az->x2+= AZONESPOT;
- BLI_init_rcti(&az->rect, az->x1, az->x2, az->y1, az->y2);
}
- else {
+ else{
az->y1-= AZONESPOT;
az->y2-= AZONESPOT;
- BLI_init_rcti(&az->rect, az->x1, az->x2, az->y1, az->y2);
}
+ BLI_init_rcti(&az->rect, az->x1, az->x2, az->y1, az->y2);
}
}
}
}
-static void region_azone_initialize(ScrArea *sa, ARegion *ar, char edge)
+static void region_azone_initialize(ScrArea *sa, ARegion *ar, AZEdge edge)
{
AZone *az;
@@ -575,17 +589,16 @@ static void region_azone_initialize(ScrArea *sa, ARegion *ar, char edge)
static void region_azone_add(ScrArea *sa, ARegion *ar, int alignment)
{
- /* edge code (t b l r) is where azone will be drawn */
+ /* edge code (t b l r) is along which area edge azone will be drawn */
if(alignment==RGN_ALIGN_TOP)
- region_azone_initialize(sa, ar, 'b');
+ region_azone_initialize(sa, ar, AE_BOTTOM_TO_TOPLEFT);
else if(alignment==RGN_ALIGN_BOTTOM)
- region_azone_initialize(sa, ar, 't');
+ region_azone_initialize(sa, ar, AE_TOP_TO_BOTTOMRIGHT);
else if(ELEM(alignment, RGN_ALIGN_RIGHT, RGN_OVERLAP_RIGHT))
- region_azone_initialize(sa, ar, 'l');
+ region_azone_initialize(sa, ar, AE_LEFT_TO_TOPRIGHT);
else if(ELEM(alignment, RGN_ALIGN_LEFT, RGN_OVERLAP_LEFT))
- region_azone_initialize(sa, ar, 'r');
-
+ region_azone_initialize(sa, ar, AE_RIGHT_TO_TOPLEFT);
}
/* dir is direction to check, not the splitting edge direction! */
@@ -812,7 +825,7 @@ static void area_calc_totrct(ScrArea *sa, int sizex, int sizey)
/* used for area initialize below */
-static void region_subwindow(wmWindowManager *wm, wmWindow *win, ARegion *ar)
+static void region_subwindow(wmWindow *win, ARegion *ar)
{
if(ar->flag & (RGN_FLAG_HIDDEN|RGN_FLAG_TOO_SMALL)) {
if(ar->swinid)
@@ -903,7 +916,7 @@ void ED_area_initialize(wmWindowManager *wm, wmWindow *win, ScrArea *sa)
/* region windows, default and own handlers */
for(ar= sa->regionbase.first; ar; ar= ar->next) {
- region_subwindow(wm, win, ar);
+ region_subwindow(win, ar);
if(ar->swinid) {
/* default region handlers */
@@ -926,7 +939,7 @@ void ED_region_init(bContext *C, ARegion *ar)
// ARegionType *at= ar->type;
/* refresh can be called before window opened */
- region_subwindow(CTX_wm_manager(C), CTX_wm_window(C), ar);
+ region_subwindow(CTX_wm_window(C), ar);
ar->winx= ar->winrct.xmax - ar->winrct.xmin + 1;
ar->winy= ar->winrct.ymax - ar->winrct.ymin + 1;
@@ -941,7 +954,6 @@ void ED_region_toggle_hidden(bContext *C, ARegion *ar)
ScrArea *sa= CTX_wm_area(C);
ar->flag ^= RGN_FLAG_HIDDEN;
- ar->v2d.flag &= ~V2D_IS_INITIALISED; /* XXX should become hide/unhide api? */
if(ar->flag & RGN_FLAG_HIDDEN)
WM_event_remove_handlers(C, &ar->handlers);
@@ -1085,23 +1097,18 @@ void ED_area_newspace(bContext *C, ScrArea *sa, int type)
/*send space change notifyer*/
WM_event_add_notifier(C, NC_SPACE|ND_SPACE_CHANGED, sa);
-
- ED_area_tag_redraw(sa);
+
ED_area_tag_refresh(sa);
}
+
+ /* also redraw when re-used */
+ ED_area_tag_redraw(sa);
}
void ED_area_prevspace(bContext *C, ScrArea *sa)
{
SpaceLink *sl = (sa) ? sa->spacedata.first : CTX_wm_space_data(C);
- /* Special handling of filebrowser to stop background thread for
- thumbnail creation - don't want to waste cpu resources if not showing
- the filebrowser */
- if (sl->spacetype == SPACE_FILE) {
- ED_fileselect_exit(C, (SpaceFile*)sl);
- }
-
if(sl->next) {
/* workaround for case of double prevspace, render window
with a file browser on top of it */
@@ -1119,7 +1126,7 @@ void ED_area_prevspace(bContext *C, ScrArea *sa)
WM_event_add_notifier(C, NC_SPACE|ND_SPACE_CHANGED, sa);
}
-static char *editortype_pup(void)
+static const char *editortype_pup(void)
{
return(
"Editor type:%t"
@@ -1154,11 +1161,11 @@ static char *editortype_pup(void)
"|%l"
- "|Console %x18"
+ "|Python Console %x18"
);
}
-static void spacefunc(struct bContext *C, void *arg1, void *arg2)
+static void spacefunc(struct bContext *C, void *UNUSED(arg1), void *UNUSED(arg2))
{
ED_area_newspace(C, CTX_wm_area(C), CTX_wm_area(C)->butspacetype);
ED_area_tag_redraw(CTX_wm_area(C));
@@ -1216,7 +1223,7 @@ int ED_area_header_standardbuttons(const bContext *C, uiBlock *block, int yco)
/************************ standard UI regions ************************/
-void ED_region_panels(const bContext *C, ARegion *ar, int vertical, char *context, int contextnr)
+void ED_region_panels(const bContext *C, ARegion *ar, int vertical, const char *context, int contextnr)
{
ScrArea *sa= CTX_wm_area(C);
uiStyle *style= U.uistyles.first;
@@ -1246,7 +1253,7 @@ void ED_region_panels(const bContext *C, ARegion *ar, int vertical, char *contex
uiBeginPanels(C, ar);
/* set view2d view matrix for scrolling (without scrollers) */
- UI_view2d_view_ortho(C, v2d);
+ UI_view2d_view_ortho(v2d);
for(pt= ar->type->paneltypes.first; pt; pt= pt->next) {
/* verify context */
@@ -1277,6 +1284,9 @@ void ED_region_panels(const bContext *C, ARegion *ar, int vertical, char *contex
panel->labelofs= xco - triangle;
panel->layout= NULL;
}
+ else {
+ panel->labelofs= 0;
+ }
if(open) {
short panelContext;
@@ -1367,7 +1377,7 @@ void ED_region_panels(const bContext *C, ARegion *ar, int vertical, char *contex
UI_view2d_totRect_set(v2d, x+V2D_SCROLL_WIDTH, y+V2D_SCROLL_HEIGHT);
/* set the view */
- UI_view2d_view_ortho(C, v2d);
+ UI_view2d_view_ortho(v2d);
/* this does the actual drawing! */
uiEndPanels(C, ar);
@@ -1416,7 +1426,7 @@ void ED_region_header(const bContext *C, ARegion *ar)
glClear(GL_COLOR_BUFFER_BIT);
/* set view2d view matrix for scrolling (without scrollers) */
- UI_view2d_view_ortho(C, &ar->v2d);
+ UI_view2d_view_ortho(&ar->v2d);
xco= maxco= 8;
yco= HEADERY-3;
diff --git a/source/blender/editors/screen/glutil.c b/source/blender/editors/screen/glutil.c
index 06da91c3e37..ce96df5d3b1 100644
--- a/source/blender/editors/screen/glutil.c
+++ b/source/blender/editors/screen/glutil.c
@@ -1,4 +1,4 @@
-/**
+/*
* $Id$
*
* ***** BEGIN GPL LICENSE BLOCK *****
@@ -26,14 +26,14 @@
*/
#include <stdio.h>
-#include <math.h>
#include <string.h>
#include "MEM_guardedalloc.h"
#include "DNA_vec_types.h"
-#include "BKE_utildefines.h"
+#include "BLI_utildefines.h"
+
#include "BKE_colortools.h"
#include "BLI_math.h"
@@ -527,7 +527,8 @@ void glaDrawPixelsTex(float x, float y, int img_w, int img_h, int format, void *
glaDrawPixelsTexScaled(x, y, img_w, img_h, format, rect, 1.0f, 1.0f);
}
-void glaDrawPixelsSafe_to32(float fx, float fy, int img_w, int img_h, int row_w, float *rectf, int gamma_correct)
+/* row_w is unused but kept for completeness */
+void glaDrawPixelsSafe_to32(float fx, float fy, int img_w, int img_h, int UNUSED(row_w), float *rectf, int do_gamma_correct)
{
unsigned char *rect32;
@@ -536,7 +537,7 @@ void glaDrawPixelsSafe_to32(float fx, float fy, int img_w, int img_h, int row_w,
rect32= MEM_mallocN(img_w*img_h*sizeof(int), "temp 32 bits");
- if (gamma_correct) {
+ if (do_gamma_correct) {
floatbuf_to_srgb_byte(rectf, rect32, 0, img_w, 0, img_h, img_w);
} else {
floatbuf_to_byte(rectf, rect32, 0, img_w, 0, img_h, img_w);
@@ -764,15 +765,15 @@ void bglBegin(int mode)
}
}
-int bglPointHack() {
+int bglPointHack(void) {
float value[4];
- int pointhack;
+ int pointhack_px;
glGetFloatv(GL_POINT_SIZE_RANGE, value);
if(value[1]<2.0) {
glGetFloatv(GL_POINT_SIZE, value);
- pointhack= floor(value[0]+0.5);
- if(pointhack>4) pointhack= 4;
- return pointhack;
+ pointhack_px= floor(value[0]+0.5);
+ if(pointhack_px>4) pointhack_px= 4;
+ return pointhack_px;
}
return 0;
}
diff --git a/source/blender/editors/screen/screen_context.c b/source/blender/editors/screen/screen_context.c
index fbc83b1de65..754d75fe9a5 100644
--- a/source/blender/editors/screen/screen_context.c
+++ b/source/blender/editors/screen/screen_context.c
@@ -1,4 +1,4 @@
-/**
+/*
* $Id$
*
* ***** BEGIN GPL LICENSE BLOCK *****
@@ -33,9 +33,13 @@
#include "DNA_scene_types.h"
#include "DNA_screen_types.h"
+#include "BLI_utildefines.h"
+
+
#include "BKE_context.h"
-#include "BKE_utildefines.h"
+#include "BKE_object.h"
#include "BKE_action.h"
+#include "BKE_armature.h"
#include "BKE_sequencer.h"
#include "RNA_access.h"
@@ -43,11 +47,26 @@
#include "ED_object.h"
#include "ED_armature.h"
+#include "screen_intern.h"
+
+const char *screen_context_dir[] = {
+ "scene", "visible_objects", "visible_bases", "selectable_objects", "selectable_bases",
+ "selected_objects", "selected_bases",
+ "selected_editable_objects", "selected_editable_bases",
+ "visible_bones", "editable_bones", "selected_bones", "selected_editable_bones",
+ "visible_pose_bones", "selected_pose_bones", "active_bone", "active_pose_bone",
+ "active_base", "active_object", "object", "edit_object",
+ "sculpt_object", "vertex_paint_object", "weight_paint_object",
+ "texture_paint_object", "particle_edit_object",
+ "sequences", "selected_sequences", "selected_editable_sequences", /* sequencer */
+ NULL};
+
int ed_screen_context(const bContext *C, const char *member, bContextDataResult *result)
{
bScreen *sc= CTX_wm_screen(C);
Scene *scene= sc->scene;
Base *base;
+ unsigned int lay = scene->lay;
#if 0 /* Using the context breaks adding objects in the UI. Need to find out why - campbell */
Object *obact= CTX_data_active_object(C);
@@ -60,18 +79,7 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult
#endif
if(CTX_data_dir(member)) {
- static const char *dir[] = {
- "scene", "visible_objects", "visible_bases", "selected_objects", "selected_bases",
- "selected_editable_objects", "selected_editable_bases",
- "visible_bones", "editable_bones", "selected_bones", "selected_editable_bones",
- "visible_pose_bones", "selected_pose_bones", "active_bone", "active_pose_bone",
- "active_base", "active_object", "object", "edit_object",
- "sculpt_object", "vertex_paint_object", "weight_paint_object",
- "texture_paint_object", "particle_edit_object",
- "sequences", "selected_sequences", "selected_editable_sequences", /* sequencer */
- NULL};
-
- CTX_data_dir_set(result, dir);
+ CTX_data_dir_set(result, screen_context_dir);
return 1;
}
else if(CTX_data_equals(member, "scene")) {
@@ -92,6 +100,22 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult
CTX_data_type_set(result, CTX_DATA_TYPE_COLLECTION);
return 1;
}
+ else if(CTX_data_equals(member, "selectable_objects") || CTX_data_equals(member, "selectable_bases")) {
+ int selectable_objects= CTX_data_equals(member, "selectable_objects");
+
+ for(base=scene->base.first; base; base=base->next) {
+ if(base->lay & lay) {
+ if((base->object->restrictflag & OB_RESTRICT_VIEW)==0 && (base->object->restrictflag & OB_RESTRICT_SELECT)==0) {
+ if(selectable_objects)
+ CTX_data_id_list_add(result, &base->object->id);
+ else
+ CTX_data_list_add(result, &scene->id, &RNA_ObjectBase, base);
+ }
+ }
+ }
+ CTX_data_type_set(result, CTX_DATA_TYPE_COLLECTION);
+ return 1;
+ }
else if(CTX_data_equals(member, "selected_objects") || CTX_data_equals(member, "selected_bases")) {
int selected_objects= CTX_data_equals(member, "selected_objects");
@@ -209,14 +233,15 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult
}
}
else if(CTX_data_equals(member, "visible_pose_bones")) {
- bArmature *arm= (obact) ? obact->data : NULL;
+ Object *obpose= ED_object_pose_armature(obact);
+ bArmature *arm= (obpose) ? obpose->data : NULL;
bPoseChannel *pchan;
- if (obact && obact->pose && arm) {
- for (pchan= obact->pose->chanbase.first; pchan; pchan= pchan->next) {
+ if (obpose && obpose->pose && arm) {
+ for (pchan= obpose->pose->chanbase.first; pchan; pchan= pchan->next) {
/* ensure that PoseChannel is on visible layer and is not hidden in PoseMode */
- if ((pchan->bone) && (arm->layer & pchan->bone->layer) && !(pchan->bone->flag & BONE_HIDDEN_P)) {
- CTX_data_list_add(result, &obact->id, &RNA_PoseBone, pchan);
+ if (PBONE_VISIBLE(arm, pchan->bone)) {
+ CTX_data_list_add(result, &obpose->id, &RNA_PoseBone, pchan);
}
}
CTX_data_type_set(result, CTX_DATA_TYPE_COLLECTION);
@@ -224,15 +249,16 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult
}
}
else if(CTX_data_equals(member, "selected_pose_bones")) {
- bArmature *arm= (obact) ? obact->data : NULL;
+ Object *obpose= ED_object_pose_armature(obact);
+ bArmature *arm= (obpose) ? obpose->data : NULL;
bPoseChannel *pchan;
- if (obact && obact->pose && arm) {
- for (pchan= obact->pose->chanbase.first; pchan; pchan= pchan->next) {
+ if (obpose && obpose->pose && arm) {
+ for (pchan= obpose->pose->chanbase.first; pchan; pchan= pchan->next) {
/* ensure that PoseChannel is on visible layer and is not hidden in PoseMode */
- if ((pchan->bone) && (arm->layer & pchan->bone->layer) && !(pchan->bone->flag & BONE_HIDDEN_P)) {
- if (pchan->bone->flag & BONE_SELECTED || pchan->bone == arm->act_bone)
- CTX_data_list_add(result, &obact->id, &RNA_PoseBone, pchan);
+ if (PBONE_VISIBLE(arm, pchan->bone)) {
+ if (pchan->bone->flag & BONE_SELECTED)
+ CTX_data_list_add(result, &obpose->id, &RNA_PoseBone, pchan);
}
}
CTX_data_type_set(result, CTX_DATA_TYPE_COLLECTION);
@@ -258,10 +284,11 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult
}
else if(CTX_data_equals(member, "active_pose_bone")) {
bPoseChannel *pchan;
+ Object *obpose= ED_object_pose_armature(obact);
- pchan= get_active_posechannel(obact);
+ pchan= get_active_posechannel(obpose);
if (pchan) {
- CTX_data_pointer_set(result, &obact->id, &RNA_PoseBone, pchan);
+ CTX_data_pointer_set(result, &obpose->id, &RNA_PoseBone, pchan);
return 1;
}
}
diff --git a/source/blender/editors/screen/screen_edit.c b/source/blender/editors/screen/screen_edit.c
index 8874c5d1bc8..f2f11f42204 100644
--- a/source/blender/editors/screen/screen_edit.c
+++ b/source/blender/editors/screen/screen_edit.c
@@ -1,4 +1,4 @@
-/**
+/*
* $Id$
*
* ***** BEGIN GPL LICENSE BLOCK *****
@@ -34,6 +34,7 @@
#include "DNA_userdef_types.h"
#include "BLI_blenlib.h"
+#include "BLI_utildefines.h"
#include "BKE_context.h"
#include "BKE_global.h"
@@ -53,6 +54,7 @@
#include "ED_object.h"
#include "ED_screen.h"
#include "ED_screen_types.h"
+#include "ED_fileselect.h"
#include "UI_interface.h"
@@ -308,7 +310,7 @@ static void screen_delarea(bContext *C, bScreen *sc, ScrArea *sa)
/* return 0: no split possible */
/* else return (integer) screencoordinate split point */
-static short testsplitpoint(wmWindow *win, ScrArea *sa, char dir, float fac)
+static short testsplitpoint(ScrArea *sa, char dir, float fac)
{
short x, y;
@@ -344,7 +346,7 @@ static short testsplitpoint(wmWindow *win, ScrArea *sa, char dir, float fac)
}
}
-ScrArea *area_split(wmWindow *win, bScreen *sc, ScrArea *sa, char dir, float fac)
+ScrArea *area_split(bScreen *sc, ScrArea *sa, char dir, float fac, int merge)
{
ScrArea *newa=NULL;
ScrVert *sv1, *sv2;
@@ -352,7 +354,7 @@ ScrArea *area_split(wmWindow *win, bScreen *sc, ScrArea *sa, char dir, float fac
if(sa==NULL) return NULL;
- split= testsplitpoint(win, sa, dir, fac);
+ split= testsplitpoint(sa, dir, fac);
if(split==0) return NULL;
if(dir=='h') {
@@ -398,7 +400,8 @@ ScrArea *area_split(wmWindow *win, bScreen *sc, ScrArea *sa, char dir, float fac
}
/* remove double vertices en edges */
- removedouble_scrverts(sc);
+ if(merge)
+ removedouble_scrverts(sc);
removedouble_scredges(sc);
removenotused_scredges(sc);
@@ -407,7 +410,7 @@ ScrArea *area_split(wmWindow *win, bScreen *sc, ScrArea *sa, char dir, float fac
/* empty screen, with 1 dummy area without spacedata */
/* uses window size */
-bScreen *ED_screen_add(wmWindow *win, Scene *scene, char *name)
+bScreen *ED_screen_add(wmWindow *win, Scene *scene, const char *name)
{
bScreen *sc;
ScrVert *sv1, *sv2, *sv3, *sv4;
@@ -415,6 +418,7 @@ bScreen *ED_screen_add(wmWindow *win, Scene *scene, char *name)
sc= alloc_libblock(&G.main->screen, ID_SCR, name);
sc->scene= scene;
sc->do_refresh= 1;
+ sc->redraws_flag= TIME_ALL_3D_WIN|TIME_ALL_ANIM_WIN;
sc->winid= win->winid;
sv1= screen_addvert(sc, 0, 0);
@@ -483,7 +487,7 @@ static void screen_copy(bScreen *to, bScreen *from)
/* with sa as center, sb is located at: 0=W, 1=N, 2=E, 3=S */
/* -1 = not valid check */
/* used with join operator */
-int area_getorientation(bScreen *screen, ScrArea *sa, ScrArea *sb)
+int area_getorientation(ScrArea *sa, ScrArea *sb)
{
ScrVert *sav1, *sav2, *sav3, *sav4;
ScrVert *sbv1, *sbv2, *sbv3, *sbv4;
@@ -522,7 +526,7 @@ int screen_area_join(bContext *C, bScreen* scr, ScrArea *sa1, ScrArea *sa2)
{
int dir;
- dir = area_getorientation(scr, sa1, sa2);
+ dir = area_getorientation(sa1, sa2);
/*printf("dir is : %i \n", dir);*/
if (dir < 0)
@@ -642,18 +646,20 @@ static void screen_test_scale(bScreen *sc, int winsizex, int winsizey)
/* make sure it fits! */
for(sv= sc->vertbase.first; sv; sv= sv->next) {
+ /* FIXME, this resizing logic is no good when resizing the window + redrawing [#24428]
+ * need some way to store these as floats internally and re-apply from there. */
tempf= ((float)sv->vec.x)*facx;
sv->vec.x= (short)(tempf+0.5);
sv->vec.x+= AREAGRID-1;
sv->vec.x-= (sv->vec.x % AREAGRID);
-
+
CLAMP(sv->vec.x, 0, winsizex);
- tempf= ((float)sv->vec.y )*facy;
+ tempf= ((float)sv->vec.y)*facy;
sv->vec.y= (short)(tempf+0.5);
sv->vec.y+= AREAGRID-1;
sv->vec.y-= (sv->vec.y % AREAGRID);
-
+
CLAMP(sv->vec.y, 0, winsizey);
}
}
@@ -860,7 +866,7 @@ static void scrarea_draw_shape_dark(ScrArea *sa, char dir)
}
/* draw screen area ligher with arrow shape ("eraser" of previous dark shape) */
-static void scrarea_draw_shape_light(ScrArea *sa, char dir)
+static void scrarea_draw_shape_light(ScrArea *sa, char UNUSED(dir))
{
glBlendFunc(GL_DST_COLOR, GL_SRC_ALPHA);
glEnable(GL_BLEND);
@@ -992,7 +998,7 @@ void ED_screen_draw(wmWindow *win)
/* blended join arrow */
if (sa1 && sa2) {
- dir = area_getorientation(win->screen, sa1, sa2);
+ dir = area_getorientation(sa1, sa2);
if (dir >= 0) {
switch(dir) {
case 0: /* W */
@@ -1024,27 +1030,35 @@ void ED_screen_draw(wmWindow *win)
/* make this screen usable */
/* for file read and first use, for scaling window, area moves */
void ED_screen_refresh(wmWindowManager *wm, wmWindow *win)
-{
- ScrArea *sa;
- rcti winrct= {0, win->sizex-1, 0, win->sizey-1};
-
- screen_test_scale(win->screen, win->sizex, win->sizey);
+{
+ /* exception for bg mode, we only need the screen context */
+ if (!G.background) {
+ ScrArea *sa;
+ rcti winrct;
- if(win->screen->mainwin==0)
- win->screen->mainwin= wm_subwindow_open(win, &winrct);
- else
- wm_subwindow_position(win, win->screen->mainwin, &winrct);
+ winrct.xmin= 0;
+ winrct.xmax= win->sizex-1;
+ winrct.ymin= 0;
+ winrct.ymax= win->sizey-1;
+
+ screen_test_scale(win->screen, win->sizex, win->sizey);
+
+ if(win->screen->mainwin==0)
+ win->screen->mainwin= wm_subwindow_open(win, &winrct);
+ else
+ wm_subwindow_position(win, win->screen->mainwin, &winrct);
+
+ for(sa= win->screen->areabase.first; sa; sa= sa->next) {
+ /* set spacetype and region callbacks, calls init() */
+ /* sets subwindows for regions, adds handlers */
+ ED_area_initialize(wm, win, sa);
+ }
- for(sa= win->screen->areabase.first; sa; sa= sa->next) {
- /* set spacetype and region callbacks, calls init() */
- /* sets subwindows for regions, adds handlers */
- ED_area_initialize(wm, win, sa);
+ /* wake up animtimer */
+ if(win->screen->animtimer)
+ WM_event_timer_sleep(wm, win, win->screen->animtimer, 0);
}
- /* wake up animtimer */
- if(win->screen->animtimer)
- WM_event_timer_sleep(wm, win, win->screen->animtimer, 0);
-
if(G.f & G_DEBUG) printf("set screen\n");
win->screen->do_refresh= 0;
@@ -1090,6 +1104,10 @@ void ED_area_exit(bContext *C, ScrArea *sa)
ScrArea *prevsa= CTX_wm_area(C);
ARegion *ar;
+ if (sa->spacetype == SPACE_FILE) {
+ ED_fileselect_exit(C, (SpaceFile*)(sa) ? sa->spacedata.first : CTX_wm_space_data(C));
+ }
+
CTX_wm_area_set(C, sa);
for(ar= sa->regionbase.first; ar; ar= ar->next)
ED_region_exit(C, ar);
@@ -1125,8 +1143,7 @@ void ED_screen_exit(bContext *C, wmWindow *window, bScreen *screen)
/* mark it available for use for other windows */
screen->winid= 0;
- /* before deleting the temp screen or we get invalid access */
- if (prevwin->screen->full != SCREENTEMP) {
+ if (prevwin->screen->temp == 0) {
/* use previous window if possible */
CTX_wm_window_set(C, prevwin);
} else {
@@ -1134,11 +1151,6 @@ void ED_screen_exit(bContext *C, wmWindow *window, bScreen *screen)
CTX_wm_window_set(C, NULL);
}
- /* if temp screen, delete it */
- if(screen->full == SCREENTEMP) {
- Main *bmain= CTX_data_main(C);
- free_libblock(&bmain->screen, screen);
- }
}
/* *********************************** */
@@ -1157,7 +1169,7 @@ static void screen_cursor_set(wmWindow *win, wmEvent *event)
if(az->type==AZONE_AREA)
WM_cursor_set(win, CURSOR_EDIT);
else if(az->type==AZONE_REGION) {
- if(az->edge == 'l' || az->edge == 'r')
+ if(az->edge == AE_LEFT_TO_TOPRIGHT || az->edge == AE_RIGHT_TO_TOPLEFT)
WM_cursor_set(win, CURSOR_X_MOVE);
else
WM_cursor_set(win, CURSOR_Y_MOVE);
@@ -1307,6 +1319,7 @@ void ED_screen_set(bContext *C, bScreen *sc)
ED_screen_refresh(CTX_wm_manager(C), CTX_wm_window(C));
WM_event_add_notifier(C, NC_WINDOW, NULL);
+ WM_event_add_notifier(C, NC_SCREEN|ND_SCREENSET, sc);
/* makes button hilites work */
WM_event_add_mousemove(C);
@@ -1426,7 +1439,7 @@ void ED_screen_set_scene(bContext *C, Scene *scene)
CTX_data_scene_set(C, scene);
set_scene_bg(CTX_data_main(C), scene);
- ED_update_for_newframe(C, 1);
+ ED_update_for_newframe(CTX_data_main(C), scene, curscreen, 1);
/* complete redraw */
WM_event_add_notifier(C, NC_WINDOW, NULL);
@@ -1500,8 +1513,18 @@ void ED_screen_full_restore(bContext *C, ScrArea *sa)
if (sl->next) {
/* specific checks for space types */
+
+ int sima_restore = 0;
+
+ /* Special check added for non-render image window (back from fullscreen through "Back to Previous" button) */
if (sl->spacetype == SPACE_IMAGE) {
SpaceImage *sima= sa->spacedata.first;
+ if (!(sima->flag & SI_PREVSPACE) && !(sima->flag & SI_FULLWINDOW))
+ sima_restore = 1;
+ }
+
+ if (sl->spacetype == SPACE_IMAGE && !sima_restore) {
+ SpaceImage *sima= sa->spacedata.first;
if (sima->flag & SI_PREVSPACE)
sima->flag &= ~SI_PREVSPACE;
if (sima->flag & SI_FULLWINDOW) {
@@ -1534,46 +1557,39 @@ ScrArea *ED_screen_full_toggle(bContext *C, wmWindow *win, ScrArea *sa)
}
if(sa && sa->full) {
+ ScrArea *old;
short fulltype;
sc= sa->full; /* the old screen to restore */
oldscreen= win->screen; /* the one disappearing */
fulltype = sc->full;
+ sc->full= 0;
- /* refuse to go out of SCREENAUTOPLAY as long as G_FLAGS_AUTOPLAY
- is set */
-
- if (fulltype != SCREENAUTOPLAY || (G.flags & G_FILE_AUTOPLAY) == 0) {
- ScrArea *old;
-
- sc->full= 0;
+ /* removed: SCREENAUTOPLAY exception here */
+
+ /* find old area */
+ for(old= sc->areabase.first; old; old= old->next)
+ if(old->full) break;
+ if(old==NULL) {
+ if (G.f & G_DEBUG)
+ printf("something wrong in areafullscreen\n");
+ return NULL;
+ }
- /* find old area */
- for(old= sc->areabase.first; old; old= old->next)
- if(old->full) break;
- if(old==NULL) {
- if (G.f & G_DEBUG)
- printf("something wrong in areafullscreen\n");
- return NULL;
- }
- // old feature described below (ton)
- // in autoplay screens the headers are disabled by
- // default. So use the old headertype instead
+ area_copy_data(old, sa, 1); /* 1 = swap spacelist */
+ if (sa->flag & AREA_TEMP_INFO) sa->flag &= ~AREA_TEMP_INFO;
+ old->full= NULL;
- area_copy_data(old, sa, 1); /* 1 = swap spacelist */
- if (sa->flag & AREA_TEMP_INFO) sa->flag &= ~AREA_TEMP_INFO;
- old->full= NULL;
+ /* animtimer back */
+ sc->animtimer= oldscreen->animtimer;
+ oldscreen->animtimer= NULL;
- /* animtimer back */
- sc->animtimer= oldscreen->animtimer;
- oldscreen->animtimer= NULL;
+ ED_screen_set(C, sc);
- ED_screen_set(C, sc);
+ free_screen(oldscreen);
+ free_libblock(&CTX_data_main(C)->screen, oldscreen);
- free_screen(oldscreen);
- free_libblock(&CTX_data_main(C)->screen, oldscreen);
- }
}
else {
ScrArea *newa;
@@ -1588,7 +1604,7 @@ ScrArea *ED_screen_full_toggle(bContext *C, wmWindow *win, ScrArea *sa)
*/
oldscreen->full = SCREENFULL;
- BLI_snprintf(newname, sizeof(newname), "%s-%s", oldscreen->id.name+2, "temp");
+ BLI_snprintf(newname, sizeof(newname), "%s-%s", oldscreen->id.name+2, "full");
sc= ED_screen_add(win, oldscreen->scene, newname);
sc->full = SCREENFULL; // XXX
@@ -1597,7 +1613,7 @@ ScrArea *ED_screen_full_toggle(bContext *C, wmWindow *win, ScrArea *sa)
oldscreen->animtimer= NULL;
/* returns the top small area */
- newa= area_split(win, sc, (ScrArea *)sc->areabase.first, 'h', 0.99f);
+ newa= area_split(sc, (ScrArea *)sc->areabase.first, 'h', 0.99f, 1);
ED_area_newspace(C, newa, SPACE_INFO);
/* use random area when we have no active one, e.g. when the
@@ -1722,20 +1738,17 @@ void ED_screen_animation_timer_update(bScreen *screen, int redraws, int refresh)
}
}
-/* results in fully updated anim system */
-void ED_update_for_newframe(const bContext *C, int mute)
-{
- Main *bmain= CTX_data_main(C);
- bScreen *screen= CTX_wm_screen(C);
- Scene *scene= CTX_data_scene(C);
-
+/* results in fully updated anim system
+ * screen can be NULL */
+void ED_update_for_newframe(Main *bmain, Scene *scene, bScreen *screen, int UNUSED(mute))
+{
#ifdef DURIAN_CAMERA_SWITCH
void *camera= scene_camera_switch_find(scene);
if(camera && scene->camera != camera) {
bScreen *sc;
scene->camera= camera;
/* are there cameras in the views that are not in the scene? */
- for(sc= CTX_data_main(C)->screen.first; sc; sc= sc->id.next) {
+ for(sc= bmain->screen.first; sc; sc= sc->id.next) {
BKE_screen_view3d_scene_sync(sc);
}
}
@@ -1745,7 +1758,7 @@ void ED_update_for_newframe(const bContext *C, int mute)
/* update animated image textures for gpu, etc,
* call before scene_update_for_newframe so modifiers with textuers dont lag 1 frame */
- ED_image_update_frame(C);
+ ED_image_update_frame(bmain, scene->r.cfra);
/* this function applies the changes too */
/* XXX future: do all windows */
@@ -1767,7 +1780,7 @@ void ED_update_for_newframe(const bContext *C, int mute)
/* update animated texture nodes */
{
Tex *tex;
- for(tex= CTX_data_main(C)->tex.first; tex; tex= tex->id.next)
+ for(tex= bmain->tex.first; tex; tex= tex->id.next)
if( tex->use_nodes && tex->nodetree ) {
ntreeTexTagAnimated( tex->nodetree );
}
diff --git a/source/blender/editors/screen/screen_intern.h b/source/blender/editors/screen/screen_intern.h
index 79789b1876e..50a3159644d 100644
--- a/source/blender/editors/screen/screen_intern.h
+++ b/source/blender/editors/screen/screen_intern.h
@@ -1,4 +1,4 @@
-/**
+/*
* $Id$
*
* ***** BEGIN GPL LICENSE BLOCK *****
@@ -32,14 +32,16 @@
struct wmWindow;
struct Scene;
+#define AZONESPOT 12
+
/* area.c */
void area_copy_data (ScrArea *sa1, ScrArea *sa2, int swap_space);
/* screen_edit.c */
ScrEdge *screen_findedge(bScreen *sc, ScrVert *v1, ScrVert *v2);
-ScrArea *area_split(wmWindow *win, bScreen *sc, ScrArea *sa, char dir, float fac);
+ScrArea *area_split(bScreen *sc, ScrArea *sa, char dir, float fac, int merge);
int screen_area_join(bContext *C, bScreen* scr, ScrArea *sa1, ScrArea *sa2);
-int area_getorientation(bScreen *screen, ScrArea *sa, ScrArea *sb);
+int area_getorientation(ScrArea *sa, ScrArea *sb);
void select_connected_scredge(bScreen *sc, ScrEdge *edge);
void removenotused_scrverts(bScreen *sc);
@@ -49,10 +51,12 @@ void removenotused_scredges(bScreen *sc);
int scredge_is_horizontal(ScrEdge *se);
ScrEdge *screen_find_active_scredge(bScreen *sc, int mx, int my);
-AZone *is_in_area_actionzone(ScrArea *sa, int x, int y);
+struct AZone *is_in_area_actionzone(ScrArea *sa, int x, int y);
/* screen_context.c */
-void ed_screen_context(const bContext *C, const char *member, bContextDataResult *result);
+int ed_screen_context(const bContext *C, const char *member, bContextDataResult *result);
+
+extern const char *screen_context_dir[]; /* doc access */
/* screendump.c */
void SCREEN_OT_screenshot(struct wmOperatorType *ot);
diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c
index 2b9a929d4bf..2c9a11b2112 100644
--- a/source/blender/editors/screen/screen_ops.c
+++ b/source/blender/editors/screen/screen_ops.c
@@ -1,4 +1,4 @@
-/**
+/*
* $Id$
*
* ***** BEGIN GPL LICENSE BLOCK *****
@@ -33,6 +33,7 @@
#include "BLI_blenlib.h"
#include "BLI_editVert.h"
#include "BLI_dlrbTree.h"
+#include "BLI_utildefines.h"
#include "DNA_armature_types.h"
#include "DNA_lattice_types.h"
@@ -55,8 +56,10 @@
#include "WM_types.h"
#include "ED_util.h"
+#include "ED_image.h"
#include "ED_screen.h"
#include "ED_object.h"
+#include "ED_armature.h"
#include "ED_screen_types.h"
#include "ED_keyframes_draw.h"
@@ -64,6 +67,7 @@
#include "RNA_define.h"
#include "UI_interface.h"
+#include "UI_resources.h"
#include "wm_window.h"
@@ -116,6 +120,24 @@ int ED_operator_scene_editable(bContext *C)
return 0;
}
+int ED_operator_objectmode(bContext *C)
+{
+ Scene *scene= CTX_data_scene(C);
+ Object *obact= CTX_data_active_object(C);
+
+ if(scene==NULL || scene->id.lib)
+ return 0;
+ if( CTX_data_edit_object(C) )
+ return 0;
+
+ /* add a check for ob->mode too? */
+ if(obact && obact->mode)
+ return 0;
+
+ return 1;
+}
+
+
static int ed_spacetype_test(bContext *C, int type)
{
if(ED_operator_areaactive(C)) {
@@ -130,6 +152,28 @@ int ED_operator_view3d_active(bContext *C)
return ed_spacetype_test(C, SPACE_VIEW3D);
}
+int ED_operator_region_view3d_active(bContext *C)
+{
+ if(CTX_wm_region_view3d(C))
+ return TRUE;
+
+ CTX_wm_operator_poll_msg_set(C, "expected a view3d region");
+ return FALSE;
+}
+
+/* generic for any view2d which uses anim_ops */
+int ED_operator_animview_active(bContext *C)
+{
+ if(ED_operator_areaactive(C)) {
+ SpaceLink *sl= (SpaceLink *)CTX_wm_space_data(C);
+ if (sl && (ELEM6(sl->spacetype, SPACE_SEQ, SPACE_SOUND, SPACE_ACTION, SPACE_NLA, SPACE_IPO, SPACE_TIME)))
+ return TRUE;
+ }
+
+ CTX_wm_operator_poll_msg_set(C, "expected an timeline/animation area to be active");
+ return 0;
+}
+
int ED_operator_timeline_active(bContext *C)
{
return ed_spacetype_test(C, SPACE_TIME);
@@ -140,6 +184,19 @@ int ED_operator_outliner_active(bContext *C)
return ed_spacetype_test(C, SPACE_OUTLINER);
}
+int ED_operator_outliner_active_no_editobject(bContext *C)
+{
+ if(ed_spacetype_test(C, SPACE_OUTLINER)) {
+ Object *ob = ED_object_active_context(C);
+ Object *obedit= CTX_data_edit_object(C);
+ if(ob && ob == obedit)
+ return 0;
+ else
+ return 1;
+ }
+ return 0;
+}
+
int ED_operator_file_active(bContext *C)
{
return ed_spacetype_test(C, SPACE_FILE);
@@ -166,7 +223,7 @@ int ED_operator_node_active(bContext *C)
}
// XXX rename
-int ED_operator_ipo_active(bContext *C)
+int ED_operator_graphedit_active(bContext *C)
{
return ed_spacetype_test(C, SPACE_IPO);
}
@@ -191,15 +248,33 @@ int ED_operator_logic_active(bContext *C)
return ed_spacetype_test(C, SPACE_LOGIC);
}
+int ED_operator_info_active(bContext *C)
+{
+ return ed_spacetype_test(C, SPACE_INFO);
+}
+
+
+int ED_operator_console_active(bContext *C)
+{
+ return ed_spacetype_test(C, SPACE_CONSOLE);
+}
+
int ED_operator_object_active(bContext *C)
{
- return NULL != ED_object_active_context(C);
+ Object *ob = ED_object_active_context(C);
+ return ((ob != NULL) && !(ob->restrictflag & OB_RESTRICT_VIEW));
}
int ED_operator_object_active_editable(bContext *C)
{
Object *ob = ED_object_active_context(C);
- return ((ob != NULL) && !(ob->id.lib));
+ return ((ob != NULL) && !(ob->id.lib) && !(ob->restrictflag & OB_RESTRICT_VIEW));
+}
+
+int ED_operator_object_active_editable_mesh(bContext *C)
+{
+ Object *ob = ED_object_active_context(C);
+ return ((ob != NULL) && !(ob->id.lib) && !(ob->restrictflag & OB_RESTRICT_VIEW) && ob->type == OB_MESH);
}
int ED_operator_editmesh(bContext *C)
@@ -215,6 +290,15 @@ int ED_operator_editmesh_view3d(bContext *C)
return ED_operator_editmesh(C) && ED_operator_view3d_active(C);
}
+int ED_operator_editmesh_region_view3d(bContext *C)
+{
+ if(ED_operator_editmesh(C) && CTX_wm_region_view3d(C))
+ return 1;
+
+ CTX_wm_operator_poll_msg_set(C, "expected a view3d region & editmesh");
+ return 0;
+}
+
int ED_operator_editarmature(bContext *C)
{
Object *obedit= CTX_data_edit_object(C);
@@ -226,27 +310,26 @@ int ED_operator_editarmature(bContext *C)
int ED_operator_posemode(bContext *C)
{
Object *obact= CTX_data_active_object(C);
- Object *obedit= CTX_data_edit_object(C);
-
- if ((obact != obedit) && (obact) && (obact->type==OB_ARMATURE))
- return (obact->mode & OB_MODE_POSE)!=0;
-
+
+ if (obact && !(obact->mode & OB_MODE_EDIT)) {
+ Object *obpose;
+ if((obpose= ED_object_pose_armature(obact))) {
+ if((obact == obpose) || (obact->mode & OB_MODE_WEIGHT_PAINT)) {
+ return 1;
+ }
+ }
+ }
+
return 0;
}
-
+/* wrapper for ED_space_image_show_uvedit */
int ED_operator_uvedit(bContext *C)
{
+ SpaceImage *sima= CTX_wm_space_image(C);
Object *obedit= CTX_data_edit_object(C);
- BMEditMesh *em= NULL;
-
- if(obedit && obedit->type==OB_MESH)
- em= ((Mesh *)obedit->data)->edit_btmesh;
- if (em && em->bm->totface && CustomData_has_layer(&em->bm->pdata, CD_MTEXPOLY))
- return 1;
-
- return 0;
+ return ED_space_image_show_uvedit(sima, obedit);
}
int ED_operator_uvmap(bContext *C)
@@ -271,6 +354,14 @@ int ED_operator_editsurfcurve(bContext *C)
return 0;
}
+int ED_operator_editsurfcurve_region_view3d(bContext *C)
+{
+ if(ED_operator_editsurfcurve(C) && CTX_wm_region_view3d(C))
+ return 1;
+
+ CTX_wm_operator_poll_msg_set(C, "expected a view3d region & editcurve");
+ return 0;
+}
int ED_operator_editcurve(bContext *C)
{
@@ -381,7 +472,10 @@ AZone *is_in_area_actionzone(ScrArea *sa, int x, int y)
for(az= sa->actionzones.first; az; az= az->next) {
if(BLI_in_rcti(&az->rect, x, y)) {
if(az->type == AZONE_AREA) {
- if(isect_point_tri_v2_int(az->x1, az->y1, az->x2, az->y2, x, y))
+ /* no triangle intersect but a hotspot circle based on corner */
+ int radius= (x-az->x1)*(x-az->x1) + (y-az->y1)*(y-az->y1);
+
+ if(radius <= AZONESPOT*AZONESPOT)
break;
}
else if(az->type == AZONE_REGION) {
@@ -394,7 +488,7 @@ AZone *is_in_area_actionzone(ScrArea *sa, int x, int y)
}
-static void actionzone_exit(bContext *C, wmOperator *op)
+static void actionzone_exit(wmOperator *op)
{
if(op->customdata)
MEM_freeN(op->customdata);
@@ -440,7 +534,7 @@ static int actionzone_invoke(bContext *C, wmOperator *op, wmEvent *event)
/* region azone directly reacts on mouse clicks */
if(sad->az->type==AZONE_REGION) {
actionzone_apply(C, op, AZONE_REGION);
- actionzone_exit(C, op);
+ actionzone_exit(op);
return OPERATOR_FINISHED;
}
else {
@@ -480,16 +574,16 @@ static int actionzone_modal(bContext *C, wmOperator *op, wmEvent *event)
sad->sa2= screen_areahascursor(CTX_wm_screen(C), event->x, event->y);
/* apply sends event */
actionzone_apply(C, op, sad->az->type);
- actionzone_exit(C, op);
+ actionzone_exit(op);
return OPERATOR_FINISHED;
}
break;
case ESCKEY:
- actionzone_exit(C, op);
+ actionzone_exit(op);
return OPERATOR_CANCELLED;
case LEFTMOUSE:
- actionzone_exit(C, op);
+ actionzone_exit(op);
return OPERATOR_CANCELLED;
}
@@ -540,7 +634,7 @@ typedef struct sAreaSwapData {
ScrArea *sa1, *sa2;
} sAreaSwapData;
-static int area_swap_init(bContext *C, wmOperator *op, wmEvent *event)
+static int area_swap_init(wmOperator *op, wmEvent *event)
{
sAreaSwapData *sd= NULL;
sActionzoneData *sad= event->customdata;
@@ -574,7 +668,7 @@ static int area_swap_cancel(bContext *C, wmOperator *op)
static int area_swap_invoke(bContext *C, wmOperator *op, wmEvent *event)
{
- if(!area_swap_init(C, op, event))
+ if(!area_swap_init(op, event))
return OPERATOR_PASS_THROUGH;
/* add modal handler */
@@ -660,7 +754,7 @@ static int area_dupli_invoke(bContext *C, wmOperator *op, wmEvent *event)
/* poll() checks area context, but we don't accept full-area windows */
if(sc->full != SCREENNORMAL) {
if(event->type==EVT_ACTIONZONE_AREA)
- actionzone_exit(C, op);
+ actionzone_exit(op);
return OPERATOR_CANCELLED;
}
@@ -682,7 +776,7 @@ static int area_dupli_invoke(bContext *C, wmOperator *op, wmEvent *event)
WM_event_add_notifier(C, NC_SCREEN|NA_EDITED, NULL);
if(event->type==EVT_ACTIONZONE_AREA)
- actionzone_exit(C, op);
+ actionzone_exit(op);
return OPERATOR_FINISHED;
}
@@ -1076,7 +1170,7 @@ static int area_split_apply(bContext *C, wmOperator *op)
fac= RNA_float_get(op->ptr, "factor");
dir= RNA_enum_get(op->ptr, "direction");
- sd->narea= area_split(CTX_wm_window(C), sc, sd->sarea, dir, fac);
+ sd->narea= area_split(sc, sd->sarea, dir, fac, 0); /* 0 = no merge */
if(sd->narea) {
ScrVert *sv;
@@ -1283,19 +1377,19 @@ typedef struct RegionMoveData {
int bigger, smaller, origval;
int origx, origy;
int maxsize;
- char edge;
+ AZEdge edge;
} RegionMoveData;
-static int area_max_regionsize(ScrArea *sa, ARegion *scalear, char edge)
+static int area_max_regionsize(ScrArea *sa, ARegion *scalear, AZEdge edge)
{
ARegion *ar;
int dist;
- if(edge=='l' || edge=='r') {
+ if(edge==AE_RIGHT_TO_TOPLEFT || edge==AE_LEFT_TO_TOPRIGHT) {
dist = sa->totrct.xmax - sa->totrct.xmin;
- } else { /* t, b */
+ } else { /* AE_BOTTOM_TO_TOPLEFT, AE_TOP_TO_BOTTOMRIGHT */
dist = sa->totrct.ymax - sa->totrct.ymin;
}
@@ -1317,9 +1411,9 @@ static int area_max_regionsize(ScrArea *sa, ARegion *scalear, char edge)
/* case of regions in regions, like operator properties panel */
/* these can sit on top of other regions such as headers, so account for this */
- else if (edge == 'b' && scalear->alignment & RGN_ALIGN_TOP && ar->alignment == RGN_ALIGN_TOP && ar->regiontype == RGN_TYPE_HEADER)
+ else if (edge == AE_BOTTOM_TO_TOPLEFT && scalear->alignment & RGN_ALIGN_TOP && ar->alignment == RGN_ALIGN_TOP && ar->regiontype == RGN_TYPE_HEADER)
dist -= ar->winy;
- else if (edge == 't' && scalear->alignment & RGN_ALIGN_BOTTOM && ar->alignment == RGN_ALIGN_BOTTOM && ar->regiontype == RGN_TYPE_HEADER)
+ else if (edge == AE_TOP_TO_BOTTOMRIGHT && scalear->alignment & RGN_ALIGN_BOTTOM && ar->alignment == RGN_ALIGN_BOTTOM && ar->regiontype == RGN_TYPE_HEADER)
dist -= ar->winy;
}
@@ -1359,7 +1453,7 @@ static int region_scale_invoke(bContext *C, wmOperator *op, wmEvent *event)
rmd->ar->sizey= rmd->ar->type->prefsizey;
/* now copy to regionmovedata */
- if(rmd->edge=='l' || rmd->edge=='r') {
+ if(rmd->edge==AE_LEFT_TO_TOPRIGHT || rmd->edge==AE_RIGHT_TO_TOPLEFT) {
rmd->origval= rmd->ar->sizex;
} else {
rmd->origval= rmd->ar->sizey;
@@ -1391,9 +1485,9 @@ static int region_scale_modal(bContext *C, wmOperator *op, wmEvent *event)
switch(event->type) {
case MOUSEMOVE:
- if(rmd->edge=='l' || rmd->edge=='r') {
+ if(rmd->edge==AE_LEFT_TO_TOPRIGHT || rmd->edge==AE_RIGHT_TO_TOPLEFT) {
delta= event->x - rmd->origx;
- if(rmd->edge=='l') delta= -delta;
+ if(rmd->edge==AE_LEFT_TO_TOPRIGHT) delta= -delta;
rmd->ar->sizex= rmd->origval + delta;
CLAMP(rmd->ar->sizex, 0, rmd->maxsize);
@@ -1407,13 +1501,17 @@ static int region_scale_modal(bContext *C, wmOperator *op, wmEvent *event)
ED_region_toggle_hidden(C, rmd->ar);
}
else {
+ int maxsize=0;
delta= event->y - rmd->origy;
- if(rmd->edge=='b') delta= -delta;
+ if(rmd->edge==AE_BOTTOM_TO_TOPLEFT) delta= -delta;
rmd->ar->sizey= rmd->origval + delta;
CLAMP(rmd->ar->sizey, 0, rmd->maxsize);
- if(rmd->ar->sizey < 24) {
+ if(rmd->ar->regiontype == RGN_TYPE_TOOL_PROPS)
+ maxsize = rmd->maxsize - ((rmd->sa->headertype==2)?48:24) - 10;
+
+ if(rmd->ar->sizey < 24 || (maxsize > 0 && (rmd->ar->sizey > maxsize)) ) {
rmd->ar->sizey= rmd->origval;
if(!(rmd->ar->flag & RGN_FLAG_HIDDEN))
ED_region_toggle_hidden(C, rmd->ar);
@@ -1505,15 +1603,32 @@ static void SCREEN_OT_frame_offset(wmOperatorType *ot)
static int frame_jump_exec(bContext *C, wmOperator *op)
{
Scene *scene= CTX_data_scene(C);
-
- if (RNA_boolean_get(op->ptr, "end"))
- CFRA= PEFRA;
- else
- CFRA= PSFRA;
-
- sound_seek_scene(C);
+ wmTimer *animtimer= CTX_wm_screen(C)->animtimer;
+
+ /* Don't change CFRA directly if animtimer is running as this can cause
+ * first/last frame not to be actually shown (bad since for example physics
+ * simulations aren't reset properly).
+ */
+ if(animtimer) {
+ ScreenAnimData *sad = animtimer->customdata;
+
+ sad->flag |= ANIMPLAY_FLAG_USE_NEXT_FRAME;
+
+ if (RNA_boolean_get(op->ptr, "end"))
+ sad->nextfra= PEFRA;
+ else
+ sad->nextfra= PSFRA;
+ }
+ else {
+ if (RNA_boolean_get(op->ptr, "end"))
+ CFRA= PEFRA;
+ else
+ CFRA= PSFRA;
+
+ sound_seek_scene(C);
- WM_event_add_notifier(C, NC_SCENE|ND_FRAME, scene);
+ WM_event_add_notifier(C, NC_SCENE|ND_FRAME, scene);
+ }
return OPERATOR_FINISHED;
}
@@ -1541,6 +1656,7 @@ static int keyframe_jump_exec(bContext *C, wmOperator *op)
{
Scene *scene= CTX_data_scene(C);
Object *ob= CTX_data_active_object(C);
+ bDopeSheet ads= {0};
DLRBT_Tree keys;
ActKeyColumn *ak;
float cfra= (scene)? (float)(CFRA) : 0.0f;
@@ -1555,10 +1671,10 @@ static int keyframe_jump_exec(bContext *C, wmOperator *op)
BLI_dlrbTree_init(&keys);
/* populate tree with keyframe nodes */
- if (scene && scene->adt)
- scene_to_keylist(NULL, scene, &keys, NULL);
- if (ob && ob->adt)
- ob_to_keylist(NULL, ob, &keys, NULL);
+ if (scene)
+ scene_to_keylist(&ads, scene, &keys, NULL);
+ if (ob)
+ ob_to_keylist(&ads, ob, &keys, NULL);
/* build linked-list for searching */
BLI_dlrbTree_linkedlist_sync(&keys);
@@ -1623,6 +1739,10 @@ static int screen_set_exec(bContext *C, wmOperator *op)
int tot= BLI_countlist(&CTX_data_main(C)->screen);
int delta= RNA_int_get(op->ptr, "delta");
+ /* temp screens are for userpref or render display */
+ if(screen->temp)
+ return OPERATOR_CANCELLED;
+
/* return to previous state before switching screens */
if(sa && sa->full)
ED_screen_full_restore(C, sa);
@@ -1671,7 +1791,7 @@ static void SCREEN_OT_screen_set(wmOperatorType *ot)
/* function to be called outside UI context, or for redo */
-static int screen_full_area_exec(bContext *C, wmOperator *op)
+static int screen_full_area_exec(bContext *C, wmOperator *UNUSED(op))
{
ED_screen_full_toggle(C, CTX_wm_window(C), CTX_wm_area(C));
return OPERATOR_FINISHED;
@@ -1878,7 +1998,7 @@ static int area_join_modal(bContext *C, wmOperator *op, wmEvent *event)
if (sa) {
if (jd->sa1 != sa) {
- dir = area_getorientation(sc, jd->sa1, sa);
+ dir = area_getorientation(jd->sa1, sa);
if (dir >= 0) {
if (jd->sa2) jd->sa2->flag &= ~AREA_FLAG_DRAWJOINTO;
jd->sa2 = sa;
@@ -1889,7 +2009,7 @@ static int area_join_modal(bContext *C, wmOperator *op, wmEvent *event)
we check if area has common border with the one marked for removal
in this case we can swap areas.
*/
- dir = area_getorientation(sc, sa, jd->sa2);
+ dir = area_getorientation(sa, jd->sa2);
if (dir >= 0) {
if (jd->sa1) jd->sa1->flag &= ~AREA_FLAG_DRAWJOINFROM;
if (jd->sa2) jd->sa2->flag &= ~AREA_FLAG_DRAWJOINTO;
@@ -1915,13 +2035,13 @@ static int area_join_modal(bContext *C, wmOperator *op, wmEvent *event)
jd->sa2 = sa;
if (jd->sa1) jd->sa1->flag |= AREA_FLAG_DRAWJOINFROM;
if (jd->sa2) jd->sa2->flag |= AREA_FLAG_DRAWJOINTO;
- dir = area_getorientation(sc, jd->sa1, jd->sa2);
+ dir = area_getorientation(jd->sa1, jd->sa2);
if (dir < 0) {
printf("oops, didn't expect that!\n");
}
}
else {
- dir = area_getorientation(sc, jd->sa1, sa);
+ dir = area_getorientation(jd->sa1, sa);
if (dir >= 0) {
if (jd->sa2) jd->sa2->flag &= ~AREA_FLAG_DRAWJOINTO;
jd->sa2 = sa;
@@ -1976,9 +2096,47 @@ static void SCREEN_OT_area_join(wmOperatorType *ot)
RNA_def_int(ot->srna, "max_y", -100, INT_MIN, INT_MAX, "Y 2", "", INT_MIN, INT_MAX);
}
+
+static int spacedata_cleanup(bContext *C, wmOperator *op)
+{
+ Main *bmain= CTX_data_main(C);
+ bScreen *screen;
+ ScrArea *sa;
+ int tot= 0;
+
+ for(screen= bmain->screen.first; screen; screen= screen->id.next) {
+ for(sa= screen->areabase.first; sa; sa= sa->next) {
+ if(sa->spacedata.first != sa->spacedata.last) {
+ SpaceLink *sl= sa->spacedata.first;
+
+ BLI_remlink(&sa->spacedata, sl);
+ tot+= BLI_countlist(&sa->spacedata);
+ BKE_spacedata_freelist(&sa->spacedata);
+ BLI_addtail(&sa->spacedata, sl);
+ }
+ }
+ }
+ BKE_reportf(op->reports, RPT_INFO, "Removed amount of editors: %d", tot);
+
+ return OPERATOR_FINISHED;
+}
+
+static void SCREEN_OT_spacedata_cleanup(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name= "Clean-up space-data";
+ ot->description= "Remove unused settings for invisible editors";
+ ot->idname= "SCREEN_OT_spacedata_cleanup";
+
+ /* api callbacks */
+ ot->exec= spacedata_cleanup;
+ ot->poll= WM_operator_winactive;
+
+}
+
/* ************** repeat last operator ***************************** */
-static int repeat_last_exec(bContext *C, wmOperator *op)
+static int repeat_last_exec(bContext *C, wmOperator *UNUSED(op))
{
wmOperator *lastop= CTX_wm_manager(C)->operators.last;
@@ -2002,7 +2160,7 @@ static void SCREEN_OT_repeat_last(wmOperatorType *ot)
}
-static int repeat_history_invoke(bContext *C, wmOperator *op, wmEvent *event)
+static int repeat_history_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event))
{
wmWindowManager *wm= CTX_wm_manager(C);
wmOperator *lastop;
@@ -2014,11 +2172,11 @@ static int repeat_history_invoke(bContext *C, wmOperator *op, wmEvent *event)
if(items==0)
return OPERATOR_CANCELLED;
- pup= uiPupMenuBegin(C, op->type->name, 0);
+ pup= uiPupMenuBegin(C, op->type->name, ICON_NULL);
layout= uiPupMenuLayout(pup);
for (i=items-1, lastop= wm->operators.last; lastop; lastop= lastop->prev, i--)
- uiItemIntO(layout, lastop->type->name, 0, op->type->idname, "index", i);
+ uiItemIntO(layout, lastop->type->name, ICON_NULL, op->type->idname, "index", i);
uiPupMenuEnd(C, pup);
@@ -2059,7 +2217,7 @@ static void SCREEN_OT_repeat_history(wmOperatorType *ot)
/* ********************** redo operator ***************************** */
-static int redo_last_invoke(bContext *C, wmOperator *op, wmEvent *event)
+static int redo_last_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent *UNUSED(event))
{
wmWindowManager *wm= CTX_wm_manager(C);
wmOperator *lastop;
@@ -2178,7 +2336,7 @@ static void SCREEN_OT_region_quadview(wmOperatorType *ot)
/* api callbacks */
// ot->invoke= WM_operator_confirm;
ot->exec= region_quadview_exec;
- ot->poll= ED_operator_areaactive;
+ ot->poll= ED_operator_region_view3d_active;
ot->flag= 0;
}
@@ -2187,7 +2345,7 @@ static void SCREEN_OT_region_quadview(wmOperatorType *ot)
/* ************** region flip operator ***************************** */
/* flip a region alignment */
-static int region_flip_exec(bContext *C, wmOperator *op)
+static int region_flip_exec(bContext *C, wmOperator *UNUSED(op))
{
ARegion *ar= CTX_wm_region(C);
@@ -2225,7 +2383,7 @@ static void SCREEN_OT_region_flip(wmOperatorType *ot)
/* ************** header flip operator ***************************** */
/* flip a header region alignment */
-static int header_flip_exec(bContext *C, wmOperator *op)
+static int header_flip_exec(bContext *C, wmOperator *UNUSED(op))
{
ARegion *ar= CTX_wm_region(C);
@@ -2279,30 +2437,30 @@ static void SCREEN_OT_header_flip(wmOperatorType *ot)
/* ************** header tools operator ***************************** */
-static int header_toolbox_invoke(bContext *C, wmOperator *op, wmEvent *event)
+static int header_toolbox_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent *UNUSED(event))
{
ScrArea *sa= CTX_wm_area(C);
ARegion *ar= CTX_wm_region(C);
uiPopupMenu *pup;
uiLayout *layout;
- pup= uiPupMenuBegin(C, "Header", 0);
+ pup= uiPupMenuBegin(C, "Header", ICON_NULL);
layout= uiPupMenuLayout(pup);
// XXX SCREEN_OT_region_flip doesn't work - gets wrong context for active region, so added custom operator
if (ar->alignment == RGN_ALIGN_TOP)
- uiItemO(layout, "Flip to Bottom", 0, "SCREEN_OT_header_flip");
+ uiItemO(layout, "Flip to Bottom", ICON_NULL, "SCREEN_OT_header_flip");
else
- uiItemO(layout, "Flip to Top", 0, "SCREEN_OT_header_flip");
+ uiItemO(layout, "Flip to Top", ICON_NULL, "SCREEN_OT_header_flip");
uiItemS(layout);
/* file browser should be fullscreen all the time, but other regions can be maximised/restored... */
if (sa->spacetype != SPACE_FILE) {
if (sa->full)
- uiItemO(layout, "Tile Area", 0, "SCREEN_OT_screen_full_area");
+ uiItemO(layout, "Tile Area", ICON_NULL, "SCREEN_OT_screen_full_area");
else
- uiItemO(layout, "Maximize Area", 0, "SCREEN_OT_screen_full_area");
+ uiItemO(layout, "Maximize Area", ICON_NULL, "SCREEN_OT_screen_full_area");
}
uiPupMenuEnd(C, pup);
@@ -2310,7 +2468,7 @@ static int header_toolbox_invoke(bContext *C, wmOperator *op, wmEvent *event)
return OPERATOR_CANCELLED;
}
-void SCREEN_OT_header_toolbox(wmOperatorType *ot)
+static void SCREEN_OT_header_toolbox(wmOperatorType *ot)
{
/* identifiers */
ot->name= "Header Toolbox";
@@ -2393,7 +2551,7 @@ static int match_region_with_redraws(int spacetype, int regiontype, int redraws)
return 0;
}
-static int screen_animation_step(bContext *C, wmOperator *op, wmEvent *event)
+static int screen_animation_step(bContext *C, wmOperator *UNUSED(op), wmEvent *event)
{
bScreen *screen= CTX_wm_screen(C);
@@ -2465,12 +2623,19 @@ static int screen_animation_step(bContext *C, wmOperator *op, wmEvent *event)
}
}
}
+
+ /* next frame overriden by user action (pressed jump to first/last frame) */
+ if(sad->flag & ANIMPLAY_FLAG_USE_NEXT_FRAME) {
+ scene->r.cfra = sad->nextfra;
+ sad->flag &= ~ANIMPLAY_FLAG_USE_NEXT_FRAME;
+ sad->flag |= ANIMPLAY_FLAG_JUMPED;
+ }
if (sad->flag & ANIMPLAY_FLAG_JUMPED)
sound_seek_scene(C);
/* since we follow drawflags, we can't send notifier but tag regions ourselves */
- ED_update_for_newframe(C, 1);
+ ED_update_for_newframe(CTX_data_main(C), scene, screen, 1);
for (sa= screen->areabase.first; sa; sa= sa->next) {
ARegion *ar;
@@ -2531,38 +2696,19 @@ int ED_screen_animation_play(bContext *C, int sync, int mode)
sound_stop_scene(scene);
}
else {
- ScrArea *sa= CTX_wm_area(C);
- int refresh= SPACE_TIME;
+ int refresh= SPACE_TIME; /* these settings are currently only available from a menu in the TimeLine */
if (mode == 1) // XXX only play audio forwards!?
sound_play_scene(scene);
- /* timeline gets special treatment since it has it's own menu for determining redraws */
- if ((sa) && (sa->spacetype == SPACE_TIME)) {
- SpaceTime *stime= (SpaceTime *)sa->spacedata.first;
-
- ED_screen_animation_timer(C, stime->redraws, refresh, sync, mode);
-
- /* update region if TIME_REGION was set, to leftmost 3d window */
- ED_screen_animation_timer_update(screen, stime->redraws, refresh);
- }
- else {
- int redraws = TIME_REGION|TIME_ALL_3D_WIN;
-
- /* XXX - would like a better way to deal with this situation - Campbell */
- if ((!sa) || (sa->spacetype == SPACE_SEQ)) {
- redraws |= TIME_SEQ;
- }
-
- ED_screen_animation_timer(C, redraws, refresh, sync, mode);
+ ED_screen_animation_timer(C, screen->redraws_flag, refresh, sync, mode);
+
+ if (screen->animtimer) {
+ wmTimer *wt= screen->animtimer;
+ ScreenAnimData *sad= wt->customdata;
- if(screen->animtimer) {
- wmTimer *wt= screen->animtimer;
- ScreenAnimData *sad= wt->customdata;
-
- sad->ar= CTX_wm_region(C);
+ sad->ar= CTX_wm_region(C);
}
- }
}
return OPERATOR_FINISHED;
@@ -2595,11 +2741,11 @@ static void SCREEN_OT_animation_play(wmOperatorType *ot)
RNA_def_boolean(ot->srna, "sync", 0, "Sync", "Drop frames to maintain framerate");
}
-static int screen_animation_cancel_exec(bContext *C, wmOperator *op)
+static int screen_animation_cancel_exec(bContext *C, wmOperator *UNUSED(op))
{
bScreen *screen= CTX_wm_screen(C);
- if(screen->animtimer) {
+ if (screen->animtimer) {
ScreenAnimData *sad= screen->animtimer->customdata;
Scene *scene= CTX_data_scene(C);
@@ -2723,9 +2869,8 @@ static void SCREEN_OT_back_to_previous(struct wmOperatorType *ot)
/* *********** show user pref window ****** */
-static int userpref_show_invoke(bContext *C, wmOperator *unused, wmEvent *event)
+static int userpref_show_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent *event)
{
- ScrArea *sa;
rcti rect;
int sizex, sizey;
@@ -2741,9 +2886,6 @@ static int userpref_show_invoke(bContext *C, wmOperator *unused, wmEvent *event)
/* changes context! */
WM_window_open_temp(C, &rect, WM_WINDOW_USERPREFS);
- sa= CTX_wm_area(C);
-
-
return OPERATOR_FINISHED;
}
@@ -2762,7 +2904,7 @@ static void SCREEN_OT_userpref_show(struct wmOperatorType *ot)
/********************* new screen operator *********************/
-static int screen_new_exec(bContext *C, wmOperator *op)
+static int screen_new_exec(bContext *C, wmOperator *UNUSED(op))
{
wmWindow *win= CTX_wm_window(C);
bScreen *sc= CTX_wm_screen(C);
@@ -2773,7 +2915,7 @@ static int screen_new_exec(bContext *C, wmOperator *op)
return OPERATOR_FINISHED;
}
-void SCREEN_OT_new(wmOperatorType *ot)
+static void SCREEN_OT_new(wmOperatorType *ot)
{
/* identifiers */
ot->name= "New Screen";
@@ -2789,7 +2931,7 @@ void SCREEN_OT_new(wmOperatorType *ot)
/********************* delete screen operator *********************/
-static int screen_delete_exec(bContext *C, wmOperator *op)
+static int screen_delete_exec(bContext *C, wmOperator *UNUSED(op))
{
bScreen *sc= CTX_wm_screen(C);
@@ -2798,7 +2940,7 @@ static int screen_delete_exec(bContext *C, wmOperator *op)
return OPERATOR_FINISHED;
}
-void SCREEN_OT_delete(wmOperatorType *ot)
+static void SCREEN_OT_delete(wmOperatorType *ot)
{
/* identifiers */
ot->name= "Delete Screen"; //was scene
@@ -2820,7 +2962,7 @@ static int scene_new_exec(bContext *C, wmOperator *op)
Main *bmain= CTX_data_main(C);
int type= RNA_enum_get(op->ptr, "type");
- newscene= copy_scene(bmain, scene, type);
+ newscene= copy_scene(scene, type);
/* these can't be handled in blenkernel curently, so do them here */
if(type == SCE_COPY_LINK_DATA)
@@ -2833,7 +2975,7 @@ static int scene_new_exec(bContext *C, wmOperator *op)
return OPERATOR_FINISHED;
}
-void SCENE_OT_new(wmOperatorType *ot)
+static void SCENE_OT_new(wmOperatorType *ot)
{
static EnumPropertyItem type_items[]= {
{SCE_COPY_EMPTY, "EMPTY", 0, "Empty", "Add empty scene"},
@@ -2860,7 +3002,7 @@ void SCENE_OT_new(wmOperatorType *ot)
/********************* delete scene operator *********************/
-static int scene_delete_exec(bContext *C, wmOperator *op)
+static int scene_delete_exec(bContext *C, wmOperator *UNUSED(op))
{
Scene *scene= CTX_data_scene(C);
@@ -2869,7 +3011,7 @@ static int scene_delete_exec(bContext *C, wmOperator *op)
return OPERATOR_FINISHED;
}
-void SCENE_OT_delete(wmOperatorType *ot)
+static void SCENE_OT_delete(wmOperatorType *ot)
{
/* identifiers */
ot->name= "Delete Scene";
@@ -2885,6 +3027,7 @@ void SCENE_OT_delete(wmOperatorType *ot)
/* **************** Assigning operatortypes to global list, adding handlers **************** */
+
/* called in spacetypes.c */
void ED_operatortypes_screen(void)
{
@@ -2908,6 +3051,7 @@ void ED_operatortypes_screen(void)
WM_operatortype_append(SCREEN_OT_screen_set);
WM_operatortype_append(SCREEN_OT_screen_full_area);
WM_operatortype_append(SCREEN_OT_back_to_previous);
+ WM_operatortype_append(SCREEN_OT_spacedata_cleanup);
WM_operatortype_append(SCREEN_OT_screenshot);
WM_operatortype_append(SCREEN_OT_screencast);
WM_operatortype_append(SCREEN_OT_userpref_show);
@@ -2929,6 +3073,7 @@ void ED_operatortypes_screen(void)
/* tools shared by more space types */
WM_operatortype_append(ED_OT_undo);
+ WM_operatortype_append(ED_OT_undo_push);
WM_operatortype_append(ED_OT_redo);
}
@@ -2958,9 +3103,27 @@ static void keymap_modal_set(wmKeyConfig *keyconf)
}
+static int open_file_drop_poll(bContext *UNUSED(C), wmDrag *drag, wmEvent *UNUSED(event))
+{
+ if(drag->type==WM_DRAG_PATH) {
+ if(drag->icon==ICON_FILE_BLEND)
+ return 1;
+ }
+ return 0;
+}
+
+static void open_file_drop_copy(wmDrag *drag, wmDropBox *drop)
+{
+ /* copy drag path to properties */
+ RNA_string_set(drop->ptr, "filepath", drag->path);
+ drop->opcontext= WM_OP_EXEC_DEFAULT;
+}
+
+
/* called in spacetypes.c */
void ED_keymap_screen(wmKeyConfig *keyconf)
{
+ ListBase *lb;
wmKeyMap *keymap;
//wmKeyMapItem *kmi;
@@ -3074,6 +3237,10 @@ void ED_keymap_screen(wmKeyConfig *keyconf)
WM_keymap_add_item(keymap, "SCREEN_OT_animation_play", DOWNARROWKEY, KM_PRESS, KM_ALT, 0);
#endif
+ /* dropbox for entire window */
+ lb= WM_dropboxmap_find("Window", 0, 0);
+ WM_dropbox_add(lb, "WM_OT_open_mainfile", open_file_drop_poll, open_file_drop_copy);
+
keymap_modal_set(keyconf);
}
diff --git a/source/blender/editors/screen/screendump.c b/source/blender/editors/screen/screendump.c
index 56efa0a5a83..7ac73eb8c14 100644
--- a/source/blender/editors/screen/screendump.c
+++ b/source/blender/editors/screen/screendump.c
@@ -1,4 +1,4 @@
-/**
+/*
* $Id$
*
* ***** BEGIN GPL LICENSE BLOCK *****
@@ -31,6 +31,7 @@
#include "MEM_guardedalloc.h"
#include "BLI_blenlib.h"
+#include "BLI_utildefines.h"
#include "IMB_imbuf_types.h"
#include "IMB_imbuf.h"
@@ -42,6 +43,7 @@
#include "BKE_context.h"
#include "BKE_global.h"
+#include "BKE_main.h"
#include "BKE_image.h"
#include "BKE_report.h"
#include "BKE_writeavi.h"
@@ -69,29 +71,31 @@ static int screenshot_exec(bContext *C, wmOperator *op)
{
ScreenshotData *scd= op->customdata;
- if(scd && scd->dumprect) {
- Scene *scene= CTX_data_scene(C);
- ImBuf *ibuf;
- char path[FILE_MAX];
-
- RNA_string_get(op->ptr, "filepath", path);
-
- strcpy(G.ima, path);
- BLI_path_abs(path, G.sce);
+ if(scd) {
+ if(scd->dumprect) {
+ Scene *scene= CTX_data_scene(C);
+ ImBuf *ibuf;
+ char path[FILE_MAX];
- /* BKE_add_image_extension() checks for if extension was already set */
- if(scene->r.scemode & R_EXTENSION)
- if(strlen(path)<FILE_MAXDIR+FILE_MAXFILE-5)
- BKE_add_image_extension(path, scene->r.imtype);
+ RNA_string_get(op->ptr, "filepath", path);
- ibuf= IMB_allocImBuf(scd->dumpsx, scd->dumpsy, 24, 0, 0);
- ibuf->rect= scd->dumprect;
-
- BKE_write_ibuf(scene, ibuf, path, scene->r.imtype, scene->r.subimtype, scene->r.quality);
+ strcpy(G.ima, path);
+ BLI_path_abs(path, G.main->name);
+
+ /* BKE_add_image_extension() checks for if extension was already set */
+ if(scene->r.scemode & R_EXTENSION)
+ if(strlen(path)<FILE_MAXDIR+FILE_MAXFILE-5)
+ BKE_add_image_extension(path, scene->r.imtype);
+
+ ibuf= IMB_allocImBuf(scd->dumpsx, scd->dumpsy, 24, 0);
+ ibuf->rect= scd->dumprect;
+
+ BKE_write_ibuf(scene, ibuf, path, scene->r.imtype, scene->r.subimtype, scene->r.quality);
- IMB_freeImBuf(ibuf);
+ IMB_freeImBuf(ibuf);
- MEM_freeN(scd->dumprect);
+ MEM_freeN(scd->dumprect);
+ }
MEM_freeN(scd);
op->customdata= NULL;
}
@@ -132,7 +136,7 @@ static unsigned int *screenshot(bContext *C, int *dumpsx, int *dumpsy, int fscre
}
-static int screenshot_invoke(bContext *C, wmOperator *op, wmEvent *event)
+static int screenshot_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event))
{
unsigned int *dumprect;
int dumpsx, dumpsy;
@@ -158,6 +162,18 @@ static int screenshot_invoke(bContext *C, wmOperator *op, wmEvent *event)
return OPERATOR_CANCELLED;
}
+static int screenshot_cancel(bContext *UNUSED(C), wmOperator *op)
+{
+ ScreenshotData *scd= op->customdata;
+
+ if(scd) {
+ if(scd->dumprect)
+ MEM_freeN(scd->dumprect);
+ MEM_freeN(scd);
+ op->customdata= NULL;
+ }
+ return OPERATOR_CANCELLED;
+}
void SCREEN_OT_screenshot(wmOperatorType *ot)
{
@@ -167,6 +183,7 @@ void SCREEN_OT_screenshot(wmOperatorType *ot)
ot->invoke= screenshot_invoke;
ot->exec= screenshot_exec;
ot->poll= WM_operator_winactive;
+ ot->cancel= screenshot_cancel;
ot->flag= 0;
@@ -214,7 +231,7 @@ static void screenshot_updatejob(void *sjv)
/* only this runs inside thread */
-static void screenshot_startjob(void *sjv, short *stop, short *do_update, float *progress)
+static void screenshot_startjob(void *sjv, short *stop, short *do_update, float *UNUSED(progress))
{
ScreenshotJob *sj= sjv;
RenderData rd= sj->scene->r;
@@ -251,11 +268,11 @@ static void screenshot_startjob(void *sjv, short *stop, short *do_update, float
break;
}
else {
- ImBuf *ibuf= IMB_allocImBuf(sj->dumpsx, sj->dumpsy, rd.planes, 0, 0);
+ ImBuf *ibuf= IMB_allocImBuf(sj->dumpsx, sj->dumpsy, rd.planes, 0);
char name[FILE_MAXDIR+FILE_MAXFILE];
int ok;
- BKE_makepicstring(name, rd.pic, cfra, rd.imtype, rd.scemode & R_EXTENSION);
+ BKE_makepicstring(name, rd.pic, cfra, rd.imtype, rd.scemode & R_EXTENSION, TRUE);
ibuf->rect= sj->dumprect;
ok= BKE_write_ibuf(sj->scene, ibuf, name, rd.imtype, rd.subimtype, rd.quality);