2011-02-23 10:52:22 +00:00
/*
2010-03-21 01:14:04 +00:00
* $ Id $
2007-12-24 18:27:28 +00:00
*
* * * * * * 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 ,
2010-02-12 13:34:04 +00:00
* Inc . , 51 Franklin Street , Fifth Floor , Boston , MA 02110 - 1301 , USA .
2007-12-24 18:27:28 +00:00
*
* The Original Code is Copyright ( C ) 2007 Blender Foundation .
* All rights reserved .
*
*
* Contributor ( s ) : Blender Foundation
*
* * * * * * END GPL LICENSE BLOCK * * * * *
*/
2011-02-25 14:04:21 +00:00
/** \file blender/windowmanager/intern/wm_operators.c
* \ ingroup wm
*/
2009-01-24 16:59:55 +00:00
# include <float.h>
2007-12-24 18:27:28 +00:00
# include <string.h>
2009-07-17 12:26:40 +00:00
# include <ctype.h>
# include <stdio.h>
2010-08-13 15:26:37 +00:00
# include <stddef.h>
2010-10-31 14:43:30 +00:00
# include <assert.h>
2010-11-11 20:32:28 +00:00
2011-05-02 08:07:24 +00:00
# include "GHOST_C-api.h"
2007-12-24 18:27:28 +00:00
2011-01-07 18:36:47 +00:00
# include "MEM_guardedalloc.h"
2008-01-14 19:44:20 +00:00
# include "DNA_ID.h"
2009-09-14 10:56:40 +00:00
# include "DNA_object_types.h"
2.5: gesture code in WM
- Simplified and cleaned previous border code
It was a bit too complex, too many data manipulations
Original idea was to have WM API calls to manage border, circle, lines,
lasso, etc. This now means that WM provides callbacks for custom operators,
so it's very easy to make them. Check bottom of screen_edit.c for an
example.
Currently two borders were coded; with and without cross hair.
Press Bkey in any area-region to test it (note: time window has wrong matrix!)
Some specs to note:
- gestures are in region space, and draw 'over'. That latter still needs some
work when we do real composites.
- only the active region is redrawn.
- on todo is the generic gesture engine for 'tweak' or like how currently grab
gestures in Blender work. These will be configurable per area-region, and WM
then will send the proper "Gesture Event" with properties (N, S, E, W, etc)
to which you then can assign operators. Such events will be generated with low
priority, so other handlers who swallowed mouse events have preference.
2008-11-19 13:16:05 +00:00
# include "DNA_screen_types.h"
2009-05-19 15:37:50 +00:00
# include "DNA_scene_types.h"
2008-12-19 18:28:37 +00:00
# include "DNA_userdef_types.h"
2007-12-24 18:27:28 +00:00
# include "DNA_windowmanager_types.h"
2010-01-08 05:51:51 +00:00
# include "BLF_api.h"
2009-05-19 12:54:54 +00:00
# include "PIL_time.h"
2007-12-24 18:27:28 +00:00
# include "BLI_blenlib.h"
2008-12-26 03:56:52 +00:00
# include "BLI_dynstr.h" /*for WM_operator_pystring */
2010-01-26 11:25:39 +00:00
# include "BLI_math.h"
2011-01-07 18:36:47 +00:00
# include "BLI_utildefines.h"
2007-12-24 18:27:28 +00:00
2009-09-12 19:54:39 +00:00
# include "BLO_readfile.h"
2007-12-24 18:27:28 +00:00
# include "BKE_blender.h"
2011-05-12 01:57:47 +00:00
# include "BKE_brush.h"
2008-12-18 02:56:48 +00:00
# include "BKE_context.h"
2009-09-12 19:54:39 +00:00
# include "BKE_depsgraph.h"
2.5: work on bringing back SpaceTime options
- RMB select, also with SHIFT
- RMB tweak for translate
- SHIFT+D dupli
- BKEY border select/deselect
- AKEY (de)select all
- XKEY delete
- GKEY grab
Added some XXX comments for future todos, especially for when other
spaces come back with time markers.
Also added ED_util for putting in all to-be-cleaned cruft
Context conflict: input methods for Markers can conflict with other
spacetypes. It was solved in pre-2.5 with manually tweaking it all over,
but I would prefer one keymap for all marker stuff. Needs some thinking...
could be solved with a boundbox check for bottom part of 2d window.
Tweak issue: both tweak styles are possible:
- Hold mouse button, move, operator ends on mouse release
- Hold mouse button, move, operator ends on mouse click
Problem is that modally handled operators use fixed keymaps... like ESC,
SPACE, ENTER, or press/release mousebutton for 'assign'. There's a lot
to say for making this all consistant, or become part of 1 general keymap?
Should also be possibe to define 'tweak' defaults for Tablet different
than for mouse...
2008-11-29 15:10:31 +00:00
# include "BKE_idprop.h"
2007-12-24 18:27:28 +00:00
# include "BKE_library.h"
2008-12-19 18:28:37 +00:00
# include "BKE_global.h"
2007-12-24 18:27:28 +00:00
# include "BKE_main.h"
2009-09-12 19:54:39 +00:00
# include "BKE_report.h"
2009-05-19 15:37:50 +00:00
# include "BKE_scene.h"
2009-10-06 13:04:31 +00:00
# include "BKE_screen.h" /* BKE_ST_MAXNAME */
2011-01-07 19:18:31 +00:00
2010-08-10 15:14:19 +00:00
# include "BKE_idcode.h"
2007-12-24 18:27:28 +00:00
2009-01-24 16:59:55 +00:00
# include "BIF_gl.h"
# include "BIF_glutil.h" /* for paint cursor */
2009-05-19 12:54:54 +00:00
2009-01-24 22:58:22 +00:00
# include "IMB_imbuf_types.h"
2009-01-24 16:59:55 +00:00
2009-01-06 14:42:54 +00:00
# include "ED_screen.h"
2009-04-01 14:02:06 +00:00
# include "ED_util.h"
2009-01-06 14:42:54 +00:00
2008-11-21 19:14:38 +00:00
# include "RNA_access.h"
# include "RNA_define.h"
2011-02-13 14:16:36 +00:00
# include "RNA_enum_types.h"
2008-11-21 19:14:38 +00:00
2008-12-15 19:19:39 +00:00
# include "UI_interface.h"
2008-12-17 15:38:40 +00:00
# include "UI_resources.h"
2008-12-15 19:19:39 +00:00
2007-12-24 18:27:28 +00:00
# include "WM_api.h"
# include "WM_types.h"
2.5: gesture code in WM
- Simplified and cleaned previous border code
It was a bit too complex, too many data manipulations
Original idea was to have WM API calls to manage border, circle, lines,
lasso, etc. This now means that WM provides callbacks for custom operators,
so it's very easy to make them. Check bottom of screen_edit.c for an
example.
Currently two borders were coded; with and without cross hair.
Press Bkey in any area-region to test it (note: time window has wrong matrix!)
Some specs to note:
- gestures are in region space, and draw 'over'. That latter still needs some
work when we do real composites.
- only the active region is redrawn.
- on todo is the generic gesture engine for 'tweak' or like how currently grab
gestures in Blender work. These will be configurable per area-region, and WM
then will send the proper "Gesture Event" with properties (N, S, E, W, etc)
to which you then can assign operators. Such events will be generated with low
priority, so other handlers who swallowed mouse events have preference.
2008-11-19 13:16:05 +00:00
2008-11-24 10:45:36 +00:00
# include "wm.h"
2009-05-19 12:54:54 +00:00
# include "wm_draw.h"
2007-12-24 18:27:28 +00:00
# include "wm_event_system.h"
2009-11-05 17:32:06 +00:00
# include "wm_event_types.h"
2009-05-19 12:54:54 +00:00
# include "wm_subwindow.h"
# include "wm_window.h"
2007-12-24 18:27:28 +00:00
static ListBase global_ops = { NULL , NULL } ;
/* ************ operator API, exported ********** */
2009-07-17 12:26:40 +00:00
2009-07-13 08:33:51 +00:00
wmOperatorType * WM_operatortype_find ( const char * idname , int quiet )
2007-12-24 18:27:28 +00:00
{
wmOperatorType * ot ;
2009-07-17 12:26:40 +00:00
char idname_bl [ OP_MAX_TYPENAME ] ; // XXX, needed to support python style names without the _OT_ syntax
WM_operator_bl_idname ( idname_bl , idname ) ;
2010-08-13 06:30:04 +00:00
2009-09-08 02:09:14 +00:00
if ( idname_bl [ 0 ] ) {
2010-08-13 14:42:45 +00:00
ot = ( wmOperatorType * ) BLI_findstring_ptr ( & global_ops , idname_bl , offsetof ( wmOperatorType , idname ) ) ;
2010-08-13 06:30:04 +00:00
if ( ot ) {
return ot ;
2009-09-08 02:09:14 +00:00
}
2007-12-24 18:27:28 +00:00
}
2009-07-13 08:33:51 +00:00
if ( ! quiet )
2009-07-17 12:26:40 +00:00
printf ( " search for unknown operator %s, %s \n " , idname_bl , idname ) ;
2009-07-13 08:33:51 +00:00
2007-12-24 18:27:28 +00:00
return NULL ;
}
2008-12-21 08:53:36 +00:00
wmOperatorType * WM_operatortype_first ( void )
{
return global_ops . first ;
}
2008-01-07 18:03:41 +00:00
/* all ops in 1 list (for time being... needs evaluation later) */
2.5 Branch
==========
* Changed wmOperatorType, removing init/exit callbacks and adding cancel
callback, removed default storage in favor of properties. Defined return
values for exec/invoke/modal/cancel.
* Don't allocate operator on the stack, and removed operator copy for
handlers. Now it frees based on return values from callbacks, and just
keeps a wmOperator on the heap. Also it now registers after the operator
is fully finished, to get the correct final properties.
* Changed OP_get_* functions to return 1 if the property is found and 0
otherwise, gives more readable code in my opinion. Added OP_verify_*
functions to quickly check if the property is available and set if it's
not, that's common for exec/invoke.
* Removed WM_operatortypelist_append in favor of WM_operatortype_append
which takes a function pointer instead of a list, avoids macro's and
duplicating code.
* Fix a crash where the handler would still be used while it was freed by
the operator.
* Spacetypes now have operatortypes() and keymap() callbacks to abstract
them a bit more.
* Renamed C->curarea to C->area for consistency. Removed View3D/View2D/
SpaceIpo from bContext, seems bad to keep these.
* Set context variables like window/screen/area/region to NULL again when
leaving that context, instead of leaving the pointers there.
* Added if(G.f & G_DEBUG) for many of the prints, makes output a bit
cleaner and easier to debug.
* Fixed priority of the editors/interface module in scons, would otherwise
give link errors.
* Added start of generic view2d api.
* Added space_time with some basic drawing and a single operator to change
the frame.
2008-06-11 10:10:31 +00:00
void WM_operatortype_append ( void ( * opfunc ) ( wmOperatorType * ) )
2008-01-07 18:03:41 +00:00
{
2.5 Branch
==========
* Changed wmOperatorType, removing init/exit callbacks and adding cancel
callback, removed default storage in favor of properties. Defined return
values for exec/invoke/modal/cancel.
* Don't allocate operator on the stack, and removed operator copy for
handlers. Now it frees based on return values from callbacks, and just
keeps a wmOperator on the heap. Also it now registers after the operator
is fully finished, to get the correct final properties.
* Changed OP_get_* functions to return 1 if the property is found and 0
otherwise, gives more readable code in my opinion. Added OP_verify_*
functions to quickly check if the property is available and set if it's
not, that's common for exec/invoke.
* Removed WM_operatortypelist_append in favor of WM_operatortype_append
which takes a function pointer instead of a list, avoids macro's and
duplicating code.
* Fix a crash where the handler would still be used while it was freed by
the operator.
* Spacetypes now have operatortypes() and keymap() callbacks to abstract
them a bit more.
* Renamed C->curarea to C->area for consistency. Removed View3D/View2D/
SpaceIpo from bContext, seems bad to keep these.
* Set context variables like window/screen/area/region to NULL again when
leaving that context, instead of leaving the pointers there.
* Added if(G.f & G_DEBUG) for many of the prints, makes output a bit
cleaner and easier to debug.
* Fixed priority of the editors/interface module in scons, would otherwise
give link errors.
* Added start of generic view2d api.
* Added space_time with some basic drawing and a single operator to change
the frame.
2008-06-11 10:10:31 +00:00
wmOperatorType * ot ;
ot = MEM_callocN ( sizeof ( wmOperatorType ) , " operatortype " ) ;
2008-12-19 04:06:24 +00:00
ot - > srna = RNA_def_struct ( & BLENDER_RNA , " " , " OperatorProperties " ) ;
2.5 Branch
==========
* Changed wmOperatorType, removing init/exit callbacks and adding cancel
callback, removed default storage in favor of properties. Defined return
values for exec/invoke/modal/cancel.
* Don't allocate operator on the stack, and removed operator copy for
handlers. Now it frees based on return values from callbacks, and just
keeps a wmOperator on the heap. Also it now registers after the operator
is fully finished, to get the correct final properties.
* Changed OP_get_* functions to return 1 if the property is found and 0
otherwise, gives more readable code in my opinion. Added OP_verify_*
functions to quickly check if the property is available and set if it's
not, that's common for exec/invoke.
* Removed WM_operatortypelist_append in favor of WM_operatortype_append
which takes a function pointer instead of a list, avoids macro's and
duplicating code.
* Fix a crash where the handler would still be used while it was freed by
the operator.
* Spacetypes now have operatortypes() and keymap() callbacks to abstract
them a bit more.
* Renamed C->curarea to C->area for consistency. Removed View3D/View2D/
SpaceIpo from bContext, seems bad to keep these.
* Set context variables like window/screen/area/region to NULL again when
leaving that context, instead of leaving the pointers there.
* Added if(G.f & G_DEBUG) for many of the prints, makes output a bit
cleaner and easier to debug.
* Fixed priority of the editors/interface module in scons, would otherwise
give link errors.
* Added start of generic view2d api.
* Added space_time with some basic drawing and a single operator to change
the frame.
2008-06-11 10:10:31 +00:00
opfunc ( ot ) ;
2009-07-19 14:57:20 +00:00
if ( ot - > name = = NULL ) {
static char dummy_name [ ] = " Dummy Name " ;
fprintf ( stderr , " ERROR: Operator %s has no name property! \n " , ot - > idname ) ;
ot - > name = dummy_name ;
}
2009-07-26 18:18:14 +00:00
RNA_def_struct_ui_text ( ot - > srna , ot - > name , ot - > description ? ot - > description : " (undocumented operator) " ) ; // XXX All ops should have a description but for now allow them not to.
2008-12-19 04:06:24 +00:00
RNA_def_struct_identifier ( ot - > srna , ot - > idname ) ;
2.5 Branch
==========
* Changed wmOperatorType, removing init/exit callbacks and adding cancel
callback, removed default storage in favor of properties. Defined return
values for exec/invoke/modal/cancel.
* Don't allocate operator on the stack, and removed operator copy for
handlers. Now it frees based on return values from callbacks, and just
keeps a wmOperator on the heap. Also it now registers after the operator
is fully finished, to get the correct final properties.
* Changed OP_get_* functions to return 1 if the property is found and 0
otherwise, gives more readable code in my opinion. Added OP_verify_*
functions to quickly check if the property is available and set if it's
not, that's common for exec/invoke.
* Removed WM_operatortypelist_append in favor of WM_operatortype_append
which takes a function pointer instead of a list, avoids macro's and
duplicating code.
* Fix a crash where the handler would still be used while it was freed by
the operator.
* Spacetypes now have operatortypes() and keymap() callbacks to abstract
them a bit more.
* Renamed C->curarea to C->area for consistency. Removed View3D/View2D/
SpaceIpo from bContext, seems bad to keep these.
* Set context variables like window/screen/area/region to NULL again when
leaving that context, instead of leaving the pointers there.
* Added if(G.f & G_DEBUG) for many of the prints, makes output a bit
cleaner and easier to debug.
* Fixed priority of the editors/interface module in scons, would otherwise
give link errors.
* Added start of generic view2d api.
* Added space_time with some basic drawing and a single operator to change
the frame.
2008-06-11 10:10:31 +00:00
BLI_addtail ( & global_ops , ot ) ;
2008-01-07 18:03:41 +00:00
}
python operators (in bpy_opwrapper.*)
This means you can define an operator in python that is called from C or Python - like any other operator.
Python functions for invoke and exec can be registered with an operator name.
keywords are read from the python exec() function, then used to create operator properties. The default python values are used to set the property type and defaults.
def exec(size=2.0, text="blah"): ...
is equivalent to...
prop = RNA_def_property(ot->srna, "size", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_default(prop, 2.0f);
prop = RNA_def_property(ot->srna, "size", PROP_STRING, PROP_NONE);
RNA_def_property_string_default(prop, "blah");
TODO -
* make use of events
* return OPERATOR_CANCELLED/OPERATOR_FINISHED.. etc
* add support for array args
* more testing
2008-12-27 14:52:49 +00:00
void WM_operatortype_append_ptr ( void ( * opfunc ) ( wmOperatorType * , void * ) , void * userdata )
{
wmOperatorType * ot ;
ot = MEM_callocN ( sizeof ( wmOperatorType ) , " operatortype " ) ;
ot - > srna = RNA_def_struct ( & BLENDER_RNA , " " , " OperatorProperties " ) ;
opfunc ( ot , userdata ) ;
2009-07-26 18:18:14 +00:00
RNA_def_struct_ui_text ( ot - > srna , ot - > name , ot - > description ? ot - > description : " (undocumented operator) " ) ;
python operators (in bpy_opwrapper.*)
This means you can define an operator in python that is called from C or Python - like any other operator.
Python functions for invoke and exec can be registered with an operator name.
keywords are read from the python exec() function, then used to create operator properties. The default python values are used to set the property type and defaults.
def exec(size=2.0, text="blah"): ...
is equivalent to...
prop = RNA_def_property(ot->srna, "size", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_default(prop, 2.0f);
prop = RNA_def_property(ot->srna, "size", PROP_STRING, PROP_NONE);
RNA_def_property_string_default(prop, "blah");
TODO -
* make use of events
* return OPERATOR_CANCELLED/OPERATOR_FINISHED.. etc
* add support for array args
* more testing
2008-12-27 14:52:49 +00:00
RNA_def_struct_identifier ( ot - > srna , ot - > idname ) ;
BLI_addtail ( & global_ops , ot ) ;
}
2.5
Operator goodies!
--- Macro operators
Operators now can consist of multiple operators. Such a macro operator
is identical and behaves identical to other opererators. Macros can
also be constructed of macros even! Currently only hardcoded macros are
implemented, this to solve combined operators such as 'add duplicate' or
'extrude' (both want a transform appended).
Usage is simple:
- WM_operatortype_append_macro() : add new operatortype, name, flags
- WM_operatortype_macro_define() : add existing operator to macro
(Note: macro_define will also allow properties to be set, doesnt work
right now)
On converting the macro wmOperatorType to a real operator, it makes a
list of all operators, and the standard macro callbacks (exec, invoke,
modal, poll) just will use all.
Important note; switching to a modal operator only works as last in the
chain now!
Macros implemented for duplicate, extrude and rip. Tool menu works fine
for it, also the redo hotkey F4 works properly.
--- Operator redo fix
The operators use the undo system to switch back, but this could give
errors if other actions added undo pushes (buttons, outliner). Now the
redo for operator searches back for the correct undo level.
This fixes issues with many redos.
Note for brecht: removed the ED_undo_push for buttons... it was called
on *every* button now, which is probably too much? For example, using
the 'toolbar' redo also caused this...
2009-07-29 17:56:38 +00:00
/* ********************* macro operator ******************** */
2009-11-21 19:49:11 +00:00
typedef struct {
int retval ;
} MacroData ;
static void wm_macro_start ( wmOperator * op )
{
if ( op - > customdata = = NULL ) {
op - > customdata = MEM_callocN ( sizeof ( MacroData ) , " MacroData " ) ;
}
}
static int wm_macro_end ( wmOperator * op , int retval )
{
if ( retval & OPERATOR_CANCELLED ) {
MacroData * md = op - > customdata ;
if ( md - > retval & OPERATOR_FINISHED ) {
retval | = OPERATOR_FINISHED ;
retval & = ~ OPERATOR_CANCELLED ;
}
}
/* if modal is ending, free custom data */
if ( retval & ( OPERATOR_FINISHED | OPERATOR_CANCELLED ) ) {
if ( op - > customdata ) {
MEM_freeN ( op - > customdata ) ;
2010-01-04 20:18:13 +00:00
op - > customdata = NULL ;
2009-11-21 19:49:11 +00:00
}
}
return retval ;
}
2.5
Operator goodies!
--- Macro operators
Operators now can consist of multiple operators. Such a macro operator
is identical and behaves identical to other opererators. Macros can
also be constructed of macros even! Currently only hardcoded macros are
implemented, this to solve combined operators such as 'add duplicate' or
'extrude' (both want a transform appended).
Usage is simple:
- WM_operatortype_append_macro() : add new operatortype, name, flags
- WM_operatortype_macro_define() : add existing operator to macro
(Note: macro_define will also allow properties to be set, doesnt work
right now)
On converting the macro wmOperatorType to a real operator, it makes a
list of all operators, and the standard macro callbacks (exec, invoke,
modal, poll) just will use all.
Important note; switching to a modal operator only works as last in the
chain now!
Macros implemented for duplicate, extrude and rip. Tool menu works fine
for it, also the redo hotkey F4 works properly.
--- Operator redo fix
The operators use the undo system to switch back, but this could give
errors if other actions added undo pushes (buttons, outliner). Now the
redo for operator searches back for the correct undo level.
This fixes issues with many redos.
Note for brecht: removed the ED_undo_push for buttons... it was called
on *every* button now, which is probably too much? For example, using
the 'toolbar' redo also caused this...
2009-07-29 17:56:38 +00:00
/* macro exec only runs exec calls */
static int wm_macro_exec ( bContext * C , wmOperator * op )
{
wmOperator * opm ;
int retval = OPERATOR_FINISHED ;
2009-11-21 19:49:11 +00:00
wm_macro_start ( op ) ;
2.5
Operator goodies!
--- Macro operators
Operators now can consist of multiple operators. Such a macro operator
is identical and behaves identical to other opererators. Macros can
also be constructed of macros even! Currently only hardcoded macros are
implemented, this to solve combined operators such as 'add duplicate' or
'extrude' (both want a transform appended).
Usage is simple:
- WM_operatortype_append_macro() : add new operatortype, name, flags
- WM_operatortype_macro_define() : add existing operator to macro
(Note: macro_define will also allow properties to be set, doesnt work
right now)
On converting the macro wmOperatorType to a real operator, it makes a
list of all operators, and the standard macro callbacks (exec, invoke,
modal, poll) just will use all.
Important note; switching to a modal operator only works as last in the
chain now!
Macros implemented for duplicate, extrude and rip. Tool menu works fine
for it, also the redo hotkey F4 works properly.
--- Operator redo fix
The operators use the undo system to switch back, but this could give
errors if other actions added undo pushes (buttons, outliner). Now the
redo for operator searches back for the correct undo level.
This fixes issues with many redos.
Note for brecht: removed the ED_undo_push for buttons... it was called
on *every* button now, which is probably too much? For example, using
the 'toolbar' redo also caused this...
2009-07-29 17:56:38 +00:00
for ( opm = op - > macro . first ; opm ; opm = opm - > next ) {
if ( opm - > type - > exec ) {
retval = opm - > type - > exec ( C , opm ) ;
2009-11-21 19:49:11 +00:00
if ( retval & OPERATOR_FINISHED ) {
MacroData * md = op - > customdata ;
md - > retval = OPERATOR_FINISHED ; /* keep in mind that at least one operator finished */
} else {
break ; /* operator didn't finish, end macro */
}
2.5
Operator goodies!
--- Macro operators
Operators now can consist of multiple operators. Such a macro operator
is identical and behaves identical to other opererators. Macros can
also be constructed of macros even! Currently only hardcoded macros are
implemented, this to solve combined operators such as 'add duplicate' or
'extrude' (both want a transform appended).
Usage is simple:
- WM_operatortype_append_macro() : add new operatortype, name, flags
- WM_operatortype_macro_define() : add existing operator to macro
(Note: macro_define will also allow properties to be set, doesnt work
right now)
On converting the macro wmOperatorType to a real operator, it makes a
list of all operators, and the standard macro callbacks (exec, invoke,
modal, poll) just will use all.
Important note; switching to a modal operator only works as last in the
chain now!
Macros implemented for duplicate, extrude and rip. Tool menu works fine
for it, also the redo hotkey F4 works properly.
--- Operator redo fix
The operators use the undo system to switch back, but this could give
errors if other actions added undo pushes (buttons, outliner). Now the
redo for operator searches back for the correct undo level.
This fixes issues with many redos.
Note for brecht: removed the ED_undo_push for buttons... it was called
on *every* button now, which is probably too much? For example, using
the 'toolbar' redo also caused this...
2009-07-29 17:56:38 +00:00
}
}
2009-11-21 19:49:11 +00:00
return wm_macro_end ( op , retval ) ;
2.5
Operator goodies!
--- Macro operators
Operators now can consist of multiple operators. Such a macro operator
is identical and behaves identical to other opererators. Macros can
also be constructed of macros even! Currently only hardcoded macros are
implemented, this to solve combined operators such as 'add duplicate' or
'extrude' (both want a transform appended).
Usage is simple:
- WM_operatortype_append_macro() : add new operatortype, name, flags
- WM_operatortype_macro_define() : add existing operator to macro
(Note: macro_define will also allow properties to be set, doesnt work
right now)
On converting the macro wmOperatorType to a real operator, it makes a
list of all operators, and the standard macro callbacks (exec, invoke,
modal, poll) just will use all.
Important note; switching to a modal operator only works as last in the
chain now!
Macros implemented for duplicate, extrude and rip. Tool menu works fine
for it, also the redo hotkey F4 works properly.
--- Operator redo fix
The operators use the undo system to switch back, but this could give
errors if other actions added undo pushes (buttons, outliner). Now the
redo for operator searches back for the correct undo level.
This fixes issues with many redos.
Note for brecht: removed the ED_undo_push for buttons... it was called
on *every* button now, which is probably too much? For example, using
the 'toolbar' redo also caused this...
2009-07-29 17:56:38 +00:00
}
2011-02-13 14:16:36 +00:00
static int wm_macro_invoke_internal ( bContext * C , wmOperator * op , wmEvent * event , wmOperator * opm )
2.5
Operator goodies!
--- Macro operators
Operators now can consist of multiple operators. Such a macro operator
is identical and behaves identical to other opererators. Macros can
also be constructed of macros even! Currently only hardcoded macros are
implemented, this to solve combined operators such as 'add duplicate' or
'extrude' (both want a transform appended).
Usage is simple:
- WM_operatortype_append_macro() : add new operatortype, name, flags
- WM_operatortype_macro_define() : add existing operator to macro
(Note: macro_define will also allow properties to be set, doesnt work
right now)
On converting the macro wmOperatorType to a real operator, it makes a
list of all operators, and the standard macro callbacks (exec, invoke,
modal, poll) just will use all.
Important note; switching to a modal operator only works as last in the
chain now!
Macros implemented for duplicate, extrude and rip. Tool menu works fine
for it, also the redo hotkey F4 works properly.
--- Operator redo fix
The operators use the undo system to switch back, but this could give
errors if other actions added undo pushes (buttons, outliner). Now the
redo for operator searches back for the correct undo level.
This fixes issues with many redos.
Note for brecht: removed the ED_undo_push for buttons... it was called
on *every* button now, which is probably too much? For example, using
the 'toolbar' redo also caused this...
2009-07-29 17:56:38 +00:00
{
int retval = OPERATOR_FINISHED ;
2009-11-17 22:19:48 +00:00
/* start from operator received as argument */
for ( ; opm ; opm = opm - > next ) {
2.5
Operator goodies!
--- Macro operators
Operators now can consist of multiple operators. Such a macro operator
is identical and behaves identical to other opererators. Macros can
also be constructed of macros even! Currently only hardcoded macros are
implemented, this to solve combined operators such as 'add duplicate' or
'extrude' (both want a transform appended).
Usage is simple:
- WM_operatortype_append_macro() : add new operatortype, name, flags
- WM_operatortype_macro_define() : add existing operator to macro
(Note: macro_define will also allow properties to be set, doesnt work
right now)
On converting the macro wmOperatorType to a real operator, it makes a
list of all operators, and the standard macro callbacks (exec, invoke,
modal, poll) just will use all.
Important note; switching to a modal operator only works as last in the
chain now!
Macros implemented for duplicate, extrude and rip. Tool menu works fine
for it, also the redo hotkey F4 works properly.
--- Operator redo fix
The operators use the undo system to switch back, but this could give
errors if other actions added undo pushes (buttons, outliner). Now the
redo for operator searches back for the correct undo level.
This fixes issues with many redos.
Note for brecht: removed the ED_undo_push for buttons... it was called
on *every* button now, which is probably too much? For example, using
the 'toolbar' redo also caused this...
2009-07-29 17:56:38 +00:00
if ( opm - > type - > invoke )
retval = opm - > type - > invoke ( C , opm , event ) ;
else if ( opm - > type - > exec )
retval = opm - > type - > exec ( C , opm ) ;
2009-11-17 22:19:48 +00:00
2010-12-21 14:49:34 +00:00
BLI_movelisttolist ( & op - > reports - > list , & opm - > reports - > list ) ;
2010-12-21 14:08:58 +00:00
2009-11-21 19:49:11 +00:00
if ( retval & OPERATOR_FINISHED ) {
MacroData * md = op - > customdata ;
md - > retval = OPERATOR_FINISHED ; /* keep in mind that at least one operator finished */
} else {
break ; /* operator didn't finish, end macro */
}
2.5
Operator goodies!
--- Macro operators
Operators now can consist of multiple operators. Such a macro operator
is identical and behaves identical to other opererators. Macros can
also be constructed of macros even! Currently only hardcoded macros are
implemented, this to solve combined operators such as 'add duplicate' or
'extrude' (both want a transform appended).
Usage is simple:
- WM_operatortype_append_macro() : add new operatortype, name, flags
- WM_operatortype_macro_define() : add existing operator to macro
(Note: macro_define will also allow properties to be set, doesnt work
right now)
On converting the macro wmOperatorType to a real operator, it makes a
list of all operators, and the standard macro callbacks (exec, invoke,
modal, poll) just will use all.
Important note; switching to a modal operator only works as last in the
chain now!
Macros implemented for duplicate, extrude and rip. Tool menu works fine
for it, also the redo hotkey F4 works properly.
--- Operator redo fix
The operators use the undo system to switch back, but this could give
errors if other actions added undo pushes (buttons, outliner). Now the
redo for operator searches back for the correct undo level.
This fixes issues with many redos.
Note for brecht: removed the ED_undo_push for buttons... it was called
on *every* button now, which is probably too much? For example, using
the 'toolbar' redo also caused this...
2009-07-29 17:56:38 +00:00
}
2009-11-17 22:19:48 +00:00
2009-11-21 19:49:11 +00:00
return wm_macro_end ( op , retval ) ;
2.5
Operator goodies!
--- Macro operators
Operators now can consist of multiple operators. Such a macro operator
is identical and behaves identical to other opererators. Macros can
also be constructed of macros even! Currently only hardcoded macros are
implemented, this to solve combined operators such as 'add duplicate' or
'extrude' (both want a transform appended).
Usage is simple:
- WM_operatortype_append_macro() : add new operatortype, name, flags
- WM_operatortype_macro_define() : add existing operator to macro
(Note: macro_define will also allow properties to be set, doesnt work
right now)
On converting the macro wmOperatorType to a real operator, it makes a
list of all operators, and the standard macro callbacks (exec, invoke,
modal, poll) just will use all.
Important note; switching to a modal operator only works as last in the
chain now!
Macros implemented for duplicate, extrude and rip. Tool menu works fine
for it, also the redo hotkey F4 works properly.
--- Operator redo fix
The operators use the undo system to switch back, but this could give
errors if other actions added undo pushes (buttons, outliner). Now the
redo for operator searches back for the correct undo level.
This fixes issues with many redos.
Note for brecht: removed the ED_undo_push for buttons... it was called
on *every* button now, which is probably too much? For example, using
the 'toolbar' redo also caused this...
2009-07-29 17:56:38 +00:00
}
2009-11-17 22:19:48 +00:00
static int wm_macro_invoke ( bContext * C , wmOperator * op , wmEvent * event )
{
2009-11-21 19:49:11 +00:00
wm_macro_start ( op ) ;
2009-11-17 22:19:48 +00:00
return wm_macro_invoke_internal ( C , op , event , op - > macro . first ) ;
}
2.5
Operator goodies!
--- Macro operators
Operators now can consist of multiple operators. Such a macro operator
is identical and behaves identical to other opererators. Macros can
also be constructed of macros even! Currently only hardcoded macros are
implemented, this to solve combined operators such as 'add duplicate' or
'extrude' (both want a transform appended).
Usage is simple:
- WM_operatortype_append_macro() : add new operatortype, name, flags
- WM_operatortype_macro_define() : add existing operator to macro
(Note: macro_define will also allow properties to be set, doesnt work
right now)
On converting the macro wmOperatorType to a real operator, it makes a
list of all operators, and the standard macro callbacks (exec, invoke,
modal, poll) just will use all.
Important note; switching to a modal operator only works as last in the
chain now!
Macros implemented for duplicate, extrude and rip. Tool menu works fine
for it, also the redo hotkey F4 works properly.
--- Operator redo fix
The operators use the undo system to switch back, but this could give
errors if other actions added undo pushes (buttons, outliner). Now the
redo for operator searches back for the correct undo level.
This fixes issues with many redos.
Note for brecht: removed the ED_undo_push for buttons... it was called
on *every* button now, which is probably too much? For example, using
the 'toolbar' redo also caused this...
2009-07-29 17:56:38 +00:00
static int wm_macro_modal ( bContext * C , wmOperator * op , wmEvent * event )
{
2009-11-17 22:19:48 +00:00
wmOperator * opm = op - > opm ;
int retval = OPERATOR_FINISHED ;
2.5
Operator goodies!
--- Macro operators
Operators now can consist of multiple operators. Such a macro operator
is identical and behaves identical to other opererators. Macros can
also be constructed of macros even! Currently only hardcoded macros are
implemented, this to solve combined operators such as 'add duplicate' or
'extrude' (both want a transform appended).
Usage is simple:
- WM_operatortype_append_macro() : add new operatortype, name, flags
- WM_operatortype_macro_define() : add existing operator to macro
(Note: macro_define will also allow properties to be set, doesnt work
right now)
On converting the macro wmOperatorType to a real operator, it makes a
list of all operators, and the standard macro callbacks (exec, invoke,
modal, poll) just will use all.
Important note; switching to a modal operator only works as last in the
chain now!
Macros implemented for duplicate, extrude and rip. Tool menu works fine
for it, also the redo hotkey F4 works properly.
--- Operator redo fix
The operators use the undo system to switch back, but this could give
errors if other actions added undo pushes (buttons, outliner). Now the
redo for operator searches back for the correct undo level.
This fixes issues with many redos.
Note for brecht: removed the ED_undo_push for buttons... it was called
on *every* button now, which is probably too much? For example, using
the 'toolbar' redo also caused this...
2009-07-29 17:56:38 +00:00
2009-11-17 22:19:48 +00:00
if ( opm = = NULL )
2.5
Operator goodies!
--- Macro operators
Operators now can consist of multiple operators. Such a macro operator
is identical and behaves identical to other opererators. Macros can
also be constructed of macros even! Currently only hardcoded macros are
implemented, this to solve combined operators such as 'add duplicate' or
'extrude' (both want a transform appended).
Usage is simple:
- WM_operatortype_append_macro() : add new operatortype, name, flags
- WM_operatortype_macro_define() : add existing operator to macro
(Note: macro_define will also allow properties to be set, doesnt work
right now)
On converting the macro wmOperatorType to a real operator, it makes a
list of all operators, and the standard macro callbacks (exec, invoke,
modal, poll) just will use all.
Important note; switching to a modal operator only works as last in the
chain now!
Macros implemented for duplicate, extrude and rip. Tool menu works fine
for it, also the redo hotkey F4 works properly.
--- Operator redo fix
The operators use the undo system to switch back, but this could give
errors if other actions added undo pushes (buttons, outliner). Now the
redo for operator searches back for the correct undo level.
This fixes issues with many redos.
Note for brecht: removed the ED_undo_push for buttons... it was called
on *every* button now, which is probably too much? For example, using
the 'toolbar' redo also caused this...
2009-07-29 17:56:38 +00:00
printf ( " macro error, calling NULL modal() \n " ) ;
else {
2009-11-17 22:19:48 +00:00
retval = opm - > type - > modal ( C , opm , event ) ;
/* if this one is done but it's not the last operator in the macro */
if ( ( retval & OPERATOR_FINISHED ) & & opm - > next ) {
2009-11-21 19:49:11 +00:00
MacroData * md = op - > customdata ;
md - > retval = OPERATOR_FINISHED ; /* keep in mind that at least one operator finished */
2011-05-04 20:42:34 +00:00
retval = wm_macro_invoke_internal ( C , op , event , opm - > next ) ;
/* if new operator is modal and also added its own handler */
if ( retval & OPERATOR_RUNNING_MODAL & & op - > opm ! = opm ) {
wmWindow * win = CTX_wm_window ( C ) ;
wmEventHandler * handler = NULL ;
for ( handler = win - > modalhandlers . first ; handler ; handler = handler - > next ) {
/* first handler in list is the new one */
if ( handler - > op = = op )
break ;
}
if ( handler ) {
BLI_remlink ( & win - > modalhandlers , handler ) ;
wm_event_free_handler ( handler ) ;
}
/* if operator is blocking, grab cursor
* This may end up grabbing twice , but we don ' t care .
* */
if ( op - > opm - > type - > flag & OPTYPE_BLOCKING ) {
int bounds [ 4 ] = { - 1 , - 1 , - 1 , - 1 } ;
int wrap = ( U . uiflag & USER_CONTINUOUS_MOUSE ) & & ( ( op - > opm - > flag & OP_GRAB_POINTER ) | | ( op - > opm - > type - > flag & OPTYPE_GRAB_POINTER ) ) ;
if ( wrap ) {
ARegion * ar = CTX_wm_region ( C ) ;
if ( ar ) {
bounds [ 0 ] = ar - > winrct . xmin ;
bounds [ 1 ] = ar - > winrct . ymax ;
bounds [ 2 ] = ar - > winrct . xmax ;
bounds [ 3 ] = ar - > winrct . ymin ;
2009-11-19 19:27:10 +00:00
}
}
2011-05-04 20:42:34 +00:00
WM_cursor_grab ( CTX_wm_window ( C ) , wrap , FALSE , bounds ) ;
2009-11-19 19:27:10 +00:00
}
2009-11-17 22:19:48 +00:00
}
}
2009-11-21 19:49:11 +00:00
}
return wm_macro_end ( op , retval ) ;
}
static int wm_macro_cancel ( bContext * C , wmOperator * op )
{
/* call cancel on the current modal operator, if any */
if ( op - > opm & & op - > opm - > type - > cancel ) {
op - > opm - > type - > cancel ( C , op - > opm ) ;
}
return wm_macro_end ( op , OPERATOR_CANCELLED ) ;
2.5
Operator goodies!
--- Macro operators
Operators now can consist of multiple operators. Such a macro operator
is identical and behaves identical to other opererators. Macros can
also be constructed of macros even! Currently only hardcoded macros are
implemented, this to solve combined operators such as 'add duplicate' or
'extrude' (both want a transform appended).
Usage is simple:
- WM_operatortype_append_macro() : add new operatortype, name, flags
- WM_operatortype_macro_define() : add existing operator to macro
(Note: macro_define will also allow properties to be set, doesnt work
right now)
On converting the macro wmOperatorType to a real operator, it makes a
list of all operators, and the standard macro callbacks (exec, invoke,
modal, poll) just will use all.
Important note; switching to a modal operator only works as last in the
chain now!
Macros implemented for duplicate, extrude and rip. Tool menu works fine
for it, also the redo hotkey F4 works properly.
--- Operator redo fix
The operators use the undo system to switch back, but this could give
errors if other actions added undo pushes (buttons, outliner). Now the
redo for operator searches back for the correct undo level.
This fixes issues with many redos.
Note for brecht: removed the ED_undo_push for buttons... it was called
on *every* button now, which is probably too much? For example, using
the 'toolbar' redo also caused this...
2009-07-29 17:56:38 +00:00
}
/* Names have to be static for now */
2010-11-17 09:45:45 +00:00
wmOperatorType * WM_operatortype_append_macro ( const char * idname , const char * name , int flag )
2.5
Operator goodies!
--- Macro operators
Operators now can consist of multiple operators. Such a macro operator
is identical and behaves identical to other opererators. Macros can
also be constructed of macros even! Currently only hardcoded macros are
implemented, this to solve combined operators such as 'add duplicate' or
'extrude' (both want a transform appended).
Usage is simple:
- WM_operatortype_append_macro() : add new operatortype, name, flags
- WM_operatortype_macro_define() : add existing operator to macro
(Note: macro_define will also allow properties to be set, doesnt work
right now)
On converting the macro wmOperatorType to a real operator, it makes a
list of all operators, and the standard macro callbacks (exec, invoke,
modal, poll) just will use all.
Important note; switching to a modal operator only works as last in the
chain now!
Macros implemented for duplicate, extrude and rip. Tool menu works fine
for it, also the redo hotkey F4 works properly.
--- Operator redo fix
The operators use the undo system to switch back, but this could give
errors if other actions added undo pushes (buttons, outliner). Now the
redo for operator searches back for the correct undo level.
This fixes issues with many redos.
Note for brecht: removed the ED_undo_push for buttons... it was called
on *every* button now, which is probably too much? For example, using
the 'toolbar' redo also caused this...
2009-07-29 17:56:38 +00:00
{
wmOperatorType * ot ;
2010-08-13 14:42:45 +00:00
if ( WM_operatortype_find ( idname , TRUE ) ) {
2.5
Operator goodies!
--- Macro operators
Operators now can consist of multiple operators. Such a macro operator
is identical and behaves identical to other opererators. Macros can
also be constructed of macros even! Currently only hardcoded macros are
implemented, this to solve combined operators such as 'add duplicate' or
'extrude' (both want a transform appended).
Usage is simple:
- WM_operatortype_append_macro() : add new operatortype, name, flags
- WM_operatortype_macro_define() : add existing operator to macro
(Note: macro_define will also allow properties to be set, doesnt work
right now)
On converting the macro wmOperatorType to a real operator, it makes a
list of all operators, and the standard macro callbacks (exec, invoke,
modal, poll) just will use all.
Important note; switching to a modal operator only works as last in the
chain now!
Macros implemented for duplicate, extrude and rip. Tool menu works fine
for it, also the redo hotkey F4 works properly.
--- Operator redo fix
The operators use the undo system to switch back, but this could give
errors if other actions added undo pushes (buttons, outliner). Now the
redo for operator searches back for the correct undo level.
This fixes issues with many redos.
Note for brecht: removed the ED_undo_push for buttons... it was called
on *every* button now, which is probably too much? For example, using
the 'toolbar' redo also caused this...
2009-07-29 17:56:38 +00:00
printf ( " Macro error: operator %s exists \n " , idname ) ;
return NULL ;
}
ot = MEM_callocN ( sizeof ( wmOperatorType ) , " operatortype " ) ;
ot - > srna = RNA_def_struct ( & BLENDER_RNA , " " , " OperatorProperties " ) ;
ot - > idname = idname ;
ot - > name = name ;
2009-09-14 12:30:49 +00:00
ot - > flag = OPTYPE_MACRO | flag ;
2.5
Operator goodies!
--- Macro operators
Operators now can consist of multiple operators. Such a macro operator
is identical and behaves identical to other opererators. Macros can
also be constructed of macros even! Currently only hardcoded macros are
implemented, this to solve combined operators such as 'add duplicate' or
'extrude' (both want a transform appended).
Usage is simple:
- WM_operatortype_append_macro() : add new operatortype, name, flags
- WM_operatortype_macro_define() : add existing operator to macro
(Note: macro_define will also allow properties to be set, doesnt work
right now)
On converting the macro wmOperatorType to a real operator, it makes a
list of all operators, and the standard macro callbacks (exec, invoke,
modal, poll) just will use all.
Important note; switching to a modal operator only works as last in the
chain now!
Macros implemented for duplicate, extrude and rip. Tool menu works fine
for it, also the redo hotkey F4 works properly.
--- Operator redo fix
The operators use the undo system to switch back, but this could give
errors if other actions added undo pushes (buttons, outliner). Now the
redo for operator searches back for the correct undo level.
This fixes issues with many redos.
Note for brecht: removed the ED_undo_push for buttons... it was called
on *every* button now, which is probably too much? For example, using
the 'toolbar' redo also caused this...
2009-07-29 17:56:38 +00:00
ot - > exec = wm_macro_exec ;
ot - > invoke = wm_macro_invoke ;
ot - > modal = wm_macro_modal ;
2009-11-21 19:49:11 +00:00
ot - > cancel = wm_macro_cancel ;
2.5
Operator goodies!
--- Macro operators
Operators now can consist of multiple operators. Such a macro operator
is identical and behaves identical to other opererators. Macros can
also be constructed of macros even! Currently only hardcoded macros are
implemented, this to solve combined operators such as 'add duplicate' or
'extrude' (both want a transform appended).
Usage is simple:
- WM_operatortype_append_macro() : add new operatortype, name, flags
- WM_operatortype_macro_define() : add existing operator to macro
(Note: macro_define will also allow properties to be set, doesnt work
right now)
On converting the macro wmOperatorType to a real operator, it makes a
list of all operators, and the standard macro callbacks (exec, invoke,
modal, poll) just will use all.
Important note; switching to a modal operator only works as last in the
chain now!
Macros implemented for duplicate, extrude and rip. Tool menu works fine
for it, also the redo hotkey F4 works properly.
--- Operator redo fix
The operators use the undo system to switch back, but this could give
errors if other actions added undo pushes (buttons, outliner). Now the
redo for operator searches back for the correct undo level.
This fixes issues with many redos.
Note for brecht: removed the ED_undo_push for buttons... it was called
on *every* button now, which is probably too much? For example, using
the 'toolbar' redo also caused this...
2009-07-29 17:56:38 +00:00
ot - > poll = NULL ;
2010-01-21 21:58:40 +00:00
if ( ! ot - > description )
ot - > description = " (undocumented operator) " ;
2.5
Operator goodies!
--- Macro operators
Operators now can consist of multiple operators. Such a macro operator
is identical and behaves identical to other opererators. Macros can
also be constructed of macros even! Currently only hardcoded macros are
implemented, this to solve combined operators such as 'add duplicate' or
'extrude' (both want a transform appended).
Usage is simple:
- WM_operatortype_append_macro() : add new operatortype, name, flags
- WM_operatortype_macro_define() : add existing operator to macro
(Note: macro_define will also allow properties to be set, doesnt work
right now)
On converting the macro wmOperatorType to a real operator, it makes a
list of all operators, and the standard macro callbacks (exec, invoke,
modal, poll) just will use all.
Important note; switching to a modal operator only works as last in the
chain now!
Macros implemented for duplicate, extrude and rip. Tool menu works fine
for it, also the redo hotkey F4 works properly.
--- Operator redo fix
The operators use the undo system to switch back, but this could give
errors if other actions added undo pushes (buttons, outliner). Now the
redo for operator searches back for the correct undo level.
This fixes issues with many redos.
Note for brecht: removed the ED_undo_push for buttons... it was called
on *every* button now, which is probably too much? For example, using
the 'toolbar' redo also caused this...
2009-07-29 17:56:38 +00:00
2010-01-21 21:58:40 +00:00
RNA_def_struct_ui_text ( ot - > srna , ot - > name , ot - > description ) ; // XXX All ops should have a description but for now allow them not to.
2.5
Operator goodies!
--- Macro operators
Operators now can consist of multiple operators. Such a macro operator
is identical and behaves identical to other opererators. Macros can
also be constructed of macros even! Currently only hardcoded macros are
implemented, this to solve combined operators such as 'add duplicate' or
'extrude' (both want a transform appended).
Usage is simple:
- WM_operatortype_append_macro() : add new operatortype, name, flags
- WM_operatortype_macro_define() : add existing operator to macro
(Note: macro_define will also allow properties to be set, doesnt work
right now)
On converting the macro wmOperatorType to a real operator, it makes a
list of all operators, and the standard macro callbacks (exec, invoke,
modal, poll) just will use all.
Important note; switching to a modal operator only works as last in the
chain now!
Macros implemented for duplicate, extrude and rip. Tool menu works fine
for it, also the redo hotkey F4 works properly.
--- Operator redo fix
The operators use the undo system to switch back, but this could give
errors if other actions added undo pushes (buttons, outliner). Now the
redo for operator searches back for the correct undo level.
This fixes issues with many redos.
Note for brecht: removed the ED_undo_push for buttons... it was called
on *every* button now, which is probably too much? For example, using
the 'toolbar' redo also caused this...
2009-07-29 17:56:38 +00:00
RNA_def_struct_identifier ( ot - > srna , ot - > idname ) ;
BLI_addtail ( & global_ops , ot ) ;
return ot ;
}
2009-12-05 19:27:26 +00:00
void WM_operatortype_append_macro_ptr ( void ( * opfunc ) ( wmOperatorType * , void * ) , void * userdata )
{
wmOperatorType * ot ;
ot = MEM_callocN ( sizeof ( wmOperatorType ) , " operatortype " ) ;
ot - > srna = RNA_def_struct ( & BLENDER_RNA , " " , " OperatorProperties " ) ;
2009-12-30 22:14:32 +00:00
ot - > flag = OPTYPE_MACRO ;
2009-12-05 19:27:26 +00:00
ot - > exec = wm_macro_exec ;
ot - > invoke = wm_macro_invoke ;
ot - > modal = wm_macro_modal ;
ot - > cancel = wm_macro_cancel ;
ot - > poll = NULL ;
2010-01-21 21:58:40 +00:00
if ( ! ot - > description )
ot - > description = " (undocumented operator) " ;
2009-12-05 19:27:26 +00:00
opfunc ( ot , userdata ) ;
2010-01-21 21:58:40 +00:00
RNA_def_struct_ui_text ( ot - > srna , ot - > name , ot - > description ) ;
2009-12-05 19:27:26 +00:00
RNA_def_struct_identifier ( ot - > srna , ot - > idname ) ;
BLI_addtail ( & global_ops , ot ) ;
}
2.5
Operator goodies!
--- Macro operators
Operators now can consist of multiple operators. Such a macro operator
is identical and behaves identical to other opererators. Macros can
also be constructed of macros even! Currently only hardcoded macros are
implemented, this to solve combined operators such as 'add duplicate' or
'extrude' (both want a transform appended).
Usage is simple:
- WM_operatortype_append_macro() : add new operatortype, name, flags
- WM_operatortype_macro_define() : add existing operator to macro
(Note: macro_define will also allow properties to be set, doesnt work
right now)
On converting the macro wmOperatorType to a real operator, it makes a
list of all operators, and the standard macro callbacks (exec, invoke,
modal, poll) just will use all.
Important note; switching to a modal operator only works as last in the
chain now!
Macros implemented for duplicate, extrude and rip. Tool menu works fine
for it, also the redo hotkey F4 works properly.
--- Operator redo fix
The operators use the undo system to switch back, but this could give
errors if other actions added undo pushes (buttons, outliner). Now the
redo for operator searches back for the correct undo level.
This fixes issues with many redos.
Note for brecht: removed the ED_undo_push for buttons... it was called
on *every* button now, which is probably too much? For example, using
the 'toolbar' redo also caused this...
2009-07-29 17:56:38 +00:00
wmOperatorTypeMacro * WM_operatortype_macro_define ( wmOperatorType * ot , const char * idname )
{
wmOperatorTypeMacro * otmacro = MEM_callocN ( sizeof ( wmOperatorTypeMacro ) , " wmOperatorTypeMacro " ) ;
2011-02-25 04:15:45 +00:00
2.5
Operator goodies!
--- Macro operators
Operators now can consist of multiple operators. Such a macro operator
is identical and behaves identical to other opererators. Macros can
also be constructed of macros even! Currently only hardcoded macros are
implemented, this to solve combined operators such as 'add duplicate' or
'extrude' (both want a transform appended).
Usage is simple:
- WM_operatortype_append_macro() : add new operatortype, name, flags
- WM_operatortype_macro_define() : add existing operator to macro
(Note: macro_define will also allow properties to be set, doesnt work
right now)
On converting the macro wmOperatorType to a real operator, it makes a
list of all operators, and the standard macro callbacks (exec, invoke,
modal, poll) just will use all.
Important note; switching to a modal operator only works as last in the
chain now!
Macros implemented for duplicate, extrude and rip. Tool menu works fine
for it, also the redo hotkey F4 works properly.
--- Operator redo fix
The operators use the undo system to switch back, but this could give
errors if other actions added undo pushes (buttons, outliner). Now the
redo for operator searches back for the correct undo level.
This fixes issues with many redos.
Note for brecht: removed the ED_undo_push for buttons... it was called
on *every* button now, which is probably too much? For example, using
the 'toolbar' redo also caused this...
2009-07-29 17:56:38 +00:00
BLI_strncpy ( otmacro - > idname , idname , OP_MAX_TYPENAME ) ;
/* do this on first use, since operatordefinitions might have been not done yet */
2009-10-12 12:54:08 +00:00
WM_operator_properties_alloc ( & ( otmacro - > ptr ) , & ( otmacro - > properties ) , idname ) ;
2010-02-01 18:26:45 +00:00
WM_operator_properties_sanitize ( otmacro - > ptr , 1 ) ;
2011-02-25 04:15:45 +00:00
2.5
Operator goodies!
--- Macro operators
Operators now can consist of multiple operators. Such a macro operator
is identical and behaves identical to other opererators. Macros can
also be constructed of macros even! Currently only hardcoded macros are
implemented, this to solve combined operators such as 'add duplicate' or
'extrude' (both want a transform appended).
Usage is simple:
- WM_operatortype_append_macro() : add new operatortype, name, flags
- WM_operatortype_macro_define() : add existing operator to macro
(Note: macro_define will also allow properties to be set, doesnt work
right now)
On converting the macro wmOperatorType to a real operator, it makes a
list of all operators, and the standard macro callbacks (exec, invoke,
modal, poll) just will use all.
Important note; switching to a modal operator only works as last in the
chain now!
Macros implemented for duplicate, extrude and rip. Tool menu works fine
for it, also the redo hotkey F4 works properly.
--- Operator redo fix
The operators use the undo system to switch back, but this could give
errors if other actions added undo pushes (buttons, outliner). Now the
redo for operator searches back for the correct undo level.
This fixes issues with many redos.
Note for brecht: removed the ED_undo_push for buttons... it was called
on *every* button now, which is probably too much? For example, using
the 'toolbar' redo also caused this...
2009-07-29 17:56:38 +00:00
BLI_addtail ( & ot - > macro , otmacro ) ;
2010-01-21 21:58:40 +00:00
{
2011-02-25 04:15:45 +00:00
/* operator should always be found but in the event its not. dont segfault */
2010-01-21 21:58:40 +00:00
wmOperatorType * otsub = WM_operatortype_find ( idname , 0 ) ;
2011-02-25 04:15:45 +00:00
if ( otsub ) {
RNA_def_pointer_runtime ( ot - > srna , otsub - > idname , otsub - > srna ,
otsub - > name , otsub - > description ) ;
}
2010-01-21 21:58:40 +00:00
}
2011-02-25 04:15:45 +00:00
2.5
Operator goodies!
--- Macro operators
Operators now can consist of multiple operators. Such a macro operator
is identical and behaves identical to other opererators. Macros can
also be constructed of macros even! Currently only hardcoded macros are
implemented, this to solve combined operators such as 'add duplicate' or
'extrude' (both want a transform appended).
Usage is simple:
- WM_operatortype_append_macro() : add new operatortype, name, flags
- WM_operatortype_macro_define() : add existing operator to macro
(Note: macro_define will also allow properties to be set, doesnt work
right now)
On converting the macro wmOperatorType to a real operator, it makes a
list of all operators, and the standard macro callbacks (exec, invoke,
modal, poll) just will use all.
Important note; switching to a modal operator only works as last in the
chain now!
Macros implemented for duplicate, extrude and rip. Tool menu works fine
for it, also the redo hotkey F4 works properly.
--- Operator redo fix
The operators use the undo system to switch back, but this could give
errors if other actions added undo pushes (buttons, outliner). Now the
redo for operator searches back for the correct undo level.
This fixes issues with many redos.
Note for brecht: removed the ED_undo_push for buttons... it was called
on *every* button now, which is probably too much? For example, using
the 'toolbar' redo also caused this...
2009-07-29 17:56:38 +00:00
return otmacro ;
}
static void wm_operatortype_free_macro ( wmOperatorType * ot )
{
wmOperatorTypeMacro * otmacro ;
for ( otmacro = ot - > macro . first ; otmacro ; otmacro = otmacro - > next ) {
if ( otmacro - > ptr ) {
WM_operator_properties_free ( otmacro - > ptr ) ;
MEM_freeN ( otmacro - > ptr ) ;
}
}
BLI_freelistN ( & ot - > macro ) ;
}
python operators (in bpy_opwrapper.*)
This means you can define an operator in python that is called from C or Python - like any other operator.
Python functions for invoke and exec can be registered with an operator name.
keywords are read from the python exec() function, then used to create operator properties. The default python values are used to set the property type and defaults.
def exec(size=2.0, text="blah"): ...
is equivalent to...
prop = RNA_def_property(ot->srna, "size", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_default(prop, 2.0f);
prop = RNA_def_property(ot->srna, "size", PROP_STRING, PROP_NONE);
RNA_def_property_string_default(prop, "blah");
TODO -
* make use of events
* return OPERATOR_CANCELLED/OPERATOR_FINISHED.. etc
* add support for array args
* more testing
2008-12-27 14:52:49 +00:00
int WM_operatortype_remove ( const char * idname )
{
2009-07-13 08:33:51 +00:00
wmOperatorType * ot = WM_operatortype_find ( idname , 0 ) ;
python operators (in bpy_opwrapper.*)
This means you can define an operator in python that is called from C or Python - like any other operator.
Python functions for invoke and exec can be registered with an operator name.
keywords are read from the python exec() function, then used to create operator properties. The default python values are used to set the property type and defaults.
def exec(size=2.0, text="blah"): ...
is equivalent to...
prop = RNA_def_property(ot->srna, "size", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_default(prop, 2.0f);
prop = RNA_def_property(ot->srna, "size", PROP_STRING, PROP_NONE);
RNA_def_property_string_default(prop, "blah");
TODO -
* make use of events
* return OPERATOR_CANCELLED/OPERATOR_FINISHED.. etc
* add support for array args
* more testing
2008-12-27 14:52:49 +00:00
if ( ot = = NULL )
return 0 ;
BLI_remlink ( & global_ops , ot ) ;
RNA_struct_free ( & BLENDER_RNA , ot - > srna ) ;
2.5
Operator goodies!
--- Macro operators
Operators now can consist of multiple operators. Such a macro operator
is identical and behaves identical to other opererators. Macros can
also be constructed of macros even! Currently only hardcoded macros are
implemented, this to solve combined operators such as 'add duplicate' or
'extrude' (both want a transform appended).
Usage is simple:
- WM_operatortype_append_macro() : add new operatortype, name, flags
- WM_operatortype_macro_define() : add existing operator to macro
(Note: macro_define will also allow properties to be set, doesnt work
right now)
On converting the macro wmOperatorType to a real operator, it makes a
list of all operators, and the standard macro callbacks (exec, invoke,
modal, poll) just will use all.
Important note; switching to a modal operator only works as last in the
chain now!
Macros implemented for duplicate, extrude and rip. Tool menu works fine
for it, also the redo hotkey F4 works properly.
--- Operator redo fix
The operators use the undo system to switch back, but this could give
errors if other actions added undo pushes (buttons, outliner). Now the
redo for operator searches back for the correct undo level.
This fixes issues with many redos.
Note for brecht: removed the ED_undo_push for buttons... it was called
on *every* button now, which is probably too much? For example, using
the 'toolbar' redo also caused this...
2009-07-29 17:56:38 +00:00
if ( ot - > macro . first )
wm_operatortype_free_macro ( ot ) ;
python operators (in bpy_opwrapper.*)
This means you can define an operator in python that is called from C or Python - like any other operator.
Python functions for invoke and exec can be registered with an operator name.
keywords are read from the python exec() function, then used to create operator properties. The default python values are used to set the property type and defaults.
def exec(size=2.0, text="blah"): ...
is equivalent to...
prop = RNA_def_property(ot->srna, "size", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_default(prop, 2.0f);
prop = RNA_def_property(ot->srna, "size", PROP_STRING, PROP_NONE);
RNA_def_property_string_default(prop, "blah");
TODO -
* make use of events
* return OPERATOR_CANCELLED/OPERATOR_FINISHED.. etc
* add support for array args
* more testing
2008-12-27 14:52:49 +00:00
MEM_freeN ( ot ) ;
return 1 ;
}
2009-07-17 12:26:40 +00:00
/* SOME_OT_op -> some.op */
2009-07-18 19:42:13 +00:00
void WM_operator_py_idname ( char * to , const char * from )
2009-07-17 12:26:40 +00:00
{
char * sep = strstr ( from , " _OT_ " ) ;
if ( sep ) {
int i , ofs = ( sep - from ) ;
for ( i = 0 ; i < ofs ; i + + )
to [ i ] = tolower ( from [ i ] ) ;
to [ ofs ] = ' . ' ;
BLI_strncpy ( to + ( ofs + 1 ) , sep + 4 , OP_MAX_TYPENAME ) ;
}
else {
/* should not happen but support just incase */
BLI_strncpy ( to , from , OP_MAX_TYPENAME ) ;
}
}
/* some.op -> SOME_OT_op */
2009-07-18 19:42:13 +00:00
void WM_operator_bl_idname ( char * to , const char * from )
2009-07-17 12:26:40 +00:00
{
2009-09-08 02:09:14 +00:00
if ( from ) {
char * sep = strchr ( from , ' . ' ) ;
2009-07-17 12:26:40 +00:00
2009-09-08 02:09:14 +00:00
if ( sep ) {
int i , ofs = ( sep - from ) ;
2009-07-17 12:26:40 +00:00
2009-09-08 02:09:14 +00:00
for ( i = 0 ; i < ofs ; i + + )
to [ i ] = toupper ( from [ i ] ) ;
2009-07-17 12:26:40 +00:00
2009-09-08 02:09:14 +00:00
BLI_strncpy ( to + ofs , " _OT_ " , OP_MAX_TYPENAME ) ;
BLI_strncpy ( to + ( ofs + 4 ) , sep + 1 , OP_MAX_TYPENAME ) ;
}
else {
/* should not happen but support just incase */
BLI_strncpy ( to , from , OP_MAX_TYPENAME ) ;
}
2009-07-17 12:26:40 +00:00
}
2009-09-08 02:09:14 +00:00
else
to [ 0 ] = 0 ;
2009-07-17 12:26:40 +00:00
}
2008-12-26 03:56:52 +00:00
/* print a string representation of the operator, with the args that it runs
2009-07-29 23:12:30 +00:00
* so python can run it again ,
*
* When calling from an existing wmOperator do .
* WM_operator_pystring ( op - > type , op - > ptr ) ;
*/
2009-08-16 14:43:08 +00:00
char * WM_operator_pystring ( bContext * C , wmOperatorType * ot , PointerRNA * opptr , int all_args )
2008-12-26 03:56:52 +00:00
{
const char * arg_name = NULL ;
2009-07-17 12:26:40 +00:00
char idname_py [ OP_MAX_TYPENAME ] ;
2008-12-26 03:56:52 +00:00
PropertyRNA * prop , * iterprop ;
/* for building the string */
DynStr * dynstr = BLI_dynstr_new ( ) ;
char * cstring , * buf ;
2009-07-29 23:48:06 +00:00
int first_iter = 1 , ok = 1 ;
/* only to get the orginal props for comparisons */
PointerRNA opptr_default ;
PropertyRNA * prop_default ;
char * buf_default ;
2009-11-28 17:45:23 +00:00
if ( all_args = = 0 | | opptr = = NULL ) {
2009-11-24 16:19:15 +00:00
WM_operator_properties_create_ptr ( & opptr_default , ot ) ;
2009-11-28 17:45:23 +00:00
if ( opptr = = NULL )
opptr = & opptr_default ;
2009-07-29 23:48:06 +00:00
}
2008-12-26 03:56:52 +00:00
2009-07-29 23:12:30 +00:00
WM_operator_py_idname ( idname_py , ot - > idname ) ;
2009-07-17 12:26:40 +00:00
BLI_dynstr_appendf ( dynstr , " bpy.ops.%s( " , idname_py ) ;
2008-12-26 03:56:52 +00:00
2009-07-29 23:12:30 +00:00
iterprop = RNA_struct_iterator_property ( opptr - > type ) ;
2008-12-26 03:56:52 +00:00
2009-07-29 23:12:30 +00:00
RNA_PROP_BEGIN ( opptr , propptr , iterprop ) {
2009-06-24 21:27:10 +00:00
prop = propptr . data ;
2009-04-19 13:37:59 +00:00
arg_name = RNA_property_identifier ( prop ) ;
2008-12-26 03:56:52 +00:00
if ( strcmp ( arg_name , " rna_type " ) = = 0 ) continue ;
2009-08-16 14:43:08 +00:00
buf = RNA_property_as_string ( C , opptr , prop ) ;
2008-12-26 03:56:52 +00:00
2009-07-29 23:48:06 +00:00
ok = 1 ;
if ( ! all_args ) {
/* not verbose, so only add in attributes that use non-default values
* slow but good for tooltips */
prop_default = RNA_struct_find_property ( & opptr_default , arg_name ) ;
if ( prop_default ) {
2009-08-16 14:43:08 +00:00
buf_default = RNA_property_as_string ( C , & opptr_default , prop_default ) ;
2009-07-29 23:48:06 +00:00
if ( strcmp ( buf , buf_default ) = = 0 )
ok = 0 ; /* values match, dont bother printing */
MEM_freeN ( buf_default ) ;
}
}
if ( ok ) {
BLI_dynstr_appendf ( dynstr , first_iter ? " %s=%s " : " , %s=%s " , arg_name , buf ) ;
first_iter = 0 ;
}
2008-12-26 03:56:52 +00:00
MEM_freeN ( buf ) ;
2009-07-29 23:48:06 +00:00
2008-12-26 03:56:52 +00:00
}
2009-06-24 21:27:10 +00:00
RNA_PROP_END ;
2008-12-26 03:56:52 +00:00
2009-11-28 17:45:23 +00:00
if ( all_args = = 0 | | opptr = = & opptr_default )
2009-07-29 23:48:06 +00:00
WM_operator_properties_free ( & opptr_default ) ;
2008-12-26 03:56:52 +00:00
BLI_dynstr_append ( dynstr , " ) " ) ;
cstring = BLI_dynstr_get_cstring ( dynstr ) ;
BLI_dynstr_free ( dynstr ) ;
return cstring ;
}
2009-11-24 16:19:15 +00:00
void WM_operator_properties_create_ptr ( PointerRNA * ptr , wmOperatorType * ot )
{
RNA_pointer_create ( NULL , ot - > srna , NULL , ptr ) ;
}
2009-01-01 20:44:40 +00:00
void WM_operator_properties_create ( PointerRNA * ptr , const char * opstring )
{
2009-07-13 08:33:51 +00:00
wmOperatorType * ot = WM_operatortype_find ( opstring , 0 ) ;
2009-01-01 20:44:40 +00:00
if ( ot )
2009-11-24 16:19:15 +00:00
WM_operator_properties_create_ptr ( ptr , ot ) ;
2009-01-01 20:44:40 +00:00
else
2009-01-15 04:13:38 +00:00
RNA_pointer_create ( NULL , & RNA_OperatorProperties , NULL , ptr ) ;
2009-01-01 20:44:40 +00:00
}
2009-10-12 12:54:08 +00:00
/* similar to the function above except its uses ID properties
* used for keymaps and macros */
void WM_operator_properties_alloc ( PointerRNA * * ptr , IDProperty * * properties , const char * opstring )
{
if ( * properties = = NULL ) {
IDPropertyTemplate val = { 0 } ;
* properties = IDP_New ( IDP_GROUP , val , " wmOpItemProp " ) ;
}
if ( * ptr = = NULL ) {
* ptr = MEM_callocN ( sizeof ( PointerRNA ) , " wmOpItemPtr " ) ;
WM_operator_properties_create ( * ptr , opstring ) ;
}
( * ptr ) - > data = * properties ;
}
2010-11-23 12:05:35 +00:00
void WM_operator_properties_sanitize ( PointerRNA * ptr , const short no_context )
2010-01-27 21:19:39 +00:00
{
RNA_STRUCT_BEGIN ( ptr , prop ) {
switch ( RNA_property_type ( prop ) ) {
case PROP_ENUM :
2010-11-23 12:05:35 +00:00
if ( no_context )
2010-02-01 18:26:45 +00:00
RNA_def_property_flag ( prop , PROP_ENUM_NO_CONTEXT ) ;
else
RNA_def_property_clear_flag ( prop , PROP_ENUM_NO_CONTEXT ) ;
2010-01-27 21:19:39 +00:00
break ;
case PROP_POINTER :
{
StructRNA * ptype = RNA_property_pointer_type ( ptr , prop ) ;
/* recurse into operator properties */
if ( RNA_struct_is_a ( ptype , & RNA_OperatorProperties ) ) {
PointerRNA opptr = RNA_property_pointer_get ( ptr , prop ) ;
2010-11-23 12:05:35 +00:00
WM_operator_properties_sanitize ( & opptr , no_context ) ;
2010-01-27 21:19:39 +00:00
}
break ;
}
default :
break ;
}
}
RNA_STRUCT_END ;
}
2009-10-12 12:54:08 +00:00
2009-01-01 20:44:40 +00:00
void WM_operator_properties_free ( PointerRNA * ptr )
{
IDProperty * properties = ptr - > data ;
if ( properties ) {
IDP_FreeProperty ( properties ) ;
MEM_freeN ( properties ) ;
2010-11-10 11:19:52 +00:00
ptr - > data = NULL ; /* just incase */
2009-01-01 20:44:40 +00:00
}
}
2.5: work on bringing back SpaceTime options
- RMB select, also with SHIFT
- RMB tweak for translate
- SHIFT+D dupli
- BKEY border select/deselect
- AKEY (de)select all
- XKEY delete
- GKEY grab
Added some XXX comments for future todos, especially for when other
spaces come back with time markers.
Also added ED_util for putting in all to-be-cleaned cruft
Context conflict: input methods for Markers can conflict with other
spacetypes. It was solved in pre-2.5 with manually tweaking it all over,
but I would prefer one keymap for all marker stuff. Needs some thinking...
could be solved with a boundbox check for bottom part of 2d window.
Tweak issue: both tweak styles are possible:
- Hold mouse button, move, operator ends on mouse release
- Hold mouse button, move, operator ends on mouse click
Problem is that modally handled operators use fixed keymaps... like ESC,
SPACE, ENTER, or press/release mousebutton for 'assign'. There's a lot
to say for making this all consistant, or become part of 1 general keymap?
Should also be possibe to define 'tweak' defaults for Tablet different
than for mouse...
2008-11-29 15:10:31 +00:00
/* ************ default op callbacks, exported *********** */
2007-12-24 18:27:28 +00:00
2008-12-24 18:06:51 +00:00
/* invoke callback, uses enum property named "type" */
2010-10-16 02:40:31 +00:00
int WM_menu_invoke ( bContext * C , wmOperator * op , wmEvent * UNUSED ( event ) )
2008-12-17 15:38:40 +00:00
{
2010-01-15 22:40:33 +00:00
PropertyRNA * prop = op - > type - > prop ;
2009-04-22 18:39:44 +00:00
uiPopupMenu * pup ;
uiLayout * layout ;
2009-02-01 02:37:12 +00:00
if ( prop = = NULL ) {
2010-01-15 22:40:33 +00:00
printf ( " WM_menu_invoke: %s has no enum property set \n " , op - > type - > idname ) ;
2009-02-01 02:37:12 +00:00
}
2009-04-19 13:37:59 +00:00
else if ( RNA_property_type ( prop ) ! = PROP_ENUM ) {
2010-01-15 22:40:33 +00:00
printf ( " WM_menu_invoke: %s \" %s \" is not an enum property \n " , op - > type - > idname , RNA_property_identifier ( prop ) ) ;
2009-02-01 02:37:12 +00:00
}
2009-12-10 23:22:43 +00:00
else if ( RNA_property_is_set ( op - > ptr , RNA_property_identifier ( prop ) ) ) {
return op - > type - > exec ( C , op ) ;
}
2009-02-01 02:37:12 +00:00
else {
2011-02-27 18:03:19 +00:00
pup = uiPupMenuBegin ( C , op - > type - > name , ICON_NONE ) ;
2009-04-22 18:39:44 +00:00
layout = uiPupMenuLayout ( pup ) ;
2009-12-22 11:59:30 +00:00
uiItemsFullEnumO ( layout , op - > type - > idname , ( char * ) RNA_property_identifier ( prop ) , op - > ptr - > data , WM_OP_EXEC_REGION_WIN , 0 ) ;
2009-04-22 18:39:44 +00:00
uiPupMenuEnd ( C , pup ) ;
2008-12-24 18:06:51 +00:00
}
2009-02-04 11:52:16 +00:00
2008-12-24 18:06:51 +00:00
return OPERATOR_CANCELLED ;
2008-12-17 15:38:40 +00:00
}
2010-01-15 17:23:16 +00:00
2010-01-15 22:40:33 +00:00
/* generic enum search invoke popup */
2010-11-17 09:45:45 +00:00
static void operator_enum_search_cb ( const struct bContext * C , void * arg_ot , const char * str , uiSearchItems * items )
2010-01-15 17:23:16 +00:00
{
wmOperatorType * ot = ( wmOperatorType * ) arg_ot ;
2010-01-15 22:40:33 +00:00
PropertyRNA * prop = ot - > prop ;
2010-01-15 17:23:16 +00:00
2010-01-15 22:40:33 +00:00
if ( prop = = NULL ) {
printf ( " WM_enum_search_invoke: %s has no enum property set \n " , ot - > idname ) ;
}
else if ( RNA_property_type ( prop ) ! = PROP_ENUM ) {
printf ( " WM_enum_search_invoke: %s \" %s \" is not an enum property \n " , ot - > idname , RNA_property_identifier ( prop ) ) ;
2010-01-15 17:23:16 +00:00
}
2010-01-15 22:40:33 +00:00
else {
PointerRNA ptr ;
2010-01-15 17:23:16 +00:00
2010-01-15 22:40:33 +00:00
EnumPropertyItem * item , * item_array ;
2010-12-03 12:30:59 +00:00
int do_free ;
2010-01-15 17:23:16 +00:00
2010-01-15 22:40:33 +00:00
RNA_pointer_create ( NULL , ot - > srna , NULL , & ptr ) ;
2010-12-03 12:30:59 +00:00
RNA_property_enum_items ( ( bContext * ) C , & ptr , prop , & item_array , NULL , & do_free ) ;
2010-01-15 17:23:16 +00:00
2010-01-15 22:40:33 +00:00
for ( item = item_array ; item - > identifier ; item + + ) {
/* note: need to give the intex rather then the dientifier because the enum can be freed */
if ( BLI_strcasestr ( item - > name , str ) )
if ( 0 = = uiSearchItemAdd ( items , item - > name , SET_INT_IN_POINTER ( item - > value ) , 0 ) )
break ;
}
2010-12-03 12:30:59 +00:00
if ( do_free )
2010-01-15 22:40:33 +00:00
MEM_freeN ( item_array ) ;
}
2010-01-15 17:23:16 +00:00
}
static void operator_enum_call_cb ( struct bContext * C , void * arg1 , void * arg2 )
{
wmOperatorType * ot = arg1 ;
if ( ot ) {
2011-05-08 12:51:05 +00:00
if ( ot - > prop ) {
PointerRNA props_ptr ;
WM_operator_properties_create_ptr ( & props_ptr , ot ) ;
RNA_property_enum_set ( & props_ptr , ot - > prop , GET_INT_FROM_POINTER ( arg2 ) ) ;
WM_operator_name_call ( C , ot - > idname , WM_OP_EXEC_DEFAULT , & props_ptr ) ;
WM_operator_properties_free ( & props_ptr ) ;
}
else {
printf ( " operator_enum_call_cb: op->prop for '%s' is NULL \n " , ot - > idname ) ;
}
2010-01-15 17:23:16 +00:00
}
}
static uiBlock * wm_enum_search_menu ( bContext * C , ARegion * ar , void * arg_op )
{
static char search [ 256 ] = " " ;
wmEvent event ;
wmWindow * win = CTX_wm_window ( C ) ;
uiBlock * block ;
uiBut * but ;
2010-01-15 22:40:33 +00:00
wmOperator * op = ( wmOperator * ) arg_op ;
2010-01-15 17:23:16 +00:00
block = uiBeginBlock ( C , ar , " _popup " , UI_EMBOSS ) ;
uiBlockSetFlag ( block , UI_BLOCK_LOOP | UI_BLOCK_RET_1 | UI_BLOCK_MOVEMOUSE_QUIT ) ;
2010-01-15 22:40:33 +00:00
//uiDefBut(block, LABEL, 0, op->type->name, 10, 10, 180, 19, NULL, 0.0, 0.0, 0, 0, ""); // ok, this isnt so easy...
2010-01-15 17:23:16 +00:00
but = uiDefSearchBut ( block , search , 0 , ICON_VIEWZOOM , 256 , 10 , 10 , 180 , 19 , 0 , 0 , " " ) ;
2010-01-15 22:40:33 +00:00
uiButSetSearchFunc ( but , operator_enum_search_cb , op - > type , operator_enum_call_cb , NULL ) ;
2010-01-15 17:23:16 +00:00
/* fake button, it holds space for search items */
uiDefBut ( block , LABEL , 0 , " " , 10 , 10 - uiSearchBoxhHeight ( ) , 180 , uiSearchBoxhHeight ( ) , NULL , 0 , 0 , 0 , 0 , NULL ) ;
2011-02-18 06:07:41 +00:00
uiPopupBoundsBlock ( block , 6 , 0 , - 20 ) ; /* move it downwards, mouse over button */
2010-01-15 17:23:16 +00:00
uiEndBlock ( C , block ) ;
event = * ( win - > eventstate ) ; /* XXX huh huh? make api call */
event . type = EVT_BUT_OPEN ;
event . val = KM_PRESS ;
event . customdata = but ;
event . customdatafree = FALSE ;
wm_event_add ( win , & event ) ;
return block ;
}
2010-10-16 02:40:31 +00:00
int WM_enum_search_invoke ( bContext * C , wmOperator * op , wmEvent * UNUSED ( event ) )
2010-01-15 17:23:16 +00:00
{
uiPupBlock ( C , wm_enum_search_menu , op ) ;
return OPERATOR_CANCELLED ;
}
2009-10-10 12:29:11 +00:00
/* Can't be used as an invoke directly, needs message arg (can be NULL) */
2010-12-03 17:05:21 +00:00
int WM_operator_confirm_message ( bContext * C , wmOperator * op , const char * message )
2007-12-24 18:27:28 +00:00
{
2009-04-22 18:39:44 +00:00
uiPopupMenu * pup ;
uiLayout * layout ;
2009-12-22 11:59:30 +00:00
IDProperty * properties = op - > ptr - > data ;
if ( properties & & properties - > len )
properties = IDP_CopyProperty ( op - > ptr - > data ) ;
else
properties = NULL ;
2009-02-04 11:52:16 +00:00
2009-05-23 07:19:31 +00:00
pup = uiPupMenuBegin ( C , " OK? " , ICON_QUESTION ) ;
2009-04-22 18:39:44 +00:00
layout = uiPupMenuLayout ( pup ) ;
2011-02-27 18:03:19 +00:00
uiItemFullO ( layout , op - > type - > idname , message , ICON_NONE , properties , WM_OP_EXEC_REGION_WIN , 0 ) ;
2009-04-22 18:39:44 +00:00
uiPupMenuEnd ( C , pup ) ;
2008-12-17 15:38:40 +00:00
2009-02-04 11:52:16 +00:00
return OPERATOR_CANCELLED ;
2007-12-24 18:27:28 +00:00
}
2008-12-17 15:38:40 +00:00
2009-10-10 12:29:11 +00:00
2010-10-16 02:40:31 +00:00
int WM_operator_confirm ( bContext * C , wmOperator * op , wmEvent * UNUSED ( event ) )
2009-10-10 12:29:11 +00:00
{
return WM_operator_confirm_message ( C , op , NULL ) ;
}
2009-09-12 19:54:39 +00:00
/* op->invoke, opens fileselect if path property not set, otherwise executes */
2010-10-16 02:40:31 +00:00
int WM_operator_filesel ( bContext * C , wmOperator * op , wmEvent * UNUSED ( event ) )
2009-01-26 09:13:15 +00:00
{
2010-06-14 03:52:10 +00:00
if ( RNA_property_is_set ( op - > ptr , " filepath " ) ) {
2009-01-26 09:13:15 +00:00
return WM_operator_call ( C , op ) ;
2009-02-16 12:14:04 +00:00
}
else {
WM_event_add_fileselect ( C , op ) ;
2009-01-26 09:13:15 +00:00
return OPERATOR_RUNNING_MODAL ;
}
}
2009-07-28 16:46:14 +00:00
/* default properties for fileselect */
2010-06-09 14:04:34 +00:00
void WM_operator_properties_filesel ( wmOperatorType * ot , int filter , short type , short action , short flag )
2009-07-28 16:46:14 +00:00
{
Key Configuration
Keymaps are now saveable and configurable from the user preferences, note
that editing one item in a keymap means the whole keymap is now defined by
the user and will not be updated by Blender, an option for syncing might be
added later. The outliner interface is still there, but I will probably
remove it.
There's actually 3 levels now:
* Default builtin key configuration.
* Key configuration loaded from .py file, for configs like Blender 2.4x
or other 3D applications.
* Keymaps edited by the user and saved in .B.blend. These can be saved
to .py files as well to make creating distributable configurations
easier.
Also, user preferences sections were reorganized a bit, now there is:
Interface, Editing, Input, Files and System.
Implementation notes:
* wmKeyConfig was added which represents a key configuration containing
keymaps.
* wmKeymapItem was renamed to wmKeyMapItem for consistency with wmKeyMap.
* Modal maps are not wrapped yet.
* User preferences DNA file reading did not support newdataadr() yet,
added this now for reading keymaps.
* Key configuration related settings are now RNA wrapped.
* is_property_set and is_property_hidden python methods were added.
2009-10-08 18:40:03 +00:00
PropertyRNA * prop ;
2009-07-28 16:46:14 +00:00
2010-07-01 19:28:45 +00:00
if ( flag & WM_FILESEL_FILEPATH )
RNA_def_string_file_path ( ot - > srna , " filepath " , " " , FILE_MAX , " File Path " , " Path to file " ) ;
if ( flag & WM_FILESEL_DIRECTORY )
RNA_def_string_dir_path ( ot - > srna , " directory " , " " , FILE_MAX , " Directory " , " Directory of the file " ) ;
if ( flag & WM_FILESEL_FILENAME )
RNA_def_string_file_name ( ot - > srna , " filename " , " " , FILE_MAX , " File Name " , " Name of the file " ) ;
2009-09-12 19:54:39 +00:00
2010-01-27 02:20:24 +00:00
if ( action = = FILE_SAVE ) {
prop = RNA_def_boolean ( ot - > srna , " check_existing " , 1 , " Check Existing " , " Check and warn on overwriting existing files " ) ;
RNA_def_property_flag ( prop , PROP_HIDDEN ) ;
}
Key Configuration
Keymaps are now saveable and configurable from the user preferences, note
that editing one item in a keymap means the whole keymap is now defined by
the user and will not be updated by Blender, an option for syncing might be
added later. The outliner interface is still there, but I will probably
remove it.
There's actually 3 levels now:
* Default builtin key configuration.
* Key configuration loaded from .py file, for configs like Blender 2.4x
or other 3D applications.
* Keymaps edited by the user and saved in .B.blend. These can be saved
to .py files as well to make creating distributable configurations
easier.
Also, user preferences sections were reorganized a bit, now there is:
Interface, Editing, Input, Files and System.
Implementation notes:
* wmKeyConfig was added which represents a key configuration containing
keymaps.
* wmKeymapItem was renamed to wmKeyMapItem for consistency with wmKeyMap.
* Modal maps are not wrapped yet.
* User preferences DNA file reading did not support newdataadr() yet,
added this now for reading keymaps.
* Key configuration related settings are now RNA wrapped.
* is_property_set and is_property_hidden python methods were added.
2009-10-08 18:40:03 +00:00
prop = RNA_def_boolean ( ot - > srna , " filter_blender " , ( filter & BLENDERFILE ) , " Filter .blend files " , " " ) ;
RNA_def_property_flag ( prop , PROP_HIDDEN ) ;
prop = RNA_def_boolean ( ot - > srna , " filter_image " , ( filter & IMAGEFILE ) , " Filter image files " , " " ) ;
RNA_def_property_flag ( prop , PROP_HIDDEN ) ;
prop = RNA_def_boolean ( ot - > srna , " filter_movie " , ( filter & MOVIEFILE ) , " Filter movie files " , " " ) ;
RNA_def_property_flag ( prop , PROP_HIDDEN ) ;
prop = RNA_def_boolean ( ot - > srna , " filter_python " , ( filter & PYSCRIPTFILE ) , " Filter python files " , " " ) ;
RNA_def_property_flag ( prop , PROP_HIDDEN ) ;
prop = RNA_def_boolean ( ot - > srna , " filter_font " , ( filter & FTFONTFILE ) , " Filter font files " , " " ) ;
RNA_def_property_flag ( prop , PROP_HIDDEN ) ;
prop = RNA_def_boolean ( ot - > srna , " filter_sound " , ( filter & SOUNDFILE ) , " Filter sound files " , " " ) ;
RNA_def_property_flag ( prop , PROP_HIDDEN ) ;
prop = RNA_def_boolean ( ot - > srna , " filter_text " , ( filter & TEXTFILE ) , " Filter text files " , " " ) ;
RNA_def_property_flag ( prop , PROP_HIDDEN ) ;
2009-12-10 14:26:06 +00:00
prop = RNA_def_boolean ( ot - > srna , " filter_btx " , ( filter & BTXFILE ) , " Filter btx files " , " " ) ;
RNA_def_property_flag ( prop , PROP_HIDDEN ) ;
2010-03-29 08:33:35 +00:00
prop = RNA_def_boolean ( ot - > srna , " filter_collada " , ( filter & COLLADAFILE ) , " Filter COLLADA files " , " " ) ;
RNA_def_property_flag ( prop , PROP_HIDDEN ) ;
Key Configuration
Keymaps are now saveable and configurable from the user preferences, note
that editing one item in a keymap means the whole keymap is now defined by
the user and will not be updated by Blender, an option for syncing might be
added later. The outliner interface is still there, but I will probably
remove it.
There's actually 3 levels now:
* Default builtin key configuration.
* Key configuration loaded from .py file, for configs like Blender 2.4x
or other 3D applications.
* Keymaps edited by the user and saved in .B.blend. These can be saved
to .py files as well to make creating distributable configurations
easier.
Also, user preferences sections were reorganized a bit, now there is:
Interface, Editing, Input, Files and System.
Implementation notes:
* wmKeyConfig was added which represents a key configuration containing
keymaps.
* wmKeymapItem was renamed to wmKeyMapItem for consistency with wmKeyMap.
* Modal maps are not wrapped yet.
* User preferences DNA file reading did not support newdataadr() yet,
added this now for reading keymaps.
* Key configuration related settings are now RNA wrapped.
* is_property_set and is_property_hidden python methods were added.
2009-10-08 18:40:03 +00:00
prop = RNA_def_boolean ( ot - > srna , " filter_folder " , ( filter & FOLDERFILE ) , " Filter folders " , " " ) ;
RNA_def_property_flag ( prop , PROP_HIDDEN ) ;
prop = RNA_def_int ( ot - > srna , " filemode " , type , FILE_LOADLIB , FILE_SPECIAL ,
2010-02-11 01:11:52 +00:00
" File Browser Mode " , " The setting for the file browser mode to load a .blend file, a library or a special file " ,
2009-09-12 19:54:39 +00:00
FILE_LOADLIB , FILE_SPECIAL ) ;
Key Configuration
Keymaps are now saveable and configurable from the user preferences, note
that editing one item in a keymap means the whole keymap is now defined by
the user and will not be updated by Blender, an option for syncing might be
added later. The outliner interface is still there, but I will probably
remove it.
There's actually 3 levels now:
* Default builtin key configuration.
* Key configuration loaded from .py file, for configs like Blender 2.4x
or other 3D applications.
* Keymaps edited by the user and saved in .B.blend. These can be saved
to .py files as well to make creating distributable configurations
easier.
Also, user preferences sections were reorganized a bit, now there is:
Interface, Editing, Input, Files and System.
Implementation notes:
* wmKeyConfig was added which represents a key configuration containing
keymaps.
* wmKeymapItem was renamed to wmKeyMapItem for consistency with wmKeyMap.
* Modal maps are not wrapped yet.
* User preferences DNA file reading did not support newdataadr() yet,
added this now for reading keymaps.
* Key configuration related settings are now RNA wrapped.
* is_property_set and is_property_hidden python methods were added.
2009-10-08 18:40:03 +00:00
RNA_def_property_flag ( prop , PROP_HIDDEN ) ;
2010-06-09 14:04:34 +00:00
2010-07-01 19:28:45 +00:00
if ( flag & WM_FILESEL_RELPATH )
2010-07-08 22:07:34 +00:00
RNA_def_boolean ( ot - > srna , " relative_path " , ( U . flag & USER_RELPATHS ) ? 1 : 0 , " Relative Path " , " Select the file relative to the blend file " ) ;
2009-07-28 16:46:14 +00:00
}
2009-11-29 22:16:29 +00:00
void WM_operator_properties_select_all ( wmOperatorType * ot ) {
static EnumPropertyItem select_all_actions [ ] = {
{ SEL_TOGGLE , " TOGGLE " , 0 , " Toggle " , " Toggle selection for all elements " } ,
{ SEL_SELECT , " SELECT " , 0 , " Select " , " Select all elements " } ,
{ SEL_DESELECT , " DESELECT " , 0 , " Deselect " , " Deselect all elements " } ,
{ SEL_INVERT , " INVERT " , 0 , " Invert " , " Invert selection of all elements " } ,
{ 0 , NULL , 0 , NULL , NULL }
} ;
RNA_def_enum ( ot - > srna , " action " , select_all_actions , SEL_TOGGLE , " Action " , " Selection action to execute " ) ;
}
2009-11-06 22:51:08 +00:00
void WM_operator_properties_gesture_border ( wmOperatorType * ot , int extend )
{
RNA_def_int ( ot - > srna , " gesture_mode " , 0 , INT_MIN , INT_MAX , " Gesture Mode " , " " , INT_MIN , INT_MAX ) ;
RNA_def_int ( ot - > srna , " xmin " , 0 , INT_MIN , INT_MAX , " X Min " , " " , INT_MIN , INT_MAX ) ;
RNA_def_int ( ot - > srna , " xmax " , 0 , INT_MIN , INT_MAX , " X Max " , " " , INT_MIN , INT_MAX ) ;
RNA_def_int ( ot - > srna , " ymin " , 0 , INT_MIN , INT_MAX , " Y Min " , " " , INT_MIN , INT_MAX ) ;
RNA_def_int ( ot - > srna , " ymax " , 0 , INT_MIN , INT_MAX , " Y Max " , " " , INT_MIN , INT_MAX ) ;
if ( extend )
2010-02-11 01:11:52 +00:00
RNA_def_boolean ( ot - > srna , " extend " , 1 , " Extend " , " Extend selection instead of deselecting everything first " ) ;
2009-11-06 22:51:08 +00:00
}
2010-04-04 00:21:37 +00:00
void WM_operator_properties_gesture_straightline ( wmOperatorType * ot , int cursor )
{
RNA_def_int ( ot - > srna , " xstart " , 0 , INT_MIN , INT_MAX , " X Start " , " " , INT_MIN , INT_MAX ) ;
RNA_def_int ( ot - > srna , " xend " , 0 , INT_MIN , INT_MAX , " X End " , " " , INT_MIN , INT_MAX ) ;
RNA_def_int ( ot - > srna , " ystart " , 0 , INT_MIN , INT_MAX , " Y Start " , " " , INT_MIN , INT_MAX ) ;
RNA_def_int ( ot - > srna , " yend " , 0 , INT_MIN , INT_MAX , " Y End " , " " , INT_MIN , INT_MAX ) ;
if ( cursor )
RNA_def_int ( ot - > srna , " cursor " , cursor , 0 , INT_MAX , " Cursor " , " Mouse cursor style to use during the modal operator " , 0 , INT_MAX ) ;
}
2009-11-06 22:51:08 +00:00
2008-12-24 14:52:17 +00:00
/* op->poll */
2007-12-24 18:27:28 +00:00
int WM_operator_winactive ( bContext * C )
{
2008-12-18 02:56:48 +00:00
if ( CTX_wm_window ( C ) = = NULL ) return 0 ;
2007-12-24 18:27:28 +00:00
return 1 ;
}
2009-04-01 14:02:06 +00:00
static uiBlock * wm_block_create_redo ( bContext * C , ARegion * ar , void * arg_op )
{
wmOperator * op = arg_op ;
uiBlock * block ;
2009-05-19 17:13:33 +00:00
uiLayout * layout ;
uiStyle * style = U . uistyles . first ;
2010-12-15 05:42:23 +00:00
int width = 300 ;
2009-04-01 14:02:06 +00:00
2009-11-23 00:56:19 +00:00
2.5
More cleanup!
- removed old UI font completely, including from uiBeginBlock
- emboss hints for uiBlock only have three types now;
Regular, Pulldown, or "Nothing" (only icon/text)
- removed old font path from Userdef
- removed all old button theme hinting
- removed old "auto block" to merge buttons in groups
(was only in use for radiosity buttons)
And went over all warnings. One hooray for make giving clean output :)
Well, we need uniform definitions for warnings, so people at least fix
them... here's the real bad bugs I found:
- in mesh code, a call to editmesh mixed *em and *me
- in armature, ED_util.h was not included, so no warnings for wrong call
to ED_undo_push()
- The extern Py api .h was not included in the bpy_interface.c, showing
a several calls using different args.
Further just added the missing includes, and removed unused vars.
2009-04-14 15:59:52 +00:00
block = uiBeginBlock ( C , ar , " redo_popup " , UI_EMBOSS ) ;
2009-04-01 14:02:06 +00:00
uiBlockClearFlag ( block , UI_BLOCK_LOOP ) ;
2009-11-23 13:58:55 +00:00
uiBlockSetFlag ( block , UI_BLOCK_KEEP_OPEN | UI_BLOCK_RET_1 | UI_BLOCK_MOVEMOUSE_QUIT ) ;
2010-10-31 14:43:30 +00:00
/* if register is not enabled, the operator gets freed on OPERATOR_FINISHED
2010-12-15 04:06:19 +00:00
* ui_apply_but_funcs_after calls ED_undo_operator_repeate_cb and crashes */
2010-10-31 14:43:30 +00:00
assert ( op - > type - > flag & OPTYPE_REGISTER ) ;
2010-12-15 04:06:19 +00:00
uiBlockSetHandleFunc ( block , ED_undo_operator_repeat_cb_evt , arg_op ) ;
2009-11-23 00:56:19 +00:00
layout = uiBlockLayout ( block , UI_LAYOUT_VERTICAL , UI_LAYOUT_PANEL , 0 , 0 , width , 20 , style ) ;
2010-12-15 04:06:19 +00:00
2011-01-12 18:00:23 +00:00
if ( ED_undo_valid ( C , op - > type - > name ) = = 0 )
uiLayoutSetEnabled ( layout , 0 ) ;
2010-12-15 05:42:23 +00:00
uiLayoutOperatorButs ( C , layout , op , NULL , ' H ' , UI_LAYOUT_OP_SHOW_TITLE ) ;
2009-04-01 14:02:06 +00:00
2011-04-03 13:17:07 +00:00
uiPopupBoundsBlock ( block , 4 , 0 , 0 ) ;
2009-04-01 14:02:06 +00:00
uiEndBlock ( C , block ) ;
return block ;
}
2010-03-20 18:03:59 +00:00
/* Only invoked by OK button in popups created with wm_block_create_dialog() */
static void dialog_exec_cb ( bContext * C , void * arg1 , void * arg2 )
{
wmOperator * op = arg1 ;
uiBlock * block = arg2 ;
WM_operator_call ( C , op ) ;
uiPupBlockClose ( C , block ) ;
}
2011-02-13 14:16:36 +00:00
static void dialog_check_cb ( bContext * C , void * op_ptr , void * UNUSED ( arg ) )
2010-09-17 09:27:31 +00:00
{
wmOperator * op = op_ptr ;
if ( op - > type - > check ) {
if ( op - > type - > check ( C , op ) ) {
/* refresh */
}
}
}
2010-03-20 18:03:59 +00:00
/* Dialogs are popups that require user verification (click OK) before exec */
static uiBlock * wm_block_create_dialog ( bContext * C , ARegion * ar , void * userData )
{
struct { wmOperator * op ; int width ; int height ; } * data = userData ;
wmOperator * op = data - > op ;
uiBlock * block ;
uiLayout * layout ;
uiStyle * style = U . uistyles . first ;
block = uiBeginBlock ( C , ar , " operator dialog " , UI_EMBOSS ) ;
uiBlockClearFlag ( block , UI_BLOCK_LOOP ) ;
uiBlockSetFlag ( block , UI_BLOCK_KEEP_OPEN | UI_BLOCK_RET_1 | UI_BLOCK_MOVEMOUSE_QUIT ) ;
layout = uiBlockLayout ( block , UI_LAYOUT_VERTICAL , UI_LAYOUT_PANEL , 0 , 0 , data - > width , data - > height , style ) ;
2010-09-17 09:27:31 +00:00
uiBlockSetFunc ( block , dialog_check_cb , op , NULL ) ;
2010-03-20 18:03:59 +00:00
2010-12-15 05:42:23 +00:00
uiLayoutOperatorButs ( C , layout , op , NULL , ' H ' , UI_LAYOUT_OP_SHOW_TITLE ) ;
2010-09-17 09:27:31 +00:00
2010-12-15 05:42:23 +00:00
/* clear so the OK button is left alone */
2010-09-17 09:27:31 +00:00
uiBlockSetFunc ( block , NULL , NULL , NULL ) ;
2010-03-20 18:03:59 +00:00
2011-03-10 22:22:47 +00:00
/* new column so as not to interfear with custom layouts [#26436] */
{
uiBlock * col_block ;
uiLayout * col ;
uiBut * btn ;
col = uiLayoutColumn ( layout , FALSE ) ;
col_block = uiLayoutGetBlock ( col ) ;
/* Create OK button, the callback of which will execute op */
btn = uiDefBut ( col_block , BUT , 0 , " OK " , 0 , - 30 , 0 , 20 , NULL , 0 , 0 , 0 , 0 , " " ) ;
uiButSetFunc ( btn , dialog_exec_cb , op , col_block ) ;
}
2010-03-20 18:03:59 +00:00
2010-11-30 18:07:44 +00:00
/* center around the mouse */
2011-04-03 13:17:07 +00:00
uiPopupBoundsBlock ( block , 4 , data - > width / - 2 , data - > height / 2 ) ;
2010-03-20 18:03:59 +00:00
uiEndBlock ( C , block ) ;
return block ;
}
2009-12-06 04:35:00 +00:00
static uiBlock * wm_operator_create_ui ( bContext * C , ARegion * ar , void * userData )
{
struct { wmOperator * op ; int width ; int height ; } * data = userData ;
wmOperator * op = data - > op ;
uiBlock * block ;
uiLayout * layout ;
uiStyle * style = U . uistyles . first ;
block = uiBeginBlock ( C , ar , " opui_popup " , UI_EMBOSS ) ;
uiBlockClearFlag ( block , UI_BLOCK_LOOP ) ;
uiBlockSetFlag ( block , UI_BLOCK_KEEP_OPEN | UI_BLOCK_RET_1 | UI_BLOCK_MOVEMOUSE_QUIT ) ;
layout = uiBlockLayout ( block , UI_LAYOUT_VERTICAL , UI_LAYOUT_PANEL , 0 , 0 , data - > width , data - > height , style ) ;
2010-12-15 05:42:23 +00:00
/* since ui is defined the auto-layout args are not used */
uiLayoutOperatorButs ( C , layout , op , NULL , ' V ' , 0 ) ;
2009-12-06 04:35:00 +00:00
2011-04-03 13:17:07 +00:00
uiPopupBoundsBlock ( block , 4 , 0 , 0 ) ;
2009-12-06 04:35:00 +00:00
uiEndBlock ( C , block ) ;
return block ;
}
2011-01-19 14:19:20 +00:00
/* operator menu needs undo, for redo callback */
2010-10-16 02:40:31 +00:00
int WM_operator_props_popup ( bContext * C , wmOperator * op , wmEvent * UNUSED ( event ) )
2009-04-01 14:02:06 +00:00
{
2010-10-31 14:43:30 +00:00
if ( ( op - > type - > flag & OPTYPE_REGISTER ) = = 0 ) {
BKE_reportf ( op - > reports , RPT_ERROR , " Operator '%s' does not have register enabled, incorrect invoke function. " , op - > type - > idname ) ;
return OPERATOR_CANCELLED ;
}
2011-01-19 14:19:20 +00:00
ED_undo_push_op ( C , op ) ;
wm_operator_register ( C , op ) ;
WM_operator_props_popup was calling ED_undo_push_op() which is also called by wm_operator_finished.
This made new image operator and seperate image sequence call ED_undo_push_op() twice.
Tested with move to layer and python select pattern operators and it works ok.
including backtraces for the double calls just incase.
# first
#2 0x00000000009ff4c4 in ED_undo_push_op (C=0x20e1098, op=0x3ea13a8) at /media/data/blender_ideasman42/blender_trunk/source/blender/editors/util/undo.c:187
#3 0x00000000008b5fa1 in WM_operator_props_popup (C=0x20e1098, op=0x3ea13a8, event=0x3ea0d28) at /media/data/blender_ideasman42/blender_trunk/source/blender/windowmanager/intern/wm_operators.c:1032
#4 0x00000000008be6be in wm_operator_invoke (C=0x20e1098, ot=0x2408bd8, event=0x3ea0d28, properties=0x3e943d8, reports=0x0) at /media/data/blender_ideasman42/blender_trunk/source/blender/windowmanager/intern/wm_event_system.c:613
#5 0x00000000008bfa44 in wm_handler_operator_call (C=0x20e1098, handlers=0x25509a0, handler=0x25cb658, event=0x3ea0d28, properties=0x3e943d8) at /media/data/blender_ideasman42/blender_trunk/source/blender/windowmanager/intern/wm_event_system.c:1158
# second
#2 0x00000000009ff4c4 in ED_undo_push_op (C=0x20e1098, op=0x3ea13a8) at /media/data/blender_ideasman42/blender_trunk/source/blender/editors/util/undo.c:187
#3 0x00000000008bde8e in wm_operator_finished (C=0x20e1098, op=0x3ea13a8, repeat=0) at /media/data/blender_ideasman42/blender_trunk/source/blender/windowmanager/intern/wm_event_system.c:439
#4 0x00000000008be82a in wm_operator_invoke (C=0x20e1098, ot=0x2408bd8, event=0x3ea0d28, properties=0x3e943d8, reports=0x0) at /media/data/blender_ideasman42/blender_trunk/source/blender/windowmanager/intern/wm_event_system.c:640
#5 0x00000000008bfa44 in wm_handler_operator_call (C=0x20e1098, handlers=0x25509a0, handler=0x25cb658, event=0x3ea0d28, properties=0x3e943d8) at /media/data/blender_ideasman42/blender_trunk/source/blender/windowmanager/intern/wm_event_system.c:1158
2010-07-03 12:55:03 +00:00
2011-01-19 14:19:20 +00:00
uiPupBlock ( C , wm_block_create_redo , op ) ;
2009-04-01 14:02:06 +00:00
2011-01-19 14:19:20 +00:00
return OPERATOR_RUNNING_MODAL ;
2009-04-01 14:02:06 +00:00
}
2010-03-20 18:03:59 +00:00
int WM_operator_props_dialog_popup ( bContext * C , wmOperator * op , int width , int height )
{
struct { wmOperator * op ; int width ; int height ; } data ;
data . op = op ;
data . width = width ;
data . height = height ;
/* op is not executed until popup OK but is clicked */
uiPupBlock ( C , wm_block_create_dialog , & data ) ;
return OPERATOR_RUNNING_MODAL ;
}
int WM_operator_ui_popup ( bContext * C , wmOperator * op , int width , int height )
2009-12-06 04:35:00 +00:00
{
struct { wmOperator * op ; int width ; int height ; } data ;
data . op = op ;
data . width = width ;
data . height = height ;
uiPupBlock ( C , wm_operator_create_ui , & data ) ;
2010-03-20 18:03:59 +00:00
return OPERATOR_RUNNING_MODAL ;
2009-12-06 04:35:00 +00:00
}
2009-04-01 14:02:06 +00:00
int WM_operator_redo_popup ( bContext * C , wmOperator * op )
{
2011-04-01 12:51:04 +00:00
/* CTX_wm_reports(C) because operator is on stack, not active in event system */
2010-10-31 14:43:30 +00:00
if ( ( op - > type - > flag & OPTYPE_REGISTER ) = = 0 ) {
2011-04-01 12:51:04 +00:00
BKE_reportf ( CTX_wm_reports ( C ) , RPT_ERROR , " Operator redo '%s' does not have register enabled, incorrect invoke function. " , op - > type - > idname ) ;
return OPERATOR_CANCELLED ;
}
if ( op - > type - > poll & & op - > type - > poll ( C ) = = 0 ) {
BKE_reportf ( CTX_wm_reports ( C ) , RPT_ERROR , " Operator redo '%s': wrong context. " , op - > type - > idname ) ;
2010-10-31 14:43:30 +00:00
return OPERATOR_CANCELLED ;
}
2009-04-01 14:02:06 +00:00
uiPupBlock ( C , wm_block_create_redo , op ) ;
return OPERATOR_CANCELLED ;
}
2009-05-22 15:02:32 +00:00
/* ***************** Debug menu ************************* */
static int wm_debug_menu_exec ( bContext * C , wmOperator * op )
{
2010-12-15 06:12:16 +00:00
G . rt = RNA_int_get ( op - > ptr , " debug_value " ) ;
2009-05-22 15:02:32 +00:00
ED_screen_refresh ( CTX_wm_manager ( C ) , CTX_wm_window ( C ) ) ;
WM_event_add_notifier ( C , NC_WINDOW , NULL ) ;
2010-12-15 06:12:16 +00:00
2009-05-22 15:02:32 +00:00
return OPERATOR_FINISHED ;
}
2010-10-16 02:40:31 +00:00
static int wm_debug_menu_invoke ( bContext * C , wmOperator * op , wmEvent * UNUSED ( event ) )
2009-05-22 15:02:32 +00:00
{
2010-12-15 06:12:16 +00:00
RNA_int_set ( op - > ptr , " debug_value " , G . rt ) ;
return WM_operator_props_dialog_popup ( C , op , 180 , 20 ) ;
2009-05-22 15:02:32 +00:00
}
static void WM_OT_debug_menu ( wmOperatorType * ot )
{
ot - > name = " Debug Menu " ;
ot - > idname = " WM_OT_debug_menu " ;
2010-02-10 21:15:44 +00:00
ot - > description = " Open a popup to set the debug level " ;
2009-05-22 15:02:32 +00:00
ot - > invoke = wm_debug_menu_invoke ;
ot - > exec = wm_debug_menu_exec ;
ot - > poll = WM_operator_winactive ;
2010-12-15 06:12:16 +00:00
RNA_def_int ( ot - > srna , " debug_value " , 0 , - 10000 , 10000 , " Debug Value " , " " , INT_MIN , INT_MAX ) ;
2009-05-22 15:02:32 +00:00
}
2009-11-23 13:58:55 +00:00
/* ***************** Splash Screen ************************* */
2010-10-16 02:40:31 +00:00
static void wm_block_splash_close ( bContext * C , void * arg_block , void * UNUSED ( arg ) )
2009-11-23 13:58:55 +00:00
{
uiPupBlockClose ( C , arg_block ) ;
}
* Interaction Presets
This adds a new presets menu in the splash screen and the Input section of
User Preferences to choose a preset interaction style, consisting of key configurations
and also other user preferences such as select mouse button, view rotation style, etc.
Currently, just 'Blender' and 'Maya' presets are included, hopefully we can have more
presets contributed (and maintained!) by the community.
It's best to keep these presets minimal to avoid too many key conflicts. In the Maya one
I changed the view manipulation key/mouse combos and also the transform
manipulator keys, not much more than that.
To save an interaction preset, open the user preferences Input section, and press the
[ + ] button next to the presets menu. It will save out a .py file containing any edited key
maps and navigation preferences to the presets/interaction folder in your scripts folder.
---
Part of this commit changes the way that key maps are exported/displayed in
preferences - now partial key configs are allowed. Previously it would export/import the
entire key configuration, regardless of whether individual key maps were edited or not
(which would make them more susceptible to conflicts in unexpected areas).
(note, in blender terminology, a key map is a category of key items, such as
'Object Mode' or 'View 2d'.)
Now, the export and the UI display work in a similar way to how key maps are
processed internally - Locally edited key maps (after pressing the 'Edit' button) are
processed first, falling back to other key maps in the current key config, and then falling
back to the default key config. So it's possible for a key config to only include a few
key maps, and the rest just gets pulled from the default key config. The preferences
UI display works like this too behind the scenes in deciding what to show users,
however using it is just like it was before, the complexity is hidden.
2010-04-14 06:27:50 +00:00
static uiBlock * wm_block_create_splash ( bContext * C , ARegion * ar , void * arg_unused ) ;
/* XXX: hack to refresh splash screen with updated prest menu name,
* since popup blocks don ' t get regenerated like panels do */
2011-02-13 14:16:36 +00:00
static void wm_block_splash_refreshmenu ( bContext * UNUSED ( C ) , void * UNUSED ( arg_block ) , void * UNUSED ( arg ) )
* Interaction Presets
This adds a new presets menu in the splash screen and the Input section of
User Preferences to choose a preset interaction style, consisting of key configurations
and also other user preferences such as select mouse button, view rotation style, etc.
Currently, just 'Blender' and 'Maya' presets are included, hopefully we can have more
presets contributed (and maintained!) by the community.
It's best to keep these presets minimal to avoid too many key conflicts. In the Maya one
I changed the view manipulation key/mouse combos and also the transform
manipulator keys, not much more than that.
To save an interaction preset, open the user preferences Input section, and press the
[ + ] button next to the presets menu. It will save out a .py file containing any edited key
maps and navigation preferences to the presets/interaction folder in your scripts folder.
---
Part of this commit changes the way that key maps are exported/displayed in
preferences - now partial key configs are allowed. Previously it would export/import the
entire key configuration, regardless of whether individual key maps were edited or not
(which would make them more susceptible to conflicts in unexpected areas).
(note, in blender terminology, a key map is a category of key items, such as
'Object Mode' or 'View 2d'.)
Now, the export and the UI display work in a similar way to how key maps are
processed internally - Locally edited key maps (after pressing the 'Edit' button) are
processed first, falling back to other key maps in the current key config, and then falling
back to the default key config. So it's possible for a key config to only include a few
key maps, and the rest just gets pulled from the default key config. The preferences
UI display works like this too behind the scenes in deciding what to show users,
however using it is just like it was before, the complexity is hidden.
2010-04-14 06:27:50 +00:00
{
2010-04-14 08:08:15 +00:00
/* ugh, causes crashes in other buttons, disabling for now until
* a better fix
* Interaction Presets
This adds a new presets menu in the splash screen and the Input section of
User Preferences to choose a preset interaction style, consisting of key configurations
and also other user preferences such as select mouse button, view rotation style, etc.
Currently, just 'Blender' and 'Maya' presets are included, hopefully we can have more
presets contributed (and maintained!) by the community.
It's best to keep these presets minimal to avoid too many key conflicts. In the Maya one
I changed the view manipulation key/mouse combos and also the transform
manipulator keys, not much more than that.
To save an interaction preset, open the user preferences Input section, and press the
[ + ] button next to the presets menu. It will save out a .py file containing any edited key
maps and navigation preferences to the presets/interaction folder in your scripts folder.
---
Part of this commit changes the way that key maps are exported/displayed in
preferences - now partial key configs are allowed. Previously it would export/import the
entire key configuration, regardless of whether individual key maps were edited or not
(which would make them more susceptible to conflicts in unexpected areas).
(note, in blender terminology, a key map is a category of key items, such as
'Object Mode' or 'View 2d'.)
Now, the export and the UI display work in a similar way to how key maps are
processed internally - Locally edited key maps (after pressing the 'Edit' button) are
processed first, falling back to other key maps in the current key config, and then falling
back to the default key config. So it's possible for a key config to only include a few
key maps, and the rest just gets pulled from the default key config. The preferences
UI display works like this too behind the scenes in deciding what to show users,
however using it is just like it was before, the complexity is hidden.
2010-04-14 06:27:50 +00:00
uiPupBlockClose ( C , arg_block ) ;
uiPupBlock ( C , wm_block_create_splash , NULL ) ;
2010-04-14 08:08:15 +00:00
*/
* Interaction Presets
This adds a new presets menu in the splash screen and the Input section of
User Preferences to choose a preset interaction style, consisting of key configurations
and also other user preferences such as select mouse button, view rotation style, etc.
Currently, just 'Blender' and 'Maya' presets are included, hopefully we can have more
presets contributed (and maintained!) by the community.
It's best to keep these presets minimal to avoid too many key conflicts. In the Maya one
I changed the view manipulation key/mouse combos and also the transform
manipulator keys, not much more than that.
To save an interaction preset, open the user preferences Input section, and press the
[ + ] button next to the presets menu. It will save out a .py file containing any edited key
maps and navigation preferences to the presets/interaction folder in your scripts folder.
---
Part of this commit changes the way that key maps are exported/displayed in
preferences - now partial key configs are allowed. Previously it would export/import the
entire key configuration, regardless of whether individual key maps were edited or not
(which would make them more susceptible to conflicts in unexpected areas).
(note, in blender terminology, a key map is a category of key items, such as
'Object Mode' or 'View 2d'.)
Now, the export and the UI display work in a similar way to how key maps are
processed internally - Locally edited key maps (after pressing the 'Edit' button) are
processed first, falling back to other key maps in the current key config, and then falling
back to the default key config. So it's possible for a key config to only include a few
key maps, and the rest just gets pulled from the default key config. The preferences
UI display works like this too behind the scenes in deciding what to show users,
however using it is just like it was before, the complexity is hidden.
2010-04-14 06:27:50 +00:00
}
2011-04-11 15:13:06 +00:00
static int wm_resource_check_prev ( void )
{
char * res = BLI_get_folder_version ( BLENDER_RESOURCE_PATH_USER , BLENDER_VERSION , TRUE ) ;
// if(res) printf("USER: %s\n", res);
2011-04-12 14:57:02 +00:00
#if 0 /* ignore the local folder */
2011-04-11 15:13:06 +00:00
if ( res = = NULL ) {
2011-04-12 04:23:38 +00:00
/* with a local dir, copying old files isnt useful since local dir get priority for config */
2011-04-11 15:13:06 +00:00
res = BLI_get_folder_version ( BLENDER_RESOURCE_PATH_LOCAL , BLENDER_VERSION , TRUE ) ;
}
2011-04-12 14:57:02 +00:00
# endif
2011-04-11 15:13:06 +00:00
// if(res) printf("LOCAL: %s\n", res);
2011-04-12 04:23:38 +00:00
if ( res ) {
return FALSE ;
}
else {
return ( BLI_get_folder_version ( BLENDER_RESOURCE_PATH_USER , BLENDER_VERSION - 1 , TRUE ) ! = NULL ) ;
2011-04-11 15:13:06 +00:00
}
}
2010-10-16 02:40:31 +00:00
static uiBlock * wm_block_create_splash ( bContext * C , ARegion * ar , void * UNUSED ( arg ) )
2009-11-23 13:58:55 +00:00
{
uiBlock * block ;
uiBut * but ;
uiLayout * layout , * split , * col ;
uiStyle * style = U . uistyles . first ;
2009-12-28 10:44:02 +00:00
struct RecentFile * recent ;
2010-01-11 10:48:41 +00:00
int i ;
* Interaction Presets
This adds a new presets menu in the splash screen and the Input section of
User Preferences to choose a preset interaction style, consisting of key configurations
and also other user preferences such as select mouse button, view rotation style, etc.
Currently, just 'Blender' and 'Maya' presets are included, hopefully we can have more
presets contributed (and maintained!) by the community.
It's best to keep these presets minimal to avoid too many key conflicts. In the Maya one
I changed the view manipulation key/mouse combos and also the transform
manipulator keys, not much more than that.
To save an interaction preset, open the user preferences Input section, and press the
[ + ] button next to the presets menu. It will save out a .py file containing any edited key
maps and navigation preferences to the presets/interaction folder in your scripts folder.
---
Part of this commit changes the way that key maps are exported/displayed in
preferences - now partial key configs are allowed. Previously it would export/import the
entire key configuration, regardless of whether individual key maps were edited or not
(which would make them more susceptible to conflicts in unexpected areas).
(note, in blender terminology, a key map is a category of key items, such as
'Object Mode' or 'View 2d'.)
Now, the export and the UI display work in a similar way to how key maps are
processed internally - Locally edited key maps (after pressing the 'Edit' button) are
processed first, falling back to other key maps in the current key config, and then falling
back to the default key config. So it's possible for a key config to only include a few
key maps, and the rest just gets pulled from the default key config. The preferences
UI display works like this too behind the scenes in deciding what to show users,
however using it is just like it was before, the complexity is hidden.
2010-04-14 06:27:50 +00:00
MenuType * mt = WM_menutype_find ( " USERPREF_MT_splash " , TRUE ) ;
2011-04-12 16:20:41 +00:00
char url [ 96 ] ;
* Interaction Presets
This adds a new presets menu in the splash screen and the Input section of
User Preferences to choose a preset interaction style, consisting of key configurations
and also other user preferences such as select mouse button, view rotation style, etc.
Currently, just 'Blender' and 'Maya' presets are included, hopefully we can have more
presets contributed (and maintained!) by the community.
It's best to keep these presets minimal to avoid too many key conflicts. In the Maya one
I changed the view manipulation key/mouse combos and also the transform
manipulator keys, not much more than that.
To save an interaction preset, open the user preferences Input section, and press the
[ + ] button next to the presets menu. It will save out a .py file containing any edited key
maps and navigation preferences to the presets/interaction folder in your scripts folder.
---
Part of this commit changes the way that key maps are exported/displayed in
preferences - now partial key configs are allowed. Previously it would export/import the
entire key configuration, regardless of whether individual key maps were edited or not
(which would make them more susceptible to conflicts in unexpected areas).
(note, in blender terminology, a key map is a category of key items, such as
'Object Mode' or 'View 2d'.)
Now, the export and the UI display work in a similar way to how key maps are
processed internally - Locally edited key maps (after pressing the 'Edit' button) are
processed first, falling back to other key maps in the current key config, and then falling
back to the default key config. So it's possible for a key config to only include a few
key maps, and the rest just gets pulled from the default key config. The preferences
UI display works like this too behind the scenes in deciding what to show users,
however using it is just like it was before, the complexity is hidden.
2010-04-14 06:27:50 +00:00
2010-01-11 10:48:41 +00:00
# ifdef NAN_BUILDINFO
int ver_width , rev_width ;
2010-01-08 05:51:51 +00:00
char * version_str = NULL ;
char * revision_str = NULL ;
char version_buf [ 128 ] ;
char revision_buf [ 128 ] ;
2010-03-14 17:18:36 +00:00
extern char build_rev [ ] ;
2010-01-08 05:51:51 +00:00
version_str = & version_buf [ 0 ] ;
revision_str = & revision_buf [ 0 ] ;
sprintf ( version_str , " %d.%02d.%d " , BLENDER_VERSION / 100 , BLENDER_VERSION % 100 , BLENDER_SUBVERSION ) ;
sprintf ( revision_str , " r%s " , build_rev ) ;
BugFix:
[#20854] PROPERTIES STAMP: Rendering stamp flickers in output renders
Blenfont was not thread safe, that is why one thread can change
the font properties (size, dpi, color, etc) at the same time
that the stamp draw on the image, and then the problem.
To make blenfont thread safe I have to change two important things:
1) Every BLF_* function take one argument, the font id.
2) We have two new function to make font "thread safe":
BLF_load_unique
BLF_load_mem_unique
This two function are for case like stamp, that need and own font
that don't share the glyph cache, so can draw without problem
in a different thread.
Why the BLF_*_unique function ?
Because blenfont keep only one copy of a font and keep a list of
"glyph cache". Every glyph cache have size and dpi, so if two
different thread access the same font at the same time, they can
change value and finish with something like the stamp problem.
Why don't remove the glyph cache ?
Because if we do that, we finish with a font object for every size
and dpi, and the stamp is really a special case that happen in
the rendering process, so I really thing is better keep the
glyph cache and make this two new function to handle this
special case.
(When I say "font object" I mean have the same freetype font multiple
times just to have differents size and dpi)
As Matt point we still can have one case that two thread access
the BLF_*_unique function at the same time, but I am looking to
fix this with some class of thread lock.
For now I test and work fine, so if some one found problem, please
let me know.
Campbell I have to change the python api (python/generic/blf_api.c)
to the new syntax, so maybe you can take a look at this.
2010-04-22 10:56:45 +00:00
BLF_size ( style - > widgetlabel . uifont_id , style - > widgetlabel . points , U . dpi ) ;
2011-04-06 06:03:48 +00:00
ver_width = ( int ) BLF_width ( style - > widgetlabel . uifont_id , version_str ) + 5 ;
rev_width = ( int ) BLF_width ( style - > widgetlabel . uifont_id , revision_str ) + 5 ;
2010-01-10 20:16:56 +00:00
# endif //NAN_BUILDINFO
2010-01-08 06:05:42 +00:00
2009-11-23 13:58:55 +00:00
block = uiBeginBlock ( C , ar , " _popup " , UI_EMBOSS ) ;
* Interaction Presets
This adds a new presets menu in the splash screen and the Input section of
User Preferences to choose a preset interaction style, consisting of key configurations
and also other user preferences such as select mouse button, view rotation style, etc.
Currently, just 'Blender' and 'Maya' presets are included, hopefully we can have more
presets contributed (and maintained!) by the community.
It's best to keep these presets minimal to avoid too many key conflicts. In the Maya one
I changed the view manipulation key/mouse combos and also the transform
manipulator keys, not much more than that.
To save an interaction preset, open the user preferences Input section, and press the
[ + ] button next to the presets menu. It will save out a .py file containing any edited key
maps and navigation preferences to the presets/interaction folder in your scripts folder.
---
Part of this commit changes the way that key maps are exported/displayed in
preferences - now partial key configs are allowed. Previously it would export/import the
entire key configuration, regardless of whether individual key maps were edited or not
(which would make them more susceptible to conflicts in unexpected areas).
(note, in blender terminology, a key map is a category of key items, such as
'Object Mode' or 'View 2d'.)
Now, the export and the UI display work in a similar way to how key maps are
processed internally - Locally edited key maps (after pressing the 'Edit' button) are
processed first, falling back to other key maps in the current key config, and then falling
back to the default key config. So it's possible for a key config to only include a few
key maps, and the rest just gets pulled from the default key config. The preferences
UI display works like this too behind the scenes in deciding what to show users,
however using it is just like it was before, the complexity is hidden.
2010-04-14 06:27:50 +00:00
uiBlockSetFlag ( block , UI_BLOCK_KEEP_OPEN ) ;
2009-11-23 13:58:55 +00:00
but = uiDefBut ( block , BUT_IMAGE , 0 , " " , 0 , 10 , 501 , 282 , NULL , 0.0 , 0.0 , 0 , 0 , " " ) ;
uiButSetFunc ( but , wm_block_splash_close , block , NULL ) ;
* Interaction Presets
This adds a new presets menu in the splash screen and the Input section of
User Preferences to choose a preset interaction style, consisting of key configurations
and also other user preferences such as select mouse button, view rotation style, etc.
Currently, just 'Blender' and 'Maya' presets are included, hopefully we can have more
presets contributed (and maintained!) by the community.
It's best to keep these presets minimal to avoid too many key conflicts. In the Maya one
I changed the view manipulation key/mouse combos and also the transform
manipulator keys, not much more than that.
To save an interaction preset, open the user preferences Input section, and press the
[ + ] button next to the presets menu. It will save out a .py file containing any edited key
maps and navigation preferences to the presets/interaction folder in your scripts folder.
---
Part of this commit changes the way that key maps are exported/displayed in
preferences - now partial key configs are allowed. Previously it would export/import the
entire key configuration, regardless of whether individual key maps were edited or not
(which would make them more susceptible to conflicts in unexpected areas).
(note, in blender terminology, a key map is a category of key items, such as
'Object Mode' or 'View 2d'.)
Now, the export and the UI display work in a similar way to how key maps are
processed internally - Locally edited key maps (after pressing the 'Edit' button) are
processed first, falling back to other key maps in the current key config, and then falling
back to the default key config. So it's possible for a key config to only include a few
key maps, and the rest just gets pulled from the default key config. The preferences
UI display works like this too behind the scenes in deciding what to show users,
however using it is just like it was before, the complexity is hidden.
2010-04-14 06:27:50 +00:00
uiBlockSetFunc ( block , wm_block_splash_refreshmenu , block , NULL ) ;
2009-11-23 13:58:55 +00:00
2010-01-08 06:05:42 +00:00
# ifdef NAN_BUILDINFO
* Interaction Presets
This adds a new presets menu in the splash screen and the Input section of
User Preferences to choose a preset interaction style, consisting of key configurations
and also other user preferences such as select mouse button, view rotation style, etc.
Currently, just 'Blender' and 'Maya' presets are included, hopefully we can have more
presets contributed (and maintained!) by the community.
It's best to keep these presets minimal to avoid too many key conflicts. In the Maya one
I changed the view manipulation key/mouse combos and also the transform
manipulator keys, not much more than that.
To save an interaction preset, open the user preferences Input section, and press the
[ + ] button next to the presets menu. It will save out a .py file containing any edited key
maps and navigation preferences to the presets/interaction folder in your scripts folder.
---
Part of this commit changes the way that key maps are exported/displayed in
preferences - now partial key configs are allowed. Previously it would export/import the
entire key configuration, regardless of whether individual key maps were edited or not
(which would make them more susceptible to conflicts in unexpected areas).
(note, in blender terminology, a key map is a category of key items, such as
'Object Mode' or 'View 2d'.)
Now, the export and the UI display work in a similar way to how key maps are
processed internally - Locally edited key maps (after pressing the 'Edit' button) are
processed first, falling back to other key maps in the current key config, and then falling
back to the default key config. So it's possible for a key config to only include a few
key maps, and the rest just gets pulled from the default key config. The preferences
UI display works like this too behind the scenes in deciding what to show users,
however using it is just like it was before, the complexity is hidden.
2010-04-14 06:27:50 +00:00
uiDefBut ( block , LABEL , 0 , version_str , 494 - ver_width , 282 - 24 , ver_width , 20 , NULL , 0 , 0 , 0 , 0 , NULL ) ;
uiDefBut ( block , LABEL , 0 , revision_str , 494 - rev_width , 282 - 36 , rev_width , 20 , NULL , 0 , 0 , 0 , 0 , NULL ) ;
2010-01-10 20:16:56 +00:00
# endif //NAN_BUILDINFO
2010-01-08 06:05:42 +00:00
* Interaction Presets
This adds a new presets menu in the splash screen and the Input section of
User Preferences to choose a preset interaction style, consisting of key configurations
and also other user preferences such as select mouse button, view rotation style, etc.
Currently, just 'Blender' and 'Maya' presets are included, hopefully we can have more
presets contributed (and maintained!) by the community.
It's best to keep these presets minimal to avoid too many key conflicts. In the Maya one
I changed the view manipulation key/mouse combos and also the transform
manipulator keys, not much more than that.
To save an interaction preset, open the user preferences Input section, and press the
[ + ] button next to the presets menu. It will save out a .py file containing any edited key
maps and navigation preferences to the presets/interaction folder in your scripts folder.
---
Part of this commit changes the way that key maps are exported/displayed in
preferences - now partial key configs are allowed. Previously it would export/import the
entire key configuration, regardless of whether individual key maps were edited or not
(which would make them more susceptible to conflicts in unexpected areas).
(note, in blender terminology, a key map is a category of key items, such as
'Object Mode' or 'View 2d'.)
Now, the export and the UI display work in a similar way to how key maps are
processed internally - Locally edited key maps (after pressing the 'Edit' button) are
processed first, falling back to other key maps in the current key config, and then falling
back to the default key config. So it's possible for a key config to only include a few
key maps, and the rest just gets pulled from the default key config. The preferences
UI display works like this too behind the scenes in deciding what to show users,
however using it is just like it was before, the complexity is hidden.
2010-04-14 06:27:50 +00:00
layout = uiBlockLayout ( block , UI_LAYOUT_VERTICAL , UI_LAYOUT_PANEL , 10 , 2 , 480 , 110 , style ) ;
2010-01-08 05:51:51 +00:00
* Interaction Presets
This adds a new presets menu in the splash screen and the Input section of
User Preferences to choose a preset interaction style, consisting of key configurations
and also other user preferences such as select mouse button, view rotation style, etc.
Currently, just 'Blender' and 'Maya' presets are included, hopefully we can have more
presets contributed (and maintained!) by the community.
It's best to keep these presets minimal to avoid too many key conflicts. In the Maya one
I changed the view manipulation key/mouse combos and also the transform
manipulator keys, not much more than that.
To save an interaction preset, open the user preferences Input section, and press the
[ + ] button next to the presets menu. It will save out a .py file containing any edited key
maps and navigation preferences to the presets/interaction folder in your scripts folder.
---
Part of this commit changes the way that key maps are exported/displayed in
preferences - now partial key configs are allowed. Previously it would export/import the
entire key configuration, regardless of whether individual key maps were edited or not
(which would make them more susceptible to conflicts in unexpected areas).
(note, in blender terminology, a key map is a category of key items, such as
'Object Mode' or 'View 2d'.)
Now, the export and the UI display work in a similar way to how key maps are
processed internally - Locally edited key maps (after pressing the 'Edit' button) are
processed first, falling back to other key maps in the current key config, and then falling
back to the default key config. So it's possible for a key config to only include a few
key maps, and the rest just gets pulled from the default key config. The preferences
UI display works like this too behind the scenes in deciding what to show users,
however using it is just like it was before, the complexity is hidden.
2010-04-14 06:27:50 +00:00
uiBlockSetEmboss ( block , UI_EMBOSS ) ;
/* show the splash menu (containing interaction presets), using python */
if ( mt ) {
2011-03-03 17:59:04 +00:00
Menu menu = { NULL } ;
* Interaction Presets
This adds a new presets menu in the splash screen and the Input section of
User Preferences to choose a preset interaction style, consisting of key configurations
and also other user preferences such as select mouse button, view rotation style, etc.
Currently, just 'Blender' and 'Maya' presets are included, hopefully we can have more
presets contributed (and maintained!) by the community.
It's best to keep these presets minimal to avoid too many key conflicts. In the Maya one
I changed the view manipulation key/mouse combos and also the transform
manipulator keys, not much more than that.
To save an interaction preset, open the user preferences Input section, and press the
[ + ] button next to the presets menu. It will save out a .py file containing any edited key
maps and navigation preferences to the presets/interaction folder in your scripts folder.
---
Part of this commit changes the way that key maps are exported/displayed in
preferences - now partial key configs are allowed. Previously it would export/import the
entire key configuration, regardless of whether individual key maps were edited or not
(which would make them more susceptible to conflicts in unexpected areas).
(note, in blender terminology, a key map is a category of key items, such as
'Object Mode' or 'View 2d'.)
Now, the export and the UI display work in a similar way to how key maps are
processed internally - Locally edited key maps (after pressing the 'Edit' button) are
processed first, falling back to other key maps in the current key config, and then falling
back to the default key config. So it's possible for a key config to only include a few
key maps, and the rest just gets pulled from the default key config. The preferences
UI display works like this too behind the scenes in deciding what to show users,
however using it is just like it was before, the complexity is hidden.
2010-04-14 06:27:50 +00:00
menu . layout = layout ;
menu . type = mt ;
mt - > draw ( C , & menu ) ;
2010-10-06 20:29:00 +00:00
// wmWindowManager *wm= CTX_wm_manager(C);
2011-02-27 18:03:19 +00:00
// uiItemM(layout, C, "USERPREF_MT_keyconfigs", U.keyconfigstr, ICON_NONE);
* Interaction Presets
This adds a new presets menu in the splash screen and the Input section of
User Preferences to choose a preset interaction style, consisting of key configurations
and also other user preferences such as select mouse button, view rotation style, etc.
Currently, just 'Blender' and 'Maya' presets are included, hopefully we can have more
presets contributed (and maintained!) by the community.
It's best to keep these presets minimal to avoid too many key conflicts. In the Maya one
I changed the view manipulation key/mouse combos and also the transform
manipulator keys, not much more than that.
To save an interaction preset, open the user preferences Input section, and press the
[ + ] button next to the presets menu. It will save out a .py file containing any edited key
maps and navigation preferences to the presets/interaction folder in your scripts folder.
---
Part of this commit changes the way that key maps are exported/displayed in
preferences - now partial key configs are allowed. Previously it would export/import the
entire key configuration, regardless of whether individual key maps were edited or not
(which would make them more susceptible to conflicts in unexpected areas).
(note, in blender terminology, a key map is a category of key items, such as
'Object Mode' or 'View 2d'.)
Now, the export and the UI display work in a similar way to how key maps are
processed internally - Locally edited key maps (after pressing the 'Edit' button) are
processed first, falling back to other key maps in the current key config, and then falling
back to the default key config. So it's possible for a key config to only include a few
key maps, and the rest just gets pulled from the default key config. The preferences
UI display works like this too behind the scenes in deciding what to show users,
however using it is just like it was before, the complexity is hidden.
2010-04-14 06:27:50 +00:00
}
2009-11-23 13:58:55 +00:00
* Interaction Presets
This adds a new presets menu in the splash screen and the Input section of
User Preferences to choose a preset interaction style, consisting of key configurations
and also other user preferences such as select mouse button, view rotation style, etc.
Currently, just 'Blender' and 'Maya' presets are included, hopefully we can have more
presets contributed (and maintained!) by the community.
It's best to keep these presets minimal to avoid too many key conflicts. In the Maya one
I changed the view manipulation key/mouse combos and also the transform
manipulator keys, not much more than that.
To save an interaction preset, open the user preferences Input section, and press the
[ + ] button next to the presets menu. It will save out a .py file containing any edited key
maps and navigation preferences to the presets/interaction folder in your scripts folder.
---
Part of this commit changes the way that key maps are exported/displayed in
preferences - now partial key configs are allowed. Previously it would export/import the
entire key configuration, regardless of whether individual key maps were edited or not
(which would make them more susceptible to conflicts in unexpected areas).
(note, in blender terminology, a key map is a category of key items, such as
'Object Mode' or 'View 2d'.)
Now, the export and the UI display work in a similar way to how key maps are
processed internally - Locally edited key maps (after pressing the 'Edit' button) are
processed first, falling back to other key maps in the current key config, and then falling
back to the default key config. So it's possible for a key config to only include a few
key maps, and the rest just gets pulled from the default key config. The preferences
UI display works like this too behind the scenes in deciding what to show users,
however using it is just like it was before, the complexity is hidden.
2010-04-14 06:27:50 +00:00
uiBlockSetEmboss ( block , UI_EMBOSSP ) ;
2009-11-23 13:58:55 +00:00
uiLayoutSetOperatorContext ( layout , WM_OP_EXEC_REGION_WIN ) ;
2009-12-10 14:47:07 +00:00
split = uiLayoutSplit ( layout , 0 , 0 ) ;
2009-11-23 13:58:55 +00:00
col = uiLayoutColumn ( split , 0 ) ;
2011-02-27 18:03:19 +00:00
uiItemL ( col , " Links " , ICON_NONE ) ;
2010-07-21 11:12:26 +00:00
uiItemStringO ( col , " Donations " , ICON_URL , " WM_OT_url_open " , " url " , " http://www.blender.org/blenderorg/blender-foundation/donation-payment/ " ) ;
2011-04-12 21:17:31 +00:00
uiItemStringO ( col , " Release Log " , ICON_URL , " WM_OT_url_open " , " url " , " http://www.blender.org/development/release-logs/blender-257/ " ) ;
2011-05-03 07:51:07 +00:00
uiItemStringO ( col , " Manual " , ICON_URL , " WM_OT_url_open " , " url " , " http://wiki.blender.org/index.php/Doc:2.5/Manual " ) ;
2010-05-31 11:38:13 +00:00
uiItemStringO ( col , " Blender Website " , ICON_URL , " WM_OT_url_open " , " url " , " http://www.blender.org/ " ) ;
2010-09-11 04:23:45 +00:00
uiItemStringO ( col , " User Community " , ICON_URL , " WM_OT_url_open " , " url " , " http://www.blender.org/community/user-community/ " ) ; //
2011-04-12 16:20:41 +00:00
if ( strcmp ( STRINGIFY ( BLENDER_VERSION_CYCLE ) , " release " ) = = 0 ) {
BLI_snprintf ( url , sizeof ( url ) , " http://www.blender.org/documentation/blender_python_api_%d_%d " STRINGIFY ( BLENDER_VERSION_CHAR ) " _release " , BLENDER_VERSION / 100 , BLENDER_VERSION % 100 ) ;
}
else {
BLI_snprintf ( url , sizeof ( url ) , " http://www.blender.org/documentation/blender_python_api_%d_%d_%d " , BLENDER_VERSION / 100 , BLENDER_VERSION % 100 , BLENDER_SUBVERSION ) ;
}
2010-09-11 04:23:45 +00:00
uiItemStringO ( col , " Python API Reference " , ICON_URL , " WM_OT_url_open " , " url " , url ) ;
2011-02-27 18:03:19 +00:00
uiItemL ( col , " " , ICON_NONE ) ;
2010-09-11 04:23:45 +00:00
2009-11-23 13:58:55 +00:00
col = uiLayoutColumn ( split , 0 ) ;
2011-04-11 15:13:06 +00:00
if ( wm_resource_check_prev ( ) ) {
uiItemO ( col , NULL , ICON_NEW , " WM_OT_copy_prev_settings " ) ;
2011-04-12 04:23:38 +00:00
uiItemS ( col ) ;
}
uiItemL ( col , " Recent " , ICON_NONE ) ;
for ( recent = G . recent_files . first , i = 0 ; ( i < 5 ) & & ( recent ) ; recent = recent - > next , i + + ) {
uiItemStringO ( col , BLI_path_basename ( recent - > filepath ) , ICON_FILE_BLEND , " WM_OT_open_mainfile " , " filepath " , recent - > filepath ) ;
2011-04-11 15:13:06 +00:00
}
2010-03-18 07:05:20 +00:00
uiItemS ( col ) ;
2010-05-03 03:33:20 +00:00
uiItemO ( col , NULL , ICON_RECOVER_LAST , " WM_OT_recover_last_session " ) ;
2011-02-27 18:03:19 +00:00
uiItemL ( col , " " , ICON_NONE ) ;
* Interaction Presets
This adds a new presets menu in the splash screen and the Input section of
User Preferences to choose a preset interaction style, consisting of key configurations
and also other user preferences such as select mouse button, view rotation style, etc.
Currently, just 'Blender' and 'Maya' presets are included, hopefully we can have more
presets contributed (and maintained!) by the community.
It's best to keep these presets minimal to avoid too many key conflicts. In the Maya one
I changed the view manipulation key/mouse combos and also the transform
manipulator keys, not much more than that.
To save an interaction preset, open the user preferences Input section, and press the
[ + ] button next to the presets menu. It will save out a .py file containing any edited key
maps and navigation preferences to the presets/interaction folder in your scripts folder.
---
Part of this commit changes the way that key maps are exported/displayed in
preferences - now partial key configs are allowed. Previously it would export/import the
entire key configuration, regardless of whether individual key maps were edited or not
(which would make them more susceptible to conflicts in unexpected areas).
(note, in blender terminology, a key map is a category of key items, such as
'Object Mode' or 'View 2d'.)
Now, the export and the UI display work in a similar way to how key maps are
processed internally - Locally edited key maps (after pressing the 'Edit' button) are
processed first, falling back to other key maps in the current key config, and then falling
back to the default key config. So it's possible for a key config to only include a few
key maps, and the rest just gets pulled from the default key config. The preferences
UI display works like this too behind the scenes in deciding what to show users,
however using it is just like it was before, the complexity is hidden.
2010-04-14 06:27:50 +00:00
2011-04-10 09:37:04 +00:00
uiCenteredBoundsBlock ( block , 0 ) ;
2009-11-23 13:58:55 +00:00
uiEndBlock ( C , block ) ;
return block ;
}
2010-10-16 02:40:31 +00:00
static int wm_splash_invoke ( bContext * C , wmOperator * UNUSED ( op ) , wmEvent * UNUSED ( event ) )
2009-11-23 13:58:55 +00:00
{
uiPupBlock ( C , wm_block_create_splash , NULL ) ;
return OPERATOR_FINISHED ;
}
static void WM_OT_splash ( wmOperatorType * ot )
{
ot - > name = " Splash Screen " ;
ot - > idname = " WM_OT_splash " ;
ot - > description = " Opens a blocking popup region with release info " ;
ot - > invoke = wm_splash_invoke ;
ot - > poll = WM_operator_winactive ;
}
2009-06-03 18:31:37 +00:00
/* ***************** Search menu ************************* */
2010-10-16 02:40:31 +00:00
static void operator_call_cb ( struct bContext * C , void * UNUSED ( arg1 ) , void * arg2 )
2009-06-03 18:31:37 +00:00
{
wmOperatorType * ot = arg2 ;
if ( ot )
WM_operator_name_call ( C , ot - > idname , WM_OP_INVOKE_DEFAULT , NULL ) ;
}
2010-11-17 09:45:45 +00:00
static void operator_search_cb ( const struct bContext * C , void * UNUSED ( arg ) , const char * str , uiSearchItems * items )
2009-06-03 18:31:37 +00:00
{
wmOperatorType * ot = WM_operatortype_first ( ) ;
for ( ; ot ; ot = ot - > next ) {
if ( BLI_strcasestr ( ot - > name , str ) ) {
2009-09-18 13:02:20 +00:00
if ( WM_operator_poll ( ( bContext * ) C , ot ) ) {
2009-06-03 18:31:37 +00:00
char name [ 256 ] ;
int len = strlen ( ot - > name ) ;
/* display name for menu, can hold hotkey */
BLI_strncpy ( name , ot - > name , 256 ) ;
/* check for hotkey */
if ( len < 256 - 6 ) {
if ( WM_key_event_operator_string ( C , ot - > idname , WM_OP_EXEC_DEFAULT , NULL , & name [ len + 1 ] , 256 - len - 1 ) )
name [ len ] = ' | ' ;
}
2009-06-24 16:44:54 +00:00
if ( 0 = = uiSearchItemAdd ( items , name , ot , 0 ) )
2009-06-03 18:31:37 +00:00
break ;
}
}
}
}
2010-10-16 02:40:31 +00:00
static uiBlock * wm_block_search_menu ( bContext * C , ARegion * ar , void * UNUSED ( arg_op ) )
2009-06-03 18:31:37 +00:00
{
static char search [ 256 ] = " " ;
wmEvent event ;
wmWindow * win = CTX_wm_window ( C ) ;
uiBlock * block ;
uiBut * but ;
block = uiBeginBlock ( C , ar , " _popup " , UI_EMBOSS ) ;
2009-11-23 13:58:55 +00:00
uiBlockSetFlag ( block , UI_BLOCK_LOOP | UI_BLOCK_RET_1 | UI_BLOCK_MOVEMOUSE_QUIT ) ;
2009-06-03 18:31:37 +00:00
2010-01-03 08:37:18 +00:00
but = uiDefSearchBut ( block , search , 0 , ICON_VIEWZOOM , 256 , 10 , 10 , 180 , 19 , 0 , 0 , " " ) ;
2009-06-29 19:37:09 +00:00
uiButSetSearchFunc ( but , operator_search_cb , NULL , operator_call_cb , NULL ) ;
2009-06-03 18:31:37 +00:00
2009-06-05 16:11:18 +00:00
/* fake button, it holds space for search items */
uiDefBut ( block , LABEL , 0 , " " , 10 , 10 - uiSearchBoxhHeight ( ) , 180 , uiSearchBoxhHeight ( ) , NULL , 0 , 0 , 0 , 0 , NULL ) ;
2011-04-03 13:17:07 +00:00
uiPopupBoundsBlock ( block , 6 , 0 , - 20 ) ; /* move it downwards, mouse over button */
2009-06-03 18:31:37 +00:00
uiEndBlock ( C , block ) ;
event = * ( win - > eventstate ) ; /* XXX huh huh? make api call */
event . type = EVT_BUT_OPEN ;
event . val = KM_PRESS ;
event . customdata = but ;
event . customdatafree = FALSE ;
wm_event_add ( win , & event ) ;
return block ;
}
2010-10-16 02:40:31 +00:00
static int wm_search_menu_exec ( bContext * UNUSED ( C ) , wmOperator * UNUSED ( op ) )
2009-06-03 18:31:37 +00:00
{
return OPERATOR_FINISHED ;
}
2010-10-16 02:40:31 +00:00
static int wm_search_menu_invoke ( bContext * C , wmOperator * op , wmEvent * UNUSED ( event ) )
2009-06-03 18:31:37 +00:00
{
uiPupBlock ( C , wm_block_search_menu , op ) ;
return OPERATOR_CANCELLED ;
}
2009-07-28 08:50:11 +00:00
/* op->poll */
2009-09-14 16:52:06 +00:00
static int wm_search_menu_poll ( bContext * C )
2009-07-28 08:50:11 +00:00
{
if ( CTX_wm_window ( C ) = = NULL ) return 0 ;
if ( CTX_wm_area ( C ) & & CTX_wm_area ( C ) - > spacetype = = SPACE_CONSOLE ) return 0 ; // XXX - so we can use the shortcut in the console
2009-08-23 07:33:29 +00:00
if ( CTX_wm_area ( C ) & & CTX_wm_area ( C ) - > spacetype = = SPACE_TEXT ) return 0 ; // XXX - so we can use the spacebar in the text editor
2010-03-14 12:12:48 +00:00
if ( CTX_data_edit_object ( C ) & & CTX_data_edit_object ( C ) - > type = = OB_FONT ) return 0 ; // XXX - so we can use the spacebar for entering text
2009-07-28 08:50:11 +00:00
return 1 ;
}
2009-06-03 18:31:37 +00:00
static void WM_OT_search_menu ( wmOperatorType * ot )
{
ot - > name = " Search Menu " ;
ot - > idname = " WM_OT_search_menu " ;
ot - > invoke = wm_search_menu_invoke ;
ot - > exec = wm_search_menu_exec ;
2009-07-28 08:50:11 +00:00
ot - > poll = wm_search_menu_poll ;
2009-06-03 18:31:37 +00:00
}
2010-02-11 21:17:05 +00:00
static int wm_call_menu_exec ( bContext * C , wmOperator * op )
2009-10-06 13:04:31 +00:00
{
char idname [ BKE_ST_MAXNAME ] ;
RNA_string_get ( op - > ptr , " name " , idname ) ;
2009-10-08 19:06:32 +00:00
uiPupMenuInvoke ( C , idname ) ;
2009-10-06 13:04:31 +00:00
return OPERATOR_CANCELLED ;
}
static void WM_OT_call_menu ( wmOperatorType * ot )
{
ot - > name = " Call Menu " ;
ot - > idname = " WM_OT_call_menu " ;
2010-02-11 21:17:05 +00:00
ot - > exec = wm_call_menu_exec ;
2011-03-22 10:13:42 +00:00
ot - > poll = WM_operator_winactive ;
2009-10-06 13:04:31 +00:00
2009-12-27 17:57:24 +00:00
RNA_def_string ( ot - > srna , " name " , " " , BKE_ST_MAXNAME , " Name " , " Name of the menu " ) ;
2009-10-06 13:04:31 +00:00
}
2009-05-22 15:02:32 +00:00
2007-12-24 18:27:28 +00:00
/* ************ window / screen operator definitions ************** */
2010-01-27 09:16:28 +00:00
/* this poll functions is needed in place of WM_operator_winactive
* while it crashes on full screen */
static int wm_operator_winactive_normal ( bContext * C )
{
wmWindow * win = CTX_wm_window ( C ) ;
2010-03-22 09:30:00 +00:00
if ( win = = NULL | | win - > screen = = NULL | | win - > screen - > full ! = SCREENNORMAL )
return 0 ;
2010-01-27 09:16:28 +00:00
return 1 ;
}
2007-12-24 18:27:28 +00:00
static void WM_OT_window_duplicate ( wmOperatorType * ot )
{
ot - > name = " Duplicate Window " ;
ot - > idname = " WM_OT_window_duplicate " ;
2010-02-10 21:15:44 +00:00
ot - > description = " Duplicate the current Blender window " ;
2009-09-12 17:16:12 +00:00
2010-10-16 02:40:31 +00:00
ot - > exec = wm_window_duplicate_exec ;
2010-01-27 09:16:28 +00:00
ot - > poll = wm_operator_winactive_normal ;
2007-12-24 18:27:28 +00:00
}
static void WM_OT_save_homefile ( wmOperatorType * ot )
{
ot - > name = " Save User Settings " ;
ot - > idname = " WM_OT_save_homefile " ;
2010-02-10 21:15:44 +00:00
ot - > description = " Make the current file the default .blend file " ;
2009-09-12 17:16:12 +00:00
2008-12-17 15:38:40 +00:00
ot - > invoke = WM_operator_confirm ;
2007-12-24 18:27:28 +00:00
ot - > exec = WM_write_homefile ;
ot - > poll = WM_operator_winactive ;
}
2009-02-07 10:00:46 +00:00
static void WM_OT_read_homefile ( wmOperatorType * ot )
{
ot - > name = " Reload Start-Up File " ;
ot - > idname = " WM_OT_read_homefile " ;
2010-02-10 21:15:44 +00:00
ot - > description = " Open the default file (doesn't save the current file) " ;
2009-02-07 10:00:46 +00:00
ot - > invoke = WM_operator_confirm ;
2011-01-19 09:13:24 +00:00
ot - > exec = WM_read_homefile_exec ;
2011-02-01 02:54:29 +00:00
/* ommit poll to run in background mode */
2010-10-02 13:45:26 +00:00
}
static void WM_OT_read_factory_settings ( wmOperatorType * ot )
{
ot - > name = " Load Factory Settings " ;
ot - > idname = " WM_OT_read_factory_settings " ;
ot - > description = " Load default file and user preferences " ;
2009-02-07 10:00:46 +00:00
2010-10-02 13:45:26 +00:00
ot - > invoke = WM_operator_confirm ;
2011-01-19 09:13:24 +00:00
ot - > exec = WM_read_homefile_exec ;
2011-02-01 02:54:29 +00:00
/* ommit poll to run in background mode */
2009-02-07 10:00:46 +00:00
}
2009-09-14 12:30:49 +00:00
/* *************** open file **************** */
2009-01-06 14:42:54 +00:00
2009-09-14 12:30:49 +00:00
static void open_set_load_ui ( wmOperator * op )
2009-08-21 14:33:53 +00:00
{
if ( ! RNA_property_is_set ( op - > ptr , " load_ui " ) )
RNA_boolean_set ( op - > ptr , " load_ui " , ! ( U . flag & USER_FILENOUI ) ) ;
}
2009-02-13 13:04:48 +00:00
2010-02-27 01:27:22 +00:00
static void open_set_use_scripts ( wmOperator * op )
{
2011-03-15 08:04:11 +00:00
if ( ! RNA_property_is_set ( op - > ptr , " use_scripts " ) ) {
/* use G_SCRIPT_AUTOEXEC rather then the userpref because this means if
* the flag has been disabled from the command line , then opening
* from the menu wont enable this setting . */
RNA_boolean_set ( op - > ptr , " use_scripts " , ( G . f & G_SCRIPT_AUTOEXEC ) ) ;
}
2010-02-27 01:27:22 +00:00
}
2010-10-16 02:40:31 +00:00
static int wm_open_mainfile_invoke ( bContext * C , wmOperator * op , wmEvent * UNUSED ( event ) )
2009-01-06 14:42:54 +00:00
{
2010-11-11 18:53:10 +00:00
const char * openname = G . main - > name ;
/* if possible, get the name of the most recently used .blend file */
if ( G . recent_files . first ) {
struct RecentFile * recent = G . recent_files . first ;
openname = recent - > filepath ;
}
RNA_string_set ( op - > ptr , " filepath " , openname ) ;
2009-09-14 12:30:49 +00:00
open_set_load_ui ( op ) ;
2010-02-27 01:27:22 +00:00
open_set_use_scripts ( op ) ;
2009-08-21 14:33:53 +00:00
2009-02-16 12:14:04 +00:00
WM_event_add_fileselect ( C , op ) ;
2009-01-06 14:42:54 +00:00
return OPERATOR_RUNNING_MODAL ;
}
2009-02-18 18:08:33 +00:00
static int wm_open_mainfile_exec ( bContext * C , wmOperator * op )
2009-01-06 14:42:54 +00:00
{
2009-09-12 19:54:39 +00:00
char path [ FILE_MAX ] ;
2009-08-21 14:33:53 +00:00
2010-06-14 03:52:10 +00:00
RNA_string_get ( op - > ptr , " filepath " , path ) ;
2009-09-14 12:30:49 +00:00
open_set_load_ui ( op ) ;
2010-02-27 01:27:22 +00:00
open_set_use_scripts ( op ) ;
2009-08-21 14:33:53 +00:00
if ( RNA_boolean_get ( op - > ptr , " load_ui " ) )
G . fileflags & = ~ G_FILE_NO_UI ;
else
G . fileflags | = G_FILE_NO_UI ;
2010-02-27 01:27:22 +00:00
if ( RNA_boolean_get ( op - > ptr , " use_scripts " ) )
2010-02-27 12:01:10 +00:00
G . f | = G_SCRIPT_AUTOEXEC ;
2010-02-27 01:27:22 +00:00
else
2010-02-27 12:01:10 +00:00
G . f & = ~ G_SCRIPT_AUTOEXEC ;
2009-01-06 14:42:54 +00:00
2009-01-21 19:28:28 +00:00
// XXX wm in context is not set correctly after WM_read_file -> crash
2.5: WM Compositing
* Triple Buffer is now more complete:
- Proper handling of window resize, duplicate, etc.
- It now uses 3x3 textures (or less) if the power of two sizes
do not match well. That still has a worst case wast of 23.4%,
but better than 300%.
- It can also use the ARB/NV/EXT_texture_rectangle extension
now, which may be supported on hardware that does not support
ARB_texture_non_power_of_two.
- Gesture, menu and brushe redraws now require no redraws at all
from the area regions. So even on a high poly scene just moving
the paint cursor or opening a menu should be fast.
* Testing can be done by setting the "Window Draw Method" in the
User Preferences in the outliner. "Overlap" is still default,
since "Triple Buffer" has not been tested on computers other than
mine, would like to avoid crashing Blender on startup in case
there is a common bug, but it's ready for testing now.
- For reference "Full" draws the full window each time.
- "Triple Buffer" should work for both swap copy and swap exchange
systems, the latter still need the -E command line option for
"Overlap".
- Resizing and going fullscreen still gives flicker here but no
more than "Full" drawing.
* Partial Redraw was added. ED_region_tag_redraw_partial takes a
rect in window coordinates to define a subarea of the region.
On region draw it will then set glScissor to a smaller area, and
ar->drawrct will always be set to either the partial or full
window rect. The latter can then be used for clipping in the 3D
view or clipping interface drawing. Neither is implemented yet.
2009-01-23 03:52:52 +00:00
// do it before for now, but is this correct with multiple windows?
WM_event_add_notifier ( C , NC_WINDOW , NULL ) ;
2009-01-06 14:42:54 +00:00
2009-09-12 19:54:39 +00:00
WM_read_file ( C , path , op - > reports ) ;
2.5: WM Compositing
* Triple Buffer is now more complete:
- Proper handling of window resize, duplicate, etc.
- It now uses 3x3 textures (or less) if the power of two sizes
do not match well. That still has a worst case wast of 23.4%,
but better than 300%.
- It can also use the ARB/NV/EXT_texture_rectangle extension
now, which may be supported on hardware that does not support
ARB_texture_non_power_of_two.
- Gesture, menu and brushe redraws now require no redraws at all
from the area regions. So even on a high poly scene just moving
the paint cursor or opening a menu should be fast.
* Testing can be done by setting the "Window Draw Method" in the
User Preferences in the outliner. "Overlap" is still default,
since "Triple Buffer" has not been tested on computers other than
mine, would like to avoid crashing Blender on startup in case
there is a common bug, but it's ready for testing now.
- For reference "Full" draws the full window each time.
- "Triple Buffer" should work for both swap copy and swap exchange
systems, the latter still need the -E command line option for
"Overlap".
- Resizing and going fullscreen still gives flicker here but no
more than "Full" drawing.
* Partial Redraw was added. ED_region_tag_redraw_partial takes a
rect in window coordinates to define a subarea of the region.
On region draw it will then set glScissor to a smaller area, and
ar->drawrct will always be set to either the partial or full
window rect. The latter can then be used for clipping in the 3D
view or clipping interface drawing. Neither is implemented yet.
2009-01-23 03:52:52 +00:00
2009-10-20 13:58:53 +00:00
return OPERATOR_FINISHED ;
2009-01-06 14:42:54 +00:00
}
static void WM_OT_open_mainfile ( wmOperatorType * ot )
{
ot - > name = " Open Blender File " ;
ot - > idname = " WM_OT_open_mainfile " ;
2010-02-10 21:15:44 +00:00
ot - > description = " Open a Blender file " ;
2009-01-06 14:42:54 +00:00
2009-02-18 18:08:33 +00:00
ot - > invoke = wm_open_mainfile_invoke ;
ot - > exec = wm_open_mainfile_exec ;
2009-01-06 14:42:54 +00:00
ot - > poll = WM_operator_winactive ;
2010-07-01 19:28:45 +00:00
WM_operator_properties_filesel ( ot , FOLDERFILE | BLENDERFILE , FILE_BLENDER , FILE_OPENFILE , WM_FILESEL_FILEPATH ) ;
2009-08-21 14:33:53 +00:00
2010-02-11 01:11:52 +00:00
RNA_def_boolean ( ot - > srna , " load_ui " , 1 , " Load UI " , " Load user interface setup in the .blend file " ) ;
2010-02-27 01:27:22 +00:00
RNA_def_boolean ( ot - > srna , " use_scripts " , 1 , " Trusted Source " , " Allow blend file execute scripts automatically, default available from system preferences " ) ;
2009-07-23 21:35:11 +00:00
}
2009-09-14 12:30:49 +00:00
/* **************** link/append *************** */
2010-10-16 02:40:31 +00:00
static int wm_link_append_invoke ( bContext * C , wmOperator * op , wmEvent * UNUSED ( event ) )
2009-09-12 19:54:39 +00:00
{
2010-03-09 16:57:24 +00:00
if ( ! RNA_property_is_set ( op - > ptr , " relative_path " ) )
RNA_boolean_set ( op - > ptr , " relative_path " , U . flag & USER_RELPATHS ) ;
2010-06-14 03:52:10 +00:00
if ( RNA_property_is_set ( op - > ptr , " filepath " ) ) {
2009-09-12 19:54:39 +00:00
return WM_operator_call ( C , op ) ;
}
else {
2009-09-20 19:10:12 +00:00
/* XXX TODO solve where to get last linked library from */
2010-06-14 03:52:10 +00:00
RNA_string_set ( op - > ptr , " filepath " , G . lib ) ;
2009-09-12 19:54:39 +00:00
WM_event_add_fileselect ( C , op ) ;
return OPERATOR_RUNNING_MODAL ;
}
}
static short wm_link_append_flag ( wmOperator * op )
{
2009-09-14 12:30:49 +00:00
short flag = 0 ;
2009-09-12 19:54:39 +00:00
2009-09-14 12:30:49 +00:00
if ( RNA_boolean_get ( op - > ptr , " autoselect " ) ) flag | = FILE_AUTOSELECT ;
if ( RNA_boolean_get ( op - > ptr , " active_layer " ) ) flag | = FILE_ACTIVELAY ;
2010-03-09 17:36:23 +00:00
if ( RNA_boolean_get ( op - > ptr , " relative_path " ) ) flag | = FILE_RELPATH ;
2009-09-14 12:30:49 +00:00
if ( RNA_boolean_get ( op - > ptr , " link " ) ) flag | = FILE_LINK ;
2010-01-07 14:28:00 +00:00
if ( RNA_boolean_get ( op - > ptr , " instance_groups " ) ) flag | = FILE_GROUP_INSTANCE ;
2010-04-08 11:46:52 +00:00
2009-09-14 12:30:49 +00:00
return flag ;
}
2009-09-12 19:54:39 +00:00
static int wm_link_append_exec ( bContext * C , wmOperator * op )
{
2009-09-14 12:30:49 +00:00
Main * bmain = CTX_data_main ( C ) ;
Scene * scene = CTX_data_scene ( C ) ;
2011-03-03 17:59:04 +00:00
Main * mainl = NULL ;
2009-09-12 19:54:39 +00:00
BlendHandle * bh ;
PropertyRNA * prop ;
2009-09-14 12:30:49 +00:00
char name [ FILE_MAX ] , dir [ FILE_MAX ] , libname [ FILE_MAX ] , group [ GROUP_MAX ] ;
int idcode , totfiles = 0 ;
2009-09-12 19:54:39 +00:00
short flag ;
name [ 0 ] = ' \0 ' ;
RNA_string_get ( op - > ptr , " filename " , name ) ;
RNA_string_get ( op - > ptr , " directory " , dir ) ;
2009-09-14 12:30:49 +00:00
/* test if we have a valid data */
if ( BLO_is_a_library ( dir , libname , group ) = = 0 ) {
2009-09-12 19:54:39 +00:00
BKE_report ( op - > reports , RPT_ERROR , " Not a library " ) ;
2009-09-14 12:30:49 +00:00
return OPERATOR_CANCELLED ;
}
else if ( group [ 0 ] = = 0 ) {
2009-09-12 19:54:39 +00:00
BKE_report ( op - > reports , RPT_ERROR , " Nothing indicated " ) ;
2009-09-14 12:30:49 +00:00
return OPERATOR_CANCELLED ;
}
2011-04-06 06:03:48 +00:00
else if ( BLI_path_cmp ( bmain - > name , libname ) = = 0 ) {
2009-09-12 19:54:39 +00:00
BKE_report ( op - > reports , RPT_ERROR , " Cannot use current file as library " ) ;
2009-09-14 12:30:49 +00:00
return OPERATOR_CANCELLED ;
2009-09-12 19:54:39 +00:00
}
/* check if something is indicated for append/link */
prop = RNA_struct_find_property ( op - > ptr , " files " ) ;
2009-09-14 12:30:49 +00:00
if ( prop ) {
2009-09-12 19:54:39 +00:00
totfiles = RNA_property_collection_length ( op - > ptr , prop ) ;
2009-09-14 12:30:49 +00:00
if ( totfiles = = 0 ) {
if ( name [ 0 ] = = ' \0 ' ) {
2009-09-12 19:54:39 +00:00
BKE_report ( op - > reports , RPT_ERROR , " Nothing indicated " ) ;
2009-09-14 12:30:49 +00:00
return OPERATOR_CANCELLED ;
2009-09-12 19:54:39 +00:00
}
}
2009-09-14 12:30:49 +00:00
}
else if ( name [ 0 ] = = ' \0 ' ) {
2009-09-12 19:54:39 +00:00
BKE_report ( op - > reports , RPT_ERROR , " Nothing indicated " ) ;
2009-09-14 12:30:49 +00:00
return OPERATOR_CANCELLED ;
2009-09-12 19:54:39 +00:00
}
2011-03-12 15:15:40 +00:00
bh = BLO_blendhandle_from_file ( libname , op - > reports ) ;
if ( bh = = NULL ) {
/* unlikely since we just browsed it, but possible
* error reports will have been made by BLO_blendhandle_from_file ( ) */
return OPERATOR_CANCELLED ;
}
/* from here down, no error returns */
idcode = BKE_idcode_from_name ( group ) ;
2009-09-12 19:54:39 +00:00
/* now we have or selected, or an indicated file */
2009-09-14 12:30:49 +00:00
if ( RNA_boolean_get ( op - > ptr , " autoselect " ) )
2009-09-12 19:54:39 +00:00
scene_deselect_all ( scene ) ;
flag = wm_link_append_flag ( op ) ;
2010-04-08 11:46:52 +00:00
/* sanity checks for flag */
if ( scene - > id . lib & & ( flag & FILE_GROUP_INSTANCE ) ) {
/* TODO, user never gets this message */
BKE_reportf ( op - > reports , RPT_WARNING , " Scene '%s' is linked, group instance disabled " , scene - > id . name + 2 ) ;
flag & = ~ FILE_GROUP_INSTANCE ;
}
2010-01-07 16:19:38 +00:00
/* tag everything, all untagged data can be made local
* its also generally useful to know what is new
*
* take extra care flag_all_listbases_ids ( LIB_LINK_TAG , 0 ) is called after ! */
flag_all_listbases_ids ( LIB_PRE_EXISTING , 1 ) ;
2009-09-12 19:54:39 +00:00
/* here appending/linking starts */
mainl = BLO_library_append_begin ( C , & bh , libname ) ;
2009-09-14 12:30:49 +00:00
if ( totfiles = = 0 ) {
2009-09-12 19:54:39 +00:00
BLO_library_append_named_part ( C , mainl , & bh , name , idcode , flag ) ;
2009-09-14 12:30:49 +00:00
}
else {
2009-09-12 19:54:39 +00:00
RNA_BEGIN ( op - > ptr , itemptr , " files " ) {
RNA_string_get ( & itemptr , " name " , name ) ;
BLO_library_append_named_part ( C , mainl , & bh , name , idcode , flag ) ;
}
RNA_END ;
}
BLO_library_append_end ( C , mainl , & bh , idcode , flag ) ;
2009-09-14 12:30:49 +00:00
/* mark all library linked objects to be updated */
recalc_all_library_objects ( bmain ) ;
2009-09-12 19:54:39 +00:00
2009-09-14 12:30:49 +00:00
/* append, rather than linking */
library loading api.
this is not well suited to RNA so this is a native python api.
This uses:
bpy.data.libraries.load(filepath, link=False, relative=False)
however the return value needs to use pythons context manager, this means the library loading is confined to a block of code and python cant leave a half loaded library state.
eg, load a single scene we know the name of:
with bpy.data.libraries.load(filepath) as (data_from, data_to):
data_to.scenes = ["Scene"]
eg, load all scenes:
with bpy.data.libraries.load(filepath) as (data_from, data_to):
data_to.scenes = data_from.scenes
eg, load all objects starting with 'A'
with bpy.data.libraries.load(filepath) as (data_from, data_to):
data_to.objects = [name for name in data_from.objects if name.startswith("A")]
As you can see gives 2 objects like 'bpy.data', but containing lists of strings which can be moved from one into another.
2011-03-12 16:06:37 +00:00
if ( ( flag & FILE_LINK ) = = 0 ) {
Library * lib = BLI_findstring ( & bmain - > library , libname , offsetof ( Library , filepath ) ) ;
if ( lib ) all_local ( lib , 1 ) ;
else BLI_assert ( ! " cant find name of just added library! " ) ;
}
2009-09-12 19:54:39 +00:00
2010-01-07 16:19:38 +00:00
/* important we unset, otherwise these object wont
* link into other scenes from this blend file */
flag_all_listbases_ids ( LIB_PRE_EXISTING , 0 ) ;
2009-09-14 12:30:49 +00:00
/* recreate dependency graph to include new objects */
2010-08-01 12:47:49 +00:00
DAG_scene_sort ( bmain , scene ) ;
DAG_ids_flush_update ( bmain , 0 ) ;
2009-09-12 19:54:39 +00:00
BLO_blendhandle_close ( bh ) ;
2009-09-20 19:10:12 +00:00
/* XXX TODO: align G.lib with other directory storage (like last opened image etc...) */
2009-09-12 19:54:39 +00:00
BLI_strncpy ( G . lib , dir , FILE_MAX ) ;
WM_event_add_notifier ( C , NC_WINDOW , NULL ) ;
return OPERATOR_FINISHED ;
}
static void WM_OT_link_append ( wmOperatorType * ot )
{
ot - > name = " Link/Append from Library " ;
ot - > idname = " WM_OT_link_append " ;
ot - > description = " Link or Append from a Library .blend file " ;
ot - > invoke = wm_link_append_invoke ;
ot - > exec = wm_link_append_exec ;
ot - > poll = WM_operator_winactive ;
Key Configuration
Keymaps are now saveable and configurable from the user preferences, note
that editing one item in a keymap means the whole keymap is now defined by
the user and will not be updated by Blender, an option for syncing might be
added later. The outliner interface is still there, but I will probably
remove it.
There's actually 3 levels now:
* Default builtin key configuration.
* Key configuration loaded from .py file, for configs like Blender 2.4x
or other 3D applications.
* Keymaps edited by the user and saved in .B.blend. These can be saved
to .py files as well to make creating distributable configurations
easier.
Also, user preferences sections were reorganized a bit, now there is:
Interface, Editing, Input, Files and System.
Implementation notes:
* wmKeyConfig was added which represents a key configuration containing
keymaps.
* wmKeymapItem was renamed to wmKeyMapItem for consistency with wmKeyMap.
* Modal maps are not wrapped yet.
* User preferences DNA file reading did not support newdataadr() yet,
added this now for reading keymaps.
* Key configuration related settings are now RNA wrapped.
* is_property_set and is_property_hidden python methods were added.
2009-10-08 18:40:03 +00:00
ot - > flag | = OPTYPE_UNDO ;
2010-07-01 19:28:45 +00:00
WM_operator_properties_filesel ( ot , FOLDERFILE | BLENDERFILE , FILE_LOADLIB , FILE_OPENFILE , WM_FILESEL_FILEPATH | WM_FILESEL_DIRECTORY | WM_FILESEL_FILENAME | WM_FILESEL_RELPATH ) ;
2009-09-12 19:54:39 +00:00
2010-02-11 01:11:52 +00:00
RNA_def_boolean ( ot - > srna , " link " , 1 , " Link " , " Link the objects or datablocks rather than appending " ) ;
RNA_def_boolean ( ot - > srna , " autoselect " , 1 , " Select " , " Select the linked objects " ) ;
RNA_def_boolean ( ot - > srna , " active_layer " , 1 , " Active Layer " , " Put the linked objects on the active layer " ) ;
RNA_def_boolean ( ot - > srna , " instance_groups " , 1 , " Instance Groups " , " Create instances for each group as a DupliGroup " ) ;
2009-09-12 19:54:39 +00:00
RNA_def_collection_runtime ( ot - > srna , " files " , & RNA_OperatorFileListElement , " Files " , " " ) ;
}
2009-09-14 12:30:49 +00:00
/* *************** recover last session **************** */
2009-07-23 21:35:11 +00:00
static int wm_recover_last_session_exec ( bContext * C , wmOperator * op )
{
2009-10-20 13:58:53 +00:00
char filename [ FILE_MAX ] ;
2009-01-06 14:42:54 +00:00
2009-10-20 13:58:53 +00:00
G . fileflags | = G_FILE_RECOVER ;
2009-07-23 21:35:11 +00:00
// XXX wm in context is not set correctly after WM_read_file -> crash
// do it before for now, but is this correct with multiple windows?
WM_event_add_notifier ( C , NC_WINDOW , NULL ) ;
/* load file */
BLI_make_file_string ( " / " , filename , btempdir , " quit.blend " ) ;
WM_read_file ( C , filename , op - > reports ) ;
2009-10-20 13:58:53 +00:00
G . fileflags & = ~ G_FILE_RECOVER ;
return OPERATOR_FINISHED ;
2009-07-23 21:35:11 +00:00
}
static void WM_OT_recover_last_session ( wmOperatorType * ot )
{
ot - > name = " Recover Last Session " ;
ot - > idname = " WM_OT_recover_last_session " ;
2010-02-10 21:15:44 +00:00
ot - > description = " Open the last closed file ( \" quit.blend \" ) " ;
2009-07-23 21:35:11 +00:00
ot - > exec = wm_recover_last_session_exec ;
ot - > poll = WM_operator_winactive ;
}
2009-10-20 13:58:53 +00:00
/* *************** recover auto save **************** */
static int wm_recover_auto_save_exec ( bContext * C , wmOperator * op )
{
char path [ FILE_MAX ] ;
2010-06-14 03:52:10 +00:00
RNA_string_get ( op - > ptr , " filepath " , path ) ;
2009-10-20 13:58:53 +00:00
G . fileflags | = G_FILE_RECOVER ;
// XXX wm in context is not set correctly after WM_read_file -> crash
// do it before for now, but is this correct with multiple windows?
WM_event_add_notifier ( C , NC_WINDOW , NULL ) ;
/* load file */
WM_read_file ( C , path , op - > reports ) ;
G . fileflags & = ~ G_FILE_RECOVER ;
return OPERATOR_FINISHED ;
}
2010-10-16 02:40:31 +00:00
static int wm_recover_auto_save_invoke ( bContext * C , wmOperator * op , wmEvent * UNUSED ( event ) )
2009-10-20 13:58:53 +00:00
{
char filename [ FILE_MAX ] ;
wm_autosave_location ( filename ) ;
2010-06-14 03:52:10 +00:00
RNA_string_set ( op - > ptr , " filepath " , filename ) ;
2009-10-20 13:58:53 +00:00
WM_event_add_fileselect ( C , op ) ;
return OPERATOR_RUNNING_MODAL ;
}
static void WM_OT_recover_auto_save ( wmOperatorType * ot )
{
ot - > name = " Recover Auto Save " ;
ot - > idname = " WM_OT_recover_auto_save " ;
2010-02-10 21:15:44 +00:00
ot - > description = " Open an automatically saved file to recover it " ;
2009-10-20 13:58:53 +00:00
ot - > exec = wm_recover_auto_save_exec ;
ot - > invoke = wm_recover_auto_save_invoke ;
ot - > poll = WM_operator_winactive ;
2010-07-01 19:28:45 +00:00
WM_operator_properties_filesel ( ot , BLENDERFILE , FILE_BLENDER , FILE_OPENFILE , WM_FILESEL_FILEPATH ) ;
2009-10-20 13:58:53 +00:00
}
2009-09-14 12:30:49 +00:00
/* *************** save file as **************** */
static void untitled ( char * name )
{
if ( G . save_over = = 0 & & strlen ( name ) < FILE_MAX - 16 ) {
char * c = BLI_last_slash ( name ) ;
if ( c )
strcpy ( & c [ 1 ] , " untitled.blend " ) ;
else
strcpy ( name , " untitled.blend " ) ;
}
}
2009-07-23 21:35:11 +00:00
static void save_set_compress ( wmOperator * op )
{
if ( ! RNA_property_is_set ( op - > ptr , " compress " ) ) {
if ( G . save_over ) /* keep flag for existing file */
RNA_boolean_set ( op - > ptr , " compress " , G . fileflags & G_FILE_COMPRESS ) ;
else /* use userdef for new file */
RNA_boolean_set ( op - > ptr , " compress " , U . flag & USER_FILECOMPRESS ) ;
}
2009-01-06 14:42:54 +00:00
}
2010-10-16 02:40:31 +00:00
static int wm_save_as_mainfile_invoke ( bContext * C , wmOperator * op , wmEvent * UNUSED ( event ) )
2009-01-21 19:28:28 +00:00
{
2009-02-13 13:04:48 +00:00
char name [ FILE_MAX ] ;
2009-07-23 21:35:11 +00:00
save_set_compress ( op ) ;
2009-01-21 19:28:28 +00:00
2011-02-05 15:05:17 +00:00
/* if not saved before, get the name of the most recently used .blend file */
if ( G . main - > name [ 0 ] = = 0 & & G . recent_files . first ) {
struct RecentFile * recent = G . recent_files . first ;
BLI_strncpy ( name , recent - > filepath , FILE_MAX ) ;
}
else
BLI_strncpy ( name , G . main - > name , FILE_MAX ) ;
2009-02-13 13:04:48 +00:00
untitled ( name ) ;
2010-06-14 03:52:10 +00:00
RNA_string_set ( op - > ptr , " filepath " , name ) ;
2009-02-16 12:14:04 +00:00
WM_event_add_fileselect ( C , op ) ;
2009-01-21 19:28:28 +00:00
return OPERATOR_RUNNING_MODAL ;
}
2009-02-08 19:15:59 +00:00
/* function used for WM_OT_save_mainfile too */
2009-01-21 19:28:28 +00:00
static int wm_save_as_mainfile_exec ( bContext * C , wmOperator * op )
{
2009-09-12 19:54:39 +00:00
char path [ FILE_MAX ] ;
2009-10-20 13:58:53 +00:00
int fileflags ;
2010-07-19 15:39:12 +00:00
int copy = 0 ;
2009-07-23 21:35:11 +00:00
save_set_compress ( op ) ;
2009-01-21 19:28:28 +00:00
2010-06-14 03:52:10 +00:00
if ( RNA_property_is_set ( op - > ptr , " filepath " ) )
RNA_string_get ( op - > ptr , " filepath " , path ) ;
2009-02-18 13:29:54 +00:00
else {
2010-10-18 06:41:16 +00:00
BLI_strncpy ( path , G . main - > name , FILE_MAX ) ;
2009-09-12 19:54:39 +00:00
untitled ( path ) ;
2009-02-18 13:29:54 +00:00
}
2009-07-23 21:35:11 +00:00
2010-07-19 15:39:12 +00:00
if ( RNA_property_is_set ( op - > ptr , " copy " ) )
copy = RNA_boolean_get ( op - > ptr , " copy " ) ;
2009-10-20 13:58:53 +00:00
fileflags = G . fileflags ;
/* set compression flag */
2010-01-08 17:50:55 +00:00
if ( RNA_boolean_get ( op - > ptr , " compress " ) ) fileflags | = G_FILE_COMPRESS ;
else fileflags & = ~ G_FILE_COMPRESS ;
if ( RNA_boolean_get ( op - > ptr , " relative_remap " ) ) fileflags | = G_FILE_RELATIVE_REMAP ;
else fileflags & = ~ G_FILE_RELATIVE_REMAP ;
2009-10-20 13:58:53 +00:00
2010-07-19 15:39:12 +00:00
if ( WM_write_file ( C , path , fileflags , op - > reports , copy ) ! = 0 )
2010-04-14 20:45:36 +00:00
return OPERATOR_CANCELLED ;
2009-02-18 13:29:54 +00:00
WM_event_add_notifier ( C , NC_WM | ND_FILESAVE , NULL ) ;
2009-01-21 19:28:28 +00:00
2010-04-14 20:27:45 +00:00
return OPERATOR_FINISHED ;
2009-01-21 19:28:28 +00:00
}
2010-09-17 09:27:31 +00:00
/* function used for WM_OT_save_mainfile too */
2010-10-16 02:40:31 +00:00
static int blend_save_check ( bContext * UNUSED ( C ) , wmOperator * op )
2010-09-17 09:27:31 +00:00
{
char filepath [ FILE_MAX ] ;
RNA_string_get ( op - > ptr , " filepath " , filepath ) ;
if ( BLI_replace_extension ( filepath , sizeof ( filepath ) , " .blend " ) ) {
RNA_string_set ( op - > ptr , " filepath " , filepath ) ;
return TRUE ;
}
return FALSE ;
}
2009-01-21 19:28:28 +00:00
static void WM_OT_save_as_mainfile ( wmOperatorType * ot )
{
2009-02-08 19:15:59 +00:00
ot - > name = " Save As Blender File " ;
2009-01-21 19:28:28 +00:00
ot - > idname = " WM_OT_save_as_mainfile " ;
2010-02-10 21:15:44 +00:00
ot - > description = " Save the current file in the desired location " ;
2009-01-21 19:28:28 +00:00
ot - > invoke = wm_save_as_mainfile_invoke ;
ot - > exec = wm_save_as_mainfile_exec ;
2010-09-17 09:27:31 +00:00
ot - > check = blend_save_check ;
2011-02-01 12:47:50 +00:00
/* ommit window poll so this can work in background mode */
2010-07-01 19:28:45 +00:00
WM_operator_properties_filesel ( ot , FOLDERFILE | BLENDERFILE , FILE_BLENDER , FILE_SAVE , WM_FILESEL_FILEPATH ) ;
2010-02-11 01:11:52 +00:00
RNA_def_boolean ( ot - > srna , " compress " , 0 , " Compress " , " Write compressed .blend file " ) ;
2010-07-08 22:07:34 +00:00
RNA_def_boolean ( ot - > srna , " relative_remap " , 1 , " Remap Relative " , " Remap relative paths when saving in a different directory " ) ;
2010-07-19 15:39:12 +00:00
RNA_def_boolean ( ot - > srna , " copy " , 0 , " Save Copy " , " Save a copy of the actual working state but does not make saved file active. " ) ;
2009-01-21 19:28:28 +00:00
}
2009-09-14 12:30:49 +00:00
/* *************** save file directly ******** */
2009-02-08 19:15:59 +00:00
2010-10-16 02:40:31 +00:00
static int wm_save_mainfile_invoke ( bContext * C , wmOperator * op , wmEvent * UNUSED ( event ) )
2009-02-08 19:15:59 +00:00
{
2009-02-13 13:04:48 +00:00
char name [ FILE_MAX ] ;
2010-01-27 02:20:24 +00:00
int check_existing = 1 ;
2009-12-04 19:07:25 +00:00
/* cancel if no active window */
if ( CTX_wm_window ( C ) = = NULL )
return OPERATOR_CANCELLED ;
2009-07-23 21:35:11 +00:00
save_set_compress ( op ) ;
2011-02-05 15:05:17 +00:00
/* if not saved before, get the name of the most recently used .blend file */
if ( G . main - > name [ 0 ] = = 0 & & G . recent_files . first ) {
struct RecentFile * recent = G . recent_files . first ;
BLI_strncpy ( name , recent - > filepath , FILE_MAX ) ;
}
else
BLI_strncpy ( name , G . main - > name , FILE_MAX ) ;
2009-02-13 13:04:48 +00:00
untitled ( name ) ;
2011-02-05 15:05:17 +00:00
2010-06-14 03:52:10 +00:00
RNA_string_set ( op - > ptr , " filepath " , name ) ;
2009-10-21 23:05:54 +00:00
2010-01-27 02:20:24 +00:00
if ( RNA_struct_find_property ( op - > ptr , " check_existing " ) )
if ( RNA_boolean_get ( op - > ptr , " check_existing " ) = = 0 )
check_existing = 0 ;
if ( G . save_over ) {
if ( check_existing )
uiPupMenuSaveOver ( C , op , name ) ;
else {
2010-04-19 18:11:00 +00:00
wm_save_as_mainfile_exec ( C , op ) ;
2010-01-27 02:20:24 +00:00
}
} else {
2009-10-21 23:05:54 +00:00
WM_event_add_fileselect ( C , op ) ;
2010-01-27 02:20:24 +00:00
}
2009-10-21 23:05:54 +00:00
2009-02-08 19:15:59 +00:00
return OPERATOR_RUNNING_MODAL ;
}
static void WM_OT_save_mainfile ( wmOperatorType * ot )
{
ot - > name = " Save Blender File " ;
ot - > idname = " WM_OT_save_mainfile " ;
2010-02-10 21:15:44 +00:00
ot - > description = " Save the current Blender file " ;
2009-02-08 19:15:59 +00:00
ot - > invoke = wm_save_mainfile_invoke ;
ot - > exec = wm_save_as_mainfile_exec ;
2010-09-17 09:27:31 +00:00
ot - > check = blend_save_check ;
2009-12-04 19:07:25 +00:00
ot - > poll = NULL ;
2009-02-08 19:15:59 +00:00
2010-07-01 19:28:45 +00:00
WM_operator_properties_filesel ( ot , FOLDERFILE | BLENDERFILE , FILE_BLENDER , FILE_SAVE , WM_FILESEL_FILEPATH ) ;
2010-02-11 01:11:52 +00:00
RNA_def_boolean ( ot - > srna , " compress " , 0 , " Compress " , " Write compressed .blend file " ) ;
RNA_def_boolean ( ot - > srna , " relative_remap " , 0 , " Remap Relative " , " Remap relative paths when saving in a different directory " ) ;
2009-02-08 19:15:59 +00:00
}
Merge of the COLLADA GSoC branch into trunk.
COLLADA code is disabled by default (it has dependencies requiring manual install).
SCons and CMake builds are supported on Windows and Linux, no Mac building yet. More on building COLLADA code: http://wiki.blender.org/index.php/User:Kazanbas/Building_Collada_Branch.
The detailed command log of the merge (can be useful for educational purposes):
branch=https://svn.blender.org/svnroot/bf-blender/branches/soc-2009-chingachgook
# collada code
svn copy $branch/source/blender/collada source/blender/collada
# operator
svn merge -c 20401,20955,21077,24077,24079 $branch/source/blender/windowmanager/intern/wm_operators.c source/blender/windowmanager/intern/wm_operators.c
# menu
svn merge -c 24079 $branch/release/scripts/ui/space_info.py release/scripts/ui/space_info.py
# scons
svn merge -c 20398 $branch/source/blender/SConscript source/blender/SConscript
svn merge -c 20398,20691,20955,22726 $branch/tools/btools.py tools/btools.py
svn merge -c 20691,20955,22726 $branch/tools/Blender.py tools/Blender.py
svn merge -c 20398,20692,20955 $branch/config/linux2-config.py config/linux2-config.py
svn merge -c 22726 $branch/config/win64-vc-config.py config/win64-vc-config.py
svn merge -c 22726 $branch/config/win32-vc-config.py config/win32-vc-config.py
svn merge -c 24077 $branch/source/blender/windowmanager/SConscript source/blender/windowmanager/SConscript
# cmake
svn merge -c 23319,23905,24077,24158 $branch/CMakeLists.txt CMakeLists.txt
svn merge -c 23319 $branch/source/blender/CMakeLists.txt source/blender/CMakeLists.txt
svn merge -c 23319 $branch/source/creator/CMakeLists.txt source/creator/CMakeLists.txt
svn merge -c 23319 $branch/CMake/macros.cmake CMake/macros.cmake
svn merge -c 24077 $branch/source/blender/windowmanager/CMakeLists.txt source/blender/windowmanager/CMakeLists.txt
2009-10-30 15:35:50 +00:00
/* XXX: move these collada operators to a more appropriate place */
# ifdef WITH_COLLADA
# include "../../collada/collada.h"
2010-11-03 22:44:39 +00:00
static int wm_collada_export_invoke ( bContext * C , wmOperator * op , wmEvent * UNUSED ( event ) )
2010-04-18 09:12:18 +00:00
{
2010-06-14 03:52:10 +00:00
if ( ! RNA_property_is_set ( op - > ptr , " filepath " ) ) {
2010-10-02 13:52:46 +00:00
char filepath [ FILE_MAX ] ;
2010-10-18 06:41:16 +00:00
BLI_strncpy ( filepath , G . main - > name , sizeof ( filepath ) ) ;
2010-09-17 09:27:31 +00:00
BLI_replace_extension ( filepath , sizeof ( filepath ) , " .dae " ) ;
RNA_string_set ( op - > ptr , " filepath " , filepath ) ;
2010-03-29 08:33:35 +00:00
}
2010-04-18 09:12:18 +00:00
Merge of the COLLADA GSoC branch into trunk.
COLLADA code is disabled by default (it has dependencies requiring manual install).
SCons and CMake builds are supported on Windows and Linux, no Mac building yet. More on building COLLADA code: http://wiki.blender.org/index.php/User:Kazanbas/Building_Collada_Branch.
The detailed command log of the merge (can be useful for educational purposes):
branch=https://svn.blender.org/svnroot/bf-blender/branches/soc-2009-chingachgook
# collada code
svn copy $branch/source/blender/collada source/blender/collada
# operator
svn merge -c 20401,20955,21077,24077,24079 $branch/source/blender/windowmanager/intern/wm_operators.c source/blender/windowmanager/intern/wm_operators.c
# menu
svn merge -c 24079 $branch/release/scripts/ui/space_info.py release/scripts/ui/space_info.py
# scons
svn merge -c 20398 $branch/source/blender/SConscript source/blender/SConscript
svn merge -c 20398,20691,20955,22726 $branch/tools/btools.py tools/btools.py
svn merge -c 20691,20955,22726 $branch/tools/Blender.py tools/Blender.py
svn merge -c 20398,20692,20955 $branch/config/linux2-config.py config/linux2-config.py
svn merge -c 22726 $branch/config/win64-vc-config.py config/win64-vc-config.py
svn merge -c 22726 $branch/config/win32-vc-config.py config/win32-vc-config.py
svn merge -c 24077 $branch/source/blender/windowmanager/SConscript source/blender/windowmanager/SConscript
# cmake
svn merge -c 23319,23905,24077,24158 $branch/CMakeLists.txt CMakeLists.txt
svn merge -c 23319 $branch/source/blender/CMakeLists.txt source/blender/CMakeLists.txt
svn merge -c 23319 $branch/source/creator/CMakeLists.txt source/creator/CMakeLists.txt
svn merge -c 23319 $branch/CMake/macros.cmake CMake/macros.cmake
svn merge -c 24077 $branch/source/blender/windowmanager/CMakeLists.txt source/blender/windowmanager/CMakeLists.txt
2009-10-30 15:35:50 +00:00
WM_event_add_fileselect ( C , op ) ;
2010-04-18 09:12:18 +00:00
Merge of the COLLADA GSoC branch into trunk.
COLLADA code is disabled by default (it has dependencies requiring manual install).
SCons and CMake builds are supported on Windows and Linux, no Mac building yet. More on building COLLADA code: http://wiki.blender.org/index.php/User:Kazanbas/Building_Collada_Branch.
The detailed command log of the merge (can be useful for educational purposes):
branch=https://svn.blender.org/svnroot/bf-blender/branches/soc-2009-chingachgook
# collada code
svn copy $branch/source/blender/collada source/blender/collada
# operator
svn merge -c 20401,20955,21077,24077,24079 $branch/source/blender/windowmanager/intern/wm_operators.c source/blender/windowmanager/intern/wm_operators.c
# menu
svn merge -c 24079 $branch/release/scripts/ui/space_info.py release/scripts/ui/space_info.py
# scons
svn merge -c 20398 $branch/source/blender/SConscript source/blender/SConscript
svn merge -c 20398,20691,20955,22726 $branch/tools/btools.py tools/btools.py
svn merge -c 20691,20955,22726 $branch/tools/Blender.py tools/Blender.py
svn merge -c 20398,20692,20955 $branch/config/linux2-config.py config/linux2-config.py
svn merge -c 22726 $branch/config/win64-vc-config.py config/win64-vc-config.py
svn merge -c 22726 $branch/config/win32-vc-config.py config/win32-vc-config.py
svn merge -c 24077 $branch/source/blender/windowmanager/SConscript source/blender/windowmanager/SConscript
# cmake
svn merge -c 23319,23905,24077,24158 $branch/CMakeLists.txt CMakeLists.txt
svn merge -c 23319 $branch/source/blender/CMakeLists.txt source/blender/CMakeLists.txt
svn merge -c 23319 $branch/source/creator/CMakeLists.txt source/creator/CMakeLists.txt
svn merge -c 23319 $branch/CMake/macros.cmake CMake/macros.cmake
svn merge -c 24077 $branch/source/blender/windowmanager/CMakeLists.txt source/blender/windowmanager/CMakeLists.txt
2009-10-30 15:35:50 +00:00
return OPERATOR_RUNNING_MODAL ;
}
/* function used for WM_OT_save_mainfile too */
static int wm_collada_export_exec ( bContext * C , wmOperator * op )
{
char filename [ FILE_MAX ] ;
2010-06-14 03:52:10 +00:00
if ( ! RNA_property_is_set ( op - > ptr , " filepath " ) ) {
2010-03-29 08:33:35 +00:00
BKE_report ( op - > reports , RPT_ERROR , " No filename given " ) ;
return OPERATOR_CANCELLED ;
Merge of the COLLADA GSoC branch into trunk.
COLLADA code is disabled by default (it has dependencies requiring manual install).
SCons and CMake builds are supported on Windows and Linux, no Mac building yet. More on building COLLADA code: http://wiki.blender.org/index.php/User:Kazanbas/Building_Collada_Branch.
The detailed command log of the merge (can be useful for educational purposes):
branch=https://svn.blender.org/svnroot/bf-blender/branches/soc-2009-chingachgook
# collada code
svn copy $branch/source/blender/collada source/blender/collada
# operator
svn merge -c 20401,20955,21077,24077,24079 $branch/source/blender/windowmanager/intern/wm_operators.c source/blender/windowmanager/intern/wm_operators.c
# menu
svn merge -c 24079 $branch/release/scripts/ui/space_info.py release/scripts/ui/space_info.py
# scons
svn merge -c 20398 $branch/source/blender/SConscript source/blender/SConscript
svn merge -c 20398,20691,20955,22726 $branch/tools/btools.py tools/btools.py
svn merge -c 20691,20955,22726 $branch/tools/Blender.py tools/Blender.py
svn merge -c 20398,20692,20955 $branch/config/linux2-config.py config/linux2-config.py
svn merge -c 22726 $branch/config/win64-vc-config.py config/win64-vc-config.py
svn merge -c 22726 $branch/config/win32-vc-config.py config/win32-vc-config.py
svn merge -c 24077 $branch/source/blender/windowmanager/SConscript source/blender/windowmanager/SConscript
# cmake
svn merge -c 23319,23905,24077,24158 $branch/CMakeLists.txt CMakeLists.txt
svn merge -c 23319 $branch/source/blender/CMakeLists.txt source/blender/CMakeLists.txt
svn merge -c 23319 $branch/source/creator/CMakeLists.txt source/creator/CMakeLists.txt
svn merge -c 23319 $branch/CMake/macros.cmake CMake/macros.cmake
svn merge -c 24077 $branch/source/blender/windowmanager/CMakeLists.txt source/blender/windowmanager/CMakeLists.txt
2009-10-30 15:35:50 +00:00
}
2011-04-25 12:39:53 +00:00
2010-06-14 03:52:10 +00:00
RNA_string_get ( op - > ptr , " filepath " , filename ) ;
2011-04-25 12:39:53 +00:00
if ( collada_export ( CTX_data_scene ( C ) , filename ) ) {
return OPERATOR_FINISHED ;
}
else {
return OPERATOR_CANCELLED ;
}
Merge of the COLLADA GSoC branch into trunk.
COLLADA code is disabled by default (it has dependencies requiring manual install).
SCons and CMake builds are supported on Windows and Linux, no Mac building yet. More on building COLLADA code: http://wiki.blender.org/index.php/User:Kazanbas/Building_Collada_Branch.
The detailed command log of the merge (can be useful for educational purposes):
branch=https://svn.blender.org/svnroot/bf-blender/branches/soc-2009-chingachgook
# collada code
svn copy $branch/source/blender/collada source/blender/collada
# operator
svn merge -c 20401,20955,21077,24077,24079 $branch/source/blender/windowmanager/intern/wm_operators.c source/blender/windowmanager/intern/wm_operators.c
# menu
svn merge -c 24079 $branch/release/scripts/ui/space_info.py release/scripts/ui/space_info.py
# scons
svn merge -c 20398 $branch/source/blender/SConscript source/blender/SConscript
svn merge -c 20398,20691,20955,22726 $branch/tools/btools.py tools/btools.py
svn merge -c 20691,20955,22726 $branch/tools/Blender.py tools/Blender.py
svn merge -c 20398,20692,20955 $branch/config/linux2-config.py config/linux2-config.py
svn merge -c 22726 $branch/config/win64-vc-config.py config/win64-vc-config.py
svn merge -c 22726 $branch/config/win32-vc-config.py config/win32-vc-config.py
svn merge -c 24077 $branch/source/blender/windowmanager/SConscript source/blender/windowmanager/SConscript
# cmake
svn merge -c 23319,23905,24077,24158 $branch/CMakeLists.txt CMakeLists.txt
svn merge -c 23319 $branch/source/blender/CMakeLists.txt source/blender/CMakeLists.txt
svn merge -c 23319 $branch/source/creator/CMakeLists.txt source/creator/CMakeLists.txt
svn merge -c 23319 $branch/CMake/macros.cmake CMake/macros.cmake
svn merge -c 24077 $branch/source/blender/windowmanager/CMakeLists.txt source/blender/windowmanager/CMakeLists.txt
2009-10-30 15:35:50 +00:00
}
static void WM_OT_collada_export ( wmOperatorType * ot )
{
ot - > name = " Export COLLADA " ;
ot - > idname = " WM_OT_collada_export " ;
ot - > invoke = wm_collada_export_invoke ;
ot - > exec = wm_collada_export_exec ;
ot - > poll = WM_operator_winactive ;
2010-07-01 19:28:45 +00:00
WM_operator_properties_filesel ( ot , FOLDERFILE | COLLADAFILE , FILE_BLENDER , FILE_SAVE , WM_FILESEL_FILEPATH ) ;
Merge of the COLLADA GSoC branch into trunk.
COLLADA code is disabled by default (it has dependencies requiring manual install).
SCons and CMake builds are supported on Windows and Linux, no Mac building yet. More on building COLLADA code: http://wiki.blender.org/index.php/User:Kazanbas/Building_Collada_Branch.
The detailed command log of the merge (can be useful for educational purposes):
branch=https://svn.blender.org/svnroot/bf-blender/branches/soc-2009-chingachgook
# collada code
svn copy $branch/source/blender/collada source/blender/collada
# operator
svn merge -c 20401,20955,21077,24077,24079 $branch/source/blender/windowmanager/intern/wm_operators.c source/blender/windowmanager/intern/wm_operators.c
# menu
svn merge -c 24079 $branch/release/scripts/ui/space_info.py release/scripts/ui/space_info.py
# scons
svn merge -c 20398 $branch/source/blender/SConscript source/blender/SConscript
svn merge -c 20398,20691,20955,22726 $branch/tools/btools.py tools/btools.py
svn merge -c 20691,20955,22726 $branch/tools/Blender.py tools/Blender.py
svn merge -c 20398,20692,20955 $branch/config/linux2-config.py config/linux2-config.py
svn merge -c 22726 $branch/config/win64-vc-config.py config/win64-vc-config.py
svn merge -c 22726 $branch/config/win32-vc-config.py config/win32-vc-config.py
svn merge -c 24077 $branch/source/blender/windowmanager/SConscript source/blender/windowmanager/SConscript
# cmake
svn merge -c 23319,23905,24077,24158 $branch/CMakeLists.txt CMakeLists.txt
svn merge -c 23319 $branch/source/blender/CMakeLists.txt source/blender/CMakeLists.txt
svn merge -c 23319 $branch/source/creator/CMakeLists.txt source/creator/CMakeLists.txt
svn merge -c 23319 $branch/CMake/macros.cmake CMake/macros.cmake
svn merge -c 24077 $branch/source/blender/windowmanager/CMakeLists.txt source/blender/windowmanager/CMakeLists.txt
2009-10-30 15:35:50 +00:00
}
/* function used for WM_OT_save_mainfile too */
static int wm_collada_import_exec ( bContext * C , wmOperator * op )
{
char filename [ FILE_MAX ] ;
2010-06-14 03:52:10 +00:00
if ( ! RNA_property_is_set ( op - > ptr , " filepath " ) ) {
2010-03-29 08:33:35 +00:00
BKE_report ( op - > reports , RPT_ERROR , " No filename given " ) ;
return OPERATOR_CANCELLED ;
Merge of the COLLADA GSoC branch into trunk.
COLLADA code is disabled by default (it has dependencies requiring manual install).
SCons and CMake builds are supported on Windows and Linux, no Mac building yet. More on building COLLADA code: http://wiki.blender.org/index.php/User:Kazanbas/Building_Collada_Branch.
The detailed command log of the merge (can be useful for educational purposes):
branch=https://svn.blender.org/svnroot/bf-blender/branches/soc-2009-chingachgook
# collada code
svn copy $branch/source/blender/collada source/blender/collada
# operator
svn merge -c 20401,20955,21077,24077,24079 $branch/source/blender/windowmanager/intern/wm_operators.c source/blender/windowmanager/intern/wm_operators.c
# menu
svn merge -c 24079 $branch/release/scripts/ui/space_info.py release/scripts/ui/space_info.py
# scons
svn merge -c 20398 $branch/source/blender/SConscript source/blender/SConscript
svn merge -c 20398,20691,20955,22726 $branch/tools/btools.py tools/btools.py
svn merge -c 20691,20955,22726 $branch/tools/Blender.py tools/Blender.py
svn merge -c 20398,20692,20955 $branch/config/linux2-config.py config/linux2-config.py
svn merge -c 22726 $branch/config/win64-vc-config.py config/win64-vc-config.py
svn merge -c 22726 $branch/config/win32-vc-config.py config/win32-vc-config.py
svn merge -c 24077 $branch/source/blender/windowmanager/SConscript source/blender/windowmanager/SConscript
# cmake
svn merge -c 23319,23905,24077,24158 $branch/CMakeLists.txt CMakeLists.txt
svn merge -c 23319 $branch/source/blender/CMakeLists.txt source/blender/CMakeLists.txt
svn merge -c 23319 $branch/source/creator/CMakeLists.txt source/creator/CMakeLists.txt
svn merge -c 23319 $branch/CMake/macros.cmake CMake/macros.cmake
svn merge -c 24077 $branch/source/blender/windowmanager/CMakeLists.txt source/blender/windowmanager/CMakeLists.txt
2009-10-30 15:35:50 +00:00
}
2010-03-29 08:33:35 +00:00
2010-06-14 03:52:10 +00:00
RNA_string_get ( op - > ptr , " filepath " , filename ) ;
Merge of the COLLADA GSoC branch into trunk.
COLLADA code is disabled by default (it has dependencies requiring manual install).
SCons and CMake builds are supported on Windows and Linux, no Mac building yet. More on building COLLADA code: http://wiki.blender.org/index.php/User:Kazanbas/Building_Collada_Branch.
The detailed command log of the merge (can be useful for educational purposes):
branch=https://svn.blender.org/svnroot/bf-blender/branches/soc-2009-chingachgook
# collada code
svn copy $branch/source/blender/collada source/blender/collada
# operator
svn merge -c 20401,20955,21077,24077,24079 $branch/source/blender/windowmanager/intern/wm_operators.c source/blender/windowmanager/intern/wm_operators.c
# menu
svn merge -c 24079 $branch/release/scripts/ui/space_info.py release/scripts/ui/space_info.py
# scons
svn merge -c 20398 $branch/source/blender/SConscript source/blender/SConscript
svn merge -c 20398,20691,20955,22726 $branch/tools/btools.py tools/btools.py
svn merge -c 20691,20955,22726 $branch/tools/Blender.py tools/Blender.py
svn merge -c 20398,20692,20955 $branch/config/linux2-config.py config/linux2-config.py
svn merge -c 22726 $branch/config/win64-vc-config.py config/win64-vc-config.py
svn merge -c 22726 $branch/config/win32-vc-config.py config/win32-vc-config.py
svn merge -c 24077 $branch/source/blender/windowmanager/SConscript source/blender/windowmanager/SConscript
# cmake
svn merge -c 23319,23905,24077,24158 $branch/CMakeLists.txt CMakeLists.txt
svn merge -c 23319 $branch/source/blender/CMakeLists.txt source/blender/CMakeLists.txt
svn merge -c 23319 $branch/source/creator/CMakeLists.txt source/creator/CMakeLists.txt
svn merge -c 23319 $branch/CMake/macros.cmake CMake/macros.cmake
svn merge -c 24077 $branch/source/blender/windowmanager/CMakeLists.txt source/blender/windowmanager/CMakeLists.txt
2009-10-30 15:35:50 +00:00
collada_import ( C , filename ) ;
return OPERATOR_FINISHED ;
}
static void WM_OT_collada_import ( wmOperatorType * ot )
{
ot - > name = " Import COLLADA " ;
ot - > idname = " WM_OT_collada_import " ;
2010-03-29 08:33:35 +00:00
ot - > invoke = WM_operator_filesel ;
Merge of the COLLADA GSoC branch into trunk.
COLLADA code is disabled by default (it has dependencies requiring manual install).
SCons and CMake builds are supported on Windows and Linux, no Mac building yet. More on building COLLADA code: http://wiki.blender.org/index.php/User:Kazanbas/Building_Collada_Branch.
The detailed command log of the merge (can be useful for educational purposes):
branch=https://svn.blender.org/svnroot/bf-blender/branches/soc-2009-chingachgook
# collada code
svn copy $branch/source/blender/collada source/blender/collada
# operator
svn merge -c 20401,20955,21077,24077,24079 $branch/source/blender/windowmanager/intern/wm_operators.c source/blender/windowmanager/intern/wm_operators.c
# menu
svn merge -c 24079 $branch/release/scripts/ui/space_info.py release/scripts/ui/space_info.py
# scons
svn merge -c 20398 $branch/source/blender/SConscript source/blender/SConscript
svn merge -c 20398,20691,20955,22726 $branch/tools/btools.py tools/btools.py
svn merge -c 20691,20955,22726 $branch/tools/Blender.py tools/Blender.py
svn merge -c 20398,20692,20955 $branch/config/linux2-config.py config/linux2-config.py
svn merge -c 22726 $branch/config/win64-vc-config.py config/win64-vc-config.py
svn merge -c 22726 $branch/config/win32-vc-config.py config/win32-vc-config.py
svn merge -c 24077 $branch/source/blender/windowmanager/SConscript source/blender/windowmanager/SConscript
# cmake
svn merge -c 23319,23905,24077,24158 $branch/CMakeLists.txt CMakeLists.txt
svn merge -c 23319 $branch/source/blender/CMakeLists.txt source/blender/CMakeLists.txt
svn merge -c 23319 $branch/source/creator/CMakeLists.txt source/creator/CMakeLists.txt
svn merge -c 23319 $branch/CMake/macros.cmake CMake/macros.cmake
svn merge -c 24077 $branch/source/blender/windowmanager/CMakeLists.txt source/blender/windowmanager/CMakeLists.txt
2009-10-30 15:35:50 +00:00
ot - > exec = wm_collada_import_exec ;
ot - > poll = WM_operator_winactive ;
2010-07-01 19:28:45 +00:00
WM_operator_properties_filesel ( ot , FOLDERFILE | COLLADAFILE , FILE_BLENDER , FILE_OPENFILE , WM_FILESEL_FILEPATH ) ;
Merge of the COLLADA GSoC branch into trunk.
COLLADA code is disabled by default (it has dependencies requiring manual install).
SCons and CMake builds are supported on Windows and Linux, no Mac building yet. More on building COLLADA code: http://wiki.blender.org/index.php/User:Kazanbas/Building_Collada_Branch.
The detailed command log of the merge (can be useful for educational purposes):
branch=https://svn.blender.org/svnroot/bf-blender/branches/soc-2009-chingachgook
# collada code
svn copy $branch/source/blender/collada source/blender/collada
# operator
svn merge -c 20401,20955,21077,24077,24079 $branch/source/blender/windowmanager/intern/wm_operators.c source/blender/windowmanager/intern/wm_operators.c
# menu
svn merge -c 24079 $branch/release/scripts/ui/space_info.py release/scripts/ui/space_info.py
# scons
svn merge -c 20398 $branch/source/blender/SConscript source/blender/SConscript
svn merge -c 20398,20691,20955,22726 $branch/tools/btools.py tools/btools.py
svn merge -c 20691,20955,22726 $branch/tools/Blender.py tools/Blender.py
svn merge -c 20398,20692,20955 $branch/config/linux2-config.py config/linux2-config.py
svn merge -c 22726 $branch/config/win64-vc-config.py config/win64-vc-config.py
svn merge -c 22726 $branch/config/win32-vc-config.py config/win32-vc-config.py
svn merge -c 24077 $branch/source/blender/windowmanager/SConscript source/blender/windowmanager/SConscript
# cmake
svn merge -c 23319,23905,24077,24158 $branch/CMakeLists.txt CMakeLists.txt
svn merge -c 23319 $branch/source/blender/CMakeLists.txt source/blender/CMakeLists.txt
svn merge -c 23319 $branch/source/creator/CMakeLists.txt source/creator/CMakeLists.txt
svn merge -c 23319 $branch/CMake/macros.cmake CMake/macros.cmake
svn merge -c 24077 $branch/source/blender/windowmanager/CMakeLists.txt source/blender/windowmanager/CMakeLists.txt
2009-10-30 15:35:50 +00:00
}
# endif
2008-12-19 18:28:37 +00:00
/* *********************** */
2008-01-01 09:07:02 +00:00
static void WM_OT_window_fullscreen_toggle ( wmOperatorType * ot )
{
2009-09-12 17:16:12 +00:00
ot - > name = " Toggle Fullscreen " ;
ot - > idname = " WM_OT_window_fullscreen_toggle " ;
2010-02-10 21:15:44 +00:00
ot - > description = " Toggle the current window fullscreen " ;
2008-01-01 09:07:02 +00:00
2010-10-16 02:40:31 +00:00
ot - > exec = wm_window_fullscreen_toggle_exec ;
2009-09-12 17:16:12 +00:00
ot - > poll = WM_operator_winactive ;
2008-01-01 09:07:02 +00:00
}
2009-01-31 13:30:56 +00:00
static int wm_exit_blender_op ( bContext * C , wmOperator * op )
{
WM_operator_free ( op ) ;
WM_exit ( C ) ;
return OPERATOR_FINISHED ;
}
2010-10-11 22:05:45 +00:00
static void WM_OT_quit_blender ( wmOperatorType * ot )
2008-01-15 18:54:38 +00:00
{
2010-10-11 22:05:45 +00:00
ot - > name = " Quit Blender " ;
ot - > idname = " WM_OT_quit_blender " ;
2010-02-10 21:15:44 +00:00
ot - > description = " Quit Blender " ;
2008-01-15 18:54:38 +00:00
2008-12-17 15:38:40 +00:00
ot - > invoke = WM_operator_confirm ;
2008-01-15 18:54:38 +00:00
ot - > exec = wm_exit_blender_op ;
ot - > poll = WM_operator_winactive ;
}
2010-10-18 20:41:52 +00:00
/* *********************** */
2011-05-09 08:01:48 +00:00
# if defined(WIN32)
2011-05-02 08:36:00 +00:00
static int wm_console_toggle_op ( bContext * UNUSED ( C ) , wmOperator * UNUSED ( op ) )
2010-10-18 20:41:52 +00:00
{
2011-05-02 08:07:24 +00:00
GHOST_toggleConsole ( 2 ) ;
2010-10-18 20:41:52 +00:00
return OPERATOR_FINISHED ;
}
2011-04-06 12:30:07 +00:00
static void WM_OT_console_toggle ( wmOperatorType * ot )
2010-10-18 20:41:52 +00:00
{
ot - > name = " Toggle System Console " ;
2011-04-06 12:30:07 +00:00
ot - > idname = " WM_OT_console_toggle " ;
2010-10-18 20:41:52 +00:00
ot - > description = " Toggle System Console " ;
2011-04-06 12:30:07 +00:00
ot - > exec = wm_console_toggle_op ;
2010-10-18 20:41:52 +00:00
ot - > poll = WM_operator_winactive ;
}
2011-05-09 08:01:48 +00:00
# endif
2.5
Vertex Paint back!
Added WM level "paint cursor" system, which manages a custom painting
cursor for tools or modes.
- Activate it with WM_paint_cursor_activate(). That function wants two
callbacks, a poll(C) to check whether there's a cursor in given context
and ARegion, and a draw(C, x, y) which gets called when appropriate.
- While paintcursor is active, the WM handles necessary redrawing events
for all regions, also to nicely clear the cursor on region exit.
- WM_paint_cursor_activate returns a handle, which you have to use to
end the paint cursor. This handle also means you can register as many
custom cursors as you want.
At the moment, vertex paint mode registers only a mousemove handler,
all other events are still normally handled. This is stuff for the
future todo.
2009-01-09 13:55:45 +00:00
/* ************ default paint cursors, draw always around cursor *********** */
/*
- returns handler to free
- poll ( bContext ) : returns 1 if draw should happen
- draw ( bContext ) : drawing callback for paint cursor
*/
2009-01-24 16:59:55 +00:00
void * WM_paint_cursor_activate ( wmWindowManager * wm , int ( * poll ) ( bContext * C ) ,
2010-03-22 09:30:00 +00:00
wmPaintCursorDraw draw , void * customdata )
2.5
Vertex Paint back!
Added WM level "paint cursor" system, which manages a custom painting
cursor for tools or modes.
- Activate it with WM_paint_cursor_activate(). That function wants two
callbacks, a poll(C) to check whether there's a cursor in given context
and ARegion, and a draw(C, x, y) which gets called when appropriate.
- While paintcursor is active, the WM handles necessary redrawing events
for all regions, also to nicely clear the cursor on region exit.
- WM_paint_cursor_activate returns a handle, which you have to use to
end the paint cursor. This handle also means you can register as many
custom cursors as you want.
At the moment, vertex paint mode registers only a mousemove handler,
all other events are still normally handled. This is stuff for the
future todo.
2009-01-09 13:55:45 +00:00
{
wmPaintCursor * pc = MEM_callocN ( sizeof ( wmPaintCursor ) , " paint cursor " ) ;
BLI_addtail ( & wm - > paintcursors , pc ) ;
2009-01-24 16:59:55 +00:00
pc - > customdata = customdata ;
2.5
Vertex Paint back!
Added WM level "paint cursor" system, which manages a custom painting
cursor for tools or modes.
- Activate it with WM_paint_cursor_activate(). That function wants two
callbacks, a poll(C) to check whether there's a cursor in given context
and ARegion, and a draw(C, x, y) which gets called when appropriate.
- While paintcursor is active, the WM handles necessary redrawing events
for all regions, also to nicely clear the cursor on region exit.
- WM_paint_cursor_activate returns a handle, which you have to use to
end the paint cursor. This handle also means you can register as many
custom cursors as you want.
At the moment, vertex paint mode registers only a mousemove handler,
all other events are still normally handled. This is stuff for the
future todo.
2009-01-09 13:55:45 +00:00
pc - > poll = poll ;
pc - > draw = draw ;
return pc ;
}
void WM_paint_cursor_end ( wmWindowManager * wm , void * handle )
{
wmPaintCursor * pc ;
for ( pc = wm - > paintcursors . first ; pc ; pc = pc - > next ) {
if ( pc = = ( wmPaintCursor * ) handle ) {
BLI_remlink ( & wm - > paintcursors , pc ) ;
MEM_freeN ( pc ) ;
return ;
}
}
}
2.5: gesture code in WM
- Simplified and cleaned previous border code
It was a bit too complex, too many data manipulations
Original idea was to have WM API calls to manage border, circle, lines,
lasso, etc. This now means that WM provides callbacks for custom operators,
so it's very easy to make them. Check bottom of screen_edit.c for an
example.
Currently two borders were coded; with and without cross hair.
Press Bkey in any area-region to test it (note: time window has wrong matrix!)
Some specs to note:
- gestures are in region space, and draw 'over'. That latter still needs some
work when we do real composites.
- only the active region is redrawn.
- on todo is the generic gesture engine for 'tweak' or like how currently grab
gestures in Blender work. These will be configurable per area-region, and WM
then will send the proper "Gesture Event" with properties (N, S, E, W, etc)
to which you then can assign operators. Such events will be generated with low
priority, so other handlers who swallowed mouse events have preference.
2008-11-19 13:16:05 +00:00
/* ************ window gesture operator-callback definitions ************** */
2008-01-19 17:54:05 +00:00
/*
2.5: gesture code in WM
- Simplified and cleaned previous border code
It was a bit too complex, too many data manipulations
Original idea was to have WM API calls to manage border, circle, lines,
lasso, etc. This now means that WM provides callbacks for custom operators,
so it's very easy to make them. Check bottom of screen_edit.c for an
example.
Currently two borders were coded; with and without cross hair.
Press Bkey in any area-region to test it (note: time window has wrong matrix!)
Some specs to note:
- gestures are in region space, and draw 'over'. That latter still needs some
work when we do real composites.
- only the active region is redrawn.
- on todo is the generic gesture engine for 'tweak' or like how currently grab
gestures in Blender work. These will be configurable per area-region, and WM
then will send the proper "Gesture Event" with properties (N, S, E, W, etc)
to which you then can assign operators. Such events will be generated with low
priority, so other handlers who swallowed mouse events have preference.
2008-11-19 13:16:05 +00:00
* These are default callbacks for use in operators requiring gesture input
2008-01-19 17:54:05 +00:00
*/
2008-11-24 10:45:36 +00:00
/* **************** Border gesture *************** */
/* Border gesture has two types:
1 ) WM_GESTURE_CROSS_RECT : starts a cross , on mouse click it changes to border
2 ) WM_GESTURE_RECT : starts immediate as a border , on mouse click or release it ends
It stores 4 values ( xmin , xmax , ymin , ymax ) and event it ended with ( event_type )
*/
2011-03-21 03:22:33 +00:00
static int border_apply_rect ( wmOperator * op )
2008-01-19 17:54:05 +00:00
{
2.5: gesture code in WM
- Simplified and cleaned previous border code
It was a bit too complex, too many data manipulations
Original idea was to have WM API calls to manage border, circle, lines,
lasso, etc. This now means that WM provides callbacks for custom operators,
so it's very easy to make them. Check bottom of screen_edit.c for an
example.
Currently two borders were coded; with and without cross hair.
Press Bkey in any area-region to test it (note: time window has wrong matrix!)
Some specs to note:
- gestures are in region space, and draw 'over'. That latter still needs some
work when we do real composites.
- only the active region is redrawn.
- on todo is the generic gesture engine for 'tweak' or like how currently grab
gestures in Blender work. These will be configurable per area-region, and WM
then will send the proper "Gesture Event" with properties (N, S, E, W, etc)
to which you then can assign operators. Such events will be generated with low
priority, so other handlers who swallowed mouse events have preference.
2008-11-19 13:16:05 +00:00
wmGesture * gesture = op - > customdata ;
rcti * rect = gesture - > customdata ;
2009-01-31 10:00:08 +00:00
if ( rect - > xmin = = rect - > xmax | | rect - > ymin = = rect - > ymax )
return 0 ;
2011-03-20 00:34:08 +00:00
2009-01-31 13:30:56 +00:00
/* operator arguments and storage. */
2011-03-20 00:34:08 +00:00
RNA_int_set ( op - > ptr , " xmin " , MIN2 ( rect - > xmin , rect - > xmax ) ) ;
RNA_int_set ( op - > ptr , " ymin " , MIN2 ( rect - > ymin , rect - > ymax ) ) ;
RNA_int_set ( op - > ptr , " xmax " , MAX2 ( rect - > xmin , rect - > xmax ) ) ;
RNA_int_set ( op - > ptr , " ymax " , MAX2 ( rect - > ymin , rect - > ymax ) ) ;
return 1 ;
}
static int border_apply ( bContext * C , wmOperator * op , int gesture_mode )
{
2011-03-21 03:22:33 +00:00
if ( ! border_apply_rect ( op ) )
2011-03-20 00:34:08 +00:00
return 0 ;
2009-01-31 13:30:56 +00:00
2009-07-26 12:52:39 +00:00
/* XXX weak; border should be configured for this without reading event types */
2009-11-06 22:51:08 +00:00
if ( RNA_struct_find_property ( op - > ptr , " gesture_mode " ) )
RNA_int_set ( op - > ptr , " gesture_mode " , gesture_mode ) ;
2009-01-31 13:30:56 +00:00
op - > type - > exec ( C , op ) ;
return 1 ;
2.5 Branch
==========
* Changed wmOperatorType, removing init/exit callbacks and adding cancel
callback, removed default storage in favor of properties. Defined return
values for exec/invoke/modal/cancel.
* Don't allocate operator on the stack, and removed operator copy for
handlers. Now it frees based on return values from callbacks, and just
keeps a wmOperator on the heap. Also it now registers after the operator
is fully finished, to get the correct final properties.
* Changed OP_get_* functions to return 1 if the property is found and 0
otherwise, gives more readable code in my opinion. Added OP_verify_*
functions to quickly check if the property is available and set if it's
not, that's common for exec/invoke.
* Removed WM_operatortypelist_append in favor of WM_operatortype_append
which takes a function pointer instead of a list, avoids macro's and
duplicating code.
* Fix a crash where the handler would still be used while it was freed by
the operator.
* Spacetypes now have operatortypes() and keymap() callbacks to abstract
them a bit more.
* Renamed C->curarea to C->area for consistency. Removed View3D/View2D/
SpaceIpo from bContext, seems bad to keep these.
* Set context variables like window/screen/area/region to NULL again when
leaving that context, instead of leaving the pointers there.
* Added if(G.f & G_DEBUG) for many of the prints, makes output a bit
cleaner and easier to debug.
* Fixed priority of the editors/interface module in scons, would otherwise
give link errors.
* Added start of generic view2d api.
* Added space_time with some basic drawing and a single operator to change
the frame.
2008-06-11 10:10:31 +00:00
}
2009-01-02 14:11:18 +00:00
static void wm_gesture_end ( bContext * C , wmOperator * op )
2.5 Branch
==========
* Changed wmOperatorType, removing init/exit callbacks and adding cancel
callback, removed default storage in favor of properties. Defined return
values for exec/invoke/modal/cancel.
* Don't allocate operator on the stack, and removed operator copy for
handlers. Now it frees based on return values from callbacks, and just
keeps a wmOperator on the heap. Also it now registers after the operator
is fully finished, to get the correct final properties.
* Changed OP_get_* functions to return 1 if the property is found and 0
otherwise, gives more readable code in my opinion. Added OP_verify_*
functions to quickly check if the property is available and set if it's
not, that's common for exec/invoke.
* Removed WM_operatortypelist_append in favor of WM_operatortype_append
which takes a function pointer instead of a list, avoids macro's and
duplicating code.
* Fix a crash where the handler would still be used while it was freed by
the operator.
* Spacetypes now have operatortypes() and keymap() callbacks to abstract
them a bit more.
* Renamed C->curarea to C->area for consistency. Removed View3D/View2D/
SpaceIpo from bContext, seems bad to keep these.
* Set context variables like window/screen/area/region to NULL again when
leaving that context, instead of leaving the pointers there.
* Added if(G.f & G_DEBUG) for many of the prints, makes output a bit
cleaner and easier to debug.
* Fixed priority of the editors/interface module in scons, would otherwise
give link errors.
* Added start of generic view2d api.
* Added space_time with some basic drawing and a single operator to change
the frame.
2008-06-11 10:10:31 +00:00
{
2.5: gesture code in WM
- Simplified and cleaned previous border code
It was a bit too complex, too many data manipulations
Original idea was to have WM API calls to manage border, circle, lines,
lasso, etc. This now means that WM provides callbacks for custom operators,
so it's very easy to make them. Check bottom of screen_edit.c for an
example.
Currently two borders were coded; with and without cross hair.
Press Bkey in any area-region to test it (note: time window has wrong matrix!)
Some specs to note:
- gestures are in region space, and draw 'over'. That latter still needs some
work when we do real composites.
- only the active region is redrawn.
- on todo is the generic gesture engine for 'tweak' or like how currently grab
gestures in Blender work. These will be configurable per area-region, and WM
then will send the proper "Gesture Event" with properties (N, S, E, W, etc)
to which you then can assign operators. Such events will be generated with low
priority, so other handlers who swallowed mouse events have preference.
2008-11-19 13:16:05 +00:00
wmGesture * gesture = op - > customdata ;
WM_gesture_end ( C , gesture ) ; /* frees gesture itself, and unregisters from window */
op - > customdata = NULL ;
Lots of stuff; couldn't commit in parts because of refactor work.
* Changes in interface/ module
This commit brings back the way how buttons/menus work under control
of WM event system. The previous implementation extended usage of
handlers and operators in an interesting but confusing way. Better to
try it first according the design specs. :)
Most obviously:
- modal-handler operators are not stored anymore in regions/areas/windows.
such modal handlers own their operator, and should remove it themselves.
- removed code to move handlers from one queue to another.
(needs review with brecht!)
- WM fix: the API call to remove a modal handler got removed. This was a
dangerous thing anyway, and you should leave that to the event system.
Now, if a handler modal() call gets a cancel/finish return, it frees
itself in event system. WM_event_remove_modal_handler was a confusing
call anyway!
Todo:
- allow button-activate to refresh after using button
- re-enable arrow keys for menus
(do both after commit)
- review return values of operator callbacks in interface_ops.c
* Fixes in WM system
- Freeing areas/regions/windows, also on quit, now correctly closes
running modal handlers
- On starting a modal handler, the handler now stores previous area
and region context, so they send proper notifiers etc.
* Other fixes
- Area-split operator had bug, wrong minimal size checking. This
solves error when trying to split a very narrow area.
- removed DNA_USHORT_FIX from screen_types.h, gave warning
- operators didn't get ID name copied when activated, needed for
later re-use or saving.
2008-12-02 14:22:52 +00:00
2008-12-18 02:56:48 +00:00
ED_area_tag_redraw ( CTX_wm_area ( C ) ) ;
2.5 Branch
==========
* Changed wmOperatorType, removing init/exit callbacks and adding cancel
callback, removed default storage in favor of properties. Defined return
values for exec/invoke/modal/cancel.
* Don't allocate operator on the stack, and removed operator copy for
handlers. Now it frees based on return values from callbacks, and just
keeps a wmOperator on the heap. Also it now registers after the operator
is fully finished, to get the correct final properties.
* Changed OP_get_* functions to return 1 if the property is found and 0
otherwise, gives more readable code in my opinion. Added OP_verify_*
functions to quickly check if the property is available and set if it's
not, that's common for exec/invoke.
* Removed WM_operatortypelist_append in favor of WM_operatortype_append
which takes a function pointer instead of a list, avoids macro's and
duplicating code.
* Fix a crash where the handler would still be used while it was freed by
the operator.
* Spacetypes now have operatortypes() and keymap() callbacks to abstract
them a bit more.
* Renamed C->curarea to C->area for consistency. Removed View3D/View2D/
SpaceIpo from bContext, seems bad to keep these.
* Set context variables like window/screen/area/region to NULL again when
leaving that context, instead of leaving the pointers there.
* Added if(G.f & G_DEBUG) for many of the prints, makes output a bit
cleaner and easier to debug.
* Fixed priority of the editors/interface module in scons, would otherwise
give link errors.
* Added start of generic view2d api.
* Added space_time with some basic drawing and a single operator to change
the frame.
2008-06-11 10:10:31 +00:00
2009-02-07 14:03:34 +00:00
if ( RNA_struct_find_property ( op - > ptr , " cursor " ) )
WM_cursor_restore ( CTX_wm_window ( C ) ) ;
2.5 Branch
==========
* Changed wmOperatorType, removing init/exit callbacks and adding cancel
callback, removed default storage in favor of properties. Defined return
values for exec/invoke/modal/cancel.
* Don't allocate operator on the stack, and removed operator copy for
handlers. Now it frees based on return values from callbacks, and just
keeps a wmOperator on the heap. Also it now registers after the operator
is fully finished, to get the correct final properties.
* Changed OP_get_* functions to return 1 if the property is found and 0
otherwise, gives more readable code in my opinion. Added OP_verify_*
functions to quickly check if the property is available and set if it's
not, that's common for exec/invoke.
* Removed WM_operatortypelist_append in favor of WM_operatortype_append
which takes a function pointer instead of a list, avoids macro's and
duplicating code.
* Fix a crash where the handler would still be used while it was freed by
the operator.
* Spacetypes now have operatortypes() and keymap() callbacks to abstract
them a bit more.
* Renamed C->curarea to C->area for consistency. Removed View3D/View2D/
SpaceIpo from bContext, seems bad to keep these.
* Set context variables like window/screen/area/region to NULL again when
leaving that context, instead of leaving the pointers there.
* Added if(G.f & G_DEBUG) for many of the prints, makes output a bit
cleaner and easier to debug.
* Fixed priority of the editors/interface module in scons, would otherwise
give link errors.
* Added start of generic view2d api.
* Added space_time with some basic drawing and a single operator to change
the frame.
2008-06-11 10:10:31 +00:00
}
2.5: gesture code in WM
- Simplified and cleaned previous border code
It was a bit too complex, too many data manipulations
Original idea was to have WM API calls to manage border, circle, lines,
lasso, etc. This now means that WM provides callbacks for custom operators,
so it's very easy to make them. Check bottom of screen_edit.c for an
example.
Currently two borders were coded; with and without cross hair.
Press Bkey in any area-region to test it (note: time window has wrong matrix!)
Some specs to note:
- gestures are in region space, and draw 'over'. That latter still needs some
work when we do real composites.
- only the active region is redrawn.
- on todo is the generic gesture engine for 'tweak' or like how currently grab
gestures in Blender work. These will be configurable per area-region, and WM
then will send the proper "Gesture Event" with properties (N, S, E, W, etc)
to which you then can assign operators. Such events will be generated with low
priority, so other handlers who swallowed mouse events have preference.
2008-11-19 13:16:05 +00:00
int WM_border_select_invoke ( bContext * C , wmOperator * op , wmEvent * event )
2008-01-19 17:54:05 +00:00
{
Key Configuration
Keymaps are now saveable and configurable from the user preferences, note
that editing one item in a keymap means the whole keymap is now defined by
the user and will not be updated by Blender, an option for syncing might be
added later. The outliner interface is still there, but I will probably
remove it.
There's actually 3 levels now:
* Default builtin key configuration.
* Key configuration loaded from .py file, for configs like Blender 2.4x
or other 3D applications.
* Keymaps edited by the user and saved in .B.blend. These can be saved
to .py files as well to make creating distributable configurations
easier.
Also, user preferences sections were reorganized a bit, now there is:
Interface, Editing, Input, Files and System.
Implementation notes:
* wmKeyConfig was added which represents a key configuration containing
keymaps.
* wmKeymapItem was renamed to wmKeyMapItem for consistency with wmKeyMap.
* Modal maps are not wrapped yet.
* User preferences DNA file reading did not support newdataadr() yet,
added this now for reading keymaps.
* Key configuration related settings are now RNA wrapped.
* is_property_set and is_property_hidden python methods were added.
2009-10-08 18:40:03 +00:00
if ( ISTWEAK ( event - > type ) )
2009-07-26 12:52:39 +00:00
op - > customdata = WM_gesture_new ( C , event , WM_GESTURE_RECT ) ;
else
op - > customdata = WM_gesture_new ( C , event , WM_GESTURE_CROSS_RECT ) ;
2008-01-19 17:54:05 +00:00
2.5: gesture code in WM
- Simplified and cleaned previous border code
It was a bit too complex, too many data manipulations
Original idea was to have WM API calls to manage border, circle, lines,
lasso, etc. This now means that WM provides callbacks for custom operators,
so it's very easy to make them. Check bottom of screen_edit.c for an
example.
Currently two borders were coded; with and without cross hair.
Press Bkey in any area-region to test it (note: time window has wrong matrix!)
Some specs to note:
- gestures are in region space, and draw 'over'. That latter still needs some
work when we do real composites.
- only the active region is redrawn.
- on todo is the generic gesture engine for 'tweak' or like how currently grab
gestures in Blender work. These will be configurable per area-region, and WM
then will send the proper "Gesture Event" with properties (N, S, E, W, etc)
to which you then can assign operators. Such events will be generated with low
priority, so other handlers who swallowed mouse events have preference.
2008-11-19 13:16:05 +00:00
/* add modal handler */
2009-09-18 12:43:36 +00:00
WM_event_add_modal_handler ( C , op ) ;
2.5: gesture code in WM
- Simplified and cleaned previous border code
It was a bit too complex, too many data manipulations
Original idea was to have WM API calls to manage border, circle, lines,
lasso, etc. This now means that WM provides callbacks for custom operators,
so it's very easy to make them. Check bottom of screen_edit.c for an
example.
Currently two borders were coded; with and without cross hair.
Press Bkey in any area-region to test it (note: time window has wrong matrix!)
Some specs to note:
- gestures are in region space, and draw 'over'. That latter still needs some
work when we do real composites.
- only the active region is redrawn.
- on todo is the generic gesture engine for 'tweak' or like how currently grab
gestures in Blender work. These will be configurable per area-region, and WM
then will send the proper "Gesture Event" with properties (N, S, E, W, etc)
to which you then can assign operators. Such events will be generated with low
priority, so other handlers who swallowed mouse events have preference.
2008-11-19 13:16:05 +00:00
2008-12-27 16:09:56 +00:00
wm_gesture_tag_redraw ( C ) ;
2007-12-24 18:27:28 +00:00
2.5: gesture code in WM
- Simplified and cleaned previous border code
It was a bit too complex, too many data manipulations
Original idea was to have WM API calls to manage border, circle, lines,
lasso, etc. This now means that WM provides callbacks for custom operators,
so it's very easy to make them. Check bottom of screen_edit.c for an
example.
Currently two borders were coded; with and without cross hair.
Press Bkey in any area-region to test it (note: time window has wrong matrix!)
Some specs to note:
- gestures are in region space, and draw 'over'. That latter still needs some
work when we do real composites.
- only the active region is redrawn.
- on todo is the generic gesture engine for 'tweak' or like how currently grab
gestures in Blender work. These will be configurable per area-region, and WM
then will send the proper "Gesture Event" with properties (N, S, E, W, etc)
to which you then can assign operators. Such events will be generated with low
priority, so other handlers who swallowed mouse events have preference.
2008-11-19 13:16:05 +00:00
return OPERATOR_RUNNING_MODAL ;
2008-01-19 17:54:05 +00:00
}
2.5: gesture code in WM
- Simplified and cleaned previous border code
It was a bit too complex, too many data manipulations
Original idea was to have WM API calls to manage border, circle, lines,
lasso, etc. This now means that WM provides callbacks for custom operators,
so it's very easy to make them. Check bottom of screen_edit.c for an
example.
Currently two borders were coded; with and without cross hair.
Press Bkey in any area-region to test it (note: time window has wrong matrix!)
Some specs to note:
- gestures are in region space, and draw 'over'. That latter still needs some
work when we do real composites.
- only the active region is redrawn.
- on todo is the generic gesture engine for 'tweak' or like how currently grab
gestures in Blender work. These will be configurable per area-region, and WM
then will send the proper "Gesture Event" with properties (N, S, E, W, etc)
to which you then can assign operators. Such events will be generated with low
priority, so other handlers who swallowed mouse events have preference.
2008-11-19 13:16:05 +00:00
int WM_border_select_modal ( bContext * C , wmOperator * op , wmEvent * event )
2008-01-19 17:54:05 +00:00
{
2.5: gesture code in WM
- Simplified and cleaned previous border code
It was a bit too complex, too many data manipulations
Original idea was to have WM API calls to manage border, circle, lines,
lasso, etc. This now means that WM provides callbacks for custom operators,
so it's very easy to make them. Check bottom of screen_edit.c for an
example.
Currently two borders were coded; with and without cross hair.
Press Bkey in any area-region to test it (note: time window has wrong matrix!)
Some specs to note:
- gestures are in region space, and draw 'over'. That latter still needs some
work when we do real composites.
- only the active region is redrawn.
- on todo is the generic gesture engine for 'tweak' or like how currently grab
gestures in Blender work. These will be configurable per area-region, and WM
then will send the proper "Gesture Event" with properties (N, S, E, W, etc)
to which you then can assign operators. Such events will be generated with low
priority, so other handlers who swallowed mouse events have preference.
2008-11-19 13:16:05 +00:00
wmGesture * gesture = op - > customdata ;
rcti * rect = gesture - > customdata ;
int sx , sy ;
2009-11-06 22:51:08 +00:00
if ( event - > type = = MOUSEMOVE ) {
wm_subwindow_getorigin ( CTX_wm_window ( C ) , gesture - > swinid , & sx , & sy ) ;
if ( gesture - > type = = WM_GESTURE_CROSS_RECT & & gesture - > mode = = 0 ) {
rect - > xmin = rect - > xmax = event - > x - sx ;
rect - > ymin = rect - > ymax = event - > y - sy ;
}
else {
rect - > xmax = event - > x - sx ;
rect - > ymax = event - > y - sy ;
}
2011-03-21 03:22:33 +00:00
border_apply_rect ( op ) ;
2009-11-06 22:51:08 +00:00
wm_gesture_tag_redraw ( C ) ;
}
else if ( event - > type = = EVT_MODAL_MAP ) {
switch ( event - > val ) {
2010-04-04 00:21:37 +00:00
case GESTURE_MODAL_BEGIN :
2.5: gesture code in WM
- Simplified and cleaned previous border code
It was a bit too complex, too many data manipulations
Original idea was to have WM API calls to manage border, circle, lines,
lasso, etc. This now means that WM provides callbacks for custom operators,
so it's very easy to make them. Check bottom of screen_edit.c for an
example.
Currently two borders were coded; with and without cross hair.
Press Bkey in any area-region to test it (note: time window has wrong matrix!)
Some specs to note:
- gestures are in region space, and draw 'over'. That latter still needs some
work when we do real composites.
- only the active region is redrawn.
- on todo is the generic gesture engine for 'tweak' or like how currently grab
gestures in Blender work. These will be configurable per area-region, and WM
then will send the proper "Gesture Event" with properties (N, S, E, W, etc)
to which you then can assign operators. Such events will be generated with low
priority, so other handlers who swallowed mouse events have preference.
2008-11-19 13:16:05 +00:00
if ( gesture - > type = = WM_GESTURE_CROSS_RECT & & gesture - > mode = = 0 ) {
2009-11-06 22:51:08 +00:00
gesture - > mode = 1 ;
wm_gesture_tag_redraw ( C ) ;
2.5: gesture code in WM
- Simplified and cleaned previous border code
It was a bit too complex, too many data manipulations
Original idea was to have WM API calls to manage border, circle, lines,
lasso, etc. This now means that WM provides callbacks for custom operators,
so it's very easy to make them. Check bottom of screen_edit.c for an
example.
Currently two borders were coded; with and without cross hair.
Press Bkey in any area-region to test it (note: time window has wrong matrix!)
Some specs to note:
- gestures are in region space, and draw 'over'. That latter still needs some
work when we do real composites.
- only the active region is redrawn.
- on todo is the generic gesture engine for 'tweak' or like how currently grab
gestures in Blender work. These will be configurable per area-region, and WM
then will send the proper "Gesture Event" with properties (N, S, E, W, etc)
to which you then can assign operators. Such events will be generated with low
priority, so other handlers who swallowed mouse events have preference.
2008-11-19 13:16:05 +00:00
}
2008-01-19 17:54:05 +00:00
break ;
2009-11-06 22:51:08 +00:00
case GESTURE_MODAL_SELECT :
case GESTURE_MODAL_DESELECT :
2010-04-02 03:52:44 +00:00
case GESTURE_MODAL_IN :
case GESTURE_MODAL_OUT :
2009-11-06 22:51:08 +00:00
if ( border_apply ( C , op , event - > val ) ) {
2009-01-02 14:11:18 +00:00
wm_gesture_end ( C , op ) ;
2009-11-06 22:51:08 +00:00
return OPERATOR_FINISHED ;
2008-01-19 17:54:05 +00:00
}
2009-11-06 22:51:08 +00:00
wm_gesture_end ( C , op ) ;
return OPERATOR_CANCELLED ;
2008-01-19 17:54:05 +00:00
break ;
2009-11-06 22:51:08 +00:00
case GESTURE_MODAL_CANCEL :
2009-01-02 14:11:18 +00:00
wm_gesture_end ( C , op ) ;
2.5: gesture code in WM
- Simplified and cleaned previous border code
It was a bit too complex, too many data manipulations
Original idea was to have WM API calls to manage border, circle, lines,
lasso, etc. This now means that WM provides callbacks for custom operators,
so it's very easy to make them. Check bottom of screen_edit.c for an
example.
Currently two borders were coded; with and without cross hair.
Press Bkey in any area-region to test it (note: time window has wrong matrix!)
Some specs to note:
- gestures are in region space, and draw 'over'. That latter still needs some
work when we do real composites.
- only the active region is redrawn.
- on todo is the generic gesture engine for 'tweak' or like how currently grab
gestures in Blender work. These will be configurable per area-region, and WM
then will send the proper "Gesture Event" with properties (N, S, E, W, etc)
to which you then can assign operators. Such events will be generated with low
priority, so other handlers who swallowed mouse events have preference.
2008-11-19 13:16:05 +00:00
return OPERATOR_CANCELLED ;
2009-11-06 22:51:08 +00:00
}
2008-01-19 17:54:05 +00:00
}
2009-11-06 22:51:08 +00:00
// // Allow view navigation???
// else {
// return OPERATOR_PASS_THROUGH;
// }
2.5 Branch
==========
* Changed wmOperatorType, removing init/exit callbacks and adding cancel
callback, removed default storage in favor of properties. Defined return
values for exec/invoke/modal/cancel.
* Don't allocate operator on the stack, and removed operator copy for
handlers. Now it frees based on return values from callbacks, and just
keeps a wmOperator on the heap. Also it now registers after the operator
is fully finished, to get the correct final properties.
* Changed OP_get_* functions to return 1 if the property is found and 0
otherwise, gives more readable code in my opinion. Added OP_verify_*
functions to quickly check if the property is available and set if it's
not, that's common for exec/invoke.
* Removed WM_operatortypelist_append in favor of WM_operatortype_append
which takes a function pointer instead of a list, avoids macro's and
duplicating code.
* Fix a crash where the handler would still be used while it was freed by
the operator.
* Spacetypes now have operatortypes() and keymap() callbacks to abstract
them a bit more.
* Renamed C->curarea to C->area for consistency. Removed View3D/View2D/
SpaceIpo from bContext, seems bad to keep these.
* Set context variables like window/screen/area/region to NULL again when
leaving that context, instead of leaving the pointers there.
* Added if(G.f & G_DEBUG) for many of the prints, makes output a bit
cleaner and easier to debug.
* Fixed priority of the editors/interface module in scons, would otherwise
give link errors.
* Added start of generic view2d api.
* Added space_time with some basic drawing and a single operator to change
the frame.
2008-06-11 10:10:31 +00:00
return OPERATOR_RUNNING_MODAL ;
2008-01-19 17:54:05 +00:00
}
2008-12-21 16:24:19 +00:00
/* **************** circle gesture *************** */
2.5
Vertex Paint back!
Added WM level "paint cursor" system, which manages a custom painting
cursor for tools or modes.
- Activate it with WM_paint_cursor_activate(). That function wants two
callbacks, a poll(C) to check whether there's a cursor in given context
and ARegion, and a draw(C, x, y) which gets called when appropriate.
- While paintcursor is active, the WM handles necessary redrawing events
for all regions, also to nicely clear the cursor on region exit.
- WM_paint_cursor_activate returns a handle, which you have to use to
end the paint cursor. This handle also means you can register as many
custom cursors as you want.
At the moment, vertex paint mode registers only a mousemove handler,
all other events are still normally handled. This is stuff for the
future todo.
2009-01-09 13:55:45 +00:00
/* works now only for selection or modal paint stuff, calls exec while hold mouse, exit on release */
2008-12-21 16:24:19 +00:00
2009-11-05 17:32:06 +00:00
# ifdef GESTURE_MEMORY
int circle_select_size = 25 ; // XXX - need some operator memory thing\!
# endif
2008-12-21 16:24:19 +00:00
int WM_gesture_circle_invoke ( bContext * C , wmOperator * op , wmEvent * event )
{
op - > customdata = WM_gesture_new ( C , event , WM_GESTURE_CIRCLE ) ;
/* add modal handler */
2009-09-18 12:43:36 +00:00
WM_event_add_modal_handler ( C , op ) ;
2008-12-21 16:24:19 +00:00
2008-12-27 16:09:56 +00:00
wm_gesture_tag_redraw ( C ) ;
2008-12-21 16:24:19 +00:00
return OPERATOR_RUNNING_MODAL ;
}
2009-01-24 13:45:24 +00:00
static void gesture_circle_apply ( bContext * C , wmOperator * op )
2008-12-21 16:24:19 +00:00
{
wmGesture * gesture = op - > customdata ;
rcti * rect = gesture - > customdata ;
2010-03-22 09:30:00 +00:00
if ( RNA_int_get ( op - > ptr , " gesture_mode " ) = = GESTURE_MODAL_NOP )
return ;
2009-11-05 17:32:06 +00:00
2008-12-21 16:24:19 +00:00
/* operator arguments and storage. */
RNA_int_set ( op - > ptr , " x " , rect - > xmin ) ;
RNA_int_set ( op - > ptr , " y " , rect - > ymin ) ;
RNA_int_set ( op - > ptr , " radius " , rect - > xmax ) ;
if ( op - > type - > exec )
op - > type - > exec ( C , op ) ;
2009-11-05 17:32:06 +00:00
# ifdef GESTURE_MEMORY
circle_select_size = rect - > xmax ;
# endif
2008-12-21 16:24:19 +00:00
}
int WM_gesture_circle_modal ( bContext * C , wmOperator * op , wmEvent * event )
{
wmGesture * gesture = op - > customdata ;
rcti * rect = gesture - > customdata ;
int sx , sy ;
2009-11-05 15:59:14 +00:00
2009-11-05 17:32:06 +00:00
if ( event - > type = = MOUSEMOVE ) {
wm_subwindow_getorigin ( CTX_wm_window ( C ) , gesture - > swinid , & sx , & sy ) ;
2008-12-21 16:24:19 +00:00
2009-11-05 17:32:06 +00:00
rect - > xmin = event - > x - sx ;
rect - > ymin = event - > y - sy ;
wm_gesture_tag_redraw ( C ) ;
if ( gesture - > mode )
gesture_circle_apply ( C , op ) ;
}
else if ( event - > type = = EVT_MODAL_MAP ) {
switch ( event - > val ) {
2009-11-06 22:51:08 +00:00
case GESTURE_MODAL_CIRCLE_ADD :
2008-12-21 16:24:19 +00:00
rect - > xmax + = 2 + rect - > xmax / 10 ;
2008-12-27 16:09:56 +00:00
wm_gesture_tag_redraw ( C ) ;
2008-12-21 16:24:19 +00:00
break ;
2009-11-06 22:51:08 +00:00
case GESTURE_MODAL_CIRCLE_SUB :
2008-12-21 16:24:19 +00:00
rect - > xmax - = 2 + rect - > xmax / 10 ;
if ( rect - > xmax < 1 ) rect - > xmax = 1 ;
2008-12-27 16:09:56 +00:00
wm_gesture_tag_redraw ( C ) ;
2008-12-21 16:24:19 +00:00
break ;
2009-11-05 17:32:06 +00:00
case GESTURE_MODAL_SELECT :
case GESTURE_MODAL_DESELECT :
case GESTURE_MODAL_NOP :
if ( RNA_struct_find_property ( op - > ptr , " gesture_mode " ) )
RNA_int_set ( op - > ptr , " gesture_mode " , event - > val ) ;
if ( event - > val ! = GESTURE_MODAL_NOP ) {
2009-01-24 13:45:24 +00:00
/* apply first click */
gesture_circle_apply ( C , op ) ;
2008-12-21 16:24:19 +00:00
gesture - > mode = 1 ;
2010-02-12 15:33:32 +00:00
wm_gesture_tag_redraw ( C ) ;
2009-01-24 13:45:24 +00:00
}
2008-12-21 16:24:19 +00:00
break ;
2009-11-05 17:32:06 +00:00
case GESTURE_MODAL_CANCEL :
case GESTURE_MODAL_CONFIRM :
2009-01-02 14:11:18 +00:00
wm_gesture_end ( C , op ) ;
2009-12-01 19:43:09 +00:00
return OPERATOR_FINISHED ; /* use finish or we dont get an undo */
2009-11-05 17:32:06 +00:00
}
2008-12-21 16:24:19 +00:00
}
2009-11-06 22:51:08 +00:00
// // Allow view navigation???
// else {
// return OPERATOR_PASS_THROUGH;
// }
2009-11-05 17:32:06 +00:00
2008-12-21 16:24:19 +00:00
return OPERATOR_RUNNING_MODAL ;
}
#if 0
/* template to copy from */
void WM_OT_circle_gesture ( wmOperatorType * ot )
{
ot - > name = " Circle Gesture " ;
ot - > idname = " WM_OT_circle_gesture " ;
2010-02-10 21:15:44 +00:00
ot - > description = " Enter rotate mode with a circular gesture " ;
2008-12-21 16:24:19 +00:00
ot - > invoke = WM_gesture_circle_invoke ;
ot - > modal = WM_gesture_circle_modal ;
ot - > poll = WM_operator_winactive ;
RNA_def_property ( ot - > srna , " x " , PROP_INT , PROP_NONE ) ;
RNA_def_property ( ot - > srna , " y " , PROP_INT , PROP_NONE ) ;
RNA_def_property ( ot - > srna , " radius " , PROP_INT , PROP_NONE ) ;
}
# endif
2008-11-24 10:45:36 +00:00
/* **************** Tweak gesture *************** */
2.5
Sanitized the 'tweak' event.
Original idea was to have WM event system generating it
automatically. However, I first tested it via a handler
and operator, to check what kind of configurations would
be useful. It appeared to not work nice, also because
that inserting a tweak operator in a keymap is confusing.
Now 'tweaks' are generated automatically, and can be
catched by keymaps as any event. The current definition
of tweak is:
- if Left/Middle/Rightmouse pressed
if event wasn't handled by window queue (modal handlers)
start checking mousepositions
- while mousepositions are checked
- escape on any event other than mouse
- on mouse events:
- add tweak event if mousemove > 10 pixels
- stop checking for tweak if mousebutton released
- Tweak events have a define indicating mousebutton used
EVT_TWEAK_L, EVT_TWEAK_M, EVT_TWEAK_R
- In keymap definitions you can use _S or _A to map to
action or select mouse userdef.
- Event value in keymap should be KM_ANY for all tweaks,
or use one of the eight directions:
EVT_GESTURE_E, _SE, _S, _SW, _W, _NW, _N, _NE
- And of course you can add modifier checks in keymaps for it.
- Because tweaks are a result of mouse events, the handlers get
both to evaluate. That means that RMB-select + tweak will work
correctly.
In case you don't want both to be handled, for example the
CTRL+LMB 'extrude' and CTRL+LMB-tweak 'lasso select', you will
need to set the first acting on a EVT_RELEASE, this event only
gets passed on when tweak fails.
The current system allows all options, configurable, we had in 2.48,
and many more! A diagram of what's possible is on the todo. :)
Also in this commit: lasso select editmesh failed with 'zbuffer
occluded select'. Also circle-select failed.
2009-02-02 14:13:14 +00:00
static void tweak_gesture_modal ( bContext * C , wmEvent * event )
2008-11-24 10:45:36 +00:00
{
2008-12-18 02:56:48 +00:00
wmWindow * window = CTX_wm_window ( C ) ;
2.5
Sanitized the 'tweak' event.
Original idea was to have WM event system generating it
automatically. However, I first tested it via a handler
and operator, to check what kind of configurations would
be useful. It appeared to not work nice, also because
that inserting a tweak operator in a keymap is confusing.
Now 'tweaks' are generated automatically, and can be
catched by keymaps as any event. The current definition
of tweak is:
- if Left/Middle/Rightmouse pressed
if event wasn't handled by window queue (modal handlers)
start checking mousepositions
- while mousepositions are checked
- escape on any event other than mouse
- on mouse events:
- add tweak event if mousemove > 10 pixels
- stop checking for tweak if mousebutton released
- Tweak events have a define indicating mousebutton used
EVT_TWEAK_L, EVT_TWEAK_M, EVT_TWEAK_R
- In keymap definitions you can use _S or _A to map to
action or select mouse userdef.
- Event value in keymap should be KM_ANY for all tweaks,
or use one of the eight directions:
EVT_GESTURE_E, _SE, _S, _SW, _W, _NW, _N, _NE
- And of course you can add modifier checks in keymaps for it.
- Because tweaks are a result of mouse events, the handlers get
both to evaluate. That means that RMB-select + tweak will work
correctly.
In case you don't want both to be handled, for example the
CTRL+LMB 'extrude' and CTRL+LMB-tweak 'lasso select', you will
need to set the first acting on a EVT_RELEASE, this event only
gets passed on when tweak fails.
The current system allows all options, configurable, we had in 2.48,
and many more! A diagram of what's possible is on the todo. :)
Also in this commit: lasso select editmesh failed with 'zbuffer
occluded select'. Also circle-select failed.
2009-02-02 14:13:14 +00:00
wmGesture * gesture = window - > tweak ;
2008-11-24 10:45:36 +00:00
rcti * rect = gesture - > customdata ;
int sx , sy , val ;
switch ( event - > type ) {
case MOUSEMOVE :
2010-07-02 11:26:12 +00:00
case INBETWEEN_MOUSEMOVE :
2008-11-24 10:45:36 +00:00
2008-12-18 02:56:48 +00:00
wm_subwindow_getorigin ( window , gesture - > swinid , & sx , & sy ) ;
2008-11-24 10:45:36 +00:00
rect - > xmax = event - > x - sx ;
rect - > ymax = event - > y - sy ;
2010-10-16 02:40:31 +00:00
if ( ( val = wm_gesture_evaluate ( gesture ) ) ) {
2010-12-03 12:30:59 +00:00
wmEvent tevent ;
2.5
Sanitized the 'tweak' event.
Original idea was to have WM event system generating it
automatically. However, I first tested it via a handler
and operator, to check what kind of configurations would
be useful. It appeared to not work nice, also because
that inserting a tweak operator in a keymap is confusing.
Now 'tweaks' are generated automatically, and can be
catched by keymaps as any event. The current definition
of tweak is:
- if Left/Middle/Rightmouse pressed
if event wasn't handled by window queue (modal handlers)
start checking mousepositions
- while mousepositions are checked
- escape on any event other than mouse
- on mouse events:
- add tweak event if mousemove > 10 pixels
- stop checking for tweak if mousebutton released
- Tweak events have a define indicating mousebutton used
EVT_TWEAK_L, EVT_TWEAK_M, EVT_TWEAK_R
- In keymap definitions you can use _S or _A to map to
action or select mouse userdef.
- Event value in keymap should be KM_ANY for all tweaks,
or use one of the eight directions:
EVT_GESTURE_E, _SE, _S, _SW, _W, _NW, _N, _NE
- And of course you can add modifier checks in keymaps for it.
- Because tweaks are a result of mouse events, the handlers get
both to evaluate. That means that RMB-select + tweak will work
correctly.
In case you don't want both to be handled, for example the
CTRL+LMB 'extrude' and CTRL+LMB-tweak 'lasso select', you will
need to set the first acting on a EVT_RELEASE, this event only
gets passed on when tweak fails.
The current system allows all options, configurable, we had in 2.48,
and many more! A diagram of what's possible is on the todo. :)
Also in this commit: lasso select editmesh failed with 'zbuffer
occluded select'. Also circle-select failed.
2009-02-02 14:13:14 +00:00
2010-12-03 12:30:59 +00:00
tevent = * ( window - > eventstate ) ;
2.5: work on bringing back SpaceTime options
- RMB select, also with SHIFT
- RMB tweak for translate
- SHIFT+D dupli
- BKEY border select/deselect
- AKEY (de)select all
- XKEY delete
- GKEY grab
Added some XXX comments for future todos, especially for when other
spaces come back with time markers.
Also added ED_util for putting in all to-be-cleaned cruft
Context conflict: input methods for Markers can conflict with other
spacetypes. It was solved in pre-2.5 with manually tweaking it all over,
but I would prefer one keymap for all marker stuff. Needs some thinking...
could be solved with a boundbox check for bottom part of 2d window.
Tweak issue: both tweak styles are possible:
- Hold mouse button, move, operator ends on mouse release
- Hold mouse button, move, operator ends on mouse click
Problem is that modally handled operators use fixed keymaps... like ESC,
SPACE, ENTER, or press/release mousebutton for 'assign'. There's a lot
to say for making this all consistant, or become part of 1 general keymap?
Should also be possibe to define 'tweak' defaults for Tablet different
than for mouse...
2008-11-29 15:10:31 +00:00
if ( gesture - > event_type = = LEFTMOUSE )
2010-12-03 12:30:59 +00:00
tevent . type = EVT_TWEAK_L ;
2.5: work on bringing back SpaceTime options
- RMB select, also with SHIFT
- RMB tweak for translate
- SHIFT+D dupli
- BKEY border select/deselect
- AKEY (de)select all
- XKEY delete
- GKEY grab
Added some XXX comments for future todos, especially for when other
spaces come back with time markers.
Also added ED_util for putting in all to-be-cleaned cruft
Context conflict: input methods for Markers can conflict with other
spacetypes. It was solved in pre-2.5 with manually tweaking it all over,
but I would prefer one keymap for all marker stuff. Needs some thinking...
could be solved with a boundbox check for bottom part of 2d window.
Tweak issue: both tweak styles are possible:
- Hold mouse button, move, operator ends on mouse release
- Hold mouse button, move, operator ends on mouse click
Problem is that modally handled operators use fixed keymaps... like ESC,
SPACE, ENTER, or press/release mousebutton for 'assign'. There's a lot
to say for making this all consistant, or become part of 1 general keymap?
Should also be possibe to define 'tweak' defaults for Tablet different
than for mouse...
2008-11-29 15:10:31 +00:00
else if ( gesture - > event_type = = RIGHTMOUSE )
2010-12-03 12:30:59 +00:00
tevent . type = EVT_TWEAK_R ;
2.5: work on bringing back SpaceTime options
- RMB select, also with SHIFT
- RMB tweak for translate
- SHIFT+D dupli
- BKEY border select/deselect
- AKEY (de)select all
- XKEY delete
- GKEY grab
Added some XXX comments for future todos, especially for when other
spaces come back with time markers.
Also added ED_util for putting in all to-be-cleaned cruft
Context conflict: input methods for Markers can conflict with other
spacetypes. It was solved in pre-2.5 with manually tweaking it all over,
but I would prefer one keymap for all marker stuff. Needs some thinking...
could be solved with a boundbox check for bottom part of 2d window.
Tweak issue: both tweak styles are possible:
- Hold mouse button, move, operator ends on mouse release
- Hold mouse button, move, operator ends on mouse click
Problem is that modally handled operators use fixed keymaps... like ESC,
SPACE, ENTER, or press/release mousebutton for 'assign'. There's a lot
to say for making this all consistant, or become part of 1 general keymap?
Should also be possibe to define 'tweak' defaults for Tablet different
than for mouse...
2008-11-29 15:10:31 +00:00
else
2010-12-03 12:30:59 +00:00
tevent . type = EVT_TWEAK_M ;
tevent . val = val ;
2008-11-24 10:45:36 +00:00
/* mouse coords! */
2010-12-03 12:30:59 +00:00
wm_event_add ( window , & tevent ) ;
2008-11-24 10:45:36 +00:00
2.5
Sanitized the 'tweak' event.
Original idea was to have WM event system generating it
automatically. However, I first tested it via a handler
and operator, to check what kind of configurations would
be useful. It appeared to not work nice, also because
that inserting a tweak operator in a keymap is confusing.
Now 'tweaks' are generated automatically, and can be
catched by keymaps as any event. The current definition
of tweak is:
- if Left/Middle/Rightmouse pressed
if event wasn't handled by window queue (modal handlers)
start checking mousepositions
- while mousepositions are checked
- escape on any event other than mouse
- on mouse events:
- add tweak event if mousemove > 10 pixels
- stop checking for tweak if mousebutton released
- Tweak events have a define indicating mousebutton used
EVT_TWEAK_L, EVT_TWEAK_M, EVT_TWEAK_R
- In keymap definitions you can use _S or _A to map to
action or select mouse userdef.
- Event value in keymap should be KM_ANY for all tweaks,
or use one of the eight directions:
EVT_GESTURE_E, _SE, _S, _SW, _W, _NW, _N, _NE
- And of course you can add modifier checks in keymaps for it.
- Because tweaks are a result of mouse events, the handlers get
both to evaluate. That means that RMB-select + tweak will work
correctly.
In case you don't want both to be handled, for example the
CTRL+LMB 'extrude' and CTRL+LMB-tweak 'lasso select', you will
need to set the first acting on a EVT_RELEASE, this event only
gets passed on when tweak fails.
The current system allows all options, configurable, we had in 2.48,
and many more! A diagram of what's possible is on the todo. :)
Also in this commit: lasso select editmesh failed with 'zbuffer
occluded select'. Also circle-select failed.
2009-02-02 14:13:14 +00:00
WM_gesture_end ( C , gesture ) ; /* frees gesture itself, and unregisters from window */
2008-11-24 10:45:36 +00:00
}
break ;
case LEFTMOUSE :
case RIGHTMOUSE :
case MIDDLEMOUSE :
if ( gesture - > event_type = = event - > type ) {
2.5
Sanitized the 'tweak' event.
Original idea was to have WM event system generating it
automatically. However, I first tested it via a handler
and operator, to check what kind of configurations would
be useful. It appeared to not work nice, also because
that inserting a tweak operator in a keymap is confusing.
Now 'tweaks' are generated automatically, and can be
catched by keymaps as any event. The current definition
of tweak is:
- if Left/Middle/Rightmouse pressed
if event wasn't handled by window queue (modal handlers)
start checking mousepositions
- while mousepositions are checked
- escape on any event other than mouse
- on mouse events:
- add tweak event if mousemove > 10 pixels
- stop checking for tweak if mousebutton released
- Tweak events have a define indicating mousebutton used
EVT_TWEAK_L, EVT_TWEAK_M, EVT_TWEAK_R
- In keymap definitions you can use _S or _A to map to
action or select mouse userdef.
- Event value in keymap should be KM_ANY for all tweaks,
or use one of the eight directions:
EVT_GESTURE_E, _SE, _S, _SW, _W, _NW, _N, _NE
- And of course you can add modifier checks in keymaps for it.
- Because tweaks are a result of mouse events, the handlers get
both to evaluate. That means that RMB-select + tweak will work
correctly.
In case you don't want both to be handled, for example the
CTRL+LMB 'extrude' and CTRL+LMB-tweak 'lasso select', you will
need to set the first acting on a EVT_RELEASE, this event only
gets passed on when tweak fails.
The current system allows all options, configurable, we had in 2.48,
and many more! A diagram of what's possible is on the todo. :)
Also in this commit: lasso select editmesh failed with 'zbuffer
occluded select'. Also circle-select failed.
2009-02-02 14:13:14 +00:00
WM_gesture_end ( C , gesture ) ;
2009-09-24 10:35:04 +00:00
2009-02-02 16:30:03 +00:00
/* when tweak fails we should give the other keymap entries a chance */
2009-02-02 15:39:37 +00:00
event - > val = KM_RELEASE ;
2008-11-24 10:45:36 +00:00
}
break ;
2.5
Sanitized the 'tweak' event.
Original idea was to have WM event system generating it
automatically. However, I first tested it via a handler
and operator, to check what kind of configurations would
be useful. It appeared to not work nice, also because
that inserting a tweak operator in a keymap is confusing.
Now 'tweaks' are generated automatically, and can be
catched by keymaps as any event. The current definition
of tweak is:
- if Left/Middle/Rightmouse pressed
if event wasn't handled by window queue (modal handlers)
start checking mousepositions
- while mousepositions are checked
- escape on any event other than mouse
- on mouse events:
- add tweak event if mousemove > 10 pixels
- stop checking for tweak if mousebutton released
- Tweak events have a define indicating mousebutton used
EVT_TWEAK_L, EVT_TWEAK_M, EVT_TWEAK_R
- In keymap definitions you can use _S or _A to map to
action or select mouse userdef.
- Event value in keymap should be KM_ANY for all tweaks,
or use one of the eight directions:
EVT_GESTURE_E, _SE, _S, _SW, _W, _NW, _N, _NE
- And of course you can add modifier checks in keymaps for it.
- Because tweaks are a result of mouse events, the handlers get
both to evaluate. That means that RMB-select + tweak will work
correctly.
In case you don't want both to be handled, for example the
CTRL+LMB 'extrude' and CTRL+LMB-tweak 'lasso select', you will
need to set the first acting on a EVT_RELEASE, this event only
gets passed on when tweak fails.
The current system allows all options, configurable, we had in 2.48,
and many more! A diagram of what's possible is on the todo. :)
Also in this commit: lasso select editmesh failed with 'zbuffer
occluded select'. Also circle-select failed.
2009-02-02 14:13:14 +00:00
default :
2009-11-11 15:29:22 +00:00
if ( ! ISTIMER ( event - > type ) ) {
WM_gesture_end ( C , gesture ) ;
}
break ;
2008-11-24 10:45:36 +00:00
}
}
2.5
Sanitized the 'tweak' event.
Original idea was to have WM event system generating it
automatically. However, I first tested it via a handler
and operator, to check what kind of configurations would
be useful. It appeared to not work nice, also because
that inserting a tweak operator in a keymap is confusing.
Now 'tweaks' are generated automatically, and can be
catched by keymaps as any event. The current definition
of tweak is:
- if Left/Middle/Rightmouse pressed
if event wasn't handled by window queue (modal handlers)
start checking mousepositions
- while mousepositions are checked
- escape on any event other than mouse
- on mouse events:
- add tweak event if mousemove > 10 pixels
- stop checking for tweak if mousebutton released
- Tweak events have a define indicating mousebutton used
EVT_TWEAK_L, EVT_TWEAK_M, EVT_TWEAK_R
- In keymap definitions you can use _S or _A to map to
action or select mouse userdef.
- Event value in keymap should be KM_ANY for all tweaks,
or use one of the eight directions:
EVT_GESTURE_E, _SE, _S, _SW, _W, _NW, _N, _NE
- And of course you can add modifier checks in keymaps for it.
- Because tweaks are a result of mouse events, the handlers get
both to evaluate. That means that RMB-select + tweak will work
correctly.
In case you don't want both to be handled, for example the
CTRL+LMB 'extrude' and CTRL+LMB-tweak 'lasso select', you will
need to set the first acting on a EVT_RELEASE, this event only
gets passed on when tweak fails.
The current system allows all options, configurable, we had in 2.48,
and many more! A diagram of what's possible is on the todo. :)
Also in this commit: lasso select editmesh failed with 'zbuffer
occluded select'. Also circle-select failed.
2009-02-02 14:13:14 +00:00
/* standard tweak, called after window handlers passed on event */
void wm_tweakevent_test ( bContext * C , wmEvent * event , int action )
2008-11-24 10:45:36 +00:00
{
2.5
Sanitized the 'tweak' event.
Original idea was to have WM event system generating it
automatically. However, I first tested it via a handler
and operator, to check what kind of configurations would
be useful. It appeared to not work nice, also because
that inserting a tweak operator in a keymap is confusing.
Now 'tweaks' are generated automatically, and can be
catched by keymaps as any event. The current definition
of tweak is:
- if Left/Middle/Rightmouse pressed
if event wasn't handled by window queue (modal handlers)
start checking mousepositions
- while mousepositions are checked
- escape on any event other than mouse
- on mouse events:
- add tweak event if mousemove > 10 pixels
- stop checking for tweak if mousebutton released
- Tweak events have a define indicating mousebutton used
EVT_TWEAK_L, EVT_TWEAK_M, EVT_TWEAK_R
- In keymap definitions you can use _S or _A to map to
action or select mouse userdef.
- Event value in keymap should be KM_ANY for all tweaks,
or use one of the eight directions:
EVT_GESTURE_E, _SE, _S, _SW, _W, _NW, _N, _NE
- And of course you can add modifier checks in keymaps for it.
- Because tweaks are a result of mouse events, the handlers get
both to evaluate. That means that RMB-select + tweak will work
correctly.
In case you don't want both to be handled, for example the
CTRL+LMB 'extrude' and CTRL+LMB-tweak 'lasso select', you will
need to set the first acting on a EVT_RELEASE, this event only
gets passed on when tweak fails.
The current system allows all options, configurable, we had in 2.48,
and many more! A diagram of what's possible is on the todo. :)
Also in this commit: lasso select editmesh failed with 'zbuffer
occluded select'. Also circle-select failed.
2009-02-02 14:13:14 +00:00
wmWindow * win = CTX_wm_window ( C ) ;
2008-11-24 10:45:36 +00:00
2.5
Sanitized the 'tweak' event.
Original idea was to have WM event system generating it
automatically. However, I first tested it via a handler
and operator, to check what kind of configurations would
be useful. It appeared to not work nice, also because
that inserting a tweak operator in a keymap is confusing.
Now 'tweaks' are generated automatically, and can be
catched by keymaps as any event. The current definition
of tweak is:
- if Left/Middle/Rightmouse pressed
if event wasn't handled by window queue (modal handlers)
start checking mousepositions
- while mousepositions are checked
- escape on any event other than mouse
- on mouse events:
- add tweak event if mousemove > 10 pixels
- stop checking for tweak if mousebutton released
- Tweak events have a define indicating mousebutton used
EVT_TWEAK_L, EVT_TWEAK_M, EVT_TWEAK_R
- In keymap definitions you can use _S or _A to map to
action or select mouse userdef.
- Event value in keymap should be KM_ANY for all tweaks,
or use one of the eight directions:
EVT_GESTURE_E, _SE, _S, _SW, _W, _NW, _N, _NE
- And of course you can add modifier checks in keymaps for it.
- Because tweaks are a result of mouse events, the handlers get
both to evaluate. That means that RMB-select + tweak will work
correctly.
In case you don't want both to be handled, for example the
CTRL+LMB 'extrude' and CTRL+LMB-tweak 'lasso select', you will
need to set the first acting on a EVT_RELEASE, this event only
gets passed on when tweak fails.
The current system allows all options, configurable, we had in 2.48,
and many more! A diagram of what's possible is on the todo. :)
Also in this commit: lasso select editmesh failed with 'zbuffer
occluded select'. Also circle-select failed.
2009-02-02 14:13:14 +00:00
if ( win - > tweak = = NULL ) {
if ( CTX_wm_region ( C ) ) {
Drag and drop 2.5 integration! Finally, slashdot regulars can use
Blender too now! :)
** Drag works as follows:
- drag-able items are defined by the standard interface ui toolkit
- each button can get this feature, via uiButSetDragXXX(but, ...).
There are calls to define drag-able images, ID blocks, RNA paths,
file paths, and so on. By default you drag an icon, exceptionally
an ImBuf
- Drag items are registered centrally in the WM, it allows more drag
items simultaneous too, but not implemented
** Drop works as follows:
- On mouse release, and if drag items exist in the WM, it converts
the mouse event to an EVT_DROP type. This event then gets the full
drag info as customdata
- drop regions are defined with WM_dropbox_add(), similar to keymaps
you can make a "drop map" this way, which become 'drop map handlers'
in the queues.
- next to that the UI kit handles some common button types (like
accepting ID or names) to be catching a drop event too.
- Every "drop box" has two callbacks:
- poll() = check if the event drag data is relevant for this box
- copy() = fill in custom properties in the dropbox to initialize
an operator
- The dropbox handler then calls its standard Operator with its
dropbox properties.
** Currently implemented
Drag items:
- ID icons in browse buttons
- ID icons in context menu of properties region
- ID icons in outliner and rna viewer
- FileBrowser icons
- FileBrowser preview images
Drag-able icons are subtly visualized by making them brighter a bit
on mouse-over. In case the icon is a button or UI element too (most
cases), the drag-able feature will make the item react to
mouse-release instead of mouse-press.
Drop options:
- UI buttons: ID and text buttons (paste name)
- View3d: Object ID drop copies object
- View3d: Material ID drop assigns to object under cursor
- View3d: Image ID drop assigns to object UV texture under cursor
- Sequencer: Path drop will add either Image or Movie strip
- Image window: Path drop will open image
** Drag and drop Notes:
- Dropping into another Blender window (from same application) works
too. I've added code that passes on mousemoves and clicks to other
windows, without activating them though. This does make using multi-window
Blender a bit friendler.
- Dropping a file path to an image, is not the same as dropping an
Image ID... keep this in mind. Sequencer for example wants paths to
be dropped, textures in 3d window wants an Image ID.
- Although drop boxes could be defined via Python, I suggest they're
part of the UI and editor design (= how we want an editor to work), and
not default offered configurable like keymaps.
- At the moment only one item can be dragged at a time. This is for
several reasons.... For one, Blender doesn't have a well defined
uniform way to define "what is selected" (files, outliner items, etc).
Secondly there's potential conflicts on what todo when you drop mixed
drag sets on spots. All undefined stuff... nice for later.
- Example to bypass the above: a collection of images that form a strip,
should be represented in filewindow as a single sequence anyway.
This then will fit well and gets handled neatly by design.
- Another option to check is to allow multiple options per drop... it
could show the operator as a sort of menu, allowing arrow or scrollwheel
to choose. For time being I'd prefer to try to design a singular drop
though, just offer only one drop action per data type on given spots.
- What does work already, but a tad slow, is to use a function that
detects an object (type) under cursor, so a drag item's option can be
further refined (like drop object on object = parent). (disabled)
** More notes
- Added saving for Region layouts (like split points for toolbar)
- Label buttons now handle mouse over
- File list: added full path entry for drop feature.
- Filesel bugfix: wm_operator_exec() got called there and fully handled,
while WM event code tried same. Added new OPERATOR_HANDLED flag for this.
Maybe python needs it too?
- Cocoa: added window move event, so multi-win setups work OK (didnt save).
- Interface_handlers.c: removed win->active
- Severe area copy bug: area handlers were not set to NULL
- Filesel bugfix: next/prev folder list was not copied on area copies
** Leftover todos
- Cocoa windows seem to hang on cases still... needs check
- Cocoa 'draw overlap' swap doesn't work
- Cocoa window loses focus permanently on using Spotlight
(for these reasons, makefile building has Carbon as default atm)
- ListView templates in UI cannot become dragged yet, needs review...
it consists of two overlapping UI elements, preventing handling icon clicks.
- There's already Ghost library code to handle dropping from OS
into Blender window. I've noticed this code is unfinished for Macs, but
seems to be complete for Windows. Needs test... currently, an external
drop event will print in console when succesfully delivered to Blender's WM.
2010-01-26 18:18:21 +00:00
if ( event - > val = = KM_PRESS ) {
2.5
Sanitized the 'tweak' event.
Original idea was to have WM event system generating it
automatically. However, I first tested it via a handler
and operator, to check what kind of configurations would
be useful. It appeared to not work nice, also because
that inserting a tweak operator in a keymap is confusing.
Now 'tweaks' are generated automatically, and can be
catched by keymaps as any event. The current definition
of tweak is:
- if Left/Middle/Rightmouse pressed
if event wasn't handled by window queue (modal handlers)
start checking mousepositions
- while mousepositions are checked
- escape on any event other than mouse
- on mouse events:
- add tweak event if mousemove > 10 pixels
- stop checking for tweak if mousebutton released
- Tweak events have a define indicating mousebutton used
EVT_TWEAK_L, EVT_TWEAK_M, EVT_TWEAK_R
- In keymap definitions you can use _S or _A to map to
action or select mouse userdef.
- Event value in keymap should be KM_ANY for all tweaks,
or use one of the eight directions:
EVT_GESTURE_E, _SE, _S, _SW, _W, _NW, _N, _NE
- And of course you can add modifier checks in keymaps for it.
- Because tweaks are a result of mouse events, the handlers get
both to evaluate. That means that RMB-select + tweak will work
correctly.
In case you don't want both to be handled, for example the
CTRL+LMB 'extrude' and CTRL+LMB-tweak 'lasso select', you will
need to set the first acting on a EVT_RELEASE, this event only
gets passed on when tweak fails.
The current system allows all options, configurable, we had in 2.48,
and many more! A diagram of what's possible is on the todo. :)
Also in this commit: lasso select editmesh failed with 'zbuffer
occluded select'. Also circle-select failed.
2009-02-02 14:13:14 +00:00
if ( ELEM3 ( event - > type , LEFTMOUSE , MIDDLEMOUSE , RIGHTMOUSE ) )
win - > tweak = WM_gesture_new ( C , event , WM_GESTURE_TWEAK ) ;
}
}
}
else {
Drag and drop 2.5 integration! Finally, slashdot regulars can use
Blender too now! :)
** Drag works as follows:
- drag-able items are defined by the standard interface ui toolkit
- each button can get this feature, via uiButSetDragXXX(but, ...).
There are calls to define drag-able images, ID blocks, RNA paths,
file paths, and so on. By default you drag an icon, exceptionally
an ImBuf
- Drag items are registered centrally in the WM, it allows more drag
items simultaneous too, but not implemented
** Drop works as follows:
- On mouse release, and if drag items exist in the WM, it converts
the mouse event to an EVT_DROP type. This event then gets the full
drag info as customdata
- drop regions are defined with WM_dropbox_add(), similar to keymaps
you can make a "drop map" this way, which become 'drop map handlers'
in the queues.
- next to that the UI kit handles some common button types (like
accepting ID or names) to be catching a drop event too.
- Every "drop box" has two callbacks:
- poll() = check if the event drag data is relevant for this box
- copy() = fill in custom properties in the dropbox to initialize
an operator
- The dropbox handler then calls its standard Operator with its
dropbox properties.
** Currently implemented
Drag items:
- ID icons in browse buttons
- ID icons in context menu of properties region
- ID icons in outliner and rna viewer
- FileBrowser icons
- FileBrowser preview images
Drag-able icons are subtly visualized by making them brighter a bit
on mouse-over. In case the icon is a button or UI element too (most
cases), the drag-able feature will make the item react to
mouse-release instead of mouse-press.
Drop options:
- UI buttons: ID and text buttons (paste name)
- View3d: Object ID drop copies object
- View3d: Material ID drop assigns to object under cursor
- View3d: Image ID drop assigns to object UV texture under cursor
- Sequencer: Path drop will add either Image or Movie strip
- Image window: Path drop will open image
** Drag and drop Notes:
- Dropping into another Blender window (from same application) works
too. I've added code that passes on mousemoves and clicks to other
windows, without activating them though. This does make using multi-window
Blender a bit friendler.
- Dropping a file path to an image, is not the same as dropping an
Image ID... keep this in mind. Sequencer for example wants paths to
be dropped, textures in 3d window wants an Image ID.
- Although drop boxes could be defined via Python, I suggest they're
part of the UI and editor design (= how we want an editor to work), and
not default offered configurable like keymaps.
- At the moment only one item can be dragged at a time. This is for
several reasons.... For one, Blender doesn't have a well defined
uniform way to define "what is selected" (files, outliner items, etc).
Secondly there's potential conflicts on what todo when you drop mixed
drag sets on spots. All undefined stuff... nice for later.
- Example to bypass the above: a collection of images that form a strip,
should be represented in filewindow as a single sequence anyway.
This then will fit well and gets handled neatly by design.
- Another option to check is to allow multiple options per drop... it
could show the operator as a sort of menu, allowing arrow or scrollwheel
to choose. For time being I'd prefer to try to design a singular drop
though, just offer only one drop action per data type on given spots.
- What does work already, but a tad slow, is to use a function that
detects an object (type) under cursor, so a drag item's option can be
further refined (like drop object on object = parent). (disabled)
** More notes
- Added saving for Region layouts (like split points for toolbar)
- Label buttons now handle mouse over
- File list: added full path entry for drop feature.
- Filesel bugfix: wm_operator_exec() got called there and fully handled,
while WM event code tried same. Added new OPERATOR_HANDLED flag for this.
Maybe python needs it too?
- Cocoa: added window move event, so multi-win setups work OK (didnt save).
- Interface_handlers.c: removed win->active
- Severe area copy bug: area handlers were not set to NULL
- Filesel bugfix: next/prev folder list was not copied on area copies
** Leftover todos
- Cocoa windows seem to hang on cases still... needs check
- Cocoa 'draw overlap' swap doesn't work
- Cocoa window loses focus permanently on using Spotlight
(for these reasons, makefile building has Carbon as default atm)
- ListView templates in UI cannot become dragged yet, needs review...
it consists of two overlapping UI elements, preventing handling icon clicks.
- There's already Ghost library code to handle dropping from OS
into Blender window. I've noticed this code is unfinished for Macs, but
seems to be complete for Windows. Needs test... currently, an external
drop event will print in console when succesfully delivered to Blender's WM.
2010-01-26 18:18:21 +00:00
/* no tweaks if event was handled */
if ( ( action & WM_HANDLER_BREAK ) ) {
2.5
Sanitized the 'tweak' event.
Original idea was to have WM event system generating it
automatically. However, I first tested it via a handler
and operator, to check what kind of configurations would
be useful. It appeared to not work nice, also because
that inserting a tweak operator in a keymap is confusing.
Now 'tweaks' are generated automatically, and can be
catched by keymaps as any event. The current definition
of tweak is:
- if Left/Middle/Rightmouse pressed
if event wasn't handled by window queue (modal handlers)
start checking mousepositions
- while mousepositions are checked
- escape on any event other than mouse
- on mouse events:
- add tweak event if mousemove > 10 pixels
- stop checking for tweak if mousebutton released
- Tweak events have a define indicating mousebutton used
EVT_TWEAK_L, EVT_TWEAK_M, EVT_TWEAK_R
- In keymap definitions you can use _S or _A to map to
action or select mouse userdef.
- Event value in keymap should be KM_ANY for all tweaks,
or use one of the eight directions:
EVT_GESTURE_E, _SE, _S, _SW, _W, _NW, _N, _NE
- And of course you can add modifier checks in keymaps for it.
- Because tweaks are a result of mouse events, the handlers get
both to evaluate. That means that RMB-select + tweak will work
correctly.
In case you don't want both to be handled, for example the
CTRL+LMB 'extrude' and CTRL+LMB-tweak 'lasso select', you will
need to set the first acting on a EVT_RELEASE, this event only
gets passed on when tweak fails.
The current system allows all options, configurable, we had in 2.48,
and many more! A diagram of what's possible is on the todo. :)
Also in this commit: lasso select editmesh failed with 'zbuffer
occluded select'. Also circle-select failed.
2009-02-02 14:13:14 +00:00
WM_gesture_end ( C , win - > tweak ) ;
}
else
tweak_gesture_modal ( C , event ) ;
}
2008-11-24 10:45:36 +00:00
}
2009-01-02 14:11:18 +00:00
/* *********************** lasso gesture ****************** */
int WM_gesture_lasso_invoke ( bContext * C , wmOperator * op , wmEvent * event )
{
op - > customdata = WM_gesture_new ( C , event , WM_GESTURE_LASSO ) ;
/* add modal handler */
2009-09-18 12:43:36 +00:00
WM_event_add_modal_handler ( C , op ) ;
2009-01-02 14:11:18 +00:00
wm_gesture_tag_redraw ( C ) ;
2009-02-07 14:03:34 +00:00
if ( RNA_struct_find_property ( op - > ptr , " cursor " ) )
WM_cursor_modal ( CTX_wm_window ( C ) , RNA_int_get ( op - > ptr , " cursor " ) ) ;
return OPERATOR_RUNNING_MODAL ;
}
int WM_gesture_lines_invoke ( bContext * C , wmOperator * op , wmEvent * event )
{
op - > customdata = WM_gesture_new ( C , event , WM_GESTURE_LINES ) ;
/* add modal handler */
2009-09-18 12:43:36 +00:00
WM_event_add_modal_handler ( C , op ) ;
2009-02-07 14:03:34 +00:00
wm_gesture_tag_redraw ( C ) ;
if ( RNA_struct_find_property ( op - > ptr , " cursor " ) )
WM_cursor_modal ( CTX_wm_window ( C ) , RNA_int_get ( op - > ptr , " cursor " ) ) ;
2009-01-02 14:11:18 +00:00
return OPERATOR_RUNNING_MODAL ;
}
2010-10-16 02:40:31 +00:00
static void gesture_lasso_apply ( bContext * C , wmOperator * op )
2009-01-02 14:11:18 +00:00
{
wmGesture * gesture = op - > customdata ;
PointerRNA itemptr ;
float loc [ 2 ] ;
int i ;
short * lasso = gesture - > customdata ;
/* operator storage as path. */
for ( i = 0 ; i < gesture - > points ; i + + , lasso + = 2 ) {
loc [ 0 ] = lasso [ 0 ] ;
loc [ 1 ] = lasso [ 1 ] ;
RNA_collection_add ( op - > ptr , " path " , & itemptr ) ;
RNA_float_set_array ( & itemptr , " loc " , loc ) ;
}
wm_gesture_end ( C , op ) ;
if ( op - > type - > exec )
op - > type - > exec ( C , op ) ;
}
int WM_gesture_lasso_modal ( bContext * C , wmOperator * op , wmEvent * event )
{
wmGesture * gesture = op - > customdata ;
int sx , sy ;
switch ( event - > type ) {
case MOUSEMOVE :
2010-07-02 11:26:12 +00:00
case INBETWEEN_MOUSEMOVE :
2009-01-02 14:11:18 +00:00
wm_gesture_tag_redraw ( C ) ;
wm_subwindow_getorigin ( CTX_wm_window ( C ) , gesture - > swinid , & sx , & sy ) ;
2010-01-10 20:16:56 +00:00
if ( gesture - > points = = gesture - > size ) {
short * old_lasso = gesture - > customdata ;
gesture - > customdata = MEM_callocN ( 2 * sizeof ( short ) * ( gesture - > size + WM_LASSO_MIN_POINTS ) , " lasso points " ) ;
memcpy ( gesture - > customdata , old_lasso , 2 * sizeof ( short ) * gesture - > size ) ;
gesture - > size = gesture - > size + WM_LASSO_MIN_POINTS ;
MEM_freeN ( old_lasso ) ;
printf ( " realloc \n " ) ;
}
{
2011-05-12 16:47:36 +00:00
int x , y ;
2009-01-02 14:11:18 +00:00
short * lasso = gesture - > customdata ;
2010-10-01 08:12:37 +00:00
lasso + = ( 2 * gesture - > points - 2 ) ;
x = ( event - > x - sx - lasso [ 0 ] ) ;
y = ( event - > y - sy - lasso [ 1 ] ) ;
/* make a simple distance check to get a smoother lasso
add only when at least 2 pixels between this and previous location */
if ( ( x * x + y * y ) > 4 ) {
lasso + = 2 ;
lasso [ 0 ] = event - > x - sx ;
lasso [ 1 ] = event - > y - sy ;
gesture - > points + + ;
}
2009-01-02 14:11:18 +00:00
}
break ;
case LEFTMOUSE :
case MIDDLEMOUSE :
case RIGHTMOUSE :
2009-09-24 10:35:04 +00:00
if ( event - > val = = KM_RELEASE ) { /* key release */
2010-10-16 02:40:31 +00:00
gesture_lasso_apply ( C , op ) ;
2009-01-02 14:11:18 +00:00
return OPERATOR_FINISHED ;
}
break ;
case ESCKEY :
wm_gesture_end ( C , op ) ;
return OPERATOR_CANCELLED ;
}
return OPERATOR_RUNNING_MODAL ;
}
2009-02-07 14:03:34 +00:00
int WM_gesture_lines_modal ( bContext * C , wmOperator * op , wmEvent * event )
{
return WM_gesture_lasso_modal ( C , op , event ) ;
}
2009-01-02 14:11:18 +00:00
#if 0
/* template to copy from */
static int gesture_lasso_exec ( bContext * C , wmOperator * op )
{
RNA_BEGIN ( op - > ptr , itemptr , " path " ) {
float loc [ 2 ] ;
RNA_float_get_array ( & itemptr , " loc " , loc ) ;
printf ( " Location: %f %f \n " , loc [ 0 ] , loc [ 1 ] ) ;
}
RNA_END ;
return OPERATOR_FINISHED ;
}
void WM_OT_lasso_gesture ( wmOperatorType * ot )
{
PropertyRNA * prop ;
ot - > name = " Lasso Gesture " ;
ot - > idname = " WM_OT_lasso_gesture " ;
2010-02-10 21:15:44 +00:00
ot - > description = " Select objects within the lasso as you move the pointer " ;
2009-01-02 14:11:18 +00:00
ot - > invoke = WM_gesture_lasso_invoke ;
ot - > modal = WM_gesture_lasso_modal ;
ot - > exec = gesture_lasso_exec ;
ot - > poll = WM_operator_winactive ;
prop = RNA_def_property ( ot - > srna , " path " , PROP_COLLECTION , PROP_NONE ) ;
RNA_def_property_struct_runtime ( prop , & RNA_OperatorMousePath ) ;
}
# endif
2008-11-24 10:45:36 +00:00
2010-04-04 00:21:37 +00:00
/* *********************** straight line gesture ****************** */
static int straightline_apply ( bContext * C , wmOperator * op )
{
wmGesture * gesture = op - > customdata ;
rcti * rect = gesture - > customdata ;
if ( rect - > xmin = = rect - > xmax & & rect - > ymin = = rect - > ymax )
return 0 ;
/* operator arguments and storage. */
RNA_int_set ( op - > ptr , " xstart " , rect - > xmin ) ;
RNA_int_set ( op - > ptr , " ystart " , rect - > ymin ) ;
RNA_int_set ( op - > ptr , " xend " , rect - > xmax ) ;
RNA_int_set ( op - > ptr , " yend " , rect - > ymax ) ;
if ( op - > type - > exec )
op - > type - > exec ( C , op ) ;
return 1 ;
}
int WM_gesture_straightline_invoke ( bContext * C , wmOperator * op , wmEvent * event )
{
op - > customdata = WM_gesture_new ( C , event , WM_GESTURE_STRAIGHTLINE ) ;
/* add modal handler */
WM_event_add_modal_handler ( C , op ) ;
wm_gesture_tag_redraw ( C ) ;
if ( RNA_struct_find_property ( op - > ptr , " cursor " ) )
WM_cursor_modal ( CTX_wm_window ( C ) , RNA_int_get ( op - > ptr , " cursor " ) ) ;
return OPERATOR_RUNNING_MODAL ;
}
int WM_gesture_straightline_modal ( bContext * C , wmOperator * op , wmEvent * event )
{
wmGesture * gesture = op - > customdata ;
rcti * rect = gesture - > customdata ;
int sx , sy ;
if ( event - > type = = MOUSEMOVE ) {
wm_subwindow_getorigin ( CTX_wm_window ( C ) , gesture - > swinid , & sx , & sy ) ;
if ( gesture - > mode = = 0 ) {
rect - > xmin = rect - > xmax = event - > x - sx ;
rect - > ymin = rect - > ymax = event - > y - sy ;
}
else {
rect - > xmax = event - > x - sx ;
rect - > ymax = event - > y - sy ;
straightline_apply ( C , op ) ;
}
wm_gesture_tag_redraw ( C ) ;
}
else if ( event - > type = = EVT_MODAL_MAP ) {
switch ( event - > val ) {
case GESTURE_MODAL_BEGIN :
if ( gesture - > mode = = 0 ) {
gesture - > mode = 1 ;
wm_gesture_tag_redraw ( C ) ;
}
break ;
case GESTURE_MODAL_SELECT :
if ( straightline_apply ( C , op ) ) {
wm_gesture_end ( C , op ) ;
return OPERATOR_FINISHED ;
}
wm_gesture_end ( C , op ) ;
return OPERATOR_CANCELLED ;
break ;
case GESTURE_MODAL_CANCEL :
wm_gesture_end ( C , op ) ;
return OPERATOR_CANCELLED ;
}
}
return OPERATOR_RUNNING_MODAL ;
}
#if 0
/* template to copy from */
void WM_OT_straightline_gesture ( wmOperatorType * ot )
{
PropertyRNA * prop ;
ot - > name = " Straight Line Gesture " ;
ot - > idname = " WM_OT_straightline_gesture " ;
ot - > description = " Draw a straight line as you move the pointer " ;
ot - > invoke = WM_gesture_straightline_invoke ;
ot - > modal = WM_gesture_straightline_modal ;
ot - > exec = gesture_straightline_exec ;
ot - > poll = WM_operator_winactive ;
WM_operator_properties_gesture_straightline ( ot , 0 ) ;
}
# endif
2009-01-24 16:59:55 +00:00
/* *********************** radial control ****************** */
2011-02-13 14:16:36 +00:00
static const int WM_RADIAL_CONTROL_DISPLAY_SIZE = 200 ;
2009-01-24 22:58:22 +00:00
2011-05-12 01:57:47 +00:00
typedef struct {
PropertyType type ;
PropertySubType subtype ;
PointerRNA ptr , col_ptr , fill_col_ptr , rot_ptr , zoom_ptr , image_id_ptr ;
PropertyRNA * prop , * col_prop , * fill_col_prop , * rot_prop , * zoom_prop ;
StructRNA * image_id_srna ;
float initial_value , current_value , min_value , max_value ;
2009-01-24 16:59:55 +00:00
int initial_mouse [ 2 ] ;
2011-05-12 01:57:47 +00:00
unsigned int gltex ;
ListBase orig_paintcursors ;
2009-01-24 16:59:55 +00:00
void * cursor ;
2011-05-12 01:57:47 +00:00
} RadialControl ;
2009-01-24 16:59:55 +00:00
2011-05-12 01:57:47 +00:00
static void radial_control_set_initial_mouse ( RadialControl * rc , wmEvent * event )
2009-01-24 16:59:55 +00:00
{
2011-05-12 01:57:47 +00:00
float d [ 2 ] = { 0 , 0 } ;
float zoom [ 2 ] = { 1 , 1 } ;
2009-01-24 16:59:55 +00:00
2011-05-12 01:57:47 +00:00
rc - > initial_mouse [ 0 ] = event - > x ;
rc - > initial_mouse [ 1 ] = event - > y ;
2009-01-24 22:58:22 +00:00
2011-05-12 01:57:47 +00:00
switch ( rc - > subtype ) {
case PROP_DISTANCE :
d [ 0 ] = rc - > initial_value ;
break ;
case PROP_FACTOR :
d [ 0 ] = WM_RADIAL_CONTROL_DISPLAY_SIZE * ( 1 - rc - > initial_value ) ;
break ;
case PROP_ANGLE :
d [ 0 ] = WM_RADIAL_CONTROL_DISPLAY_SIZE * cos ( rc - > initial_value ) ;
d [ 1 ] = WM_RADIAL_CONTROL_DISPLAY_SIZE * sin ( rc - > initial_value ) ;
break ;
default :
return ;
2009-01-24 22:58:22 +00:00
}
2011-05-12 01:57:47 +00:00
if ( rc - > zoom_prop ) {
RNA_property_float_get_array ( & rc - > zoom_ptr , rc - > zoom_prop , zoom ) ;
d [ 0 ] * = zoom [ 0 ] ;
d [ 1 ] * = zoom [ 1 ] ;
}
2009-01-24 22:58:22 +00:00
2011-05-12 01:57:47 +00:00
rc - > initial_mouse [ 0 ] - = d [ 0 ] ;
rc - > initial_mouse [ 1 ] - = d [ 1 ] ;
}
2010-07-14 14:11:03 +00:00
2011-05-12 01:57:47 +00:00
static void radial_control_set_tex ( RadialControl * rc )
{
ImBuf * ibuf ;
2009-01-24 22:58:22 +00:00
2011-05-12 01:57:47 +00:00
switch ( RNA_type_to_ID_code ( rc - > image_id_ptr . type ) ) {
case ID_BR :
if ( ( ibuf = brush_gen_radial_control_imbuf ( rc - > image_id_ptr . data ) ) ) {
glGenTextures ( 1 , & rc - > gltex ) ;
glBindTexture ( GL_TEXTURE_2D , rc - > gltex ) ;
glTexImage2D ( GL_TEXTURE_2D , 0 , GL_ALPHA , ibuf - > x , ibuf - > y , 0 ,
GL_ALPHA , GL_FLOAT , ibuf - > rect_float ) ;
MEM_freeN ( ibuf - > rect_float ) ;
MEM_freeN ( ibuf ) ;
}
break ;
default :
break ;
2010-07-14 14:11:03 +00:00
}
2011-05-12 01:57:47 +00:00
}
static void radial_control_paint_tex ( RadialControl * rc , float radius , float alpha )
{
float col [ 3 ] = { 0 , 0 , 0 } ;
float rot ;
/* set fill color */
if ( rc - > fill_col_prop )
RNA_property_float_get_array ( & rc - > fill_col_ptr , rc - > fill_col_prop , col ) ;
glColor4f ( col [ 0 ] , col [ 1 ] , col [ 2 ] , alpha ) ;
2010-07-14 14:11:03 +00:00
2011-05-12 01:57:47 +00:00
if ( rc - > gltex ) {
glBindTexture ( GL_TEXTURE_2D , rc - > gltex ) ;
2009-01-24 22:58:22 +00:00
glTexParameterf ( GL_TEXTURE_2D , GL_TEXTURE_MIN_FILTER , GL_LINEAR ) ;
glTexParameterf ( GL_TEXTURE_2D , GL_TEXTURE_MAG_FILTER , GL_LINEAR ) ;
2011-05-12 01:57:47 +00:00
/* set up rotation if available */
if ( rc - > rot_prop ) {
rot = RNA_property_float_get ( & rc - > rot_ptr , rc - > rot_prop ) ;
glPushMatrix ( ) ;
glRotatef ( RAD2DEGF ( rot ) , 0 , 0 , 1 ) ;
}
/* draw textured quad */
2009-01-24 22:58:22 +00:00
glEnable ( GL_TEXTURE_2D ) ;
glBegin ( GL_QUADS ) ;
glTexCoord2f ( 0 , 0 ) ;
2011-05-12 01:57:47 +00:00
glVertex2f ( - radius , - radius ) ;
2009-01-24 22:58:22 +00:00
glTexCoord2f ( 1 , 0 ) ;
2011-05-12 01:57:47 +00:00
glVertex2f ( radius , - radius ) ;
2009-01-24 22:58:22 +00:00
glTexCoord2f ( 1 , 1 ) ;
2011-05-12 01:57:47 +00:00
glVertex2f ( radius , radius ) ;
2009-01-24 22:58:22 +00:00
glTexCoord2f ( 0 , 1 ) ;
2011-05-12 01:57:47 +00:00
glVertex2f ( - radius , radius ) ;
2009-01-24 22:58:22 +00:00
glEnd ( ) ;
glDisable ( GL_TEXTURE_2D ) ;
2011-05-12 01:57:47 +00:00
/* undo rotation */
if ( rc - > rot_prop )
glPopMatrix ( ) ;
2009-01-24 22:58:22 +00:00
}
2011-05-12 01:57:47 +00:00
else {
/* flat color if no texture available */
glutil_draw_filled_arc ( 0 , M_PI * 2 , radius , 40 ) ;
}
}
static void radial_control_paint_cursor ( bContext * C , int x , int y , void * customdata )
{
RadialControl * rc = customdata ;
ARegion * ar = CTX_wm_region ( C ) ;
float r1 = 0.0f , r2 = 0.0f , tex_radius , alpha ;
float zoom [ 2 ] , col [ 3 ] = { 1 , 1 , 1 } ;
2009-01-24 22:58:22 +00:00
2011-05-12 01:57:47 +00:00
switch ( rc - > subtype ) {
case PROP_DISTANCE :
r1 = rc - > current_value ;
r2 = rc - > initial_value ;
tex_radius = r1 ;
alpha = 0.75 ;
break ;
case PROP_FACTOR :
r1 = ( 1 - rc - > current_value ) * WM_RADIAL_CONTROL_DISPLAY_SIZE ;
r2 = tex_radius = WM_RADIAL_CONTROL_DISPLAY_SIZE ;
alpha = rc - > current_value / 2 + 0.5 ;
break ;
case PROP_ANGLE :
r1 = r2 = tex_radius = WM_RADIAL_CONTROL_DISPLAY_SIZE ;
alpha = 0.75 ;
break ;
default :
break ;
}
/* Keep cursor in the original place */
x = rc - > initial_mouse [ 0 ] - ar - > winrct . xmin ;
y = rc - > initial_mouse [ 1 ] - ar - > winrct . ymin ;
glTranslatef ( ( float ) x , ( float ) y , 0.0f ) ;
glEnable ( GL_BLEND ) ;
glEnable ( GL_LINE_SMOOTH ) ;
/* apply zoom if available */
if ( rc - > zoom_prop ) {
RNA_property_float_get_array ( & rc - > zoom_ptr , rc - > zoom_prop , zoom ) ;
glScalef ( zoom [ 0 ] , zoom [ 1 ] , 1 ) ;
}
/* draw rotated texture */
radial_control_paint_tex ( rc , tex_radius , alpha ) ;
/* set line color */
if ( rc - > col_prop )
RNA_property_float_get_array ( & rc - > col_ptr , rc - > col_prop , col ) ;
glColor4f ( col [ 0 ] , col [ 1 ] , col [ 2 ] , 0.5 ) ;
if ( rc - > subtype = = PROP_ANGLE ) {
glPushMatrix ( ) ;
/* draw original angle line */
glRotatef ( RAD2DEGF ( rc - > initial_value ) , 0 , 0 , 1 ) ;
2011-04-10 09:37:04 +00:00
fdrawline ( 0.0f , 0.0f , ( float ) WM_RADIAL_CONTROL_DISPLAY_SIZE , 0.0f ) ;
2011-05-12 01:57:47 +00:00
/* draw new angle line */
glRotatef ( RAD2DEGF ( rc - > current_value - rc - > initial_value ) , 0 , 0 , 1 ) ;
2011-04-10 09:37:04 +00:00
fdrawline ( 0.0f , 0.0f , ( float ) WM_RADIAL_CONTROL_DISPLAY_SIZE , 0.0f ) ;
2011-05-12 01:57:47 +00:00
glPopMatrix ( ) ;
2010-07-14 14:11:03 +00:00
}
2011-05-12 01:57:47 +00:00
/* draw circles on top */
2011-04-03 13:17:07 +00:00
glutil_draw_lined_arc ( 0.0 , ( float ) ( M_PI * 2.0 ) , r1 , 40 ) ;
glutil_draw_lined_arc ( 0.0 , ( float ) ( M_PI * 2.0 ) , r2 , 40 ) ;
2011-05-12 01:57:47 +00:00
2009-01-24 16:59:55 +00:00
glDisable ( GL_BLEND ) ;
2011-05-12 01:57:47 +00:00
glDisable ( GL_LINE_SMOOTH ) ;
2009-01-24 16:59:55 +00:00
}
2011-05-12 01:57:47 +00:00
/* attempt to retrieve the rna pointer/property from an rna path;
returns 0 for failure , 1 for success , and also 1 if property is not
set */
static int radial_control_get_path ( PointerRNA * ctx_ptr , wmOperator * op ,
const char * name , PointerRNA * r_ptr ,
PropertyRNA * * r_prop , int req_float ,
int req_length , int allow_missing )
2009-01-24 16:59:55 +00:00
{
2011-05-12 01:57:47 +00:00
PropertyRNA * unused_prop ;
int len ;
char * str ;
2009-01-24 16:59:55 +00:00
2011-05-12 01:57:47 +00:00
/* get an rna string path from the operator's properties */
if ( ! ( str = RNA_string_get_alloc ( op - > ptr , name , NULL , 0 ) ) )
return 1 ;
2009-01-24 16:59:55 +00:00
2011-05-12 01:57:47 +00:00
if ( str [ 0 ] = = ' \0 ' ) {
MEM_freeN ( str ) ;
return 1 ;
}
2010-07-14 14:11:03 +00:00
2011-05-12 01:57:47 +00:00
if ( ! r_prop )
r_prop = & unused_prop ;
2010-07-14 14:11:03 +00:00
2011-05-12 01:57:47 +00:00
/* get rna from path */
if ( ! RNA_path_resolve ( ctx_ptr , str , r_ptr , r_prop ) ) {
MEM_freeN ( str ) ;
if ( allow_missing )
return 1 ;
else {
BKE_reportf ( op - > reports , RPT_ERROR , " Couldn't resolve path %s " , name ) ;
return 0 ;
}
}
2009-01-24 16:59:55 +00:00
2011-05-12 01:57:47 +00:00
/* if property is expected to be a float, check its type */
if ( req_float ) {
if ( ! ( * r_prop ) | | ( RNA_property_type ( * r_prop ) ! = PROP_FLOAT ) ) {
MEM_freeN ( str ) ;
BKE_reportf ( op - > reports , RPT_ERROR ,
" Property from path %s is not a float " , name ) ;
return 0 ;
2009-01-24 22:58:22 +00:00
}
2011-05-12 01:57:47 +00:00
}
/* check property's array length */
if ( * r_prop & & ( len = RNA_property_array_length ( r_ptr , * r_prop ) ) ! = req_length ) {
MEM_freeN ( str ) ;
BKE_reportf ( op - > reports , RPT_ERROR ,
" Property from path %s has length %d instead of %d " ,
name , len , req_length ) ;
return 0 ;
2009-01-24 16:59:55 +00:00
}
2011-05-12 01:57:47 +00:00
/* success */
MEM_freeN ( str ) ;
return 1 ;
}
2009-01-24 22:58:22 +00:00
2011-05-12 01:57:47 +00:00
/* initialize the rna pointers and properties using rna paths */
static int radial_control_get_properties ( bContext * C , wmOperator * op )
{
RadialControl * rc = op - > customdata ;
PointerRNA ctx_ptr ;
2009-01-24 16:59:55 +00:00
2011-05-12 01:57:47 +00:00
RNA_pointer_create ( NULL , & RNA_Context , C , & ctx_ptr ) ;
2009-01-24 16:59:55 +00:00
2011-05-12 01:57:47 +00:00
if ( ! radial_control_get_path ( & ctx_ptr , op , " data_path " , & rc - > ptr , & rc - > prop , 0 , 0 , 0 ) )
return 0 ;
2009-01-24 16:59:55 +00:00
2011-05-12 01:57:47 +00:00
/* data path is required */
if ( ! rc - > prop )
return 0 ;
if ( ! radial_control_get_path ( & ctx_ptr , op , " rotation_path " , & rc - > rot_ptr , & rc - > rot_prop , 1 , 0 , 0 ) )
return 0 ;
if ( ! radial_control_get_path ( & ctx_ptr , op , " color_path " , & rc - > col_ptr , & rc - > col_prop , 1 , 3 , 0 ) )
return 0 ;
if ( ! radial_control_get_path ( & ctx_ptr , op , " fill_color_path " , & rc - > fill_col_ptr , & rc - > fill_col_prop , 1 , 3 , 0 ) )
return 0 ;
/* slightly ugly; allow this property to not resolve
correctly . needed because 3 d texture paint shares the same
keymap as 2 d image paint */
if ( ! radial_control_get_path ( & ctx_ptr , op , " zoom_path " , & rc - > zoom_ptr , & rc - > zoom_prop , 1 , 2 , 1 ) )
return 0 ;
if ( ! radial_control_get_path ( & ctx_ptr , op , " image_id " , & rc - > image_id_ptr , NULL , 0 , 0 , 0 ) )
return 0 ;
else if ( rc - > image_id_ptr . data ) {
/* extra check, pointer must be to an ID */
if ( ! RNA_struct_is_ID ( rc - > image_id_ptr . type ) ) {
BKE_report ( op - > reports , RPT_ERROR ,
" Pointer from path image_id is not an ID " ) ;
return 0 ;
}
}
2010-07-14 14:11:03 +00:00
2011-05-12 01:57:47 +00:00
return 1 ;
2009-01-24 16:59:55 +00:00
}
2011-05-12 01:57:47 +00:00
static int radial_control_invoke ( bContext * C , wmOperator * op , wmEvent * event )
2009-01-24 16:59:55 +00:00
{
2011-05-12 01:57:47 +00:00
wmWindowManager * wm ;
RadialControl * rc ;
int min_value_int , max_value_int , step_int ;
float step_float , precision ;
2010-11-03 06:31:53 +00:00
2011-05-12 01:57:47 +00:00
if ( ! ( op - > customdata = rc = MEM_callocN ( sizeof ( RadialControl ) , " RadialControl " ) ) )
return OPERATOR_CANCELLED ;
2010-07-14 14:11:03 +00:00
2011-05-12 01:57:47 +00:00
if ( ! radial_control_get_properties ( C , op ) ) {
MEM_freeN ( rc ) ;
return OPERATOR_CANCELLED ;
2009-01-24 22:58:22 +00:00
}
2011-05-12 01:57:47 +00:00
/* get type, initial, min, and max values of the property */
switch ( ( rc - > type = RNA_property_type ( rc - > prop ) ) ) {
case PROP_INT :
rc - > initial_value = RNA_property_int_get ( & rc - > ptr , rc - > prop ) ;
RNA_property_int_ui_range ( & rc - > ptr , rc - > prop , & min_value_int ,
& max_value_int , & step_int ) ;
rc - > min_value = min_value_int ;
rc - > max_value = max_value_int ;
break ;
case PROP_FLOAT :
rc - > initial_value = RNA_property_float_get ( & rc - > ptr , rc - > prop ) ;
RNA_property_float_ui_range ( & rc - > ptr , rc - > prop , & rc - > min_value ,
& rc - > max_value , & step_float , & precision ) ;
break ;
default :
BKE_report ( op - > reports , RPT_ERROR , " Property must be an integer or a float " ) ;
MEM_freeN ( rc ) ;
return OPERATOR_CANCELLED ;
2009-01-24 16:59:55 +00:00
}
2011-05-12 01:57:47 +00:00
/* get subtype of property */
rc - > subtype = RNA_property_subtype ( rc - > prop ) ;
if ( ! ELEM3 ( rc - > subtype , PROP_DISTANCE , PROP_FACTOR , PROP_ANGLE ) ) {
BKE_report ( op - > reports , RPT_ERROR , " Property must be a distance, a factor, or an angle " ) ;
MEM_freeN ( rc ) ;
return OPERATOR_CANCELLED ;
}
2009-01-24 16:59:55 +00:00
2011-05-12 01:57:47 +00:00
rc - > current_value = rc - > initial_value ;
radial_control_set_initial_mouse ( rc , event ) ;
radial_control_set_tex ( rc ) ;
2009-01-24 16:59:55 +00:00
2011-05-12 01:57:47 +00:00
/* temporarily disable other paint cursors */
wm = CTX_wm_manager ( C ) ;
rc - > orig_paintcursors = wm - > paintcursors ;
wm - > paintcursors . first = wm - > paintcursors . last = NULL ;
/* add radial control paint cursor */
rc - > cursor = WM_paint_cursor_activate ( wm , op - > type - > poll ,
radial_control_paint_cursor , rc ) ;
2010-07-14 14:11:03 +00:00
2009-09-18 12:43:36 +00:00
WM_event_add_modal_handler ( C , op ) ;
2011-05-12 01:57:47 +00:00
2009-01-24 16:59:55 +00:00
return OPERATOR_RUNNING_MODAL ;
}
2011-05-12 01:57:47 +00:00
static void radial_control_set_value ( RadialControl * rc , float val )
2009-01-25 21:02:52 +00:00
{
2011-05-12 01:57:47 +00:00
switch ( rc - > type ) {
case PROP_INT :
RNA_property_int_set ( & rc - > ptr , rc - > prop , val ) ;
break ;
case PROP_FLOAT :
RNA_property_float_set ( & rc - > ptr , rc - > prop , val ) ;
break ;
default :
break ;
}
2009-01-25 21:02:52 +00:00
}
2011-05-12 01:57:47 +00:00
static int radial_control_modal ( bContext * C , wmOperator * op , wmEvent * event )
2009-01-24 16:59:55 +00:00
{
2011-05-12 01:57:47 +00:00
RadialControl * rc = op - > customdata ;
wmWindowManager * wm ;
float new_value , dist , zoom [ 2 ] ;
float delta [ 2 ] , snap , ret = OPERATOR_RUNNING_MODAL ;
/* TODO: fix hardcoded events */
snap = event - > ctrl ;
switch ( event - > type ) {
case MOUSEMOVE :
delta [ 0 ] = rc - > initial_mouse [ 0 ] - event - > x ;
delta [ 1 ] = rc - > initial_mouse [ 1 ] - event - > y ;
if ( rc - > zoom_prop ) {
RNA_property_float_get_array ( & rc - > zoom_ptr , rc - > zoom_prop , zoom ) ;
delta [ 0 ] / = zoom [ 0 ] ;
delta [ 1 ] / = zoom [ 1 ] ;
}
2009-01-24 16:59:55 +00:00
2011-05-12 01:57:47 +00:00
dist = sqrt ( delta [ 0 ] * delta [ 0 ] + delta [ 1 ] * delta [ 1 ] ) ;
2009-01-24 16:59:55 +00:00
2011-05-12 01:57:47 +00:00
/* calculate new value and apply snapping */
switch ( rc - > subtype ) {
case PROP_DISTANCE :
new_value = dist ;
if ( snap ) new_value = ( ( int ) new_value + 5 ) / 10 * 10 ;
break ;
case PROP_FACTOR :
new_value = 1 - dist / WM_RADIAL_CONTROL_DISPLAY_SIZE ;
if ( snap ) new_value = ( ( int ) ceil ( new_value * 10.f ) * 10.0f ) / 100.f ;
break ;
case PROP_ANGLE :
new_value = atan2 ( delta [ 1 ] , delta [ 0 ] ) + M_PI ;
if ( snap ) new_value = DEG2RADF ( ( ( int ) RAD2DEGF ( new_value ) + 5 ) / 10 * 10 ) ;
break ;
default :
break ;
}
/* clamp and update */
CLAMP ( new_value , rc - > min_value , rc - > max_value ) ;
radial_control_set_value ( rc , new_value ) ;
rc - > current_value = new_value ;
break ;
case ESCKEY :
case RIGHTMOUSE :
/* cancelled; restore original value */
radial_control_set_value ( rc , rc - > initial_value ) ;
ret = OPERATOR_CANCELLED ;
break ;
case LEFTMOUSE :
case PADENTER :
/* done; value already set */
ret = OPERATOR_FINISHED ;
break ;
}
ED_region_tag_redraw ( CTX_wm_region ( C ) ) ;
if ( ret ! = OPERATOR_RUNNING_MODAL ) {
wm = CTX_wm_manager ( C ) ;
WM_paint_cursor_end ( wm , rc - > cursor ) ;
/* restore original paint cursors */
wm - > paintcursors = rc - > orig_paintcursors ;
/* not sure if this is a good notifier to use;
intended purpose is to update the UI so that the
new value is displayed in sliders / numfields */
WM_event_add_notifier ( C , NC_WINDOW , NULL ) ;
glDeleteTextures ( 1 , & rc - > gltex ) ;
MEM_freeN ( rc ) ;
}
return ret ;
}
static void WM_OT_radial_control ( wmOperatorType * ot )
{
ot - > name = " Radial Control " ;
ot - > idname = " WM_OT_radial_control " ;
2009-01-24 16:59:55 +00:00
2011-05-12 01:57:47 +00:00
ot - > invoke = radial_control_invoke ;
ot - > modal = radial_control_modal ;
2009-01-24 16:59:55 +00:00
2011-05-12 01:57:47 +00:00
ot - > flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING ;
2010-08-20 09:41:16 +00:00
2011-05-12 01:57:47 +00:00
/* all paths relative to the context */
RNA_def_string ( ot - > srna , " data_path " , " " , 0 , " Data Path " , " Path of property to be set by the radial control. " ) ;
RNA_def_string ( ot - > srna , " rotation_path " , " " , 0 , " Rotation Path " , " Path of property used to rotate the texture display. " ) ;
RNA_def_string ( ot - > srna , " color_path " , " " , 0 , " Color Path " , " Path of property used to set the color of the control. " ) ;
RNA_def_string ( ot - > srna , " fill_color_path " , " " , 0 , " Fill Color Path " , " Path of property used to set the fill color of the control. " ) ;
RNA_def_string ( ot - > srna , " zoom_path " , " " , 0 , " Zoom Path " , " Path of property used to set the zoom level for the control. " ) ;
RNA_def_string ( ot - > srna , " image_id " , " " , 0 , " Image ID " , " Path of ID that is used to generate an image for the control. " ) ;
2009-01-24 16:59:55 +00:00
}
2009-05-19 12:54:54 +00:00
/* ************************** timer for testing ***************** */
/* uses no type defines, fully local testing function anyway... ;) */
2010-06-14 10:33:26 +00:00
static void redraw_timer_window_swap ( bContext * C )
{
wmWindow * win = CTX_wm_window ( C ) ;
ScrArea * sa ;
for ( sa = CTX_wm_screen ( C ) - > areabase . first ; sa ; sa = sa - > next )
ED_area_tag_redraw ( sa ) ;
wm_draw_update ( C ) ;
CTX_wm_window_set ( C , win ) ; /* XXX context manipulation warning! */
}
static EnumPropertyItem redraw_timer_type_items [ ] = {
{ 0 , " DRAW " , 0 , " Draw Region " , " Draw Region " } ,
{ 1 , " DRAW_SWAP " , 0 , " Draw Region + Swap " , " Draw Region and Swap " } ,
{ 2 , " DRAW_WIN " , 0 , " Draw Window " , " Draw Window " } ,
{ 3 , " DRAW_WIN_SWAP " , 0 , " Draw Window + Swap " , " Draw Window and Swap " } ,
{ 4 , " ANIM_STEP " , 0 , " Anim Step " , " Animation Steps " } ,
{ 5 , " ANIM_PLAY " , 0 , " Anim Play " , " Animation Playback " } ,
{ 6 , " UNDO " , 0 , " Undo/Redo " , " Undo/Redo " } ,
{ 0 , NULL , 0 , NULL , NULL } } ;
2009-09-22 09:12:39 +00:00
static int redraw_timer_exec ( bContext * C , wmOperator * op )
2009-05-19 12:54:54 +00:00
{
ARegion * ar = CTX_wm_region ( C ) ;
double stime = PIL_check_seconds_timer ( ) ;
2011-03-22 13:30:20 +00:00
int type = RNA_enum_get ( op - > ptr , " type " ) ;
2009-09-22 09:12:39 +00:00
int iter = RNA_int_get ( op - > ptr , " iterations " ) ;
int a ;
float time ;
2010-06-14 10:33:26 +00:00
const char * infostr = " " ;
2009-05-19 12:54:54 +00:00
WM_cursor_wait ( 1 ) ;
2009-09-22 09:12:39 +00:00
for ( a = 0 ; a < iter ; a + + ) {
2009-05-19 12:54:54 +00:00
if ( type = = 0 ) {
2010-11-04 15:59:09 +00:00
if ( ar )
ED_region_do_draw ( C , ar ) ;
2009-05-19 12:54:54 +00:00
}
else if ( type = = 1 ) {
wmWindow * win = CTX_wm_window ( C ) ;
ED_region_tag_redraw ( ar ) ;
wm_draw_update ( C ) ;
CTX_wm_window_set ( C , win ) ; /* XXX context manipulation warning! */
}
else if ( type = = 2 ) {
wmWindow * win = CTX_wm_window ( C ) ;
ScrArea * sa ;
2009-09-22 09:12:39 +00:00
ScrArea * sa_back = CTX_wm_area ( C ) ;
ARegion * ar_back = CTX_wm_region ( C ) ;
for ( sa = CTX_wm_screen ( C ) - > areabase . first ; sa ; sa = sa - > next ) {
ARegion * ar_iter ;
CTX_wm_area_set ( C , sa ) ;
for ( ar_iter = sa - > regionbase . first ; ar_iter ; ar_iter = ar_iter - > next ) {
2009-12-14 20:37:05 +00:00
if ( ar_iter - > swinid ) {
CTX_wm_region_set ( C , ar_iter ) ;
ED_region_do_draw ( C , ar_iter ) ;
}
2009-09-22 09:12:39 +00:00
}
}
CTX_wm_window_set ( C , win ) ; /* XXX context manipulation warning! */
CTX_wm_area_set ( C , sa_back ) ;
CTX_wm_region_set ( C , ar_back ) ;
}
else if ( type = = 3 ) {
2010-06-14 10:33:26 +00:00
redraw_timer_window_swap ( C ) ;
2009-05-19 12:54:54 +00:00
}
2009-09-22 09:12:39 +00:00
else if ( type = = 4 ) {
2010-08-01 12:47:49 +00:00
Main * bmain = CTX_data_main ( C ) ;
2009-05-19 15:37:50 +00:00
Scene * scene = CTX_data_scene ( C ) ;
if ( a & 1 ) scene - > r . cfra - - ;
else scene - > r . cfra + + ;
2010-08-01 12:47:49 +00:00
scene_update_for_newframe ( bmain , scene , scene - > lay ) ;
2009-05-19 15:37:50 +00:00
}
2010-06-14 10:33:26 +00:00
else if ( type = = 5 ) {
/* play anim, return on same frame as started with */
2010-08-01 12:47:49 +00:00
Main * bmain = CTX_data_main ( C ) ;
2010-06-14 10:33:26 +00:00
Scene * scene = CTX_data_scene ( C ) ;
int tot = ( scene - > r . efra - scene - > r . sfra ) + 1 ;
while ( tot - - ) {
/* todo, ability to escape! */
scene - > r . cfra + + ;
if ( scene - > r . cfra > scene - > r . efra )
scene - > r . cfra = scene - > r . sfra ;
2010-08-01 12:47:49 +00:00
scene_update_for_newframe ( bmain , scene , scene - > lay ) ;
2010-06-14 10:33:26 +00:00
redraw_timer_window_swap ( C ) ;
}
}
else { /* 6 */
2009-05-19 12:54:54 +00:00
ED_undo_pop ( C ) ;
ED_undo_redo ( C ) ;
}
}
2011-04-10 09:37:04 +00:00
time = ( float ) ( ( PIL_check_seconds_timer ( ) - stime ) * 1000 ) ;
2010-06-14 10:33:26 +00:00
RNA_enum_description ( redraw_timer_type_items , type , & infostr ) ;
2009-05-19 12:54:54 +00:00
WM_cursor_wait ( 0 ) ;
2010-06-14 10:33:26 +00:00
2010-01-31 18:06:50 +00:00
BKE_reportf ( op - > reports , RPT_WARNING , " %d x %s: %.2f ms, average: %.4f " , iter , infostr , time , time / iter ) ;
2009-05-19 12:54:54 +00:00
return OPERATOR_FINISHED ;
}
2009-09-22 09:12:39 +00:00
static void WM_OT_redraw_timer ( wmOperatorType * ot )
2009-05-19 12:54:54 +00:00
{
2009-09-22 09:12:39 +00:00
ot - > name = " Redraw Timer " ;
ot - > idname = " WM_OT_redraw_timer " ;
2010-02-10 21:15:44 +00:00
ot - > description = " Simple redraw timer to test the speed of updating the interface " ;
2010-06-14 10:33:26 +00:00
2009-05-19 12:54:54 +00:00
ot - > invoke = WM_menu_invoke ;
2009-09-22 09:12:39 +00:00
ot - > exec = redraw_timer_exec ;
2009-05-19 12:54:54 +00:00
ot - > poll = WM_operator_winactive ;
2010-06-14 10:33:26 +00:00
ot - > prop = RNA_def_enum ( ot - > srna , " type " , redraw_timer_type_items , 0 , " Type " , " " ) ;
2009-09-22 09:12:39 +00:00
RNA_def_int ( ot - > srna , " iterations " , 10 , 1 , INT_MAX , " Iterations " , " Number of times to redraw " , 1 , 1000 ) ;
2009-05-19 12:54:54 +00:00
}
2009-10-27 10:29:51 +00:00
/* ************************** memory statistics for testing ***************** */
2009-05-19 12:54:54 +00:00
2010-10-16 02:40:31 +00:00
static int memory_statistics_exec ( bContext * UNUSED ( C ) , wmOperator * UNUSED ( op ) )
2009-10-27 10:29:51 +00:00
{
MEM_printmemlist_stats ( ) ;
return OPERATOR_FINISHED ;
}
static void WM_OT_memory_statistics ( wmOperatorType * ot )
{
ot - > name = " Memory Statistics " ;
ot - > idname = " WM_OT_memory_statistics " ;
2010-02-10 21:15:44 +00:00
ot - > description = " Print memory statistics to the console " ;
2009-10-27 10:29:51 +00:00
ot - > exec = memory_statistics_exec ;
}
2009-05-19 12:54:54 +00:00
2.5: gesture code in WM
- Simplified and cleaned previous border code
It was a bit too complex, too many data manipulations
Original idea was to have WM API calls to manage border, circle, lines,
lasso, etc. This now means that WM provides callbacks for custom operators,
so it's very easy to make them. Check bottom of screen_edit.c for an
example.
Currently two borders were coded; with and without cross hair.
Press Bkey in any area-region to test it (note: time window has wrong matrix!)
Some specs to note:
- gestures are in region space, and draw 'over'. That latter still needs some
work when we do real composites.
- only the active region is redrawn.
- on todo is the generic gesture engine for 'tweak' or like how currently grab
gestures in Blender work. These will be configurable per area-region, and WM
then will send the proper "Gesture Event" with properties (N, S, E, W, etc)
to which you then can assign operators. Such events will be generated with low
priority, so other handlers who swallowed mouse events have preference.
2008-11-19 13:16:05 +00:00
/* ******************************************************* */
2008-01-19 17:54:05 +00:00
2007-12-24 18:27:28 +00:00
/* called on initialize WM_exit() */
void wm_operatortype_free ( void )
{
2.5
Operator goodies!
--- Macro operators
Operators now can consist of multiple operators. Such a macro operator
is identical and behaves identical to other opererators. Macros can
also be constructed of macros even! Currently only hardcoded macros are
implemented, this to solve combined operators such as 'add duplicate' or
'extrude' (both want a transform appended).
Usage is simple:
- WM_operatortype_append_macro() : add new operatortype, name, flags
- WM_operatortype_macro_define() : add existing operator to macro
(Note: macro_define will also allow properties to be set, doesnt work
right now)
On converting the macro wmOperatorType to a real operator, it makes a
list of all operators, and the standard macro callbacks (exec, invoke,
modal, poll) just will use all.
Important note; switching to a modal operator only works as last in the
chain now!
Macros implemented for duplicate, extrude and rip. Tool menu works fine
for it, also the redo hotkey F4 works properly.
--- Operator redo fix
The operators use the undo system to switch back, but this could give
errors if other actions added undo pushes (buttons, outliner). Now the
redo for operator searches back for the correct undo level.
This fixes issues with many redos.
Note for brecht: removed the ED_undo_push for buttons... it was called
on *every* button now, which is probably too much? For example, using
the 'toolbar' redo also caused this...
2009-07-29 17:56:38 +00:00
wmOperatorType * ot ;
2009-12-24 19:50:43 +00:00
for ( ot = global_ops . first ; ot ; ot = ot - > next ) {
2.5
Operator goodies!
--- Macro operators
Operators now can consist of multiple operators. Such a macro operator
is identical and behaves identical to other opererators. Macros can
also be constructed of macros even! Currently only hardcoded macros are
implemented, this to solve combined operators such as 'add duplicate' or
'extrude' (both want a transform appended).
Usage is simple:
- WM_operatortype_append_macro() : add new operatortype, name, flags
- WM_operatortype_macro_define() : add existing operator to macro
(Note: macro_define will also allow properties to be set, doesnt work
right now)
On converting the macro wmOperatorType to a real operator, it makes a
list of all operators, and the standard macro callbacks (exec, invoke,
modal, poll) just will use all.
Important note; switching to a modal operator only works as last in the
chain now!
Macros implemented for duplicate, extrude and rip. Tool menu works fine
for it, also the redo hotkey F4 works properly.
--- Operator redo fix
The operators use the undo system to switch back, but this could give
errors if other actions added undo pushes (buttons, outliner). Now the
redo for operator searches back for the correct undo level.
This fixes issues with many redos.
Note for brecht: removed the ED_undo_push for buttons... it was called
on *every* button now, which is probably too much? For example, using
the 'toolbar' redo also caused this...
2009-07-29 17:56:38 +00:00
if ( ot - > macro . first )
wm_operatortype_free_macro ( ot ) ;
2009-12-24 19:50:43 +00:00
if ( ot - > ext . srna ) /* python operator, allocs own string */
2010-11-17 09:45:45 +00:00
MEM_freeN ( ( void * ) ot - > idname ) ;
2009-12-24 19:50:43 +00:00
}
2.5
Operator goodies!
--- Macro operators
Operators now can consist of multiple operators. Such a macro operator
is identical and behaves identical to other opererators. Macros can
also be constructed of macros even! Currently only hardcoded macros are
implemented, this to solve combined operators such as 'add duplicate' or
'extrude' (both want a transform appended).
Usage is simple:
- WM_operatortype_append_macro() : add new operatortype, name, flags
- WM_operatortype_macro_define() : add existing operator to macro
(Note: macro_define will also allow properties to be set, doesnt work
right now)
On converting the macro wmOperatorType to a real operator, it makes a
list of all operators, and the standard macro callbacks (exec, invoke,
modal, poll) just will use all.
Important note; switching to a modal operator only works as last in the
chain now!
Macros implemented for duplicate, extrude and rip. Tool menu works fine
for it, also the redo hotkey F4 works properly.
--- Operator redo fix
The operators use the undo system to switch back, but this could give
errors if other actions added undo pushes (buttons, outliner). Now the
redo for operator searches back for the correct undo level.
This fixes issues with many redos.
Note for brecht: removed the ED_undo_push for buttons... it was called
on *every* button now, which is probably too much? For example, using
the 'toolbar' redo also caused this...
2009-07-29 17:56:38 +00:00
2007-12-24 18:27:28 +00:00
BLI_freelistN ( & global_ops ) ;
}
/* called on initialize WM_init() */
void wm_operatortype_init ( void )
{
2.5 Branch
==========
* Changed wmOperatorType, removing init/exit callbacks and adding cancel
callback, removed default storage in favor of properties. Defined return
values for exec/invoke/modal/cancel.
* Don't allocate operator on the stack, and removed operator copy for
handlers. Now it frees based on return values from callbacks, and just
keeps a wmOperator on the heap. Also it now registers after the operator
is fully finished, to get the correct final properties.
* Changed OP_get_* functions to return 1 if the property is found and 0
otherwise, gives more readable code in my opinion. Added OP_verify_*
functions to quickly check if the property is available and set if it's
not, that's common for exec/invoke.
* Removed WM_operatortypelist_append in favor of WM_operatortype_append
which takes a function pointer instead of a list, avoids macro's and
duplicating code.
* Fix a crash where the handler would still be used while it was freed by
the operator.
* Spacetypes now have operatortypes() and keymap() callbacks to abstract
them a bit more.
* Renamed C->curarea to C->area for consistency. Removed View3D/View2D/
SpaceIpo from bContext, seems bad to keep these.
* Set context variables like window/screen/area/region to NULL again when
leaving that context, instead of leaving the pointers there.
* Added if(G.f & G_DEBUG) for many of the prints, makes output a bit
cleaner and easier to debug.
* Fixed priority of the editors/interface module in scons, would otherwise
give link errors.
* Added start of generic view2d api.
* Added space_time with some basic drawing and a single operator to change
the frame.
2008-06-11 10:10:31 +00:00
WM_operatortype_append ( WM_OT_window_duplicate ) ;
2009-02-07 10:00:46 +00:00
WM_operatortype_append ( WM_OT_read_homefile ) ;
2010-10-02 13:45:26 +00:00
WM_operatortype_append ( WM_OT_read_factory_settings ) ;
2.5 Branch
==========
* Changed wmOperatorType, removing init/exit callbacks and adding cancel
callback, removed default storage in favor of properties. Defined return
values for exec/invoke/modal/cancel.
* Don't allocate operator on the stack, and removed operator copy for
handlers. Now it frees based on return values from callbacks, and just
keeps a wmOperator on the heap. Also it now registers after the operator
is fully finished, to get the correct final properties.
* Changed OP_get_* functions to return 1 if the property is found and 0
otherwise, gives more readable code in my opinion. Added OP_verify_*
functions to quickly check if the property is available and set if it's
not, that's common for exec/invoke.
* Removed WM_operatortypelist_append in favor of WM_operatortype_append
which takes a function pointer instead of a list, avoids macro's and
duplicating code.
* Fix a crash where the handler would still be used while it was freed by
the operator.
* Spacetypes now have operatortypes() and keymap() callbacks to abstract
them a bit more.
* Renamed C->curarea to C->area for consistency. Removed View3D/View2D/
SpaceIpo from bContext, seems bad to keep these.
* Set context variables like window/screen/area/region to NULL again when
leaving that context, instead of leaving the pointers there.
* Added if(G.f & G_DEBUG) for many of the prints, makes output a bit
cleaner and easier to debug.
* Fixed priority of the editors/interface module in scons, would otherwise
give link errors.
* Added start of generic view2d api.
* Added space_time with some basic drawing and a single operator to change
the frame.
2008-06-11 10:10:31 +00:00
WM_operatortype_append ( WM_OT_save_homefile ) ;
WM_operatortype_append ( WM_OT_window_fullscreen_toggle ) ;
2010-10-11 22:05:45 +00:00
WM_operatortype_append ( WM_OT_quit_blender ) ;
2009-01-06 14:42:54 +00:00
WM_operatortype_append ( WM_OT_open_mainfile ) ;
2009-09-12 19:54:39 +00:00
WM_operatortype_append ( WM_OT_link_append ) ;
2009-07-23 21:35:11 +00:00
WM_operatortype_append ( WM_OT_recover_last_session ) ;
2009-10-20 13:58:53 +00:00
WM_operatortype_append ( WM_OT_recover_auto_save ) ;
2009-01-21 19:28:28 +00:00
WM_operatortype_append ( WM_OT_save_as_mainfile ) ;
2009-02-08 19:15:59 +00:00
WM_operatortype_append ( WM_OT_save_mainfile ) ;
2009-09-22 09:12:39 +00:00
WM_operatortype_append ( WM_OT_redraw_timer ) ;
2009-10-27 10:29:51 +00:00
WM_operatortype_append ( WM_OT_memory_statistics ) ;
2009-05-22 15:02:32 +00:00
WM_operatortype_append ( WM_OT_debug_menu ) ;
2009-11-23 13:58:55 +00:00
WM_operatortype_append ( WM_OT_splash ) ;
2009-06-03 18:31:37 +00:00
WM_operatortype_append ( WM_OT_search_menu ) ;
2009-10-06 13:04:31 +00:00
WM_operatortype_append ( WM_OT_call_menu ) ;
2011-05-12 01:57:47 +00:00
WM_operatortype_append ( WM_OT_radial_control ) ;
2010-11-11 20:32:28 +00:00
# if defined(WIN32)
2011-04-06 12:30:07 +00:00
WM_operatortype_append ( WM_OT_console_toggle ) ;
2010-10-18 20:41:52 +00:00
# endif
Merge of the COLLADA GSoC branch into trunk.
COLLADA code is disabled by default (it has dependencies requiring manual install).
SCons and CMake builds are supported on Windows and Linux, no Mac building yet. More on building COLLADA code: http://wiki.blender.org/index.php/User:Kazanbas/Building_Collada_Branch.
The detailed command log of the merge (can be useful for educational purposes):
branch=https://svn.blender.org/svnroot/bf-blender/branches/soc-2009-chingachgook
# collada code
svn copy $branch/source/blender/collada source/blender/collada
# operator
svn merge -c 20401,20955,21077,24077,24079 $branch/source/blender/windowmanager/intern/wm_operators.c source/blender/windowmanager/intern/wm_operators.c
# menu
svn merge -c 24079 $branch/release/scripts/ui/space_info.py release/scripts/ui/space_info.py
# scons
svn merge -c 20398 $branch/source/blender/SConscript source/blender/SConscript
svn merge -c 20398,20691,20955,22726 $branch/tools/btools.py tools/btools.py
svn merge -c 20691,20955,22726 $branch/tools/Blender.py tools/Blender.py
svn merge -c 20398,20692,20955 $branch/config/linux2-config.py config/linux2-config.py
svn merge -c 22726 $branch/config/win64-vc-config.py config/win64-vc-config.py
svn merge -c 22726 $branch/config/win32-vc-config.py config/win32-vc-config.py
svn merge -c 24077 $branch/source/blender/windowmanager/SConscript source/blender/windowmanager/SConscript
# cmake
svn merge -c 23319,23905,24077,24158 $branch/CMakeLists.txt CMakeLists.txt
svn merge -c 23319 $branch/source/blender/CMakeLists.txt source/blender/CMakeLists.txt
svn merge -c 23319 $branch/source/creator/CMakeLists.txt source/creator/CMakeLists.txt
svn merge -c 23319 $branch/CMake/macros.cmake CMake/macros.cmake
svn merge -c 24077 $branch/source/blender/windowmanager/CMakeLists.txt source/blender/windowmanager/CMakeLists.txt
2009-10-30 15:35:50 +00:00
# ifdef WITH_COLLADA
/* XXX: move these */
WM_operatortype_append ( WM_OT_collada_export ) ;
WM_operatortype_append ( WM_OT_collada_import ) ;
# endif
2007-12-24 18:27:28 +00:00
}
2010-04-02 03:52:44 +00:00
/* circleselect-like modal operators */
2009-11-05 17:32:06 +00:00
static void gesture_circle_modal_keymap ( wmKeyConfig * keyconf )
{
static EnumPropertyItem modal_items [ ] = {
{ GESTURE_MODAL_CANCEL , " CANCEL " , 0 , " Cancel " , " " } ,
{ GESTURE_MODAL_CONFIRM , " CONFIRM " , 0 , " Confirm " , " " } ,
2009-11-06 22:51:08 +00:00
{ GESTURE_MODAL_CIRCLE_ADD , " ADD " , 0 , " Add " , " " } ,
{ GESTURE_MODAL_CIRCLE_SUB , " SUBTRACT " , 0 , " Subtract " , " " } ,
2009-11-05 17:32:06 +00:00
{ GESTURE_MODAL_SELECT , " SELECT " , 0 , " Select " , " " } ,
{ GESTURE_MODAL_DESELECT , " DESELECT " , 0 , " DeSelect " , " " } ,
{ GESTURE_MODAL_NOP , " NOP " , 0 , " No Operation " , " " } ,
{ 0 , NULL , 0 , NULL , NULL } } ;
wmKeyMap * keymap = WM_modalkeymap_get ( keyconf , " View3D Gesture Circle " ) ;
/* this function is called for each spacetype, only needs to add map once */
if ( keymap ) return ;
keymap = WM_modalkeymap_add ( keyconf , " View3D Gesture Circle " , modal_items ) ;
/* items for modal map */
WM_modalkeymap_add_item ( keymap , ESCKEY , KM_PRESS , KM_ANY , 0 , GESTURE_MODAL_CANCEL ) ;
WM_modalkeymap_add_item ( keymap , RIGHTMOUSE , KM_ANY , KM_ANY , 0 , GESTURE_MODAL_CANCEL ) ;
WM_modalkeymap_add_item ( keymap , RETKEY , KM_PRESS , KM_ANY , 0 , GESTURE_MODAL_CONFIRM ) ;
2009-11-06 12:43:20 +00:00
WM_modalkeymap_add_item ( keymap , PADENTER , KM_PRESS , 0 , 0 , GESTURE_MODAL_CONFIRM ) ;
2009-11-05 17:32:06 +00:00
2009-11-06 12:43:20 +00:00
WM_modalkeymap_add_item ( keymap , LEFTMOUSE , KM_PRESS , 0 , 0 , GESTURE_MODAL_SELECT ) ;
2009-11-05 17:32:06 +00:00
2009-11-06 22:51:08 +00:00
#if 0 // Durien guys like this :S
2009-11-06 12:43:20 +00:00
WM_modalkeymap_add_item ( keymap , LEFTMOUSE , KM_PRESS , KM_SHIFT , 0 , GESTURE_MODAL_DESELECT ) ;
WM_modalkeymap_add_item ( keymap , LEFTMOUSE , KM_RELEASE , KM_SHIFT , 0 , GESTURE_MODAL_NOP ) ;
2009-11-06 22:51:08 +00:00
# else
WM_modalkeymap_add_item ( keymap , MIDDLEMOUSE , KM_PRESS , 0 , 0 , GESTURE_MODAL_DESELECT ) ; // defailt 2.4x
WM_modalkeymap_add_item ( keymap , MIDDLEMOUSE , KM_RELEASE , 0 , 0 , GESTURE_MODAL_NOP ) ; // defailt 2.4x
# endif
2009-11-06 12:43:20 +00:00
2009-11-06 22:51:08 +00:00
WM_modalkeymap_add_item ( keymap , LEFTMOUSE , KM_RELEASE , 0 , 0 , GESTURE_MODAL_NOP ) ;
2009-11-06 12:43:20 +00:00
2009-11-06 22:51:08 +00:00
WM_modalkeymap_add_item ( keymap , WHEELUPMOUSE , KM_PRESS , 0 , 0 , GESTURE_MODAL_CIRCLE_SUB ) ;
WM_modalkeymap_add_item ( keymap , PADMINUS , KM_PRESS , 0 , 0 , GESTURE_MODAL_CIRCLE_SUB ) ;
WM_modalkeymap_add_item ( keymap , WHEELDOWNMOUSE , KM_PRESS , 0 , 0 , GESTURE_MODAL_CIRCLE_ADD ) ;
WM_modalkeymap_add_item ( keymap , PADPLUSKEY , KM_PRESS , 0 , 0 , GESTURE_MODAL_CIRCLE_ADD ) ;
2009-11-05 17:32:06 +00:00
/* assign map to operators */
WM_modalkeymap_assign ( keymap , " VIEW3D_OT_select_circle " ) ;
WM_modalkeymap_assign ( keymap , " UV_OT_circle_select " ) ;
}
2010-04-04 00:21:37 +00:00
/* straight line modal operators */
static void gesture_straightline_modal_keymap ( wmKeyConfig * keyconf )
{
static EnumPropertyItem modal_items [ ] = {
{ GESTURE_MODAL_CANCEL , " CANCEL " , 0 , " Cancel " , " " } ,
{ GESTURE_MODAL_SELECT , " SELECT " , 0 , " Select " , " " } ,
{ GESTURE_MODAL_BEGIN , " BEGIN " , 0 , " Begin " , " " } ,
{ 0 , NULL , 0 , NULL , NULL } } ;
wmKeyMap * keymap = WM_modalkeymap_get ( keyconf , " Gesture Straight Line " ) ;
/* this function is called for each spacetype, only needs to add map once */
if ( keymap ) return ;
keymap = WM_modalkeymap_add ( keyconf , " Gesture Straight Line " , modal_items ) ;
/* items for modal map */
WM_modalkeymap_add_item ( keymap , ESCKEY , KM_PRESS , KM_ANY , 0 , GESTURE_MODAL_CANCEL ) ;
WM_modalkeymap_add_item ( keymap , RIGHTMOUSE , KM_ANY , KM_ANY , 0 , GESTURE_MODAL_CANCEL ) ;
WM_modalkeymap_add_item ( keymap , LEFTMOUSE , KM_PRESS , 0 , 0 , GESTURE_MODAL_BEGIN ) ;
WM_modalkeymap_add_item ( keymap , LEFTMOUSE , KM_RELEASE , 0 , 0 , GESTURE_MODAL_SELECT ) ;
/* assign map to operators */
WM_modalkeymap_assign ( keymap , " IMAGE_OT_sample_line " ) ;
}
2010-04-02 03:52:44 +00:00
/* borderselect-like modal operators */
2009-11-06 22:51:08 +00:00
static void gesture_border_modal_keymap ( wmKeyConfig * keyconf )
{
static EnumPropertyItem modal_items [ ] = {
{ GESTURE_MODAL_CANCEL , " CANCEL " , 0 , " Cancel " , " " } ,
{ GESTURE_MODAL_SELECT , " SELECT " , 0 , " Select " , " " } ,
{ GESTURE_MODAL_DESELECT , " DESELECT " , 0 , " DeSelect " , " " } ,
2010-04-04 00:21:37 +00:00
{ GESTURE_MODAL_BEGIN , " BEGIN " , 0 , " Begin " , " " } ,
2009-11-06 22:51:08 +00:00
{ 0 , NULL , 0 , NULL , NULL } } ;
2009-11-28 02:53:11 +00:00
wmKeyMap * keymap = WM_modalkeymap_get ( keyconf , " Gesture Border " ) ;
2009-11-06 22:51:08 +00:00
/* this function is called for each spacetype, only needs to add map once */
if ( keymap ) return ;
2009-11-28 02:53:11 +00:00
keymap = WM_modalkeymap_add ( keyconf , " Gesture Border " , modal_items ) ;
2009-11-06 22:51:08 +00:00
/* items for modal map */
WM_modalkeymap_add_item ( keymap , ESCKEY , KM_PRESS , KM_ANY , 0 , GESTURE_MODAL_CANCEL ) ;
WM_modalkeymap_add_item ( keymap , RIGHTMOUSE , KM_ANY , KM_ANY , 0 , GESTURE_MODAL_CANCEL ) ;
2010-04-04 00:21:37 +00:00
WM_modalkeymap_add_item ( keymap , LEFTMOUSE , KM_PRESS , 0 , 0 , GESTURE_MODAL_BEGIN ) ;
2010-04-15 01:35:32 +00:00
WM_modalkeymap_add_item ( keymap , LEFTMOUSE , KM_RELEASE , KM_ANY , 0 , GESTURE_MODAL_SELECT ) ;
2009-11-06 22:51:08 +00:00
#if 0 // Durian guys like this
2010-04-04 00:21:37 +00:00
WM_modalkeymap_add_item ( keymap , LEFTMOUSE , KM_PRESS , KM_SHIFT , 0 , GESTURE_MODAL_BEGIN ) ;
2009-11-06 22:51:08 +00:00
WM_modalkeymap_add_item ( keymap , LEFTMOUSE , KM_RELEASE , KM_SHIFT , 0 , GESTURE_MODAL_DESELECT ) ;
# else
2010-04-04 00:21:37 +00:00
WM_modalkeymap_add_item ( keymap , MIDDLEMOUSE , KM_PRESS , 0 , 0 , GESTURE_MODAL_BEGIN ) ;
2009-11-06 22:51:08 +00:00
WM_modalkeymap_add_item ( keymap , MIDDLEMOUSE , KM_RELEASE , 0 , 0 , GESTURE_MODAL_DESELECT ) ;
# endif
/* assign map to operators */
2009-11-28 14:37:21 +00:00
WM_modalkeymap_assign ( keymap , " ACTION_OT_select_border " ) ;
2009-11-06 22:51:08 +00:00
WM_modalkeymap_assign ( keymap , " ANIM_OT_channels_select_border " ) ;
2009-11-17 10:12:35 +00:00
WM_modalkeymap_assign ( keymap , " ANIM_OT_previewrange_set " ) ;
2010-11-11 13:36:57 +00:00
WM_modalkeymap_assign ( keymap , " INFO_OT_select_border " ) ;
2009-11-06 22:51:08 +00:00
WM_modalkeymap_assign ( keymap , " FILE_OT_select_border " ) ;
WM_modalkeymap_assign ( keymap , " GRAPH_OT_select_border " ) ;
2009-11-19 10:48:59 +00:00
WM_modalkeymap_assign ( keymap , " MARKER_OT_select_border " ) ;
2009-11-06 22:51:08 +00:00
WM_modalkeymap_assign ( keymap , " NLA_OT_select_border " ) ;
WM_modalkeymap_assign ( keymap , " NODE_OT_select_border " ) ;
2009-11-19 10:48:59 +00:00
// WM_modalkeymap_assign(keymap, "SCREEN_OT_border_select"); // template
2009-11-06 22:51:08 +00:00
WM_modalkeymap_assign ( keymap , " SEQUENCER_OT_select_border " ) ;
2010-07-08 10:03:29 +00:00
WM_modalkeymap_assign ( keymap , " SEQUENCER_OT_view_ghost_border " ) ;
2009-11-19 10:48:59 +00:00
WM_modalkeymap_assign ( keymap , " UV_OT_select_border " ) ;
2009-11-28 02:53:11 +00:00
WM_modalkeymap_assign ( keymap , " VIEW2D_OT_zoom_border " ) ;
2009-11-19 10:48:59 +00:00
WM_modalkeymap_assign ( keymap , " VIEW3D_OT_clip_border " ) ;
WM_modalkeymap_assign ( keymap , " VIEW3D_OT_render_border " ) ;
2009-11-06 22:51:08 +00:00
WM_modalkeymap_assign ( keymap , " VIEW3D_OT_select_border " ) ;
2009-11-28 02:53:11 +00:00
WM_modalkeymap_assign ( keymap , " VIEW3D_OT_zoom_border " ) ; // XXX TODO: zoom border should perhaps map rightmouse to zoom out instead of in+cancel
2009-11-06 22:51:08 +00:00
}
2010-04-02 03:52:44 +00:00
/* zoom to border modal operators */
static void gesture_zoom_border_modal_keymap ( wmKeyConfig * keyconf )
{
static EnumPropertyItem modal_items [ ] = {
{ GESTURE_MODAL_CANCEL , " CANCEL " , 0 , " Cancel " , " " } ,
{ GESTURE_MODAL_IN , " IN " , 0 , " In " , " " } ,
{ GESTURE_MODAL_OUT , " OUT " , 0 , " Out " , " " } ,
2010-04-04 00:21:37 +00:00
{ GESTURE_MODAL_BEGIN , " BEGIN " , 0 , " Begin " , " " } ,
2010-04-02 03:52:44 +00:00
{ 0 , NULL , 0 , NULL , NULL } } ;
wmKeyMap * keymap = WM_modalkeymap_get ( keyconf , " Gesture Zoom Border " ) ;
/* this function is called for each spacetype, only needs to add map once */
if ( keymap ) return ;
keymap = WM_modalkeymap_add ( keyconf , " Gesture Zoom Border " , modal_items ) ;
/* items for modal map */
WM_modalkeymap_add_item ( keymap , ESCKEY , KM_PRESS , KM_ANY , 0 , GESTURE_MODAL_CANCEL ) ;
WM_modalkeymap_add_item ( keymap , RIGHTMOUSE , KM_ANY , KM_ANY , 0 , GESTURE_MODAL_CANCEL ) ;
2010-04-04 00:21:37 +00:00
WM_modalkeymap_add_item ( keymap , LEFTMOUSE , KM_PRESS , 0 , 0 , GESTURE_MODAL_BEGIN ) ;
2010-04-02 03:52:44 +00:00
WM_modalkeymap_add_item ( keymap , LEFTMOUSE , KM_RELEASE , 0 , 0 , GESTURE_MODAL_IN ) ;
2010-04-04 00:21:37 +00:00
WM_modalkeymap_add_item ( keymap , MIDDLEMOUSE , KM_PRESS , 0 , 0 , GESTURE_MODAL_BEGIN ) ;
2010-04-02 03:52:44 +00:00
WM_modalkeymap_add_item ( keymap , MIDDLEMOUSE , KM_RELEASE , 0 , 0 , GESTURE_MODAL_OUT ) ;
/* assign map to operators */
WM_modalkeymap_assign ( keymap , " VIEW2D_OT_zoom_border " ) ;
WM_modalkeymap_assign ( keymap , " VIEW3D_OT_zoom_border " ) ;
}
2008-11-19 16:28:11 +00:00
/* default keymap for windows and screens, only call once per WM */
Key Configuration
Keymaps are now saveable and configurable from the user preferences, note
that editing one item in a keymap means the whole keymap is now defined by
the user and will not be updated by Blender, an option for syncing might be
added later. The outliner interface is still there, but I will probably
remove it.
There's actually 3 levels now:
* Default builtin key configuration.
* Key configuration loaded from .py file, for configs like Blender 2.4x
or other 3D applications.
* Keymaps edited by the user and saved in .B.blend. These can be saved
to .py files as well to make creating distributable configurations
easier.
Also, user preferences sections were reorganized a bit, now there is:
Interface, Editing, Input, Files and System.
Implementation notes:
* wmKeyConfig was added which represents a key configuration containing
keymaps.
* wmKeymapItem was renamed to wmKeyMapItem for consistency with wmKeyMap.
* Modal maps are not wrapped yet.
* User preferences DNA file reading did not support newdataadr() yet,
added this now for reading keymaps.
* Key configuration related settings are now RNA wrapped.
* is_property_set and is_property_hidden python methods were added.
2009-10-08 18:40:03 +00:00
void wm_window_keymap ( wmKeyConfig * keyconf )
2008-11-19 16:28:11 +00:00
{
Key Configuration
Keymaps are now saveable and configurable from the user preferences, note
that editing one item in a keymap means the whole keymap is now defined by
the user and will not be updated by Blender, an option for syncing might be
added later. The outliner interface is still there, but I will probably
remove it.
There's actually 3 levels now:
* Default builtin key configuration.
* Key configuration loaded from .py file, for configs like Blender 2.4x
or other 3D applications.
* Keymaps edited by the user and saved in .B.blend. These can be saved
to .py files as well to make creating distributable configurations
easier.
Also, user preferences sections were reorganized a bit, now there is:
Interface, Editing, Input, Files and System.
Implementation notes:
* wmKeyConfig was added which represents a key configuration containing
keymaps.
* wmKeymapItem was renamed to wmKeyMapItem for consistency with wmKeyMap.
* Modal maps are not wrapped yet.
* User preferences DNA file reading did not support newdataadr() yet,
added this now for reading keymaps.
* Key configuration related settings are now RNA wrapped.
* is_property_set and is_property_hidden python methods were added.
2009-10-08 18:40:03 +00:00
wmKeyMap * keymap = WM_keymap_find ( keyconf , " Window " , 0 , 0 ) ;
2009-12-24 09:36:15 +00:00
wmKeyMapItem * kmi ;
2008-12-08 15:02:57 +00:00
2008-11-19 16:28:11 +00:00
/* note, this doesn't replace existing keymap items */
2009-02-06 01:39:55 +00:00
WM_keymap_verify_item ( keymap , " WM_OT_window_duplicate " , WKEY , KM_PRESS , KM_CTRL | KM_ALT , 0 ) ;
2009-09-09 19:43:05 +00:00
# ifdef __APPLE__
WM_keymap_add_item ( keymap , " WM_OT_read_homefile " , NKEY , KM_PRESS , KM_OSKEY , 0 ) ;
2009-12-28 10:44:02 +00:00
WM_keymap_add_menu ( keymap , " INFO_MT_file_open_recent " , OKEY , KM_PRESS , KM_SHIFT | KM_OSKEY , 0 ) ;
2009-09-09 19:43:05 +00:00
WM_keymap_add_item ( keymap , " WM_OT_open_mainfile " , OKEY , KM_PRESS , KM_OSKEY , 0 ) ;
WM_keymap_add_item ( keymap , " WM_OT_save_mainfile " , SKEY , KM_PRESS , KM_OSKEY , 0 ) ;
WM_keymap_add_item ( keymap , " WM_OT_save_as_mainfile " , SKEY , KM_PRESS , KM_SHIFT | KM_OSKEY , 0 ) ;
2010-10-11 22:05:45 +00:00
WM_keymap_add_item ( keymap , " WM_OT_quit_blender " , QKEY , KM_PRESS , KM_OSKEY , 0 ) ;
2009-09-09 19:43:05 +00:00
# endif
2009-09-09 15:45:12 +00:00
WM_keymap_add_item ( keymap , " WM_OT_read_homefile " , NKEY , KM_PRESS , KM_CTRL , 0 ) ;
WM_keymap_add_item ( keymap , " WM_OT_save_homefile " , UKEY , KM_PRESS , KM_CTRL , 0 ) ;
2009-12-28 10:44:02 +00:00
WM_keymap_add_menu ( keymap , " INFO_MT_file_open_recent " , OKEY , KM_PRESS , KM_SHIFT | KM_CTRL , 0 ) ;
2009-09-09 15:45:12 +00:00
WM_keymap_add_item ( keymap , " WM_OT_open_mainfile " , OKEY , KM_PRESS , KM_CTRL , 0 ) ;
2009-10-19 17:10:16 +00:00
WM_keymap_add_item ( keymap , " WM_OT_open_mainfile " , F1KEY , KM_PRESS , 0 , 0 ) ;
2009-09-14 12:30:49 +00:00
WM_keymap_add_item ( keymap , " WM_OT_link_append " , OKEY , KM_PRESS , KM_CTRL | KM_ALT , 0 ) ;
2009-12-24 09:36:15 +00:00
kmi = WM_keymap_add_item ( keymap , " WM_OT_link_append " , F1KEY , KM_PRESS , KM_SHIFT , 0 ) ;
RNA_boolean_set ( kmi - > ptr , " link " , FALSE ) ;
2010-04-06 01:16:39 +00:00
RNA_boolean_set ( kmi - > ptr , " instance_groups " , FALSE ) ;
2009-11-03 11:00:10 +00:00
2009-09-09 15:45:12 +00:00
WM_keymap_add_item ( keymap , " WM_OT_save_mainfile " , SKEY , KM_PRESS , KM_CTRL , 0 ) ;
2009-10-19 17:10:16 +00:00
WM_keymap_add_item ( keymap , " WM_OT_save_mainfile " , WKEY , KM_PRESS , KM_CTRL , 0 ) ;
2009-09-09 15:45:12 +00:00
WM_keymap_add_item ( keymap , " WM_OT_save_as_mainfile " , SKEY , KM_PRESS , KM_SHIFT | KM_CTRL , 0 ) ;
2009-10-19 17:10:16 +00:00
WM_keymap_add_item ( keymap , " WM_OT_save_as_mainfile " , F2KEY , KM_PRESS , 0 , 0 ) ;
2010-07-20 18:06:46 +00:00
kmi = WM_keymap_add_item ( keymap , " WM_OT_save_as_mainfile " , SKEY , KM_PRESS , KM_ALT | KM_CTRL , 0 ) ;
RNA_boolean_set ( kmi - > ptr , " copy " , 1 ) ;
2009-09-09 19:43:05 +00:00
2009-10-13 17:50:14 +00:00
WM_keymap_verify_item ( keymap , " WM_OT_window_fullscreen_toggle " , F11KEY , KM_PRESS , KM_ALT , 0 ) ;
2010-10-11 22:05:45 +00:00
WM_keymap_add_item ( keymap , " WM_OT_quit_blender " , QKEY , KM_PRESS , KM_CTRL , 0 ) ;
2009-01-28 18:26:47 +00:00
2009-05-22 15:02:32 +00:00
/* debug/testing */
2009-09-22 09:12:39 +00:00
WM_keymap_verify_item ( keymap , " WM_OT_redraw_timer " , TKEY , KM_PRESS , KM_ALT | KM_CTRL , 0 ) ;
2009-05-22 15:02:32 +00:00
WM_keymap_verify_item ( keymap , " WM_OT_debug_menu " , DKEY , KM_PRESS , KM_ALT | KM_CTRL , 0 ) ;
2009-08-22 00:19:24 +00:00
WM_keymap_verify_item ( keymap , " WM_OT_search_menu " , SPACEKEY , KM_PRESS , 0 , 0 ) ;
2009-05-22 15:02:32 +00:00
2009-10-13 17:50:14 +00:00
/* Space switching */
2009-12-24 09:36:15 +00:00
kmi = WM_keymap_add_item ( keymap , " WM_OT_context_set_enum " , F2KEY , KM_PRESS , KM_SHIFT , 0 ) ; /* new in 2.5x, was DXF export */
2010-06-14 03:52:10 +00:00
RNA_string_set ( kmi - > ptr , " data_path " , " area.type " ) ;
2009-12-24 09:36:15 +00:00
RNA_string_set ( kmi - > ptr , " value " , " LOGIC_EDITOR " ) ;
2009-10-13 17:50:14 +00:00
2009-12-24 09:36:15 +00:00
kmi = WM_keymap_add_item ( keymap , " WM_OT_context_set_enum " , F3KEY , KM_PRESS , KM_SHIFT , 0 ) ;
2010-06-14 03:52:10 +00:00
RNA_string_set ( kmi - > ptr , " data_path " , " area.type " ) ;
2009-12-24 09:36:15 +00:00
RNA_string_set ( kmi - > ptr , " value " , " NODE_EDITOR " ) ;
2009-10-13 17:50:14 +00:00
2009-12-24 09:36:15 +00:00
kmi = WM_keymap_add_item ( keymap , " WM_OT_context_set_enum " , F4KEY , KM_PRESS , KM_SHIFT , 0 ) ; /* new in 2.5x, was data browser */
2010-06-14 03:52:10 +00:00
RNA_string_set ( kmi - > ptr , " data_path " , " area.type " ) ;
2009-12-24 09:36:15 +00:00
RNA_string_set ( kmi - > ptr , " value " , " CONSOLE " ) ;
2009-10-13 17:50:14 +00:00
2009-12-24 09:36:15 +00:00
kmi = WM_keymap_add_item ( keymap , " WM_OT_context_set_enum " , F5KEY , KM_PRESS , KM_SHIFT , 0 ) ;
2010-06-14 03:52:10 +00:00
RNA_string_set ( kmi - > ptr , " data_path " , " area.type " ) ;
2009-12-24 09:36:15 +00:00
RNA_string_set ( kmi - > ptr , " value " , " VIEW_3D " ) ;
2009-10-13 17:50:14 +00:00
2009-12-24 09:36:15 +00:00
kmi = WM_keymap_add_item ( keymap , " WM_OT_context_set_enum " , F6KEY , KM_PRESS , KM_SHIFT , 0 ) ;
2010-06-14 03:52:10 +00:00
RNA_string_set ( kmi - > ptr , " data_path " , " area.type " ) ;
2009-12-24 09:36:15 +00:00
RNA_string_set ( kmi - > ptr , " value " , " GRAPH_EDITOR " ) ;
2009-10-13 17:50:14 +00:00
2009-12-24 09:36:15 +00:00
kmi = WM_keymap_add_item ( keymap , " WM_OT_context_set_enum " , F7KEY , KM_PRESS , KM_SHIFT , 0 ) ;
2010-06-14 03:52:10 +00:00
RNA_string_set ( kmi - > ptr , " data_path " , " area.type " ) ;
2009-12-24 09:36:15 +00:00
RNA_string_set ( kmi - > ptr , " value " , " PROPERTIES " ) ;
2009-10-13 17:50:14 +00:00
2009-12-24 09:36:15 +00:00
kmi = WM_keymap_add_item ( keymap , " WM_OT_context_set_enum " , F8KEY , KM_PRESS , KM_SHIFT , 0 ) ;
2010-06-14 03:52:10 +00:00
RNA_string_set ( kmi - > ptr , " data_path " , " area.type " ) ;
2009-12-24 09:36:15 +00:00
RNA_string_set ( kmi - > ptr , " value " , " SEQUENCE_EDITOR " ) ;
2009-10-13 17:50:14 +00:00
2009-12-24 09:36:15 +00:00
kmi = WM_keymap_add_item ( keymap , " WM_OT_context_set_enum " , F9KEY , KM_PRESS , KM_SHIFT , 0 ) ;
2010-06-14 03:52:10 +00:00
RNA_string_set ( kmi - > ptr , " data_path " , " area.type " ) ;
2009-12-24 09:36:15 +00:00
RNA_string_set ( kmi - > ptr , " value " , " OUTLINER " ) ;
2009-10-13 17:50:14 +00:00
2009-12-24 09:36:15 +00:00
kmi = WM_keymap_add_item ( keymap , " WM_OT_context_set_enum " , F10KEY , KM_PRESS , KM_SHIFT , 0 ) ;
2010-06-14 03:52:10 +00:00
RNA_string_set ( kmi - > ptr , " data_path " , " area.type " ) ;
2009-12-24 09:36:15 +00:00
RNA_string_set ( kmi - > ptr , " value " , " IMAGE_EDITOR " ) ;
2009-10-13 17:50:14 +00:00
2009-12-24 09:36:15 +00:00
kmi = WM_keymap_add_item ( keymap , " WM_OT_context_set_enum " , F11KEY , KM_PRESS , KM_SHIFT , 0 ) ;
2010-06-14 03:52:10 +00:00
RNA_string_set ( kmi - > ptr , " data_path " , " area.type " ) ;
2009-12-24 09:36:15 +00:00
RNA_string_set ( kmi - > ptr , " value " , " TEXT_EDITOR " ) ;
2009-10-13 17:50:14 +00:00
2009-12-24 09:36:15 +00:00
kmi = WM_keymap_add_item ( keymap , " WM_OT_context_set_enum " , F12KEY , KM_PRESS , KM_SHIFT , 0 ) ;
2010-06-14 03:52:10 +00:00
RNA_string_set ( kmi - > ptr , " data_path " , " area.type " ) ;
2009-12-24 09:36:15 +00:00
RNA_string_set ( kmi - > ptr , " value " , " DOPESHEET_EDITOR " ) ;
2009-11-05 17:32:06 +00:00
gesture_circle_modal_keymap ( keyconf ) ;
2009-11-06 22:51:08 +00:00
gesture_border_modal_keymap ( keyconf ) ;
2010-04-02 03:52:44 +00:00
gesture_zoom_border_modal_keymap ( keyconf ) ;
2010-04-04 00:21:37 +00:00
gesture_straightline_modal_keymap ( keyconf ) ;
2.5 Branch
==========
* Changed wmOperatorType, removing init/exit callbacks and adding cancel
callback, removed default storage in favor of properties. Defined return
values for exec/invoke/modal/cancel.
* Don't allocate operator on the stack, and removed operator copy for
handlers. Now it frees based on return values from callbacks, and just
keeps a wmOperator on the heap. Also it now registers after the operator
is fully finished, to get the correct final properties.
* Changed OP_get_* functions to return 1 if the property is found and 0
otherwise, gives more readable code in my opinion. Added OP_verify_*
functions to quickly check if the property is available and set if it's
not, that's common for exec/invoke.
* Removed WM_operatortypelist_append in favor of WM_operatortype_append
which takes a function pointer instead of a list, avoids macro's and
duplicating code.
* Fix a crash where the handler would still be used while it was freed by
the operator.
* Spacetypes now have operatortypes() and keymap() callbacks to abstract
them a bit more.
* Renamed C->curarea to C->area for consistency. Removed View3D/View2D/
SpaceIpo from bContext, seems bad to keep these.
* Set context variables like window/screen/area/region to NULL again when
leaving that context, instead of leaving the pointers there.
* Added if(G.f & G_DEBUG) for many of the prints, makes output a bit
cleaner and easier to debug.
* Fixed priority of the editors/interface module in scons, would otherwise
give link errors.
* Added start of generic view2d api.
* Added space_time with some basic drawing and a single operator to change
the frame.
2008-06-11 10:10:31 +00:00
}
2009-11-04 10:25:57 +00:00
/* Generic itemf's for operators that take library args */
2010-12-03 12:30:59 +00:00
static EnumPropertyItem * rna_id_itemf ( bContext * UNUSED ( C ) , PointerRNA * UNUSED ( ptr ) , int * do_free , ID * id , int local )
2009-11-04 10:25:57 +00:00
{
2010-11-23 08:44:21 +00:00
EnumPropertyItem item_tmp = { 0 } , * item = NULL ;
2009-11-04 10:25:57 +00:00
int totitem = 0 ;
int i = 0 ;
for ( ; id ; id = id - > next ) {
2010-05-05 15:41:38 +00:00
if ( local = = FALSE | | id - > lib = = NULL ) {
item_tmp . identifier = item_tmp . name = id - > name + 2 ;
item_tmp . value = i + + ;
RNA_enum_item_add ( & item , & totitem , & item_tmp ) ;
}
2009-11-04 10:25:57 +00:00
}
RNA_enum_item_end ( & item , & totitem ) ;
2010-12-03 12:30:59 +00:00
* do_free = 1 ;
2009-11-04 10:25:57 +00:00
return item ;
}
2010-02-23 19:32:32 +00:00
/* can add more as needed */
2010-12-03 12:30:59 +00:00
EnumPropertyItem * RNA_action_itemf ( bContext * C , PointerRNA * ptr , int * do_free )
2010-02-23 19:32:32 +00:00
{
2010-12-03 12:30:59 +00:00
return rna_id_itemf ( C , ptr , do_free , C ? ( ID * ) CTX_data_main ( C ) - > action . first : NULL , FALSE ) ;
2010-05-05 15:41:38 +00:00
}
2010-12-03 12:30:59 +00:00
EnumPropertyItem * RNA_action_local_itemf ( bContext * C , PointerRNA * ptr , int * do_free )
2010-05-05 15:41:38 +00:00
{
2010-12-03 12:30:59 +00:00
return rna_id_itemf ( C , ptr , do_free , C ? ( ID * ) CTX_data_main ( C ) - > action . first : NULL , TRUE ) ;
2010-02-23 19:32:32 +00:00
}
2010-05-05 15:41:38 +00:00
2010-12-03 12:30:59 +00:00
EnumPropertyItem * RNA_group_itemf ( bContext * C , PointerRNA * ptr , int * do_free )
2009-11-04 10:25:57 +00:00
{
2010-12-03 12:30:59 +00:00
return rna_id_itemf ( C , ptr , do_free , C ? ( ID * ) CTX_data_main ( C ) - > group . first : NULL , FALSE ) ;
2010-05-05 15:41:38 +00:00
}
2010-12-03 12:30:59 +00:00
EnumPropertyItem * RNA_group_local_itemf ( bContext * C , PointerRNA * ptr , int * do_free )
2010-05-05 15:41:38 +00:00
{
2010-12-03 12:30:59 +00:00
return rna_id_itemf ( C , ptr , do_free , C ? ( ID * ) CTX_data_main ( C ) - > group . first : NULL , TRUE ) ;
2009-11-04 10:25:57 +00:00
}
2010-05-05 15:41:38 +00:00
2010-12-03 12:30:59 +00:00
EnumPropertyItem * RNA_image_itemf ( bContext * C , PointerRNA * ptr , int * do_free )
2010-03-05 18:19:32 +00:00
{
2010-12-03 12:30:59 +00:00
return rna_id_itemf ( C , ptr , do_free , C ? ( ID * ) CTX_data_main ( C ) - > image . first : NULL , FALSE ) ;
2010-05-05 15:41:38 +00:00
}
2010-12-03 12:30:59 +00:00
EnumPropertyItem * RNA_image_local_itemf ( bContext * C , PointerRNA * ptr , int * do_free )
2010-05-05 15:41:38 +00:00
{
2010-12-03 12:30:59 +00:00
return rna_id_itemf ( C , ptr , do_free , C ? ( ID * ) CTX_data_main ( C ) - > image . first : NULL , TRUE ) ;
2010-03-05 18:19:32 +00:00
}
2010-05-05 15:41:38 +00:00
2010-12-03 12:30:59 +00:00
EnumPropertyItem * RNA_scene_itemf ( bContext * C , PointerRNA * ptr , int * do_free )
2009-11-04 10:25:57 +00:00
{
2010-12-03 12:30:59 +00:00
return rna_id_itemf ( C , ptr , do_free , C ? ( ID * ) CTX_data_main ( C ) - > scene . first : NULL , FALSE ) ;
2010-05-05 15:41:38 +00:00
}
2010-12-03 12:30:59 +00:00
EnumPropertyItem * RNA_scene_local_itemf ( bContext * C , PointerRNA * ptr , int * do_free )
2010-05-05 15:41:38 +00:00
{
2010-12-03 12:30:59 +00:00
return rna_id_itemf ( C , ptr , do_free , C ? ( ID * ) CTX_data_main ( C ) - > scene . first : NULL , TRUE ) ;
2009-11-04 10:25:57 +00:00
}