2008-12-18 02:56:48 +00:00
|
|
|
/**
|
|
|
|
* $Id$
|
|
|
|
*
|
|
|
|
* ***** BEGIN GPL 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.
|
|
|
|
*
|
|
|
|
* 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): Blender Foundation (2008).
|
|
|
|
*
|
|
|
|
* ***** END GPL LICENSE BLOCK *****
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "MEM_guardedalloc.h"
|
|
|
|
|
2009-03-19 19:03:38 +00:00
|
|
|
#include "DNA_ID.h"
|
2008-12-18 02:56:48 +00:00
|
|
|
#include "DNA_listBase.h"
|
|
|
|
#include "DNA_scene_types.h"
|
|
|
|
#include "DNA_screen_types.h"
|
|
|
|
#include "DNA_space_types.h"
|
2009-01-17 18:35:33 +00:00
|
|
|
#include "DNA_view3d_types.h"
|
2008-12-18 02:56:48 +00:00
|
|
|
#include "DNA_windowmanager_types.h"
|
2009-08-15 19:40:09 +00:00
|
|
|
#include "DNA_object_types.h"
|
2008-12-18 02:56:48 +00:00
|
|
|
|
|
|
|
#include "RNA_access.h"
|
|
|
|
|
2008-12-23 02:07:13 +00:00
|
|
|
#include "BLI_listbase.h"
|
2009-05-28 23:13:42 +00:00
|
|
|
#include "BLI_string.h"
|
2008-12-23 02:07:13 +00:00
|
|
|
|
2008-12-18 02:56:48 +00:00
|
|
|
#include "BKE_context.h"
|
|
|
|
#include "BKE_main.h"
|
|
|
|
#include "BKE_screen.h"
|
2009-08-15 19:40:09 +00:00
|
|
|
#include "BKE_global.h"
|
2008-12-18 02:56:48 +00:00
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
/* struct */
|
|
|
|
|
|
|
|
struct bContext {
|
|
|
|
int thread;
|
|
|
|
|
|
|
|
/* windowmanager context */
|
|
|
|
struct {
|
|
|
|
struct wmWindowManager *manager;
|
|
|
|
struct wmWindow *window;
|
|
|
|
struct bScreen *screen;
|
|
|
|
struct ScrArea *area;
|
|
|
|
struct ARegion *region;
|
2009-03-25 20:49:15 +00:00
|
|
|
struct ARegion *menu;
|
2009-05-28 23:13:42 +00:00
|
|
|
struct bContextStore *store;
|
2008-12-18 02:56:48 +00:00
|
|
|
} wm;
|
|
|
|
|
|
|
|
/* data context */
|
|
|
|
struct {
|
|
|
|
struct Main *main;
|
|
|
|
struct Scene *scene;
|
2008-12-23 02:07:13 +00:00
|
|
|
|
|
|
|
int recursion;
|
2009-07-18 19:40:26 +00:00
|
|
|
int py_init; /* true if python is initialized */
|
2009-10-29 09:25:11 +00:00
|
|
|
void *py_context;
|
2008-12-18 02:56:48 +00:00
|
|
|
} data;
|
|
|
|
|
|
|
|
/* data evaluation */
|
|
|
|
struct {
|
|
|
|
int render;
|
|
|
|
} eval;
|
|
|
|
};
|
|
|
|
|
|
|
|
/* context */
|
|
|
|
|
|
|
|
bContext *CTX_create()
|
|
|
|
{
|
|
|
|
bContext *C;
|
|
|
|
|
|
|
|
C= MEM_callocN(sizeof(bContext), "bContext");
|
|
|
|
|
|
|
|
return C;
|
|
|
|
}
|
|
|
|
|
2009-03-25 20:49:15 +00:00
|
|
|
bContext *CTX_copy(const bContext *C)
|
2008-12-18 02:56:48 +00:00
|
|
|
{
|
2009-03-25 20:49:15 +00:00
|
|
|
bContext *newC= MEM_dupallocN((void*)C);
|
2008-12-18 02:56:48 +00:00
|
|
|
|
|
|
|
return newC;
|
|
|
|
}
|
|
|
|
|
|
|
|
void CTX_free(bContext *C)
|
|
|
|
{
|
|
|
|
MEM_freeN(C);
|
|
|
|
}
|
|
|
|
|
2009-05-28 23:13:42 +00:00
|
|
|
/* store */
|
|
|
|
|
|
|
|
bContextStore *CTX_store_add(ListBase *contexts, char *name, PointerRNA *ptr)
|
|
|
|
{
|
|
|
|
bContextStoreEntry *entry;
|
|
|
|
bContextStore *ctx, *lastctx;
|
|
|
|
|
|
|
|
/* ensure we have a context to put the entry in, if it was already used
|
|
|
|
* we have to copy the context to ensure */
|
|
|
|
ctx= contexts->last;
|
|
|
|
|
|
|
|
if(!ctx || ctx->used) {
|
|
|
|
if(ctx) {
|
|
|
|
lastctx= ctx;
|
|
|
|
ctx= MEM_dupallocN(lastctx);
|
|
|
|
BLI_duplicatelist(&ctx->entries, &lastctx->entries);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
ctx= MEM_callocN(sizeof(bContextStore), "bContextStore");
|
|
|
|
|
|
|
|
BLI_addtail(contexts, ctx);
|
|
|
|
}
|
|
|
|
|
|
|
|
entry= MEM_callocN(sizeof(bContextStoreEntry), "bContextStoreEntry");
|
|
|
|
BLI_strncpy(entry->name, name, sizeof(entry->name));
|
|
|
|
entry->ptr= *ptr;
|
|
|
|
|
|
|
|
BLI_addtail(&ctx->entries, entry);
|
|
|
|
|
|
|
|
return ctx;
|
|
|
|
}
|
|
|
|
|
|
|
|
void CTX_store_set(bContext *C, bContextStore *store)
|
|
|
|
{
|
|
|
|
C->wm.store= store;
|
|
|
|
}
|
|
|
|
|
|
|
|
bContextStore *CTX_store_copy(bContextStore *store)
|
|
|
|
{
|
|
|
|
bContextStore *ctx;
|
|
|
|
|
|
|
|
ctx= MEM_dupallocN(store);
|
|
|
|
BLI_duplicatelist(&ctx->entries, &store->entries);
|
|
|
|
|
|
|
|
return ctx;
|
|
|
|
}
|
|
|
|
|
|
|
|
void CTX_store_free(bContextStore *store)
|
|
|
|
{
|
|
|
|
BLI_freelistN(&store->entries);
|
|
|
|
MEM_freeN(store);
|
|
|
|
}
|
|
|
|
|
|
|
|
void CTX_store_free_list(ListBase *contexts)
|
|
|
|
{
|
|
|
|
bContextStore *ctx;
|
|
|
|
|
|
|
|
while((ctx= contexts->first)) {
|
|
|
|
BLI_remlink(contexts, ctx);
|
|
|
|
CTX_store_free(ctx);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-07-18 19:40:26 +00:00
|
|
|
/* is python initialied? */
|
|
|
|
int CTX_py_init_get(bContext *C)
|
|
|
|
{
|
|
|
|
return C->data.py_init;
|
|
|
|
}
|
2009-07-18 19:42:13 +00:00
|
|
|
void CTX_py_init_set(bContext *C, int value)
|
2009-07-18 19:40:26 +00:00
|
|
|
{
|
|
|
|
C->data.py_init= value;
|
|
|
|
}
|
|
|
|
|
2009-10-29 09:25:11 +00:00
|
|
|
void *CTX_py_dict_get(bContext *C)
|
|
|
|
{
|
|
|
|
return C->data.py_context;
|
|
|
|
}
|
|
|
|
void CTX_py_dict_set(bContext *C, void *value)
|
|
|
|
{
|
|
|
|
C->data.py_context= value;
|
|
|
|
}
|
|
|
|
|
2008-12-18 02:56:48 +00:00
|
|
|
/* window manager context */
|
|
|
|
|
|
|
|
wmWindowManager *CTX_wm_manager(const bContext *C)
|
|
|
|
{
|
|
|
|
return C->wm.manager;
|
|
|
|
}
|
|
|
|
|
|
|
|
wmWindow *CTX_wm_window(const bContext *C)
|
|
|
|
{
|
|
|
|
return C->wm.window;
|
|
|
|
}
|
|
|
|
|
|
|
|
bScreen *CTX_wm_screen(const bContext *C)
|
|
|
|
{
|
|
|
|
return C->wm.screen;
|
|
|
|
}
|
|
|
|
|
|
|
|
ScrArea *CTX_wm_area(const bContext *C)
|
|
|
|
{
|
|
|
|
return C->wm.area;
|
|
|
|
}
|
|
|
|
|
|
|
|
SpaceLink *CTX_wm_space_data(const bContext *C)
|
|
|
|
{
|
|
|
|
return (C->wm.area)? C->wm.area->spacedata.first: NULL;
|
|
|
|
}
|
|
|
|
|
2.5: Text Editor back.
There was very little structure in this code, using many globals
and duplicated code. Now it should be better structured. Most
things should work, the main parts that are not back yet are the
python plugins and markers. Notes:
* Blenfont is used for drawing the text, nicely anti-aliased.
* A monospace truetype font was added, since that is needed for
the text editor. It's Bitstream Vera Sans Mono. This is the
default gnome terminal font, but it doesn't fit entirely well
with the other font I think, can be changed easily of course.
* Clipboard copy/cut/paste now always uses the system clipboard,
the code for the own cut buffer was removed.
* The interface buttons should support copy/cut/paste again now
as well.
* WM_clipboard_text_get/WM_clipboard_text_set were added to the
windowmanager code.
* Find panel is now a kind of second header, instead of a panel.
This needs especially a way to start editing the text field
immediately on open still.
* Operators are independent of the actual space when possible,
was a bit of puzzling but got it solved nice with notifiers,
and some lazy init for syntax highlight in the drawing code.
* RNA was created for the text editor space and used for buttons.
* Operators:
* New, Open, Reload, Save, Save As, Make Internal
* Run Script, Refresh Pyconstraints
* Copy, Cut, Paste
* Convert Whitespace, Uncomment, Comment, Indent, Unindent
* Line Break, Insert
* Next Marker, Previous Marker, Clear All Markers, Mark All
* Select Line, Select All
* Jump, Move, Move Select, Delete, Toggle Overwrite
* Scroll, Scroll Bar, Set Cursor, Line Number
* Find and Replace, Find, Replace, Find Set Selected,
Replace Set Selected
* To 3D Object
* Resolve Conflict
2009-02-28 23:33:35 +00:00
|
|
|
ARegion *CTX_wm_region(const bContext *C)
|
|
|
|
{
|
|
|
|
return C->wm.region;
|
|
|
|
}
|
|
|
|
|
|
|
|
void *CTX_wm_region_data(const bContext *C)
|
|
|
|
{
|
|
|
|
return (C->wm.region)? C->wm.region->regiondata: NULL;
|
|
|
|
}
|
|
|
|
|
2009-03-25 20:49:15 +00:00
|
|
|
struct ARegion *CTX_wm_menu(const bContext *C)
|
2.5: Text Editor back.
There was very little structure in this code, using many globals
and duplicated code. Now it should be better structured. Most
things should work, the main parts that are not back yet are the
python plugins and markers. Notes:
* Blenfont is used for drawing the text, nicely anti-aliased.
* A monospace truetype font was added, since that is needed for
the text editor. It's Bitstream Vera Sans Mono. This is the
default gnome terminal font, but it doesn't fit entirely well
with the other font I think, can be changed easily of course.
* Clipboard copy/cut/paste now always uses the system clipboard,
the code for the own cut buffer was removed.
* The interface buttons should support copy/cut/paste again now
as well.
* WM_clipboard_text_get/WM_clipboard_text_set were added to the
windowmanager code.
* Find panel is now a kind of second header, instead of a panel.
This needs especially a way to start editing the text field
immediately on open still.
* Operators are independent of the actual space when possible,
was a bit of puzzling but got it solved nice with notifiers,
and some lazy init for syntax highlight in the drawing code.
* RNA was created for the text editor space and used for buttons.
* Operators:
* New, Open, Reload, Save, Save As, Make Internal
* Run Script, Refresh Pyconstraints
* Copy, Cut, Paste
* Convert Whitespace, Uncomment, Comment, Indent, Unindent
* Line Break, Insert
* Next Marker, Previous Marker, Clear All Markers, Mark All
* Select Line, Select All
* Jump, Move, Move Select, Delete, Toggle Overwrite
* Scroll, Scroll Bar, Set Cursor, Line Number
* Find and Replace, Find, Replace, Find Set Selected,
Replace Set Selected
* To 3D Object
* Resolve Conflict
2009-02-28 23:33:35 +00:00
|
|
|
{
|
2009-03-25 20:49:15 +00:00
|
|
|
return C->wm.menu;
|
2.5: Text Editor back.
There was very little structure in this code, using many globals
and duplicated code. Now it should be better structured. Most
things should work, the main parts that are not back yet are the
python plugins and markers. Notes:
* Blenfont is used for drawing the text, nicely anti-aliased.
* A monospace truetype font was added, since that is needed for
the text editor. It's Bitstream Vera Sans Mono. This is the
default gnome terminal font, but it doesn't fit entirely well
with the other font I think, can be changed easily of course.
* Clipboard copy/cut/paste now always uses the system clipboard,
the code for the own cut buffer was removed.
* The interface buttons should support copy/cut/paste again now
as well.
* WM_clipboard_text_get/WM_clipboard_text_set were added to the
windowmanager code.
* Find panel is now a kind of second header, instead of a panel.
This needs especially a way to start editing the text field
immediately on open still.
* Operators are independent of the actual space when possible,
was a bit of puzzling but got it solved nice with notifiers,
and some lazy init for syntax highlight in the drawing code.
* RNA was created for the text editor space and used for buttons.
* Operators:
* New, Open, Reload, Save, Save As, Make Internal
* Run Script, Refresh Pyconstraints
* Copy, Cut, Paste
* Convert Whitespace, Uncomment, Comment, Indent, Unindent
* Line Break, Insert
* Next Marker, Previous Marker, Clear All Markers, Mark All
* Select Line, Select All
* Jump, Move, Move Select, Delete, Toggle Overwrite
* Scroll, Scroll Bar, Set Cursor, Line Number
* Find and Replace, Find, Replace, Find Set Selected,
Replace Set Selected
* To 3D Object
* Resolve Conflict
2009-02-28 23:33:35 +00:00
|
|
|
}
|
|
|
|
|
2009-07-16 00:50:27 +00:00
|
|
|
struct ReportList *CTX_wm_reports(const bContext *C)
|
|
|
|
{
|
2009-08-14 18:18:19 +00:00
|
|
|
if (C->wm.manager)
|
|
|
|
return &(C->wm.manager->reports);
|
|
|
|
|
|
|
|
return NULL;
|
2009-07-16 00:50:27 +00:00
|
|
|
}
|
|
|
|
|
2009-01-17 18:35:33 +00:00
|
|
|
View3D *CTX_wm_view3d(const bContext *C)
|
|
|
|
{
|
|
|
|
if(C->wm.area && C->wm.area->spacetype==SPACE_VIEW3D)
|
|
|
|
return C->wm.area->spacedata.first;
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2.5
View3D has been split now in a local part (RegionView3D) and a
per-area part (old View3D). Currently local is:
- view transform
- camera zoom/offset
- gpencil (todo)
- custom clipping planes
Rest is in Area still, like active camera, draw type, layers,
localview, custom centers, around-settings, transform widget,
gridlines, and so on (mostly stuff as available in header).
To see it work; also added new feature for region split,
press SHIFT+ALT+CTRL+S for four-split.
The idea is to make a preset 4-split, configured to stick
to top/right/front views for three views.
Another cool idea to explore is to then box-clip all drawing
based on these 3 views.
Note about the code:
- currently view3d still stores some depricated settings, to
convert from older files. Not all settings are copied over
though, like custom clip planes or the 'lock view to object'.
- since some view3d ops are now on area level, the operators
for it should keep track of that.
Bugfix in transform: quat initialize in operator-invoke missed
one zero.
Als brought back GE to compile for missing Ipos and channels.
2009-01-19 16:54:41 +00:00
|
|
|
RegionView3D *CTX_wm_region_view3d(const bContext *C)
|
|
|
|
{
|
|
|
|
if(C->wm.area && C->wm.area->spacetype==SPACE_VIEW3D)
|
|
|
|
if(C->wm.region)
|
|
|
|
return C->wm.region->regiondata;
|
|
|
|
return NULL;
|
|
|
|
}
|
2009-01-17 18:35:33 +00:00
|
|
|
|
2.5: Text Editor back.
There was very little structure in this code, using many globals
and duplicated code. Now it should be better structured. Most
things should work, the main parts that are not back yet are the
python plugins and markers. Notes:
* Blenfont is used for drawing the text, nicely anti-aliased.
* A monospace truetype font was added, since that is needed for
the text editor. It's Bitstream Vera Sans Mono. This is the
default gnome terminal font, but it doesn't fit entirely well
with the other font I think, can be changed easily of course.
* Clipboard copy/cut/paste now always uses the system clipboard,
the code for the own cut buffer was removed.
* The interface buttons should support copy/cut/paste again now
as well.
* WM_clipboard_text_get/WM_clipboard_text_set were added to the
windowmanager code.
* Find panel is now a kind of second header, instead of a panel.
This needs especially a way to start editing the text field
immediately on open still.
* Operators are independent of the actual space when possible,
was a bit of puzzling but got it solved nice with notifiers,
and some lazy init for syntax highlight in the drawing code.
* RNA was created for the text editor space and used for buttons.
* Operators:
* New, Open, Reload, Save, Save As, Make Internal
* Run Script, Refresh Pyconstraints
* Copy, Cut, Paste
* Convert Whitespace, Uncomment, Comment, Indent, Unindent
* Line Break, Insert
* Next Marker, Previous Marker, Clear All Markers, Mark All
* Select Line, Select All
* Jump, Move, Move Select, Delete, Toggle Overwrite
* Scroll, Scroll Bar, Set Cursor, Line Number
* Find and Replace, Find, Replace, Find Set Selected,
Replace Set Selected
* To 3D Object
* Resolve Conflict
2009-02-28 23:33:35 +00:00
|
|
|
struct SpaceText *CTX_wm_space_text(const bContext *C)
|
2008-12-18 02:56:48 +00:00
|
|
|
{
|
2.5: Text Editor back.
There was very little structure in this code, using many globals
and duplicated code. Now it should be better structured. Most
things should work, the main parts that are not back yet are the
python plugins and markers. Notes:
* Blenfont is used for drawing the text, nicely anti-aliased.
* A monospace truetype font was added, since that is needed for
the text editor. It's Bitstream Vera Sans Mono. This is the
default gnome terminal font, but it doesn't fit entirely well
with the other font I think, can be changed easily of course.
* Clipboard copy/cut/paste now always uses the system clipboard,
the code for the own cut buffer was removed.
* The interface buttons should support copy/cut/paste again now
as well.
* WM_clipboard_text_get/WM_clipboard_text_set were added to the
windowmanager code.
* Find panel is now a kind of second header, instead of a panel.
This needs especially a way to start editing the text field
immediately on open still.
* Operators are independent of the actual space when possible,
was a bit of puzzling but got it solved nice with notifiers,
and some lazy init for syntax highlight in the drawing code.
* RNA was created for the text editor space and used for buttons.
* Operators:
* New, Open, Reload, Save, Save As, Make Internal
* Run Script, Refresh Pyconstraints
* Copy, Cut, Paste
* Convert Whitespace, Uncomment, Comment, Indent, Unindent
* Line Break, Insert
* Next Marker, Previous Marker, Clear All Markers, Mark All
* Select Line, Select All
* Jump, Move, Move Select, Delete, Toggle Overwrite
* Scroll, Scroll Bar, Set Cursor, Line Number
* Find and Replace, Find, Replace, Find Set Selected,
Replace Set Selected
* To 3D Object
* Resolve Conflict
2009-02-28 23:33:35 +00:00
|
|
|
if(C->wm.area && C->wm.area->spacetype==SPACE_TEXT)
|
|
|
|
return C->wm.area->spacedata.first;
|
|
|
|
return NULL;
|
2008-12-18 02:56:48 +00:00
|
|
|
}
|
|
|
|
|
2009-07-16 00:50:27 +00:00
|
|
|
struct SpaceConsole *CTX_wm_space_console(const bContext *C)
|
|
|
|
{
|
|
|
|
if(C->wm.area && C->wm.area->spacetype==SPACE_CONSOLE)
|
|
|
|
return C->wm.area->spacedata.first;
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2.5: Text Editor back.
There was very little structure in this code, using many globals
and duplicated code. Now it should be better structured. Most
things should work, the main parts that are not back yet are the
python plugins and markers. Notes:
* Blenfont is used for drawing the text, nicely anti-aliased.
* A monospace truetype font was added, since that is needed for
the text editor. It's Bitstream Vera Sans Mono. This is the
default gnome terminal font, but it doesn't fit entirely well
with the other font I think, can be changed easily of course.
* Clipboard copy/cut/paste now always uses the system clipboard,
the code for the own cut buffer was removed.
* The interface buttons should support copy/cut/paste again now
as well.
* WM_clipboard_text_get/WM_clipboard_text_set were added to the
windowmanager code.
* Find panel is now a kind of second header, instead of a panel.
This needs especially a way to start editing the text field
immediately on open still.
* Operators are independent of the actual space when possible,
was a bit of puzzling but got it solved nice with notifiers,
and some lazy init for syntax highlight in the drawing code.
* RNA was created for the text editor space and used for buttons.
* Operators:
* New, Open, Reload, Save, Save As, Make Internal
* Run Script, Refresh Pyconstraints
* Copy, Cut, Paste
* Convert Whitespace, Uncomment, Comment, Indent, Unindent
* Line Break, Insert
* Next Marker, Previous Marker, Clear All Markers, Mark All
* Select Line, Select All
* Jump, Move, Move Select, Delete, Toggle Overwrite
* Scroll, Scroll Bar, Set Cursor, Line Number
* Find and Replace, Find, Replace, Find Set Selected,
Replace Set Selected
* To 3D Object
* Resolve Conflict
2009-02-28 23:33:35 +00:00
|
|
|
struct SpaceImage *CTX_wm_space_image(const bContext *C)
|
2008-12-18 02:56:48 +00:00
|
|
|
{
|
2.5: Text Editor back.
There was very little structure in this code, using many globals
and duplicated code. Now it should be better structured. Most
things should work, the main parts that are not back yet are the
python plugins and markers. Notes:
* Blenfont is used for drawing the text, nicely anti-aliased.
* A monospace truetype font was added, since that is needed for
the text editor. It's Bitstream Vera Sans Mono. This is the
default gnome terminal font, but it doesn't fit entirely well
with the other font I think, can be changed easily of course.
* Clipboard copy/cut/paste now always uses the system clipboard,
the code for the own cut buffer was removed.
* The interface buttons should support copy/cut/paste again now
as well.
* WM_clipboard_text_get/WM_clipboard_text_set were added to the
windowmanager code.
* Find panel is now a kind of second header, instead of a panel.
This needs especially a way to start editing the text field
immediately on open still.
* Operators are independent of the actual space when possible,
was a bit of puzzling but got it solved nice with notifiers,
and some lazy init for syntax highlight in the drawing code.
* RNA was created for the text editor space and used for buttons.
* Operators:
* New, Open, Reload, Save, Save As, Make Internal
* Run Script, Refresh Pyconstraints
* Copy, Cut, Paste
* Convert Whitespace, Uncomment, Comment, Indent, Unindent
* Line Break, Insert
* Next Marker, Previous Marker, Clear All Markers, Mark All
* Select Line, Select All
* Jump, Move, Move Select, Delete, Toggle Overwrite
* Scroll, Scroll Bar, Set Cursor, Line Number
* Find and Replace, Find, Replace, Find Set Selected,
Replace Set Selected
* To 3D Object
* Resolve Conflict
2009-02-28 23:33:35 +00:00
|
|
|
if(C->wm.area && C->wm.area->spacetype==SPACE_IMAGE)
|
|
|
|
return C->wm.area->spacedata.first;
|
|
|
|
return NULL;
|
2008-12-18 02:56:48 +00:00
|
|
|
}
|
|
|
|
|
2009-07-28 16:33:02 +00:00
|
|
|
struct SpaceButs *CTX_wm_space_buts(const bContext *C)
|
|
|
|
{
|
|
|
|
if(C->wm.area && C->wm.area->spacetype==SPACE_BUTS)
|
|
|
|
return C->wm.area->spacedata.first;
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct SpaceFile *CTX_wm_space_file(const bContext *C)
|
|
|
|
{
|
|
|
|
if(C->wm.area && C->wm.area->spacetype==SPACE_FILE)
|
|
|
|
return C->wm.area->spacedata.first;
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct SpaceSeq *CTX_wm_space_seq(const bContext *C)
|
|
|
|
{
|
|
|
|
if(C->wm.area && C->wm.area->spacetype==SPACE_SEQ)
|
|
|
|
return C->wm.area->spacedata.first;
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct SpaceOops *CTX_wm_space_outliner(const bContext *C)
|
|
|
|
{
|
|
|
|
if(C->wm.area && C->wm.area->spacetype==SPACE_OUTLINER)
|
|
|
|
return C->wm.area->spacedata.first;
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct SpaceNla *CTX_wm_space_nla(const bContext *C)
|
|
|
|
{
|
|
|
|
if(C->wm.area && C->wm.area->spacetype==SPACE_NLA)
|
|
|
|
return C->wm.area->spacedata.first;
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct SpaceTime *CTX_wm_space_time(const bContext *C)
|
|
|
|
{
|
|
|
|
if(C->wm.area && C->wm.area->spacetype==SPACE_TIME)
|
|
|
|
return C->wm.area->spacedata.first;
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct SpaceNode *CTX_wm_space_node(const bContext *C)
|
|
|
|
{
|
|
|
|
if(C->wm.area && C->wm.area->spacetype==SPACE_NODE)
|
|
|
|
return C->wm.area->spacedata.first;
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct SpaceLogic *CTX_wm_space_logic(const bContext *C)
|
|
|
|
{
|
|
|
|
if(C->wm.area && C->wm.area->spacetype==SPACE_LOGIC)
|
|
|
|
return C->wm.area->spacedata.first;
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct SpaceIpo *CTX_wm_space_graph(const bContext *C)
|
|
|
|
{
|
|
|
|
if(C->wm.area && C->wm.area->spacetype==SPACE_IPO)
|
|
|
|
return C->wm.area->spacedata.first;
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct SpaceAction *CTX_wm_space_action(const bContext *C)
|
|
|
|
{
|
|
|
|
if(C->wm.area && C->wm.area->spacetype==SPACE_ACTION)
|
|
|
|
return C->wm.area->spacedata.first;
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct SpaceInfo *CTX_wm_space_info(const bContext *C)
|
|
|
|
{
|
|
|
|
if(C->wm.area && C->wm.area->spacetype==SPACE_INFO)
|
|
|
|
return C->wm.area->spacedata.first;
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2009-08-18 12:58:51 +00:00
|
|
|
struct SpaceUserPref *CTX_wm_space_userpref(const bContext *C)
|
|
|
|
{
|
|
|
|
if(C->wm.area && C->wm.area->spacetype==SPACE_USERPREF)
|
|
|
|
return C->wm.area->spacedata.first;
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2008-12-18 02:56:48 +00:00
|
|
|
void CTX_wm_manager_set(bContext *C, wmWindowManager *wm)
|
|
|
|
{
|
|
|
|
C->wm.manager= wm;
|
2009-01-23 17:42:36 +00:00
|
|
|
C->wm.window= NULL;
|
|
|
|
C->wm.screen= NULL;
|
|
|
|
C->wm.area= NULL;
|
|
|
|
C->wm.region= NULL;
|
2008-12-18 02:56:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CTX_wm_window_set(bContext *C, wmWindow *win)
|
|
|
|
{
|
|
|
|
C->wm.window= win;
|
|
|
|
C->wm.screen= (win)? win->screen: NULL;
|
|
|
|
C->data.scene= (C->wm.screen)? C->wm.screen->scene: NULL;
|
2009-01-23 17:42:36 +00:00
|
|
|
C->wm.area= NULL;
|
|
|
|
C->wm.region= NULL;
|
2008-12-18 02:56:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CTX_wm_screen_set(bContext *C, bScreen *screen)
|
|
|
|
{
|
|
|
|
C->wm.screen= screen;
|
|
|
|
C->data.scene= (C->wm.screen)? C->wm.screen->scene: NULL;
|
2009-01-23 17:42:36 +00:00
|
|
|
C->wm.area= NULL;
|
|
|
|
C->wm.region= NULL;
|
2008-12-18 02:56:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CTX_wm_area_set(bContext *C, ScrArea *area)
|
|
|
|
{
|
|
|
|
C->wm.area= area;
|
2009-01-23 17:42:36 +00:00
|
|
|
C->wm.region= NULL;
|
2008-12-18 02:56:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CTX_wm_region_set(bContext *C, ARegion *region)
|
|
|
|
{
|
|
|
|
C->wm.region= region;
|
|
|
|
}
|
|
|
|
|
2009-03-25 20:49:15 +00:00
|
|
|
void CTX_wm_menu_set(bContext *C, ARegion *menu)
|
2008-12-18 02:56:48 +00:00
|
|
|
{
|
2009-03-25 20:49:15 +00:00
|
|
|
C->wm.menu= menu;
|
2008-12-18 02:56:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* data context utility functions */
|
|
|
|
|
2008-12-23 02:07:13 +00:00
|
|
|
struct bContextDataResult {
|
2009-03-19 19:03:38 +00:00
|
|
|
PointerRNA ptr;
|
2008-12-23 02:07:13 +00:00
|
|
|
ListBase list;
|
2009-06-20 14:55:28 +00:00
|
|
|
const char **dir;
|
2008-12-23 02:07:13 +00:00
|
|
|
};
|
2008-12-18 02:56:48 +00:00
|
|
|
|
2009-03-19 19:03:38 +00:00
|
|
|
static int ctx_data_get(bContext *C, const char *member, bContextDataResult *result)
|
2008-12-23 02:07:13 +00:00
|
|
|
{
|
|
|
|
int done= 0, recursion= C->data.recursion;
|
2008-12-18 02:56:48 +00:00
|
|
|
|
2008-12-23 02:07:13 +00:00
|
|
|
memset(result, 0, sizeof(bContextDataResult));
|
2008-12-18 02:56:48 +00:00
|
|
|
|
2009-10-29 09:25:11 +00:00
|
|
|
if(CTX_py_dict_get(C)) {
|
|
|
|
return bpy_context_get(C, member, result);
|
|
|
|
}
|
|
|
|
|
2008-12-23 02:07:13 +00:00
|
|
|
/* we check recursion to ensure that we do not get infinite
|
|
|
|
* loops requesting data from ourselfs in a context callback */
|
2009-05-28 23:13:42 +00:00
|
|
|
if(!done && recursion < 1 && C->wm.store) {
|
|
|
|
bContextStoreEntry *entry;
|
|
|
|
|
2008-12-23 02:07:13 +00:00
|
|
|
C->data.recursion= 1;
|
2009-05-28 23:13:42 +00:00
|
|
|
|
|
|
|
for(entry=C->wm.store->entries.first; entry; entry=entry->next) {
|
|
|
|
if(strcmp(entry->name, member) == 0) {
|
|
|
|
result->ptr= entry->ptr;
|
|
|
|
done= 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(!done && recursion < 2 && C->wm.region) {
|
|
|
|
C->data.recursion= 2;
|
2008-12-30 21:28:27 +00:00
|
|
|
if(C->wm.region->type && C->wm.region->type->context)
|
2008-12-29 13:38:08 +00:00
|
|
|
done= C->wm.region->type->context(C, member, result);
|
2008-12-23 02:07:13 +00:00
|
|
|
}
|
2009-05-28 23:13:42 +00:00
|
|
|
if(!done && recursion < 3 && C->wm.area) {
|
|
|
|
C->data.recursion= 3;
|
2008-12-30 21:28:27 +00:00
|
|
|
if(C->wm.area->type && C->wm.area->type->context)
|
2008-12-29 13:38:08 +00:00
|
|
|
done= C->wm.area->type->context(C, member, result);
|
2008-12-23 02:07:13 +00:00
|
|
|
}
|
2009-05-28 23:13:42 +00:00
|
|
|
if(!done && recursion < 4 && C->wm.screen) {
|
2008-12-29 13:38:08 +00:00
|
|
|
bContextDataCallback cb= C->wm.screen->context;
|
2009-05-28 23:13:42 +00:00
|
|
|
C->data.recursion= 4;
|
2008-12-29 13:38:08 +00:00
|
|
|
if(cb)
|
|
|
|
done= cb(C, member, result);
|
2008-12-23 02:07:13 +00:00
|
|
|
}
|
2008-12-18 02:56:48 +00:00
|
|
|
|
2008-12-23 02:07:13 +00:00
|
|
|
C->data.recursion= recursion;
|
|
|
|
|
|
|
|
return done;
|
2008-12-18 02:56:48 +00:00
|
|
|
}
|
|
|
|
|
2009-03-19 19:03:38 +00:00
|
|
|
static void *ctx_data_pointer_get(const bContext *C, const char *member)
|
2008-12-18 02:56:48 +00:00
|
|
|
{
|
|
|
|
bContextDataResult result;
|
|
|
|
|
2009-10-14 18:48:19 +00:00
|
|
|
if(C && ctx_data_get((bContext*)C, member, &result))
|
2009-03-19 19:03:38 +00:00
|
|
|
return result.ptr.data;
|
2008-12-18 02:56:48 +00:00
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2009-03-19 19:03:38 +00:00
|
|
|
static int ctx_data_pointer_verify(const bContext *C, const char *member, void **pointer)
|
2008-12-18 02:56:48 +00:00
|
|
|
{
|
|
|
|
bContextDataResult result;
|
|
|
|
|
2008-12-23 02:07:13 +00:00
|
|
|
if(ctx_data_get((bContext*)C, member, &result)) {
|
2009-03-19 19:03:38 +00:00
|
|
|
*pointer= result.ptr.data;
|
2008-12-18 02:56:48 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
*pointer= NULL;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-03-19 19:03:38 +00:00
|
|
|
static int ctx_data_collection_get(const bContext *C, const char *member, ListBase *list)
|
2008-12-18 02:56:48 +00:00
|
|
|
{
|
|
|
|
bContextDataResult result;
|
|
|
|
|
2008-12-23 02:07:13 +00:00
|
|
|
if(ctx_data_get((bContext*)C, member, &result)) {
|
|
|
|
*list= result.list;
|
2008-12-18 02:56:48 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2009-06-28 11:37:45 +00:00
|
|
|
list->first= NULL;
|
|
|
|
list->last= NULL;
|
|
|
|
|
2008-12-18 02:56:48 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-06-20 14:55:28 +00:00
|
|
|
PointerRNA CTX_data_pointer_get(const bContext *C, const char *member)
|
2008-12-23 02:07:13 +00:00
|
|
|
{
|
2009-03-19 19:03:38 +00:00
|
|
|
bContextDataResult result;
|
|
|
|
|
2009-06-24 14:03:55 +00:00
|
|
|
if(ctx_data_get((bContext*)C, member, &result))
|
2009-03-19 19:03:38 +00:00
|
|
|
return result.ptr;
|
2009-06-24 14:03:55 +00:00
|
|
|
else
|
|
|
|
return PointerRNA_NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
PointerRNA CTX_data_pointer_get_type(const bContext *C, const char *member, StructRNA *type)
|
|
|
|
{
|
|
|
|
PointerRNA ptr = CTX_data_pointer_get(C, member);
|
2009-03-19 19:03:38 +00:00
|
|
|
|
2009-07-02 19:41:31 +00:00
|
|
|
if(ptr.data && RNA_struct_is_a(ptr.type, type))
|
2009-06-24 14:03:55 +00:00
|
|
|
return ptr;
|
|
|
|
|
|
|
|
return PointerRNA_NULL;
|
2008-12-23 02:07:13 +00:00
|
|
|
}
|
|
|
|
|
2009-06-20 14:55:28 +00:00
|
|
|
ListBase CTX_data_collection_get(const bContext *C, const char *member)
|
2008-12-23 02:07:13 +00:00
|
|
|
{
|
2009-03-19 19:03:38 +00:00
|
|
|
bContextDataResult result;
|
|
|
|
|
|
|
|
if(ctx_data_get((bContext*)C, member, &result)) {
|
|
|
|
return result.list;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
ListBase list;
|
|
|
|
memset(&list, 0, sizeof(list));
|
|
|
|
return list;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-06-20 14:55:28 +00:00
|
|
|
void CTX_data_get(const bContext *C, const char *member, PointerRNA *r_ptr, ListBase *r_lb)
|
2009-03-19 19:03:38 +00:00
|
|
|
{
|
|
|
|
bContextDataResult result;
|
|
|
|
|
|
|
|
if(ctx_data_get((bContext*)C, member, &result)) {
|
|
|
|
*r_ptr= result.ptr;
|
|
|
|
*r_lb= result.list;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
memset(r_ptr, 0, sizeof(*r_ptr));
|
|
|
|
memset(r_lb, 0, sizeof(*r_lb));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-06-20 14:55:28 +00:00
|
|
|
static void data_dir_add(ListBase *lb, const char *member)
|
|
|
|
{
|
|
|
|
LinkData *link;
|
|
|
|
|
|
|
|
if(strcmp(member, "scene") == 0) /* exception */
|
|
|
|
return;
|
|
|
|
|
|
|
|
for(link=lb->first; link; link=link->next)
|
|
|
|
if(strcmp(link->data, member) == 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
link= MEM_callocN(sizeof(LinkData), "LinkData");
|
|
|
|
link->data= (void*)member;
|
|
|
|
BLI_addtail(lb, link);
|
|
|
|
}
|
|
|
|
|
|
|
|
ListBase CTX_data_dir_get(const bContext *C)
|
|
|
|
{
|
|
|
|
bContextDataResult result;
|
|
|
|
ListBase lb;
|
|
|
|
int a;
|
|
|
|
|
|
|
|
memset(&lb, 0, sizeof(lb));
|
|
|
|
|
|
|
|
if(C->wm.store) {
|
|
|
|
bContextStoreEntry *entry;
|
|
|
|
|
|
|
|
for(entry=C->wm.store->entries.first; entry; entry=entry->next)
|
|
|
|
data_dir_add(&lb, entry->name);
|
|
|
|
}
|
|
|
|
if(C->wm.region && C->wm.region->type && C->wm.region->type->context) {
|
|
|
|
memset(&result, 0, sizeof(result));
|
|
|
|
C->wm.region->type->context(C, "", &result);
|
|
|
|
|
|
|
|
if(result.dir)
|
|
|
|
for(a=0; result.dir[a]; a++)
|
|
|
|
data_dir_add(&lb, result.dir[a]);
|
|
|
|
}
|
|
|
|
if(C->wm.area && C->wm.area->type && C->wm.area->type->context) {
|
|
|
|
memset(&result, 0, sizeof(result));
|
|
|
|
C->wm.area->type->context(C, "", &result);
|
|
|
|
|
|
|
|
if(result.dir)
|
|
|
|
for(a=0; result.dir[a]; a++)
|
|
|
|
data_dir_add(&lb, result.dir[a]);
|
|
|
|
}
|
|
|
|
if(C->wm.screen && C->wm.screen->context) {
|
|
|
|
bContextDataCallback cb= C->wm.screen->context;
|
|
|
|
memset(&result, 0, sizeof(result));
|
|
|
|
cb(C, "", &result);
|
|
|
|
|
|
|
|
if(result.dir)
|
|
|
|
for(a=0; result.dir[a]; a++)
|
|
|
|
data_dir_add(&lb, result.dir[a]);
|
|
|
|
}
|
|
|
|
|
|
|
|
return lb;
|
|
|
|
}
|
|
|
|
|
2009-03-19 19:03:38 +00:00
|
|
|
int CTX_data_equals(const char *member, const char *str)
|
|
|
|
{
|
|
|
|
return (strcmp(member, str) == 0);
|
|
|
|
}
|
|
|
|
|
2009-06-20 14:55:28 +00:00
|
|
|
int CTX_data_dir(const char *member)
|
|
|
|
{
|
|
|
|
return (strcmp(member, "") == 0);
|
|
|
|
}
|
|
|
|
|
2009-03-19 19:03:38 +00:00
|
|
|
void CTX_data_id_pointer_set(bContextDataResult *result, ID *id)
|
|
|
|
{
|
|
|
|
RNA_id_pointer_create(id, &result->ptr);
|
|
|
|
}
|
|
|
|
|
|
|
|
void CTX_data_pointer_set(bContextDataResult *result, ID *id, StructRNA *type, void *data)
|
|
|
|
{
|
|
|
|
RNA_pointer_create(id, type, data, &result->ptr);
|
|
|
|
}
|
|
|
|
|
|
|
|
void CTX_data_id_list_add(bContextDataResult *result, ID *id)
|
|
|
|
{
|
|
|
|
CollectionPointerLink *link;
|
|
|
|
|
|
|
|
link= MEM_callocN(sizeof(CollectionPointerLink), "CTX_data_id_list_add");
|
|
|
|
RNA_id_pointer_create(id, &link->ptr);
|
|
|
|
|
|
|
|
BLI_addtail(&result->list, link);
|
|
|
|
}
|
|
|
|
|
|
|
|
void CTX_data_list_add(bContextDataResult *result, ID *id, StructRNA *type, void *data)
|
|
|
|
{
|
|
|
|
CollectionPointerLink *link;
|
|
|
|
|
|
|
|
link= MEM_callocN(sizeof(CollectionPointerLink), "CTX_data_list_add");
|
|
|
|
RNA_pointer_create(id, type, data, &link->ptr);
|
2008-12-23 02:07:13 +00:00
|
|
|
|
|
|
|
BLI_addtail(&result->list, link);
|
|
|
|
}
|
|
|
|
|
2009-01-17 00:51:42 +00:00
|
|
|
int ctx_data_list_count(const bContext *C, int (*func)(const bContext*, ListBase*))
|
|
|
|
{
|
|
|
|
ListBase list;
|
|
|
|
|
2009-02-07 13:39:54 +00:00
|
|
|
if(func(C, &list)) {
|
|
|
|
int tot= BLI_countlist(&list);
|
|
|
|
BLI_freelistN(&list);
|
|
|
|
return tot;
|
|
|
|
}
|
2009-01-17 00:51:42 +00:00
|
|
|
else
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-06-20 14:55:28 +00:00
|
|
|
void CTX_data_dir_set(bContextDataResult *result, const char **dir)
|
|
|
|
{
|
|
|
|
result->dir= dir;
|
|
|
|
}
|
|
|
|
|
2008-12-18 02:56:48 +00:00
|
|
|
/* data context */
|
|
|
|
|
|
|
|
Main *CTX_data_main(const bContext *C)
|
|
|
|
{
|
|
|
|
Main *bmain;
|
|
|
|
|
2009-03-19 19:03:38 +00:00
|
|
|
if(ctx_data_pointer_verify(C, "main", (void*)&bmain))
|
2008-12-18 02:56:48 +00:00
|
|
|
return bmain;
|
|
|
|
else
|
|
|
|
return C->data.main;
|
|
|
|
}
|
|
|
|
|
|
|
|
void CTX_data_main_set(bContext *C, Main *bmain)
|
|
|
|
{
|
|
|
|
C->data.main= bmain;
|
|
|
|
}
|
|
|
|
|
|
|
|
Scene *CTX_data_scene(const bContext *C)
|
|
|
|
{
|
|
|
|
Scene *scene;
|
|
|
|
|
2009-03-19 19:03:38 +00:00
|
|
|
if(ctx_data_pointer_verify(C, "scene", (void*)&scene))
|
2008-12-18 02:56:48 +00:00
|
|
|
return scene;
|
|
|
|
else
|
|
|
|
return C->data.scene;
|
|
|
|
}
|
|
|
|
|
2009-08-16 03:40:00 +00:00
|
|
|
int CTX_data_mode_enum(const bContext *C)
|
2009-08-15 19:40:09 +00:00
|
|
|
{
|
|
|
|
Object *obedit= CTX_data_edit_object(C);
|
|
|
|
|
|
|
|
if(obedit) {
|
|
|
|
switch(obedit->type) {
|
|
|
|
case OB_MESH:
|
2009-08-16 03:40:00 +00:00
|
|
|
return CTX_MODE_EDIT_MESH;
|
2009-08-15 19:40:09 +00:00
|
|
|
case OB_CURVE:
|
2009-08-16 03:40:00 +00:00
|
|
|
return CTX_MODE_EDIT_CURVE;
|
2009-08-15 19:40:09 +00:00
|
|
|
case OB_SURF:
|
2009-08-16 03:40:00 +00:00
|
|
|
return CTX_MODE_EDIT_SURFACE;
|
2009-08-15 19:40:09 +00:00
|
|
|
case OB_FONT:
|
2009-08-16 03:40:00 +00:00
|
|
|
return CTX_MODE_EDIT_TEXT;
|
2009-08-15 19:40:09 +00:00
|
|
|
case OB_ARMATURE:
|
2009-08-16 03:40:00 +00:00
|
|
|
return CTX_MODE_EDIT_ARMATURE;
|
2009-08-15 19:40:09 +00:00
|
|
|
case OB_MBALL:
|
2009-08-16 03:40:00 +00:00
|
|
|
return CTX_MODE_EDIT_METABALL;
|
2009-08-15 19:40:09 +00:00
|
|
|
case OB_LATTICE:
|
2009-08-16 03:40:00 +00:00
|
|
|
return CTX_MODE_EDIT_LATTICE;
|
2009-08-15 19:40:09 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
Object *ob = CTX_data_active_object(C);
|
2009-08-16 03:40:00 +00:00
|
|
|
|
2009-08-16 01:25:53 +00:00
|
|
|
if(ob) {
|
2009-08-16 03:40:00 +00:00
|
|
|
if(ob->mode & OB_MODE_POSE) return CTX_MODE_POSE;
|
|
|
|
else if(ob->mode & OB_MODE_SCULPT) return CTX_MODE_SCULPT;
|
|
|
|
else if(ob->mode & OB_MODE_WEIGHT_PAINT) return CTX_MODE_PAINT_WEIGHT;
|
|
|
|
else if(ob->mode & OB_MODE_VERTEX_PAINT) return CTX_MODE_PAINT_VERTEX;
|
|
|
|
else if(ob->mode & OB_MODE_TEXTURE_PAINT) return CTX_MODE_PAINT_TEXTURE;
|
|
|
|
else if(ob->mode & OB_MODE_PARTICLE_EDIT) return CTX_MODE_PARTICLE;
|
2009-08-16 01:25:53 +00:00
|
|
|
}
|
2009-08-15 19:40:09 +00:00
|
|
|
}
|
2009-08-16 03:40:00 +00:00
|
|
|
|
|
|
|
return CTX_MODE_OBJECT;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* would prefer if we can use the enum version below over this one - Campbell */
|
|
|
|
/* must be aligned with above enum */
|
|
|
|
static char *data_mode_strings[] = {
|
|
|
|
"mesh_edit",
|
|
|
|
"curve_edit",
|
|
|
|
"surface_edit",
|
|
|
|
"text_edit",
|
|
|
|
"armature_edit",
|
|
|
|
"mball_edit",
|
|
|
|
"lattice_edit",
|
|
|
|
"posemode",
|
|
|
|
"sculpt_mode",
|
|
|
|
"weightpaint",
|
|
|
|
"vertexpaint",
|
|
|
|
"texturepaint",
|
|
|
|
"particlemode",
|
|
|
|
"objectmode",
|
|
|
|
0
|
|
|
|
};
|
|
|
|
char *CTX_data_mode_string(const bContext *C)
|
|
|
|
{
|
|
|
|
return data_mode_strings[CTX_data_mode_enum(C)];
|
2009-08-15 19:40:09 +00:00
|
|
|
}
|
|
|
|
|
2008-12-18 02:56:48 +00:00
|
|
|
void CTX_data_scene_set(bContext *C, Scene *scene)
|
|
|
|
{
|
|
|
|
C->data.scene= scene;
|
|
|
|
}
|
|
|
|
|
|
|
|
ToolSettings *CTX_data_tool_settings(const bContext *C)
|
|
|
|
{
|
|
|
|
Scene *scene = CTX_data_scene(C);
|
|
|
|
|
|
|
|
if(scene)
|
|
|
|
return scene->toolsettings;
|
|
|
|
else
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2009-01-02 23:58:03 +00:00
|
|
|
int CTX_data_selected_nodes(const bContext *C, ListBase *list)
|
|
|
|
{
|
2009-03-19 19:03:38 +00:00
|
|
|
return ctx_data_collection_get(C, "selected_nodes", list);
|
2009-01-02 23:58:03 +00:00
|
|
|
}
|
|
|
|
|
2009-01-17 18:35:33 +00:00
|
|
|
int CTX_data_selected_editable_objects(const bContext *C, ListBase *list)
|
|
|
|
{
|
2009-03-19 19:03:38 +00:00
|
|
|
return ctx_data_collection_get(C, "selected_editable_objects", list);
|
2009-01-17 18:35:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int CTX_data_selected_editable_bases(const bContext *C, ListBase *list)
|
|
|
|
{
|
2009-03-19 19:03:38 +00:00
|
|
|
return ctx_data_collection_get(C, "selected_editable_bases", list);
|
2009-01-17 18:35:33 +00:00
|
|
|
}
|
|
|
|
|
2008-12-23 02:07:13 +00:00
|
|
|
int CTX_data_selected_objects(const bContext *C, ListBase *list)
|
|
|
|
{
|
2009-03-19 19:03:38 +00:00
|
|
|
return ctx_data_collection_get(C, "selected_objects", list);
|
2008-12-23 02:07:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int CTX_data_selected_bases(const bContext *C, ListBase *list)
|
|
|
|
{
|
2009-03-19 19:03:38 +00:00
|
|
|
return ctx_data_collection_get(C, "selected_bases", list);
|
2008-12-23 02:07:13 +00:00
|
|
|
}
|
|
|
|
|
2008-12-28 18:10:24 +00:00
|
|
|
int CTX_data_visible_objects(const bContext *C, ListBase *list)
|
|
|
|
{
|
2009-03-19 19:03:38 +00:00
|
|
|
return ctx_data_collection_get(C, "visible_objects", list);
|
2008-12-28 18:10:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int CTX_data_visible_bases(const bContext *C, ListBase *list)
|
|
|
|
{
|
2009-03-19 19:03:38 +00:00
|
|
|
return ctx_data_collection_get(C, "visible_bases", list);
|
2008-12-28 18:10:24 +00:00
|
|
|
}
|
|
|
|
|
2009-07-11 11:31:49 +00:00
|
|
|
int CTX_data_selectable_objects(const bContext *C, ListBase *list)
|
|
|
|
{
|
|
|
|
return ctx_data_collection_get(C, "selectable_objects", list);
|
|
|
|
}
|
|
|
|
|
|
|
|
int CTX_data_selectable_bases(const bContext *C, ListBase *list)
|
|
|
|
{
|
|
|
|
return ctx_data_collection_get(C, "selectable_bases", list);
|
|
|
|
}
|
|
|
|
|
2008-12-23 02:07:13 +00:00
|
|
|
struct Object *CTX_data_active_object(const bContext *C)
|
|
|
|
{
|
2009-03-19 19:03:38 +00:00
|
|
|
return ctx_data_pointer_get(C, "active_object");
|
2008-12-23 02:07:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
struct Base *CTX_data_active_base(const bContext *C)
|
2008-12-18 02:56:48 +00:00
|
|
|
{
|
2009-03-19 19:03:38 +00:00
|
|
|
return ctx_data_pointer_get(C, "active_base");
|
2008-12-18 02:56:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
struct Object *CTX_data_edit_object(const bContext *C)
|
|
|
|
{
|
2009-03-19 19:03:38 +00:00
|
|
|
return ctx_data_pointer_get(C, "edit_object");
|
2008-12-18 02:56:48 +00:00
|
|
|
}
|
|
|
|
|
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
|
|
|
struct Image *CTX_data_edit_image(const bContext *C)
|
|
|
|
{
|
2009-03-19 19:03:38 +00:00
|
|
|
return ctx_data_pointer_get(C, "edit_image");
|
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
|
|
|
}
|
|
|
|
|
2.5: Text Editor back.
There was very little structure in this code, using many globals
and duplicated code. Now it should be better structured. Most
things should work, the main parts that are not back yet are the
python plugins and markers. Notes:
* Blenfont is used for drawing the text, nicely anti-aliased.
* A monospace truetype font was added, since that is needed for
the text editor. It's Bitstream Vera Sans Mono. This is the
default gnome terminal font, but it doesn't fit entirely well
with the other font I think, can be changed easily of course.
* Clipboard copy/cut/paste now always uses the system clipboard,
the code for the own cut buffer was removed.
* The interface buttons should support copy/cut/paste again now
as well.
* WM_clipboard_text_get/WM_clipboard_text_set were added to the
windowmanager code.
* Find panel is now a kind of second header, instead of a panel.
This needs especially a way to start editing the text field
immediately on open still.
* Operators are independent of the actual space when possible,
was a bit of puzzling but got it solved nice with notifiers,
and some lazy init for syntax highlight in the drawing code.
* RNA was created for the text editor space and used for buttons.
* Operators:
* New, Open, Reload, Save, Save As, Make Internal
* Run Script, Refresh Pyconstraints
* Copy, Cut, Paste
* Convert Whitespace, Uncomment, Comment, Indent, Unindent
* Line Break, Insert
* Next Marker, Previous Marker, Clear All Markers, Mark All
* Select Line, Select All
* Jump, Move, Move Select, Delete, Toggle Overwrite
* Scroll, Scroll Bar, Set Cursor, Line Number
* Find and Replace, Find, Replace, Find Set Selected,
Replace Set Selected
* To 3D Object
* Resolve Conflict
2009-02-28 23:33:35 +00:00
|
|
|
struct Text *CTX_data_edit_text(const bContext *C)
|
|
|
|
{
|
2009-03-19 19:03:38 +00:00
|
|
|
return ctx_data_pointer_get(C, "edit_text");
|
2.5: Text Editor back.
There was very little structure in this code, using many globals
and duplicated code. Now it should be better structured. Most
things should work, the main parts that are not back yet are the
python plugins and markers. Notes:
* Blenfont is used for drawing the text, nicely anti-aliased.
* A monospace truetype font was added, since that is needed for
the text editor. It's Bitstream Vera Sans Mono. This is the
default gnome terminal font, but it doesn't fit entirely well
with the other font I think, can be changed easily of course.
* Clipboard copy/cut/paste now always uses the system clipboard,
the code for the own cut buffer was removed.
* The interface buttons should support copy/cut/paste again now
as well.
* WM_clipboard_text_get/WM_clipboard_text_set were added to the
windowmanager code.
* Find panel is now a kind of second header, instead of a panel.
This needs especially a way to start editing the text field
immediately on open still.
* Operators are independent of the actual space when possible,
was a bit of puzzling but got it solved nice with notifiers,
and some lazy init for syntax highlight in the drawing code.
* RNA was created for the text editor space and used for buttons.
* Operators:
* New, Open, Reload, Save, Save As, Make Internal
* Run Script, Refresh Pyconstraints
* Copy, Cut, Paste
* Convert Whitespace, Uncomment, Comment, Indent, Unindent
* Line Break, Insert
* Next Marker, Previous Marker, Clear All Markers, Mark All
* Select Line, Select All
* Jump, Move, Move Select, Delete, Toggle Overwrite
* Scroll, Scroll Bar, Set Cursor, Line Number
* Find and Replace, Find, Replace, Find Set Selected,
Replace Set Selected
* To 3D Object
* Resolve Conflict
2009-02-28 23:33:35 +00:00
|
|
|
}
|
|
|
|
|
2009-02-05 03:28:07 +00:00
|
|
|
struct EditBone *CTX_data_active_bone(const bContext *C)
|
|
|
|
{
|
2009-03-19 19:03:38 +00:00
|
|
|
return ctx_data_pointer_get(C, "active_bone");
|
2009-02-05 03:28:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int CTX_data_selected_bones(const bContext *C, ListBase *list)
|
|
|
|
{
|
2009-03-19 19:03:38 +00:00
|
|
|
return ctx_data_collection_get(C, "selected_bones", list);
|
2009-02-05 03:28:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int CTX_data_selected_editable_bones(const bContext *C, ListBase *list)
|
|
|
|
{
|
2009-03-19 19:03:38 +00:00
|
|
|
return ctx_data_collection_get(C, "selected_editable_bones", list);
|
2009-02-05 03:28:07 +00:00
|
|
|
}
|
|
|
|
|
2009-02-14 07:27:12 +00:00
|
|
|
int CTX_data_visible_bones(const bContext *C, ListBase *list)
|
|
|
|
{
|
2009-03-19 19:03:38 +00:00
|
|
|
return ctx_data_collection_get(C, "visible_bones", list);
|
2009-02-14 07:27:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int CTX_data_editable_bones(const bContext *C, ListBase *list)
|
|
|
|
{
|
2009-03-19 19:03:38 +00:00
|
|
|
return ctx_data_collection_get(C, "editable_bones", list);
|
2009-02-14 07:27:12 +00:00
|
|
|
}
|
|
|
|
|
2009-02-05 03:28:07 +00:00
|
|
|
struct bPoseChannel *CTX_data_active_pchan(const bContext *C)
|
|
|
|
{
|
2009-03-19 19:03:38 +00:00
|
|
|
return ctx_data_pointer_get(C, "active_pchan");
|
2009-02-05 03:28:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int CTX_data_selected_pchans(const bContext *C, ListBase *list)
|
|
|
|
{
|
2009-03-19 19:03:38 +00:00
|
|
|
return ctx_data_collection_get(C, "selected_pchans", list);
|
2009-02-05 03:28:07 +00:00
|
|
|
}
|
|
|
|
|
2009-02-14 07:27:12 +00:00
|
|
|
int CTX_data_visible_pchans(const bContext *C, ListBase *list)
|
|
|
|
{
|
2009-03-19 19:03:38 +00:00
|
|
|
return ctx_data_collection_get(C, "visible_pchans", list);
|
2009-02-14 07:27:12 +00:00
|
|
|
}
|
|
|
|
|