2009-02-04 11:52:16 +00:00
/**
* * * * * * BEGIN GPL LICENSE BLOCK * * * * *
*
* This program is free software ; you can redistribute it and / or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation ; either version 2
* of the License , or ( at your option ) any later version .
*
* This program is distributed in the hope that it will be useful ,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
* GNU General Public License for more details .
*
* You should have received a copy of the GNU General Public License
* along with this program ; if not , write to the Free Software Foundation ,
* Inc . , 59 Temple Place - Suite 330 , Boston , MA 02111 - 1307 , USA .
*
* The Original Code is Copyright ( C ) 2009 Blender Foundation .
* All rights reserved .
*
* Contributor ( s ) : Blender Foundation
*
* * * * * * END GPL LICENSE BLOCK * * * * *
*/
# include <math.h>
# include <stdlib.h>
# include <string.h>
# include "MEM_guardedalloc.h"
2.5
Smaller jobs, all in one commit!
- Moved object_do_update out of view3d drawing, into
the event system (currently after notifiers).
Depsgraph calls for setting update flags will have to
keep track of each Screen's needs, so a UI showing only
a Sequencer doesn't do objects.
- Added button in "Properties region" in 3D window to set
or disable 4-split, including the 3 options it has.
(lock, box, clip)
- Restored legacy code for UI, to make things work like
bone rename, autocomplete.
- Node editor now shows Curves widgets again
- Bugfix: composite job increased Viewer user id count
- Bugfix: Node editor, not "Enable nodes" still called
a Job, which didn't do anything
- Various code cleaning, unused vars and prototypes.
2009-02-11 16:54:55 +00:00
# include "DNA_action_types.h"
# include "DNA_color_types.h"
2009-02-04 11:52:16 +00:00
# include "DNA_listBase.h"
2.5: ID datablock button back, previously known as std_libbuttons. The
way this worked in 2.4x wasn't really clean, with events going all over
the place and using dubious variables such as G.but->lockpoin or
G.sima->menunr. It works as follows now, for example:
xco= uiDefIDPoinButs(block, CTX_data_main(C), NULL, (ID**)&sima->image, ID_IM, &sima->pin, xco, yco,
sima_idpoin_handle, UI_ID_BROWSE|UI_ID_RENAME|UI_ID_ADD_NEW|UI_ID_OPEN|UI_ID_DELETE|UI_ID_ALONE|UI_ID_PIN);
The last two parameters are a callback function, and a list of events
or functionalities that are supported. The callback function will then
get the ID pointer + event to handle.
2009-02-06 16:40:14 +00:00
# include "DNA_material_types.h"
2009-09-16 01:15:30 +00:00
# include "DNA_lamp_types.h""
2.5
Smaller jobs, all in one commit!
- Moved object_do_update out of view3d drawing, into
the event system (currently after notifiers).
Depsgraph calls for setting update flags will have to
keep track of each Screen's needs, so a UI showing only
a Sequencer doesn't do objects.
- Added button in "Properties region" in 3D window to set
or disable 4-split, including the 3 options it has.
(lock, box, clip)
- Restored legacy code for UI, to make things work like
bone rename, autocomplete.
- Node editor now shows Curves widgets again
- Bugfix: composite job increased Viewer user id count
- Bugfix: Node editor, not "Enable nodes" still called
a Job, which didn't do anything
- Various code cleaning, unused vars and prototypes.
2009-02-11 16:54:55 +00:00
# include "DNA_object_types.h"
2009-02-04 11:52:16 +00:00
# include "DNA_screen_types.h"
2009-06-03 00:14:12 +00:00
# include "DNA_texture_types.h"
2009-02-04 11:52:16 +00:00
# include "DNA_windowmanager_types.h"
2009-06-10 11:43:21 +00:00
# include "BLI_blenlib.h"
2.5
Smaller jobs, all in one commit!
- Moved object_do_update out of view3d drawing, into
the event system (currently after notifiers).
Depsgraph calls for setting update flags will have to
keep track of each Screen's needs, so a UI showing only
a Sequencer doesn't do objects.
- Added button in "Properties region" in 3D window to set
or disable 4-split, including the 3 options it has.
(lock, box, clip)
- Restored legacy code for UI, to make things work like
bone rename, autocomplete.
- Node editor now shows Curves widgets again
- Bugfix: composite job increased Viewer user id count
- Bugfix: Node editor, not "Enable nodes" still called
a Job, which didn't do anything
- Various code cleaning, unused vars and prototypes.
2009-02-11 16:54:55 +00:00
# include "BKE_colortools.h"
2009-02-04 11:52:16 +00:00
# include "BKE_context.h"
# include "BKE_idprop.h"
2009-06-24 16:44:54 +00:00
# include "BKE_icons.h"
2.5: ID datablock button back, previously known as std_libbuttons. The
way this worked in 2.4x wasn't really clean, with events going all over
the place and using dubious variables such as G.but->lockpoin or
G.sima->menunr. It works as follows now, for example:
xco= uiDefIDPoinButs(block, CTX_data_main(C), NULL, (ID**)&sima->image, ID_IM, &sima->pin, xco, yco,
sima_idpoin_handle, UI_ID_BROWSE|UI_ID_RENAME|UI_ID_ADD_NEW|UI_ID_OPEN|UI_ID_DELETE|UI_ID_ALONE|UI_ID_PIN);
The last two parameters are a callback function, and a list of events
or functionalities that are supported. The callback function will then
get the ID pointer + event to handle.
2009-02-06 16:40:14 +00:00
# include "BKE_library.h"
# include "BKE_main.h"
2009-06-03 00:14:12 +00:00
# include "BKE_texture.h"
2009-02-04 11:52:16 +00:00
# include "BKE_utildefines.h"
# include "RNA_access.h"
# include "UI_interface.h"
# include "UI_resources.h"
2.5
Smaller jobs, all in one commit!
- Moved object_do_update out of view3d drawing, into
the event system (currently after notifiers).
Depsgraph calls for setting update flags will have to
keep track of each Screen's needs, so a UI showing only
a Sequencer doesn't do objects.
- Added button in "Properties region" in 3D window to set
or disable 4-split, including the 3 options it has.
(lock, box, clip)
- Restored legacy code for UI, to make things work like
bone rename, autocomplete.
- Node editor now shows Curves widgets again
- Bugfix: composite job increased Viewer user id count
- Bugfix: Node editor, not "Enable nodes" still called
a Job, which didn't do anything
- Various code cleaning, unused vars and prototypes.
2009-02-11 16:54:55 +00:00
# include "ED_screen.h"
2009-02-04 11:52:16 +00:00
# include "ED_util.h"
# include "WM_api.h"
# include "WM_types.h"
2.5
Summary of ain features:
- Themes and Styles are now editable.
- CTRL+U "Save user defaults" now goes to new .B25.blend, so you
can use 2.4x and 2.5x next to each other. If B25 doesn't exist, it
reads the regular .B.blend
- Press Tkey in 3d window for (unfinished) toolbar WIP. It now only
shows the last operator, if appropriate.
Nkey properties moved to the other side.
A lot of work was done on removing old themes for good and properly
getting it work with the 2.5 region system. Here's some notes;
- Buttons now all have a complete set of colors, based on button classifications
(See outliner -> user prefs -> Interface
- Theme colors have been extended with basic colors for region types.
Currently colors are defined for Window, Header, List/Channels and
for Button/Tool views.
The screen manager handles this btw, so a TH_BACK will always pick the
right backdrop color.
- Menu backdrops are in in Button theme colors. Floating Panels will be in
the per-space type Themes.
- Styles were added in RNA too, but only for the font settings now.
Only Panel font, widget font and widget-label work now. The 'group label'
will be for templates mostly.
Style settings will be expanded with spacing defaults, label conventions,
etc.
- Label text colors are stored in per-space Theme too, to make sure they fit.
Same goes for Panel title color.
Note that 'shadow' for fonts can conflict with text colors; shadow color is
currently stored in Style... shadow code needs a bit of work still.
2009-04-27 13:44:11 +00:00
# include "interface_intern.h"
2.5: ID datablock button back, previously known as std_libbuttons. The
way this worked in 2.4x wasn't really clean, with events going all over
the place and using dubious variables such as G.but->lockpoin or
G.sima->menunr. It works as follows now, for example:
xco= uiDefIDPoinButs(block, CTX_data_main(C), NULL, (ID**)&sima->image, ID_IM, &sima->pin, xco, yco,
sima_idpoin_handle, UI_ID_BROWSE|UI_ID_RENAME|UI_ID_ADD_NEW|UI_ID_OPEN|UI_ID_DELETE|UI_ID_ALONE|UI_ID_PIN);
The last two parameters are a callback function, and a list of events
or functionalities that are supported. The callback function will then
get the ID pointer + event to handle.
2009-02-06 16:40:14 +00:00
# define DEF_BUT_WIDTH 150
# define DEF_ICON_BUT_WIDTH 20
# define DEF_BUT_HEIGHT 20
2009-02-04 11:52:16 +00:00
/*************************** RNA Utilities ******************************/
2009-03-13 13:38:41 +00:00
uiBut * uiDefAutoButR ( uiBlock * block , PointerRNA * ptr , PropertyRNA * prop , int index , char * name , int icon , int x1 , int y1 , int x2 , int y2 )
2009-02-04 11:52:16 +00:00
{
uiBut * but = NULL ;
2009-04-19 13:37:59 +00:00
const char * propname = RNA_property_identifier ( prop ) ;
Implemented dynamic and multidimensional array support in RNA.
Example code: http://www.pasteall.org/7332/c.
New API functions: http://www.pasteall.org/7330/c.
Maximum number of dimensions is currently limited to 3, but can be increased arbitrarily if needed.
What this means for ID property access:
* MeshFace.verts - dynamic array, size 3 or 4 depending on MFace.v4
* MeshTextureFace.uv - dynamic, 2-dimensional array, size depends on MFace.v4
* Object.matrix - 2-dimensional array
What this means for functions:
* more intuitive API possibility, for example:
Mesh.add_vertices([(x, y, z), (x, y, z), ...])
Mesh.add_faces([(1, 2, 3), (4, 5, 6), ...])
Python part is not complete yet, e.g. it is possible to:
MeshFace.verts = (1, 2, 3) # even if Mesh.verts is (1, 2, 3, 4) and vice-versa
MeshTextureFace.uv = [(0.0, 0.0)] * 4 # only if a corresponding MFace is a quad
but the following won't work:
MeshTextureFace.uv[3] = (0.0, 0.0) # setting uv[3] modifies MTFace.uv[1][0] instead of MTFace.uv[3]
2009-08-25 17:06:36 +00:00
int arraylen = RNA_property_array_length ( ptr , prop ) ;
2009-02-04 11:52:16 +00:00
2009-04-19 13:37:59 +00:00
switch ( RNA_property_type ( prop ) ) {
2009-02-04 11:52:16 +00:00
case PROP_BOOLEAN : {
int value , length ;
if ( arraylen & & index = = - 1 )
return NULL ;
Implemented dynamic and multidimensional array support in RNA.
Example code: http://www.pasteall.org/7332/c.
New API functions: http://www.pasteall.org/7330/c.
Maximum number of dimensions is currently limited to 3, but can be increased arbitrarily if needed.
What this means for ID property access:
* MeshFace.verts - dynamic array, size 3 or 4 depending on MFace.v4
* MeshTextureFace.uv - dynamic, 2-dimensional array, size depends on MFace.v4
* Object.matrix - 2-dimensional array
What this means for functions:
* more intuitive API possibility, for example:
Mesh.add_vertices([(x, y, z), (x, y, z), ...])
Mesh.add_faces([(1, 2, 3), (4, 5, 6), ...])
Python part is not complete yet, e.g. it is possible to:
MeshFace.verts = (1, 2, 3) # even if Mesh.verts is (1, 2, 3, 4) and vice-versa
MeshTextureFace.uv = [(0.0, 0.0)] * 4 # only if a corresponding MFace is a quad
but the following won't work:
MeshTextureFace.uv[3] = (0.0, 0.0) # setting uv[3] modifies MTFace.uv[1][0] instead of MTFace.uv[3]
2009-08-25 17:06:36 +00:00
length = RNA_property_array_length ( ptr , prop ) ;
2009-02-04 11:52:16 +00:00
if ( length )
value = RNA_property_boolean_get_index ( ptr , prop , index ) ;
else
value = RNA_property_boolean_get ( ptr , prop ) ;
2009-03-13 13:38:41 +00:00
if ( icon & & name & & strcmp ( name , " " ) = = 0 )
but = uiDefIconButR ( block , ICONTOG , 0 , icon , x1 , y1 , x2 , y2 , ptr , propname , index , 0 , 0 , - 1 , - 1 , NULL ) ;
else if ( icon )
but = uiDefIconTextButR ( block , ICONTOG , 0 , icon , name , x1 , y1 , x2 , y2 , ptr , propname , index , 0 , 0 , - 1 , - 1 , NULL ) ;
else
2009-05-27 00:03:49 +00:00
but = uiDefButR ( block , OPTION , 0 , name , x1 , y1 , x2 , y2 , ptr , propname , index , 0 , 0 , - 1 , - 1 , NULL ) ;
2009-02-04 11:52:16 +00:00
break ;
}
case PROP_INT :
case PROP_FLOAT :
if ( arraylen & & index = = - 1 ) {
2009-04-19 13:37:59 +00:00
if ( RNA_property_subtype ( prop ) = = PROP_COLOR )
2009-02-04 11:52:16 +00:00
but = uiDefButR ( block , COL , 0 , name , x1 , y1 , x2 , y2 , ptr , propname , 0 , 0 , 0 , - 1 , - 1 , NULL ) ;
}
2009-04-19 13:37:59 +00:00
else if ( RNA_property_subtype ( prop ) = = PROP_PERCENTAGE )
2009-02-17 21:07:01 +00:00
but = uiDefButR ( block , NUMSLI , 0 , name , x1 , y1 , x2 , y2 , ptr , propname , index , 0 , 0 , - 1 , - 1 , NULL ) ;
2009-02-04 11:52:16 +00:00
else
but = uiDefButR ( block , NUM , 0 , name , x1 , y1 , x2 , y2 , ptr , propname , index , 0 , 0 , - 1 , - 1 , NULL ) ;
break ;
case PROP_ENUM :
2009-09-10 14:20:21 +00:00
if ( icon & & name & & strcmp ( name , " " ) = = 0 )
but = uiDefIconButR ( block , MENU , 0 , icon , x1 , y1 , x2 , y2 , ptr , propname , index , 0 , 0 , - 1 , - 1 , NULL ) ;
else if ( icon )
but = uiDefIconTextButR ( block , MENU , 0 , icon , NULL , x1 , y1 , x2 , y2 , ptr , propname , index , 0 , 0 , - 1 , - 1 , NULL ) ;
else
but = uiDefButR ( block , MENU , 0 , NULL , x1 , y1 , x2 , y2 , ptr , propname , index , 0 , 0 , - 1 , - 1 , NULL ) ;
2009-02-04 11:52:16 +00:00
break ;
case PROP_STRING :
2009-06-27 01:15:31 +00:00
if ( icon & & name & & strcmp ( name , " " ) = = 0 )
but = uiDefIconButR ( block , TEX , 0 , icon , x1 , y1 , x2 , y2 , ptr , propname , index , 0 , 0 , - 1 , - 1 , NULL ) ;
else if ( icon )
but = uiDefIconTextButR ( block , TEX , 0 , icon , name , x1 , y1 , x2 , y2 , ptr , propname , index , 0 , 0 , - 1 , - 1 , NULL ) ;
else
but = uiDefButR ( block , TEX , 0 , name , x1 , y1 , x2 , y2 , ptr , propname , index , 0 , 0 , - 1 , - 1 , NULL ) ;
2009-02-04 11:52:16 +00:00
break ;
case PROP_POINTER : {
PointerRNA pptr ;
int icon ;
pptr = RNA_property_pointer_get ( ptr , prop ) ;
2009-03-13 13:38:41 +00:00
if ( ! pptr . type )
2009-06-07 13:09:18 +00:00
pptr . type = RNA_property_pointer_type ( ptr , prop ) ;
2009-06-03 23:16:51 +00:00
icon = RNA_struct_ui_icon ( pptr . type ) ;
2009-06-24 14:16:56 +00:00
if ( icon = = ICON_DOT )
icon = 0 ;
2009-03-13 13:38:41 +00:00
2009-03-30 17:31:37 +00:00
but = uiDefIconTextButR ( block , IDPOIN , 0 , icon , name , x1 , y1 , x2 , y2 , ptr , propname , index , 0 , 0 , - 1 , - 1 , NULL ) ;
2009-02-04 11:52:16 +00:00
break ;
}
case PROP_COLLECTION : {
char text [ 256 ] ;
sprintf ( text , " %d items " , RNA_property_collection_length ( ptr , prop ) ) ;
but = uiDefBut ( block , LABEL , 0 , text , x1 , y1 , x2 , y2 , NULL , 0 , 0 , 0 , 0 , NULL ) ;
uiButSetFlag ( but , UI_BUT_DISABLED ) ;
break ;
}
default :
but = NULL ;
break ;
}
return but ;
}
2009-06-24 21:27:10 +00:00
void uiDefAutoButsRNA ( const bContext * C , uiLayout * layout , PointerRNA * ptr , int columns )
2009-02-04 11:52:16 +00:00
{
2009-06-24 21:27:10 +00:00
uiLayout * split , * col ;
2009-03-25 14:34:17 +00:00
char * name ;
2009-02-04 11:52:16 +00:00
2009-06-24 21:27:10 +00:00
RNA_STRUCT_BEGIN ( ptr , prop ) {
2009-04-19 13:37:59 +00:00
if ( strcmp ( RNA_property_identifier ( prop ) , " rna_type " ) = = 0 )
2009-02-04 11:52:16 +00:00
continue ;
2009-04-19 13:37:59 +00:00
name = ( char * ) RNA_property_ui_name ( prop ) ;
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
2009-06-24 21:27:10 +00:00
if ( columns = = 1 ) {
col = uiLayoutColumn ( layout , 1 ) ;
uiItemL ( col , name , 0 ) ;
}
else if ( columns = = 2 ) {
split = uiLayoutSplit ( layout , 0.5f ) ;
2009-02-04 11:52:16 +00:00
2009-06-24 21:27:10 +00:00
uiItemL ( uiLayoutColumn ( split , 0 ) , name , 0 ) ;
col = uiLayoutColumn ( split , 0 ) ;
}
2009-07-16 04:45:52 +00:00
else
col = NULL ;
2009-02-04 11:52:16 +00:00
2009-06-01 14:08:19 +00:00
/* temp hack to show normal button for spin/screw */
if ( strcmp ( name , " Axis " ) = = 0 ) {
2009-06-24 21:27:10 +00:00
uiDefButR ( uiLayoutGetBlock ( col ) , BUT_NORMAL , 0 , name , 0 , 0 , 100 , 100 , ptr , " axis " , - 1 , 0 , 0 , - 1 , - 1 , NULL ) ;
2009-06-01 14:08:19 +00:00
}
2009-08-21 12:57:47 +00:00
else uiItemFullR ( col , " " , 0 , ptr , prop , - 1 , 0 , 0 ) ;
2.5
Summary of ain features:
- Themes and Styles are now editable.
- CTRL+U "Save user defaults" now goes to new .B25.blend, so you
can use 2.4x and 2.5x next to each other. If B25 doesn't exist, it
reads the regular .B.blend
- Press Tkey in 3d window for (unfinished) toolbar WIP. It now only
shows the last operator, if appropriate.
Nkey properties moved to the other side.
A lot of work was done on removing old themes for good and properly
getting it work with the 2.5 region system. Here's some notes;
- Buttons now all have a complete set of colors, based on button classifications
(See outliner -> user prefs -> Interface
- Theme colors have been extended with basic colors for region types.
Currently colors are defined for Window, Header, List/Channels and
for Button/Tool views.
The screen manager handles this btw, so a TH_BACK will always pick the
right backdrop color.
- Menu backdrops are in in Button theme colors. Floating Panels will be in
the per-space type Themes.
- Styles were added in RNA too, but only for the font settings now.
Only Panel font, widget font and widget-label work now. The 'group label'
will be for templates mostly.
Style settings will be expanded with spacing defaults, label conventions,
etc.
- Label text colors are stored in per-space Theme too, to make sure they fit.
Same goes for Panel title color.
Note that 'shadow' for fonts can conflict with text colors; shadow color is
currently stored in Style... shadow code needs a bit of work still.
2009-04-27 13:44:11 +00:00
}
2009-06-24 21:27:10 +00:00
RNA_STRUCT_END ;
2.5
Summary of ain features:
- Themes and Styles are now editable.
- CTRL+U "Save user defaults" now goes to new .B25.blend, so you
can use 2.4x and 2.5x next to each other. If B25 doesn't exist, it
reads the regular .B.blend
- Press Tkey in 3d window for (unfinished) toolbar WIP. It now only
shows the last operator, if appropriate.
Nkey properties moved to the other side.
A lot of work was done on removing old themes for good and properly
getting it work with the 2.5 region system. Here's some notes;
- Buttons now all have a complete set of colors, based on button classifications
(See outliner -> user prefs -> Interface
- Theme colors have been extended with basic colors for region types.
Currently colors are defined for Window, Header, List/Channels and
for Button/Tool views.
The screen manager handles this btw, so a TH_BACK will always pick the
right backdrop color.
- Menu backdrops are in in Button theme colors. Floating Panels will be in
the per-space type Themes.
- Styles were added in RNA too, but only for the font settings now.
Only Panel font, widget font and widget-label work now. The 'group label'
will be for templates mostly.
Style settings will be expanded with spacing defaults, label conventions,
etc.
- Label text colors are stored in per-space Theme too, to make sure they fit.
Same goes for Panel title color.
Note that 'shadow' for fonts can conflict with text colors; shadow color is
currently stored in Style... shadow code needs a bit of work still.
2009-04-27 13:44:11 +00:00
}
2.5: ID datablock button back, previously known as std_libbuttons. The
way this worked in 2.4x wasn't really clean, with events going all over
the place and using dubious variables such as G.but->lockpoin or
G.sima->menunr. It works as follows now, for example:
xco= uiDefIDPoinButs(block, CTX_data_main(C), NULL, (ID**)&sima->image, ID_IM, &sima->pin, xco, yco,
sima_idpoin_handle, UI_ID_BROWSE|UI_ID_RENAME|UI_ID_ADD_NEW|UI_ID_OPEN|UI_ID_DELETE|UI_ID_ALONE|UI_ID_PIN);
The last two parameters are a callback function, and a list of events
or functionalities that are supported. The callback function will then
get the ID pointer + event to handle.
2009-02-06 16:40:14 +00:00
/***************************** ID Utilities *******************************/
2009-06-11 17:21:27 +00:00
/* note, C code version, will be replaced with version in interface_templates.c */
2.5: ID datablock button back, previously known as std_libbuttons. The
way this worked in 2.4x wasn't really clean, with events going all over
the place and using dubious variables such as G.but->lockpoin or
G.sima->menunr. It works as follows now, for example:
xco= uiDefIDPoinButs(block, CTX_data_main(C), NULL, (ID**)&sima->image, ID_IM, &sima->pin, xco, yco,
sima_idpoin_handle, UI_ID_BROWSE|UI_ID_RENAME|UI_ID_ADD_NEW|UI_ID_OPEN|UI_ID_DELETE|UI_ID_ALONE|UI_ID_PIN);
The last two parameters are a callback function, and a list of events
or functionalities that are supported. The callback function will then
get the ID pointer + event to handle.
2009-02-06 16:40:14 +00:00
typedef struct uiIDPoinParams {
uiIDPoinFunc func ;
2009-06-10 11:43:21 +00:00
ListBase * lb ;
2.5: Text Editor back.
There was very little structure in this code, using many globals
and duplicated code. Now it should be better structured. Most
things should work, the main parts that are not back yet are the
python plugins and markers. Notes:
* Blenfont is used for drawing the text, nicely anti-aliased.
* A monospace truetype font was added, since that is needed for
the text editor. It's Bitstream Vera Sans Mono. This is the
default gnome terminal font, but it doesn't fit entirely well
with the other font I think, can be changed easily of course.
* Clipboard copy/cut/paste now always uses the system clipboard,
the code for the own cut buffer was removed.
* The interface buttons should support copy/cut/paste again now
as well.
* WM_clipboard_text_get/WM_clipboard_text_set were added to the
windowmanager code.
* Find panel is now a kind of second header, instead of a panel.
This needs especially a way to start editing the text field
immediately on open still.
* Operators are independent of the actual space when possible,
was a bit of puzzling but got it solved nice with notifiers,
and some lazy init for syntax highlight in the drawing code.
* RNA was created for the text editor space and used for buttons.
* Operators:
* New, Open, Reload, Save, Save As, Make Internal
* Run Script, Refresh Pyconstraints
* Copy, Cut, Paste
* Convert Whitespace, Uncomment, Comment, Indent, Unindent
* Line Break, Insert
* Next Marker, Previous Marker, Clear All Markers, Mark All
* Select Line, Select All
* Jump, Move, Move Select, Delete, Toggle Overwrite
* Scroll, Scroll Bar, Set Cursor, Line Number
* Find and Replace, Find, Replace, Find Set Selected,
Replace Set Selected
* To 3D Object
* Resolve Conflict
2009-02-28 23:33:35 +00:00
ID * id ;
2.5: ID datablock button back, previously known as std_libbuttons. The
way this worked in 2.4x wasn't really clean, with events going all over
the place and using dubious variables such as G.but->lockpoin or
G.sima->menunr. It works as follows now, for example:
xco= uiDefIDPoinButs(block, CTX_data_main(C), NULL, (ID**)&sima->image, ID_IM, &sima->pin, xco, yco,
sima_idpoin_handle, UI_ID_BROWSE|UI_ID_RENAME|UI_ID_ADD_NEW|UI_ID_OPEN|UI_ID_DELETE|UI_ID_ALONE|UI_ID_PIN);
The last two parameters are a callback function, and a list of events
or functionalities that are supported. The callback function will then
get the ID pointer + event to handle.
2009-02-06 16:40:14 +00:00
short id_code ;
short browsenr ;
} uiIDPoinParams ;
static void idpoin_cb ( bContext * C , void * arg_params , void * arg_event )
{
uiIDPoinParams * params = ( uiIDPoinParams * ) arg_params ;
2009-06-10 11:43:21 +00:00
ListBase * lb = params - > lb ;
2.5: ID datablock button back, previously known as std_libbuttons. The
way this worked in 2.4x wasn't really clean, with events going all over
the place and using dubious variables such as G.but->lockpoin or
G.sima->menunr. It works as follows now, for example:
xco= uiDefIDPoinButs(block, CTX_data_main(C), NULL, (ID**)&sima->image, ID_IM, &sima->pin, xco, yco,
sima_idpoin_handle, UI_ID_BROWSE|UI_ID_RENAME|UI_ID_ADD_NEW|UI_ID_OPEN|UI_ID_DELETE|UI_ID_ALONE|UI_ID_PIN);
The last two parameters are a callback function, and a list of events
or functionalities that are supported. The callback function will then
get the ID pointer + event to handle.
2009-02-06 16:40:14 +00:00
uiIDPoinFunc func = params - > func ;
2.5: Text Editor back.
There was very little structure in this code, using many globals
and duplicated code. Now it should be better structured. Most
things should work, the main parts that are not back yet are the
python plugins and markers. Notes:
* Blenfont is used for drawing the text, nicely anti-aliased.
* A monospace truetype font was added, since that is needed for
the text editor. It's Bitstream Vera Sans Mono. This is the
default gnome terminal font, but it doesn't fit entirely well
with the other font I think, can be changed easily of course.
* Clipboard copy/cut/paste now always uses the system clipboard,
the code for the own cut buffer was removed.
* The interface buttons should support copy/cut/paste again now
as well.
* WM_clipboard_text_get/WM_clipboard_text_set were added to the
windowmanager code.
* Find panel is now a kind of second header, instead of a panel.
This needs especially a way to start editing the text field
immediately on open still.
* Operators are independent of the actual space when possible,
was a bit of puzzling but got it solved nice with notifiers,
and some lazy init for syntax highlight in the drawing code.
* RNA was created for the text editor space and used for buttons.
* Operators:
* New, Open, Reload, Save, Save As, Make Internal
* Run Script, Refresh Pyconstraints
* Copy, Cut, Paste
* Convert Whitespace, Uncomment, Comment, Indent, Unindent
* Line Break, Insert
* Next Marker, Previous Marker, Clear All Markers, Mark All
* Select Line, Select All
* Jump, Move, Move Select, Delete, Toggle Overwrite
* Scroll, Scroll Bar, Set Cursor, Line Number
* Find and Replace, Find, Replace, Find Set Selected,
Replace Set Selected
* To 3D Object
* Resolve Conflict
2009-02-28 23:33:35 +00:00
ID * id = params - > id , * idtest ;
2.5: ID datablock button back, previously known as std_libbuttons. The
way this worked in 2.4x wasn't really clean, with events going all over
the place and using dubious variables such as G.but->lockpoin or
G.sima->menunr. It works as follows now, for example:
xco= uiDefIDPoinButs(block, CTX_data_main(C), NULL, (ID**)&sima->image, ID_IM, &sima->pin, xco, yco,
sima_idpoin_handle, UI_ID_BROWSE|UI_ID_RENAME|UI_ID_ADD_NEW|UI_ID_OPEN|UI_ID_DELETE|UI_ID_ALONE|UI_ID_PIN);
The last two parameters are a callback function, and a list of events
or functionalities that are supported. The callback function will then
get the ID pointer + event to handle.
2009-02-06 16:40:14 +00:00
int nr , event = GET_INT_FROM_POINTER ( arg_event ) ;
2.5: Text Editor back.
There was very little structure in this code, using many globals
and duplicated code. Now it should be better structured. Most
things should work, the main parts that are not back yet are the
python plugins and markers. Notes:
* Blenfont is used for drawing the text, nicely anti-aliased.
* A monospace truetype font was added, since that is needed for
the text editor. It's Bitstream Vera Sans Mono. This is the
default gnome terminal font, but it doesn't fit entirely well
with the other font I think, can be changed easily of course.
* Clipboard copy/cut/paste now always uses the system clipboard,
the code for the own cut buffer was removed.
* The interface buttons should support copy/cut/paste again now
as well.
* WM_clipboard_text_get/WM_clipboard_text_set were added to the
windowmanager code.
* Find panel is now a kind of second header, instead of a panel.
This needs especially a way to start editing the text field
immediately on open still.
* Operators are independent of the actual space when possible,
was a bit of puzzling but got it solved nice with notifiers,
and some lazy init for syntax highlight in the drawing code.
* RNA was created for the text editor space and used for buttons.
* Operators:
* New, Open, Reload, Save, Save As, Make Internal
* Run Script, Refresh Pyconstraints
* Copy, Cut, Paste
* Convert Whitespace, Uncomment, Comment, Indent, Unindent
* Line Break, Insert
* Next Marker, Previous Marker, Clear All Markers, Mark All
* Select Line, Select All
* Jump, Move, Move Select, Delete, Toggle Overwrite
* Scroll, Scroll Bar, Set Cursor, Line Number
* Find and Replace, Find, Replace, Find Set Selected,
Replace Set Selected
* To 3D Object
* Resolve Conflict
2009-02-28 23:33:35 +00:00
if ( event = = UI_ID_BROWSE & & params - > browsenr = = 32767 )
event = UI_ID_ADD_NEW ;
else if ( event = = UI_ID_BROWSE & & params - > browsenr = = 32766 )
event = UI_ID_OPEN ;
2.5: ID datablock button back, previously known as std_libbuttons. The
way this worked in 2.4x wasn't really clean, with events going all over
the place and using dubious variables such as G.but->lockpoin or
G.sima->menunr. It works as follows now, for example:
xco= uiDefIDPoinButs(block, CTX_data_main(C), NULL, (ID**)&sima->image, ID_IM, &sima->pin, xco, yco,
sima_idpoin_handle, UI_ID_BROWSE|UI_ID_RENAME|UI_ID_ADD_NEW|UI_ID_OPEN|UI_ID_DELETE|UI_ID_ALONE|UI_ID_PIN);
The last two parameters are a callback function, and a list of events
or functionalities that are supported. The callback function will then
get the ID pointer + event to handle.
2009-02-06 16:40:14 +00:00
switch ( event ) {
case UI_ID_RENAME :
if ( id ) test_idbutton ( id - > name + 2 ) ;
else return ;
break ;
case UI_ID_BROWSE : {
2009-05-20 16:23:55 +00:00
/* ID can be NULL, if nothing was assigned yet */
if ( lb - > first = = NULL ) return ;
2.5: ID datablock button back, previously known as std_libbuttons. The
way this worked in 2.4x wasn't really clean, with events going all over
the place and using dubious variables such as G.but->lockpoin or
G.sima->menunr. It works as follows now, for example:
xco= uiDefIDPoinButs(block, CTX_data_main(C), NULL, (ID**)&sima->image, ID_IM, &sima->pin, xco, yco,
sima_idpoin_handle, UI_ID_BROWSE|UI_ID_RENAME|UI_ID_ADD_NEW|UI_ID_OPEN|UI_ID_DELETE|UI_ID_ALONE|UI_ID_PIN);
The last two parameters are a callback function, and a list of events
or functionalities that are supported. The callback function will then
get the ID pointer + event to handle.
2009-02-06 16:40:14 +00:00
if ( params - > browsenr = = - 2 ) {
2009-05-20 16:23:55 +00:00
/* XXX implement or find a replacement (ID can be NULL!)
2.5: ID datablock button back, previously known as std_libbuttons. The
way this worked in 2.4x wasn't really clean, with events going all over
the place and using dubious variables such as G.but->lockpoin or
G.sima->menunr. It works as follows now, for example:
xco= uiDefIDPoinButs(block, CTX_data_main(C), NULL, (ID**)&sima->image, ID_IM, &sima->pin, xco, yco,
sima_idpoin_handle, UI_ID_BROWSE|UI_ID_RENAME|UI_ID_ADD_NEW|UI_ID_OPEN|UI_ID_DELETE|UI_ID_ALONE|UI_ID_PIN);
The last two parameters are a callback function, and a list of events
or functionalities that are supported. The callback function will then
get the ID pointer + event to handle.
2009-02-06 16:40:14 +00:00
* activate_databrowse ( ( ID * ) G . buts - > lockpoin , GS ( id - > name ) , 0 , B_MESHBROWSE , & params - > browsenr , do_global_buttons ) ; */
return ;
}
if ( params - > browsenr < 0 )
return ;
for ( idtest = lb - > first , nr = 1 ; idtest ; idtest = idtest - > next , nr + + ) {
if ( nr = = params - > browsenr ) {
2.5: Text Editor back.
There was very little structure in this code, using many globals
and duplicated code. Now it should be better structured. Most
things should work, the main parts that are not back yet are the
python plugins and markers. Notes:
* Blenfont is used for drawing the text, nicely anti-aliased.
* A monospace truetype font was added, since that is needed for
the text editor. It's Bitstream Vera Sans Mono. This is the
default gnome terminal font, but it doesn't fit entirely well
with the other font I think, can be changed easily of course.
* Clipboard copy/cut/paste now always uses the system clipboard,
the code for the own cut buffer was removed.
* The interface buttons should support copy/cut/paste again now
as well.
* WM_clipboard_text_get/WM_clipboard_text_set were added to the
windowmanager code.
* Find panel is now a kind of second header, instead of a panel.
This needs especially a way to start editing the text field
immediately on open still.
* Operators are independent of the actual space when possible,
was a bit of puzzling but got it solved nice with notifiers,
and some lazy init for syntax highlight in the drawing code.
* RNA was created for the text editor space and used for buttons.
* Operators:
* New, Open, Reload, Save, Save As, Make Internal
* Run Script, Refresh Pyconstraints
* Copy, Cut, Paste
* Convert Whitespace, Uncomment, Comment, Indent, Unindent
* Line Break, Insert
* Next Marker, Previous Marker, Clear All Markers, Mark All
* Select Line, Select All
* Jump, Move, Move Select, Delete, Toggle Overwrite
* Scroll, Scroll Bar, Set Cursor, Line Number
* Find and Replace, Find, Replace, Find Set Selected,
Replace Set Selected
* To 3D Object
* Resolve Conflict
2009-02-28 23:33:35 +00:00
if ( id = = idtest )
2.5: ID datablock button back, previously known as std_libbuttons. The
way this worked in 2.4x wasn't really clean, with events going all over
the place and using dubious variables such as G.but->lockpoin or
G.sima->menunr. It works as follows now, for example:
xco= uiDefIDPoinButs(block, CTX_data_main(C), NULL, (ID**)&sima->image, ID_IM, &sima->pin, xco, yco,
sima_idpoin_handle, UI_ID_BROWSE|UI_ID_RENAME|UI_ID_ADD_NEW|UI_ID_OPEN|UI_ID_DELETE|UI_ID_ALONE|UI_ID_PIN);
The last two parameters are a callback function, and a list of events
or functionalities that are supported. The callback function will then
get the ID pointer + event to handle.
2009-02-06 16:40:14 +00:00
return ;
2.5: Text Editor back.
There was very little structure in this code, using many globals
and duplicated code. Now it should be better structured. Most
things should work, the main parts that are not back yet are the
python plugins and markers. Notes:
* Blenfont is used for drawing the text, nicely anti-aliased.
* A monospace truetype font was added, since that is needed for
the text editor. It's Bitstream Vera Sans Mono. This is the
default gnome terminal font, but it doesn't fit entirely well
with the other font I think, can be changed easily of course.
* Clipboard copy/cut/paste now always uses the system clipboard,
the code for the own cut buffer was removed.
* The interface buttons should support copy/cut/paste again now
as well.
* WM_clipboard_text_get/WM_clipboard_text_set were added to the
windowmanager code.
* Find panel is now a kind of second header, instead of a panel.
This needs especially a way to start editing the text field
immediately on open still.
* Operators are independent of the actual space when possible,
was a bit of puzzling but got it solved nice with notifiers,
and some lazy init for syntax highlight in the drawing code.
* RNA was created for the text editor space and used for buttons.
* Operators:
* New, Open, Reload, Save, Save As, Make Internal
* Run Script, Refresh Pyconstraints
* Copy, Cut, Paste
* Convert Whitespace, Uncomment, Comment, Indent, Unindent
* Line Break, Insert
* Next Marker, Previous Marker, Clear All Markers, Mark All
* Select Line, Select All
* Jump, Move, Move Select, Delete, Toggle Overwrite
* Scroll, Scroll Bar, Set Cursor, Line Number
* Find and Replace, Find, Replace, Find Set Selected,
Replace Set Selected
* To 3D Object
* Resolve Conflict
2009-02-28 23:33:35 +00:00
id = idtest ;
2.5: ID datablock button back, previously known as std_libbuttons. The
way this worked in 2.4x wasn't really clean, with events going all over
the place and using dubious variables such as G.but->lockpoin or
G.sima->menunr. It works as follows now, for example:
xco= uiDefIDPoinButs(block, CTX_data_main(C), NULL, (ID**)&sima->image, ID_IM, &sima->pin, xco, yco,
sima_idpoin_handle, UI_ID_BROWSE|UI_ID_RENAME|UI_ID_ADD_NEW|UI_ID_OPEN|UI_ID_DELETE|UI_ID_ALONE|UI_ID_PIN);
The last two parameters are a callback function, and a list of events
or functionalities that are supported. The callback function will then
get the ID pointer + event to handle.
2009-02-06 16:40:14 +00:00
break ;
}
}
break ;
}
case UI_ID_DELETE :
2.5: Text Editor back.
There was very little structure in this code, using many globals
and duplicated code. Now it should be better structured. Most
things should work, the main parts that are not back yet are the
python plugins and markers. Notes:
* Blenfont is used for drawing the text, nicely anti-aliased.
* A monospace truetype font was added, since that is needed for
the text editor. It's Bitstream Vera Sans Mono. This is the
default gnome terminal font, but it doesn't fit entirely well
with the other font I think, can be changed easily of course.
* Clipboard copy/cut/paste now always uses the system clipboard,
the code for the own cut buffer was removed.
* The interface buttons should support copy/cut/paste again now
as well.
* WM_clipboard_text_get/WM_clipboard_text_set were added to the
windowmanager code.
* Find panel is now a kind of second header, instead of a panel.
This needs especially a way to start editing the text field
immediately on open still.
* Operators are independent of the actual space when possible,
was a bit of puzzling but got it solved nice with notifiers,
and some lazy init for syntax highlight in the drawing code.
* RNA was created for the text editor space and used for buttons.
* Operators:
* New, Open, Reload, Save, Save As, Make Internal
* Run Script, Refresh Pyconstraints
* Copy, Cut, Paste
* Convert Whitespace, Uncomment, Comment, Indent, Unindent
* Line Break, Insert
* Next Marker, Previous Marker, Clear All Markers, Mark All
* Select Line, Select All
* Jump, Move, Move Select, Delete, Toggle Overwrite
* Scroll, Scroll Bar, Set Cursor, Line Number
* Find and Replace, Find, Replace, Find Set Selected,
Replace Set Selected
* To 3D Object
* Resolve Conflict
2009-02-28 23:33:35 +00:00
id = NULL ;
2.5: ID datablock button back, previously known as std_libbuttons. The
way this worked in 2.4x wasn't really clean, with events going all over
the place and using dubious variables such as G.but->lockpoin or
G.sima->menunr. It works as follows now, for example:
xco= uiDefIDPoinButs(block, CTX_data_main(C), NULL, (ID**)&sima->image, ID_IM, &sima->pin, xco, yco,
sima_idpoin_handle, UI_ID_BROWSE|UI_ID_RENAME|UI_ID_ADD_NEW|UI_ID_OPEN|UI_ID_DELETE|UI_ID_ALONE|UI_ID_PIN);
The last two parameters are a callback function, and a list of events
or functionalities that are supported. The callback function will then
get the ID pointer + event to handle.
2009-02-06 16:40:14 +00:00
break ;
case UI_ID_FAKE_USER :
if ( id ) {
if ( id - > flag & LIB_FAKEUSER ) id - > us + + ;
else id - > us - - ;
}
else return ;
break ;
case UI_ID_PIN :
break ;
case UI_ID_ADD_NEW :
break ;
case UI_ID_OPEN :
break ;
case UI_ID_ALONE :
if ( ! id | | id - > us < 1 )
return ;
break ;
case UI_ID_LOCAL :
if ( ! id | | id - > us < 1 )
return ;
break ;
case UI_ID_AUTO_NAME :
break ;
}
if ( func )
2.5: Text Editor back.
There was very little structure in this code, using many globals
and duplicated code. Now it should be better structured. Most
things should work, the main parts that are not back yet are the
python plugins and markers. Notes:
* Blenfont is used for drawing the text, nicely anti-aliased.
* A monospace truetype font was added, since that is needed for
the text editor. It's Bitstream Vera Sans Mono. This is the
default gnome terminal font, but it doesn't fit entirely well
with the other font I think, can be changed easily of course.
* Clipboard copy/cut/paste now always uses the system clipboard,
the code for the own cut buffer was removed.
* The interface buttons should support copy/cut/paste again now
as well.
* WM_clipboard_text_get/WM_clipboard_text_set were added to the
windowmanager code.
* Find panel is now a kind of second header, instead of a panel.
This needs especially a way to start editing the text field
immediately on open still.
* Operators are independent of the actual space when possible,
was a bit of puzzling but got it solved nice with notifiers,
and some lazy init for syntax highlight in the drawing code.
* RNA was created for the text editor space and used for buttons.
* Operators:
* New, Open, Reload, Save, Save As, Make Internal
* Run Script, Refresh Pyconstraints
* Copy, Cut, Paste
* Convert Whitespace, Uncomment, Comment, Indent, Unindent
* Line Break, Insert
* Next Marker, Previous Marker, Clear All Markers, Mark All
* Select Line, Select All
* Jump, Move, Move Select, Delete, Toggle Overwrite
* Scroll, Scroll Bar, Set Cursor, Line Number
* Find and Replace, Find, Replace, Find Set Selected,
Replace Set Selected
* To 3D Object
* Resolve Conflict
2009-02-28 23:33:35 +00:00
func ( C , id , event ) ;
2.5: ID datablock button back, previously known as std_libbuttons. The
way this worked in 2.4x wasn't really clean, with events going all over
the place and using dubious variables such as G.but->lockpoin or
G.sima->menunr. It works as follows now, for example:
xco= uiDefIDPoinButs(block, CTX_data_main(C), NULL, (ID**)&sima->image, ID_IM, &sima->pin, xco, yco,
sima_idpoin_handle, UI_ID_BROWSE|UI_ID_RENAME|UI_ID_ADD_NEW|UI_ID_OPEN|UI_ID_DELETE|UI_ID_ALONE|UI_ID_PIN);
The last two parameters are a callback function, and a list of events
or functionalities that are supported. The callback function will then
get the ID pointer + event to handle.
2009-02-06 16:40:14 +00:00
}
2009-06-10 11:43:21 +00:00
/* ***************************** ID Search browse menu ********************** */
static void id_search_call_cb ( struct bContext * C , void * arg_params , void * item )
{
uiIDPoinParams * params = ( uiIDPoinParams * ) arg_params ;
if ( item & & params - > func )
params - > func ( C , item , UI_ID_BROWSE ) ;
}
static void id_search_cb ( const struct bContext * C , void * arg_params , char * str , uiSearchItems * items )
{
uiIDPoinParams * params = ( uiIDPoinParams * ) arg_params ;
ID * id ;
for ( id = params - > lb - > first ; id ; id = id - > next ) {
2009-06-24 16:44:54 +00:00
int iconid = 0 ;
/* icon */
switch ( GS ( id - > name ) )
{
case ID_MA : /* fall through */
case ID_TE : /* fall through */
case ID_IM : /* fall through */
case ID_WO : /* fall through */
case ID_LA : /* fall through */
iconid = BKE_icon_getid ( id ) ;
break ;
default :
break ;
}
2009-06-10 11:43:21 +00:00
if ( BLI_strcasestr ( id - > name + 2 , str ) ) {
2009-06-24 16:44:54 +00:00
if ( 0 = = uiSearchItemAdd ( items , id - > name + 2 , id , iconid ) )
2009-06-10 11:43:21 +00:00
break ;
}
}
}
static uiBlock * id_search_menu ( bContext * C , ARegion * ar , void * arg_params )
{
static char search [ 256 ] ;
static uiIDPoinParams params ;
wmEvent event ;
wmWindow * win = CTX_wm_window ( C ) ;
uiBlock * block ;
uiBut * but ;
/* clear initial search string, then all items show */
search [ 0 ] = 0 ;
/* params is malloced, can be freed by parent button */
params = * ( ( uiIDPoinParams * ) arg_params ) ;
block = uiBeginBlock ( C , ar , " _popup " , UI_EMBOSS ) ;
uiBlockSetFlag ( block , UI_BLOCK_LOOP | UI_BLOCK_REDRAW | UI_BLOCK_RET_1 ) ;
/* fake button, it holds space for search items */
uiDefBut ( block , LABEL , 0 , " " , 10 , 15 , 150 , uiSearchBoxhHeight ( ) , NULL , 0 , 0 , 0 , 0 , NULL ) ;
but = uiDefSearchBut ( block , search , 0 , ICON_VIEWZOOM , 256 , 10 , 0 , 150 , 19 , " " ) ;
2009-06-29 11:29:52 +00:00
uiButSetSearchFunc ( but , id_search_cb , & params , id_search_call_cb , NULL ) ;
2009-06-10 11:43:21 +00:00
uiBoundsBlock ( block , 6 ) ;
uiBlockSetDirection ( block , UI_DOWN ) ;
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 ;
}
/* ****************** */
2.5: Text Editor back.
There was very little structure in this code, using many globals
and duplicated code. Now it should be better structured. Most
things should work, the main parts that are not back yet are the
python plugins and markers. Notes:
* Blenfont is used for drawing the text, nicely anti-aliased.
* A monospace truetype font was added, since that is needed for
the text editor. It's Bitstream Vera Sans Mono. This is the
default gnome terminal font, but it doesn't fit entirely well
with the other font I think, can be changed easily of course.
* Clipboard copy/cut/paste now always uses the system clipboard,
the code for the own cut buffer was removed.
* The interface buttons should support copy/cut/paste again now
as well.
* WM_clipboard_text_get/WM_clipboard_text_set were added to the
windowmanager code.
* Find panel is now a kind of second header, instead of a panel.
This needs especially a way to start editing the text field
immediately on open still.
* Operators are independent of the actual space when possible,
was a bit of puzzling but got it solved nice with notifiers,
and some lazy init for syntax highlight in the drawing code.
* RNA was created for the text editor space and used for buttons.
* Operators:
* New, Open, Reload, Save, Save As, Make Internal
* Run Script, Refresh Pyconstraints
* Copy, Cut, Paste
* Convert Whitespace, Uncomment, Comment, Indent, Unindent
* Line Break, Insert
* Next Marker, Previous Marker, Clear All Markers, Mark All
* Select Line, Select All
* Jump, Move, Move Select, Delete, Toggle Overwrite
* Scroll, Scroll Bar, Set Cursor, Line Number
* Find and Replace, Find, Replace, Find Set Selected,
Replace Set Selected
* To 3D Object
* Resolve Conflict
2009-02-28 23:33:35 +00:00
int uiDefIDPoinButs ( uiBlock * block , Main * bmain , ID * parid , ID * id , int id_code , short * pin_p , int x , int y , uiIDPoinFunc func , int events )
2.5: ID datablock button back, previously known as std_libbuttons. The
way this worked in 2.4x wasn't really clean, with events going all over
the place and using dubious variables such as G.but->lockpoin or
G.sima->menunr. It works as follows now, for example:
xco= uiDefIDPoinButs(block, CTX_data_main(C), NULL, (ID**)&sima->image, ID_IM, &sima->pin, xco, yco,
sima_idpoin_handle, UI_ID_BROWSE|UI_ID_RENAME|UI_ID_ADD_NEW|UI_ID_OPEN|UI_ID_DELETE|UI_ID_ALONE|UI_ID_PIN);
The last two parameters are a callback function, and a list of events
or functionalities that are supported. The callback function will then
get the ID pointer + event to handle.
2009-02-06 16:40:14 +00:00
{
uiBut * but ;
uiIDPoinParams * params , * dup_params ;
2009-06-10 11:43:21 +00:00
char str1 [ 10 ] ;
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
int len , add_addbutton = 0 ;
2.5: ID datablock button back, previously known as std_libbuttons. The
way this worked in 2.4x wasn't really clean, with events going all over
the place and using dubious variables such as G.but->lockpoin or
G.sima->menunr. It works as follows now, for example:
xco= uiDefIDPoinButs(block, CTX_data_main(C), NULL, (ID**)&sima->image, ID_IM, &sima->pin, xco, yco,
sima_idpoin_handle, UI_ID_BROWSE|UI_ID_RENAME|UI_ID_ADD_NEW|UI_ID_OPEN|UI_ID_DELETE|UI_ID_ALONE|UI_ID_PIN);
The last two parameters are a callback function, and a list of events
or functionalities that are supported. The callback function will then
get the ID pointer + event to handle.
2009-02-06 16:40:14 +00:00
/* setup struct that we will pass on with the buttons */
params = MEM_callocN ( sizeof ( uiIDPoinParams ) , " uiIDPoinParams " ) ;
2009-06-10 11:43:21 +00:00
params - > lb = wich_libbase ( bmain , id_code ) ;
2.5: Text Editor back.
There was very little structure in this code, using many globals
and duplicated code. Now it should be better structured. Most
things should work, the main parts that are not back yet are the
python plugins and markers. Notes:
* Blenfont is used for drawing the text, nicely anti-aliased.
* A monospace truetype font was added, since that is needed for
the text editor. It's Bitstream Vera Sans Mono. This is the
default gnome terminal font, but it doesn't fit entirely well
with the other font I think, can be changed easily of course.
* Clipboard copy/cut/paste now always uses the system clipboard,
the code for the own cut buffer was removed.
* The interface buttons should support copy/cut/paste again now
as well.
* WM_clipboard_text_get/WM_clipboard_text_set were added to the
windowmanager code.
* Find panel is now a kind of second header, instead of a panel.
This needs especially a way to start editing the text field
immediately on open still.
* Operators are independent of the actual space when possible,
was a bit of puzzling but got it solved nice with notifiers,
and some lazy init for syntax highlight in the drawing code.
* RNA was created for the text editor space and used for buttons.
* Operators:
* New, Open, Reload, Save, Save As, Make Internal
* Run Script, Refresh Pyconstraints
* Copy, Cut, Paste
* Convert Whitespace, Uncomment, Comment, Indent, Unindent
* Line Break, Insert
* Next Marker, Previous Marker, Clear All Markers, Mark All
* Select Line, Select All
* Jump, Move, Move Select, Delete, Toggle Overwrite
* Scroll, Scroll Bar, Set Cursor, Line Number
* Find and Replace, Find, Replace, Find Set Selected,
Replace Set Selected
* To 3D Object
* Resolve Conflict
2009-02-28 23:33:35 +00:00
params - > id = id ;
2.5: ID datablock button back, previously known as std_libbuttons. The
way this worked in 2.4x wasn't really clean, with events going all over
the place and using dubious variables such as G.but->lockpoin or
G.sima->menunr. It works as follows now, for example:
xco= uiDefIDPoinButs(block, CTX_data_main(C), NULL, (ID**)&sima->image, ID_IM, &sima->pin, xco, yco,
sima_idpoin_handle, UI_ID_BROWSE|UI_ID_RENAME|UI_ID_ADD_NEW|UI_ID_OPEN|UI_ID_DELETE|UI_ID_ALONE|UI_ID_PIN);
The last two parameters are a callback function, and a list of events
or functionalities that are supported. The callback function will then
get the ID pointer + event to handle.
2009-02-06 16:40:14 +00:00
params - > id_code = id_code ;
params - > func = func ;
/* create buttons */
uiBlockBeginAlign ( block ) ;
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
/* XXX solve?
2.5: ID datablock button back, previously known as std_libbuttons. The
way this worked in 2.4x wasn't really clean, with events going all over
the place and using dubious variables such as G.but->lockpoin or
G.sima->menunr. It works as follows now, for example:
xco= uiDefIDPoinButs(block, CTX_data_main(C), NULL, (ID**)&sima->image, ID_IM, &sima->pin, xco, yco,
sima_idpoin_handle, UI_ID_BROWSE|UI_ID_RENAME|UI_ID_ADD_NEW|UI_ID_OPEN|UI_ID_DELETE|UI_ID_ALONE|UI_ID_PIN);
The last two parameters are a callback function, and a list of events
or functionalities that are supported. The callback function will then
get the ID pointer + event to handle.
2009-02-06 16:40:14 +00:00
if ( id & & id - > us > 1 )
uiBlockSetCol ( block , TH_BUT_SETTING1 ) ;
if ( ( events & UI_ID_PIN ) & & * pin_p )
uiBlockSetCol ( block , TH_BUT_SETTING2 ) ;
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
*/
2.5: ID datablock button back, previously known as std_libbuttons. The
way this worked in 2.4x wasn't really clean, with events going all over
the place and using dubious variables such as G.but->lockpoin or
G.sima->menunr. It works as follows now, for example:
xco= uiDefIDPoinButs(block, CTX_data_main(C), NULL, (ID**)&sima->image, ID_IM, &sima->pin, xco, yco,
sima_idpoin_handle, UI_ID_BROWSE|UI_ID_RENAME|UI_ID_ADD_NEW|UI_ID_OPEN|UI_ID_DELETE|UI_ID_ALONE|UI_ID_PIN);
The last two parameters are a callback function, and a list of events
or functionalities that are supported. The callback function will then
get the ID pointer + event to handle.
2009-02-06 16:40:14 +00:00
/* pin button */
if ( id & & ( events & UI_ID_PIN ) ) {
2009-02-07 14:03:34 +00:00
but = uiDefIconButS ( block , ICONTOG , ( events & UI_ID_PIN ) , ICON_KEY_DEHLT , x , y , DEF_ICON_BUT_WIDTH , DEF_BUT_HEIGHT , pin_p , 0 , 0 , 0 , 0 , " Keeps this view displaying the current data regardless of what object is selected " ) ;
2.5: ID datablock button back, previously known as std_libbuttons. The
way this worked in 2.4x wasn't really clean, with events going all over
the place and using dubious variables such as G.but->lockpoin or
G.sima->menunr. It works as follows now, for example:
xco= uiDefIDPoinButs(block, CTX_data_main(C), NULL, (ID**)&sima->image, ID_IM, &sima->pin, xco, yco,
sima_idpoin_handle, UI_ID_BROWSE|UI_ID_RENAME|UI_ID_ADD_NEW|UI_ID_OPEN|UI_ID_DELETE|UI_ID_ALONE|UI_ID_PIN);
The last two parameters are a callback function, and a list of events
or functionalities that are supported. The callback function will then
get the ID pointer + event to handle.
2009-02-06 16:40:14 +00:00
uiButSetNFunc ( but , idpoin_cb , MEM_dupallocN ( params ) , SET_INT_IN_POINTER ( UI_ID_PIN ) ) ;
x + = DEF_ICON_BUT_WIDTH ;
}
/* browse menu */
if ( events & UI_ID_BROWSE ) {
2009-06-10 11:43:21 +00:00
uiDefBlockButN ( block , id_search_menu , MEM_dupallocN ( params ) , " " , x , y , DEF_ICON_BUT_WIDTH , DEF_BUT_HEIGHT , " Browse ID data " ) ;
2.5: ID datablock button back, previously known as std_libbuttons. The
way this worked in 2.4x wasn't really clean, with events going all over
the place and using dubious variables such as G.but->lockpoin or
G.sima->menunr. It works as follows now, for example:
xco= uiDefIDPoinButs(block, CTX_data_main(C), NULL, (ID**)&sima->image, ID_IM, &sima->pin, xco, yco,
sima_idpoin_handle, UI_ID_BROWSE|UI_ID_RENAME|UI_ID_ADD_NEW|UI_ID_OPEN|UI_ID_DELETE|UI_ID_ALONE|UI_ID_PIN);
The last two parameters are a callback function, and a list of events
or functionalities that are supported. The callback function will then
get the ID pointer + event to handle.
2009-02-06 16:40:14 +00:00
x + = DEF_ICON_BUT_WIDTH ;
}
2009-06-10 11:43:21 +00:00
2.5: ID datablock button back, previously known as std_libbuttons. The
way this worked in 2.4x wasn't really clean, with events going all over
the place and using dubious variables such as G.but->lockpoin or
G.sima->menunr. It works as follows now, for example:
xco= uiDefIDPoinButs(block, CTX_data_main(C), NULL, (ID**)&sima->image, ID_IM, &sima->pin, xco, yco,
sima_idpoin_handle, UI_ID_BROWSE|UI_ID_RENAME|UI_ID_ADD_NEW|UI_ID_OPEN|UI_ID_DELETE|UI_ID_ALONE|UI_ID_PIN);
The last two parameters are a callback function, and a list of events
or functionalities that are supported. The callback function will then
get the ID pointer + event to handle.
2009-02-06 16:40:14 +00:00
/* text button with name */
if ( id ) {
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
/* XXX solve?
2.5: ID datablock button back, previously known as std_libbuttons. The
way this worked in 2.4x wasn't really clean, with events going all over
the place and using dubious variables such as G.but->lockpoin or
G.sima->menunr. It works as follows now, for example:
xco= uiDefIDPoinButs(block, CTX_data_main(C), NULL, (ID**)&sima->image, ID_IM, &sima->pin, xco, yco,
sima_idpoin_handle, UI_ID_BROWSE|UI_ID_RENAME|UI_ID_ADD_NEW|UI_ID_OPEN|UI_ID_DELETE|UI_ID_ALONE|UI_ID_PIN);
The last two parameters are a callback function, and a list of events
or functionalities that are supported. The callback function will then
get the ID pointer + event to handle.
2009-02-06 16:40:14 +00:00
if ( id - > us > 1 )
uiBlockSetCol ( block , TH_BUT_SETTING1 ) ;
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
*/
/* pinned data?
2.5: ID datablock button back, previously known as std_libbuttons. The
way this worked in 2.4x wasn't really clean, with events going all over
the place and using dubious variables such as G.but->lockpoin or
G.sima->menunr. It works as follows now, for example:
xco= uiDefIDPoinButs(block, CTX_data_main(C), NULL, (ID**)&sima->image, ID_IM, &sima->pin, xco, yco,
sima_idpoin_handle, UI_ID_BROWSE|UI_ID_RENAME|UI_ID_ADD_NEW|UI_ID_OPEN|UI_ID_DELETE|UI_ID_ALONE|UI_ID_PIN);
The last two parameters are a callback function, and a list of events
or functionalities that are supported. The callback function will then
get the ID pointer + event to handle.
2009-02-06 16:40:14 +00:00
if ( ( events & UI_ID_PIN ) & & * pin_p )
uiBlockSetCol ( block , TH_BUT_SETTING2 ) ;
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
*/
/* redalert overrides pin color
2.5: ID datablock button back, previously known as std_libbuttons. The
way this worked in 2.4x wasn't really clean, with events going all over
the place and using dubious variables such as G.but->lockpoin or
G.sima->menunr. It works as follows now, for example:
xco= uiDefIDPoinButs(block, CTX_data_main(C), NULL, (ID**)&sima->image, ID_IM, &sima->pin, xco, yco,
sima_idpoin_handle, UI_ID_BROWSE|UI_ID_RENAME|UI_ID_ADD_NEW|UI_ID_OPEN|UI_ID_DELETE|UI_ID_ALONE|UI_ID_PIN);
The last two parameters are a callback function, and a list of events
or functionalities that are supported. The callback function will then
get the ID pointer + event to handle.
2009-02-06 16:40:14 +00:00
if ( id - > us < = 0 )
uiBlockSetCol ( block , TH_REDALERT ) ;
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
*/
2.5: ID datablock button back, previously known as std_libbuttons. The
way this worked in 2.4x wasn't really clean, with events going all over
the place and using dubious variables such as G.but->lockpoin or
G.sima->menunr. It works as follows now, for example:
xco= uiDefIDPoinButs(block, CTX_data_main(C), NULL, (ID**)&sima->image, ID_IM, &sima->pin, xco, yco,
sima_idpoin_handle, UI_ID_BROWSE|UI_ID_RENAME|UI_ID_ADD_NEW|UI_ID_OPEN|UI_ID_DELETE|UI_ID_ALONE|UI_ID_PIN);
The last two parameters are a callback function, and a list of events
or functionalities that are supported. The callback function will then
get the ID pointer + event to handle.
2009-02-06 16:40:14 +00:00
uiBlockSetButLock ( block , id - > lib ! = 0 , " Can't edit external libdata " ) ;
/* name button */
2009-04-22 18:39:44 +00:00
text_idbutton ( id , str1 ) ;
2.5: ID datablock button back, previously known as std_libbuttons. The
way this worked in 2.4x wasn't really clean, with events going all over
the place and using dubious variables such as G.but->lockpoin or
G.sima->menunr. It works as follows now, for example:
xco= uiDefIDPoinButs(block, CTX_data_main(C), NULL, (ID**)&sima->image, ID_IM, &sima->pin, xco, yco,
sima_idpoin_handle, UI_ID_BROWSE|UI_ID_RENAME|UI_ID_ADD_NEW|UI_ID_OPEN|UI_ID_DELETE|UI_ID_ALONE|UI_ID_PIN);
The last two parameters are a callback function, and a list of events
or functionalities that are supported. The callback function will then
get the ID pointer + event to handle.
2009-02-06 16:40:14 +00:00
if ( GS ( id - > name ) = = ID_IP ) len = 110 ;
else if ( ( y ) & & ( GS ( id - > name ) = = ID_AC ) ) len = 100 ; // comes from button panel (poselib)
else if ( y ) len = 140 ; // comes from button panel
else len = 120 ;
but = uiDefBut ( block , TEX , 0 , str1 , x , y , ( short ) len , DEF_BUT_HEIGHT , id - > name + 2 , 0.0 , 21.0 , 0 , 0 , " Displays current Datablock name. Click to change. " ) ;
uiButSetNFunc ( but , idpoin_cb , MEM_dupallocN ( params ) , SET_INT_IN_POINTER ( UI_ID_RENAME ) ) ;
x + = len ;
uiBlockClearButLock ( block ) ;
/* lib make local button */
if ( id - > lib ) {
if ( id - > flag & LIB_INDIRECT ) uiDefIconBut ( block , BUT , 0 , 0 /* XXX ICON_DATALIB */ , x , y , DEF_ICON_BUT_WIDTH , DEF_BUT_HEIGHT , 0 , 0 , 0 , 0 , 0 , " Indirect Library Datablock. Cannot change. " ) ;
else {
but = uiDefIconBut ( block , BUT , 0 , 0 /* XXX ICON_PARLIB */ , x , y , DEF_ICON_BUT_WIDTH , DEF_BUT_HEIGHT , 0 , 0 , 0 , 0 , 0 ,
( events & UI_ID_LOCAL ) ? " Direct linked Library Datablock. Click to make local. " : " Direct linked Library Datablock, cannot make local. " ) ;
uiButSetNFunc ( but , idpoin_cb , MEM_dupallocN ( params ) , SET_INT_IN_POINTER ( UI_ID_ALONE ) ) ;
}
x + = DEF_ICON_BUT_WIDTH ;
}
/* number of users / make local button */
if ( ( events & UI_ID_ALONE ) & & id - > us > 1 ) {
int butwidth ;
uiBlockSetButLock ( block , ( events & UI_ID_PIN ) & & * pin_p , " Can't make pinned data single-user " ) ;
sprintf ( str1 , " %d " , id - > us ) ;
butwidth = ( id - > us < 10 ) ? DEF_ICON_BUT_WIDTH : DEF_ICON_BUT_WIDTH + 10 ;
but = uiDefBut ( block , BUT , 0 , str1 , x , y , butwidth , DEF_BUT_HEIGHT , 0 , 0 , 0 , 0 , 0 , " Displays number of users of this data. Click to make a single-user copy. " ) ;
uiButSetNFunc ( but , idpoin_cb , MEM_dupallocN ( params ) , SET_INT_IN_POINTER ( UI_ID_ALONE ) ) ;
x + = butwidth ;
uiBlockClearButLock ( block ) ;
}
2009-08-25 04:32:40 +00:00
/* add button */
if ( events & UI_ID_ADD_NEW ) {
uiBlockSetButLock ( block , ( events & UI_ID_PIN ) & & * pin_p , " Can't unlink pinned data " ) ;
if ( parid & & parid - > lib ) ;
else {
dup_params = MEM_dupallocN ( params ) ;
but = uiDefIconBut ( block , BUT , 0 , ICON_ZOOMIN , x , y , DEF_ICON_BUT_WIDTH , DEF_BUT_HEIGHT , & dup_params - > browsenr , params - > browsenr , 32767.0 , 0 , 0 , " Add new data block " ) ;
uiButSetNFunc ( but , idpoin_cb , MEM_dupallocN ( params ) , SET_INT_IN_POINTER ( UI_ID_ADD_NEW ) ) ;
x + = DEF_ICON_BUT_WIDTH ;
}
uiBlockClearButLock ( block ) ;
}
2.5: ID datablock button back, previously known as std_libbuttons. The
way this worked in 2.4x wasn't really clean, with events going all over
the place and using dubious variables such as G.but->lockpoin or
G.sima->menunr. It works as follows now, for example:
xco= uiDefIDPoinButs(block, CTX_data_main(C), NULL, (ID**)&sima->image, ID_IM, &sima->pin, xco, yco,
sima_idpoin_handle, UI_ID_BROWSE|UI_ID_RENAME|UI_ID_ADD_NEW|UI_ID_OPEN|UI_ID_DELETE|UI_ID_ALONE|UI_ID_PIN);
The last two parameters are a callback function, and a list of events
or functionalities that are supported. The callback function will then
get the ID pointer + event to handle.
2009-02-06 16:40:14 +00:00
/* delete button */
if ( events & UI_ID_DELETE ) {
uiBlockSetButLock ( block , ( events & UI_ID_PIN ) & & * pin_p , " Can't unlink pinned data " ) ;
if ( parid & & parid - > lib ) ;
else {
but = uiDefIconBut ( block , BUT , 0 , ICON_X , x , y , DEF_ICON_BUT_WIDTH , DEF_BUT_HEIGHT , 0 , 0 , 0 , 0 , 0 , " Deletes link to this Datablock " ) ;
uiButSetNFunc ( but , idpoin_cb , MEM_dupallocN ( params ) , SET_INT_IN_POINTER ( UI_ID_DELETE ) ) ;
x + = DEF_ICON_BUT_WIDTH ;
}
uiBlockClearButLock ( block ) ;
}
/* auto name button */
if ( events & UI_ID_AUTO_NAME ) {
if ( parid & & parid - > lib ) ;
else {
but = uiDefIconBut ( block , BUT , 0 , ICON_AUTO , x , y , DEF_ICON_BUT_WIDTH , DEF_BUT_HEIGHT , 0 , 0 , 0 , 0 , 0 , " Generates an automatic name " ) ;
uiButSetNFunc ( but , idpoin_cb , MEM_dupallocN ( params ) , SET_INT_IN_POINTER ( UI_ID_AUTO_NAME ) ) ;
x + = DEF_ICON_BUT_WIDTH ;
}
}
/* fake user button */
if ( events & UI_ID_FAKE_USER ) {
but = uiDefButBitS ( block , TOG , LIB_FAKEUSER , 0 , " F " , x , y , DEF_ICON_BUT_WIDTH , DEF_BUT_HEIGHT , & id - > flag , 0 , 0 , 0 , 0 , " Saves this datablock even if it has no users " ) ;
uiButSetNFunc ( but , idpoin_cb , MEM_dupallocN ( params ) , SET_INT_IN_POINTER ( UI_ID_FAKE_USER ) ) ;
x + = DEF_ICON_BUT_WIDTH ;
}
}
/* add new button */
else if ( add_addbutton ) {
if ( parid ) uiBlockSetButLock ( block , parid - > lib ! = 0 , " Can't edit external libdata " ) ;
dup_params = MEM_dupallocN ( params ) ;
but = uiDefButS ( block , TOG , 0 , " Add New " , x , y , 110 , DEF_BUT_HEIGHT , & dup_params - > browsenr , params - > browsenr , 32767.0 , 0 , 0 , " Add new data block " ) ;
uiButSetNFunc ( but , idpoin_cb , dup_params , SET_INT_IN_POINTER ( UI_ID_ADD_NEW ) ) ;
x + = 110 ;
}
uiBlockEndAlign ( block ) ;
MEM_freeN ( params ) ;
return x ;
}
2009-02-04 11:52:16 +00:00
2009-09-16 01:15:30 +00:00
/* currently only object-data types */
int uiIconFromID ( ID * id )
{
if ( id = = NULL )
return 0 ;
switch ( GS ( id - > name ) ) {
case ID_OB :
{
Object * ob = ( Object * ) id ;
switch ( ob - > type ) {
case OB_EMPTY :
return ICON_EMPTY_DATA ;
case OB_CURVE :
return ICON_CURVE_DATA ;
case OB_SURF :
return ICON_SURFACE_DATA ;
case OB_FONT :
return ICON_FONT_DATA ;
}
return uiIconFromID ( ob - > data ) ;
}
case ID_ME :
return ICON_MESH_DATA ;
case ID_AR :
return ICON_ARMATURE_DATA ;
case ID_MB :
return ICON_META_DATA ;
case ID_CA :
return ICON_CAMERA_DATA ;
case ID_LT :
return ICON_LATTICE_DATA ;
case ID_CU :
return ICON_CURVE_DATA ;
case ID_LA :
{
Lamp * la = ( Lamp * ) id ;
switch ( la - > type ) {
case LA_LOCAL :
return ICON_LAMP_POINT ;
case LA_SUN :
return ICON_LAMP_SUN ;
case LA_SPOT :
return ICON_LAMP_SPOT ;
case LA_HEMI :
return ICON_LAMP_HEMI ;
case LA_AREA :
return ICON_LAMP_AREA ;
}
return ICON_LAMP_DATA ;
}
}
return 0 ;
}
2.5
Smaller jobs, all in one commit!
- Moved object_do_update out of view3d drawing, into
the event system (currently after notifiers).
Depsgraph calls for setting update flags will have to
keep track of each Screen's needs, so a UI showing only
a Sequencer doesn't do objects.
- Added button in "Properties region" in 3D window to set
or disable 4-split, including the 3 options it has.
(lock, box, clip)
- Restored legacy code for UI, to make things work like
bone rename, autocomplete.
- Node editor now shows Curves widgets again
- Bugfix: composite job increased Viewer user id count
- Bugfix: Node editor, not "Enable nodes" still called
a Job, which didn't do anything
- Various code cleaning, unused vars and prototypes.
2009-02-11 16:54:55 +00:00
/* ****************************** default button callbacks ******************* */
/* ************ LEGACY WARNING, only to get things work with 2.48 code! ****** */
void test_idbutton_cb ( struct bContext * C , void * namev , void * arg2 )
{
char * name = namev ;
test_idbutton ( name + 2 ) ;
}
void test_scriptpoin_but ( struct bContext * C , char * name , ID * * idpp )
{
ID * id ;
id = CTX_data_main ( C ) - > text . first ;
while ( id ) {
if ( strcmp ( name , id - > name + 2 ) = = 0 ) {
* idpp = id ;
return ;
}
id = id - > next ;
}
* idpp = NULL ;
}
void test_actionpoin_but ( struct bContext * C , char * name , ID * * idpp )
{
ID * id ;
id = CTX_data_main ( C ) - > action . first ;
while ( id ) {
if ( strcmp ( name , id - > name + 2 ) = = 0 ) {
id_us_plus ( id ) ;
* idpp = id ;
return ;
}
id = id - > next ;
}
* idpp = NULL ;
}
void test_obpoin_but ( struct bContext * C , char * name , ID * * idpp )
{
ID * id ;
// XXX if(idpp == (ID **)&(emptytex.object)) {
// error("You must add a texture first");
// *idpp= 0;
// return;
// }
id = CTX_data_main ( C ) - > object . first ;
while ( id ) {
if ( strcmp ( name , id - > name + 2 ) = = 0 ) {
* idpp = id ;
id_lib_extern ( id ) ; /* checks lib data, sets correct flag for saving then */
return ;
}
id = id - > next ;
}
* idpp = NULL ;
}
/* tests for an object of type OB_MESH */
void test_meshobpoin_but ( struct bContext * C , char * name , ID * * idpp )
{
ID * id ;
id = CTX_data_main ( C ) - > object . first ;
while ( id ) {
Object * ob = ( Object * ) id ;
if ( ob - > type = = OB_MESH & & strcmp ( name , id - > name + 2 ) = = 0 ) {
* idpp = id ;
/* checks lib data, sets correct flag for saving then */
id_lib_extern ( id ) ;
return ;
}
id = id - > next ;
}
* idpp = NULL ;
}
void test_meshpoin_but ( struct bContext * C , char * name , ID * * idpp )
{
ID * id ;
if ( * idpp ) ( * idpp ) - > us - - ;
id = CTX_data_main ( C ) - > mesh . first ;
while ( id ) {
if ( strcmp ( name , id - > name + 2 ) = = 0 ) {
* idpp = id ;
id_us_plus ( id ) ;
return ;
}
id = id - > next ;
}
* idpp = NULL ;
}
void test_matpoin_but ( struct bContext * C , char * name , ID * * idpp )
{
ID * id ;
if ( * idpp ) ( * idpp ) - > us - - ;
id = CTX_data_main ( C ) - > mat . first ;
while ( id ) {
if ( strcmp ( name , id - > name + 2 ) = = 0 ) {
* idpp = id ;
id_us_plus ( id ) ;
return ;
}
id = id - > next ;
}
* idpp = NULL ;
}
void test_scenepoin_but ( struct bContext * C , char * name , ID * * idpp )
{
ID * id ;
if ( * idpp ) ( * idpp ) - > us - - ;
id = CTX_data_main ( C ) - > scene . first ;
while ( id ) {
if ( strcmp ( name , id - > name + 2 ) = = 0 ) {
* idpp = id ;
id_us_plus ( id ) ;
return ;
}
id = id - > next ;
}
* idpp = NULL ;
}
void test_grouppoin_but ( struct bContext * C , char * name , ID * * idpp )
{
ID * id ;
if ( * idpp ) ( * idpp ) - > us - - ;
id = CTX_data_main ( C ) - > group . first ;
while ( id ) {
if ( strcmp ( name , id - > name + 2 ) = = 0 ) {
* idpp = id ;
id_us_plus ( id ) ;
return ;
}
id = id - > next ;
}
* idpp = NULL ;
}
void test_texpoin_but ( struct bContext * C , char * name , ID * * idpp )
{
ID * id ;
if ( * idpp ) ( * idpp ) - > us - - ;
id = CTX_data_main ( C ) - > tex . first ;
while ( id ) {
if ( strcmp ( name , id - > name + 2 ) = = 0 ) {
* idpp = id ;
id_us_plus ( id ) ;
return ;
}
id = id - > next ;
}
* idpp = NULL ;
}
void test_imapoin_but ( struct bContext * C , char * name , ID * * idpp )
{
ID * id ;
if ( * idpp ) ( * idpp ) - > us - - ;
id = CTX_data_main ( C ) - > image . first ;
while ( id ) {
if ( strcmp ( name , id - > name + 2 ) = = 0 ) {
* idpp = id ;
id_us_plus ( id ) ;
return ;
}
id = id - > next ;
}
* idpp = NULL ;
}
/* autocomplete callback for buttons */
void autocomplete_bone ( struct bContext * C , char * str , void * arg_v )
{
Object * ob = ( Object * ) arg_v ;
if ( ob = = NULL | | ob - > pose = = NULL ) return ;
/* search if str matches the beginning of name */
if ( str [ 0 ] ) {
AutoComplete * autocpl = autocomplete_begin ( str , 32 ) ;
bPoseChannel * pchan ;
for ( pchan = ob - > pose - > chanbase . first ; pchan ; pchan = pchan - > next )
autocomplete_do_name ( autocpl , pchan - > name ) ;
autocomplete_end ( autocpl , str ) ;
}
}
/* autocomplete callback for buttons */
void autocomplete_vgroup ( struct bContext * C , char * str , void * arg_v )
{
Object * ob = ( Object * ) arg_v ;
if ( ob = = NULL ) return ;
/* search if str matches the beginning of a name */
if ( str [ 0 ] ) {
AutoComplete * autocpl = autocomplete_begin ( str , 32 ) ;
bDeformGroup * dg ;
for ( dg = ob - > defbase . first ; dg ; dg = dg - > next )
if ( dg - > name ! = str )
autocomplete_do_name ( autocpl , dg - > name ) ;
autocomplete_end ( autocpl , str ) ;
}
}
/* ----------- custom button group ---------------------- */
static void curvemap_buttons_zoom_in ( bContext * C , void * cumap_v , void * unused )
{
CurveMapping * cumap = cumap_v ;
float d ;
/* we allow 20 times zoom */
if ( ( cumap - > curr . xmax - cumap - > curr . xmin ) > 0.04f * ( cumap - > clipr . xmax - cumap - > clipr . xmin ) ) {
d = 0.1154f * ( cumap - > curr . xmax - cumap - > curr . xmin ) ;
cumap - > curr . xmin + = d ;
cumap - > curr . xmax - = d ;
d = 0.1154f * ( cumap - > curr . ymax - cumap - > curr . ymin ) ;
cumap - > curr . ymin + = d ;
cumap - > curr . ymax - = d ;
}
}
static void curvemap_buttons_zoom_out ( bContext * C , void * cumap_v , void * unused )
{
CurveMapping * cumap = cumap_v ;
float d , d1 ;
/* we allow 20 times zoom, but dont view outside clip */
if ( ( cumap - > curr . xmax - cumap - > curr . xmin ) < 20.0f * ( cumap - > clipr . xmax - cumap - > clipr . xmin ) ) {
d = d1 = 0.15f * ( cumap - > curr . xmax - cumap - > curr . xmin ) ;
if ( cumap - > flag & CUMA_DO_CLIP )
if ( cumap - > curr . xmin - d < cumap - > clipr . xmin )
d1 = cumap - > curr . xmin - cumap - > clipr . xmin ;
cumap - > curr . xmin - = d1 ;
d1 = d ;
if ( cumap - > flag & CUMA_DO_CLIP )
if ( cumap - > curr . xmax + d > cumap - > clipr . xmax )
d1 = - cumap - > curr . xmax + cumap - > clipr . xmax ;
cumap - > curr . xmax + = d1 ;
d = d1 = 0.15f * ( cumap - > curr . ymax - cumap - > curr . ymin ) ;
if ( cumap - > flag & CUMA_DO_CLIP )
if ( cumap - > curr . ymin - d < cumap - > clipr . ymin )
d1 = cumap - > curr . ymin - cumap - > clipr . ymin ;
cumap - > curr . ymin - = d1 ;
d1 = d ;
if ( cumap - > flag & CUMA_DO_CLIP )
if ( cumap - > curr . ymax + d > cumap - > clipr . ymax )
d1 = - cumap - > curr . ymax + cumap - > clipr . ymax ;
cumap - > curr . ymax + = d1 ;
}
}
static void curvemap_buttons_setclip ( bContext * C , void * cumap_v , void * unused )
{
CurveMapping * cumap = cumap_v ;
curvemapping_changed ( cumap , 0 ) ;
}
static void curvemap_buttons_delete ( bContext * C , void * cumap_v , void * unused )
{
CurveMapping * cumap = cumap_v ;
curvemap_remove ( cumap - > cm + cumap - > cur , SELECT ) ;
curvemapping_changed ( cumap , 0 ) ;
}
/* NOTE: this is a block-menu, needs 0 events, otherwise the menu closes */
static uiBlock * curvemap_clipping_func ( struct bContext * C , struct ARegion * ar , void * cumap_v )
{
CurveMapping * cumap = cumap_v ;
uiBlock * block ;
uiBut * bt ;
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 , " curvemap_clipping_func " , UI_EMBOSS ) ;
2.5
Smaller jobs, all in one commit!
- Moved object_do_update out of view3d drawing, into
the event system (currently after notifiers).
Depsgraph calls for setting update flags will have to
keep track of each Screen's needs, so a UI showing only
a Sequencer doesn't do objects.
- Added button in "Properties region" in 3D window to set
or disable 4-split, including the 3 options it has.
(lock, box, clip)
- Restored legacy code for UI, to make things work like
bone rename, autocomplete.
- Node editor now shows Curves widgets again
- Bugfix: composite job increased Viewer user id count
- Bugfix: Node editor, not "Enable nodes" still called
a Job, which didn't do anything
- Various code cleaning, unused vars and prototypes.
2009-02-11 16:54:55 +00:00
/* use this for a fake extra empy space around the buttons */
uiDefBut ( block , LABEL , 0 , " " , - 4 , 16 , 128 , 106 , NULL , 0 , 0 , 0 , 0 , " " ) ;
bt = uiDefButBitI ( block , TOG , CUMA_DO_CLIP , 1 , " Use Clipping " ,
0 , 100 , 120 , 18 , & cumap - > flag , 0.0 , 0.0 , 10 , 0 , " " ) ;
uiButSetFunc ( bt , curvemap_buttons_setclip , cumap , NULL ) ;
uiBlockBeginAlign ( block ) ;
uiDefButF ( block , NUM , 0 , " Min X " , 0 , 74 , 120 , 18 , & cumap - > clipr . xmin , - 100.0 , cumap - > clipr . xmax , 10 , 0 , " " ) ;
uiDefButF ( block , NUM , 0 , " Min Y " , 0 , 56 , 120 , 18 , & cumap - > clipr . ymin , - 100.0 , cumap - > clipr . ymax , 10 , 0 , " " ) ;
uiDefButF ( block , NUM , 0 , " Max X " , 0 , 38 , 120 , 18 , & cumap - > clipr . xmax , cumap - > clipr . xmin , 100.0 , 10 , 0 , " " ) ;
uiDefButF ( block , NUM , 0 , " Max Y " , 0 , 20 , 120 , 18 , & cumap - > clipr . ymax , cumap - > clipr . ymin , 100.0 , 10 , 0 , " " ) ;
uiBlockSetDirection ( block , UI_RIGHT ) ;
uiEndBlock ( C , block ) ;
return block ;
}
static void curvemap_tools_dofunc ( bContext * C , void * cumap_v , int event )
{
CurveMapping * cumap = cumap_v ;
CurveMap * cuma = cumap - > cm + cumap - > cur ;
switch ( event ) {
case 0 :
curvemap_reset ( cuma , & cumap - > clipr ) ;
curvemapping_changed ( cumap , 0 ) ;
break ;
case 1 :
cumap - > curr = cumap - > clipr ;
break ;
case 2 : /* set vector */
curvemap_sethandle ( cuma , 1 ) ;
curvemapping_changed ( cumap , 0 ) ;
break ;
case 3 : /* set auto */
curvemap_sethandle ( cuma , 0 ) ;
curvemapping_changed ( cumap , 0 ) ;
break ;
case 4 : /* extend horiz */
cuma - > flag & = ~ CUMA_EXTEND_EXTRAPOLATE ;
curvemapping_changed ( cumap , 0 ) ;
break ;
case 5 : /* extend extrapolate */
cuma - > flag | = CUMA_EXTEND_EXTRAPOLATE ;
curvemapping_changed ( cumap , 0 ) ;
break ;
}
ED_region_tag_redraw ( CTX_wm_region ( C ) ) ;
}
static uiBlock * curvemap_tools_func ( struct bContext * C , struct ARegion * ar , void * cumap_v )
{
uiBlock * block ;
short yco = 0 , menuwidth = 120 ;
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 , " curvemap_tools_func " , UI_EMBOSS ) ;
2.5
Smaller jobs, all in one commit!
- Moved object_do_update out of view3d drawing, into
the event system (currently after notifiers).
Depsgraph calls for setting update flags will have to
keep track of each Screen's needs, so a UI showing only
a Sequencer doesn't do objects.
- Added button in "Properties region" in 3D window to set
or disable 4-split, including the 3 options it has.
(lock, box, clip)
- Restored legacy code for UI, to make things work like
bone rename, autocomplete.
- Node editor now shows Curves widgets again
- Bugfix: composite job increased Viewer user id count
- Bugfix: Node editor, not "Enable nodes" still called
a Job, which didn't do anything
- Various code cleaning, unused vars and prototypes.
2009-02-11 16:54:55 +00:00
uiBlockSetButmFunc ( block , curvemap_tools_dofunc , cumap_v ) ;
uiDefIconTextBut ( block , BUTM , 1 , ICON_BLANK1 , " Reset View " , 0 , yco - = 20 , menuwidth , 19 , NULL , 0.0 , 0.0 , 0 , 1 , " " ) ;
uiDefIconTextBut ( block , BUTM , 1 , ICON_BLANK1 , " Vector Handle " , 0 , yco - = 20 , menuwidth , 19 , NULL , 0.0 , 0.0 , 0 , 2 , " " ) ;
uiDefIconTextBut ( block , BUTM , 1 , ICON_BLANK1 , " Auto Handle " , 0 , yco - = 20 , menuwidth , 19 , NULL , 0.0 , 0.0 , 0 , 3 , " " ) ;
uiDefIconTextBut ( block , BUTM , 1 , ICON_BLANK1 , " Extend Horizontal " , 0 , yco - = 20 , menuwidth , 19 , NULL , 0.0 , 0.0 , 0 , 4 , " " ) ;
uiDefIconTextBut ( block , BUTM , 1 , ICON_BLANK1 , " Extend Extrapolated " , 0 , yco - = 20 , menuwidth , 19 , NULL , 0.0 , 0.0 , 0 , 5 , " " ) ;
uiDefIconTextBut ( block , BUTM , 1 , ICON_BLANK1 , " Reset Curve " , 0 , yco - = 20 , menuwidth , 19 , NULL , 0.0 , 0.0 , 0 , 0 , " " ) ;
uiBlockSetDirection ( block , UI_RIGHT ) ;
uiTextBoundsBlock ( block , 50 ) ;
uiEndBlock ( C , block ) ;
return block ;
}
/* still unsure how this call evolves... we use labeltype for defining what curve-channels to show */
void curvemap_buttons ( uiBlock * block , CurveMapping * cumap , char labeltype , short event , short redraw , rctf * rect )
{
uiBut * bt ;
float dx , fy = rect - > ymax - 18.0f ;
int icon ;
short xco , yco ;
yco = ( short ) ( rect - > ymax - 18.0f ) ;
/* curve choice options + tools/settings, 8 icons + spacer */
dx = ( rect - > xmax - rect - > xmin ) / ( 9.0f ) ;
uiBlockBeginAlign ( block ) ;
if ( labeltype = = ' v ' ) { /* vector */
xco = ( short ) rect - > xmin ;
if ( cumap - > cm [ 0 ] . curve )
uiDefButI ( block , ROW , redraw , " X " , xco , yco + 2 , dx , 16 , & cumap - > cur , 0.0 , 0.0 , 0.0 , 0.0 , " " ) ;
xco = ( short ) ( rect - > xmin + 1.0f * dx ) ;
if ( cumap - > cm [ 1 ] . curve )
uiDefButI ( block , ROW , redraw , " Y " , xco , yco + 2 , dx , 16 , & cumap - > cur , 0.0 , 1.0 , 0.0 , 0.0 , " " ) ;
xco = ( short ) ( rect - > xmin + 2.0f * dx ) ;
if ( cumap - > cm [ 2 ] . curve )
uiDefButI ( block , ROW , redraw , " Z " , xco , yco + 2 , dx , 16 , & cumap - > cur , 0.0 , 2.0 , 0.0 , 0.0 , " " ) ;
}
else if ( labeltype = = ' c ' ) { /* color */
xco = ( short ) rect - > xmin ;
if ( cumap - > cm [ 3 ] . curve )
uiDefButI ( block , ROW , redraw , " C " , xco , yco + 2 , dx , 16 , & cumap - > cur , 0.0 , 3.0 , 0.0 , 0.0 , " " ) ;
xco = ( short ) ( rect - > xmin + 1.0f * dx ) ;
if ( cumap - > cm [ 0 ] . curve )
uiDefButI ( block , ROW , redraw , " R " , xco , yco + 2 , dx , 16 , & cumap - > cur , 0.0 , 0.0 , 0.0 , 0.0 , " " ) ;
xco = ( short ) ( rect - > xmin + 2.0f * dx ) ;
if ( cumap - > cm [ 1 ] . curve )
uiDefButI ( block , ROW , redraw , " G " , xco , yco + 2 , dx , 16 , & cumap - > cur , 0.0 , 1.0 , 0.0 , 0.0 , " " ) ;
xco = ( short ) ( rect - > xmin + 3.0f * dx ) ;
if ( cumap - > cm [ 2 ] . curve )
uiDefButI ( block , ROW , redraw , " B " , xco , yco + 2 , dx , 16 , & cumap - > cur , 0.0 , 2.0 , 0.0 , 0.0 , " " ) ;
}
/* else no channels ! */
uiBlockEndAlign ( block ) ;
xco = ( short ) ( rect - > xmin + 4.5f * dx ) ;
uiBlockSetEmboss ( block , UI_EMBOSSN ) ;
bt = uiDefIconBut ( block , BUT , redraw , ICON_ZOOMIN , xco , yco , dx , 14 , NULL , 0.0 , 0.0 , 0.0 , 0.0 , " Zoom in " ) ;
uiButSetFunc ( bt , curvemap_buttons_zoom_in , cumap , NULL ) ;
xco = ( short ) ( rect - > xmin + 5.25f * dx ) ;
bt = uiDefIconBut ( block , BUT , redraw , ICON_ZOOMOUT , xco , yco , dx , 14 , NULL , 0.0 , 0.0 , 0.0 , 0.0 , " Zoom out " ) ;
uiButSetFunc ( bt , curvemap_buttons_zoom_out , cumap , NULL ) ;
xco = ( short ) ( rect - > xmin + 6.0f * dx ) ;
bt = uiDefIconBlockBut ( block , curvemap_tools_func , cumap , event , ICON_MODIFIER , xco , yco , dx , 18 , " Tools " ) ;
xco = ( short ) ( rect - > xmin + 7.0f * dx ) ;
if ( cumap - > flag & CUMA_DO_CLIP ) icon = ICON_CLIPUV_HLT ; else icon = ICON_CLIPUV_DEHLT ;
bt = uiDefIconBlockBut ( block , curvemap_clipping_func , cumap , event , icon , xco , yco , dx , 18 , " Clipping Options " ) ;
xco = ( short ) ( rect - > xmin + 8.0f * dx ) ;
bt = uiDefIconBut ( block , BUT , event , ICON_X , xco , yco , dx , 18 , NULL , 0.0 , 0.0 , 0.0 , 0.0 , " Delete points " ) ;
uiButSetFunc ( bt , curvemap_buttons_delete , cumap , NULL ) ;
uiBlockSetEmboss ( block , UI_EMBOSS ) ;
uiDefBut ( block , BUT_CURVE , event , " " ,
rect - > xmin , rect - > ymin , rect - > xmax - rect - > xmin , fy - rect - > ymin ,
cumap , 0.0f , 1.0f , 0 , 0 , " " ) ;
}
2009-08-10 20:48:38 +00:00
/* still unsure how this call evolves... we use labeltype for defining what curve-channels to show */
void curvemap_layout ( uiLayout * layout , CurveMapping * cumap , char labeltype , short event , short redraw , rctf * rect )
{
uiLayout * row ;
uiBlock * block ;
uiBut * bt ;
float dx , fy = rect - > ymax - 18.0f ;
int icon ;
block = uiLayoutGetBlock ( layout ) ;
/* curve choice options + tools/settings, 8 icons + spacer */
dx = UI_UNIT_X ;
row = uiLayoutRow ( layout , 0 ) ;
uiLayoutSetAlignment ( row , UI_LAYOUT_ALIGN_RIGHT ) ;
if ( labeltype = = ' v ' ) { /* vector */
row = uiLayoutRow ( layout , 1 ) ;
if ( cumap - > cm [ 0 ] . curve )
uiDefButI ( block , ROW , redraw , " X " , 0 , 0 , dx , 16 , & cumap - > cur , 0.0 , 0.0 , 0.0 , 0.0 , " " ) ;
if ( cumap - > cm [ 1 ] . curve )
uiDefButI ( block , ROW , redraw , " Y " , 0 , 0 , dx , 16 , & cumap - > cur , 0.0 , 1.0 , 0.0 , 0.0 , " " ) ;
if ( cumap - > cm [ 2 ] . curve )
uiDefButI ( block , ROW , redraw , " Z " , 0 , 0 , dx , 16 , & cumap - > cur , 0.0 , 2.0 , 0.0 , 0.0 , " " ) ;
}
else if ( labeltype = = ' c ' ) { /* color */
row = uiLayoutRow ( layout , 1 ) ;
if ( cumap - > cm [ 3 ] . curve )
uiDefButI ( block , ROW , redraw , " C " , 0 , 0 , dx , 16 , & cumap - > cur , 0.0 , 3.0 , 0.0 , 0.0 , " " ) ;
if ( cumap - > cm [ 0 ] . curve )
uiDefButI ( block , ROW , redraw , " R " , 0 , 0 , dx , 16 , & cumap - > cur , 0.0 , 0.0 , 0.0 , 0.0 , " " ) ;
if ( cumap - > cm [ 1 ] . curve )
uiDefButI ( block , ROW , redraw , " G " , 0 , 0 , dx , 16 , & cumap - > cur , 0.0 , 1.0 , 0.0 , 0.0 , " " ) ;
if ( cumap - > cm [ 2 ] . curve )
uiDefButI ( block , ROW , redraw , " B " , 0 , 0 , dx , 16 , & cumap - > cur , 0.0 , 2.0 , 0.0 , 0.0 , " " ) ;
}
row = uiLayoutRow ( row , 1 ) ;
uiBlockSetEmboss ( block , UI_EMBOSSN ) ;
bt = uiDefIconBut ( block , BUT , redraw , ICON_ZOOMIN , 0 , 0 , dx , 14 , NULL , 0.0 , 0.0 , 0.0 , 0.0 , " Zoom in " ) ;
uiButSetFunc ( bt , curvemap_buttons_zoom_in , cumap , NULL ) ;
bt = uiDefIconBut ( block , BUT , redraw , ICON_ZOOMOUT , 0 , 0 , dx , 14 , NULL , 0.0 , 0.0 , 0.0 , 0.0 , " Zoom out " ) ;
uiButSetFunc ( bt , curvemap_buttons_zoom_out , cumap , NULL ) ;
bt = uiDefIconBlockBut ( block , curvemap_tools_func , cumap , event , ICON_MODIFIER , 0 , 0 , dx , 18 , " Tools " ) ;
if ( cumap - > flag & CUMA_DO_CLIP ) icon = ICON_CLIPUV_HLT ; else icon = ICON_CLIPUV_DEHLT ;
bt = uiDefIconBlockBut ( block , curvemap_clipping_func , cumap , event , icon , 0 , 0 , dx , 18 , " Clipping Options " ) ;
bt = uiDefIconBut ( block , BUT , event , ICON_X , 0 , 0 , dx , 18 , NULL , 0.0 , 0.0 , 0.0 , 0.0 , " Delete points " ) ;
uiButSetFunc ( bt , curvemap_buttons_delete , cumap , NULL ) ;
uiBlockSetEmboss ( block , UI_EMBOSS ) ;
row = uiLayoutRow ( layout , 0 ) ;
uiDefBut ( block , BUT_CURVE , event , " " ,
rect - > xmin , rect - > ymin , rect - > xmax - rect - > xmin , fy - rect - > ymin ,
cumap , 0.0f , 1.0f , 0 , 0 , " " ) ;
}
2009-06-03 00:14:12 +00:00
# define B_BANDCOL 1
static int vergcband ( const void * a1 , const void * a2 )
{
const CBData * x1 = a1 , * x2 = a2 ;
if ( x1 - > pos > x2 - > pos ) return 1 ;
else if ( x1 - > pos < x2 - > pos ) return - 1 ;
return 0 ;
}
static void colorband_pos_cb ( bContext * C , void * coba_v , void * unused_v )
{
ColorBand * coba = coba_v ;
int a ;
if ( coba - > tot < 2 ) return ;
for ( a = 0 ; a < coba - > tot ; a + + ) coba - > data [ a ] . cur = a ;
qsort ( coba - > data , coba - > tot , sizeof ( CBData ) , vergcband ) ;
for ( a = 0 ; a < coba - > tot ; a + + ) {
if ( coba - > data [ a ] . cur = = coba - > cur ) {
// XXX if(coba->cur!=a) addqueue(curarea->win, REDRAW, 0); /* button cur */
coba - > cur = a ;
break ;
}
}
2009-07-23 20:50:24 +00:00
WM_event_add_notifier ( C , NC_TEXTURE , NULL ) ;
}
static void colorband_cb ( bContext * C , void * coba_v , void * unused_v )
{
WM_event_add_notifier ( C , NC_TEXTURE , NULL ) ;
2009-06-03 00:14:12 +00:00
}
static void colorband_add_cb ( bContext * C , void * coba_v , void * unused_v )
{
ColorBand * coba = coba_v ;
if ( coba - > tot < MAXCOLORBAND - 1 ) coba - > tot + + ;
coba - > cur = coba - > tot - 1 ;
colorband_pos_cb ( C , coba , NULL ) ;
ED_undo_push ( C , " Add colorband " ) ;
2009-07-23 20:50:24 +00:00
WM_event_add_notifier ( C , NC_TEXTURE , NULL ) ;
2009-06-03 00:14:12 +00:00
}
static void colorband_del_cb ( bContext * C , void * coba_v , void * unused_v )
{
ColorBand * coba = coba_v ;
int a ;
if ( coba - > tot < 2 ) return ;
for ( a = coba - > cur ; a < coba - > tot ; a + + ) {
coba - > data [ a ] = coba - > data [ a + 1 ] ;
}
if ( coba - > cur ) coba - > cur - - ;
coba - > tot - - ;
ED_undo_push ( C , " Delete colorband " ) ;
// XXX BIF_preview_changed(ID_TE);
2009-07-23 20:50:24 +00:00
WM_event_add_notifier ( C , NC_TEXTURE , NULL ) ;
2009-06-03 00:14:12 +00:00
}
/* offset aligns from bottom, standard width 300, height 115 */
static void colorband_buttons_large ( uiBlock * block , ColorBand * coba , int xoffs , int yoffs , int redraw )
{
CBData * cbd ;
uiBut * bt ;
if ( coba = = NULL ) return ;
2009-07-22 11:52:42 +00:00
bt = uiDefBut ( block , BUT , redraw , " Add " , 0 + xoffs , 100 + yoffs , 50 , 20 , 0 , 0 , 0 , 0 , 0 , " Add a new color stop to the colorband " ) ;
2009-06-03 00:14:12 +00:00
uiButSetFunc ( bt , colorband_add_cb , coba , NULL ) ;
2009-07-22 11:52:42 +00:00
bt = uiDefBut ( block , BUT , redraw , " Delete " , 60 + xoffs , 100 + yoffs , 50 , 20 , 0 , 0 , 0 , 0 , 0 , " Delete the active position " ) ;
2009-07-22 11:40:59 +00:00
uiDefButS ( block , NUM , redraw , " " , 120 + xoffs , 100 + yoffs , 80 , 20 , & coba - > cur , 0.0 , ( float ) ( coba - > tot - 1 ) , 0 , 0 , " Choose active color stop " ) ;
2009-06-03 00:14:12 +00:00
uiButSetFunc ( bt , colorband_del_cb , coba , NULL ) ;
2009-07-23 20:50:24 +00:00
bt = uiDefButS ( block , MENU , redraw , " Interpolation %t|Ease %x1|Cardinal %x3|Linear %x0|B-Spline %x2|Constant %x4 " ,
2009-07-22 11:52:42 +00:00
210 + xoffs , 100 + yoffs , 90 , 20 , & coba - > ipotype , 0.0 , 0.0 , 0 , 0 , " Set interpolation between color stops " ) ;
2009-07-23 20:50:24 +00:00
uiButSetFunc ( bt , colorband_cb , coba , NULL ) ;
2009-07-21 12:57:55 +00:00
uiBlockEndAlign ( block ) ;
2009-06-03 00:14:12 +00:00
2009-07-23 20:50:24 +00:00
bt = uiDefBut ( block , BUT_COLORBAND , redraw , " " , xoffs , 65 + yoffs , 300 , 30 , coba , 0 , 0 , 0 , 0 , " " ) ;
uiButSetFunc ( bt , colorband_cb , coba , NULL ) ;
2009-06-03 00:14:12 +00:00
cbd = coba - > data + coba - > cur ;
2009-07-22 11:40:59 +00:00
bt = uiDefButF ( block , NUM , redraw , " Pos: " , 0 + xoffs , 40 + yoffs , 100 , 20 , & cbd - > pos , 0.0 , 1.0 , 10 , 0 , " The position of the active color stop " ) ;
2009-06-03 00:14:12 +00:00
uiButSetFunc ( bt , colorband_pos_cb , coba , NULL ) ;
2009-07-23 20:50:24 +00:00
bt = uiDefButF ( block , COL , redraw , " " , 110 + xoffs , 40 + yoffs , 80 , 20 , & ( cbd - > r ) , 0 , 0 , 0 , B_BANDCOL , " The color value for the active color stop " ) ;
uiButSetFunc ( bt , colorband_cb , coba , NULL ) ;
bt = uiDefButF ( block , NUMSLI , redraw , " A " , 200 + xoffs , 40 + yoffs , 100 , 20 , & cbd - > a , 0.0 , 1.0 , 10 , 0 , " The alpha value of the active color stop " ) ;
uiButSetFunc ( bt , colorband_cb , coba , NULL ) ;
2009-06-03 00:14:12 +00:00
}
static void colorband_buttons_small ( uiBlock * block , ColorBand * coba , rctf * butr , int event )
{
CBData * cbd ;
uiBut * bt ;
float unit = ( butr - > xmax - butr - > xmin ) / 14.0f ;
float xs = butr - > xmin ;
cbd = coba - > data + coba - > cur ;
2009-07-22 11:52:42 +00:00
bt = uiDefBut ( block , BUT , event , " Add " , xs , butr - > ymin + 20.0f , 2.0f * unit , 20 , NULL , 0 , 0 , 0 , 0 , " Add a new color stop to the colorband " ) ;
2009-06-03 00:14:12 +00:00
uiButSetFunc ( bt , colorband_add_cb , coba , NULL ) ;
2009-07-22 11:52:42 +00:00
bt = uiDefBut ( block , BUT , event , " Delete " , xs + 2.0f * unit , butr - > ymin + 20.0f , 2.0f * unit , 20 , NULL , 0 , 0 , 0 , 0 , " Delete the active position " ) ;
2009-06-03 00:14:12 +00:00
uiButSetFunc ( bt , colorband_del_cb , coba , NULL ) ;
2009-07-22 11:52:42 +00:00
uiDefButF ( block , COL , event , " " , xs + 4.0f * unit , butr - > ymin + 20.0f , 2.0f * unit , 20 , & ( cbd - > r ) , 0 , 0 , 0 , B_BANDCOL , " The color value for the active color stop " ) ;
uiDefButF ( block , NUMSLI , event , " A: " , xs + 6.0f * unit , butr - > ymin + 20.0f , 4.0f * unit , 20 , & ( cbd - > a ) , 0.0f , 1.0f , 10 , 2 , " The alpha value of the active color stop " ) ;
2009-06-03 00:14:12 +00:00
uiDefButS ( block , MENU , event , " Interpolation %t|Ease %x1|Cardinal %x3|Linear %x0|B-Spline %x2|Constant %x4 " ,
2009-07-22 11:52:42 +00:00
xs + 10.0f * unit , butr - > ymin + 20.0f , unit * 4 , 20 , & coba - > ipotype , 0.0 , 0.0 , 0 , 0 , " Set interpolation between color stops " ) ;
2009-06-03 00:14:12 +00:00
uiDefBut ( block , BUT_COLORBAND , event , " " , xs , butr - > ymin , butr - > xmax - butr - > xmin , 20.0f , coba , 0 , 0 , 0 , 0 , " " ) ;
uiBlockEndAlign ( block ) ;
}
void colorband_buttons ( uiBlock * block , ColorBand * coba , rctf * butr , int small )
{
if ( small )
colorband_buttons_small ( block , coba , butr , 0 ) ;
else
colorband_buttons_large ( block , coba , 0 , 0 , 0 ) ;
}