BPython - first step for better integration of Python in Blender:
- add a new space: Space Script - add a new dna struct: Script - add these two properly everywhere they are meant to It's not a tiny commit, but most of it is ground work for what is still to be done. Right now the benefits should be: freeing the Text Editor to be used in a window even while a script w/ gui in "on" and letting more than one currently running script w/ gui be accessible from each window Some files are added, so some build systems (not autotools) will need updates
This commit is contained in:
@@ -68,6 +68,7 @@ typedef struct Main {
|
|||||||
ListBase key;
|
ListBase key;
|
||||||
ListBase world;
|
ListBase world;
|
||||||
ListBase screen;
|
ListBase screen;
|
||||||
|
ListBase script;
|
||||||
ListBase vfont;
|
ListBase vfont;
|
||||||
ListBase text;
|
ListBase text;
|
||||||
ListBase sound;
|
ListBase sound;
|
||||||
|
|||||||
49
source/blender/blenkernel/BKE_script.h
Normal file
49
source/blender/blenkernel/BKE_script.h
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
/**
|
||||||
|
* blenlib/BKE_script.h (mar-2001 nzc)
|
||||||
|
*
|
||||||
|
* $Id$
|
||||||
|
*
|
||||||
|
* ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation; either version 2
|
||||||
|
* of the License, or (at your option) any later version. The Blender
|
||||||
|
* Foundation also sells licenses for use in proprietary software under
|
||||||
|
* the Blender License. See http://www.blender.org/BL/ for information
|
||||||
|
* about this.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software Foundation,
|
||||||
|
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
*
|
||||||
|
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* This is a new part of Blender.
|
||||||
|
*
|
||||||
|
* Contributor(s): Willian P. Germano.
|
||||||
|
*
|
||||||
|
* ***** END GPL/BL DUAL LICENSE BLOCK *****
|
||||||
|
*/
|
||||||
|
#ifndef BKE_SCRIPT_H
|
||||||
|
#define BKE_SCRIPT_H
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
struct Script;
|
||||||
|
|
||||||
|
void free_script (struct Script *script);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* BKE_SCRIPT_H */
|
||||||
@@ -71,6 +71,7 @@
|
|||||||
#include "DNA_screen_types.h"
|
#include "DNA_screen_types.h"
|
||||||
#include "DNA_vfont_types.h"
|
#include "DNA_vfont_types.h"
|
||||||
#include "DNA_text_types.h"
|
#include "DNA_text_types.h"
|
||||||
|
#include "DNA_script_types.h"
|
||||||
#include "DNA_sound_types.h"
|
#include "DNA_sound_types.h"
|
||||||
#include "DNA_group_types.h"
|
#include "DNA_group_types.h"
|
||||||
#include "DNA_armature_types.h"
|
#include "DNA_armature_types.h"
|
||||||
@@ -86,11 +87,12 @@
|
|||||||
#include "BKE_sound.h"
|
#include "BKE_sound.h"
|
||||||
#include "BKE_object.h"
|
#include "BKE_object.h"
|
||||||
#include "BKE_screen.h"
|
#include "BKE_screen.h"
|
||||||
|
#include "BKE_script.h"
|
||||||
#include "BKE_mesh.h"
|
#include "BKE_mesh.h"
|
||||||
#include "BKE_material.h"
|
#include "BKE_material.h"
|
||||||
#include "BKE_curve.h"
|
#include "BKE_curve.h"
|
||||||
#include "BKE_mball.h"
|
#include "BKE_mball.h"
|
||||||
#include "BKE_text.h"
|
#include "BKE_text.h"
|
||||||
#include "BKE_texture.h"
|
#include "BKE_texture.h"
|
||||||
#include "BKE_scene.h"
|
#include "BKE_scene.h"
|
||||||
#include "BKE_image.h"
|
#include "BKE_image.h"
|
||||||
@@ -173,6 +175,8 @@ ListBase *wich_libbase(Main *mainlib, short type)
|
|||||||
return &(mainlib->vfont);
|
return &(mainlib->vfont);
|
||||||
case ID_TXT:
|
case ID_TXT:
|
||||||
return &(mainlib->text);
|
return &(mainlib->text);
|
||||||
|
case ID_SCRIPT:
|
||||||
|
return &(mainlib->script);
|
||||||
case ID_SO:
|
case ID_SO:
|
||||||
return &(mainlib->sound);
|
return &(mainlib->sound);
|
||||||
case ID_SAMPLE:
|
case ID_SAMPLE:
|
||||||
@@ -225,9 +229,10 @@ int set_listbasepointers(Main *main, ListBase **lb)
|
|||||||
lb[23]= &(main->group);
|
lb[23]= &(main->group);
|
||||||
|
|
||||||
lb[24]= samples;
|
lb[24]= samples;
|
||||||
lb[25]= 0;
|
lb[25]= &(main->script);
|
||||||
|
lb[26]=0;
|
||||||
return 25;
|
|
||||||
|
return 26;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* *********** ALLOC AND FREE *****************
|
/* *********** ALLOC AND FREE *****************
|
||||||
@@ -305,6 +310,9 @@ static ID *alloc_libblock_notest(short type)
|
|||||||
case ID_TXT:
|
case ID_TXT:
|
||||||
id= MEM_callocN(sizeof(Text), "text");
|
id= MEM_callocN(sizeof(Text), "text");
|
||||||
break;
|
break;
|
||||||
|
case ID_SCRIPT:
|
||||||
|
id= MEM_callocN(sizeof(Script), "script");
|
||||||
|
break;
|
||||||
case ID_SO:
|
case ID_SO:
|
||||||
id= MEM_callocN(sizeof(bSound), "sound");
|
id= MEM_callocN(sizeof(bSound), "sound");
|
||||||
break;
|
break;
|
||||||
@@ -450,6 +458,9 @@ void free_libblock(ListBase *lb, void *idv)
|
|||||||
case ID_TXT:
|
case ID_TXT:
|
||||||
free_text((Text *)id);
|
free_text((Text *)id);
|
||||||
break;
|
break;
|
||||||
|
case ID_SCRIPT:
|
||||||
|
free_script((Script *)id);
|
||||||
|
break;
|
||||||
case ID_SO:
|
case ID_SO:
|
||||||
sound_free_sound((bSound *)id);
|
sound_free_sound((bSound *)id);
|
||||||
break;
|
break;
|
||||||
|
|||||||
70
source/blender/blenkernel/intern/script.c
Normal file
70
source/blender/blenkernel/intern/script.c
Normal file
@@ -0,0 +1,70 @@
|
|||||||
|
/* script.c
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* $Id$
|
||||||
|
*
|
||||||
|
* ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation; either version 2
|
||||||
|
* of the License, or (at your option) any later version. The Blender
|
||||||
|
* Foundation also sells licenses for use in proprietary software under
|
||||||
|
* the Blender License. See http://www.blender.org/BL/ for information
|
||||||
|
* about this.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software Foundation,
|
||||||
|
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
*
|
||||||
|
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* This is a new part of Blender.
|
||||||
|
*
|
||||||
|
* Contributor(s): Willian P. Germano.
|
||||||
|
*
|
||||||
|
* ***** END GPL/BL DUAL LICENSE BLOCK *****
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "MEM_guardedalloc.h"
|
||||||
|
|
||||||
|
#include "DNA_script_types.h"
|
||||||
|
|
||||||
|
#include "BKE_script.h"
|
||||||
|
#include "BIF_drawscript.h" /* for unlink_script */
|
||||||
|
|
||||||
|
/*
|
||||||
|
#include "BLI_blenlib.h"
|
||||||
|
#include "BKE_bad_level_calls.h"
|
||||||
|
#include "BKE_utildefines.h"
|
||||||
|
#include "BKE_library.h"
|
||||||
|
#include "BKE_global.h"
|
||||||
|
#include "BKE_main.h"
|
||||||
|
|
||||||
|
#include "BPY_extern.h" // Blender Python library
|
||||||
|
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
#include <config.h>
|
||||||
|
#endif
|
||||||
|
*/
|
||||||
|
|
||||||
|
void free_script (Script *script)
|
||||||
|
{
|
||||||
|
if (!script) return;
|
||||||
|
|
||||||
|
if (script->py_globaldict || script->py_button ||
|
||||||
|
script->py_event || script->py_draw)
|
||||||
|
{
|
||||||
|
BPY_clear_script(script);
|
||||||
|
}
|
||||||
|
|
||||||
|
unlink_script (script); /* unlink from all visible SPACE_SCRIPTS */
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
@@ -147,6 +147,7 @@ void free_text(Text *text)
|
|||||||
|
|
||||||
if(text->name) MEM_freeN(text->name);
|
if(text->name) MEM_freeN(text->name);
|
||||||
MEM_freeN(text->undo_buf);
|
MEM_freeN(text->undo_buf);
|
||||||
|
if (text->compiled) BPY_free_compiled_text(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
Text *add_empty_text(void)
|
Text *add_empty_text(void)
|
||||||
|
|||||||
@@ -2477,11 +2477,12 @@ static void lib_link_screen(FileData *fd, Main *main)
|
|||||||
SpaceText *st= (SpaceText *)sl;
|
SpaceText *st= (SpaceText *)sl;
|
||||||
|
|
||||||
st->text= newlibadr(fd, sc->id.lib, st->text);
|
st->text= newlibadr(fd, sc->id.lib, st->text);
|
||||||
|
|
||||||
st->py_draw= NULL;
|
}
|
||||||
st->py_event= NULL;
|
else if(sl->spacetype==SPACE_SCRIPT) {
|
||||||
st->py_button= NULL;
|
SpaceScript *sc= (SpaceScript *)sl;
|
||||||
st->py_globaldict= NULL;
|
|
||||||
|
sc->script = NULL;
|
||||||
}
|
}
|
||||||
else if(sl->spacetype==SPACE_OOPS) {
|
else if(sl->spacetype==SPACE_OOPS) {
|
||||||
SpaceOops *so= (SpaceOops *)sl;
|
SpaceOops *so= (SpaceOops *)sl;
|
||||||
|
|||||||
@@ -1278,6 +1278,9 @@ static void write_screens(WriteData *wd, ListBase *scrbase)
|
|||||||
else if(sl->spacetype==SPACE_TEXT) {
|
else if(sl->spacetype==SPACE_TEXT) {
|
||||||
writestruct(wd, DATA, "SpaceText", 1, sl);
|
writestruct(wd, DATA, "SpaceText", 1, sl);
|
||||||
}
|
}
|
||||||
|
else if(sl->spacetype==SPACE_SCRIPT) {
|
||||||
|
writestruct(wd, DATA, "SpaceScript", 1, sl);
|
||||||
|
}
|
||||||
else if(sl->spacetype==SPACE_ACTION) {
|
else if(sl->spacetype==SPACE_ACTION) {
|
||||||
writestruct(wd, DATA, "SpaceAction", 1, sl);
|
writestruct(wd, DATA, "SpaceAction", 1, sl);
|
||||||
}
|
}
|
||||||
|
|||||||
45
source/blender/include/BIF_drawscript.h
Normal file
45
source/blender/include/BIF_drawscript.h
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
/**
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation; either version 2
|
||||||
|
* of the License, or (at your option) any later version. The Blender
|
||||||
|
* Foundation also sells licenses for use in proprietary software under
|
||||||
|
* the Blender License. See http://www.blender.org/BL/ for information
|
||||||
|
* about this.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software Foundation,
|
||||||
|
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
*
|
||||||
|
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* This is a new part of Blender.
|
||||||
|
*
|
||||||
|
* Contributor(s): Willian P. Germano.
|
||||||
|
*
|
||||||
|
* ***** END GPL/BL DUAL LICENSE BLOCK *****
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef BIF_DRAWSCRIPT_H
|
||||||
|
#define BIF_DRAWSCRIPT_H
|
||||||
|
|
||||||
|
struct ScrArea;
|
||||||
|
struct SpaceScript;
|
||||||
|
struct Script;
|
||||||
|
|
||||||
|
void unlink_script(struct Script *script);
|
||||||
|
|
||||||
|
void init_scriptspace(struct ScrArea *sa);
|
||||||
|
void free_scriptspace(struct SpaceScript *sc);
|
||||||
|
|
||||||
|
#endif /* BIF_DRAWSCRIPT_H */
|
||||||
@@ -37,7 +37,7 @@ struct uiBlock;
|
|||||||
struct ID;
|
struct ID;
|
||||||
|
|
||||||
/* these used to be in blender/src/headerbuttons.c: */
|
/* these used to be in blender/src/headerbuttons.c: */
|
||||||
#define SPACEICONMAX 14 /* See release/datafiles/blenderbuttons */
|
#define SPACEICONMAX 15 /* See release/datafiles/blenderbuttons */
|
||||||
#define XIC 20
|
#define XIC 20
|
||||||
#define YIC 20
|
#define YIC 20
|
||||||
|
|
||||||
@@ -83,6 +83,7 @@ void oops_buttons(void);
|
|||||||
void seq_buttons(void);
|
void seq_buttons(void);
|
||||||
void sound_buttons(void);
|
void sound_buttons(void);
|
||||||
void text_buttons(void);
|
void text_buttons(void);
|
||||||
|
void script_buttons(void);
|
||||||
void view3d_buttons(void);
|
void view3d_buttons(void);
|
||||||
|
|
||||||
void do_global_buttons(unsigned short event);
|
void do_global_buttons(unsigned short event);
|
||||||
@@ -101,6 +102,7 @@ void do_oops_buttons(short event);
|
|||||||
void do_seq_buttons(short event);
|
void do_seq_buttons(short event);
|
||||||
void do_sound_buttons(unsigned short event);
|
void do_sound_buttons(unsigned short event);
|
||||||
void do_text_buttons(unsigned short event);
|
void do_text_buttons(unsigned short event);
|
||||||
|
void do_script_buttons(unsigned short event);
|
||||||
void do_view3d_buttons(short event);
|
void do_view3d_buttons(short event);
|
||||||
|
|
||||||
void do_headerbuttons(short event);
|
void do_headerbuttons(short event);
|
||||||
|
|||||||
@@ -336,6 +336,9 @@
|
|||||||
#define B_TEXTSTORE 506
|
#define B_TEXTSTORE 506
|
||||||
#define B_TEXTLINENUM 507
|
#define B_TEXTLINENUM 507
|
||||||
|
|
||||||
|
/* SCRIPT: 525 */
|
||||||
|
#define B_SCRIPTBROWSE 526
|
||||||
|
|
||||||
/* FILE: 550 */
|
/* FILE: 550 */
|
||||||
#define B_SORTFILELIST 551
|
#define B_SORTFILELIST 551
|
||||||
#define B_RELOADDIR 552
|
#define B_RELOADDIR 552
|
||||||
|
|||||||
@@ -235,6 +235,7 @@
|
|||||||
#define REDRAWSOUND 0x402F
|
#define REDRAWSOUND 0x402F
|
||||||
#define REDRAWACTION 0x4030
|
#define REDRAWACTION 0x4030
|
||||||
#define REDRAWNLA 0x4031
|
#define REDRAWNLA 0x4031
|
||||||
|
#define REDRAWSCRIPT 0x4032
|
||||||
|
|
||||||
#endif /* !__MYDEVICE_H__ */
|
#endif /* !__MYDEVICE_H__ */
|
||||||
|
|
||||||
|
|||||||
@@ -126,6 +126,7 @@ typedef struct Library {
|
|||||||
#define ID_SEQ MAKE_ID2('S', 'Q')
|
#define ID_SEQ MAKE_ID2('S', 'Q')
|
||||||
#define ID_AR MAKE_ID2('A', 'R')
|
#define ID_AR MAKE_ID2('A', 'R')
|
||||||
#define ID_AC MAKE_ID2('A', 'C')
|
#define ID_AC MAKE_ID2('A', 'C')
|
||||||
|
#define ID_SCRIPT MAKE_ID2('P', 'Y')
|
||||||
|
|
||||||
#define IPO_CO MAKE_ID2('C', 'O') /* NOTE! This is not an ID, but is needed for g.sipo->blocktype */
|
#define IPO_CO MAKE_ID2('C', 'O') /* NOTE! This is not an ID, but is needed for g.sipo->blocktype */
|
||||||
|
|
||||||
|
|||||||
@@ -161,7 +161,8 @@ enum {
|
|||||||
SPACE_IMASEL,
|
SPACE_IMASEL,
|
||||||
SPACE_SOUND,
|
SPACE_SOUND,
|
||||||
SPACE_ACTION,
|
SPACE_ACTION,
|
||||||
SPACE_NLA
|
SPACE_NLA,
|
||||||
|
SPACE_SCRIPT
|
||||||
/* SPACE_LOGIC */
|
/* SPACE_LOGIC */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
69
source/blender/makesdna/DNA_script_types.h
Normal file
69
source/blender/makesdna/DNA_script_types.h
Normal file
@@ -0,0 +1,69 @@
|
|||||||
|
/**
|
||||||
|
* blenlib/DNA_script_types.h (mar-2001 nzc)
|
||||||
|
*
|
||||||
|
* $Id$
|
||||||
|
*
|
||||||
|
* ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation; either version 2
|
||||||
|
* of the License, or (at your option) any later version. The Blender
|
||||||
|
* Foundation also sells licenses for use in proprietary software under
|
||||||
|
* the Blender License. See http://www.blender.org/BL/ for information
|
||||||
|
* about this.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software Foundation,
|
||||||
|
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
*
|
||||||
|
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* This is a new part of Blender.
|
||||||
|
*
|
||||||
|
* Contributor(s): Willian P. Germano.
|
||||||
|
*
|
||||||
|
* ***** END GPL/BL DUAL LICENSE BLOCK *****
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef DNA_SCRIPT_TYPES_H
|
||||||
|
#define DNA_SCRIPT_TYPES_H
|
||||||
|
|
||||||
|
#include "DNA_listBase.h"
|
||||||
|
#include "DNA_ID.h"
|
||||||
|
|
||||||
|
typedef struct Script {
|
||||||
|
ID id;
|
||||||
|
|
||||||
|
char *filename; /* NULL for Blender Text scripts */
|
||||||
|
|
||||||
|
void *py_draw;
|
||||||
|
void *py_event;
|
||||||
|
void *py_button;
|
||||||
|
void *py_globaldict;
|
||||||
|
|
||||||
|
int flags, lastspace;
|
||||||
|
|
||||||
|
} Script;
|
||||||
|
|
||||||
|
/* Note: a script that registers callbacks in the script->py_* pointers
|
||||||
|
* above (or calls the file or image selectors) needs to keep its global
|
||||||
|
* dictionary until Draw.Exit() is called and the callbacks removed.
|
||||||
|
* Unsetting SCRIPT_RUNNING means the interpreter reached the end of the
|
||||||
|
* script and returned control to Blender, but we can't get rid of its
|
||||||
|
* namespace (global dictionary) while SCRIPT_GUI or SCRIPT_FILESEL is set,
|
||||||
|
* because of the callbacks. The flags and the script name are saved in
|
||||||
|
* each running script's global dictionary, under '__script__'. */
|
||||||
|
|
||||||
|
/* Flags */
|
||||||
|
#define SCRIPT_RUNNING 0x01
|
||||||
|
#define SCRIPT_GUI 0x02
|
||||||
|
#define SCRIPT_FILESEL 0x04
|
||||||
|
|
||||||
|
#endif /* DNA_SCRIPT_TYPES_H */
|
||||||
@@ -42,6 +42,7 @@
|
|||||||
struct Ipo;
|
struct Ipo;
|
||||||
struct ID;
|
struct ID;
|
||||||
struct Text;
|
struct Text;
|
||||||
|
struct Script;
|
||||||
struct ImBuf;
|
struct ImBuf;
|
||||||
struct Image;
|
struct Image;
|
||||||
struct SpaceIpo;
|
struct SpaceIpo;
|
||||||
@@ -250,13 +251,20 @@ typedef struct SpaceText {
|
|||||||
float pix_per_line;
|
float pix_per_line;
|
||||||
|
|
||||||
struct rcti txtscroll, txtbar;
|
struct rcti txtscroll, txtbar;
|
||||||
|
|
||||||
void *py_draw;
|
|
||||||
void *py_event;
|
|
||||||
void *py_button;
|
|
||||||
void *py_globaldict;
|
|
||||||
} SpaceText;
|
} SpaceText;
|
||||||
|
|
||||||
|
typedef struct SpaceScript {
|
||||||
|
SpaceLink *next, *prev;
|
||||||
|
int spacetype, pad1;
|
||||||
|
struct ScrArea *area;
|
||||||
|
struct Script *script;
|
||||||
|
|
||||||
|
int pad2;
|
||||||
|
short flags, menunr;
|
||||||
|
|
||||||
|
} SpaceScript;
|
||||||
|
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
typedef struct OneSelectableIma {
|
typedef struct OneSelectableIma {
|
||||||
|
|||||||
@@ -41,6 +41,8 @@ struct ID; /* defined in DNA_ID.h */
|
|||||||
struct ScriptLink; /* defined in DNA_scriptlink_types.h */
|
struct ScriptLink; /* defined in DNA_scriptlink_types.h */
|
||||||
struct ListBase; /* defined in DNA_listBase.h */
|
struct ListBase; /* defined in DNA_listBase.h */
|
||||||
struct SpaceText; /* defined in DNA_space_types.h */
|
struct SpaceText; /* defined in DNA_space_types.h */
|
||||||
|
struct SpaceScript;/* defined in DNA_space_types.h */
|
||||||
|
struct Script; /* defined in DNA_script_types.h */
|
||||||
/*
|
/*
|
||||||
struct _object; // forward declaration for PyObject !
|
struct _object; // forward declaration for PyObject !
|
||||||
*/
|
*/
|
||||||
@@ -51,7 +53,7 @@ void BPY_syspath_append_pythondir(void);
|
|||||||
int BPY_Err_getLinenumber(void);
|
int BPY_Err_getLinenumber(void);
|
||||||
const char *BPY_Err_getFilename(void);
|
const char *BPY_Err_getFilename(void);
|
||||||
/* void BPY_Err_Handle(struct Text *text); */
|
/* void BPY_Err_Handle(struct Text *text); */
|
||||||
struct _object *BPY_txt_do_python(struct SpaceText* st);
|
int BPY_txt_do_python(struct SpaceText* st);
|
||||||
void BPY_free_compiled_text(struct Text* text);
|
void BPY_free_compiled_text(struct Text* text);
|
||||||
/*void BPY_clear_bad_scriptlink(struct ID *id, struct Text *byebye); */
|
/*void BPY_clear_bad_scriptlink(struct ID *id, struct Text *byebye); */
|
||||||
void BPY_clear_bad_scriptlinks(struct Text *byebye);
|
void BPY_clear_bad_scriptlinks(struct Text *byebye);
|
||||||
@@ -64,8 +66,10 @@ void BPY_copy_scriptlink(struct ScriptLink *scriptlink);
|
|||||||
/* format importer hook */
|
/* format importer hook */
|
||||||
int BPY_call_importloader(char *name);
|
int BPY_call_importloader(char *name);
|
||||||
|
|
||||||
int BPY_spacetext_is_pywin(struct SpaceText *st);
|
//int BPY_spacetext_is_pywin(struct SpaceText *st);
|
||||||
void BPY_spacetext_do_pywin_draw(struct SpaceText *st);
|
void BPY_spacescript_do_pywin_draw(struct SpaceScript *sc);
|
||||||
void BPY_spacetext_do_pywin_event(struct SpaceText *st, unsigned short event, short val);
|
void BPY_spacescript_do_pywin_event(struct SpaceScript *sc, unsigned short event, short val);
|
||||||
|
void BPY_clear_script(struct Script *script);
|
||||||
|
void BPY_free_finished_script(struct Script *script);
|
||||||
|
|
||||||
void init_syspath(void);
|
void init_syspath(void);
|
||||||
|
|||||||
@@ -39,10 +39,10 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
#include <MEM_guardedalloc.h>
|
#include <MEM_guardedalloc.h>
|
||||||
|
|
||||||
#include <BLI_blenlib.h> /* for BLI_last_slash() */
|
#include <BLI_blenlib.h> /* for BLI_last_slash() */
|
||||||
|
|
||||||
#include <BKE_global.h>
|
#include <BKE_global.h>
|
||||||
|
#include <BKE_library.h>
|
||||||
#include <BKE_main.h>
|
#include <BKE_main.h>
|
||||||
#include <BKE_text.h>
|
#include <BKE_text.h>
|
||||||
#include <DNA_camera_types.h>
|
#include <DNA_camera_types.h>
|
||||||
@@ -51,15 +51,17 @@
|
|||||||
#include <DNA_material_types.h>
|
#include <DNA_material_types.h>
|
||||||
#include <DNA_object_types.h>
|
#include <DNA_object_types.h>
|
||||||
#include <DNA_scene_types.h>
|
#include <DNA_scene_types.h>
|
||||||
|
#include <DNA_screen_types.h>
|
||||||
|
#include <DNA_script_types.h>
|
||||||
#include <DNA_scriptlink_types.h>
|
#include <DNA_scriptlink_types.h>
|
||||||
#include <DNA_space_types.h>
|
#include <DNA_space_types.h>
|
||||||
#include <DNA_text_types.h>
|
#include <DNA_text_types.h>
|
||||||
#include <DNA_world_types.h>
|
#include <DNA_world_types.h>
|
||||||
|
|
||||||
#include <DNA_userdef_types.h> /* for U.pythondir */
|
#include <DNA_userdef_types.h> /* for U.pythondir */
|
||||||
|
|
||||||
#include "BPY_extern.h"
|
#include "BPY_extern.h"
|
||||||
#include "api2_2x/EXPP_interface.h"
|
#include "api2_2x/EXPP_interface.h"
|
||||||
|
#include "api2_2x/constant.h"
|
||||||
|
|
||||||
/* bpy_registryDict is declared in api2_2x/Registry.h and defined
|
/* bpy_registryDict is declared in api2_2x/Registry.h and defined
|
||||||
* here. This Python dictionary will be used to store data that scripts
|
* here. This Python dictionary will be used to store data that scripts
|
||||||
@@ -371,81 +373,77 @@ void BPY_Err_Handle(Text *text)
|
|||||||
/* Notes: It is called by blender/src/drawtext.c when a Blender user */
|
/* Notes: It is called by blender/src/drawtext.c when a Blender user */
|
||||||
/* presses ALT+PKEY in the script's text window. */
|
/* presses ALT+PKEY in the script's text window. */
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
struct _object *BPY_txt_do_python(struct SpaceText* st)
|
int BPY_txt_do_python(struct SpaceText* st)
|
||||||
{
|
{
|
||||||
PyObject *dict, *ret;
|
PyObject *py_dict, *py_result;
|
||||||
PyObject *main_dict = PyModule_GetDict(PyImport_AddModule("__main__"));
|
BPy_constant *tracer;
|
||||||
|
Script *script = G.main->script.first;
|
||||||
|
|
||||||
if (!st->text) return NULL;
|
if (!st->text) return 0;
|
||||||
|
|
||||||
/* The EXPP_releaseGlobalDict global variable controls whether we should run
|
/* check if this text is already running */
|
||||||
* the script with a clean global dictionary or should keep the current one,
|
while (script) {
|
||||||
* possibly already "polluted" by other calls to the Python Interpreter.
|
if (!strcmp(script->id.name+2, st->text->id.name+2)) {
|
||||||
* The default is to use a clean one. To change this the script writer must
|
/* if this text is already a running script, just move to it: */
|
||||||
* call Blender.ReleaseGlobalDict(bool), with bool == 0, in the script. */
|
EXPP_move_to_spacescript (script);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
script = script->id.next;
|
||||||
|
}
|
||||||
|
|
||||||
if (EXPP_releaseGlobalDict) {
|
/* Create a new script structure and initialize it: */
|
||||||
printf("Using a clean Global Dictionary.\n");
|
script = alloc_libblock(&G.main->script, ID_SCRIPT, GetName(st->text));
|
||||||
st->flags |= ST_CLEAR_NAMESPACE;
|
|
||||||
dict = CreateGlobalDictionary();
|
if (!script) {
|
||||||
}
|
printf("couldn't allocate memory for Script struct!");
|
||||||
else
|
return 0;
|
||||||
dict = main_dict; /* must be careful not to free the main_dict */
|
}
|
||||||
|
|
||||||
|
script->id.us = 1;
|
||||||
|
script->filename = NULL; /* it's a Blender Text script */
|
||||||
|
script->flags = SCRIPT_RUNNING;
|
||||||
|
script->py_draw = NULL;
|
||||||
|
script->py_event = NULL;
|
||||||
|
script->py_button = NULL;
|
||||||
|
|
||||||
|
py_dict = CreateGlobalDictionary();
|
||||||
|
|
||||||
|
script->py_globaldict = py_dict;
|
||||||
|
|
||||||
|
/* We will insert a constant dict at this script's namespace, with the name
|
||||||
|
* of the script. Later more info can be added, if necessary. */
|
||||||
|
tracer = (BPy_constant *)M_constant_New(); /*create a constant object*/
|
||||||
|
if (tracer) {
|
||||||
|
constant_insert(tracer, "name", PyString_FromString(script->id.name+2));
|
||||||
|
}
|
||||||
|
|
||||||
|
PyDict_SetItemString(py_dict, "__script__", (PyObject *)tracer);
|
||||||
|
|
||||||
clearScriptLinks ();
|
clearScriptLinks ();
|
||||||
|
|
||||||
ret = RunPython (st->text, dict); /* Run the script */
|
py_result = RunPython (st->text, py_dict); /* Run the script */
|
||||||
|
|
||||||
if (!ret) { /* Failed execution of the script */
|
if (!py_result) { /* Failed execution of the script */
|
||||||
|
|
||||||
if (EXPP_releaseGlobalDict && (dict != main_dict))
|
|
||||||
ReleaseGlobalDictionary(dict);
|
|
||||||
|
|
||||||
BPY_Err_Handle(st->text);
|
BPY_Err_Handle(st->text);
|
||||||
|
ReleaseGlobalDictionary(py_dict);
|
||||||
|
free_libblock(&G.main->script, script);
|
||||||
BPY_end_python();
|
BPY_end_python();
|
||||||
BPY_start_python();
|
BPY_start_python();
|
||||||
|
|
||||||
return NULL;
|
return 0;
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
Py_DECREF (py_result);
|
||||||
|
script->flags &=~SCRIPT_RUNNING;
|
||||||
|
if (!script->flags) {
|
||||||
|
ReleaseGlobalDictionary(py_dict);
|
||||||
|
script->py_globaldict = NULL;
|
||||||
|
free_libblock(&G.main->script, script);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
else Py_DECREF (ret);
|
return 1; /* normal return */
|
||||||
|
|
||||||
/* Scripts that use the GUI rely on the persistent global namespace, so
|
|
||||||
* they need a workaround: The namespace is released when the GUI is exit.'
|
|
||||||
* See api2_2x/Draw.c: Method_Register() */
|
|
||||||
|
|
||||||
/* Block below: The global dict should only be released if:
|
|
||||||
* - a script didn't defined it to be persistent and
|
|
||||||
* - Draw.Register() is not in use (no GUI) and
|
|
||||||
* - it is not the real __main__ dict (if it is, restart to clean it) */
|
|
||||||
|
|
||||||
if (EXPP_releaseGlobalDict) {
|
|
||||||
if (st->flags & ST_CLEAR_NAMESPACE) { /* False if the GUI is in use */
|
|
||||||
|
|
||||||
if (dict != main_dict) ReleaseGlobalDictionary(dict);
|
|
||||||
|
|
||||||
else {
|
|
||||||
BPY_end_python(); /* restart to get a fresh __main__ dict */
|
|
||||||
BPY_start_python();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (dict != main_dict) PyDict_Update (main_dict, dict);
|
|
||||||
|
|
||||||
/* Line above: if it should be kept and it's not already the __main__ dict,
|
|
||||||
* merge it into the __main__ one. This happens when to release is the
|
|
||||||
* current behavior and the script changes that with
|
|
||||||
* Blender.ReleaseGlobalDict(0). */
|
|
||||||
|
|
||||||
/* Edited from old BPY_main.c:
|
|
||||||
* 'The return value is the global namespace dictionary of the script
|
|
||||||
* context. This may be stored in the SpaceText instance to give control
|
|
||||||
* over namespace persistence. Remember that the same script may be
|
|
||||||
* executed in several windows ... Namespace persistence is desired for
|
|
||||||
* scripts that use the GUI and store callbacks to the current script.' */
|
|
||||||
|
|
||||||
return dict;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
@@ -460,7 +458,6 @@ void BPY_free_compiled_text(struct Text* text)
|
|||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/* ScriptLinks */
|
/* ScriptLinks */
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -46,10 +46,12 @@
|
|||||||
#include "BMF_Api.h"
|
#include "BMF_Api.h"
|
||||||
|
|
||||||
#include "DNA_screen_types.h"
|
#include "DNA_screen_types.h"
|
||||||
|
#include "DNA_script_types.h"
|
||||||
#include "DNA_space_types.h"
|
#include "DNA_space_types.h"
|
||||||
#include "DNA_text_types.h"
|
#include "DNA_text_types.h"
|
||||||
|
|
||||||
#include "BKE_global.h"
|
#include "BKE_global.h"
|
||||||
|
#include "BKE_library.h"
|
||||||
|
|
||||||
#include "BIF_gl.h"
|
#include "BIF_gl.h"
|
||||||
#include "BIF_screen.h"
|
#include "BIF_screen.h"
|
||||||
@@ -77,7 +79,6 @@ int g_window_redrawn;
|
|||||||
static char Draw_doc[] =
|
static char Draw_doc[] =
|
||||||
"The Blender.Draw submodule";
|
"The Blender.Draw submodule";
|
||||||
|
|
||||||
static void exit_pydraw (SpaceText *st);
|
|
||||||
static uiBlock *Get_uiBlock (void);
|
static uiBlock *Get_uiBlock (void);
|
||||||
void initDraw (void);
|
void initDraw (void);
|
||||||
|
|
||||||
@@ -119,13 +120,14 @@ static Button *newbutton (void);
|
|||||||
|
|
||||||
/* GUI interface routines */
|
/* GUI interface routines */
|
||||||
|
|
||||||
static void exit_pydraw(SpaceText *st);
|
static void exit_pydraw(SpaceScript *sc, short error);
|
||||||
static void exec_callback(SpaceText *st, PyObject *callback, PyObject *args);
|
static void exec_callback(SpaceScript *sc, PyObject *callback, PyObject *args);
|
||||||
void BPY_spacetext_do_pywin_draw(SpaceText *st);
|
|
||||||
static void spacetext_do_pywin_buttons(SpaceText *st, unsigned short event);
|
/* these are declared in ../BPY_extern.h */
|
||||||
void BPY_spacetext_do_pywin_event(SpaceText *st,
|
void BPY_spacescript_do_pywin_draw(SpaceScript *sc);
|
||||||
unsigned short event, short val);
|
static void spacescript_do_pywin_buttons(SpaceScript *sc, unsigned short event);
|
||||||
int BPY_spacetext_is_pywin(SpaceText *sc);
|
void BPY_spacescript_do_pywin_event(SpaceScript *sc, unsigned short event, short val);
|
||||||
|
void BPY_free_compiled_text(Text *text);
|
||||||
|
|
||||||
static char Method_Exit_doc[] =
|
static char Method_Exit_doc[] =
|
||||||
"() - Exit the windowing interface";
|
"() - Exit the windowing interface";
|
||||||
|
|||||||
@@ -33,7 +33,10 @@
|
|||||||
|
|
||||||
#include <Python.h>
|
#include <Python.h>
|
||||||
|
|
||||||
|
#include <BIF_space.h>
|
||||||
|
#include <BIF_screen.h>
|
||||||
#include <BKE_global.h>
|
#include <BKE_global.h>
|
||||||
|
#include <BKE_library.h>
|
||||||
#include <BKE_main.h>
|
#include <BKE_main.h>
|
||||||
#include <DNA_ID.h>
|
#include <DNA_ID.h>
|
||||||
#include <DNA_camera_types.h>
|
#include <DNA_camera_types.h>
|
||||||
@@ -41,7 +44,10 @@
|
|||||||
#include <DNA_material_types.h>
|
#include <DNA_material_types.h>
|
||||||
#include <DNA_object_types.h>
|
#include <DNA_object_types.h>
|
||||||
#include <DNA_scene_types.h>
|
#include <DNA_scene_types.h>
|
||||||
|
#include <DNA_screen_types.h>
|
||||||
|
#include <DNA_script_types.h>
|
||||||
#include <DNA_scriptlink_types.h>
|
#include <DNA_scriptlink_types.h>
|
||||||
|
#include <DNA_space_types.h>
|
||||||
#include <DNA_world_types.h>
|
#include <DNA_world_types.h>
|
||||||
|
|
||||||
#include "EXPP_interface.h"
|
#include "EXPP_interface.h"
|
||||||
@@ -177,3 +183,42 @@ TODO: Check this */
|
|||||||
|
|
||||||
return (scriptlink);
|
return (scriptlink);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void BPY_clear_script (Script *script)
|
||||||
|
{
|
||||||
|
if (!script) return;
|
||||||
|
|
||||||
|
Py_XDECREF((PyObject *)script->py_globaldict);
|
||||||
|
Py_XDECREF((PyObject *)script->py_button);
|
||||||
|
Py_XDECREF((PyObject *)script->py_event);
|
||||||
|
Py_XDECREF((PyObject *)script->py_draw);
|
||||||
|
}
|
||||||
|
|
||||||
|
void EXPP_move_to_spacescript (Script *script)
|
||||||
|
{ /* used by BPY_txt_do_python when a text is already being executed */
|
||||||
|
SpaceScript *sc;
|
||||||
|
newspace(curarea, SPACE_SCRIPT);
|
||||||
|
sc = curarea->spacedata.first;
|
||||||
|
sc->script = script;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/* Description: This function frees a finished (flags == 0) script. */
|
||||||
|
/*****************************************************************************/
|
||||||
|
void BPY_free_finished_script(Script *script)
|
||||||
|
{
|
||||||
|
PyObject *d = script->py_globaldict;
|
||||||
|
|
||||||
|
if (d) {
|
||||||
|
PyDict_Clear (d);
|
||||||
|
Py_DECREF (d); /* Release dictionary. */
|
||||||
|
script->py_globaldict = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (script->lastspace != SPACE_SCRIPT)
|
||||||
|
newspace (curarea, script->lastspace);
|
||||||
|
|
||||||
|
free_libblock(&G.main->script, script);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|||||||
@@ -31,7 +31,10 @@
|
|||||||
|
|
||||||
#include <DNA_ID.h>
|
#include <DNA_ID.h>
|
||||||
|
|
||||||
|
struct Script;
|
||||||
|
|
||||||
void initBlenderApi2_2x (void);
|
void initBlenderApi2_2x (void);
|
||||||
void clearScriptLinks (void);
|
void clearScriptLinks (void);
|
||||||
ScriptLink * setScriptLinks(ID *id, short event);
|
ScriptLink * setScriptLinks(ID *id, short event);
|
||||||
void discardFromBDict (char *key);
|
void discardFromBDict (char *key);
|
||||||
|
void EXPP_move_to_spacescript (struct Script *script);
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ static PyObject *M_sys_dirname (PyObject *self, PyObject *args)
|
|||||||
{
|
{
|
||||||
PyObject *c;
|
PyObject *c;
|
||||||
|
|
||||||
char *name, dirname[256];
|
char *name, *p, dirname[256];
|
||||||
char sep;
|
char sep;
|
||||||
int n;
|
int n;
|
||||||
|
|
||||||
@@ -74,14 +74,20 @@ static PyObject *M_sys_dirname (PyObject *self, PyObject *args)
|
|||||||
sep = PyString_AsString(c)[0];
|
sep = PyString_AsString(c)[0];
|
||||||
Py_DECREF(c);
|
Py_DECREF(c);
|
||||||
|
|
||||||
n = strrchr(name, sep) - name;
|
p = strrchr(name, sep);
|
||||||
if (n > 255) {
|
|
||||||
PyErr_SetString(PyExc_RuntimeError, "path too long");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
strncpy(dirname, name, n);
|
if (p) {
|
||||||
dirname[n] = 0;
|
n = p - name;
|
||||||
|
|
||||||
return Py_BuildValue("s", dirname);
|
if (n > 255) {
|
||||||
|
PyErr_SetString(PyExc_RuntimeError, "path too long");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
strncpy(dirname, name, n);
|
||||||
|
dirname[n] = 0;
|
||||||
|
return Py_BuildValue("s", dirname);
|
||||||
|
}
|
||||||
|
|
||||||
|
return Py_BuildValue("s", "."); /* XXX need to fix this? (is crossplatform?)*/
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,7 +17,7 @@
|
|||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program; if not, write to the Free Software Foundation,
|
* along with this program; if not, write to the Free Software Foundation,
|
||||||
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
*
|
*
|
||||||
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
|
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
@@ -31,90 +31,90 @@
|
|||||||
|
|
||||||
#include "Window.h"
|
#include "Window.h"
|
||||||
#include "vector.h"
|
#include "vector.h"
|
||||||
|
#include <BKE_library.h>
|
||||||
|
|
||||||
/* Many parts of the code here come from the older bpython implementation
|
/* Many parts of the code here come from the older bpython implementation
|
||||||
* (file opy_window.c) */
|
* (file opy_window.c) */
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/* Function: M_Window_Redraw */
|
/* Function: M_Window_Redraw */
|
||||||
/* Python equivalent: Blender.Window.Redraw */
|
/* Python equivalent: Blender.Window.Redraw */
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
PyObject *M_Window_Redraw(PyObject *self, PyObject *args)
|
PyObject *M_Window_Redraw(PyObject *self, PyObject *args)
|
||||||
{ /* not static so py_slider_update in Draw.[ch] can use it */
|
{ /* not static so py_slider_update in Draw.[ch] can use it */
|
||||||
ScrArea *tempsa, *sa;
|
ScrArea *tempsa, *sa;
|
||||||
SpaceText *st;
|
SpaceText *st;
|
||||||
int wintype = SPACE_VIEW3D;
|
int wintype = SPACE_VIEW3D;
|
||||||
short redraw_all = 0;
|
short redraw_all = 0;
|
||||||
|
|
||||||
if (!PyArg_ParseTuple(args, "|i", &wintype))
|
if (!PyArg_ParseTuple(args, "|i", &wintype))
|
||||||
return (EXPP_ReturnPyObjError (PyExc_AttributeError,
|
return (EXPP_ReturnPyObjError (PyExc_AttributeError,
|
||||||
"expected int argument (or nothing)"));
|
"expected int argument (or nothing)"));
|
||||||
|
|
||||||
if (wintype < 0)
|
if (wintype < 0)
|
||||||
redraw_all = 1;
|
redraw_all = 1;
|
||||||
|
|
||||||
if (!during_script()) { /* XXX check this */
|
if (!during_script()) { /* XXX check this */
|
||||||
tempsa= curarea;
|
tempsa= curarea;
|
||||||
sa = G.curscreen->areabase.first;
|
sa = G.curscreen->areabase.first;
|
||||||
|
|
||||||
while (sa) {
|
while (sa) {
|
||||||
|
|
||||||
if (sa->spacetype == wintype || redraw_all) {
|
if (sa->spacetype == wintype || redraw_all) {
|
||||||
/* don't force-redraw Text window (Python GUI) when
|
/* don't force-redraw Text window (Python GUI) when
|
||||||
redraw is called out of a slider update */
|
redraw is called out of a slider update */
|
||||||
if (sa->spacetype == SPACE_TEXT) {
|
if (sa->spacetype == SPACE_TEXT) {
|
||||||
st = sa->spacedata.first;
|
st = sa->spacedata.first;
|
||||||
if (st->text->flags & TXT_FOLLOW) /* follow cursor display */
|
if (st->text->flags & TXT_FOLLOW) /* follow cursor display */
|
||||||
pop_space_text(st);
|
pop_space_text(st);
|
||||||
if (EXPP_disable_force_draw) { /* defined in Draw.[ch] ... */
|
if (EXPP_disable_force_draw) { /* defined in Draw.[ch] ... */
|
||||||
scrarea_queue_redraw(sa);
|
scrarea_queue_redraw(sa);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
scrarea_do_windraw(sa);
|
||||||
|
if (sa->headwin) scrarea_do_headdraw(sa);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
} else {
|
sa= sa->next;
|
||||||
scrarea_do_windraw(sa);
|
}
|
||||||
if (sa->headwin) scrarea_do_headdraw(sa);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
sa= sa->next;
|
if (curarea != tempsa) areawinset (tempsa->win);
|
||||||
}
|
|
||||||
|
|
||||||
if (curarea != tempsa) areawinset (tempsa->win);
|
if (curarea->headwin) scrarea_do_headdraw (curarea);
|
||||||
|
|
||||||
if (curarea->headwin) scrarea_do_headdraw (curarea);
|
screen_swapbuffers();
|
||||||
|
}
|
||||||
|
|
||||||
screen_swapbuffers();
|
Py_INCREF(Py_None);
|
||||||
}
|
return Py_None;
|
||||||
|
|
||||||
Py_INCREF(Py_None);
|
|
||||||
return Py_None;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/* Function: M_Window_RedrawAll */
|
/* Function: M_Window_RedrawAll */
|
||||||
/* Python equivalent: Blender.Window.RedrawAll */
|
/* Python equivalent: Blender.Window.RedrawAll */
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
static PyObject *M_Window_RedrawAll(PyObject *self, PyObject *args)
|
static PyObject *M_Window_RedrawAll(PyObject *self, PyObject *args)
|
||||||
{
|
{
|
||||||
return M_Window_Redraw(self, Py_BuildValue("(i)", -1));
|
return M_Window_Redraw(self, Py_BuildValue("(i)", -1));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/* Function: M_Window_QRedrawAll */
|
/* Function: M_Window_QRedrawAll */
|
||||||
/* Python equivalent: Blender.Window.QRedrawAll */
|
/* Python equivalent: Blender.Window.QRedrawAll */
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
static PyObject *M_Window_QRedrawAll(PyObject *self, PyObject *args)
|
static PyObject *M_Window_QRedrawAll(PyObject *self, PyObject *args)
|
||||||
{
|
{
|
||||||
allqueue(REDRAWALL, 0);
|
allqueue(REDRAWALL, 0);
|
||||||
|
|
||||||
Py_INCREF(Py_None);
|
Py_INCREF(Py_None);
|
||||||
return Py_None;
|
return Py_None;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/* Function: M_Window_FileSelector */
|
/* Function: M_Window_FileSelector */
|
||||||
/* Python equivalent: Blender.Window.FileSelector */
|
/* Python equivalent: Blender.Window.FileSelector */
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
/* This is the callback to "activate_fileselect" below. It receives the
|
/* This is the callback to "activate_fileselect" below. It receives the
|
||||||
@@ -123,101 +123,147 @@ static PyObject *M_Window_QRedrawAll(PyObject *self, PyObject *args)
|
|||||||
|
|
||||||
static void getSelectedFile(char *name)
|
static void getSelectedFile(char *name)
|
||||||
{
|
{
|
||||||
if (EXPP_FS_PyCallback) {
|
if (!EXPP_FS_PyCallback) return;
|
||||||
SpaceText *st= curarea->spacedata.first;
|
|
||||||
|
|
||||||
PyObject_CallFunction((PyObject *)EXPP_FS_PyCallback, "s", name);
|
PyObject_CallFunction((PyObject *)EXPP_FS_PyCallback, "s", name);
|
||||||
|
|
||||||
EXPP_FS_PyCallback = NULL;
|
EXPP_FS_PyCallback = NULL;
|
||||||
st->flags &= ST_CLEAR_NAMESPACE; /* global dict can be cleared */
|
|
||||||
}
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *M_Window_FileSelector(PyObject *self, PyObject *args)
|
static PyObject *M_Window_FileSelector(PyObject *self, PyObject *args)
|
||||||
{
|
{
|
||||||
char *title = "SELECT FILE";
|
char *title = "SELECT FILE";
|
||||||
SpaceText *st = curarea->spacedata.first;
|
SpaceScript *sc;
|
||||||
|
Script *script = G.main->script.last;
|
||||||
|
int startspace = 0;
|
||||||
|
|
||||||
if (!PyArg_ParseTuple(args, "O!|s",
|
if (!PyArg_ParseTuple(args, "O!|s", &PyFunction_Type, &EXPP_FS_PyCallback,
|
||||||
&PyFunction_Type, &EXPP_FS_PyCallback, &title))
|
&title))
|
||||||
return (EXPP_ReturnPyObjError (PyExc_AttributeError,
|
return (EXPP_ReturnPyObjError (PyExc_AttributeError,
|
||||||
"\nexpected a callback function (and optionally a string) as argument(s)"));
|
"\nexpected a callback function (and optionally a string) as argument(s)"));
|
||||||
|
|
||||||
st->flags &= ~ST_CLEAR_NAMESPACE; /* so global dict won't be cleared */
|
/* trick: we move to a spacescript because then the fileselector will properly
|
||||||
|
* unset our SCRIPT_FILESEL flag when the user chooses a file or cancels the
|
||||||
|
* selection. This is necessary because when a user cancels, the
|
||||||
|
* getSelectedFile function above doesn't get called and so couldn't unset the
|
||||||
|
* flag. */
|
||||||
|
startspace = curarea->spacetype;
|
||||||
|
if (startspace != SPACE_SCRIPT) newspace (curarea, SPACE_SCRIPT);
|
||||||
|
|
||||||
activate_fileselect(FILE_BLENDER, title, G.sce, getSelectedFile);
|
sc = curarea->spacedata.first;
|
||||||
|
|
||||||
Py_INCREF(Py_None);
|
/* did we get the right script? */
|
||||||
return Py_None;
|
if (!(script->flags & SCRIPT_RUNNING)) {
|
||||||
|
/* if not running, then we were already on a SpaceScript space, executing
|
||||||
|
* a registered callback -- aka: this script has a gui */
|
||||||
|
script = sc->script; /* this is the right script */
|
||||||
|
}
|
||||||
|
else { /* still running, use the trick */
|
||||||
|
script->lastspace = startspace;
|
||||||
|
sc->script = script;
|
||||||
|
}
|
||||||
|
|
||||||
|
script->flags |= SCRIPT_FILESEL;
|
||||||
|
|
||||||
|
activate_fileselect(FILE_BLENDER, title, G.sce, getSelectedFile);
|
||||||
|
|
||||||
|
Py_INCREF(Py_None);
|
||||||
|
return Py_None;
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *M_Window_ImageSelector(PyObject *self, PyObject *args)
|
static PyObject *M_Window_ImageSelector(PyObject *self, PyObject *args)
|
||||||
{
|
{
|
||||||
char *title = "SELECT IMAGE";
|
char *title = "SELECT IMAGE";
|
||||||
SpaceText *st = curarea->spacedata.first;
|
SpaceScript *sc;
|
||||||
|
Script *script = G.main->script.last;
|
||||||
|
int startspace = 0;
|
||||||
|
|
||||||
if (!PyArg_ParseTuple(args, "O!|s",
|
if (!PyArg_ParseTuple(args, "O!|s", &PyFunction_Type, &EXPP_FS_PyCallback,
|
||||||
&PyFunction_Type, &EXPP_FS_PyCallback, &title))
|
&title))
|
||||||
return (EXPP_ReturnPyObjError (PyExc_AttributeError,
|
return (EXPP_ReturnPyObjError (PyExc_AttributeError,
|
||||||
"\nexpected a callback function (and optionally a string) as argument(s)"));
|
"\nexpected a callback function (and optionally a string) as argument(s)"));
|
||||||
|
|
||||||
st->flags &= ~ST_CLEAR_NAMESPACE; /* hold global dictionary */
|
/* trick: we move to a spacescript because then the fileselector will properly
|
||||||
|
* unset our SCRIPT_FILESEL flag when the user chooses a file or cancels the
|
||||||
|
* selection. This is necessary because when a user cancels, the
|
||||||
|
* getSelectedFile function above doesn't get called and so couldn't unset the
|
||||||
|
* flag. */
|
||||||
|
startspace = curarea->spacetype;
|
||||||
|
if (startspace != SPACE_SCRIPT) newspace (curarea, SPACE_SCRIPT);
|
||||||
|
|
||||||
activate_imageselect(FILE_BLENDER, title, G.sce, getSelectedFile);
|
sc = curarea->spacedata.first;
|
||||||
|
|
||||||
Py_INCREF(Py_None);
|
/* did we get the right script? */
|
||||||
return Py_None;
|
if (!(script->flags & SCRIPT_RUNNING)) {
|
||||||
|
/* if not running, then we're on a SpaceScript space, executing a
|
||||||
|
* registered callback -- aka: this script has a gui */
|
||||||
|
SpaceScript *sc = curarea->spacedata.first;
|
||||||
|
script = sc->script; /* this is the right script */
|
||||||
|
}
|
||||||
|
else { /* still running, use the trick */
|
||||||
|
script->lastspace = startspace;
|
||||||
|
sc->script = script;
|
||||||
|
}
|
||||||
|
|
||||||
|
script->flags |= SCRIPT_FILESEL; /* same flag as filesel */
|
||||||
|
|
||||||
|
activate_imageselect(FILE_BLENDER, title, G.sce, getSelectedFile);
|
||||||
|
|
||||||
|
Py_INCREF(Py_None);
|
||||||
|
return Py_None;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/* Function: M_Window_DrawProgressBar */
|
/* Function: M_Window_DrawProgressBar */
|
||||||
/* Python equivalent: Blender.Window.DrawProgressBar */
|
/* Python equivalent: Blender.Window.DrawProgressBar */
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
static PyObject *M_Window_DrawProgressBar(PyObject *self, PyObject *args)
|
static PyObject *M_Window_DrawProgressBar(PyObject *self, PyObject *args)
|
||||||
{
|
{
|
||||||
float done;
|
float done;
|
||||||
char *info = NULL;
|
char *info = NULL;
|
||||||
int retval;
|
int retval;
|
||||||
|
|
||||||
if(!PyArg_ParseTuple(args, "fs", &done, &info))
|
if(!PyArg_ParseTuple(args, "fs", &done, &info))
|
||||||
return (EXPP_ReturnPyObjError (PyExc_AttributeError,
|
return (EXPP_ReturnPyObjError (PyExc_AttributeError,
|
||||||
"expected a float and a string as arguments"));
|
"expected a float and a string as arguments"));
|
||||||
|
|
||||||
retval = progress_bar(done, info);
|
retval = progress_bar(done, info);
|
||||||
|
|
||||||
return Py_BuildValue("i", retval);
|
return Py_BuildValue("i", retval);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/* Function: M_Window_GetCursorPos */
|
/* Function: M_Window_GetCursorPos */
|
||||||
/* Python equivalent: Blender.Window.GetCursorPos */
|
/* Python equivalent: Blender.Window.GetCursorPos */
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
static PyObject *M_Window_GetCursorPos(PyObject *self)
|
static PyObject *M_Window_GetCursorPos(PyObject *self)
|
||||||
{
|
{
|
||||||
float *cursor = NULL;
|
float *cursor = NULL;
|
||||||
PyObject *pylist;
|
PyObject *pylist;
|
||||||
|
|
||||||
if (G.vd && G.vd->localview)
|
if (G.vd && G.vd->localview)
|
||||||
cursor = G.vd->cursor;
|
cursor = G.vd->cursor;
|
||||||
else cursor = G.scene->cursor;
|
else cursor = G.scene->cursor;
|
||||||
|
|
||||||
pylist = Py_BuildValue("[fff]", cursor[0], cursor[1], cursor[2]);
|
pylist = Py_BuildValue("[fff]", cursor[0], cursor[1], cursor[2]);
|
||||||
|
|
||||||
if (!pylist)
|
if (!pylist)
|
||||||
return (EXPP_ReturnPyObjError (PyExc_MemoryError,
|
return (EXPP_ReturnPyObjError (PyExc_MemoryError,
|
||||||
"GetCursorPos: couldn't create pylist"));
|
"GetCursorPos: couldn't create pylist"));
|
||||||
|
|
||||||
return pylist;
|
return pylist;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/* Function: M_Window_SetCursorPos */
|
/* Function: M_Window_SetCursorPos */
|
||||||
/* Python equivalent: Blender.Window.SetCursorPos */
|
/* Python equivalent: Blender.Window.SetCursorPos */
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
static PyObject *M_Window_SetCursorPos(PyObject *self, PyObject *args)
|
static PyObject *M_Window_SetCursorPos(PyObject *self, PyObject *args)
|
||||||
{
|
{
|
||||||
int ok = 0;
|
int ok = 0;
|
||||||
float val[3];
|
float val[3];
|
||||||
|
|
||||||
if (PyObject_Length (args) == 3)
|
if (PyObject_Length (args) == 3)
|
||||||
ok = PyArg_ParseTuple (args, "fff", &val[0], &val[1], &val[2]);
|
ok = PyArg_ParseTuple (args, "fff", &val[0], &val[1], &val[2]);
|
||||||
@@ -228,12 +274,12 @@ static PyObject *M_Window_SetCursorPos(PyObject *self, PyObject *args)
|
|||||||
return EXPP_ReturnPyObjError (PyExc_TypeError,
|
return EXPP_ReturnPyObjError (PyExc_TypeError,
|
||||||
"expected [f,f,f] or f,f,f as arguments");
|
"expected [f,f,f] or f,f,f as arguments");
|
||||||
|
|
||||||
if (G.vd && G.vd->localview) {
|
if (G.vd && G.vd->localview) {
|
||||||
G.vd->cursor[0] = val[0];
|
G.vd->cursor[0] = val[0];
|
||||||
G.vd->cursor[1] = val[1];
|
G.vd->cursor[1] = val[1];
|
||||||
G.vd->cursor[2] = val[2];
|
G.vd->cursor[2] = val[2];
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
G.scene->cursor[0] = val[0];
|
G.scene->cursor[0] = val[0];
|
||||||
G.scene->cursor[1] = val[1];
|
G.scene->cursor[1] = val[1];
|
||||||
G.scene->cursor[2] = val[2];
|
G.scene->cursor[2] = val[2];
|
||||||
@@ -244,70 +290,70 @@ static PyObject *M_Window_SetCursorPos(PyObject *self, PyObject *args)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/* Function: M_Window_GetViewVector */
|
/* Function: M_Window_GetViewVector */
|
||||||
/* Python equivalent: Blender.Window.GetViewVector */
|
/* Python equivalent: Blender.Window.GetViewVector */
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
static PyObject *M_Window_GetViewVector(PyObject *self)
|
static PyObject *M_Window_GetViewVector(PyObject *self)
|
||||||
{
|
{
|
||||||
float *vec = NULL;
|
float *vec = NULL;
|
||||||
PyObject *pylist;
|
PyObject *pylist;
|
||||||
|
|
||||||
if (!G.vd) {
|
if (!G.vd) {
|
||||||
Py_INCREF (Py_None);
|
Py_INCREF (Py_None);
|
||||||
return Py_None;
|
return Py_None;
|
||||||
}
|
}
|
||||||
|
|
||||||
vec = G.vd->viewinv[2];
|
vec = G.vd->viewinv[2];
|
||||||
|
|
||||||
pylist = Py_BuildValue("[fff]", vec[0], vec[1], vec[2]);
|
pylist = Py_BuildValue("[fff]", vec[0], vec[1], vec[2]);
|
||||||
|
|
||||||
if (!pylist)
|
if (!pylist)
|
||||||
return (EXPP_ReturnPyObjError (PyExc_MemoryError,
|
return (EXPP_ReturnPyObjError (PyExc_MemoryError,
|
||||||
"GetViewVector: couldn't create pylist"));
|
"GetViewVector: couldn't create pylist"));
|
||||||
|
|
||||||
return pylist;
|
return pylist;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/* Function: M_Window_GetViewMatrix */
|
/* Function: M_Window_GetViewMatrix */
|
||||||
/* Python equivalent: Blender.Window.GetViewMatrix */
|
/* Python equivalent: Blender.Window.GetViewMatrix */
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
static PyObject *M_Window_GetViewMatrix(PyObject *self)
|
static PyObject *M_Window_GetViewMatrix(PyObject *self)
|
||||||
{
|
{
|
||||||
PyObject *viewmat;
|
PyObject *viewmat;
|
||||||
|
|
||||||
if (!G.vd) {
|
if (!G.vd) {
|
||||||
Py_INCREF (Py_None);
|
Py_INCREF (Py_None);
|
||||||
return Py_None;
|
return Py_None;
|
||||||
}
|
}
|
||||||
|
|
||||||
viewmat = newMatrixObject (G.vd->viewmat);
|
viewmat = newMatrixObject (G.vd->viewmat);
|
||||||
|
|
||||||
if (!viewmat)
|
if (!viewmat)
|
||||||
return (EXPP_ReturnPyObjError (PyExc_MemoryError,
|
return (EXPP_ReturnPyObjError (PyExc_MemoryError,
|
||||||
"GetViewMatrix: couldn't create matrix pyobject"));
|
"GetViewMatrix: couldn't create matrix pyobject"));
|
||||||
|
|
||||||
return viewmat;
|
return viewmat;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/* Function: Window_Init */
|
/* Function: Window_Init */
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
PyObject *Window_Init (void)
|
PyObject *Window_Init (void)
|
||||||
{
|
{
|
||||||
PyObject *submodule, *Types;
|
PyObject *submodule, *Types;
|
||||||
|
|
||||||
submodule = Py_InitModule3("Blender.Window", M_Window_methods, M_Window_doc);
|
submodule = Py_InitModule3("Blender.Window", M_Window_methods, M_Window_doc);
|
||||||
|
|
||||||
Types = Py_BuildValue("{s:h,s:h,s:h,s:h,s:h,s:h,s:h,s:h,s:h,s:h,s:h,s:h,s:h}",
|
Types = Py_BuildValue("{s:h,s:h,s:h,s:h,s:h,s:h,s:h,s:h,s:h,s:h,s:h,s:h,s:h,s:h}",
|
||||||
"VIEW3D", SPACE_VIEW3D, "IPO", SPACE_IPO, "OOPS", SPACE_OOPS,
|
"VIEW3D", SPACE_VIEW3D, "IPO", SPACE_IPO, "OOPS", SPACE_OOPS,
|
||||||
"BUTS", SPACE_BUTS, "FILE", SPACE_FILE, "IMAGE", SPACE_IMAGE,
|
"BUTS", SPACE_BUTS, "FILE", SPACE_FILE, "IMAGE", SPACE_IMAGE,
|
||||||
"INFO", SPACE_INFO, "SEQ", SPACE_SEQ, "IMASEL", SPACE_IMASEL,
|
"INFO", SPACE_INFO, "SEQ", SPACE_SEQ, "IMASEL", SPACE_IMASEL,
|
||||||
"SOUND", SPACE_SOUND, "ACTION", SPACE_ACTION,
|
"SOUND", SPACE_SOUND, "ACTION", SPACE_ACTION,
|
||||||
"TEXT", SPACE_TEXT, "NLA", SPACE_NLA);
|
"TEXT", SPACE_TEXT, "NLA", SPACE_NLA, "SCRIPT", SPACE_SCRIPT);
|
||||||
|
|
||||||
if (Types) PyModule_AddObject(submodule, "Types", Types);
|
if (Types) PyModule_AddObject(submodule, "Types", Types);
|
||||||
|
|
||||||
return submodule;
|
return submodule;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -30,6 +30,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "gen_utils.h"
|
#include "gen_utils.h"
|
||||||
|
#include "constant.h"
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/* Description: This function clamps an int to the given interval */
|
/* Description: This function clamps an int to the given interval */
|
||||||
@@ -184,13 +185,9 @@ PyObject *EXPP_tuple_repr(PyObject *self, int size)
|
|||||||
Py_DECREF(item);
|
Py_DECREF(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return repr;
|
return repr;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/****************************************************************************/
|
/****************************************************************************/
|
||||||
/* Description: searches through a map for a pair with a given name. If the */
|
/* Description: searches through a map for a pair with a given name. If the */
|
||||||
/* pair is present, its ival is stored in *ival and nonzero is */
|
/* pair is present, its ival is stored in *ival and nonzero is */
|
||||||
@@ -238,20 +235,16 @@ int EXPP_map_getShortVal (const EXPP_map_pair *map,
|
|||||||
/* and nonzero is returned. If the pair is absent, zero is */
|
/* and nonzero is returned. If the pair is absent, zero is */
|
||||||
/* returned. */
|
/* returned. */
|
||||||
/****************************************************************************/
|
/****************************************************************************/
|
||||||
int EXPP_map_getStrVal (const EXPP_map_pair *map,
|
int EXPP_map_getStrVal (const EXPP_map_pair *map, int ival, const char **sval)
|
||||||
int ival, const char **sval)
|
|
||||||
{
|
{
|
||||||
while (map->sval)
|
while (map->sval)
|
||||||
|
{
|
||||||
|
if (ival == map->ival)
|
||||||
{
|
{
|
||||||
if (ival == map->ival)
|
*sval = map->sval;
|
||||||
{
|
return 1;
|
||||||
*sval = map->sval;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
++map;
|
|
||||||
}
|
}
|
||||||
return 0;
|
++map;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -33,6 +33,8 @@
|
|||||||
#define EXPP_gen_utils_h
|
#define EXPP_gen_utils_h
|
||||||
|
|
||||||
#include <Python.h>
|
#include <Python.h>
|
||||||
|
#include "compile.h"
|
||||||
|
#include "eval.h" /* for PyEval_GetLocals */
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
@@ -41,6 +43,7 @@
|
|||||||
#include <DNA_ID.h>
|
#include <DNA_ID.h>
|
||||||
#include <DNA_object_types.h>
|
#include <DNA_object_types.h>
|
||||||
#include <DNA_material_types.h>
|
#include <DNA_material_types.h>
|
||||||
|
#include <DNA_script_types.h>
|
||||||
#include <DNA_scriptlink_types.h>
|
#include <DNA_scriptlink_types.h>
|
||||||
#include <DNA_listBase.h>
|
#include <DNA_listBase.h>
|
||||||
|
|
||||||
@@ -63,7 +66,6 @@ int EXPP_ReturnIntError (PyObject *type, char *error_msg);
|
|||||||
int EXPP_check_sequence_consistency (PyObject *seq, PyTypeObject *against);
|
int EXPP_check_sequence_consistency (PyObject *seq, PyTypeObject *against);
|
||||||
PyObject *EXPP_tuple_repr(PyObject *self, int size);
|
PyObject *EXPP_tuple_repr(PyObject *self, int size);
|
||||||
|
|
||||||
|
|
||||||
/* mapping utilities - see Texture.c for an example of how to use these */
|
/* mapping utilities - see Texture.c for an example of how to use these */
|
||||||
typedef struct {
|
typedef struct {
|
||||||
const char *sval;
|
const char *sval;
|
||||||
|
|||||||
155
source/blender/src/drawscript.c
Normal file
155
source/blender/src/drawscript.c
Normal file
@@ -0,0 +1,155 @@
|
|||||||
|
/**
|
||||||
|
* $Id$
|
||||||
|
*
|
||||||
|
* ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation; either version 2
|
||||||
|
* of the License, or (at your option) any later version. The Blender
|
||||||
|
* Foundation also sells licenses for use in proprietary software under
|
||||||
|
* the Blender License. See http://www.blender.org/BL/ for information
|
||||||
|
* about this.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software Foundation,
|
||||||
|
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
*
|
||||||
|
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* The Original Code is: drawtext.c.
|
||||||
|
*
|
||||||
|
* Contributor(s): Willian Padovani Germano.
|
||||||
|
*
|
||||||
|
* ***** END GPL/BL DUAL LICENSE BLOCK *****
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <math.h>
|
||||||
|
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
#include <config.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef _WIN32
|
||||||
|
#include <unistd.h>
|
||||||
|
#else
|
||||||
|
#include <io.h>
|
||||||
|
#include "BLI_winstuff.h"
|
||||||
|
#endif
|
||||||
|
#include "MEM_guardedalloc.h"
|
||||||
|
#include "PIL_time.h"
|
||||||
|
|
||||||
|
#include "BMF_Api.h"
|
||||||
|
|
||||||
|
#include "BLI_blenlib.h"
|
||||||
|
|
||||||
|
#include "DNA_script_types.h"
|
||||||
|
#include "DNA_space_types.h"
|
||||||
|
#include "DNA_screen_types.h"
|
||||||
|
#include "DNA_userdef_types.h"
|
||||||
|
|
||||||
|
#include "BKE_utildefines.h"
|
||||||
|
#include "BKE_text.h"
|
||||||
|
#include "BKE_global.h"
|
||||||
|
#include "BKE_main.h"
|
||||||
|
|
||||||
|
#include "BPY_extern.h"
|
||||||
|
|
||||||
|
#include "BIF_gl.h"
|
||||||
|
#include "BIF_keyval.h"
|
||||||
|
#include "BIF_interface.h"
|
||||||
|
#include "BIF_drawscript.h"
|
||||||
|
#include "BIF_editfont.h"
|
||||||
|
#include "BIF_spacetypes.h"
|
||||||
|
#include "BIF_usiblender.h"
|
||||||
|
#include "BIF_screen.h"
|
||||||
|
#include "BIF_toolbox.h"
|
||||||
|
#include "BIF_space.h"
|
||||||
|
#include "BIF_mywindow.h"
|
||||||
|
|
||||||
|
#include "BSE_filesel.h"
|
||||||
|
|
||||||
|
#include "mydevice.h"
|
||||||
|
#include "blendef.h"
|
||||||
|
#include "interface.h"
|
||||||
|
|
||||||
|
void drawscriptspace(ScrArea *sa, void *spacedata);
|
||||||
|
void winqreadscriptspace(struct ScrArea *sa, void *spacedata, struct BWinEvent *evt);
|
||||||
|
|
||||||
|
void drawscriptspace(ScrArea *sa, void *spacedata)
|
||||||
|
{
|
||||||
|
SpaceScript *sc = curarea->spacedata.first;
|
||||||
|
|
||||||
|
glClearColor(0.6, 0.6, 0.6, 1.0);
|
||||||
|
glClear(GL_COLOR_BUFFER_BIT);
|
||||||
|
myortho2(-0.5, curarea->winrct.xmax-curarea->winrct.xmin-0.5, -0.5, curarea->winrct.ymax-curarea->winrct.ymin-0.5);
|
||||||
|
|
||||||
|
if(!sc->script) {
|
||||||
|
if (G.main->script.first)
|
||||||
|
sc->script = G.main->script.first;
|
||||||
|
else
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
BPY_spacescript_do_pywin_draw(sc);
|
||||||
|
}
|
||||||
|
|
||||||
|
void winqreadscriptspace(struct ScrArea *sa, void *spacedata, struct BWinEvent *evt)
|
||||||
|
{
|
||||||
|
unsigned short event = evt->event;
|
||||||
|
short val = evt->val;
|
||||||
|
SpaceScript *sc = curarea->spacedata.first;
|
||||||
|
Script *script = sc->script;
|
||||||
|
|
||||||
|
if (script) {
|
||||||
|
BPY_spacescript_do_pywin_event(sc, event, val);
|
||||||
|
|
||||||
|
if (!script->flags) /* finished with this script, let's free it */
|
||||||
|
BPY_free_finished_script(script);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (event == QKEY)
|
||||||
|
if (val && okee("QUIT BLENDER")) exit_usiblender();
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
void free_scriptspace (SpaceScript *sc)
|
||||||
|
{
|
||||||
|
if (!sc) return;
|
||||||
|
|
||||||
|
sc->script = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
void unlink_script(Script *script)
|
||||||
|
{ /* copied from unlink_text in drawtext.c */
|
||||||
|
bScreen *scr;
|
||||||
|
ScrArea *area;
|
||||||
|
SpaceLink *sl;
|
||||||
|
|
||||||
|
for (scr= G.main->screen.first; scr; scr= scr->id.next) {
|
||||||
|
for (area= scr->areabase.first; area; area= area->next) {
|
||||||
|
for (sl= area->spacedata.first; sl; sl= sl->next) {
|
||||||
|
if (sl->spacetype==SPACE_SCRIPT) {
|
||||||
|
SpaceScript *sc= (SpaceScript*) sl;
|
||||||
|
|
||||||
|
if (sc->script==script) {
|
||||||
|
sc->script= NULL;
|
||||||
|
|
||||||
|
if (sc==area->spacedata.first) {
|
||||||
|
scrarea_queue_redraw(area);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -543,11 +543,6 @@ void drawtextspace(ScrArea *sa, void *spacedata)
|
|||||||
float col[3];
|
float col[3];
|
||||||
int linecount = 0;
|
int linecount = 0;
|
||||||
|
|
||||||
if (BPY_spacetext_is_pywin(st)) {
|
|
||||||
BPY_spacetext_do_pywin_draw(st);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
BIF_GetThemeColor3fv(TH_BACK, col);
|
BIF_GetThemeColor3fv(TH_BACK, col);
|
||||||
glClearColor(col[0], col[1], col[2], 0.0);
|
glClearColor(col[0], col[1], col[2], 0.0);
|
||||||
glClear(GL_COLOR_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT);
|
||||||
@@ -984,11 +979,6 @@ void winqreadtextspace(ScrArea *sa, void *spacedata, BWinEvent *evt)
|
|||||||
Text *text= st->text;
|
Text *text= st->text;
|
||||||
int do_draw=0, p;
|
int do_draw=0, p;
|
||||||
|
|
||||||
if (BPY_spacetext_is_pywin(st)) {
|
|
||||||
BPY_spacetext_do_pywin_event(st, event, val);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* smartass code to prevent the events below from not working! */
|
/* smartass code to prevent the events below from not working! */
|
||||||
if (!isprint(ascii) || (G.qual & ~LR_SHIFTKEY)) ascii= 0;
|
if (!isprint(ascii) || (G.qual & ~LR_SHIFTKEY)) ascii= 0;
|
||||||
|
|
||||||
|
|||||||
@@ -352,6 +352,7 @@ void scrarea_do_headdraw(ScrArea *area)
|
|||||||
case SPACE_IMASEL: imasel_buttons(); break;
|
case SPACE_IMASEL: imasel_buttons(); break;
|
||||||
case SPACE_OOPS: oops_buttons(); break;
|
case SPACE_OOPS: oops_buttons(); break;
|
||||||
case SPACE_TEXT: text_buttons(); break;
|
case SPACE_TEXT: text_buttons(); break;
|
||||||
|
case SPACE_SCRIPT:script_buttons(); break;
|
||||||
case SPACE_SOUND: sound_buttons(); break;
|
case SPACE_SOUND: sound_buttons(); break;
|
||||||
case SPACE_ACTION: action_buttons(); break;
|
case SPACE_ACTION: action_buttons(); break;
|
||||||
case SPACE_NLA: nla_buttons(); break;
|
case SPACE_NLA: nla_buttons(); break;
|
||||||
@@ -1055,7 +1056,7 @@ void screenmain(void)
|
|||||||
towin= 0;
|
towin= 0;
|
||||||
}
|
}
|
||||||
else if (event==QKEY) {
|
else if (event==QKEY) {
|
||||||
if((G.obedit && G.obedit->type==OB_FONT && g_activearea->spacetype==SPACE_VIEW3D)||g_activearea->spacetype==SPACE_TEXT);
|
if((G.obedit && G.obedit->type==OB_FONT && g_activearea->spacetype==SPACE_VIEW3D)||g_activearea->spacetype==SPACE_TEXT||g_activearea->spacetype==SPACE_SCRIPT);
|
||||||
else {
|
else {
|
||||||
if(val && okee("QUIT BLENDER")) exit_usiblender();
|
if(val && okee("QUIT BLENDER")) exit_usiblender();
|
||||||
towin= 0;
|
towin= 0;
|
||||||
@@ -1084,7 +1085,7 @@ void screenmain(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (event==SPACEKEY) {
|
else if (event==SPACEKEY) {
|
||||||
if((G.obedit && G.obedit->type==OB_FONT && g_activearea->spacetype==SPACE_VIEW3D)||g_activearea->spacetype==SPACE_TEXT);
|
if((G.obedit && G.obedit->type==OB_FONT && g_activearea->spacetype==SPACE_VIEW3D)||g_activearea->spacetype==SPACE_TEXT||g_activearea->spacetype==SPACE_SCRIPT);
|
||||||
else {
|
else {
|
||||||
if(val) toolbox_n();
|
if(val) toolbox_n();
|
||||||
towin= 0;
|
towin= 0;
|
||||||
|
|||||||
@@ -66,6 +66,7 @@ char *event_to_string(short evt) {
|
|||||||
smap(IMALEFTMOUSE);
|
smap(IMALEFTMOUSE);
|
||||||
smap(AFTERPIBREAD);
|
smap(AFTERPIBREAD);
|
||||||
smap(REDRAWTEXT);
|
smap(REDRAWTEXT);
|
||||||
|
smap(REDRAWSCRIPT);
|
||||||
smap(REDRAWACTION);
|
smap(REDRAWACTION);
|
||||||
smap(LEFTMOUSE);
|
smap(LEFTMOUSE);
|
||||||
smap(MIDDLEMOUSE);
|
smap(MIDDLEMOUSE);
|
||||||
|
|||||||
@@ -71,6 +71,7 @@
|
|||||||
#include "DNA_space_types.h"
|
#include "DNA_space_types.h"
|
||||||
#include "DNA_scene_types.h"
|
#include "DNA_scene_types.h"
|
||||||
#include "DNA_screen_types.h"
|
#include "DNA_screen_types.h"
|
||||||
|
#include "DNA_script_types.h"
|
||||||
#include "DNA_view3d_types.h"
|
#include "DNA_view3d_types.h"
|
||||||
#include "DNA_userdef_types.h"
|
#include "DNA_userdef_types.h"
|
||||||
|
|
||||||
@@ -1410,6 +1411,12 @@ void filesel_prevspace()
|
|||||||
BLI_addtail(&curarea->spacedata, sfile);
|
BLI_addtail(&curarea->spacedata, sfile);
|
||||||
|
|
||||||
sfile= curarea->spacedata.first;
|
sfile= curarea->spacedata.first;
|
||||||
|
|
||||||
|
if (sfile->spacetype == SPACE_SCRIPT) {
|
||||||
|
SpaceScript *sc = (SpaceScript *)sfile;
|
||||||
|
if (sc->script) sc->script->flags &=~SCRIPT_FILESEL;
|
||||||
|
}
|
||||||
|
|
||||||
newspace(curarea, sfile->spacetype);
|
newspace(curarea, sfile->spacetype);
|
||||||
}
|
}
|
||||||
else newspace(curarea, SPACE_INFO);
|
else newspace(curarea, SPACE_INFO);
|
||||||
|
|||||||
162
source/blender/src/header_script.c
Normal file
162
source/blender/src/header_script.c
Normal file
@@ -0,0 +1,162 @@
|
|||||||
|
/**
|
||||||
|
* header_script.c nov-2003
|
||||||
|
*
|
||||||
|
* Functions to draw the "Script Window" window header
|
||||||
|
* and handle user events sent to it.
|
||||||
|
*
|
||||||
|
* $Id$
|
||||||
|
*
|
||||||
|
* ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation; either version 2
|
||||||
|
* of the License, or (at your option) any later version. The Blender
|
||||||
|
* Foundation also sells licenses for use in proprietary software under
|
||||||
|
* the Blender License. See http://www.blender.org/BL/ for information
|
||||||
|
* about this.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software Foundation,
|
||||||
|
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
*
|
||||||
|
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Contributor(s): Willian P. Germano.
|
||||||
|
*
|
||||||
|
* ***** END GPL/BL DUAL LICENSE BLOCK *****
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
#include <config.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef WIN32
|
||||||
|
#include "BLI_winstuff.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "BMF_Api.h"
|
||||||
|
#include "BIF_language.h"
|
||||||
|
#ifdef INTERNATIONAL
|
||||||
|
#include "FTF_Api.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "BSE_headerbuttons.h"
|
||||||
|
|
||||||
|
#include "DNA_ID.h"
|
||||||
|
#include "DNA_screen_types.h"
|
||||||
|
#include "DNA_space_types.h"
|
||||||
|
#include "DNA_script_types.h"
|
||||||
|
|
||||||
|
#include "BIF_interface.h"
|
||||||
|
#include "BIF_resources.h"
|
||||||
|
#include "BIF_screen.h"
|
||||||
|
#include "BIF_space.h"
|
||||||
|
#include "BIF_toolbox.h"
|
||||||
|
#include "BKE_global.h"
|
||||||
|
#include "BKE_library.h"
|
||||||
|
#include "BKE_main.h"
|
||||||
|
#include "BKE_sca.h"
|
||||||
|
#include "BPY_extern.h"
|
||||||
|
#include "BSE_filesel.h"
|
||||||
|
|
||||||
|
#include "blendef.h"
|
||||||
|
#include "mydevice.h"
|
||||||
|
|
||||||
|
/* ********************** SCRIPT ****************************** */
|
||||||
|
void do_script_buttons(unsigned short event)
|
||||||
|
{
|
||||||
|
SpaceScript *sc= curarea->spacedata.first;
|
||||||
|
ID *id, *idtest;
|
||||||
|
int nr= 1;
|
||||||
|
Script *script;
|
||||||
|
|
||||||
|
if (!sc) return;
|
||||||
|
if (sc->spacetype != SPACE_SCRIPT) return;
|
||||||
|
|
||||||
|
switch (event) {
|
||||||
|
case B_SCRIPTBROWSE:
|
||||||
|
if (sc->menunr==-2) {
|
||||||
|
activate_databrowse((ID *)sc->script, ID_SCR, 0, B_SCRIPTBROWSE,
|
||||||
|
&sc->menunr, do_script_buttons);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if(sc->menunr < 0) break;
|
||||||
|
|
||||||
|
script = sc->script;
|
||||||
|
|
||||||
|
nr = 1;
|
||||||
|
id = (ID *)script;
|
||||||
|
|
||||||
|
idtest= G.main->script.first;
|
||||||
|
while(idtest) {
|
||||||
|
if(nr==sc->menunr) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
nr++;
|
||||||
|
idtest= idtest->next;
|
||||||
|
}
|
||||||
|
if(idtest!=id) {
|
||||||
|
sc->script= (Script *)idtest;
|
||||||
|
|
||||||
|
allqueue(REDRAWSCRIPT, 0);
|
||||||
|
allqueue(REDRAWHEADERS, 0);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
void script_buttons(void)
|
||||||
|
{
|
||||||
|
uiBlock *block;
|
||||||
|
SpaceScript *sc= curarea->spacedata.first;
|
||||||
|
short xco = 8;
|
||||||
|
char naam[256];
|
||||||
|
|
||||||
|
if (!sc || sc->spacetype != SPACE_SCRIPT) return;
|
||||||
|
|
||||||
|
sprintf(naam, "header %d", curarea->headwin);
|
||||||
|
block= uiNewBlock(&curarea->uiblocks, naam, UI_EMBOSSX, UI_HELV, curarea->headwin);
|
||||||
|
|
||||||
|
if(area_is_active_area(curarea)) uiBlockSetCol(block, TH_HEADER);
|
||||||
|
else uiBlockSetCol(block, TH_HEADERDESEL);
|
||||||
|
|
||||||
|
curarea->butspacetype= SPACE_SCRIPT;
|
||||||
|
|
||||||
|
uiDefIconTextButC(block, ICONTEXTROW,B_NEWSPACE, ICON_VIEW3D,
|
||||||
|
windowtype_pup(), xco,0,XIC+10,YIC, &(curarea->butspacetype), 1.0,
|
||||||
|
SPACEICONMAX, 0, 0, "Displays Current Window Type. Click for menu"
|
||||||
|
" of available types.");
|
||||||
|
|
||||||
|
/* FULL WINDOW */
|
||||||
|
xco= 25;
|
||||||
|
if(curarea->full)
|
||||||
|
uiDefIconBut(block, BUT,B_FULL, ICON_SPLITSCREEN, xco+=XIC,0,XIC,YIC, 0, 0,
|
||||||
|
0, 0, 0, "Returns to multiple views window (CTRL+Up arrow)");
|
||||||
|
else
|
||||||
|
uiDefIconBut(block, BUT,B_FULL, ICON_FULLSCREEN, xco+=XIC,0,XIC,YIC, 0, 0,
|
||||||
|
0, 0, 0, "Makes current window full screen (CTRL+Down arrow)");
|
||||||
|
|
||||||
|
/* STD SCRIPT BUTTONS */
|
||||||
|
xco+= 2*XIC;
|
||||||
|
xco= std_libbuttons(block, xco, 0, 0, NULL, B_SCRIPTBROWSE, (ID*)sc->script, 0, &(sc->menunr), 0, 0, 0, 0, 0);
|
||||||
|
|
||||||
|
/* always as last */
|
||||||
|
curarea->headbutlen= xco+2*XIC;
|
||||||
|
|
||||||
|
uiDrawBlock(block);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ********************** SCRIPT ****************************** */
|
||||||
|
|
||||||
@@ -508,28 +508,26 @@ void text_buttons(void)
|
|||||||
|
|
||||||
|
|
||||||
/* STD TEXT BUTTONS */
|
/* STD TEXT BUTTONS */
|
||||||
if (!BPY_spacetext_is_pywin(st)) {
|
xco+= 2*XIC;
|
||||||
xco+= 2*XIC;
|
xco= std_libbuttons(block, xco, 0, 0, NULL, B_TEXTBROWSE, (ID*)st->text, 0, &(st->menunr), 0, 0, B_TEXTDELETE, 0, 0);
|
||||||
xco= std_libbuttons(block, xco, 0, 0, NULL, B_TEXTBROWSE, (ID*)st->text, 0, &(st->menunr), 0, 0, B_TEXTDELETE, 0, 0);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
if (st->text) {
|
if (st->text) {
|
||||||
if (st->text->flags & TXT_ISDIRTY && (st->text->flags & TXT_ISEXT || !(st->text->flags & TXT_ISMEM)))
|
if (st->text->flags & TXT_ISDIRTY && (st->text->flags & TXT_ISEXT || !(st->text->flags & TXT_ISMEM)))
|
||||||
uiDefIconBut(block, BUT,0, ICON_ERROR, xco+=XIC,0,XIC,YIC, 0, 0, 0, 0, 0, "The text has been changed");
|
uiDefIconBut(block, BUT,0, ICON_ERROR, xco+=XIC,0,XIC,YIC, 0, 0, 0, 0, 0, "The text has been changed");
|
||||||
if (st->text->flags & TXT_ISEXT)
|
if (st->text->flags & TXT_ISEXT)
|
||||||
uiDefBut(block, BUT,B_TEXTSTORE, ICON(), xco+=XIC,0,XIC,YIC, 0, 0, 0, 0, 0, "Stores text in project file");
|
uiDefBut(block, BUT,B_TEXTSTORE, ICON(), xco+=XIC,0,XIC,YIC, 0, 0, 0, 0, 0, "Stores text in project file");
|
||||||
else
|
else
|
||||||
uiDefBut(block, BUT,B_TEXTSTORE, ICON(), xco+=XIC,0,XIC,YIC, 0, 0, 0, 0, 0, "Disables storing of text in project file");
|
uiDefBut(block, BUT,B_TEXTSTORE, ICON(), xco+=XIC,0,XIC,YIC, 0, 0, 0, 0, 0, "Disables storing of text in project file");
|
||||||
xco+=10;
|
xco+=10;
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
xco+=XIC;
|
|
||||||
if(st->font_id>1) st->font_id= 0;
|
|
||||||
uiDefButI(block, MENU, B_TEXTFONT, "Screen 12 %x0|Screen 15%x1", xco,0,100,YIC, &st->font_id, 0, 0, 0, 0, "Displays available fonts");
|
|
||||||
xco+=100;
|
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
xco+=XIC;
|
||||||
|
if(st->font_id>1) st->font_id= 0;
|
||||||
|
uiDefButI(block, MENU, B_TEXTFONT, "Screen 12 %x0|Screen 15%x1", xco,0,100,YIC, &st->font_id, 0, 0, 0, 0, "Displays available fonts");
|
||||||
|
xco+=100;
|
||||||
|
|
||||||
/* always as last */
|
/* always as last */
|
||||||
curarea->headbutlen= xco+2*XIC;
|
curarea->headbutlen= xco+2*XIC;
|
||||||
|
|
||||||
|
|||||||
@@ -78,6 +78,7 @@
|
|||||||
#include "DNA_packedFile_types.h"
|
#include "DNA_packedFile_types.h"
|
||||||
#include "DNA_scene_types.h"
|
#include "DNA_scene_types.h"
|
||||||
#include "DNA_screen_types.h"
|
#include "DNA_screen_types.h"
|
||||||
|
#include "DNA_script_types.h"
|
||||||
#include "DNA_sequence_types.h"
|
#include "DNA_sequence_types.h"
|
||||||
#include "DNA_sound_types.h"
|
#include "DNA_sound_types.h"
|
||||||
#include "DNA_space_types.h"
|
#include "DNA_space_types.h"
|
||||||
@@ -216,8 +217,12 @@ char *windowtype_pup(void)
|
|||||||
|
|
||||||
strcat(string, "|%l"); //254
|
strcat(string, "|%l"); //254
|
||||||
|
|
||||||
strcat(string, "|Image Browser %x10");
|
strcat(string, "|Image Browser %x10"); //273
|
||||||
strcat(string, "|File Browser %x5");
|
strcat(string, "|File Browser %x5"); //290
|
||||||
|
|
||||||
|
strcat(string, "|%l"); //293
|
||||||
|
|
||||||
|
strcat(string, "|Scripts Window %x14"); //313
|
||||||
|
|
||||||
return (string);
|
return (string);
|
||||||
}
|
}
|
||||||
@@ -302,6 +307,9 @@ int std_libbuttons(uiBlock *block, short xco, short yco,
|
|||||||
else if(curarea->spacetype==SPACE_TEXT) {
|
else if(curarea->spacetype==SPACE_TEXT) {
|
||||||
id= G.main->text.first;
|
id= G.main->text.first;
|
||||||
}
|
}
|
||||||
|
else if(curarea->spacetype==SPACE_SCRIPT) {
|
||||||
|
id= G.main->script.first;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if(id) {
|
if(id) {
|
||||||
char *extrastr= NULL;
|
char *extrastr= NULL;
|
||||||
@@ -356,6 +364,9 @@ int std_libbuttons(uiBlock *block, short xco, short yco,
|
|||||||
else if(curarea->spacetype==SPACE_TEXT) {
|
else if(curarea->spacetype==SPACE_TEXT) {
|
||||||
uiDefButS(block, MENU, browse, "OPEN NEW %x 32766 | ADD NEW %x 32767", xco,yco,XIC,YIC, menupoin, 0, 0, 0, 0, "Browses Datablock");
|
uiDefButS(block, MENU, browse, "OPEN NEW %x 32766 | ADD NEW %x 32767", xco,yco,XIC,YIC, menupoin, 0, 0, 0, 0, "Browses Datablock");
|
||||||
}
|
}
|
||||||
|
else if(curarea->spacetype==SPACE_SCRIPT) {
|
||||||
|
uiDefButS(block, MENU, browse, "No running scripts", xco, yco, XIC, YIC, menupoin, 0, 0, 0, 0, "Browses Datablock");
|
||||||
|
}
|
||||||
else if(curarea->spacetype==SPACE_SOUND) {
|
else if(curarea->spacetype==SPACE_SOUND) {
|
||||||
uiDefButS(block, MENU, browse, "OPEN NEW %x 32766",xco,yco,XIC,YIC, menupoin, 0, 0, 0, 0, "Browses Datablock");
|
uiDefButS(block, MENU, browse, "OPEN NEW %x 32766",xco,yco,XIC,YIC, menupoin, 0, 0, 0, 0, "Browses Datablock");
|
||||||
}
|
}
|
||||||
@@ -2000,7 +2011,8 @@ void do_headerbuttons(short event)
|
|||||||
else if(event<400) do_image_buttons(event);
|
else if(event<400) do_image_buttons(event);
|
||||||
else if(event<450) do_buts_buttons(event);
|
else if(event<450) do_buts_buttons(event);
|
||||||
else if(event<500) do_imasel_buttons(event);
|
else if(event<500) do_imasel_buttons(event);
|
||||||
else if(event<550) do_text_buttons(event);
|
else if(event<525) do_text_buttons(event);
|
||||||
|
else if(event<550) do_script_buttons(event);
|
||||||
else if(event<600) do_file_buttons(event);
|
else if(event<600) do_file_buttons(event);
|
||||||
else if(event<650) do_seq_buttons(event);
|
else if(event<650) do_seq_buttons(event);
|
||||||
else if(event<700) do_sound_buttons(event);
|
else if(event<700) do_sound_buttons(event);
|
||||||
|
|||||||
@@ -3070,6 +3070,19 @@ void init_textspace(ScrArea *sa)
|
|||||||
st->top= 0;
|
st->top= 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void init_scriptspace(ScrArea *sa)
|
||||||
|
{
|
||||||
|
SpaceScript *sc;
|
||||||
|
|
||||||
|
sc = MEM_callocN(sizeof(SpaceScript), "initscriptspace");
|
||||||
|
BLI_addhead(&sa->spacedata, sc);
|
||||||
|
|
||||||
|
sc->spacetype = SPACE_SCRIPT;
|
||||||
|
|
||||||
|
sc->script = NULL;
|
||||||
|
sc->flags = 0;
|
||||||
|
}
|
||||||
|
|
||||||
void init_imaselspace(ScrArea *sa)
|
void init_imaselspace(ScrArea *sa)
|
||||||
{
|
{
|
||||||
SpaceImaSel *simasel;
|
SpaceImaSel *simasel;
|
||||||
@@ -3477,6 +3490,11 @@ void init_oopsspace(ScrArea *sa)
|
|||||||
extern void drawtextspace(ScrArea *sa, void *spacedata);
|
extern void drawtextspace(ScrArea *sa, void *spacedata);
|
||||||
extern void winqreadtextspace(struct ScrArea *sa, void *spacedata, struct BWinEvent *evt);
|
extern void winqreadtextspace(struct ScrArea *sa, void *spacedata, struct BWinEvent *evt);
|
||||||
|
|
||||||
|
/* ******************** SPACE: Script ********************** */
|
||||||
|
|
||||||
|
extern void drawscriptspace(ScrArea *sa, void *spacedata);
|
||||||
|
extern void winqreadscriptspace(struct ScrArea *sa, void *spacedata, struct BWinEvent *evt);
|
||||||
|
|
||||||
/* ******************** SPACE: ALGEMEEN ********************** */
|
/* ******************** SPACE: ALGEMEEN ********************** */
|
||||||
|
|
||||||
void newspace(ScrArea *sa, int type)
|
void newspace(ScrArea *sa, int type)
|
||||||
@@ -3531,6 +3549,8 @@ void newspace(ScrArea *sa, int type)
|
|||||||
init_actionspace(sa);
|
init_actionspace(sa);
|
||||||
else if(type==SPACE_TEXT)
|
else if(type==SPACE_TEXT)
|
||||||
init_textspace(sa);
|
init_textspace(sa);
|
||||||
|
else if(type==SPACE_SCRIPT)
|
||||||
|
init_scriptspace(sa);
|
||||||
else if(type==SPACE_SOUND)
|
else if(type==SPACE_SOUND)
|
||||||
init_soundspace(sa);
|
init_soundspace(sa);
|
||||||
else if(type==SPACE_NLA)
|
else if(type==SPACE_NLA)
|
||||||
@@ -3611,6 +3631,9 @@ void freespacelist(ListBase *lb)
|
|||||||
else if(sl->spacetype==SPACE_TEXT) {
|
else if(sl->spacetype==SPACE_TEXT) {
|
||||||
free_textspace((SpaceText *)sl);
|
free_textspace((SpaceText *)sl);
|
||||||
}
|
}
|
||||||
|
else if(sl->spacetype==SPACE_SCRIPT) {
|
||||||
|
free_scriptspace((SpaceScript *)sl);
|
||||||
|
}
|
||||||
else if(sl->spacetype==SPACE_SOUND) {
|
else if(sl->spacetype==SPACE_SOUND) {
|
||||||
free_soundspace((SpaceSound *)sl);
|
free_soundspace((SpaceSound *)sl);
|
||||||
}
|
}
|
||||||
@@ -3878,6 +3901,11 @@ void allqueue(unsigned short event, short val)
|
|||||||
scrarea_queue_winredraw(sa);
|
scrarea_queue_winredraw(sa);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case REDRAWSCRIPT:
|
||||||
|
if (sa->spacetype==SPACE_SCRIPT) {
|
||||||
|
scrarea_queue_winredraw(sa);
|
||||||
|
}
|
||||||
|
break;
|
||||||
case REDRAWSOUND:
|
case REDRAWSOUND:
|
||||||
if(sa->spacetype==SPACE_SOUND) {
|
if(sa->spacetype==SPACE_SOUND) {
|
||||||
scrarea_queue_headredraw(sa);
|
scrarea_queue_headredraw(sa);
|
||||||
@@ -4162,6 +4190,17 @@ SpaceType *spacetext_get_type(void)
|
|||||||
|
|
||||||
return st;
|
return st;
|
||||||
}
|
}
|
||||||
|
SpaceType *spacescript_get_type(void)
|
||||||
|
{
|
||||||
|
static SpaceType *st = NULL;
|
||||||
|
|
||||||
|
if (!st) {
|
||||||
|
st = spacetype_new("Script");
|
||||||
|
spacetype_set_winfuncs(st, drawscriptspace, NULL, winqreadscriptspace);
|
||||||
|
}
|
||||||
|
|
||||||
|
return st;
|
||||||
|
}
|
||||||
SpaceType *spaceview3d_get_type(void)
|
SpaceType *spaceview3d_get_type(void)
|
||||||
{
|
{
|
||||||
static SpaceType *st= NULL;
|
static SpaceType *st= NULL;
|
||||||
|
|||||||
@@ -92,6 +92,7 @@ SpaceType *spacetype_from_code(int spacecode)
|
|||||||
case SPACE_SEQ: return spaceseq_get_type();
|
case SPACE_SEQ: return spaceseq_get_type();
|
||||||
case SPACE_SOUND: return spacesound_get_type();
|
case SPACE_SOUND: return spacesound_get_type();
|
||||||
case SPACE_TEXT: return spacetext_get_type();
|
case SPACE_TEXT: return spacetext_get_type();
|
||||||
|
case SPACE_SCRIPT:return spacescript_get_type();
|
||||||
case SPACE_VIEW3D: return spaceview3d_get_type();
|
case SPACE_VIEW3D: return spaceview3d_get_type();
|
||||||
default:
|
default:
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|||||||
@@ -521,6 +521,7 @@ int blenderqread(unsigned short event, short val)
|
|||||||
if (G.flags & G_FLAGS_AUTOPLAY) return 1;
|
if (G.flags & G_FLAGS_AUTOPLAY) return 1;
|
||||||
|
|
||||||
if (curarea && curarea->spacetype==SPACE_TEXT) textspace= 1;
|
if (curarea && curarea->spacetype==SPACE_TEXT) textspace= 1;
|
||||||
|
else if (curarea && curarea->spacetype==SPACE_SCRIPT) textspace= 1;
|
||||||
|
|
||||||
switch(event) {
|
switch(event) {
|
||||||
|
|
||||||
@@ -798,7 +799,7 @@ int blenderqread(unsigned short event, short val)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case NKEY:
|
case NKEY:
|
||||||
if(textediting==0 && textspace==0 ) {
|
if(textediting==0 && textspace==0) {
|
||||||
if(G.qual & LR_CTRLKEY);
|
if(G.qual & LR_CTRLKEY);
|
||||||
else if(G.qual==0 || (G.qual & LR_SHIFTKEY)) {
|
else if(G.qual==0 || (G.qual & LR_SHIFTKEY)) {
|
||||||
if(curarea->spacetype==SPACE_VIEW3D); // is new panel, in view3d queue
|
if(curarea->spacetype==SPACE_VIEW3D); // is new panel, in view3d queue
|
||||||
|
|||||||
Reference in New Issue
Block a user