2007-12-24 18:27:28 +00:00
/**
* $ Id :
*
* * * * * * BEGIN GPL LICENSE BLOCK * * * * *
*
* This program is free software ; you can redistribute it and / or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation ; either version 2
* of the License , or ( at your option ) any later version .
*
* This program is distributed in the hope that it will be useful ,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
* GNU General Public License for more details .
*
* You should have received a copy of the GNU General Public License
* along with this program ; if not , write to the Free Software Foundation ,
* Inc . , 59 Temple Place - Suite 330 , Boston , MA 02111 - 1307 , USA .
*
* The Original Code is Copyright ( C ) 2007 Blender Foundation .
* All rights reserved .
*
*
* Contributor ( s ) : Blender Foundation
*
* * * * * * END GPL LICENSE BLOCK * * * * *
*/
2009-01-24 16:59:55 +00:00
# include <float.h>
2009-01-24 23:37:34 +00:00
# define _USE_MATH_DEFINES
2009-01-24 16:59:55 +00:00
# include <math.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>
2007-12-24 18:27:28 +00:00
2008-01-14 19:44:20 +00:00
# include "DNA_ID.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"
# include "MEM_guardedalloc.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 */
2007-12-24 18:27:28 +00:00
# include "BKE_blender.h"
2008-12-18 02:56:48 +00:00
# include "BKE_context.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-05-19 15:37:50 +00:00
# include "BKE_scene.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_utildefines.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"
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-05-19 12:54:54 +00:00
# include "wm_subwindow.h"
# include "wm_window.h"
2007-12-24 18:27:28 +00:00
2009-01-06 14:42:54 +00:00
2008-12-16 13:19:02 +00:00
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 ) ;
2007-12-24 18:27:28 +00:00
for ( ot = global_ops . first ; ot ; ot = ot - > next ) {
2009-07-17 12:26:40 +00:00
if ( strncmp ( ot - > idname , idname_bl , OP_MAX_TYPENAME ) = = 0 )
2007-12-24 18:27:28 +00:00
return ot ;
}
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 ;
}
2009-07-08 21:31:28 +00:00
wmOperatorType * WM_operatortype_exists ( const char * idname )
{
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 ) ;
2009-07-08 21:31:28 +00:00
for ( ot = global_ops . first ; ot ; ot = ot - > next ) {
2009-07-17 12:26:40 +00:00
if ( strncmp ( ot - > idname , idname_bl , OP_MAX_TYPENAME ) = = 0 )
2009-07-08 21:31:28 +00:00
return ot ;
}
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 ) ;
}
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 ) ;
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
{
char * sep = strstr ( from , " . " ) ;
if ( sep ) {
int i , ofs = ( sep - from ) ;
for ( i = 0 ; i < ofs ; i + + )
to [ i ] = toupper ( from [ i ] ) ;
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 ) ;
}
}
2008-12-26 03:56:52 +00:00
/* print a string representation of the operator, with the args that it runs
* so python can run it again */
char * WM_operator_pystring ( wmOperator * op )
{
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 ;
int first_iter = 1 ;
2009-07-17 12:26:40 +00:00
WM_operator_py_idname ( idname_py , op - > idname ) ;
BLI_dynstr_appendf ( dynstr , " bpy.ops.%s( " , idname_py ) ;
2008-12-26 03:56:52 +00:00
2009-04-19 13:37:59 +00:00
iterprop = RNA_struct_iterator_property ( op - > ptr - > type ) ;
2008-12-26 03:56:52 +00:00
2009-06-24 21:27:10 +00:00
RNA_PROP_BEGIN ( op - > ptr , propptr , iterprop ) {
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 ;
buf = RNA_property_as_string ( op - > ptr , prop ) ;
BLI_dynstr_appendf ( dynstr , first_iter ? " %s=%s " : " , %s=%s " , arg_name , buf ) ;
MEM_freeN ( buf ) ;
first_iter = 0 ;
}
2009-06-24 21:27:10 +00:00
RNA_PROP_END ;
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-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-01-08 15:33:34 +00:00
RNA_pointer_create ( NULL , ot - > srna , NULL , ptr ) ;
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
}
void WM_operator_properties_free ( PointerRNA * ptr )
{
IDProperty * properties = ptr - > data ;
if ( properties ) {
IDP_FreeProperty ( properties ) ;
MEM_freeN ( properties ) ;
}
}
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" */
/* only weak thing is the fixed property name... */
int WM_menu_invoke ( bContext * C , wmOperator * op , wmEvent * event )
2008-12-17 15:38:40 +00:00
{
2008-12-24 18:06:51 +00:00
PropertyRNA * prop = RNA_struct_find_property ( op - > ptr , " type " ) ;
2009-04-22 18:39:44 +00:00
uiPopupMenu * pup ;
uiLayout * layout ;
2009-02-01 02:37:12 +00:00
if ( prop = = NULL ) {
printf ( " WM_menu_invoke: %s has no \" type \" enum property \n " , op - > type - > idname ) ;
}
2009-04-19 13:37:59 +00:00
else if ( RNA_property_type ( prop ) ! = PROP_ENUM ) {
2009-02-01 02:37:12 +00:00
printf ( " WM_menu_invoke: %s \" type \" is not an enum property \n " , op - > type - > idname ) ;
}
else {
UI: Layout Engine
* Buttons are now created first, and after that the layout is computed.
This means the layout engine now works at button level, and makes it
easier to write templates. Otherwise you had to store all info and
create the buttons later.
* Added interface_templates.c as a separate file to put templates in.
These can contain regular buttons, and can be put in a Free layout,
which means you can specify manual coordinates, but still get nested
correct inside other layouts.
* API was changed to allow better nesting. Previously items were added
in the last added layout specifier, i.e. one level up in the layout
hierarchy. This doesn't work well in always, so now when creating things
like rows or columns it always returns a layout which you have to add
the items in. All py scripts were updated to follow this.
* Computing the layout now goes in two passes, first estimating the
required width/height of all nested layouts, and then in the second
pass using the results of that to decide on the actual locations.
* Enum and array buttons now follow the direction of the layout, i.e.
they are vertical or horizontal depending if they are in a column or row.
* Color properties now get a color picker, and only get the additional
RGB sliders with Expand=True.
* File/directory string properties now get a button next to them for
opening the file browse, though this is not implemented yet.
* Layout items can now be aligned, set align=True when creating a column,
row, etc.
* Buttons now get a minimum width of one icon (avoids squashing icon
buttons).
* Moved some more space variables into Style.
2009-05-15 11:19:59 +00:00
pup = uiPupMenuBegin ( C , op - > type - > name , 0 ) ;
2009-04-22 18:39:44 +00:00
layout = uiPupMenuLayout ( pup ) ;
uiItemsEnumO ( layout , op - > type - > idname , " type " ) ;
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
}
2008-12-24 14:52:17 +00:00
/* op->invoke */
2007-12-24 18:27:28 +00:00
int WM_operator_confirm ( bContext * C , wmOperator * op , wmEvent * event )
{
2009-04-22 18:39:44 +00:00
uiPopupMenu * pup ;
uiLayout * layout ;
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 ) ;
uiItemO ( layout , NULL , 0 , op - > type - > idname ) ;
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-01-26 09:13:15 +00:00
/* op->invoke, opens fileselect if filename property not set, otherwise executes */
int WM_operator_filesel ( bContext * C , wmOperator * op , wmEvent * event )
{
if ( RNA_property_is_set ( op - > ptr , " filename " ) ) {
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 ;
}
}
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
/* op->invoke */
static void redo_cb ( bContext * C , void * arg_op , void * arg2 )
{
wmOperator * lastop = arg_op ;
if ( lastop ) {
ED_undo_pop ( C ) ;
WM_operator_repeat ( C , lastop ) ;
}
}
static uiBlock * wm_block_create_redo ( bContext * C , ARegion * ar , void * arg_op )
{
wmWindowManager * wm = CTX_wm_manager ( C ) ;
wmOperator * op = arg_op ;
PointerRNA ptr ;
uiBlock * block ;
2009-05-19 17:13:33 +00:00
uiLayout * layout ;
uiStyle * style = U . uistyles . first ;
2009-04-01 14:02:06 +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 ) ;
uiBlockSetFlag ( block , UI_BLOCK_KEEP_OPEN | UI_BLOCK_RET_1 ) ;
uiBlockSetFunc ( block , redo_cb , arg_op , NULL ) ;
if ( ! op - > properties ) {
IDPropertyTemplate val = { 0 } ;
op - > properties = IDP_New ( IDP_GROUP , val , " wmOperatorProperties " ) ;
}
RNA_pointer_create ( & wm - > id , op - > type - > srna , op - > properties , & ptr ) ;
2009-05-19 17:13:33 +00:00
layout = uiBlockLayout ( block , UI_LAYOUT_VERTICAL , UI_LAYOUT_PANEL , 0 , 0 , 300 , 20 , style ) ;
2009-06-24 21:27:10 +00:00
uiDefAutoButsRNA ( C , layout , & ptr , 2 ) ;
2009-04-01 14:02:06 +00:00
uiPopupBoundsBlock ( block , 4.0f , 0 , 0 ) ;
uiEndBlock ( C , block ) ;
return block ;
}
2009-07-08 15:34:41 +00:00
int WM_operator_props_popup ( bContext * C , wmOperator * op , wmEvent * event )
2009-04-01 14:02:06 +00:00
{
int retval = OPERATOR_CANCELLED ;
if ( op - > type - > exec )
retval = op - > type - > exec ( C , op ) ;
if ( retval ! = OPERATOR_CANCELLED )
uiPupBlock ( C , wm_block_create_redo , op ) ;
return retval ;
}
int WM_operator_redo_popup ( bContext * C , wmOperator * op )
{
uiPupBlock ( C , wm_block_create_redo , op ) ;
return OPERATOR_CANCELLED ;
}
2009-05-22 15:02:32 +00:00
/* ***************** Debug menu ************************* */
static uiBlock * wm_block_create_menu ( bContext * C , ARegion * ar , void * arg_op )
{
wmOperator * op = arg_op ;
uiBlock * block ;
uiLayout * layout ;
uiStyle * style = U . uistyles . first ;
block = uiBeginBlock ( C , ar , " _popup " , UI_EMBOSS ) ;
uiBlockClearFlag ( block , UI_BLOCK_LOOP ) ;
uiBlockSetFlag ( block , UI_BLOCK_KEEP_OPEN | UI_BLOCK_RET_1 ) ;
layout = uiBlockLayout ( block , UI_LAYOUT_VERTICAL , UI_LAYOUT_PANEL , 0 , 0 , 300 , 20 , style ) ;
2009-06-24 21:27:10 +00:00
uiDefAutoButsRNA ( C , layout , op - > ptr , 2 ) ;
2009-05-22 15:02:32 +00:00
uiPopupBoundsBlock ( block , 4.0f , 0 , 0 ) ;
uiEndBlock ( C , block ) ;
return block ;
}
static int wm_debug_menu_exec ( bContext * C , wmOperator * op )
{
G . rt = RNA_int_get ( op - > ptr , " debugval " ) ;
ED_screen_refresh ( CTX_wm_manager ( C ) , CTX_wm_window ( C ) ) ;
WM_event_add_notifier ( C , NC_WINDOW , NULL ) ;
return OPERATOR_FINISHED ;
}
static int wm_debug_menu_invoke ( bContext * C , wmOperator * op , wmEvent * event )
{
RNA_int_set ( op - > ptr , " debugval " , G . rt ) ;
/* pass on operator, so return modal */
uiPupBlockOperator ( C , wm_block_create_menu , op , WM_OP_EXEC_DEFAULT ) ;
return OPERATOR_RUNNING_MODAL ;
}
static void WM_OT_debug_menu ( wmOperatorType * ot )
{
ot - > name = " Debug Menu " ;
ot - > idname = " WM_OT_debug_menu " ;
ot - > invoke = wm_debug_menu_invoke ;
ot - > exec = wm_debug_menu_exec ;
ot - > poll = WM_operator_winactive ;
RNA_def_int ( ot - > srna , " debugval " , 0 , - 10000 , 10000 , " Debug Value " , " " , INT_MIN , INT_MAX ) ;
}
2009-06-03 18:31:37 +00:00
/* ***************** Search menu ************************* */
static void operator_call_cb ( struct bContext * C , void * arg1 , void * arg2 )
{
wmOperatorType * ot = arg2 ;
if ( ot )
WM_operator_name_call ( C , ot - > idname , WM_OP_INVOKE_DEFAULT , NULL ) ;
}
static void operator_search_cb ( const struct bContext * C , void * arg , char * str , uiSearchItems * items )
{
wmOperatorType * ot = WM_operatortype_first ( ) ;
for ( ; ot ; ot = ot - > next ) {
if ( BLI_strcasestr ( ot - > name , str ) ) {
if ( ot - > poll = = NULL | | ot - > poll ( ( bContext * ) C ) ) {
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 ;
}
}
}
}
static uiBlock * wm_block_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 ;
block = uiBeginBlock ( C , ar , " _popup " , UI_EMBOSS ) ;
uiBlockSetFlag ( block , UI_BLOCK_LOOP | UI_BLOCK_RET_1 ) ;
2009-06-04 15:19:48 +00:00
but = uiDefSearchBut ( block , search , 0 , ICON_VIEWZOOM , 256 , 10 , 10 , 180 , 19 , " " ) ;
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 ) ;
uiPopupBoundsBlock ( block , 6.0f , 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 ;
}
static int wm_search_menu_exec ( bContext * C , wmOperator * op )
{
return OPERATOR_FINISHED ;
}
static int wm_search_menu_invoke ( bContext * C , wmOperator * op , wmEvent * event )
{
uiPupBlock ( C , wm_block_search_menu , op ) ;
return OPERATOR_CANCELLED ;
}
2009-07-28 08:50:11 +00:00
/* op->poll */
int wm_search_menu_poll ( bContext * C )
{
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
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
}
2009-05-22 15:02:32 +00:00
2007-12-24 18:27:28 +00:00
/* ************ window / screen operator definitions ************** */
static void WM_OT_window_duplicate ( wmOperatorType * ot )
{
ot - > name = " Duplicate Window " ;
ot - > idname = " WM_OT_window_duplicate " ;
2008-12-17 15:38:40 +00:00
ot - > invoke = WM_operator_confirm ;
2007-12-24 18:27:28 +00:00
ot - > exec = wm_window_duplicate_op ;
ot - > poll = WM_operator_winactive ;
}
static void WM_OT_save_homefile ( wmOperatorType * ot )
{
ot - > name = " Save User Settings " ;
ot - > idname = " WM_OT_save_homefile " ;
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 " ;
ot - > invoke = WM_operator_confirm ;
ot - > exec = WM_read_homefile ;
ot - > poll = WM_operator_winactive ;
RNA_def_boolean ( ot - > srna , " factory " , 0 , " Factory Settings " , " " ) ;
}
2008-12-19 18:28:37 +00:00
/* ********* recent file *********** */
2008-12-24 14:52:17 +00:00
static int recentfile_exec ( bContext * C , wmOperator * op )
2008-12-19 18:28:37 +00:00
{
2009-07-23 21:35:11 +00:00
int event = RNA_enum_get ( op - > ptr , " file " ) ;
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
// 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?
2008-12-19 18:28:37 +00:00
if ( event > 0 ) {
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
if ( G . sce [ 0 ] & & ( event = = 1 ) ) {
WM_event_add_notifier ( C , NC_WINDOW , NULL ) ;
2008-12-29 13:38:08 +00:00
WM_read_file ( C , G . sce , 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
}
2008-12-19 18:28:37 +00:00
else {
struct RecentFile * recent = BLI_findlink ( & ( G . recent_files ) , event - 2 ) ;
if ( recent ) {
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
WM_event_add_notifier ( C , NC_WINDOW , NULL ) ;
2008-12-29 13:38:08 +00:00
WM_read_file ( C , recent - > filename , op - > reports ) ;
2008-12-19 18:28:37 +00:00
}
}
}
2008-12-24 14:52:17 +00:00
return 0 ;
2008-12-19 18:28:37 +00:00
}
static int wm_recentfile_invoke ( bContext * C , wmOperator * op , wmEvent * event )
{
2009-04-22 18:39:44 +00:00
uiPopupMenu * pup ;
uiLayout * layout ;
2009-02-04 11:52:16 +00:00
UI: Layout Engine
* Buttons are now created first, and after that the layout is computed.
This means the layout engine now works at button level, and makes it
easier to write templates. Otherwise you had to store all info and
create the buttons later.
* Added interface_templates.c as a separate file to put templates in.
These can contain regular buttons, and can be put in a Free layout,
which means you can specify manual coordinates, but still get nested
correct inside other layouts.
* API was changed to allow better nesting. Previously items were added
in the last added layout specifier, i.e. one level up in the layout
hierarchy. This doesn't work well in always, so now when creating things
like rows or columns it always returns a layout which you have to add
the items in. All py scripts were updated to follow this.
* Computing the layout now goes in two passes, first estimating the
required width/height of all nested layouts, and then in the second
pass using the results of that to decide on the actual locations.
* Enum and array buttons now follow the direction of the layout, i.e.
they are vertical or horizontal depending if they are in a column or row.
* Color properties now get a color picker, and only get the additional
RGB sliders with Expand=True.
* File/directory string properties now get a button next to them for
opening the file browse, though this is not implemented yet.
* Layout items can now be aligned, set align=True when creating a column,
row, etc.
* Buttons now get a minimum width of one icon (avoids squashing icon
buttons).
* Moved some more space variables into Style.
2009-05-15 11:19:59 +00:00
pup = uiPupMenuBegin ( C , " Open Recent " , 0 ) ;
2009-04-22 18:39:44 +00:00
layout = uiPupMenuLayout ( pup ) ;
2009-07-23 21:35:11 +00:00
uiItemsEnumO ( layout , op - > type - > idname , " file " ) ;
uiPupMenuEnd ( C , pup ) ;
return OPERATOR_CANCELLED ;
}
static EnumPropertyItem * open_recentfile_itemf ( bContext * C , PointerRNA * ptr , int * free )
{
EnumPropertyItem tmp = { 0 , " " , 0 , " " , " " } ;
EnumPropertyItem * item = NULL ;
struct RecentFile * recent ;
int totitem = 0 , i , ofs = 0 ;
2009-02-04 11:52:16 +00:00
if ( G . sce [ 0 ] ) {
2009-07-23 21:35:11 +00:00
tmp . value = 1 ;
tmp . identifier = G . sce ;
tmp . name = G . sce ;
RNA_enum_item_add ( & item , & totitem , & tmp ) ;
2009-02-04 11:52:16 +00:00
ofs = 1 ;
}
2009-07-23 21:35:11 +00:00
/* dynamically construct enum */
for ( recent = G . recent_files . first , i = 0 ; ( i < U . recent_files ) & & ( recent ) ; recent = recent - > next , i + + ) {
if ( strcmp ( recent - > filename , G . sce ) ) {
tmp . value = i + ofs + 1 ;
tmp . identifier = recent - > filename ;
tmp . name = recent - > filename ;
RNA_enum_item_add ( & item , & totitem , & tmp ) ;
}
}
RNA_enum_item_end ( & item , & totitem ) ;
* free = 1 ;
return item ;
2008-12-19 18:28:37 +00:00
}
static void WM_OT_open_recentfile ( wmOperatorType * ot )
{
2009-07-23 21:35:11 +00:00
PropertyRNA * prop ;
static EnumPropertyItem file_items [ ] = {
{ 0 , NULL , 0 , NULL , NULL } } ;
2008-12-19 18:28:37 +00:00
ot - > name = " Open Recent File " ;
ot - > idname = " WM_OT_open_recentfile " ;
ot - > invoke = wm_recentfile_invoke ;
2008-12-24 14:52:17 +00:00
ot - > exec = recentfile_exec ;
2008-12-19 18:28:37 +00:00
ot - > poll = WM_operator_winactive ;
2009-07-23 21:35:11 +00:00
prop = RNA_def_enum ( ot - > srna , " file " , file_items , 1 , " File " , " " ) ;
RNA_def_enum_funcs ( prop , open_recentfile_itemf ) ;
2008-12-19 18:28:37 +00:00
}
2009-01-06 14:42:54 +00:00
/* ********* main file *********** */
2009-02-13 13:04:48 +00:00
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-02-18 18:08:33 +00:00
static int wm_open_mainfile_invoke ( bContext * C , wmOperator * op , wmEvent * event )
2009-01-06 14:42:54 +00:00
{
2009-02-16 12:14:04 +00:00
RNA_string_set ( op - > ptr , " filename " , G . sce ) ;
2009-07-27 19:06:33 +00:00
RNA_boolean_set ( op - > ptr , " filter_blender " , 1 ) ;
RNA_boolean_set ( op - > ptr , " filter_folder " , 1 ) ;
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
{
char filename [ FILE_MAX ] ;
RNA_string_get ( op - > ptr , " filename " , filename ) ;
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
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
WM_read_file ( C , filename , op - > reports ) ;
2009-01-06 14:42:54 +00:00
return 0 ;
}
static void WM_OT_open_mainfile ( wmOperatorType * ot )
{
2009-07-27 19:06:33 +00:00
PropertyRNA * prop ;
2009-01-06 14:42:54 +00:00
ot - > name = " Open Blender File " ;
ot - > idname = " WM_OT_open_mainfile " ;
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 ;
2009-07-27 19:06:33 +00:00
RNA_def_string_file_path ( ot - > srna , " filename " , " " , FILE_MAX , " Filename " , " File path of blendfile to open. " ) ;
prop = RNA_def_boolean ( ot - > srna , " filter_blender " , 0 , " Filter Blendfiles " , " " ) ;
RNA_def_property_boolean_sdna ( prop , NULL , " filter " , BLENDERFILE ) ;
prop = RNA_def_boolean ( ot - > srna , " filter_folder " , 0 , " Filter Blendfiles " , " " ) ;
RNA_def_property_boolean_sdna ( prop , NULL , " filter " , FOLDERFILE ) ;
2009-07-23 21:35:11 +00:00
}
static int wm_recover_last_session_exec ( bContext * C , wmOperator * op )
{
char scestr [ FILE_MAX ] , filename [ FILE_MAX ] ;
int save_over ;
2009-01-06 14:42:54 +00:00
2009-07-23 21:35:11 +00:00
/* back up some values */
BLI_strncpy ( scestr , G . sce , sizeof ( scestr ) ) ;
save_over = G . save_over ;
// 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 ) ;
/* restore */
G . save_over = save_over ;
BLI_strncpy ( G . sce , scestr , sizeof ( G . sce ) ) ;
return 0 ;
}
static void WM_OT_recover_last_session ( wmOperatorType * ot )
{
ot - > name = " Recover Last Session " ;
ot - > idname = " WM_OT_recover_last_session " ;
ot - > exec = wm_recover_last_session_exec ;
ot - > poll = WM_operator_winactive ;
}
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
}
2009-01-21 19:28:28 +00:00
static int wm_save_as_mainfile_invoke ( bContext * C , wmOperator * op , wmEvent * event )
{
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
2009-02-13 13:04:48 +00:00
BLI_strncpy ( name , G . sce , FILE_MAX ) ;
untitled ( name ) ;
2009-02-16 12:14:04 +00:00
RNA_string_set ( op - > ptr , " filename " , name ) ;
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 )
{
char filename [ FILE_MAX ] ;
2009-07-23 21:35:11 +00:00
int compress ;
save_set_compress ( op ) ;
compress = RNA_boolean_get ( op - > ptr , " compress " ) ;
2009-01-21 19:28:28 +00:00
2009-02-18 13:29:54 +00:00
if ( RNA_property_is_set ( op - > ptr , " filename " ) )
RNA_string_get ( op - > ptr , " filename " , filename ) ;
else {
BLI_strncpy ( filename , G . sce , FILE_MAX ) ;
untitled ( filename ) ;
}
2009-07-23 21:35:11 +00:00
WM_write_file ( C , filename , compress , op - > reports ) ;
2009-01-21 19:28:28 +00:00
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
return 0 ;
}
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 " ;
ot - > invoke = wm_save_as_mainfile_invoke ;
ot - > exec = wm_save_as_mainfile_exec ;
ot - > poll = WM_operator_winactive ;
2009-07-23 21:35:11 +00:00
RNA_def_string_file_path ( ot - > srna , " filename " , " " , 0 , " Filename " , " " ) ;
RNA_def_boolean ( ot - > srna , " compress " , 0 , " Compress " , " Write compressed .blend file. " ) ;
2009-01-21 19:28:28 +00:00
}
2009-02-08 19:15:59 +00:00
/* *************** Save file directly ******** */
static int wm_save_mainfile_invoke ( bContext * C , wmOperator * op , wmEvent * event )
{
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-02-08 19:15:59 +00:00
2009-02-13 13:04:48 +00:00
BLI_strncpy ( name , G . sce , FILE_MAX ) ;
untitled ( name ) ;
RNA_string_set ( op - > ptr , " filename " , name ) ;
uiPupMenuSaveOver ( C , op , name ) ;
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 " ;
ot - > invoke = wm_save_mainfile_invoke ;
ot - > exec = wm_save_as_mainfile_exec ;
ot - > poll = WM_operator_winactive ;
2009-07-23 21:35:11 +00:00
RNA_def_string_file_path ( ot - > srna , " filename " , " " , 0 , " Filename " , " " ) ;
RNA_def_boolean ( ot - > srna , " compress " , 0 , " Compress " , " Write compressed .blend file. " ) ;
2009-02-08 19:15:59 +00:00
}
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 )
{
ot - > name = " Toggle Fullscreen " ;
ot - > idname = " WM_OT_window_fullscreen_toggle " ;
2008-12-17 15:38:40 +00:00
ot - > invoke = WM_operator_confirm ;
2008-01-01 09:07:02 +00:00
ot - > exec = wm_window_fullscreen_toggle_op ;
ot - > poll = WM_operator_winactive ;
}
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 ;
}
2008-01-15 18:54:38 +00:00
static void WM_OT_exit_blender ( wmOperatorType * ot )
{
ot - > name = " Exit Blender " ;
ot - > idname = " WM_OT_exit_blender " ;
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 ;
}
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 ) ,
void ( * draw ) ( bContext * C , int , int , void * customdata ) , 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 )
*/
2009-07-26 12:52:39 +00:00
static int border_apply ( bContext * C , wmOperator * op , int event_type , int event_orig )
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 ;
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 ( rect - > xmin > rect - > xmax )
SWAP ( int , rect - > xmin , rect - > xmax ) ;
if ( rect - > ymin > rect - > ymax )
SWAP ( int , rect - > ymin , rect - > ymax ) ;
2009-01-31 10:00:08 +00:00
if ( rect - > xmin = = rect - > xmax | | rect - > ymin = = rect - > ymax )
return 0 ;
2009-01-31 13:30:56 +00:00
/* operator arguments and storage. */
RNA_int_set ( op - > ptr , " xmin " , rect - > xmin ) ;
RNA_int_set ( op - > ptr , " ymin " , rect - > ymin ) ;
RNA_int_set ( op - > ptr , " xmax " , rect - > xmax ) ;
RNA_int_set ( op - > ptr , " ymax " , rect - > ymax ) ;
2009-07-26 12:52:39 +00:00
/* XXX weak; border should be configured for this without reading event types */
if ( RNA_struct_find_property ( op - > ptr , " event_type " ) ) {
if ( ELEM4 ( event_orig , EVT_TWEAK_L , EVT_TWEAK_R , EVT_TWEAK_A , EVT_TWEAK_S ) )
event_type = LEFTMOUSE ;
RNA_int_set ( op - > ptr , " event_type " , event_type ) ;
}
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
{
2009-07-26 12:52:39 +00:00
if ( WM_key_event_is_tweak ( event - > type ) )
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 */
2008-12-18 02:56:48 +00:00
WM_event_add_modal_handler ( C , & CTX_wm_window ( C ) - > handlers , 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 ;
2008-01-19 17:54:05 +00:00
switch ( event - > type ) {
case MOUSEMOVE :
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-18 02:56:48 +00:00
wm_subwindow_getorigin ( CTX_wm_window ( C ) , gesture - > swinid , & sx , & sy ) ;
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 ) {
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 ;
}
2008-12-27 16:09:56 +00:00
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 ;
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
case LEFTMOUSE :
2008-11-24 10:45:36 +00:00
case MIDDLEMOUSE :
case RIGHTMOUSE :
2009-07-26 12:52:39 +00:00
if ( event - > val = = KM_PRESS ) {
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 ) {
gesture - > mode = 1 ;
2008-12-27 16:09:56 +00:00
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
}
}
else {
2009-07-26 12:52:39 +00:00
if ( border_apply ( C , op , event - > type , gesture - > event_type ) ) {
2009-01-31 10:00:08 +00:00
wm_gesture_end ( C , op ) ;
return OPERATOR_FINISHED ;
}
2009-01-02 14:11:18 +00:00
wm_gesture_end ( C , op ) ;
2009-01-31 10:00:08 +00:00
return OPERATOR_CANCELLED ;
2008-01-19 17:54:05 +00:00
}
break ;
case ESCKEY :
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 ;
2008-01-19 17:54:05 +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
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
int WM_gesture_circle_invoke ( bContext * C , wmOperator * op , wmEvent * event )
{
op - > customdata = WM_gesture_new ( C , event , WM_GESTURE_CIRCLE ) ;
/* add modal handler */
WM_event_add_modal_handler ( C , & CTX_wm_window ( C ) - > handlers , op ) ;
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 ;
/* 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 ) ;
}
int WM_gesture_circle_modal ( bContext * C , wmOperator * op , wmEvent * event )
{
wmGesture * gesture = op - > customdata ;
rcti * rect = gesture - > customdata ;
int sx , sy ;
switch ( event - > type ) {
case MOUSEMOVE :
wm_subwindow_getorigin ( CTX_wm_window ( C ) , gesture - > swinid , & sx , & sy ) ;
rect - > xmin = event - > x - sx ;
rect - > ymin = event - > y - sy ;
2008-12-27 16:09:56 +00:00
wm_gesture_tag_redraw ( C ) ;
2008-12-21 16:24:19 +00:00
if ( gesture - > mode )
2009-01-24 13:45:24 +00:00
gesture_circle_apply ( C , op ) ;
2008-12-21 16:24:19 +00:00
break ;
case WHEELUPMOUSE :
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 ;
case WHEELDOWNMOUSE :
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 ;
case LEFTMOUSE :
case MIDDLEMOUSE :
case RIGHTMOUSE :
if ( event - > val = = 0 ) { /* key release */
2009-01-02 14:11:18 +00:00
wm_gesture_end ( C , op ) ;
2008-12-21 16:24:19 +00:00
return OPERATOR_FINISHED ;
}
2009-01-24 13:45:24 +00:00
else {
if ( RNA_struct_find_property ( op - > ptr , " event_type " ) )
RNA_int_set ( op - > ptr , " event_type " , event - > type ) ;
/* apply first click */
gesture_circle_apply ( C , op ) ;
2008-12-21 16:24:19 +00:00
gesture - > mode = 1 ;
2009-01-24 13:45:24 +00:00
}
2008-12-21 16:24:19 +00:00
break ;
case ESCKEY :
2009-01-02 14:11:18 +00:00
wm_gesture_end ( C , op ) ;
2008-12-21 16:24:19 +00:00
return OPERATOR_CANCELLED ;
}
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 " ;
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 :
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 ;
if ( ( val = wm_gesture_evaluate ( C , gesture ) ) ) {
wmEvent event ;
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
2008-12-18 02:56:48 +00:00
event = * ( 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 )
event . type = EVT_TWEAK_L ;
else if ( gesture - > event_type = = RIGHTMOUSE )
event . type = EVT_TWEAK_R ;
else
event . type = EVT_TWEAK_M ;
2008-11-24 10:45:36 +00:00
event . val = val ;
/* mouse coords! */
2008-12-18 02:56:48 +00:00
wm_event_add ( window , & event ) ;
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 */
window - > tweak = NULL ;
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 ) ;
window - > tweak = NULL ;
2.5
- Edit mesh: Add ctrl+click add vertex or extrude.
I've made it not move the 3d cursor in that case.
Also found out tweak events conflicted with existing
keymap definitions; on tweak failure (= no mousemove)
it now passes on the mouse event as 'mouse down' for
the remaining keymaps to check.
These then actually respond to mouse-up instead of down...
The location in the keymaps where tweaks get generated
remains important. Examples:
1 - 'select' mouse-handler, operator return pass-through
2 - tweak handler checks, and makes tweak event
3 - grabber responds to tweak event
1 - ctrl+mouse tweak handler checks, makes tweak event,
or passes event on
2 - if tweak event, it runs lasso
3 - else when passed on, ctrl+click extrude happens
In the first case, select works on mouse-down, immediate.
In the second case, extrude happens on mouse-release, even
though the keymap defined mouse-press.
This will make designing nice balanced keymaps still not
simple; especially because you can't tell operators to
pass on the key... although we can add the convention that
select-mouse operators always pass on to enable tweaks.
Still a good reason to wait with custom keymaps
when this is fully settled!
2009-01-30 18:18:41 +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 :
WM_gesture_end ( C , gesture ) ;
window - > tweak = NULL ;
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 ) ) {
if ( event - > val ) { // pressed
if ( ELEM3 ( event - > type , LEFTMOUSE , MIDDLEMOUSE , RIGHTMOUSE ) )
win - > tweak = WM_gesture_new ( C , event , WM_GESTURE_TWEAK ) ;
}
}
}
else {
if ( action = = WM_HANDLER_BREAK ) {
WM_gesture_end ( C , win - > tweak ) ;
win - > tweak = NULL ;
}
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 */
WM_event_add_modal_handler ( C , & CTX_wm_window ( C ) - > handlers , op ) ;
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 */
WM_event_add_modal_handler ( C , & CTX_wm_window ( C ) - > handlers , 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 " ) ) ;
2009-01-02 14:11:18 +00:00
return OPERATOR_RUNNING_MODAL ;
}
static void gesture_lasso_apply ( bContext * C , wmOperator * op , int event_type )
{
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 :
wm_gesture_tag_redraw ( C ) ;
wm_subwindow_getorigin ( CTX_wm_window ( C ) , gesture - > swinid , & sx , & sy ) ;
if ( gesture - > points < WM_LASSO_MAX_POINTS ) {
short * lasso = gesture - > customdata ;
lasso + = 2 * gesture - > points ;
lasso [ 0 ] = event - > x - sx ;
lasso [ 1 ] = event - > y - sy ;
gesture - > points + + ;
}
else {
gesture_lasso_apply ( C , op , event - > type ) ;
return OPERATOR_FINISHED ;
}
break ;
case LEFTMOUSE :
case MIDDLEMOUSE :
case RIGHTMOUSE :
if ( event - > val = = 0 ) { /* key release */
gesture_lasso_apply ( C , op , event - > type ) ;
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 " ;
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
2009-01-24 16:59:55 +00:00
/* *********************** radial control ****************** */
2009-01-24 22:58:22 +00:00
const int WM_RADIAL_CONTROL_DISPLAY_SIZE = 200 ;
2009-01-24 16:59:55 +00:00
typedef struct wmRadialControl {
2009-01-24 22:58:22 +00:00
int mode ;
float initial_value , value , max_value ;
2009-01-24 16:59:55 +00:00
int initial_mouse [ 2 ] ;
void * cursor ;
2009-01-24 22:58:22 +00:00
GLuint tex ;
2009-01-24 16:59:55 +00:00
} wmRadialControl ;
static void wm_radial_control_paint ( bContext * C , int x , int y , void * customdata )
{
2009-01-24 22:58:22 +00:00
wmRadialControl * rc = ( wmRadialControl * ) customdata ;
2009-01-24 16:59:55 +00:00
ARegion * ar = CTX_wm_region ( C ) ;
2009-02-06 01:39:55 +00:00
float r1 = 0.0f , r2 = 0.0f , r3 = 0.0f , angle = 0.0f ;
2009-01-24 16:59:55 +00:00
/* Keep cursor in the original place */
2009-01-24 22:58:22 +00:00
x = rc - > initial_mouse [ 0 ] - ar - > winrct . xmin ;
y = rc - > initial_mouse [ 1 ] - ar - > winrct . ymin ;
glPushMatrix ( ) ;
2009-01-24 16:59:55 +00:00
glTranslatef ( ( float ) x , ( float ) y , 0.0f ) ;
2009-01-24 22:58:22 +00:00
if ( rc - > mode = = WM_RADIALCONTROL_SIZE ) {
r1 = rc - > value ;
r2 = rc - > initial_value ;
r3 = r1 ;
} else if ( rc - > mode = = WM_RADIALCONTROL_STRENGTH ) {
r1 = ( 1 - rc - > value ) * WM_RADIAL_CONTROL_DISPLAY_SIZE ;
r2 = WM_RADIAL_CONTROL_DISPLAY_SIZE ;
r3 = WM_RADIAL_CONTROL_DISPLAY_SIZE ;
} else if ( rc - > mode = = WM_RADIALCONTROL_ANGLE ) {
r1 = r2 = WM_RADIAL_CONTROL_DISPLAY_SIZE ;
r3 = WM_RADIAL_CONTROL_DISPLAY_SIZE ;
angle = rc - > value ;
}
2009-01-24 16:59:55 +00:00
glColor4ub ( 255 , 255 , 255 , 128 ) ;
glEnable ( GL_LINE_SMOOTH ) ;
glEnable ( GL_BLEND ) ;
2009-01-24 22:58:22 +00:00
if ( rc - > mode = = WM_RADIALCONTROL_ANGLE )
fdrawline ( 0 , 0 , WM_RADIAL_CONTROL_DISPLAY_SIZE , 0 ) ;
if ( rc - > tex ) {
const float str = rc - > mode = = WM_RADIALCONTROL_STRENGTH ? ( rc - > value + 0.5 ) : 1 ;
2009-01-24 23:20:25 +00:00
if ( rc - > mode = = WM_RADIALCONTROL_ANGLE ) {
glRotatef ( angle , 0 , 0 , 1 ) ;
fdrawline ( 0 , 0 , WM_RADIAL_CONTROL_DISPLAY_SIZE , 0 ) ;
}
2009-01-24 22:58:22 +00:00
glBindTexture ( GL_TEXTURE_2D , rc - > tex ) ;
glTexParameterf ( GL_TEXTURE_2D , GL_TEXTURE_MIN_FILTER , GL_LINEAR ) ;
glTexParameterf ( GL_TEXTURE_2D , GL_TEXTURE_MAG_FILTER , GL_LINEAR ) ;
glEnable ( GL_TEXTURE_2D ) ;
glBegin ( GL_QUADS ) ;
glColor4f ( 0 , 0 , 0 , str ) ;
glTexCoord2f ( 0 , 0 ) ;
glVertex2f ( - r3 , - r3 ) ;
glTexCoord2f ( 1 , 0 ) ;
glVertex2f ( r3 , - r3 ) ;
glTexCoord2f ( 1 , 1 ) ;
glVertex2f ( r3 , r3 ) ;
glTexCoord2f ( 0 , 1 ) ;
glVertex2f ( - r3 , r3 ) ;
glEnd ( ) ;
glDisable ( GL_TEXTURE_2D ) ;
}
glColor4ub ( 255 , 255 , 255 , 128 ) ;
glutil_draw_lined_arc ( 0.0 , M_PI * 2.0 , r1 , 40 ) ;
glutil_draw_lined_arc ( 0.0 , M_PI * 2.0 , r2 , 40 ) ;
2009-01-24 16:59:55 +00:00
glDisable ( GL_BLEND ) ;
glDisable ( GL_LINE_SMOOTH ) ;
2009-01-24 22:58:22 +00:00
glPopMatrix ( ) ;
2009-01-24 16:59:55 +00:00
}
2009-01-24 22:58:22 +00:00
int WM_radial_control_modal ( bContext * C , wmOperator * op , wmEvent * event )
2009-01-24 16:59:55 +00:00
{
wmRadialControl * rc = ( wmRadialControl * ) op - > customdata ;
int mode , initial_mouse [ 2 ] , delta [ 2 ] ;
float dist ;
double new_value = RNA_float_get ( op - > ptr , " new_value " ) ;
int ret = OPERATOR_RUNNING_MODAL ;
mode = RNA_int_get ( op - > ptr , " mode " ) ;
RNA_int_get_array ( op - > ptr , " initial_mouse " , initial_mouse ) ;
switch ( event - > type ) {
case MOUSEMOVE :
delta [ 0 ] = initial_mouse [ 0 ] - event - > x ;
delta [ 1 ] = initial_mouse [ 1 ] - event - > y ;
dist = sqrt ( delta [ 0 ] * delta [ 0 ] + delta [ 1 ] * delta [ 1 ] ) ;
if ( mode = = WM_RADIALCONTROL_SIZE )
new_value = dist ;
else if ( mode = = WM_RADIALCONTROL_STRENGTH ) {
2009-01-24 22:58:22 +00:00
new_value = 1 - dist / WM_RADIAL_CONTROL_DISPLAY_SIZE ;
2009-01-24 16:59:55 +00:00
} else if ( mode = = WM_RADIALCONTROL_ANGLE )
new_value = ( ( int ) ( atan2 ( delta [ 1 ] , delta [ 0 ] ) * ( 180.0 / M_PI ) ) + 180 ) ;
2009-01-24 22:58:22 +00:00
if ( event - > ctrl ) {
if ( mode = = WM_RADIALCONTROL_STRENGTH )
new_value = ( ( int ) ( new_value * 100 ) / 10 * 10 ) / 100.0f ;
else
new_value = ( ( int ) new_value + 5 ) / 10 * 10 ;
}
2009-01-24 16:59:55 +00:00
break ;
case ESCKEY :
case RIGHTMOUSE :
ret = OPERATOR_CANCELLED ;
break ;
case LEFTMOUSE :
case PADENTER :
op - > type - > exec ( C , op ) ;
ret = OPERATOR_FINISHED ;
break ;
}
2009-01-24 22:58:22 +00:00
/* Clamp */
if ( new_value > rc - > max_value )
new_value = rc - > max_value ;
else if ( new_value < 0 )
new_value = 0 ;
2009-01-24 16:59:55 +00:00
/* Update paint data */
2009-01-24 22:58:22 +00:00
rc - > value = new_value ;
2009-01-24 16:59:55 +00:00
RNA_float_set ( op - > ptr , " new_value " , new_value ) ;
if ( ret ! = OPERATOR_RUNNING_MODAL ) {
WM_paint_cursor_end ( CTX_wm_manager ( C ) , rc - > cursor ) ;
MEM_freeN ( rc ) ;
}
ED_region_tag_redraw ( CTX_wm_region ( C ) ) ;
return ret ;
}
2009-01-24 22:58:22 +00:00
/* Expects the operator customdata to be an ImBuf (or NULL) */
2009-01-24 16:59:55 +00:00
int WM_radial_control_invoke ( bContext * C , wmOperator * op , wmEvent * event )
{
wmRadialControl * rc = MEM_callocN ( sizeof ( wmRadialControl ) , " radial control " ) ;
int mode = RNA_int_get ( op - > ptr , " mode " ) ;
float initial_value = RNA_float_get ( op - > ptr , " initial_value " ) ;
int mouse [ 2 ] = { event - > x , event - > y } ;
2009-01-24 22:58:22 +00:00
if ( mode = = WM_RADIALCONTROL_SIZE ) {
rc - > max_value = 200 ;
2009-01-24 16:59:55 +00:00
mouse [ 0 ] - = initial_value ;
2009-01-24 22:58:22 +00:00
}
else if ( mode = = WM_RADIALCONTROL_STRENGTH ) {
rc - > max_value = 1 ;
mouse [ 0 ] - = WM_RADIAL_CONTROL_DISPLAY_SIZE * ( 1 - initial_value ) ;
}
2009-01-24 16:59:55 +00:00
else if ( mode = = WM_RADIALCONTROL_ANGLE ) {
2009-01-24 22:58:22 +00:00
rc - > max_value = 360 ;
mouse [ 0 ] - = WM_RADIAL_CONTROL_DISPLAY_SIZE * cos ( initial_value ) ;
mouse [ 1 ] - = WM_RADIAL_CONTROL_DISPLAY_SIZE * sin ( initial_value ) ;
initial_value * = 180.0f / M_PI ;
}
if ( op - > customdata ) {
ImBuf * im = ( ImBuf * ) op - > customdata ;
/* Build GL texture */
glGenTextures ( 1 , & rc - > tex ) ;
glBindTexture ( GL_TEXTURE_2D , rc - > tex ) ;
glTexImage2D ( GL_TEXTURE_2D , 0 , GL_ALPHA , im - > x , im - > y , 0 , GL_ALPHA , GL_FLOAT , im - > rect_float ) ;
MEM_freeN ( im - > rect_float ) ;
MEM_freeN ( im ) ;
2009-01-24 16:59:55 +00:00
}
RNA_int_set_array ( op - > ptr , " initial_mouse " , mouse ) ;
RNA_float_set ( op - > ptr , " new_value " , initial_value ) ;
op - > customdata = rc ;
2009-01-24 22:58:22 +00:00
rc - > mode = mode ;
rc - > initial_value = initial_value ;
2009-01-24 16:59:55 +00:00
rc - > initial_mouse [ 0 ] = mouse [ 0 ] ;
rc - > initial_mouse [ 1 ] = mouse [ 1 ] ;
rc - > cursor = WM_paint_cursor_activate ( CTX_wm_manager ( C ) , op - > type - > poll ,
wm_radial_control_paint , op - > customdata ) ;
/* add modal handler */
WM_event_add_modal_handler ( C , & CTX_wm_window ( C ) - > handlers , op ) ;
2009-01-24 22:58:22 +00:00
WM_radial_control_modal ( C , op , event ) ;
2009-01-24 16:59:55 +00:00
return OPERATOR_RUNNING_MODAL ;
}
2009-01-25 21:02:52 +00:00
/* Gets a descriptive string of the operation */
void WM_radial_control_string ( wmOperator * op , char str [ ] , int maxlen )
{
int mode = RNA_int_get ( op - > ptr , " mode " ) ;
float v = RNA_float_get ( op - > ptr , " new_value " ) ;
if ( mode = = WM_RADIALCONTROL_SIZE )
sprintf ( str , " Size: %d " , ( int ) v ) ;
else if ( mode = = WM_RADIALCONTROL_STRENGTH )
sprintf ( str , " Strength: %d " , ( int ) v ) ;
else if ( mode = = WM_RADIALCONTROL_ANGLE )
sprintf ( str , " Angle: %d " , ( int ) ( v * 180.0f / M_PI ) ) ;
}
2009-01-24 16:59:55 +00:00
/** Important: this doesn't define an actual operator, it
just sets up the common parts of the radial control op . * */
void WM_OT_radial_control_partial ( wmOperatorType * ot )
{
static EnumPropertyItem prop_mode_items [ ] = {
2009-06-16 00:52:21 +00:00
{ WM_RADIALCONTROL_SIZE , " SIZE " , 0 , " Size " , " " } ,
{ WM_RADIALCONTROL_STRENGTH , " STRENGTH " , 0 , " Strength " , " " } ,
{ WM_RADIALCONTROL_ANGLE , " ANGLE " , 0 , " Angle " , " " } ,
{ 0 , NULL , 0 , NULL , NULL } } ;
2009-01-24 16:59:55 +00:00
/* Should be set in custom invoke() */
RNA_def_float ( ot - > srna , " initial_value " , 0 , 0 , FLT_MAX , " Initial Value " , " " , 0 , FLT_MAX ) ;
/* Set internally, should be used in custom exec() to get final value */
RNA_def_float ( ot - > srna , " new_value " , 0 , 0 , FLT_MAX , " New Value " , " " , 0 , FLT_MAX ) ;
/* Should be set before calling operator */
RNA_def_enum ( ot - > srna , " mode " , prop_mode_items , 0 , " Mode " , " " ) ;
/* Internal */
RNA_def_int_vector ( ot - > srna , " initial_mouse " , 2 , NULL , INT_MIN , INT_MAX , " initial_mouse " , " " , INT_MIN , INT_MAX ) ;
}
2009-05-19 12:54:54 +00:00
/* ************************** timer for testing ***************** */
/* uses no type defines, fully local testing function anyway... ;) */
static int ten_timer_exec ( bContext * C , wmOperator * op )
{
ARegion * ar = CTX_wm_region ( C ) ;
double stime = PIL_check_seconds_timer ( ) ;
int type = RNA_int_get ( op - > ptr , " type " ) ;
int a , time ;
char tmpstr [ 128 ] ;
WM_cursor_wait ( 1 ) ;
for ( a = 0 ; a < 10 ; a + + ) {
if ( type = = 0 ) {
ED_region_do_draw ( C , ar ) ;
}
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 ;
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! */
}
2009-05-19 15:37:50 +00:00
else if ( type = = 3 ) {
Scene * scene = CTX_data_scene ( C ) ;
if ( a & 1 ) scene - > r . cfra - - ;
else scene - > r . cfra + + ;
scene_update_for_newframe ( scene , scene - > lay ) ;
}
2009-05-19 12:54:54 +00:00
else {
ED_undo_pop ( C ) ;
ED_undo_redo ( C ) ;
}
}
time = ( int ) ( ( PIL_check_seconds_timer ( ) - stime ) * 1000 ) ;
if ( type = = 0 ) sprintf ( tmpstr , " 10 x Draw Region: %d ms " , time ) ;
if ( type = = 1 ) sprintf ( tmpstr , " 10 x Draw Region and Swap: %d ms " , time ) ;
if ( type = = 2 ) sprintf ( tmpstr , " 10 x Draw Window and Swap: %d ms " , time ) ;
2009-05-19 15:37:50 +00:00
if ( type = = 3 ) sprintf ( tmpstr , " Anim Step: %d ms " , time ) ;
if ( type = = 4 ) sprintf ( tmpstr , " 10 x Undo/Redo: %d ms " , time ) ;
2009-05-19 12:54:54 +00:00
WM_cursor_wait ( 0 ) ;
uiPupMenuNotice ( C , tmpstr ) ;
return OPERATOR_FINISHED ;
}
static void WM_OT_ten_timer ( wmOperatorType * ot )
{
static EnumPropertyItem prop_type_items [ ] = {
2009-06-16 00:52:21 +00:00
{ 0 , " DRAW " , 0 , " Draw Region " , " " } ,
{ 1 , " DRAWSWAP " , 0 , " Draw Region + Swap " , " " } ,
{ 2 , " DRAWWINSWAP " , 0 , " Draw Window + Swap " , " " } ,
{ 3 , " ANIMSTEP " , 0 , " Anim Step " , " " } ,
{ 4 , " UNDO " , 0 , " Undo/Redo " , " " } ,
{ 0 , NULL , 0 , NULL , NULL } } ;
2009-05-19 12:54:54 +00:00
ot - > name = " Ten Timer " ;
ot - > idname = " WM_OT_ten_timer " ;
ot - > invoke = WM_menu_invoke ;
ot - > exec = ten_timer_exec ;
ot - > poll = WM_operator_winactive ;
RNA_def_enum ( ot - > srna , " type " , prop_type_items , 0 , " Type " , " " ) ;
}
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 )
{
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 ) ;
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 ) ;
WM_operatortype_append ( WM_OT_exit_blender ) ;
2008-12-19 18:28:37 +00:00
WM_operatortype_append ( WM_OT_open_recentfile ) ;
2009-01-06 14:42:54 +00:00
WM_operatortype_append ( WM_OT_open_mainfile ) ;
2009-07-23 21:35:11 +00:00
WM_operatortype_append ( WM_OT_recover_last_session ) ;
2.5
Added WM Jobs manager
- WM can manage threaded jobs for you; just provide a couple
of components to get it work:
- customdata, free callback for it
- timer step, notifier code
- start callback, update callback
- Once started, each job runs an own timer, and will for
every time step check necessary updates, or close the
job when ready.
- No drawing happens in jobs, that's for notifiers!
- Every job stores an owner pointer, and based on this owner
it will prevent multiple jobs to enter the stack.
Instead it will re-use a running job, signal it to stop
and allow caller to re-initialize it even.
- Check new wm_jobs.c for more explanation. Jobs API is still
under construction.
Fun: BLI_addtail(&wm->jobs, steve); :)
Put Node shader previews back using wmJobs
- Preview calculating is now fully threaded (1 thread still)
- Thanks to new event system + notifiers, you can see
previews update even while dragging sliders!
- Currently it only starts when you change a node setting.
Warning: the thread render shares Node data, so don't delete
nodes while it renders! This topic is on the todo to make safe.
Also:
- bug in region initialize (do_versions) showed channel list in
node editor wrong.
- flagged the channel list 'hidden' now, it was really in the
way! This is for later to work on anyway.
- recoded Render API callbacks so it gets handlers passed on,
no globals to use anymore, remember?
- previewrender code gets now so much nicer! Will remove a lot
of stuff from code soon.
2009-01-22 14:59:49 +00:00
WM_operatortype_append ( WM_OT_jobs_timer ) ;
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-05-19 12:54:54 +00:00
WM_operatortype_append ( WM_OT_ten_timer ) ;
2009-05-22 15:02:32 +00:00
WM_operatortype_append ( WM_OT_debug_menu ) ;
2009-06-03 18:31:37 +00:00
WM_operatortype_append ( WM_OT_search_menu ) ;
2007-12-24 18:27:28 +00:00
}
2008-11-19 16:28:11 +00:00
/* default keymap for windows and screens, only call once per WM */
void wm_window_keymap ( wmWindowManager * wm )
{
2008-12-08 15:02:57 +00:00
ListBase * keymap = WM_keymap_listbase ( wm , " Window " , 0 , 0 ) ;
2.5
Added WM Jobs manager
- WM can manage threaded jobs for you; just provide a couple
of components to get it work:
- customdata, free callback for it
- timer step, notifier code
- start callback, update callback
- Once started, each job runs an own timer, and will for
every time step check necessary updates, or close the
job when ready.
- No drawing happens in jobs, that's for notifiers!
- Every job stores an owner pointer, and based on this owner
it will prevent multiple jobs to enter the stack.
Instead it will re-use a running job, signal it to stop
and allow caller to re-initialize it even.
- Check new wm_jobs.c for more explanation. Jobs API is still
under construction.
Fun: BLI_addtail(&wm->jobs, steve); :)
Put Node shader previews back using wmJobs
- Preview calculating is now fully threaded (1 thread still)
- Thanks to new event system + notifiers, you can see
previews update even while dragging sliders!
- Currently it only starts when you change a node setting.
Warning: the thread render shares Node data, so don't delete
nodes while it renders! This topic is on the todo to make safe.
Also:
- bug in region initialize (do_versions) showed channel list in
node editor wrong.
- flagged the channel list 'hidden' now, it was really in the
way! This is for later to work on anyway.
- recoded Render API callbacks so it gets handlers passed on,
no globals to use anymore, remember?
- previewrender code gets now so much nicer! Will remove a lot
of stuff from code soon.
2009-01-22 14:59:49 +00:00
/* items to make WM work */
WM_keymap_verify_item ( keymap , " WM_OT_jobs_timer " , TIMERJOBS , KM_ANY , KM_ANY , 0 ) ;
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-02-07 10:00:46 +00:00
WM_keymap_verify_item ( keymap , " WM_OT_read_homefile " , XKEY , KM_PRESS , KM_CTRL , 0 ) ;
2008-12-08 15:02:57 +00:00
WM_keymap_verify_item ( keymap , " WM_OT_save_homefile " , UKEY , KM_PRESS , KM_CTRL , 0 ) ;
2008-12-19 18:28:37 +00:00
WM_keymap_verify_item ( keymap , " WM_OT_open_recentfile " , OKEY , KM_PRESS , KM_CTRL , 0 ) ;
2009-01-06 14:42:54 +00:00
WM_keymap_verify_item ( keymap , " WM_OT_open_mainfile " , F1KEY , KM_PRESS , 0 , 0 ) ;
2009-02-08 19:15:59 +00:00
WM_keymap_verify_item ( keymap , " WM_OT_save_mainfile " , WKEY , KM_PRESS , KM_CTRL , 0 ) ;
2009-01-21 19:28:28 +00:00
WM_keymap_verify_item ( keymap , " WM_OT_save_as_mainfile " , F2KEY , KM_PRESS , 0 , 0 ) ;
2009-07-10 16:55:49 +00:00
WM_keymap_verify_item ( keymap , " WM_OT_window_fullscreen_toggle " , F11KEY , KM_PRESS , KM_SHIFT , 0 ) ;
2008-12-17 15:38:40 +00:00
WM_keymap_verify_item ( keymap , " WM_OT_exit_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-05-19 12:54:54 +00:00
WM_keymap_verify_item ( keymap , " WM_OT_ten_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-07-28 08:50:11 +00:00
WM_keymap_verify_item ( keymap , " WM_OT_search_menu " , SPACEKEY , KM_PRESS , KM_CTRL , 0 ) ;
2009-05-22 15:02:32 +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
}