diff options
author | Joseph Eagar <joeedh@gmail.com> | 2009-08-26 14:27:04 +0400 |
---|---|---|
committer | Joseph Eagar <joeedh@gmail.com> | 2009-08-26 14:27:04 +0400 |
commit | de7f08cc41c7087ecde096c89ee58f43ccb1cf91 (patch) | |
tree | 401ab2a2a7429c2caa63c3135341958155a86935 /source/blender/editors | |
parent | a34ffefa0025d144826cd1bf7a136af743847f1b (diff) | |
parent | d893b0f9ff5fc21277b9c24568e224961537c23c (diff) |
merge with 2.5 at r22793
Diffstat (limited to 'source/blender/editors')
161 files changed, 8247 insertions, 9778 deletions
diff --git a/source/blender/editors/Makefile b/source/blender/editors/Makefile index dbd0ca779aa..bbbb3fb985f 100644 --- a/source/blender/editors/Makefile +++ b/source/blender/editors/Makefile @@ -65,5 +65,6 @@ DIRS = armature \ space_text \ space_sequencer \ space_logic \ + space_userpref \ include nan_subdirs.mk diff --git a/source/blender/editors/SConscript b/source/blender/editors/SConscript index 0a13082faaf..05f17dae1a1 100644 --- a/source/blender/editors/SConscript +++ b/source/blender/editors/SConscript @@ -32,6 +32,7 @@ SConscript(['datafiles/SConscript', 'space_sequencer/SConscript', 'space_logic/SConscript', 'space_console/SConscript', + 'space_userpref/SConscript', 'transform/SConscript', 'screen/SConscript', 'sculpt_paint/SConscript', diff --git a/source/blender/editors/animation/anim_channels_defines.c b/source/blender/editors/animation/anim_channels_defines.c new file mode 100644 index 00000000000..b16420a7094 --- /dev/null +++ b/source/blender/editors/animation/anim_channels_defines.c @@ -0,0 +1,2260 @@ +/** + * $Id$ + * + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * The Original Code is Copyright (C) 2009 Blender Foundation, Joshua Leung + * All rights reserved. + * + * Contributor(s): Joshua Leung + * + * ***** END GPL LICENSE BLOCK ***** + */ + +#include <math.h> +#include <stdlib.h> +#include <string.h> +#include <float.h> + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include "MEM_guardedalloc.h" + +#include "BLI_blenlib.h" +#include "BLI_arithb.h" + +#include "DNA_listBase.h" +#include "DNA_anim_types.h" +#include "DNA_action_types.h" +#include "DNA_armature_types.h" +#include "DNA_camera_types.h" +#include "DNA_curve_types.h" +#include "DNA_object_types.h" +#include "DNA_particle_types.h" +#include "DNA_screen_types.h" +#include "DNA_scene_types.h" +#include "DNA_space_types.h" +#include "DNA_constraint_types.h" +#include "DNA_key_types.h" +#include "DNA_lamp_types.h" +#include "DNA_material_types.h" +#include "DNA_meta_types.h" +#include "DNA_userdef_types.h" +#include "DNA_gpencil_types.h" +#include "DNA_windowmanager_types.h" +#include "DNA_world_types.h" + +#include "RNA_access.h" +#include "RNA_define.h" + +#include "BKE_animsys.h" +#include "BKE_action.h" +#include "BKE_depsgraph.h" +#include "BKE_fcurve.h" +#include "BKE_key.h" +#include "BKE_material.h" +#include "BKE_object.h" +#include "BKE_context.h" +#include "BKE_utildefines.h" + +#include "UI_interface.h" +#include "UI_interface_icons.h" +#include "UI_resources.h" +#include "UI_view2d.h" + +#include "ED_anim_api.h" +#include "ED_keyframing.h" +#include "ED_keyframes_edit.h" // XXX move the select modes out of there! +#include "ED_screen.h" +#include "ED_space_api.h" + +#include "BIF_gl.h" + +#include "WM_api.h" +#include "WM_types.h" + +/* *********************************************** */ +// XXX constant defines to be moved elsewhere? + +/* extra padding for lengths (to go under scrollers) */ +#define EXTRA_SCROLL_PAD 100.0f + +/* size of indent steps */ +#define INDENT_STEP_SIZE 7 + +/* macros used for type defines */ + /* get the pointer used for some flag */ +#define GET_ACF_FLAG_PTR(ptr) \ + { \ + *type= sizeof((ptr)); \ + return &(ptr); \ + } + + +/* XXX */ +extern void gl_round_box(int mode, float minx, float miny, float maxx, float maxy, float rad); +extern void gl_round_box_shade(int mode, float minx, float miny, float maxx, float maxy, float rad, float shadetop, float shadedown); + + +/* *********************************************** */ +/* Generic Functions (Type independent) */ + +/* Draw Backdrop ---------------------------------- */ + +/* backdrop for top-level widgets (Scene and Object only) */ +static void acf_generic_root_backdrop(bAnimContext *ac, bAnimListElem *ale, float yminc, float ymaxc) +{ + bAnimChannelType *acf= ANIM_channel_get_typeinfo(ale); + View2D *v2d= &ac->ar->v2d; + short expanded= ANIM_channel_setting_get(ac, ale, ACHANNEL_SETTING_EXPAND) != 0; + short offset= (acf->get_offset) ? acf->get_offset(ac, ale) : 0; + + /* darker blue for top-level widgets */ + UI_ThemeColor(TH_DOPESHEET_CHANNELOB); + + /* rounded corners on LHS only - top only when expanded, but bottom too when collapsed */ + uiSetRoundBox((expanded)? (1):(1|8)); + gl_round_box(GL_POLYGON, offset, yminc, v2d->cur.xmax+EXTRA_SCROLL_PAD, ymaxc, 8); +} + +/* backdrop for data expanders under top-level Scene/Object */ +static void acf_generic_dataexpand_backdrop(bAnimContext *ac, bAnimListElem *ale, float yminc, float ymaxc) +{ + bAnimChannelType *acf= ANIM_channel_get_typeinfo(ale); + View2D *v2d= &ac->ar->v2d; + short offset= (acf->get_offset) ? acf->get_offset(ac, ale) : 0; + + /* lighter color than top-level widget */ + UI_ThemeColor(TH_DOPESHEET_CHANNELSUBOB); + + /* no rounded corner - just rectangular box */ + glRectf(offset, yminc, v2d->cur.xmax+EXTRA_SCROLL_PAD, ymaxc); +} + +/* backdrop for generic channels */ +static void acf_generic_channel_backdrop(bAnimContext *ac, bAnimListElem *ale, float yminc, float ymaxc) +{ + bAnimChannelType *acf= ANIM_channel_get_typeinfo(ale); + View2D *v2d= &ac->ar->v2d; + SpaceAction *saction = NULL; + bActionGroup *grp = NULL; + short indent= (acf->get_indent_level) ? acf->get_indent_level(ac, ale) : 0; + short offset= (acf->get_offset) ? acf->get_offset(ac, ale) : 0; + + /* get context info needed... */ + if ((ac->sa) && (ac->sa->spacetype == SPACE_ACTION)) + saction= (SpaceAction *)ac->sa->spacedata.first; + + if (ale->type == ANIMTYPE_FCURVE) { + FCurve *fcu= (FCurve *)ale->data; + grp= fcu->grp; + } + + /* set color for normal channels + * - use 3 shades of color group/standard color for 3 indention level + * - only use group colors if allowed to, and if actually feasible + */ + if ( (saction && !(saction->flag & SACTION_NODRAWGCOLORS)) && + ((grp) && (grp->customCol)) ) + { + char cp[3]; + + if (indent == 2) { + VECCOPY(cp, grp->cs.solid); + } + else if (indent == 1) { + VECCOPY(cp, grp->cs.select); + } + else { + VECCOPY(cp, grp->cs.active); + } + + glColor3ub(cp[0], cp[1], cp[2]); + } + else // FIXME: what happens when the indention is 1 greater than what it should be (due to grouping)? + UI_ThemeColorShade(TH_HEADER, ((indent==0)?20: (indent==1)?-20: -40)); + + /* no rounded corners - just rectangular box */ + glRectf(offset, yminc, v2d->cur.xmax+EXTRA_SCROLL_PAD, ymaxc); +} + +/* Indention + Offset ------------------------------------------- */ + +/* indention level is always the value in the name */ +static short acf_generic_indention_0(bAnimContext *ac, bAnimListElem *ale) +{ + return 0; +} +static short acf_generic_indention_1(bAnimContext *ac, bAnimListElem *ale) +{ + return 1; +} +#if 0 // XXX not used +static short acf_generic_indention_2(bAnimContext *ac, bAnimListElem *ale) +{ + return 2; +} +#endif + +/* indention which varies with the grouping status */ +static short acf_generic_indention_flexible(bAnimContext *ac, bAnimListElem *ale) +{ + short indent= 0; + + if (ale->id) { + /* special exception for materials and particles */ + if (ELEM(GS(ale->id->name),ID_MA,ID_PA)) + indent++; + } + + /* grouped F-Curves need extra level of indention */ + if (ale->type == ANIMTYPE_FCURVE) { + FCurve *fcu= (FCurve *)ale->data; + + // TODO: we need some way of specifying that the indention color should be one less... + if (fcu->grp) + indent++; + } + + /* no indention */ + return indent; +} + +/* basic offset for channels derived from indention */ +static short acf_generic_basic_offset(bAnimContext *ac, bAnimListElem *ale) +{ + bAnimChannelType *acf= ANIM_channel_get_typeinfo(ale); + + if (acf && acf->get_indent_level) + return acf->get_indent_level(ac, ale) * INDENT_STEP_SIZE; + else + return 0; +} + +/* offset for groups + grouped entities */ +static short acf_generic_group_offset(bAnimContext *ac, bAnimListElem *ale) +{ + short offset= acf_generic_basic_offset(ac, ale); + + if (ale->id) { + /* special exception for materials and particles */ + if (ELEM(GS(ale->id->name),ID_MA,ID_PA)) + offset += 21; + + /* if not in Action Editor mode, groupings must carry some offset too... */ + else if (ac->datatype != ANIMCONT_ACTION) + offset += 14; + } + + /* offset is just the normal type - i.e. based on indention */ + return offset; +} + +/* Name ------------------------------------------- */ + +/* name for ID block entries */ +static void acf_generic_idblock_name(bAnimListElem *ale, char *name) +{ + ID *id= (ID *)ale->data; /* data pointed to should be an ID block */ + + /* just copy the name... */ + if (id && name) + strcpy(name, id->name+2); +} + +/* Settings ------------------------------------------- */ + +/* check if some setting exists for this object-based data-expander (category only) */ +static short acf_generic_dsexpand_setting_valid(bAnimContext *ac, bAnimListElem *ale, int setting) +{ + switch (setting) { + /* only expand supported */ + case ACHANNEL_SETTING_EXPAND: + return 1; + + /* visible - only available in Graph Editor */ + case ACHANNEL_SETTING_VISIBLE: + return ((ac) && (ac->spacetype == SPACE_IPO)); + + default: + return 0; + } +} + +/* get pointer to the setting (category only) */ +static void *acf_generic_dsexpand_setting_ptr(bAnimListElem *ale, int setting, short *type) +{ + Object *ob= (Object *)ale->data; + + /* clear extra return data first */ + *type= 0; + + switch (setting) { + case ACHANNEL_SETTING_EXPAND: /* expanded */ + GET_ACF_FLAG_PTR(ob->nlaflag); // XXX + + default: /* unsupported */ + return NULL; + } +} + +/* check if some setting exists for this object-based data-expander (datablock only) */ +static short acf_generic_dataexpand_setting_valid(bAnimContext *ac, bAnimListElem *ale, int setting) +{ + switch (setting) { + /* expand is always supported */ + case ACHANNEL_SETTING_EXPAND: + return 1; + + /* mute is only supported for NLA */ + case ACHANNEL_SETTING_MUTE: + return ((ac) && (ac->spacetype == SPACE_NLA)); + + /* other flags are never supported */ + default: + return 0; + } +} + +/* *********************************************** */ +/* Type Specific Functions + Defines */ + +/* Scene ------------------------------------------- */ + +// TODO: just get this from RNA? +static int acf_scene_icon(bAnimListElem *ale) +{ + return ICON_SCENE_DATA; +} + +/* check if some setting exists for this channel */ +static short acf_scene_setting_valid(bAnimContext *ac, bAnimListElem *ale, int setting) +{ + switch (setting) { + /* muted only in NLA */ + case ACHANNEL_SETTING_MUTE: + return ((ac) && (ac->spacetype == SPACE_NLA)); + + /* visible only in Graph Editor */ + case ACHANNEL_SETTING_VISIBLE: + return ((ac) && (ac->spacetype == SPACE_IPO)); + + /* only select and expand supported otherwise */ + case ACHANNEL_SETTING_SELECT: + case ACHANNEL_SETTING_EXPAND: + return 1; + + default: + return 0; + } +} + +/* get the appropriate flag(s) for the setting when it is valid */ +static int acf_scene_setting_flag(int setting, short *neg) +{ + /* clear extra return data first */ + *neg= 0; + + switch (setting) { + case ACHANNEL_SETTING_SELECT: /* selected */ + return SCE_DS_SELECTED; + + case ACHANNEL_SETTING_EXPAND: /* expanded */ + *neg= 1; + return SCE_DS_COLLAPSED; + + case ACHANNEL_SETTING_MUTE: /* mute (only in NLA) */ + return ADT_NLA_EVAL_OFF; + + case ACHANNEL_SETTING_VISIBLE: /* visible (only in Graph Editor) */ + *neg= 1; + return ADT_CURVES_NOT_VISIBLE; + + default: /* unsupported */ + return 0; + } +} + +/* get pointer to the setting */ +static void *acf_scene_setting_ptr(bAnimListElem *ale, int setting, short *type) +{ + Scene *scene= (Scene *)ale->data; + + /* clear extra return data first */ + *type= 0; + + switch (setting) { + case ACHANNEL_SETTING_SELECT: /* selected */ + GET_ACF_FLAG_PTR(scene->flag); + + case ACHANNEL_SETTING_EXPAND: /* expanded */ + GET_ACF_FLAG_PTR(scene->flag); + + case ACHANNEL_SETTING_MUTE: /* mute (only in NLA) */ + case ACHANNEL_SETTING_VISIBLE: /* visible (for Graph Editor only) */ + if (scene->adt) + GET_ACF_FLAG_PTR(scene->adt->flag) + else + return NULL; + + default: /* unsupported */ + return 0; + } +} + +/* scene type define */ +static bAnimChannelType ACF_SCENE = +{ + acf_generic_root_backdrop, /* backdrop */ + acf_generic_indention_0, /* indent level */ + NULL, /* offset */ + + acf_generic_idblock_name, /* name */ + acf_scene_icon, /* icon */ + + acf_scene_setting_valid, /* has setting */ + acf_scene_setting_flag, /* flag for setting */ + acf_scene_setting_ptr /* pointer for setting */ +}; + +/* Object ------------------------------------------- */ + +static int acf_object_icon(bAnimListElem *ale) +{ + Base *base= (Base *)ale->data; + Object *ob= base->object; + + /* icon depends on object-type */ + if (ob->type == OB_ARMATURE) + return ICON_ARMATURE_DATA; + else + return ICON_OBJECT_DATA; +} + +/* name for object */ +static void acf_object_name(bAnimListElem *ale, char *name) +{ + Base *base= (Base *)ale->data; + Object *ob= base->object; + + /* just copy the name... */ + if (ob && name) + strcpy(name, ob->id.name+2); +} + +/* check if some setting exists for this channel */ +static short acf_object_setting_valid(bAnimContext *ac, bAnimListElem *ale, int setting) +{ + switch (setting) { + /* muted only in NLA */ + case ACHANNEL_SETTING_MUTE: + return ((ac) && (ac->spacetype == SPACE_NLA)); + + /* visible only in Graph Editor */ + case ACHANNEL_SETTING_VISIBLE: + return ((ac) && (ac->spacetype == SPACE_IPO)); + + /* only select and expand supported otherwise */ + case ACHANNEL_SETTING_SELECT: + case ACHANNEL_SETTING_EXPAND: + return 1; + + default: + return 0; + } +} + +/* get the appropriate flag(s) for the setting when it is valid */ +static int acf_object_setting_flag(int setting, short *neg) +{ + /* clear extra return data first */ + *neg= 0; + + switch (setting) { + case ACHANNEL_SETTING_SELECT: /* selected */ + return SELECT; + + case ACHANNEL_SETTING_EXPAND: /* expanded */ + *neg= 1; + return OB_ADS_COLLAPSED; + + case ACHANNEL_SETTING_MUTE: /* mute (only in NLA) */ + return ADT_NLA_EVAL_OFF; + + case ACHANNEL_SETTING_VISIBLE: /* visible (only in Graph Editor) */ + *neg= 1; + return ADT_CURVES_NOT_VISIBLE; + + default: /* unsupported */ + return 0; + } +} + +/* get pointer to the setting */ +static void *acf_object_setting_ptr(bAnimListElem *ale, int setting, short *type) +{ + Base *base= (Base *)ale->data; + Object *ob= base->object; + + /* clear extra return data first */ + *type= 0; + + switch (setting) { + case ACHANNEL_SETTING_SELECT: /* selected */ + GET_ACF_FLAG_PTR(ob->flag); + + case ACHANNEL_SETTING_EXPAND: /* expanded */ + GET_ACF_FLAG_PTR(ob->nlaflag); // xxx + + case ACHANNEL_SETTING_MUTE: /* mute (only in NLA) */ + case ACHANNEL_SETTING_VISIBLE: /* visible (for Graph Editor only) */ + if (ob->adt) + GET_ACF_FLAG_PTR(ob->adt->flag) + else + return NULL; + + default: /* unsupported */ + return 0; + } +} + +/* object type define */ +static bAnimChannelType ACF_OBJECT = +{ + acf_generic_root_backdrop, /* backdrop */ + acf_generic_indention_0, /* indent level */ + NULL, /* offset */ + + acf_object_name, /* name */ + acf_object_icon, /* icon */ + + acf_object_setting_valid, /* has setting */ + acf_object_setting_flag, /* flag for setting */ + acf_object_setting_ptr /* pointer for setting */ +}; + +/* Group ------------------------------------------- */ + +/* backdrop for group widget */ +static void acf_group_backdrop(bAnimContext *ac, bAnimListElem *ale, float yminc, float ymaxc) +{ + bAnimChannelType *acf= ANIM_channel_get_typeinfo(ale); + View2D *v2d= &ac->ar->v2d; + short expanded= ANIM_channel_setting_get(ac, ale, ACHANNEL_SETTING_EXPAND) != 0; + short offset= (acf->get_offset) ? acf->get_offset(ac, ale) : 0; + + /* only for action group channels */ + if (ale->flag & AGRP_ACTIVE) + UI_ThemeColorShade(TH_GROUP_ACTIVE, 10); + else + UI_ThemeColorShade(TH_GROUP, 20); + + /* rounded corners on LHS only - top only when expanded, but bottom too when collapsed */ + uiSetRoundBox((expanded)? (1):(1|8)); + gl_round_box(GL_POLYGON, offset, yminc, v2d->cur.xmax+EXTRA_SCROLL_PAD, ymaxc, 8); +} + +/* name for group entries */ +static void acf_group_name(bAnimListElem *ale, char *name) +{ + bActionGroup *agrp= (bActionGroup *)ale->data; + + /* just copy the name... */ + if (agrp && name) + strcpy(name, agrp->name); +} + +/* check if some setting exists for this channel */ +static short acf_group_setting_valid(bAnimContext *ac, bAnimListElem *ale, int setting) +{ + /* for now, all settings are supported, though some are only conditionally */ + switch (setting) { + case ACHANNEL_SETTING_VISIBLE: /* Only available in Graph Editor */ + return ((ac->sa) && (ac->sa->spacetype==SPACE_IPO)); + + default: /* always supported */ + return 1; + } +} + +/* get the appropriate flag(s) for the setting when it is valid */ +static int acf_group_setting_flag(int setting, short *neg) +{ + /* clear extra return data first */ + *neg= 0; + + switch (setting) { + case ACHANNEL_SETTING_SELECT: /* selected */ + return AGRP_SELECTED; + + case ACHANNEL_SETTING_EXPAND: /* expanded */ + return AGRP_EXPANDED; + + case ACHANNEL_SETTING_MUTE: /* muted */ + return AGRP_MUTED; + + case ACHANNEL_SETTING_PROTECT: /* protected */ + //*neg= 1; - if we change this to edtiability + return AGRP_PROTECTED; + + case ACHANNEL_SETTING_VISIBLE: /* visiblity - graph editor */ + *neg= 1; + return AGRP_NOTVISIBLE; + } + + /* this shouldn't happen */ + return 0; +} + +/* get pointer to the setting */ +static void *acf_group_setting_ptr(bAnimListElem *ale, int setting, short *type) +{ + bActionGroup *agrp= (bActionGroup *)ale->data; + + /* all flags are just in agrp->flag for now... */ + GET_ACF_FLAG_PTR(agrp->flag); +} + +/* group type define */ +static bAnimChannelType ACF_GROUP = +{ + acf_group_backdrop, /* backdrop */ + acf_generic_indention_0, /* indent level */ + acf_generic_group_offset, /* offset */ + + acf_group_name, /* name */ + NULL, /* icon */ + + acf_group_setting_valid, /* has setting */ + acf_group_setting_flag, /* flag for setting */ + acf_group_setting_ptr /* pointer for setting */ +}; + +/* F-Curve ------------------------------------------- */ + +/* name for fcurve entries */ +static void acf_fcurve_name(bAnimListElem *ale, char *name) +{ + getname_anim_fcurve(name, ale->id, ale->data); +} + +/* check if some setting exists for this channel */ +static short acf_fcurve_setting_valid(bAnimContext *ac, bAnimListElem *ale, int setting) +{ + FCurve *fcu= (FCurve *)ale->data; + + switch (setting) { + /* unsupported */ + case ACHANNEL_SETTING_EXPAND: /* F-Curves are not containers */ + return 0; + + /* conditionally available */ + case ACHANNEL_SETTING_PROTECT: /* Protection is only valid when there's keyframes */ + if (fcu->bezt) + return 1; + else + return 0; // NOTE: in this special case, we need to draw ICON_ZOOMOUT + + case ACHANNEL_SETTING_VISIBLE: /* Only available in Graph Editor */ + return ((ac->sa) && (ac->sa->spacetype==SPACE_IPO)); + + /* always available */ + default: + return 1; + } +} + +/* get the appropriate flag(s) for the setting when it is valid */ +static int acf_fcurve_setting_flag(int setting, short *neg) +{ + /* clear extra return data first */ + *neg= 0; + + switch (setting) { + case ACHANNEL_SETTING_SELECT: /* selected */ + return FCURVE_SELECTED; + + case ACHANNEL_SETTING_MUTE: /* muted */ + return FCURVE_MUTED; + + case ACHANNEL_SETTING_PROTECT: /* protected */ + //*neg= 1; - if we change this to edtiability + return FCURVE_PROTECTED; + + case ACHANNEL_SETTING_VISIBLE: /* visiblity - graph editor */ + return FCURVE_VISIBLE; + + default: /* unsupported */ + return 0; + } +} + +/* get pointer to the setting */ +static void *acf_fcurve_setting_ptr(bAnimListElem *ale, int setting, short *type) +{ + FCurve *fcu= (FCurve *)ale->data; + + /* all flags are just in agrp->flag for now... */ + GET_ACF_FLAG_PTR(fcu->flag); +} + +/* fcurve type define */ +static bAnimChannelType ACF_FCURVE = +{ + acf_generic_channel_backdrop, /* backdrop */ + acf_generic_indention_flexible, /* indent level */ // xxx rename this to f-curves only? + acf_generic_group_offset, /* offset */ + + acf_fcurve_name, /* name */ + NULL, /* icon */ + + acf_fcurve_setting_valid, /* has setting */ + acf_fcurve_setting_flag, /* flag for setting */ + acf_fcurve_setting_ptr /* pointer for setting */ +}; + +/* Object Action Expander ------------------------------------------- */ + +// TODO: just get this from RNA? +static int acf_fillactd_icon(bAnimListElem *ale) +{ + return ICON_ACTION; +} + +/* check if some setting exists for this channel */ +static short acf_fillactd_setting_valid(bAnimContext *ac, bAnimListElem *ale, int setting) +{ + switch (setting) { + /* only select and expand supported */ + case ACHANNEL_SETTING_SELECT: + case ACHANNEL_SETTING_EXPAND: + return 1; + + default: + return 0; + } +} + +/* get the appropriate flag(s) for the setting when it is valid */ +static int acf_fillactd_setting_flag(int setting, short *neg) +{ + /* clear extra return data first */ + *neg= 0; + + switch (setting) { + case ACHANNEL_SETTING_SELECT: /* selected */ + return ACT_SELECTED; + + case ACHANNEL_SETTING_EXPAND: /* expanded */ + *neg= 1; + return ACT_COLLAPSED; + + default: /* unsupported */ + return 0; + } +} + +/* get pointer to the setting */ +static void *acf_fillactd_setting_ptr(bAnimListElem *ale, int setting, short *type) +{ + bAction *act= (bAction *)ale->data; + + /* clear extra return data first */ + *type= 0; + + switch (setting) { + case ACHANNEL_SETTING_SELECT: /* selected */ + GET_ACF_FLAG_PTR(act->flag); + + case ACHANNEL_SETTING_EXPAND: /* expanded */ + GET_ACF_FLAG_PTR(act->flag); + + default: /* unsupported */ + return 0; + } +} + +/* object action expander type define */ +static bAnimChannelType ACF_FILLACTD = +{ + acf_generic_dataexpand_backdrop,/* backdrop */ + acf_generic_indention_1, /* indent level */ + acf_generic_basic_offset, /* offset */ + + acf_generic_idblock_name, /* name */ + acf_fillactd_icon, /* icon */ + + acf_fillactd_setting_valid, /* has setting */ + acf_fillactd_setting_flag, /* flag for setting */ + acf_fillactd_setting_ptr /* pointer for setting */ +}; + +/* Drivers Expander ------------------------------------------- */ + +// TODO: just get this from RNA? +static int acf_filldrivers_icon(bAnimListElem *ale) +{ + return ICON_ANIM_DATA; +} + +static void acf_filldrivers_name(bAnimListElem *ale, char *name) +{ + strcpy(name, "Drivers"); +} + +/* check if some setting exists for this channel */ +// TODO: this could be made more generic +static short acf_filldrivers_setting_valid(bAnimContext *ac, bAnimListElem *ale, int setting) +{ + switch (setting) { + /* only expand supported */ + case ACHANNEL_SETTING_EXPAND: + return 1; + + default: + return 0; + } +} + +/* get the appropriate flag(s) for the setting when it is valid */ +static int acf_filldrivers_setting_flag(int setting, short *neg) +{ + /* clear extra return data first */ + *neg= 0; + + switch (setting) { + case ACHANNEL_SETTING_EXPAND: /* expanded */ + *neg= 1; + return ADT_DRIVERS_COLLAPSED; + + default: /* unsupported */ + return 0; + } +} + +/* get pointer to the setting */ +static void *acf_filldrivers_setting_ptr(bAnimListElem *ale, int setting, short *type) +{ + AnimData *adt= (AnimData *)ale->data; + + /* clear extra return data first */ + *type= 0; + + switch (setting) { + case ACHANNEL_SETTING_EXPAND: /* expanded */ + GET_ACF_FLAG_PTR(adt->flag); + + default: /* unsupported */ + return 0; + } +} + +/* drivers expander type define */ +static bAnimChannelType ACF_FILLDRIVERS = +{ + acf_generic_dataexpand_backdrop,/* backdrop */ + acf_generic_indention_1, /* indent level */ + acf_generic_basic_offset, /* offset */ + + acf_filldrivers_name, /* name */ + acf_filldrivers_icon, /* icon */ + + acf_filldrivers_setting_valid, /* has setting */ + acf_filldrivers_setting_flag, /* flag for setting */ + acf_filldrivers_setting_ptr /* pointer for setting */ +}; + +/* Materials Expander ------------------------------------------- */ + +// TODO: just get this from RNA? +static int acf_fillmatd_icon(bAnimListElem *ale) +{ + return ICON_MATERIAL_DATA; +} + +static void acf_fillmatd_name(bAnimListElem *ale, char *name) +{ + strcpy(name, "Materials"); +} + +/* get the appropriate flag(s) for the setting when it is valid */ +static int acf_fillmatd_setting_flag(int setting, short *neg) +{ + /* clear extra return data first */ + *neg= 0; + + switch (setting) { + case ACHANNEL_SETTING_EXPAND: /* expanded */ + *neg= 1; + return OB_ADS_SHOWMATS; + + default: /* unsupported */ + return 0; + } +} + +/* materials expander type define */ +static bAnimChannelType ACF_FILLMATD= +{ + acf_generic_dataexpand_backdrop,/* backdrop */ + acf_generic_indention_1, /* indent level */ + acf_generic_basic_offset, /* offset */ + + acf_fillmatd_name, /* name */ + acf_fillmatd_icon, /* icon */ + + acf_generic_dsexpand_setting_valid, /* has setting */ + acf_fillmatd_setting_flag, /* flag for setting */ + acf_generic_dsexpand_setting_ptr /* pointer for setting */ +}; + +/* Particles Expander ------------------------------------------- */ + +// TODO: just get this from RNA? +static int acf_fillpartd_icon(bAnimListElem *ale) +{ + return ICON_PARTICLE_DATA; +} + +static void acf_fillpartd_name(bAnimListElem *ale, char *name) +{ + strcpy(name, "Particles"); +} + +/* get the appropriate flag(s) for the setting when it is valid */ +static int acf_fillpartd_setting_flag(int setting, short *neg) +{ + /* clear extra return data first */ + *neg= 0; + + switch (setting) { + case ACHANNEL_SETTING_EXPAND: /* expanded */ + *neg= 1; + return OB_ADS_SHOWPARTS; + + default: /* unsupported */ + return 0; + } +} + +/* particles expander type define */ +static bAnimChannelType ACF_FILLPARTD= +{ + acf_generic_dataexpand_backdrop,/* backdrop */ + acf_generic_indention_1, /* indent level */ + acf_generic_basic_offset, /* offset */ + + acf_fillpartd_name, /* name */ + acf_fillpartd_icon, /* icon */ + + acf_generic_dsexpand_setting_valid, /* has setting */ + acf_fillpartd_setting_flag, /* flag for setting */ + acf_generic_dsexpand_setting_ptr /* pointer for setting */ +}; + +/* Material Expander ------------------------------------------- */ + +// TODO: just get this from RNA? +static int acf_dsmat_icon(bAnimListElem *ale) +{ + return ICON_MATERIAL_DATA; +} + +/* offset for material expanders */ +static short acf_dsmat_offset(bAnimContext *ac, bAnimListElem *ale) +{ + return 21; +} + +/* get the appropriate flag(s) for the setting when it is valid */ +static int acf_dsmat_setting_flag(int setting, short *neg) +{ + /* clear extra return data first */ + *neg= 0; + + switch (setting) { + case ACHANNEL_SETTING_EXPAND: /* expanded */ + return MA_DS_EXPAND; + + case ACHANNEL_SETTING_MUTE: /* mute (only in NLA) */ + return ADT_NLA_EVAL_OFF; + + case ACHANNEL_SETTING_VISIBLE: /* visible (only in Graph Editor) */ + *neg= 1; + return ADT_CURVES_NOT_VISIBLE; + + default: /* unsupported */ + return 0; + } +} + +/* get pointer to the setting */ +static void *acf_dsmat_setting_ptr(bAnimListElem *ale, int setting, short *type) +{ + Material *ma= (Material *)ale->data; + + /* clear extra return data first */ + *type= 0; + + switch (setting) { + case ACHANNEL_SETTING_EXPAND: /* expanded */ + GET_ACF_FLAG_PTR(ma->flag); + + case ACHANNEL_SETTING_MUTE: /* muted (for NLA only) */ + case ACHANNEL_SETTING_VISIBLE: /* visible (for Graph Editor only) */ + if (ma->adt) + GET_ACF_FLAG_PTR(ma->adt->flag) + else + return NULL; + + default: /* unsupported */ + return NULL; + } +} + +/* material expander type define */ +static bAnimChannelType ACF_DSMAT= +{ + acf_generic_channel_backdrop, /* backdrop */ + acf_generic_indention_0, /* indent level */ + acf_dsmat_offset, /* offset */ + + acf_generic_idblock_name, /* name */ + acf_dsmat_icon, /* icon */ + + acf_generic_dataexpand_setting_valid, /* has setting */ + acf_dsmat_setting_flag, /* flag for setting */ + acf_dsmat_setting_ptr /* pointer for setting */ +}; + +/* Lamp Expander ------------------------------------------- */ + +// TODO: just get this from RNA? +static int acf_dslam_icon(bAnimListElem *ale) +{ + return ICON_LAMP_DATA; +} + +/* get the appropriate flag(s) for the setting when it is valid */ +static int acf_dslam_setting_flag(int setting, short *neg) +{ + /* clear extra return data first */ + *neg= 0; + + switch (setting) { + case ACHANNEL_SETTING_EXPAND: /* expanded */ + return LA_DS_EXPAND; + + case ACHANNEL_SETTING_MUTE: /* mute (only in NLA) */ + return ADT_NLA_EVAL_OFF; + + case ACHANNEL_SETTING_VISIBLE: /* visible (only in Graph Editor) */ + *neg= 1; + return ADT_CURVES_NOT_VISIBLE; + + default: /* unsupported */ + return 0; + } +} + +/* get pointer to the setting */ +static void *acf_dslam_setting_ptr(bAnimListElem *ale, int setting, short *type) +{ + Lamp *la= (Lamp *)ale->data; + + /* clear extra return data first */ + *type= 0; + + switch (setting) { + case ACHANNEL_SETTING_EXPAND: /* expanded */ + GET_ACF_FLAG_PTR(la->flag); + + case ACHANNEL_SETTING_MUTE: /* muted (for NLA only) */ + case ACHANNEL_SETTING_VISIBLE: /* visible (for Graph Editor only) */ + if (la->adt) + GET_ACF_FLAG_PTR(la->adt->flag) + else + return NULL; + + default: /* unsupported */ + return NULL; + } +} + +/* lamp expander type define */ +static bAnimChannelType ACF_DSLAM= +{ + acf_generic_dataexpand_backdrop,/* backdrop */ + acf_generic_indention_1, /* indent level */ + acf_generic_basic_offset, /* offset */ + + acf_generic_idblock_name, /* name */ + acf_dslam_icon, /* icon */ + + acf_generic_dataexpand_setting_valid, /* has setting */ + acf_dslam_setting_flag, /* flag for setting */ + acf_dslam_setting_ptr /* pointer for setting */ +}; + +/* Camera Expander ------------------------------------------- */ + +// TODO: just get this from RNA? +static int acf_dscam_icon(bAnimListElem *ale) +{ + return ICON_CAMERA_DATA; +} + +/* get the appropriate flag(s) for the setting when it is valid */ +static int acf_dscam_setting_flag(int setting, short *neg) +{ + /* clear extra return data first */ + *neg= 0; + + switch (setting) { + case ACHANNEL_SETTING_EXPAND: /* expanded */ + return CAM_DS_EXPAND; + + case ACHANNEL_SETTING_MUTE: /* mute (only in NLA) */ + return ADT_NLA_EVAL_OFF; + + case ACHANNEL_SETTING_VISIBLE: /* visible (only in Graph Editor) */ + *neg= 1; + return ADT_CURVES_NOT_VISIBLE; + + default: /* unsupported */ + return 0; + } +} + +/* get pointer to the setting */ +static void *acf_dscam_setting_ptr(bAnimListElem *ale, int setting, short *type) +{ + Camera *ca= (Camera *)ale->data; + + /* clear extra return data first */ + *type= 0; + + switch (setting) { + case ACHANNEL_SETTING_EXPAND: /* expanded */ + GET_ACF_FLAG_PTR(ca->flag); + + case ACHANNEL_SETTING_MUTE: /* muted (for NLA only) */ + case ACHANNEL_SETTING_VISIBLE: /* visible (for Graph Editor only) */ + if (ca->adt) + GET_ACF_FLAG_PTR(ca->adt->flag) + else + return NULL; + + default: /* unsupported */ + return NULL; + } +} + +/* camera expander type define */ +static bAnimChannelType ACF_DSCAM= +{ + acf_generic_dataexpand_backdrop,/* backdrop */ + acf_generic_indention_1, /* indent level */ + acf_generic_basic_offset, /* offset */ + + acf_generic_idblock_name, /* name */ + acf_dscam_icon, /* icon */ + + acf_generic_dataexpand_setting_valid, /* has setting */ + acf_dscam_setting_flag, /* flag for setting */ + acf_dscam_setting_ptr /* pointer for setting */ +}; + +/* Curve Expander ------------------------------------------- */ + +// TODO: just get this from RNA? +static int acf_dscur_icon(bAnimListElem *ale) +{ + return ICON_CURVE_DATA; +} + +/* get the appropriate flag(s) for the setting when it is valid */ +static int acf_dscur_setting_flag(int setting, short *neg) +{ + /* clear extra return data first */ + *neg= 0; + + switch (setting) { + case ACHANNEL_SETTING_EXPAND: /* expanded */ + return CU_DS_EXPAND; + + case ACHANNEL_SETTING_MUTE: /* mute (only in NLA) */ + return ADT_NLA_EVAL_OFF; + + case ACHANNEL_SETTING_VISIBLE: /* visible (only in Graph Editor) */ + *neg= 1; + return ADT_CURVES_NOT_VISIBLE; + + default: /* unsupported */ + return 0; + } +} + +/* get pointer to the setting */ +static void *acf_dscur_setting_ptr(bAnimListElem *ale, int setting, short *type) +{ + Curve *cu= (Curve *)ale->data; + + /* clear extra return data first */ + *type= 0; + + switch (setting) { + case ACHANNEL_SETTING_EXPAND: /* expanded */ + GET_ACF_FLAG_PTR(cu->flag); + + case ACHANNEL_SETTING_MUTE: /* muted (for NLA only) */ + case ACHANNEL_SETTING_VISIBLE: /* visible (for Graph Editor only) */ + if (cu->adt) + GET_ACF_FLAG_PTR(cu->adt->flag) + else + return NULL; + + default: /* unsupported */ + return NULL; + } +} + +/* curve expander type define */ +static bAnimChannelType ACF_DSCUR= +{ + acf_generic_dataexpand_backdrop,/* backdrop */ + acf_generic_indention_1, /* indent level */ + acf_generic_basic_offset, /* offset */ + + acf_generic_idblock_name, /* name */ + acf_dscur_icon, /* icon */ + + acf_generic_dataexpand_setting_valid, /* has setting */ + acf_dscur_setting_flag, /* flag for setting */ + acf_dscur_setting_ptr /* pointer for setting */ +}; + +/* Shape Key Expander ------------------------------------------- */ + +// TODO: just get this from RNA? +static int acf_dsskey_icon(bAnimListElem *ale) +{ + return ICON_SHAPEKEY_DATA; +} + +/* get the appropriate flag(s) for the setting when it is valid */ +static int acf_dsskey_setting_flag(int setting, short *neg) +{ + /* clear extra return data first */ + *neg= 0; + + switch (setting) { + case ACHANNEL_SETTING_EXPAND: /* expanded */ + return KEYBLOCK_DS_EXPAND; + + case ACHANNEL_SETTING_MUTE: /* mute (only in NLA) */ + return ADT_NLA_EVAL_OFF; + + case ACHANNEL_SETTING_VISIBLE: /* visible (only in Graph Editor) */ + *neg= 1; + return ADT_CURVES_NOT_VISIBLE; + + default: /* unsupported */ + return 0; + } +} + +/* get pointer to the setting */ +static void *acf_dsskey_setting_ptr(bAnimListElem *ale, int setting, short *type) +{ + Key *key= (Key *)ale->data; + + /* clear extra return data first */ + *type= 0; + + switch (setting) { + case ACHANNEL_SETTING_EXPAND: /* expanded */ + GET_ACF_FLAG_PTR(key->flag); + + case ACHANNEL_SETTING_MUTE: /* muted (for NLA only) */ + case ACHANNEL_SETTING_VISIBLE: /* visible (for Graph Editor only) */ + if (key->adt) + GET_ACF_FLAG_PTR(key->adt->flag) + else + return NULL; + + default: /* unsupported */ + return NULL; + } +} + +/* shapekey expander type define */ +static bAnimChannelType ACF_DSSKEY= +{ + acf_generic_dataexpand_backdrop,/* backdrop */ + acf_generic_indention_1, /* indent level */ + acf_generic_basic_offset, /* offset */ + + acf_generic_idblock_name, /* name */ + acf_dsskey_icon, /* icon */ + + acf_generic_dataexpand_setting_valid, /* has setting */ + acf_dsskey_setting_flag, /* flag for setting */ + acf_dsskey_setting_ptr /* pointer for setting */ +}; + +/* World Expander ------------------------------------------- */ + +// TODO: just get this from RNA? +static int acf_dswor_icon(bAnimListElem *ale) +{ + return ICON_WORLD_DATA; +} + +/* get the appropriate flag(s) for the setting when it is valid */ +static int acf_dswor_setting_flag(int setting, short *neg) +{ + /* clear extra return data first */ + *neg= 0; + + switch (setting) { + case ACHANNEL_SETTING_EXPAND: /* expanded */ + return WO_DS_EXPAND; + + case ACHANNEL_SETTING_MUTE: /* mute (only in NLA) */ + return ADT_NLA_EVAL_OFF; + + case ACHANNEL_SETTING_VISIBLE: /* visible (only in Graph Editor) */ + *neg= 1; + return ADT_CURVES_NOT_VISIBLE; + + default: /* unsupported */ + return 0; + } +} + +/* get pointer to the setting */ +static void *acf_dswor_setting_ptr(bAnimListElem *ale, int setting, short *type) +{ + World *wo= (World *)ale->data; + + /* clear extra return data first */ + *type= 0; + + switch (setting) { + case ACHANNEL_SETTING_EXPAND: /* expanded */ + GET_ACF_FLAG_PTR(wo->flag); + + case ACHANNEL_SETTING_MUTE: /* muted (for NLA only) */ + case ACHANNEL_SETTING_VISIBLE: /* visible (for Graph Editor only) */ + if (wo->adt) + GET_ACF_FLAG_PTR(wo->adt->flag) + else + return NULL; + + default: /* unsupported */ + return NULL; + } +} + +/* world expander type define */ +static bAnimChannelType ACF_DSWOR= +{ + acf_generic_dataexpand_backdrop,/* backdrop */ + acf_generic_indention_1, /* indent level */ + acf_generic_basic_offset, /* offset */ + + acf_generic_idblock_name, /* name */ + acf_dswor_icon, /* icon */ + + acf_generic_dataexpand_setting_valid, /* has setting */ + acf_dswor_setting_flag, /* flag for setting */ + acf_dswor_setting_ptr /* pointer for setting */ +}; + +/* Particle Expander ------------------------------------------- */ + +// TODO: just get this from RNA? +static int acf_dspart_icon(bAnimListElem *ale) +{ + return ICON_PARTICLE_DATA; +} + +/* get the appropriate flag(s) for the setting when it is valid */ +static int acf_dspart_setting_flag(int setting, short *neg) +{ + /* clear extra return data first */ + *neg= 0; + + switch (setting) { + case ACHANNEL_SETTING_EXPAND: /* expanded */ + return PART_DS_EXPAND; + + case ACHANNEL_SETTING_MUTE: /* mute (only in NLA) */ + return ADT_NLA_EVAL_OFF; + + case ACHANNEL_SETTING_VISIBLE: /* visible (only in Graph Editor) */ + *neg= 1; + return ADT_CURVES_NOT_VISIBLE; + + default: /* unsupported */ + return 0; + } +} + +/* get pointer to the setting */ +static void *acf_dspart_setting_ptr(bAnimListElem *ale, int setting, short *type) +{ + ParticleSettings *part= (ParticleSettings *)ale->data; + + /* clear extra return data first */ + *type= 0; + + switch (setting) { + case ACHANNEL_SETTING_EXPAND: /* expanded */ + GET_ACF_FLAG_PTR(part->flag); + + case ACHANNEL_SETTING_MUTE: /* muted (for NLA only) */ + case ACHANNEL_SETTING_VISIBLE: /* visible (for Graph Editor only) */ + if (part->adt) + GET_ACF_FLAG_PTR(part->adt->flag) + else + return NULL; + + default: /* unsupported */ + return NULL; + } +} + +/* particle expander type define */ +static bAnimChannelType ACF_DSPART= +{ + acf_generic_dataexpand_backdrop,/* backdrop */ + acf_generic_indention_1, /* indent level */ + acf_generic_basic_offset, /* offset */ + + acf_generic_idblock_name, /* name */ + acf_dspart_icon, /* icon */ + + acf_generic_dataexpand_setting_valid, /* has setting */ + acf_dspart_setting_flag, /* flag for setting */ + acf_dspart_setting_ptr /* pointer for setting */ +}; + +/* MetaBall Expander ------------------------------------------- */ + +// TODO: just get this from RNA? +static int acf_dsmball_icon(bAnimListElem *ale) +{ + return ICON_META_DATA; +} + +/* get the appropriate flag(s) for the setting when it is valid */ +static int acf_dsmball_setting_flag(int setting, short *neg) +{ + /* clear extra return data first */ + *neg= 0; + + switch (setting) { + case ACHANNEL_SETTING_EXPAND: /* expanded */ + return MB_DS_EXPAND; + + case ACHANNEL_SETTING_MUTE: /* mute (only in NLA) */ + return ADT_NLA_EVAL_OFF; + + case ACHANNEL_SETTING_VISIBLE: /* visible (only in Graph Editor) */ + *neg= 1; + return ADT_CURVES_NOT_VISIBLE; + + default: /* unsupported */ + return 0; + } +} + +/* get pointer to the setting */ +static void *acf_dsmball_setting_ptr(bAnimListElem *ale, int setting, short *type) +{ + MetaBall *mb= (MetaBall *)ale->data; + + /* clear extra return data first */ + *type= 0; + + switch (setting) { + case ACHANNEL_SETTING_EXPAND: /* expanded */ + GET_ACF_FLAG_PTR(mb->flag); + + case ACHANNEL_SETTING_MUTE: /* muted (for NLA only) */ + case ACHANNEL_SETTING_VISIBLE: /* visible (for Graph Editor only) */ + if (mb->adt) + GET_ACF_FLAG_PTR(mb->adt->flag) + else + return NULL; + + default: /* unsupported */ + return NULL; + } +} + +/* metaball expander type define */ +static bAnimChannelType ACF_DSMBALL= +{ + acf_generic_dataexpand_backdrop,/* backdrop */ + acf_generic_indention_1, /* indent level */ + acf_generic_basic_offset, /* offset */ + + acf_generic_idblock_name, /* name */ + acf_dsmball_icon, /* icon */ + + acf_generic_dataexpand_setting_valid, /* has setting */ + acf_dsmball_setting_flag, /* flag for setting */ + acf_dsmball_setting_ptr /* pointer for setting */ +}; + +/* ShapeKey Entry ------------------------------------------- */ +// XXX ... this is currently obsolete... + +#if 0 +static void dummy_olddraw_shapekeys () +{ + case ANIMTYPE_SHAPEKEY: /* shapekey channel */ + { + KeyBlock *kb = (KeyBlock *)ale->data; + + indent = 0; + special = -1; + + offset= (ale->id) ? 21 : 0; + + if (kb->name[0] == '\0') + sprintf(name, "Key %d", ale->index); + else + strcpy(name, kb->name); + } + break; +} +#endif + +/* Grease Pencil entries ------------------------------------------- */ +// XXX ... this is currently not restored yet + +#if 0 +static void dummy_olddraw_gpencil () +{ + /* determine what needs to be drawn */ + switch (ale->type) { + case ANIMTYPE_GPDATABLOCK: /* gpencil datablock */ + { + bGPdata *gpd = (bGPdata *)ale->data; + ScrArea *sa = (ScrArea *)ale->owner; + + indent = 0; + group= 3; + + /* only show expand if there are any channels */ + if (gpd->layers.first) { + if (gpd->flag & GP_DATA_EXPAND) + expand = ICON_TRIA_DOWN; + else + expand = ICON_TRIA_RIGHT; + } + + switch (sa->spacetype) { + case SPACE_VIEW3D: + { + /* this shouldn't cause any overflow... */ + //sprintf(name, "3DView:%s", view3d_get_name(sa->spacedata.first)); // XXX missing func.. + strcpy(name, "3dView"); + special= ICON_VIEW3D; + } + break; + case SPACE_NODE: + { + SpaceNode *snode= sa->spacedata.first; + char treetype[12]; + + if (snode->treetype == 1) + strcpy(treetype, "Composite"); + else + strcpy(treetype, "Material"); + sprintf(name, "Nodes:%s", treetype); + + special= ICON_NODE; + } + break; + case SPACE_SEQ: + { + SpaceSeq *sseq= sa->spacedata.first; + char imgpreview[10]; + + switch (sseq->mainb) { + case 1: sprintf(imgpreview, "Image..."); break; + case 2: sprintf(imgpreview, "Luma..."); break; + case 3: sprintf(imgpreview, "Chroma..."); break; + case 4: sprintf(imgpreview, "Histogram"); break; + + default: sprintf(imgpreview, "Sequence"); break; + } + sprintf(name, "Sequencer:%s", imgpreview); + + special= ICON_SEQUENCE; + } + break; + case SPACE_IMAGE: + { + SpaceImage *sima= sa->spacedata.first; + + if (sima->image) + sprintf(name, "Image:%s", sima->image->id.name+2); + else + strcpy(name, "Image:<None>"); + + special= ICON_IMAGE_COL; + } + break; + + default: + { + sprintf(name, "<Unknown GP-Data Source>"); + special= -1; + } + break; + } + } + break; + case ANIMTYPE_GPLAYER: /* gpencil layer */ + { + bGPDlayer *gpl = (bGPDlayer *)ale->data; + + indent = 0; + special = -1; + expand = -1; + group = 1; + + if (EDITABLE_GPL(gpl)) + protect = ICON_UNLOCKED; + else + protect = ICON_LOCKED; + + if (gpl->flag & GP_LAYER_HIDE) + mute = ICON_MUTE_IPO_ON; + else + mute = ICON_MUTE_IPO_OFF; + + sel = SEL_GPL(gpl); + BLI_snprintf(name, 32, gpl->info); + } + break; + } + + if (group == 3) { + /* only for gp-data channels */ + UI_ThemeColorShade(TH_GROUP, 20); + uiSetRoundBox((expand == ICON_TRIA_DOWN)? (1):(1|8)); + gl_round_box(GL_POLYGON, x+offset, yminc, (float)ACHANNEL_NAMEWIDTH, ymaxc, 8); + } +} +#endif + +/* *********************************************** */ +/* Type Registration and General Access */ + +/* These globals only ever get directly accessed in this file */ +static bAnimChannelType *animchannelTypeInfo[ANIMTYPE_NUM_TYPES]; +static short ACF_INIT= 1; /* when non-zero, the list needs to be updated */ + +/* Initialise type info definitions */ +void ANIM_init_channel_typeinfo_data (void) +{ + int type= 0; + + /* start initialising if necessary... */ + if (ACF_INIT) { + ACF_INIT= 0; + + animchannelTypeInfo[type++]= NULL; /* None */ + animchannelTypeInfo[type++]= NULL; /* AnimData */ + animchannelTypeInfo[type++]= NULL; /* Special */ + + animchannelTypeInfo[type++]= &ACF_SCENE; /* Scene */ + animchannelTypeInfo[type++]= &ACF_OBJECT; /* Object */ + animchannelTypeInfo[type++]= &ACF_GROUP; /* Group */ + animchannelTypeInfo[type++]= &ACF_FCURVE; /* F-Curve */ + + animchannelTypeInfo[type++]= &ACF_FILLACTD; /* Object Action Expander */ + animchannelTypeInfo[type++]= &ACF_FILLDRIVERS; /* Drivers Expander */ + animchannelTypeInfo[type++]= &ACF_FILLMATD; /* Materials Expander */ + animchannelTypeInfo[type++]= &ACF_FILLPARTD; /* Particles Expander */ + + animchannelTypeInfo[type++]= &ACF_DSMAT; /* Material Channel */ + animchannelTypeInfo[type++]= &ACF_DSLAM; /* Lamp Channel */ + animchannelTypeInfo[type++]= &ACF_DSCAM; /* Camera Channel */ + animchannelTypeInfo[type++]= &ACF_DSCUR; /* Curve Channel */ + animchannelTypeInfo[type++]= &ACF_DSSKEY; /* ShapeKey Channel */ + animchannelTypeInfo[type++]= &ACF_DSWOR; /* World Channel */ + animchannelTypeInfo[type++]= &ACF_DSPART; /* Particle Channel */ + animchannelTypeInfo[type++]= &ACF_DSMBALL; /* MetaBall Channel */ + + animchannelTypeInfo[type++]= NULL; /* ShapeKey */ // XXX this is no longer used for now... + + // XXX not restored yet + animchannelTypeInfo[type++]= NULL; /* Grease Pencil Datablock */ + animchannelTypeInfo[type++]= NULL; /* Grease Pencil Layer */ + + // TODO: these types still need to be implemented!!! + // probably need a few extra flags for these special cases... + animchannelTypeInfo[type++]= NULL; /* NLA Track */ + animchannelTypeInfo[type++]= NULL; /* NLA Action */ + } +} + +/* Get type info from given channel type */ +bAnimChannelType *ANIM_channel_get_typeinfo (bAnimListElem *ale) +{ + /* santiy checks */ + if (ale == NULL) + return NULL; + + /* init the typeinfo if not available yet... */ + ANIM_init_channel_typeinfo_data(); + + /* check if type is in bounds... */ + if ((ale->type >= 0) && (ale->type < ANIMTYPE_NUM_TYPES)) + return animchannelTypeInfo[ale->type]; + else + return NULL; +} + +/* --------------------------- */ + +/* Check if some setting for a channel is enabled + * Returns: 1 = On, 0 = Off, -1 = Invalid + */ +short ANIM_channel_setting_get (bAnimContext *ac, bAnimListElem *ale, int setting) +{ + bAnimChannelType *acf= ANIM_channel_get_typeinfo(ale); + + /* 1) check that the setting exists for the current context */ + if ( (acf) && (!acf->has_setting || acf->has_setting(ac, ale, setting)) ) + { + /* 2) get pointer to check for flag in, and the flag to check for */ + short negflag, ptrsize; + int flag; + void *ptr; + + flag= acf->setting_flag(setting, &negflag); + ptr= acf->setting_ptr(ale, setting, &ptrsize); + + /* check if flag is enabled */ + if (ptr && flag) { + switch (ptrsize) { + case sizeof(int): /* integer pointer for setting */ + { + int *val= (int *)ptr; + + if (negflag) + return ((*val) & flag) == 0; + else + return ((*val) & flag) != 0; + } + break; + + case sizeof(short): /* short pointer for setting */ + { + short *val= (short *)ptr; + + if (negflag) + return ((*val) & flag) == 0; + else + return ((*val) & flag) != 0; + } + break; + + case sizeof(char): /* char pointer for setting */ + { + char *val= (char *)ptr; + + if (negflag) + return ((*val) & flag) == 0; + else + return ((*val) & flag) != 0; + } + break; + } + } + } + + /* not found... */ + return -1; +} + + +/* quick macro for use in ANIM_channel_setting_set - set flag for setting according the mode given */ +#define ACF_SETTING_SET(sval, sflag, smode) \ + {\ + if (negflag) {\ + if (smode == ACHANNEL_SETFLAG_TOGGLE) (sval) ^= (sflag); \ + else if (smode == ACHANNEL_SETFLAG_ADD) (sval) &= ~(sflag); \ + else (sval) |= (sflag); \ + } \ + else {\ + if (smode == ACHANNEL_SETFLAG_TOGGLE) (sval) ^= (sflag); \ + else if (smode == ACHANNEL_SETFLAG_ADD) (sval) |= (sflag); \ + else (sval) &= ~(sflag); \ + }\ + } + +/* Change value of some setting for a channel + * - setting: eAnimChannel_Settings + * - mode: eAnimChannels_SetFlag + */ +void ANIM_channel_setting_set (bAnimContext *ac, bAnimListElem *ale, int setting, short mode) +{ + bAnimChannelType *acf= ANIM_channel_get_typeinfo(ale); + + /* 1) check that the setting exists for the current context */ + if ( (acf) && (!acf->has_setting || acf->has_setting(ac, ale, setting)) ) + { + /* 2) get pointer to check for flag in, and the flag to check for */ + short negflag, ptrsize; + int flag; + void *ptr; + + flag= acf->setting_flag(setting, &negflag); + ptr= acf->setting_ptr(ale, setting, &ptrsize); + + /* check if flag is enabled */ + if (ptr && flag) { + switch (ptrsize) { + case sizeof(int): /* integer pointer for setting */ + { + int *val= (int *)ptr; + ACF_SETTING_SET(*val, flag, mode); + } + break; + + case sizeof(short): /* short pointer for setting */ + { + short *val= (short *)ptr; + ACF_SETTING_SET(*val, flag, mode); + } + break; + + case sizeof(char): /* char pointer for setting */ + { + char *val= (char *)ptr; + ACF_SETTING_SET(*val, flag, mode); + } + break; + } + } + } +} + +/* --------------------------- */ + +// XXX hardcoded size of icons +#define ICON_WIDTH 17 +// XXX hardcoded width of sliders +#define SLIDER_WIDTH 70 + +/* Draw the given channel */ +// TODO: make this use UI controls for the buttons +void ANIM_channel_draw (bAnimContext *ac, bAnimListElem *ale, float yminc, float ymaxc) +{ + bAnimChannelType *acf= ANIM_channel_get_typeinfo(ale); + short selected, offset; + float y, ymid, ytext; + + /* sanity checks - don't draw anything */ + if ELEM(NULL, acf, ale) + return; + + /* get initial offset */ + if (acf->get_offset) + offset= acf->get_offset(ac, ale); + else + offset= 0; + + /* calculate appropriate y-coordinates for icon buttons + * 7 is hardcoded factor for half-height of icons + */ + y= (ymaxc - yminc)/2 + yminc; + ymid= y - 7; + /* y-coordinates for text is only 4 down from middle */ + ytext= y - 4; + + /* check if channel is selected */ + if (acf->has_setting(ac, ale, ACHANNEL_SETTING_SELECT)) + selected= ANIM_channel_setting_get(ac, ale, ACHANNEL_SETTING_SELECT); + else + selected= 0; + + /* set blending again, as may not be set in previous step */ + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glEnable(GL_BLEND); + + /* step 1) draw backdrop ........................................... */ + if (acf->draw_backdrop) + acf->draw_backdrop(ac, ale, yminc, ymaxc); + + /* step 2) draw expand widget ....................................... */ + if (acf->has_setting(ac, ale, ACHANNEL_SETTING_EXPAND)) { + /* just skip - drawn as widget now */ + offset += ICON_WIDTH; + } + + /* step 3) draw icon ............................................... */ + if (acf->icon) { + UI_icon_draw(offset, ymid, acf->icon(ale)); + offset += ICON_WIDTH; + } + + /* step 4) draw special toggles ................................. + * - in Graph Editor, checkboxes for visibility in curves area + * - in NLA Editor, glowing dots for solo/not solo... + */ + if (ac->sa) { + if ((ac->spacetype == SPACE_IPO) && acf->has_setting(ac, ale, ACHANNEL_SETTING_VISIBLE)) { + /* for F-Curves, draw color-preview of curve behind checkbox */ + if (ale->type == ANIMTYPE_FCURVE) { + FCurve *fcu= (FCurve *)ale->data; + + /* F-Curve channels need to have a special 'color code' box drawn, which is colored with whatever + * color the curve has stored + */ + glColor3fv(fcu->color); + + /* just a solid color rect + * hardcoded 17 pixels width is slightly wider than icon width, so that + * there's a slight border around it + */ + glRectf(offset, yminc, offset+17, ymaxc); + } + + /* icon is drawn as widget now... */ + offset += ICON_WIDTH; + } + else if ((ac->spacetype == SPACE_NLA) && acf->has_setting(ac, ale, ACHANNEL_SETTING_SOLO)) { + /* just skip - drawn as widget now */ + offset += ICON_WIDTH; + } + } + + /* step 5) draw name ............................................... */ + if (acf->name) { + char name[256]; /* hopefully this will be enough! */ + + /* set text color */ + if (selected) + UI_ThemeColor(TH_TEXT_HI); + else + UI_ThemeColor(TH_TEXT); + + /* get name */ + acf->name(ale, name); + + offset += 3; + UI_DrawString(offset, ytext, name); + } +} + +/* ------------------ */ + +/* callback for widget settings - send notifiers */ +static void achannel_setting_widget_cb(bContext *C, void *poin, void *poin2) +{ + WM_event_add_notifier(C, NC_ANIMATION|ND_ANIMCHAN_EDIT, NULL); +} + +/* callback for widget sliders - insert keyframes */ +static void achannel_setting_slider_cb(bContext *C, void *id_poin, void *fcu_poin) +{ + ID *id= (ID *)id_poin; + FCurve *fcu= (FCurve *)fcu_poin; + + Scene *scene= CTX_data_scene(C); + PointerRNA id_ptr, ptr; + PropertyRNA *prop; + short flag=0, done=0; + float cfra; + + /* get current frame */ + // NOTE: this will do for now... + cfra= (float)CFRA; + + /* get flags for keyframing */ + if (IS_AUTOKEY_FLAG(INSERTNEEDED)) + flag |= INSERTKEY_NEEDED; + if (IS_AUTOKEY_FLAG(AUTOMATKEY)) + flag |= INSERTKEY_MATRIX; + + + /* get RNA pointer, and resolve the path */ + RNA_id_pointer_create(id, &id_ptr); + + /* try to resolve the path stored in the F-Curve */ + if (RNA_path_resolve(&id_ptr, fcu->rna_path, &ptr, &prop)) { + /* insert a keyframe for this F-Curve */ + done= insert_keyframe_direct(ptr, prop, fcu, cfra, flag); + + if (done) + WM_event_add_notifier(C, NC_ANIMATION|ND_ANIMCHAN_EDIT, NULL); + } +} + + + +/* Draw a widget for some setting */ +static void draw_setting_widget (bAnimContext *ac, bAnimListElem *ale, bAnimChannelType *acf, uiBlock *block, int xpos, int ypos, int setting) +{ + short negflag, ptrsize, enabled, butType; + int flag, icon; + void *ptr; + char *tooltip; + uiBut *but = NULL; + + /* get the flag and the pointer to that flag */ + flag= acf->setting_flag(setting, &negflag); + ptr= acf->setting_ptr(ale, setting, &ptrsize); + enabled= ANIM_channel_setting_get(ac, ale, setting); + + /* get the base icon for the setting */ + switch (setting) { + case ACHANNEL_SETTING_VISIBLE: /* visibility checkboxes */ + //icon= ((enabled)? ICON_CHECKBOX_HLT : ICON_CHECKBOX_DEHLT); + icon= ICON_CHECKBOX_DEHLT; + + if (ale->type == ANIMTYPE_FCURVE) + tooltip= "F-Curve is visible in Graph Editor for editing."; + else + tooltip= "F-Curve(s) are visible in Graph Editor for editing."; + break; + + case ACHANNEL_SETTING_EXPAND: /* expanded triangle */ + //icon= ((enabled)? ICON_TRIA_DOWN : ICON_TRIA_RIGHT); + icon= ICON_TRIA_RIGHT; + tooltip= "Make channels grouped under this channel visible."; + break; + + case ACHANNEL_SETTING_SOLO: /* NLA Tracks only */ + //icon= ((enabled)? ICON_LAYER_ACTIVE : ICON_LAYER_USED); + icon= ICON_LAYER_USED; + tooltip= "NLA Track is the only one evaluated for the AnimData block it belongs to."; + break; + + /* --- */ + + case ACHANNEL_SETTING_PROTECT: /* protected lock */ + // TODO: what about when there's no protect needed? + //icon= ((enabled)? ICON_LOCKED : ICON_UNLOCKED); + icon= ICON_UNLOCKED; + tooltip= "Editability of keyframes for this channel."; + break; + + case ACHANNEL_SETTING_MUTE: /* muted eye */ + //icon= ((enabled)? ICON_MUTE_IPO_ON : ICON_MUTE_IPO_OFF); + icon= ICON_MUTE_IPO_OFF; + + if (ale->type == ALE_FCURVE) + tooltip= "Does F-Curve contribute to result."; + else + tooltip= "Do channels contribute to result."; + break; + + default: + tooltip= NULL; + icon= 0; + break; + } + + /* type of button */ + if (negflag) + butType= ICONTOGN; + else + butType= ICONTOG; + + /* draw button for setting */ + if (ptr && flag) { + switch (ptrsize) { + case sizeof(int): /* integer pointer for setting */ + but= uiDefIconButBitI(block, butType, flag, 0, icon, + xpos, ypos, ICON_WIDTH, ICON_WIDTH, ptr, 0, 0, 0, 0, tooltip); + break; + + case sizeof(short): /* short pointer for setting */ + but= uiDefIconButBitS(block, butType, flag, 0, icon, + xpos, ypos, ICON_WIDTH, ICON_WIDTH, ptr, 0, 0, 0, 0, tooltip); + break; + + case sizeof(char): /* char pointer for setting */ + but= uiDefIconButBitC(block, butType, flag, 0, icon, + xpos, ypos, ICON_WIDTH, ICON_WIDTH, ptr, 0, 0, 0, 0, tooltip); + break; + } + + /* set call to send relevant notifiers */ + // NOTE: for now, we only need to send 'edited' + if (but) + uiButSetFunc(but, achannel_setting_widget_cb, NULL, NULL); + } +} + +/* Draw UI widgets the given channel */ +// TODO: make this use UI controls for the buttons +void ANIM_channel_draw_widgets (bAnimContext *ac, bAnimListElem *ale, uiBlock *block, float yminc, float ymaxc) +{ + bAnimChannelType *acf= ANIM_channel_get_typeinfo(ale); + View2D *v2d= &ac->ar->v2d; + float y, ymid, ytext; + short offset; + + /* sanity checks - don't draw anything */ + if ELEM3(NULL, acf, ale, block) + return; + + /* get initial offset */ + if (acf->get_offset) + offset= acf->get_offset(ac, ale); + else + offset= 0; + + /* calculate appropriate y-coordinates for icon buttons + * 7 is hardcoded factor for half-height of icons + */ + y= (ymaxc - yminc)/2 + yminc; + ymid= y - 7; + /* y-coordinates for text is only 4 down from middle */ + ytext= y - 4; + + /* no button backdrop behind icons */ + uiBlockSetEmboss(block, UI_EMBOSSN); + + /* step 1) draw expand widget ....................................... */ + if (acf->has_setting(ac, ale, ACHANNEL_SETTING_EXPAND)) { + draw_setting_widget(ac, ale, acf, block, offset, ymid, ACHANNEL_SETTING_EXPAND); + offset += ICON_WIDTH; + } + + /* step 2) draw icon ............................................... */ + if (acf->icon) { + /* icon is not drawn here (not a widget) */ + offset += ICON_WIDTH; + } + + /* step 3) draw special toggles ................................. + * - in Graph Editor, checkboxes for visibility in curves area + * - in NLA Editor, glowing dots for solo/not solo... + */ + if (ac->sa) { + if ((ac->spacetype == SPACE_IPO) && acf->has_setting(ac, ale, ACHANNEL_SETTING_VISIBLE)) { + /* visibility toggle */ + draw_setting_widget(ac, ale, acf, block, offset, ymid, ACHANNEL_SETTING_VISIBLE); + offset += ICON_WIDTH; + } + else if ((ac->spacetype == SPACE_NLA) && acf->has_setting(ac, ale, ACHANNEL_SETTING_SOLO)) { + /* 'solo' setting for NLA Tracks */ + draw_setting_widget(ac, ale, acf, block, offset, ymid, ACHANNEL_SETTING_SOLO); + offset += ICON_WIDTH; + } + } + + /* step 4) draw text... */ + /* NOTE: this is not done here, since nothing to be clicked on... */ + + /* step 5) draw mute+protection toggles + (sliders) ....................... */ + /* reset offset - now goes from RHS of panel */ + offset = 0; + + // TODO: when drawing sliders, make those draw instead of these toggles if not enough space + + if (v2d) { + short draw_sliders = 0; + + /* check if we need to show the sliders */ + if ((ac->sa) && ELEM(ac->spacetype, SPACE_ACTION, SPACE_IPO)) { + switch (ac->spacetype) { + case SPACE_ACTION: + { + SpaceAction *saction= (SpaceAction *)ac->sa->spacedata.first; + draw_sliders= (saction->flag & SACTION_SLIDERS); + } + break; + case SPACE_IPO: + { + SpaceIpo *sipo= (SpaceIpo *)ac->sa->spacedata.first; + draw_sliders= (sipo->flag & SIPO_SLIDERS); + } + break; + } + } + + /* check if there's enough space for the toggles if the sliders are drawn too */ + if ( !(draw_sliders) || ((v2d->mask.xmax-v2d->mask.xmin) > ACHANNEL_BUTTON_WIDTH/2) ) { + /* protect... */ + if (acf->has_setting(ac, ale, ACHANNEL_SETTING_PROTECT)) { + offset += ICON_WIDTH; + draw_setting_widget(ac, ale, acf, block, (int)v2d->cur.xmax-offset, ymid, ACHANNEL_SETTING_PROTECT); + } + /* mute... */ + if (acf->has_setting(ac, ale, ACHANNEL_SETTING_MUTE)) { + offset += ICON_WIDTH; + draw_setting_widget(ac, ale, acf, block, (int)v2d->cur.xmax-offset, ymid, ACHANNEL_SETTING_MUTE); + } + } + + /* draw slider + * - even if we can draw sliders for this view, we must also check that the channel-type supports them + * (only only F-Curves really can support them for now) + * - to make things easier, we use RNA-autobuts for this so that changes are reflected immediately, + * whereever they occurred. BUT, we don't use the layout engine, otherwise we'd get wrong alignment, + * and wouldn't be able to auto-keyframe... + * - slider should start before the toggles (if they're visible) to keep a clean line down the side + */ + if ((draw_sliders) && (ale->type == ANIMTYPE_FCURVE)) { + /* adjust offset */ + offset += SLIDER_WIDTH; + + /* need backdrop behind sliders... */ + uiBlockSetEmboss(block, UI_EMBOSS); + + if (ale->id) { /* Slider using RNA Access -------------------- */ + FCurve *fcu= (FCurve *)ale->data; + PointerRNA id_ptr, ptr; + PropertyRNA *prop; + + /* get RNA pointer, and resolve the path */ + RNA_id_pointer_create(ale->id, &id_ptr); + + /* try to resolve the path */ + if (RNA_path_resolve(&id_ptr, fcu->rna_path, &ptr, &prop)) { + uiBut *but; + + /* create the slider button, and assign relevant callback to ensure keyframes are inserted... */ + but= uiDefAutoButR(block, &ptr, prop, fcu->array_index, "", 0, (int)v2d->cur.xmax-offset, ymid, SLIDER_WIDTH, (int)ymaxc-yminc); + uiButSetFunc(but, achannel_setting_slider_cb, ale->id, fcu); + } + } + else { /* Special Slider for stuff without RNA Access ---------- */ + // TODO: only implement this case when we really need it... + } + } + } +} + +/* *********************************************** */ diff --git a/source/blender/editors/animation/anim_channels.c b/source/blender/editors/animation/anim_channels_edit.c index 235a3039b2c..72d8f71bc26 100644 --- a/source/blender/editors/animation/anim_channels.c +++ b/source/blender/editors/animation/anim_channels_edit.c @@ -17,11 +17,9 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * - * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. + * The Original Code is Copyright (C) 2009 Blender Foundation, Joshua Leung * All rights reserved. * - * The Original Code is: all of this file. - * * Contributor(s): Joshua Leung * * ***** END GPL LICENSE BLOCK ***** @@ -884,14 +882,6 @@ void ANIM_OT_channels_visibility_toggle (wmOperatorType *ot) /* ********************** Set Flags Operator *********************** */ -enum { -// ACHANNEL_SETTING_SELECT = 0, - ACHANNEL_SETTING_PROTECT = 1, - ACHANNEL_SETTING_MUTE, - ACHANNEL_SETTING_VISIBLE, - ACHANNEL_SETTING_EXPAND, -} eAnimChannel_Settings; - /* defines for setting animation-channel flags */ EnumPropertyItem prop_animchannel_setflag_types[] = { {ACHANNEL_SETFLAG_CLEAR, "DISABLE", 0, "Disable", ""}, @@ -901,6 +891,7 @@ EnumPropertyItem prop_animchannel_setflag_types[] = { }; /* defines for set animation-channel settings */ +// TODO: could add some more types, but those are really quite dependent on the mode... EnumPropertyItem prop_animchannel_settings_types[] = { {ACHANNEL_SETTING_PROTECT, "PROTECT", 0, "Protect", ""}, {ACHANNEL_SETTING_MUTE, "MUTE", 0, "Mute", ""}, @@ -932,213 +923,8 @@ static void setflag_anim_channels (bAnimContext *ac, short setting, short mode, /* affect selected channels */ for (ale= anim_data.first; ale; ale= ale->next) { - switch (ale->type) { - case ANIMTYPE_OBJECT: - { - Base *base= (Base *)ale->data; - Object *ob= base->object; - - if (setting == ACHANNEL_SETTING_EXPAND) { - // XXX - settings should really be moved out of ob->nlaflag - if (mode == ACHANNEL_SETFLAG_TOGGLE) ob->nlaflag ^= OB_ADS_COLLAPSED; - else if (mode == ACHANNEL_SETFLAG_ADD) ob->nlaflag &= ~OB_ADS_COLLAPSED; - else ob->nlaflag |= OB_ADS_COLLAPSED; - } - } - break; - - case ANIMTYPE_FILLACTD: - { - bAction *act= (bAction *)ale->data; - - if (ASUBCHANNEL_SEL_OK(ale)) { - if (setting == ACHANNEL_SETTING_EXPAND) { - ACHANNEL_SET_FLAG_NEG(act, mode, ACT_COLLAPSED); - } - } - } - break; - case ANIMTYPE_FILLDRIVERS: - { - AnimData *adt= (AnimData *)ale->data; - - if (ASUBCHANNEL_SEL_OK(ale)) { - if (setting == ACHANNEL_SETTING_EXPAND) { - ACHANNEL_SET_FLAG_NEG(adt, mode, ADT_DRIVERS_COLLAPSED); - } - } - } - break; - case ANIMTYPE_FILLMATD: - { - Object *ob= (Object *)ale->data; - - // XXX - settings should really be moved out of ob->nlaflag - if ((onlysel == 0) || (ob->flag & SELECT)) { - if (setting == ACHANNEL_SETTING_EXPAND) { - if (mode == ACHANNEL_SETFLAG_TOGGLE) ob->nlaflag ^= OB_ADS_SHOWMATS; - else if (mode == ACHANNEL_SETFLAG_ADD) ob->nlaflag |= OB_ADS_SHOWMATS; - else ob->nlaflag &= ~OB_ADS_SHOWMATS; - } - } - } - break; - case ANIMTYPE_FILLPARTD: - { - Object *ob= (Object *)ale->data; - - // XXX - settings should really be moved out of ob->nlaflag - if ((onlysel == 0) || (ob->flag & SELECT)) { - if (setting == ACHANNEL_SETTING_EXPAND) { - if (mode == ACHANNEL_SETFLAG_TOGGLE) ob->nlaflag ^= OB_ADS_SHOWPARTS; - else if (mode == ACHANNEL_SETFLAG_ADD) ob->nlaflag |= OB_ADS_SHOWPARTS; - else ob->nlaflag &= ~OB_ADS_SHOWPARTS; - } - } - } - break; - - case ANIMTYPE_DSMAT: - { - Material *ma= (Material *)ale->data; - - if (ASUBCHANNEL_SEL_OK(ale)) { - if (setting == ACHANNEL_SETTING_EXPAND) { - ACHANNEL_SET_FLAG(ma, mode, MA_DS_EXPAND); - } - } - } - break; - case ANIMTYPE_DSLAM: - { - Lamp *la= (Lamp *)ale->data; - - if (ASUBCHANNEL_SEL_OK(ale)) { - if (setting == ACHANNEL_SETTING_EXPAND) { - ACHANNEL_SET_FLAG(la, mode, LA_DS_EXPAND); - } - } - } - break; - case ANIMTYPE_DSCAM: - { - Camera *ca= (Camera *)ale->data; - - if (ASUBCHANNEL_SEL_OK(ale)) { - if (setting == ACHANNEL_SETTING_EXPAND) { - ACHANNEL_SET_FLAG(ca, mode, CAM_DS_EXPAND); - } - } - } - break; - case ANIMTYPE_DSCUR: - { - Curve *cu= (Curve *)ale->data; - - if (ASUBCHANNEL_SEL_OK(ale)) { - if (setting == ACHANNEL_SETTING_EXPAND) { - ACHANNEL_SET_FLAG(cu, mode, CU_DS_EXPAND); - } - } - } - break; - case ANIMTYPE_DSSKEY: - { - Key *key= (Key *)ale->data; - - if (ASUBCHANNEL_SEL_OK(ale)) { - if (setting == ACHANNEL_SETTING_EXPAND) { - ACHANNEL_SET_FLAG(key, mode, KEYBLOCK_DS_EXPAND); - } - } - } - break; - case ANIMTYPE_DSWOR: - { - World *wo= (World *)ale->data; - - if (ASUBCHANNEL_SEL_OK(ale)) { - if (setting == ACHANNEL_SETTING_EXPAND) { - ACHANNEL_SET_FLAG(wo, mode, WO_DS_EXPAND); - } - } - } - break; - case ANIMTYPE_DSPART: - { - ParticleSettings *part= (ParticleSettings*)ale->data; - - if (ASUBCHANNEL_SEL_OK(ale)) { - if (setting == ACHANNEL_SETTING_EXPAND) { - ACHANNEL_SET_FLAG(part, mode, PART_DS_EXPAND); - } - } - } - break; - case ANIMTYPE_DSMBALL: - { - MetaBall *mb= (MetaBall *)ale->data; - - if (ASUBCHANNEL_SEL_OK(ale)) { - if (setting == ACHANNEL_SETTING_EXPAND) { - ACHANNEL_SET_FLAG(mb, mode, MB_DS_EXPAND); - } - } - } - break; - - case ANIMTYPE_GROUP: - { - bActionGroup *agrp= (bActionGroup *)ale->data; - - switch (setting) { - case ACHANNEL_SETTING_PROTECT: - ACHANNEL_SET_FLAG(agrp, mode, AGRP_PROTECTED); - break; - case ACHANNEL_SETTING_EXPAND: - ACHANNEL_SET_FLAG(agrp, mode, AGRP_EXPANDED); - break; - case ACHANNEL_SETTING_MUTE: - ACHANNEL_SET_FLAG(agrp, mode, AGRP_MUTED); - break; - case ACHANNEL_SETTING_VISIBLE: - ACHANNEL_SET_FLAG_NEG(agrp, mode, AGRP_NOTVISIBLE); - break; - } - } - break; - case ANIMTYPE_FCURVE: - { - FCurve *fcu= (FCurve *)ale->data; - - switch (setting) { - case ACHANNEL_SETTING_MUTE: - ACHANNEL_SET_FLAG(fcu, mode, FCURVE_MUTED); - break; - case ACHANNEL_SETTING_PROTECT: - ACHANNEL_SET_FLAG(fcu, mode, FCURVE_PROTECTED); - break; - case ACHANNEL_SETTING_VISIBLE: - ACHANNEL_SET_FLAG(fcu, mode, FCURVE_VISIBLE); - break; - } - } - break; - case ANIMTYPE_GPLAYER: - { - bGPDlayer *gpl= (bGPDlayer *)ale->data; - - switch (setting) { - case ACHANNEL_SETTING_MUTE: - ACHANNEL_SET_FLAG(gpl, mode, GP_LAYER_HIDE); - break; - case ACHANNEL_SETTING_PROTECT: - ACHANNEL_SET_FLAG(gpl, mode, GP_LAYER_LOCKED); - break; - } - } - break; - } + /* set the setting in the appropriate way (if available) */ + ANIM_channel_setting_set(ac, ale, setting, mode); } BLI_freelistN(&anim_data); @@ -1407,47 +1193,19 @@ static void borderselect_anim_channels (bAnimContext *ac, rcti *rect, short sele /* if channel is within border-select region, alter it */ if (!((ymax < rectf.ymin) || (ymin > rectf.ymax))) { - /* only the following types can be selected */ + /* set selection flags only */ + ANIM_channel_setting_set(ac, ale, ACHANNEL_SETTING_SELECT, selectmode); + + /* type specific actions */ switch (ale->type) { - case ANIMTYPE_OBJECT: /* object */ - { - Base *base= (Base *)ale->data; - Object *ob= base->object; - - ACHANNEL_SET_FLAG(base, selectmode, SELECT); - ACHANNEL_SET_FLAG(ob, selectmode, SELECT); - } - break; - case ANIMTYPE_GROUP: /* action group */ + case ANIMTYPE_GROUP: { bActionGroup *agrp= (bActionGroup *)ale->data; - ACHANNEL_SET_FLAG(agrp, selectmode, AGRP_SELECTED); + /* always clear active flag after doing this */ agrp->flag &= ~AGRP_ACTIVE; } break; - case ANIMTYPE_FCURVE: /* F-Curve channel */ - { - FCurve *fcu = (FCurve *)ale->data; - - ACHANNEL_SET_FLAG(fcu, selectmode, FCURVE_SELECTED); - } - break; - case ANIMTYPE_GPLAYER: /* grease-pencil layer */ - { - bGPDlayer *gpl = (bGPDlayer *)ale->data; - - ACHANNEL_SET_FLAG(gpl, selectmode, GP_LAYER_SELECT); - } - break; - - case ANIMTYPE_NLATRACK: /* nla-track */ - { - NlaTrack *nlt= (NlaTrack *)ale->data; - - ACHANNEL_SET_FLAG(nlt, selectmode, NLATRACK_SELECTED); - } - break; } } @@ -1519,11 +1277,7 @@ void ANIM_OT_channels_select_border(wmOperatorType *ot) } /* ******************** Mouse-Click Operator *********************** */ -/* Depending on the channel that was clicked on, the mouse click will activate whichever - * part of the channel is relevant. - * - * NOTE: eventually, this should probably be phased out when many of these things are replaced with buttons - */ +/* Handle selection changes due to clicking on channels. Settings will get caught by UI code... */ static int mouse_anim_channels (bAnimContext *ac, float x, int channel_index, short selectmode) { @@ -1561,24 +1315,16 @@ static int mouse_anim_channels (bAnimContext *ac, float x, int channel_index, sh { Scene *sce= (Scene *)ale->data; - if (x < 16) { - /* toggle expand */ - sce->flag ^= SCE_DS_COLLAPSED; - - notifierFlags |= ND_ANIMCHAN_EDIT; + /* set selection status */ + if (selectmode == SELECT_INVERT) { + /* swap select */ + sce->flag ^= SCE_DS_SELECTED; } else { - /* set selection status */ - if (selectmode == SELECT_INVERT) { - /* swap select */ - sce->flag ^= SCE_DS_SELECTED; - } - else { - sce->flag |= SCE_DS_SELECTED; - } - - notifierFlags |= ND_ANIMCHAN_SELECT; + sce->flag |= SCE_DS_SELECTED; } + + notifierFlags |= ND_ANIMCHAN_SELECT; } break; case ANIMTYPE_OBJECT: @@ -1588,233 +1334,87 @@ static int mouse_anim_channels (bAnimContext *ac, float x, int channel_index, sh Base *base= (Base *)ale->data; Object *ob= base->object; - if (x < 16) { - /* toggle expand */ - ob->nlaflag ^= OB_ADS_COLLAPSED; // XXX - - notifierFlags |= ND_ANIMCHAN_EDIT; + /* set selection status */ + if (selectmode == SELECT_INVERT) { + /* swap select */ + base->flag ^= SELECT; + ob->flag= base->flag; } else { - /* set selection status */ - if (selectmode == SELECT_INVERT) { - /* swap select */ - base->flag ^= SELECT; - ob->flag= base->flag; - } - else { - Base *b; - - /* deleselect all */ - for (b= sce->base.first; b; b= b->next) { - b->flag &= ~SELECT; - b->object->flag= b->flag; - } - - /* select object now */ - base->flag |= SELECT; - ob->flag |= SELECT; - } + Base *b; - /* xxx should be ED_base_object_activate(), but we need context pointer for that... */ - //set_active_base(base); + /* deleselect all */ + for (b= sce->base.first; b; b= b->next) { + b->flag &= ~SELECT; + b->object->flag= b->flag; + } - notifierFlags |= ND_ANIMCHAN_SELECT; + /* select object now */ + base->flag |= SELECT; + ob->flag |= SELECT; } - } - break; - case ANIMTYPE_FILLACTD: - { - bAction *act= (bAction *)ale->data; - act->flag ^= ACT_COLLAPSED; - notifierFlags |= ND_ANIMCHAN_EDIT; - } - break; - case ANIMTYPE_FILLDRIVERS: - { - AnimData *adt= (AnimData* )ale->data; - adt->flag ^= ADT_DRIVERS_COLLAPSED; - notifierFlags |= ND_ANIMCHAN_EDIT; - } - break; - case ANIMTYPE_FILLMATD: - { - Object *ob= (Object *)ale->data; - ob->nlaflag ^= OB_ADS_SHOWMATS; // XXX - notifierFlags |= ND_ANIMCHAN_EDIT; - } - break; - case ANIMTYPE_FILLPARTD: - { - Object *ob= (Object *)ale->data; - ob->nlaflag ^= OB_ADS_SHOWPARTS; // XXX - notifierFlags |= ND_ANIMCHAN_EDIT; - } - break; - - case ANIMTYPE_DSMAT: - { - Material *ma= (Material *)ale->data; - ma->flag ^= MA_DS_EXPAND; - notifierFlags |= ND_ANIMCHAN_EDIT; - } - break; - case ANIMTYPE_DSLAM: - { - Lamp *la= (Lamp *)ale->data; - la->flag ^= LA_DS_EXPAND; - notifierFlags |= ND_ANIMCHAN_EDIT; - } - break; - case ANIMTYPE_DSCAM: - { - Camera *ca= (Camera *)ale->data; - ca->flag ^= CAM_DS_EXPAND; - notifierFlags |= ND_ANIMCHAN_EDIT; - } - break; - case ANIMTYPE_DSCUR: - { - Curve *cu= (Curve *)ale->data; - cu->flag ^= CU_DS_EXPAND; - notifierFlags |= ND_ANIMCHAN_EDIT; - } - break; - case ANIMTYPE_DSSKEY: - { - Key *key= (Key *)ale->data; - key->flag ^= KEYBLOCK_DS_EXPAND; - notifierFlags |= ND_ANIMCHAN_EDIT; - } - break; - case ANIMTYPE_DSWOR: - { - World *wo= (World *)ale->data; - wo->flag ^= WO_DS_EXPAND; - notifierFlags |= ND_ANIMCHAN_EDIT; - } - break; - case ANIMTYPE_DSPART: - { - ParticleSettings *part= (ParticleSettings *)ale->data; - part->flag ^= PART_DS_EXPAND; - notifierFlags |= ND_ANIMCHAN_EDIT; - } - break; - case ANIMTYPE_DSMBALL: - { - MetaBall *mb= (MetaBall *)ale->data; - mb->flag2 ^= MB_DS_EXPAND; - notifierFlags |= ND_ANIMCHAN_EDIT; + + /* xxx should be ED_base_object_activate(), but we need context pointer for that... */ + //set_active_base(base); + + notifierFlags |= ND_ANIMCHAN_SELECT; } break; case ANIMTYPE_GROUP: { bActionGroup *agrp= (bActionGroup *)ale->data; - short offset= (ELEM3(ac->datatype, ANIMCONT_DOPESHEET, ANIMCONT_FCURVES, ANIMCONT_DRIVERS))? 18 : 0; - if ((x < (offset+17)) && (agrp->channels.first)) { - /* toggle expand */ - agrp->flag ^= AGRP_EXPANDED; - notifierFlags |= ND_ANIMCHAN_EDIT; - } - else if ((x < (offset+32)) && (ac->spacetype==SPACE_IPO)) { - /* toggle visibility (of grouped F-Curves in Graph editor) */ - agrp->flag ^= AGRP_NOTVISIBLE; - notifierFlags |= ND_ANIMCHAN_EDIT; - } - else if (x >= (ACHANNEL_NAMEWIDTH-ACHANNEL_BUTTON_WIDTH)) { - /* toggle protection/locking */ - agrp->flag ^= AGRP_PROTECTED; - notifierFlags |= ND_ANIMCHAN_EDIT; + /* select/deselect group */ + if (selectmode == SELECT_INVERT) { + /* inverse selection status of this group only */ + agrp->flag ^= AGRP_SELECTED; } - else if (x >= (ACHANNEL_NAMEWIDTH-2*ACHANNEL_BUTTON_WIDTH)) { - /* toggle mute */ - agrp->flag ^= AGRP_MUTED; - notifierFlags |= ND_ANIMCHAN_EDIT; + else if (selectmode == -1) { + /* select all in group (and deselect everthing else) */ + FCurve *fcu; + + /* deselect all other channels */ + ANIM_deselect_anim_channels(ac->data, ac->datatype, 0, ACHANNEL_SETFLAG_CLEAR); + + /* only select channels in group and group itself */ + for (fcu= agrp->channels.first; fcu && fcu->grp==agrp; fcu= fcu->next) + fcu->flag |= FCURVE_SELECTED; + agrp->flag |= AGRP_SELECTED; } else { - /* select/deselect group */ - if (selectmode == SELECT_INVERT) { - /* inverse selection status of this group only */ - agrp->flag ^= AGRP_SELECTED; - } - else if (selectmode == -1) { - /* select all in group (and deselect everthing else) */ - FCurve *fcu; - - /* deselect all other channels */ - ANIM_deselect_anim_channels(ac->data, ac->datatype, 0, ACHANNEL_SETFLAG_CLEAR); - - /* only select channels in group and group itself */ - for (fcu= agrp->channels.first; fcu && fcu->grp==agrp; fcu= fcu->next) - fcu->flag |= FCURVE_SELECTED; - agrp->flag |= AGRP_SELECTED; - } - else { - /* select group by itself */ - ANIM_deselect_anim_channels(ac->data, ac->datatype, 0, ACHANNEL_SETFLAG_CLEAR); - agrp->flag |= AGRP_SELECTED; - } - - /* if group is selected now, make group the 'active' one in the visible list */ - if (agrp->flag & AGRP_SELECTED) - ANIM_set_active_channel(ac, ac->data, ac->datatype, filter, agrp, ANIMTYPE_GROUP); - - notifierFlags |= ND_ANIMCHAN_SELECT; + /* select group by itself */ + ANIM_deselect_anim_channels(ac->data, ac->datatype, 0, ACHANNEL_SETFLAG_CLEAR); + agrp->flag |= AGRP_SELECTED; } + + /* if group is selected now, make group the 'active' one in the visible list */ + if (agrp->flag & AGRP_SELECTED) + ANIM_set_active_channel(ac, ac->data, ac->datatype, filter, agrp, ANIMTYPE_GROUP); + + notifierFlags |= ND_ANIMCHAN_SELECT; } break; case ANIMTYPE_FCURVE: { FCurve *fcu= (FCurve *)ale->data; - short offset; - - if (ac->datatype != ANIMCONT_ACTION) { - /* for now, special case for materials */ - if (ale->ownertype == ANIMTYPE_DSMAT) - offset= 21; - else - offset= 18; - } - else - offset = 0; - if (x >= (ACHANNEL_NAMEWIDTH-ACHANNEL_BUTTON_WIDTH)) { - /* toggle protection (only if there's a toggle there) */ - if (fcu->bezt) { - fcu->flag ^= FCURVE_PROTECTED; - notifierFlags |= ND_ANIMCHAN_EDIT; - } - } - else if (x >= (ACHANNEL_NAMEWIDTH-2*ACHANNEL_BUTTON_WIDTH)) { - /* toggle mute */ - fcu->flag ^= FCURVE_MUTED; - notifierFlags |= ND_ANIMCHAN_EDIT; - } - else if ((x < (offset+17)) && (ac->spacetype==SPACE_IPO)) { - /* toggle visibility */ - fcu->flag ^= FCURVE_VISIBLE; - notifierFlags |= ND_ANIMCHAN_EDIT; + /* select/deselect */ + if (selectmode == SELECT_INVERT) { + /* inverse selection status of this F-Curve only */ + fcu->flag ^= FCURVE_SELECTED; } else { - /* select/deselect */ - if (selectmode == SELECT_INVERT) { - /* inverse selection status of this F-Curve only */ - fcu->flag ^= FCURVE_SELECTED; - } - else { - /* select F-Curve by itself */ - ANIM_deselect_anim_channels(ac->data, ac->datatype, 0, ACHANNEL_SETFLAG_CLEAR); - fcu->flag |= FCURVE_SELECTED; - } - - /* if F-Curve is selected now, make F-Curve the 'active' one in the visible list */ - if (fcu->flag & FCURVE_SELECTED) - ANIM_set_active_channel(ac, ac->data, ac->datatype, filter, fcu, ANIMTYPE_FCURVE); - - notifierFlags |= ND_ANIMCHAN_SELECT; + /* select F-Curve by itself */ + ANIM_deselect_anim_channels(ac->data, ac->datatype, 0, ACHANNEL_SETFLAG_CLEAR); + fcu->flag |= FCURVE_SELECTED; } + + /* if F-Curve is selected now, make F-Curve the 'active' one in the visible list */ + if (fcu->flag & FCURVE_SELECTED) + ANIM_set_active_channel(ac, ac->data, ac->datatype, filter, fcu, ANIMTYPE_FCURVE); + + notifierFlags |= ND_ANIMCHAN_SELECT; } break; case ANIMTYPE_GPDATABLOCK: diff --git a/source/blender/editors/animation/anim_deps.c b/source/blender/editors/animation/anim_deps.c index 13667159fe0..af2355b91a5 100644 --- a/source/blender/editors/animation/anim_deps.c +++ b/source/blender/editors/animation/anim_deps.c @@ -138,6 +138,7 @@ void ANIM_action_to_pose_sync (Object *ob) */ void ANIM_pose_to_action_sync (Object *ob, ScrArea *sa) { +#if 0 // XXX old animation system SpaceAction *saction= (SpaceAction *)sa->spacedata.first; bArmature *arm= (bArmature *)ob->data; bAction *act= (bAction *)ob->action; @@ -174,4 +175,5 @@ void ANIM_pose_to_action_sync (Object *ob, ScrArea *sa) // XXX step 2 needs to be coded still... currently missing action/bone group API to do any more work here... // XXX step 3 needs to be coded still... it's a messy case to deal with (we'll use the temp indices for this?) +#endif // XXX old animation system } diff --git a/source/blender/editors/animation/anim_filter.c b/source/blender/editors/animation/anim_filter.c index 4797c7946a4..37c8aeac13a 100644 --- a/source/blender/editors/animation/anim_filter.c +++ b/source/blender/editors/animation/anim_filter.c @@ -374,27 +374,29 @@ short ANIM_animdata_get_context (const bContext *C, bAnimContext *ac) */ #define ANIMDATA_FILTER_CASES(id, adtOk, nlaOk, driversOk, keysOk) \ {\ - if (filter_mode & ANIMFILTER_ANIMDATA) {\ - if ((id)->adt) {\ - adtOk\ - }\ - }\ - else if (ads->filterflag & ADS_FILTER_ONLYNLA) {\ - if (ANIMDATA_HAS_NLA(id)) {\ - nlaOk\ - }\ - else if (!(ads->filterflag & ADS_FILTER_NLA_NOACT) && ANIMDATA_HAS_KEYS(id)) {\ - nlaOk\ - }\ - }\ - else if (ads->filterflag & ADS_FILTER_ONLYDRIVERS) {\ - if (ANIMDATA_HAS_DRIVERS(id)) {\ - driversOk\ - }\ - }\ - else {\ - if (ANIMDATA_HAS_KEYS(id)) {\ - keysOk\ + if ((id)->adt) {\ + if (!(filter_mode & ANIMFILTER_CURVEVISIBLE) || !((id)->adt->flag & ADT_CURVES_NOT_VISIBLE)) {\ + if (filter_mode & ANIMFILTER_ANIMDATA) {\ + adtOk\ + }\ + else if (ads->filterflag & ADS_FILTER_ONLYNLA) {\ + if (ANIMDATA_HAS_NLA(id)) {\ + nlaOk\ + }\ + else if (!(ads->filterflag & ADS_FILTER_NLA_NOACT) && ANIMDATA_HAS_KEYS(id)) {\ + nlaOk\ + }\ + }\ + else if (ads->filterflag & ADS_FILTER_ONLYDRIVERS) {\ + if (ANIMDATA_HAS_DRIVERS(id)) {\ + driversOk\ + }\ + }\ + else {\ + if (ANIMDATA_HAS_KEYS(id)) {\ + keysOk\ + }\ + }\ }\ }\ } @@ -1465,6 +1467,14 @@ static int animdata_filter_dopesheet (ListBase *anim_data, bDopeSheet *ads, int worOk= !(ads->filterflag & ADS_FILTER_NOWOR);) } + /* if only F-Curves with visible flags set can be shown, check that + * datablocks haven't been set to invisible + */ + if (filter_mode & ANIMFILTER_CURVEVISIBLE) { + if ((sce->adt) && (sce->adt->flag & ADT_CURVES_NOT_VISIBLE)) + sceOk= worOk= 0; + } + /* check if not all bad (i.e. so there is something to show) */ if ( !(!sceOk && !worOk) ) { /* add scene data to the list of filtered channels */ @@ -1481,7 +1491,7 @@ static int animdata_filter_dopesheet (ListBase *anim_data, bDopeSheet *ads, int Key *key= ob_get_key(ob); short actOk=1, keyOk=1, dataOk=1, matOk=1, partOk=1; - /* firstly, check if object can be included, by the following fanimors: + /* firstly, check if object can be included, by the following factors: * - if only visible, must check for layer and also viewport visibility * - if only selected, must check if object is selected * - there must be animation data to edit @@ -1495,6 +1505,14 @@ static int animdata_filter_dopesheet (ListBase *anim_data, bDopeSheet *ads, int if (ob->restrictflag & OB_RESTRICT_VIEW) continue; } + /* if only F-Curves with visible flags set can be shown, check that + * datablock hasn't been set to invisible + */ + if (filter_mode & ANIMFILTER_CURVEVISIBLE) { + if ((ob->adt) && (ob->adt->flag & ADT_CURVES_NOT_VISIBLE)) + continue; + } + /* additionally, dopesheet filtering also affects what objects to consider */ if (ads->filterflag) { /* check selection and object type filters */ diff --git a/source/blender/editors/animation/anim_ipo_utils.c b/source/blender/editors/animation/anim_ipo_utils.c index aecf437a30b..26edf930f0b 100644 --- a/source/blender/editors/animation/anim_ipo_utils.c +++ b/source/blender/editors/animation/anim_ipo_utils.c @@ -93,9 +93,8 @@ int geticon_anim_blocktype(short blocktype) } /* Write into "name" buffer, the name of the property (retrieved using RNA from the curve's settings) - * WARNING: name buffer we're writing to cannot exceed 128 chars (check action_draw.c for details) + * WARNING: name buffer we're writing to cannot exceed 256 chars (check anim_channels_defines.c for details) */ -// TODO: have an extra var to indicate if prop was valid? void getname_anim_fcurve(char *name, ID *id, FCurve *fcu) { /* sanity checks */ @@ -148,26 +147,14 @@ void getname_anim_fcurve(char *name, ID *id, FCurve *fcu) propname= (char *)RNA_property_ui_name(prop); /* Array Index - only if applicable */ - if (RNA_property_array_length(prop)) { - static char *vectoritem[4]= {"X ", "Y ", "Z ", "W "}; - static char *quatitem[4]= {"W ", "X ", "Y ", "Z "}; - static char *coloritem[4]= {"R ", "G ", "B ", "A "}; + if (RNA_property_array_length(&ptr, prop)) { + char c= RNA_property_array_item_char(prop, fcu->array_index); - int tot= RNA_property_array_length(prop); - int propsubtype= RNA_property_subtype(prop); - - /* get string to use for array index */ - if ((tot == 4) && (propsubtype == PROP_ROTATION)) - arrayname= quatitem[fcu->array_index]; - else if ( (tot <= 4) && ((propsubtype == PROP_VECTOR) || (propsubtype == PROP_ROTATION)) ) - arrayname= vectoritem[fcu->array_index]; - else if ((tot <= 4) && (propsubtype == PROP_COLOR)) - arrayname= coloritem[fcu->array_index]; - else { - /* we need to write the index to a temp buffer (in py syntax), as it is a number... */ - sprintf(arrayindbuf, "[%d]", fcu->array_index); - arrayname= &arrayindbuf[0]; - } + /* we need to write the index to a temp buffer (in py syntax) */ + if(c) sprintf(arrayindbuf, "%c ", c); + else sprintf(arrayindbuf, "[%d]", fcu->array_index); + + arrayname= &arrayindbuf[0]; } else { /* no array index */ diff --git a/source/blender/editors/animation/anim_ops.c b/source/blender/editors/animation/anim_ops.c index 9c039693b72..72fee937e25 100644 --- a/source/blender/editors/animation/anim_ops.c +++ b/source/blender/editors/animation/anim_ops.c @@ -56,6 +56,8 @@ #include "ED_markers.h" #include "ED_screen.h" +#include "BKE_sound.h" + /* ********************** frame change operator ***************************/ /* Set any flags that are necessary to indicate modal time-changing operation */ @@ -91,6 +93,8 @@ static void change_frame_apply(bContext *C, wmOperator *op) if (cfra < MINAFRAME) cfra= MINAFRAME; CFRA= cfra; + sound_scrub(C); + WM_event_add_notifier(C, NC_SCENE|ND_FRAME, scene); } @@ -121,6 +125,7 @@ static int change_frame_exec(bContext *C, wmOperator *op) change_frame_apply(C, op); change_frame_exit(C, op); + return OPERATOR_FINISHED; } @@ -393,9 +398,6 @@ void ED_operatortypes_anim(void) WM_operatortype_append(ANIM_OT_add_driver_button); WM_operatortype_append(ANIM_OT_remove_driver_button); - - WM_operatortype_append(ANIM_OT_keyingset_add_new); - WM_operatortype_append(ANIM_OT_keyingset_add_destination); } void ED_keymap_anim(wmWindowManager *wm) diff --git a/source/blender/editors/animation/drivers.c b/source/blender/editors/animation/drivers.c index 849e2d2eede..e7b7d785d7b 100644 --- a/source/blender/editors/animation/drivers.c +++ b/source/blender/editors/animation/drivers.c @@ -157,7 +157,7 @@ short ANIM_add_driver (ID *id, const char rna_path[], int array_index, short fla /* fill in current value for python */ if(type == DRIVER_TYPE_PYTHON) { PropertyType proptype= RNA_property_type(prop); - int array= RNA_property_array_length(prop); + int array= RNA_property_array_length(&ptr, prop); char *expression= fcu->driver->expression; int val, maxlen= sizeof(fcu->driver->expression); float fval; @@ -241,7 +241,7 @@ static int add_driver_button_exec (bContext *C, wmOperator *op) if (path) { if (all) { - length= RNA_property_array_length(prop); + length= RNA_property_array_length(&ptr, prop); if (length) index= 0; else length= 1; @@ -303,7 +303,7 @@ static int remove_driver_button_exec (bContext *C, wmOperator *op) if (path) { if (all) { - length= RNA_property_array_length(prop); + length= RNA_property_array_length(&ptr, prop); if(length) index= 0; else length= 1; diff --git a/source/blender/editors/animation/fmodifier_ui.c b/source/blender/editors/animation/fmodifier_ui.c index 7a618f4d222..4aff26105f3 100644 --- a/source/blender/editors/animation/fmodifier_ui.c +++ b/source/blender/editors/animation/fmodifier_ui.c @@ -258,14 +258,14 @@ static void draw_modifier__fn_generator(uiLayout *layout, ID *id, FModifier *fcm /* add the settings */ col= uiLayoutColumn(layout, 1); - uiItemR(col, "", 0, &ptr, "type", 0, 0, 0); - uiItemR(col, NULL, 0, &ptr, "additive", 0, 0, 1); + uiItemR(col, "", 0, &ptr, "type", 0); + uiItemR(col, NULL, 0, &ptr, "additive", UI_ITEM_R_TOGGLE); col= uiLayoutColumn(layout, 0); // no grouping for now - uiItemR(col, NULL, 0, &ptr, "amplitude", 0, 0, 0); - uiItemR(col, NULL, 0, &ptr, "phase_multiplier", 0, 0, 0); - uiItemR(col, NULL, 0, &ptr, "phase_offset", 0, 0, 0); - uiItemR(col, NULL, 0, &ptr, "value_offset", 0, 0, 0); + uiItemR(col, NULL, 0, &ptr, "amplitude", 0); + uiItemR(col, NULL, 0, &ptr, "phase_multiplier", 0); + uiItemR(col, NULL, 0, &ptr, "phase_offset", 0); + uiItemR(col, NULL, 0, &ptr, "value_offset", 0); } /* --------------- */ @@ -287,14 +287,14 @@ static void draw_modifier__cycles(uiLayout *layout, ID *id, FModifier *fcm, shor /* before range */ col= uiLayoutColumn(split, 1); uiItemL(col, "Before:", 0); - uiItemR(col, "", 0, &ptr, "before_mode", 0, 0, 0); - uiItemR(col, NULL, 0, &ptr, "before_cycles", 0, 0, 0); + uiItemR(col, "", 0, &ptr, "before_mode", 0); + uiItemR(col, NULL, 0, &ptr, "before_cycles", 0); /* after range */ col= uiLayoutColumn(split, 1); uiItemL(col, "After:", 0); - uiItemR(col, "", 0, &ptr, "after_mode", 0, 0, 0); - uiItemR(col, NULL, 0, &ptr, "after_cycles", 0, 0, 0); + uiItemR(col, "", 0, &ptr, "after_mode", 0); + uiItemR(col, NULL, 0, &ptr, "after_cycles", 0); } /* --------------- */ @@ -309,20 +309,20 @@ static void draw_modifier__noise(uiLayout *layout, ID *id, FModifier *fcm, short RNA_pointer_create(id, &RNA_FModifierNoise, fcm, &ptr); /* blending mode */ - uiItemR(layout, NULL, 0, &ptr, "modification", 0, 0, 0); + uiItemR(layout, NULL, 0, &ptr, "modification", 0); /* split into 2 columns */ split= uiLayoutSplit(layout, 0.5f); /* col 1 */ col= uiLayoutColumn(split, 0); - uiItemR(col, NULL, 0, &ptr, "size", 0, 0, 0); - uiItemR(col, NULL, 0, &ptr, "strength", 0, 0, 0); + uiItemR(col, NULL, 0, &ptr, "size", 0); + uiItemR(col, NULL, 0, &ptr, "strength", 0); /* col 2 */ col= uiLayoutColumn(split, 0); - uiItemR(col, NULL, 0, &ptr, "phase", 0, 0, 0); - uiItemR(col, NULL, 0, &ptr, "depth", 0, 0, 0); + uiItemR(col, NULL, 0, &ptr, "phase", 0); + uiItemR(col, NULL, 0, &ptr, "depth", 0); } /* --------------- */ @@ -503,11 +503,11 @@ static void draw_modifier__envelope(uiLayout *layout, ID *id, FModifier *fcm, sh /* general settings */ col= uiLayoutColumn(layout, 1); uiItemL(col, "Envelope:", 0); - uiItemR(col, NULL, 0, &ptr, "reference_value", 0, 0, 0); + uiItemR(col, NULL, 0, &ptr, "reference_value", 0); row= uiLayoutRow(col, 1); - uiItemR(row, "Min", 0, &ptr, "default_minimum", 0, 0, 0); - uiItemR(row, "Max", 0, &ptr, "default_maximum", 0, 0, 0); + uiItemR(row, "Min", 0, &ptr, "default_minimum", 0); + uiItemR(row, "Max", 0, &ptr, "default_maximum", 0); /* control points header */ // TODO: move this control-point control stuff to using the new special widgets for lists @@ -559,13 +559,13 @@ static void draw_modifier__limits(uiLayout *layout, ID *id, FModifier *fcm, shor /* x-minimum */ col= uiLayoutColumn(split, 1); - uiItemR(col, NULL, 0, &ptr, "use_minimum_x", 0, 0, 0); - uiItemR(col, NULL, 0, &ptr, "minimum_x", 0, 0, 0); + uiItemR(col, NULL, 0, &ptr, "use_minimum_x", 0); + uiItemR(col, NULL, 0, &ptr, "minimum_x", 0); /* y-minimum*/ col= uiLayoutColumn(split, 1); - uiItemR(col, NULL, 0, &ptr, "use_minimum_y", 0, 0, 0); - uiItemR(col, NULL, 0, &ptr, "minimum_y", 0, 0, 0); + uiItemR(col, NULL, 0, &ptr, "use_minimum_y", 0); + uiItemR(col, NULL, 0, &ptr, "minimum_y", 0); } /* row 2: minimum */ @@ -577,13 +577,13 @@ static void draw_modifier__limits(uiLayout *layout, ID *id, FModifier *fcm, shor /* x-minimum */ col= uiLayoutColumn(split, 1); - uiItemR(col, NULL, 0, &ptr, "use_maximum_x", 0, 0, 0); - uiItemR(col, NULL, 0, &ptr, "maximum_x", 0, 0, 0); + uiItemR(col, NULL, 0, &ptr, "use_maximum_x", 0); + uiItemR(col, NULL, 0, &ptr, "maximum_x", 0); /* y-minimum*/ col= uiLayoutColumn(split, 1); - uiItemR(col, NULL, 0, &ptr, "use_maximum_y", 0, 0, 0); - uiItemR(col, NULL, 0, &ptr, "maximum_y", 0, 0, 0); + uiItemR(col, NULL, 0, &ptr, "use_maximum_y", 0); + uiItemR(col, NULL, 0, &ptr, "maximum_y", 0); } } diff --git a/source/blender/editors/animation/keyframes_general.c b/source/blender/editors/animation/keyframes_general.c index fc67ee34a2e..ced3c117700 100644 --- a/source/blender/editors/animation/keyframes_general.c +++ b/source/blender/editors/animation/keyframes_general.c @@ -127,11 +127,11 @@ void duplicate_fcurve_keys(FCurve *fcu) { BezTriple *newbezt; int i; - - if (fcu == NULL) + + /* this can only work when there is an F-Curve, and also when there are some BezTriples */ + if ELEM(NULL, fcu, fcu->bezt) return; - // XXX this does not take into account sample data... for (i=0; i < fcu->totvert; i++) { /* If a key is selected */ if (fcu->bezt[i].f2 & SELECT) { @@ -160,7 +160,7 @@ void duplicate_fcurve_keys(FCurve *fcu) /* **************************************************** */ /* Various Tools */ -/* Basic IPO-Curve 'cleanup' function that removes 'double points' and unnecessary keyframes on linear-segments only */ +/* Basic F-Curve 'cleanup' function that removes 'double points' and unnecessary keyframes on linear-segments only */ void clean_fcurve(FCurve *fcu, float thresh) { BezTriple *old_bezts, *bezt, *beztn; @@ -285,74 +285,74 @@ void smooth_fcurve (FCurve *fcu) } } - /* if any points were selected, allocate tSmooth_Bezt points to work on */ - if (totSel >= 3) { - tSmooth_Bezt *tarray, *tsb; - - /* allocate memory in one go */ - tsb= tarray= MEM_callocN(totSel*sizeof(tSmooth_Bezt), "tSmooth_Bezt Array"); - - /* populate tarray with data of selected points */ - bezt= fcu->bezt; - for (i=0, x=0; (i < fcu->totvert) && (x < totSel); i++, bezt++) { - if (BEZSELECTED(bezt)) { - /* tsb simply needs pointer to vec, and index */ - tsb->h1 = &bezt->vec[0][1]; - tsb->h2 = &bezt->vec[1][1]; - tsb->h3 = &bezt->vec[2][1]; - - /* advance to the next tsb to populate */ - if (x < totSel- 1) - tsb++; - else - break; - } + /* if any points were selected, allocate tSmooth_Bezt points to work on */ + if (totSel >= 3) { + tSmooth_Bezt *tarray, *tsb; + + /* allocate memory in one go */ + tsb= tarray= MEM_callocN(totSel*sizeof(tSmooth_Bezt), "tSmooth_Bezt Array"); + + /* populate tarray with data of selected points */ + bezt= fcu->bezt; + for (i=0, x=0; (i < fcu->totvert) && (x < totSel); i++, bezt++) { + if (BEZSELECTED(bezt)) { + /* tsb simply needs pointer to vec, and index */ + tsb->h1 = &bezt->vec[0][1]; + tsb->h2 = &bezt->vec[1][1]; + tsb->h3 = &bezt->vec[2][1]; + + /* advance to the next tsb to populate */ + if (x < totSel- 1) + tsb++; + else + break; } + } - /* calculate the new smoothed F-Curve's with weighted averages: - * - this is done with two passes - * - uses 5 points for each operation (which stores in the relevant handles) - * - previous: w/a ratio = 3:5:2:1:1 - * - next: w/a ratio = 1:1:2:5:3 - */ - - /* round 1: calculate previous and next */ - tsb= tarray; - for (i=0; i < totSel; i++, tsb++) { - /* don't touch end points (otherwise, curves slowly explode) */ - if (ELEM(i, 0, (totSel-1)) == 0) { - const tSmooth_Bezt *tP1 = tsb - 1; - const tSmooth_Bezt *tP2 = (i-2 > 0) ? (tsb - 2) : (NULL); - const tSmooth_Bezt *tN1 = tsb + 1; - const tSmooth_Bezt *tN2 = (i+2 < totSel) ? (tsb + 2) : (NULL); - - const float p1 = *tP1->h2; - const float p2 = (tP2) ? (*tP2->h2) : (*tP1->h2); - const float c1 = *tsb->h2; - const float n1 = *tN1->h2; - const float n2 = (tN2) ? (*tN2->h2) : (*tN1->h2); + /* calculate the new smoothed F-Curve's with weighted averages: + * - this is done with two passes + * - uses 5 points for each operation (which stores in the relevant handles) + * - previous: w/a ratio = 3:5:2:1:1 + * - next: w/a ratio = 1:1:2:5:3 + */ + + /* round 1: calculate previous and next */ + tsb= tarray; + for (i=0; i < totSel; i++, tsb++) { + /* don't touch end points (otherwise, curves slowly explode) */ + if (ELEM(i, 0, (totSel-1)) == 0) { + const tSmooth_Bezt *tP1 = tsb - 1; + const tSmooth_Bezt *tP2 = (i-2 > 0) ? (tsb - 2) : (NULL); + const tSmooth_Bezt *tN1 = tsb + 1; + const tSmooth_Bezt *tN2 = (i+2 < totSel) ? (tsb + 2) : (NULL); + + const float p1 = *tP1->h2; + const float p2 = (tP2) ? (*tP2->h2) : (*tP1->h2); + const float c1 = *tsb->h2; + const float n1 = *tN1->h2; + const float n2 = (tN2) ? (*tN2->h2) : (*tN1->h2); + + /* calculate previous and next */ + *tsb->h1= (3*p2 + 5*p1 + 2*c1 + n1 + n2) / 12; + *tsb->h3= (p2 + p1 + 2*c1 + 5*n1 + 3*n2) / 12; + } + } + + /* round 2: calculate new values and reset handles */ + tsb= tarray; + for (i=0; i < totSel; i++, tsb++) { + /* calculate new position by averaging handles */ + *tsb->h2 = (*tsb->h1 + *tsb->h3) / 2; - /* calculate previous and next */ - *tsb->h1= (3*p2 + 5*p1 + 2*c1 + n1 + n2) / 12; - *tsb->h3= (p2 + p1 + 2*c1 + 5*n1 + 3*n2) / 12; + /* reset handles now */ + *tsb->h1 = *tsb->h2; + *tsb->h3 = *tsb->h2; } - } - - /* round 2: calculate new values and reset handles */ - tsb= tarray; - for (i=0; i < totSel; i++, tsb++) { - /* calculate new position by averaging handles */ - *tsb->h2 = (*tsb->h1 + *tsb->h3) / 2; - /* reset handles now */ - *tsb->h1 = *tsb->h2; - *tsb->h3 = *tsb->h2; + /* free memory required for tarray */ + MEM_freeN(tarray); } - /* free memory required for tarray */ - MEM_freeN(tarray); -} - /* recalculate handles */ calchandles_fcurve(fcu); } @@ -371,7 +371,6 @@ ListBase animcopybuf = {NULL, NULL}; static float animcopy_firstframe= 999999999.0f; /* datatype for use in copy/paste buffer */ -// XXX F-Curve editor should use this too typedef struct tAnimCopybufItem { struct tAnimCopybufItem *next, *prev; diff --git a/source/blender/editors/animation/keyframing.c b/source/blender/editors/animation/keyframing.c index 2da082a9b7c..dc73011549c 100644 --- a/source/blender/editors/animation/keyframing.c +++ b/source/blender/editors/animation/keyframing.c @@ -503,19 +503,19 @@ static float setting_get_rna_value (PointerRNA *ptr, PropertyRNA *prop, int inde switch (RNA_property_type(prop)) { case PROP_BOOLEAN: - if (RNA_property_array_length(prop)) + if (RNA_property_array_length(ptr, prop)) value= (float)RNA_property_boolean_get_index(ptr, prop, index); else value= (float)RNA_property_boolean_get(ptr, prop); break; case PROP_INT: - if (RNA_property_array_length(prop)) + if (RNA_property_array_length(ptr, prop)) value= (float)RNA_property_int_get_index(ptr, prop, index); else value= (float)RNA_property_int_get(ptr, prop); break; case PROP_FLOAT: - if (RNA_property_array_length(prop)) + if (RNA_property_array_length(ptr, prop)) value= RNA_property_float_get_index(ptr, prop, index); else value= RNA_property_float_get(ptr, prop); @@ -740,6 +740,12 @@ short insert_keyframe_direct (PointerRNA ptr, PropertyRNA *prop, FCurve *fcu, fl printf("ERROR: no F-Curve to add keyframes to \n"); return 0; } + /* F-Curve not editable? */ + if ( (fcu->flag & FCURVE_PROTECTED) || ((fcu->grp) && (fcu->grp->flag & AGRP_PROTECTED)) ) { + if (G.f & G_DEBUG) + printf("WARNING: not inserting keyframe for locked F-Curve \n"); + return 0; + } /* if no property given yet, try to validate from F-Curve info */ if ((ptr.id.data == NULL) && (ptr.data==NULL)) { @@ -911,8 +917,19 @@ short delete_keyframe (ID *id, bAction *act, const char group[], const char rna_ /* we don't check the validity of the path here yet, but it should be ok... */ fcu= verify_fcurve(act, group, rna_path, array_index, 0); - /* only continue if we have an F-Curve to remove keyframes from */ - if (act && fcu) { + /* check if F-Curve exists and/or whether it can be edited */ + if ELEM(NULL, act, fcu) { + printf("ERROR: no F-Curve and/or Action to delete keyframe from \n"); + return 0; + } + if ( (fcu->flag & FCURVE_PROTECTED) || ((fcu->grp) && (fcu->grp->flag & AGRP_PROTECTED)) ) { + if (G.f & G_DEBUG) + printf("WARNING: not inserting keyframe for locked F-Curve \n"); + return 0; + } + + /* it should be fine to continue now... */ + { short found = -1; int i; @@ -1296,7 +1313,7 @@ static int insert_key_button_exec (bContext *C, wmOperator *op) if (path) { if (all) { - length= RNA_property_array_length(prop); + length= RNA_property_array_length(&ptr, prop); if(length) index= 0; else length= 1; @@ -1379,7 +1396,7 @@ static int delete_key_button_exec (bContext *C, wmOperator *op) if (path) { if (all) { - length= RNA_property_array_length(prop); + length= RNA_property_array_length(&ptr, prop); if(length) index= 0; else length= 1; diff --git a/source/blender/editors/animation/keyingsets.c b/source/blender/editors/animation/keyingsets.c index ffc93340f8c..21f969467aa 100644 --- a/source/blender/editors/animation/keyingsets.c +++ b/source/blender/editors/animation/keyingsets.c @@ -80,137 +80,6 @@ /* ************************************************** */ /* KEYING SETS - EDITING API */ -/* Operators ------------------------------------------- */ - -/* These operators are only provided for scripting/macro usage, not for direct - * calling from the UI since they wrap some of the data-access API code for these - * (defined in blenkernel) which have quite a few properties. - */ - -/* ----- */ - -static int keyingset_add_destination_exec (bContext *C, wmOperator *op) -{ - PointerRNA ptr; - KeyingSet *ks= NULL; - ID *id= NULL; - char rna_path[256], group_name[64]; // xxx - short groupmode=0, flag=0; - int array_index=0; - - /* get settings from operator properties */ - ptr = RNA_pointer_get(op->ptr, "keyingset"); - if (ptr.data) - ks= (KeyingSet *)ptr.data; - - ptr = RNA_pointer_get(op->ptr, "id"); - if (ptr.data) - id= (ID *)ptr.data; - - groupmode= RNA_enum_get(op->ptr, "grouping_method"); - RNA_string_get(op->ptr, "group_name", group_name); - - RNA_string_get(op->ptr, "rna_path", rna_path); - array_index= RNA_int_get(op->ptr, "array_index"); - - if (RNA_boolean_get(op->ptr, "entire_array")) - flag |= KSP_FLAG_WHOLE_ARRAY; - - /* if enough args are provided, call API method */ - if (ks) { - BKE_keyingset_add_destination(ks, id, group_name, rna_path, array_index, flag, groupmode); - return OPERATOR_FINISHED; - } - else { - BKE_report(op->reports, RPT_ERROR, "Keying Set could not be added."); - return OPERATOR_CANCELLED; - } -} - -void ANIM_OT_keyingset_add_destination (wmOperatorType *ot) -{ - // XXX: this is also defined in rna_animation.c - static EnumPropertyItem prop_mode_grouping_items[] = { - {KSP_GROUP_NAMED, "NAMED", 0, "Named Group", ""}, - {KSP_GROUP_NONE, "NONE", 0, "None", ""}, - {KSP_GROUP_KSNAME, "KEYINGSET", 0, "Keying Set Name", ""}, - {0, NULL, 0, NULL, NULL}}; - - /* identifiers */ - ot->name= "Add Keying Set Destination"; - ot->idname= "ANIM_OT_keyingset_add_destination"; - - /* callbacks */ - ot->exec= keyingset_add_destination_exec; - ot->poll= ED_operator_scene_editable; - - /* props */ - /* pointers */ // xxx - do we want to directly expose these? - RNA_def_pointer_runtime(ot->srna, "keyingset", &RNA_KeyingSet, "Keying Set", "Keying Set to add destination to."); - RNA_def_pointer_runtime(ot->srna, "id", &RNA_ID, "ID", "ID-block for the destination."); - /* grouping */ - RNA_def_enum(ot->srna, "grouping_method", prop_mode_grouping_items, KSP_GROUP_NAMED, "Grouping Method", "Method used to define which Group-name to use."); - RNA_def_string(ot->srna, "group_name", "", 64, "Group Name", "Name of Action Group to assign destination to (only if grouping mode is to use this name)."); - /* rna-path */ - RNA_def_string(ot->srna, "rna_path", "", 256, "RNA-Path", "RNA-Path to destination property."); // xxx hopefully this is long enough - RNA_def_int(ot->srna, "array_index", 0, 0, INT_MAX, "Array Index", "If applicable, the index ", 0, INT_MAX); - /* flags */ - RNA_def_boolean(ot->srna, "entire_array", 1, "Entire Array", "hen an 'array/vector' type is chosen (Location, Rotation, Color, etc.), entire array is to be used."); - -} - -/* ----- */ - -static int keyingset_add_new_exec (bContext *C, wmOperator *op) -{ - Scene *sce= CTX_data_scene(C); - KeyingSet *ks= NULL; - short flag=0, keyingflag=0; - char name[64]; - - /* get settings from operator properties */ - RNA_string_get(op->ptr, "name", name); - - if (RNA_boolean_get(op->ptr, "absolute")) - flag |= KEYINGSET_ABSOLUTE; - if (RNA_boolean_get(op->ptr, "insertkey_needed")) - keyingflag |= INSERTKEY_NEEDED; - if (RNA_boolean_get(op->ptr, "insertkey_visual")) - keyingflag |= INSERTKEY_MATRIX; - - /* call the API func, and set the active keyingset index */ - ks= BKE_keyingset_add(&sce->keyingsets, name, flag, keyingflag); - - if (ks) { - sce->active_keyingset= BLI_countlist(&sce->keyingsets); - return OPERATOR_FINISHED; - } - else { - BKE_report(op->reports, RPT_ERROR, "Keying Set could not be added."); - return OPERATOR_CANCELLED; - } -} - -void ANIM_OT_keyingset_add_new (wmOperatorType *ot) -{ - /* identifiers */ - ot->name= "Add Keying Set"; - ot->idname= "ANIM_OT_keyingset_add_new"; - - /* callbacks */ - ot->exec= keyingset_add_new_exec; - ot->poll= ED_operator_scene_editable; - - /* props */ - /* name */ - RNA_def_string(ot->srna, "name", "KeyingSet", 64, "Name", "Name of Keying Set"); - /* flags */ - RNA_def_boolean(ot->srna, "absolute", 1, "Absolute", "Keying Set defines specific paths/settings to be keyframed (i.e. is not reliant on context info)"); - /* keying flags */ - RNA_def_boolean(ot->srna, "insertkey_needed", 0, "Insert Keyframes - Only Needed", "Only insert keyframes where they're needed in the relevant F-Curves."); - RNA_def_boolean(ot->srna, "insertkey_visual", 0, "Insert Keyframes - Visual", "Insert keyframes based on 'visual transforms'."); -} - /* UI API --------------------------------------------- */ /* Build menu-string of available keying-sets (allocates memory for string) @@ -899,7 +768,7 @@ short keyingset_context_ok_poll (bContext *C, KeyingSet *ks) Object *obact= CTX_data_active_object(C); /* if in posemode, check if 'pose-channels' requested for in KeyingSet */ - if ((obact && obact->pose) && (obact->flag & OB_POSEMODE)) { + if ((obact && obact->pose) && (obact->mode & OB_MODE_POSE)) { /* check for posechannels */ } @@ -930,7 +799,7 @@ static short modifykey_get_context_v3d_data (bContext *C, ListBase *dsources, Ke /* check if the active object is in PoseMode (i.e. only deal with bones) */ // TODO: check with the templates to see what we really need to store - if ((obact && obact->pose) && (obact->flag & OB_POSEMODE)) { + if ((obact && obact->pose) && (obact->mode & OB_MODE_POSE)) { /* Pose Mode: Selected bones */ #if 0 //set_pose_keys(ob); /* sets pchan->flag to POSE_KEY if bone selected, and clears if not */ @@ -1047,7 +916,7 @@ int modify_keyframes (bContext *C, ListBase *dsources, bAction *act, KeyingSet * * normal non-array entries get keyframed correctly */ i= ksp->array_index; - arraylen= i+1; + arraylen= i; /* get length of array if whole array option is enabled */ if (ksp->flag & KSP_FLAG_WHOLE_ARRAY) { @@ -1056,9 +925,13 @@ int modify_keyframes (bContext *C, ListBase *dsources, bAction *act, KeyingSet * RNA_id_pointer_create(ksp->id, &id_ptr); if (RNA_path_resolve(&id_ptr, ksp->rna_path, &ptr, &prop) && prop) - arraylen= RNA_property_array_length(prop); + arraylen= RNA_property_array_length(&ptr, prop); } + /* we should do at least one step */ + if (arraylen == i) + arraylen++; + /* for each possible index, perform operation * - assume that arraylen is greater than index */ @@ -1175,7 +1048,7 @@ int modify_keyframes (bContext *C, ListBase *dsources, bAction *act, KeyingSet * RNA_id_pointer_create(cks->id, &id_ptr); if (RNA_path_resolve(&id_ptr, path, &ptr, &prop) && prop) - arraylen= RNA_property_array_length(prop); + arraylen= RNA_property_array_length(&ptr, prop); } /* for each possible index, perform operation diff --git a/source/blender/editors/armature/editarmature.c b/source/blender/editors/armature/editarmature.c index c1b24375b3d..632f037679f 100644 --- a/source/blender/editors/armature/editarmature.c +++ b/source/blender/editors/armature/editarmature.c @@ -713,7 +713,7 @@ int join_armature_exec(bContext *C, wmOperator *op) /* get pose of active object and move it out of posemode */ pose= ob->pose; - ob->flag &= ~OB_POSEMODE; + ob->mode &= ~OB_MODE_POSE; CTX_DATA_BEGIN(C, Base*, base, selected_editable_bases) { if ((base->object->type==OB_ARMATURE) && (base->object!=ob)) { @@ -724,8 +724,8 @@ int join_armature_exec(bContext *C, wmOperator *op) /* Get Pose of current armature */ opose= base->object->pose; - base->object->flag &= ~OB_POSEMODE; - BASACT->flag &= ~OB_POSEMODE; + base->object->mode &= ~OB_MODE_POSE; + //BASACT->flag &= ~OB_MODE_POSE; /* Find the difference matrix */ Mat4Invert(oimat, ob->obmat); @@ -1034,8 +1034,8 @@ static int separate_armature_exec (bContext *C, wmOperator *op) /* 1) store starting settings and exit editmode */ oldob= obedit; oldbase= BASACT; - oldob->flag &= ~OB_POSEMODE; - oldbase->flag &= ~OB_POSEMODE; + oldob->mode &= ~OB_MODE_POSE; + //oldbase->flag &= ~OB_POSEMODE; ED_armature_from_edit(scene, obedit); ED_armature_edit_free(obedit); @@ -4332,7 +4332,7 @@ int ED_do_pose_selectbuffer(Scene *scene, Base *base, unsigned int *buffer, shor } /* in weightpaint we select the associated vertex group too */ - if (G.f & G_WEIGHTPAINT) { + if (ob->mode & OB_MODE_WEIGHT_PAINT) { if (nearBone->flag & BONE_ACTIVE) { vertexgroup_select_by_name(OBACT, nearBone->name); DAG_object_flush_update(scene, OBACT, OB_RECALC_DATA); @@ -4424,7 +4424,7 @@ static int bone_skinnable(Object *ob, Bone *bone, void *datap) int a, segments; struct { Object *armob; void *list; int heat; } *data = datap; - if(!(G.f & G_WEIGHTPAINT) || !(bone->flag & BONE_HIDDEN_P)) { + if(!(ob->mode & OB_MODE_WEIGHT_PAINT) || !(bone->flag & BONE_HIDDEN_P)) { if (!(bone->flag & BONE_NO_DEFORM)) { if (data->heat && data->armob->pose && get_pose_channel(data->armob->pose, bone->name)) segments = bone->segments; @@ -4489,7 +4489,7 @@ static int dgroup_skinnable(Object *ob, Bone *bone, void *datap) int a, segments; struct { Object *armob; void *list; int heat; } *data= datap; - if (!(G.f & G_WEIGHTPAINT) || !(bone->flag & BONE_HIDDEN_P)) { + if (!(ob->mode & OB_MODE_WEIGHT_PAINT) || !(bone->flag & BONE_HIDDEN_P)) { if (!(bone->flag & BONE_NO_DEFORM)) { if (data->heat && data->armob->pose && get_pose_channel(data->armob->pose, bone->name)) segments = bone->segments; @@ -4588,7 +4588,7 @@ void add_verts_to_dgroups(Scene *scene, Object *ob, Object *par, int heat, int m float (*root)[3], (*tip)[3], (*verts)[3]; int *selected; int numbones, vertsfilled = 0, i, j, segments = 0; - int wpmode = (G.f & G_WEIGHTPAINT); + int wpmode = (ob->mode & OB_MODE_WEIGHT_PAINT); struct { Object *armob; void *list; int heat; } looper_data; looper_data.armob = par; diff --git a/source/blender/editors/armature/editarmature_sketch.c b/source/blender/editors/armature/editarmature_sketch.c index f3f7bccde04..79d3d7b1366 100644 --- a/source/blender/editors/armature/editarmature_sketch.c +++ b/source/blender/editors/armature/editarmature_sketch.c @@ -2320,7 +2320,7 @@ void sk_drawSketch(Scene *scene, View3D *v3d, SK_Sketch *sketch, int with_names) for (p = sketch->depth_peels.first; p; p = p->next) { - int index = (int)(p->ob); + int index = GET_INT_FROM_POINTER(p->ob); index = (index >> 5) & 7; glColor3fv(colors[index]); @@ -2466,8 +2466,10 @@ static int sketch_delete(bContext *C, wmOperator *op, wmEvent *event) void BIF_sk_selectStroke(bContext *C, short mval[2], short extend) { + ToolSettings *ts = CTX_data_tool_settings(C); SK_Sketch *sketch = contextSketch(C, 0); - if (sketch) + + if (sketch != NULL && ts->bone_sketching & BONE_SKETCHING) { sk_selectStroke(C, sketch, mval, extend); } diff --git a/source/blender/editors/armature/poselib.c b/source/blender/editors/armature/poselib.c index ef2e5188487..021bec05a3b 100644 --- a/source/blender/editors/armature/poselib.c +++ b/source/blender/editors/armature/poselib.c @@ -342,7 +342,7 @@ static int poselib_add_menu_invoke (bContext *C, wmOperator *op, wmEvent *evt) uiItemIntO(layout, "Add New (Current Frame)", 0, "POSELIB_OT_pose_add", "frame", CFRA); /* replace existing - submenu */ - uiItemMenuF(layout, "Replace Existing...", 0, poselib_add_menu_invoke__replacemenu); + uiItemMenuF(layout, "Replace Existing...", 0, poselib_add_menu_invoke__replacemenu, NULL); } uiPupMenuEnd(C, pup); diff --git a/source/blender/editors/armature/poseobject.c b/source/blender/editors/armature/poseobject.c index 174bb39d7b9..5b378878f91 100644 --- a/source/blender/editors/armature/poseobject.c +++ b/source/blender/editors/armature/poseobject.c @@ -126,7 +126,7 @@ void ED_armature_enter_posemode(bContext *C, Base *base) switch (ob->type){ case OB_ARMATURE: - ob->flag |= OB_POSEMODE; + ob->mode |= OB_MODE_POSE; base->flag= ob->flag; WM_event_add_notifier(C, NC_SCENE|ND_MODE|NS_MODE_POSE, NULL); @@ -135,7 +135,8 @@ void ED_armature_enter_posemode(bContext *C, Base *base) default: return; } - ED_view3d_exit_paint_modes(C); + + ED_object_toggle_modes(C, ob->mode); } void ED_armature_exit_posemode(bContext *C, Base *base) @@ -143,7 +144,7 @@ void ED_armature_exit_posemode(bContext *C, Base *base) if(base) { Object *ob= base->object; - ob->flag &= ~OB_POSEMODE; + ob->mode &= ~OB_MODE_POSE; base->flag= ob->flag; WM_event_add_notifier(C, NC_SCENE|ND_MODE|NS_MODE_OBJECT, NULL); @@ -527,7 +528,7 @@ void pose_select_constraint_target(Scene *scene) /* paranoia checks */ if (!ob && !ob->pose) return; - if (ob==obedit || (ob->flag & OB_POSEMODE)==0) return; + if (ob==obedit || (ob->mode & OB_MODE_POSE)==0) return; for(pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) { if (arm->layer & pchan->bone->layer) { @@ -715,7 +716,7 @@ void pose_copy_menu(Scene *scene) /* paranoia checks */ if (ELEM(NULL, ob, ob->pose)) return; - if ((ob==obedit) || (ob->flag & OB_POSEMODE)==0) return; + if ((ob==obedit) || (ob->mode & OB_MODE_POSE)==0) return; /* find active */ for (pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) { @@ -1105,7 +1106,7 @@ void pose_adds_vgroups(Scene *scene, Object *meshobj, int heatweights) // XXX extern VPaint Gwp; /* from vpaint */ Object *poseobj= modifiers_isDeformedByArmature(meshobj); - if(poseobj==NULL || (poseobj->flag & OB_POSEMODE)==0) { + if(poseobj==NULL || (poseobj->mode & OB_MODE_POSE)==0) { error("The active object must have a deforming armature in pose mode"); return; } @@ -1646,10 +1647,10 @@ void pose_activate_flipped_bone(Scene *scene) if(ob==NULL) return; - if(G.f & G_WEIGHTPAINT) { + if(ob->mode && OB_MODE_WEIGHT_PAINT) { ob= modifiers_isDeformedByArmature(ob); } - if(ob && (ob->flag & OB_POSEMODE)) { + if(ob && (ob->mode & OB_MODE_POSE)) { bPoseChannel *pchan, *pchanf; for(pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) { @@ -1670,7 +1671,7 @@ void pose_activate_flipped_bone(Scene *scene) pchanf->bone->flag |= (BONE_SELECTED|BONE_ACTIVE); /* in weightpaint we select the associated vertex group too */ - if(G.f & G_WEIGHTPAINT) { + if(ob->mode & OB_MODE_WEIGHT_PAINT) { vertexgroup_select_by_name(OBACT, name); DAG_object_flush_update(scene, OBACT, OB_RECALC_DATA); } @@ -2150,7 +2151,7 @@ void pose_special_editmenu(Scene *scene) /* paranoia checks */ if(!ob && !ob->pose) return; - if(ob==obedit || (ob->flag & OB_POSEMODE)==0) return; + if(ob==obedit || (ob->mode & OB_MODE_POSE)==0) return; nr= pupmenu("Specials%t|Select Constraint Target%x1|Flip Left-Right Names%x2|Calculate Paths%x3|Clear Paths%x4|Clear User Transform %x5|Relax Pose %x6|%l|AutoName Left-Right%x7|AutoName Front-Back%x8|AutoName Top-Bottom%x9"); if(nr==1) { diff --git a/source/blender/editors/curve/curve_ops.c b/source/blender/editors/curve/curve_ops.c index 6006c7e656b..d3bcdcb69bb 100644 --- a/source/blender/editors/curve/curve_ops.c +++ b/source/blender/editors/curve/curve_ops.c @@ -202,8 +202,11 @@ void ED_keymap_curve(wmWindowManager *wm) RNA_int_set(WM_keymap_add_item(keymap, "FONT_OT_change_character", DOWNARROWKEY, KM_PRESS, KM_ALT, 0)->ptr, "delta", -1); WM_keymap_add_item(keymap, "FONT_OT_text_copy", CKEY, KM_PRESS, KM_CTRL, 0); + WM_keymap_add_item(keymap, "FONT_OT_text_copy", CKEY, KM_PRESS, KM_OSKEY, 0); WM_keymap_add_item(keymap, "FONT_OT_text_cut", XKEY, KM_PRESS, KM_CTRL, 0); - WM_keymap_add_item(keymap, "FONT_OT_text_paste", PKEY, KM_PRESS, KM_CTRL, 0); + WM_keymap_add_item(keymap, "FONT_OT_text_cut", XKEY, KM_PRESS, KM_OSKEY, 0); + WM_keymap_add_item(keymap, "FONT_OT_text_paste", VKEY, KM_PRESS, KM_CTRL, 0); + WM_keymap_add_item(keymap, "FONT_OT_text_paste", VKEY, KM_PRESS, KM_OSKEY, 0); WM_keymap_add_item(keymap, "FONT_OT_line_break", RETKEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "FONT_OT_text_insert", KM_TEXTINPUT, KM_ANY, KM_ANY, 0); // last! diff --git a/source/blender/editors/include/ED_anim_api.h b/source/blender/editors/include/ED_anim_api.h index 0786d0f9be0..179f362b13f 100644 --- a/source/blender/editors/include/ED_anim_api.h +++ b/source/blender/editors/include/ED_anim_api.h @@ -46,6 +46,8 @@ struct bActionGroup; struct FCurve; struct FModifier; +struct uiBlock; + /* ************************************************ */ /* ANIMATION CHANNEL FILTERING */ /* anim_filter.c */ @@ -107,7 +109,10 @@ typedef struct bAnimListElem { } bAnimListElem; -/* Some types for easier type-testing */ +/* Some types for easier type-testing + * NOTE: need to keep the order of these synchronised with the channels define code + * which is used for drawing and handling channel lists for + */ // XXX was ACTTYPE_* typedef enum eAnim_ChannelType { ANIMTYPE_NONE= 0, @@ -140,6 +145,9 @@ typedef enum eAnim_ChannelType { ANIMTYPE_NLATRACK, ANIMTYPE_NLAACTION, + + /* always as last item, the total number of channel types... */ + ANIMTYPE_NUM_TYPES, } eAnim_ChannelType; /* types of keyframe data in bAnimListElem */ @@ -275,25 +283,89 @@ short ANIM_animdata_context_getdata(bAnimContext *ac); /* ************************************************ */ /* ANIMATION CHANNELS LIST */ -/* anim_channels.c */ +/* anim_channels_*.c */ -/* ------------------------ API -------------------------- */ - -/* Deselect all animation channels */ -void ANIM_deselect_anim_channels(void *data, short datatype, short test, short sel); - -/* Set the 'active' channel of type channel_type, in the given action */ -void ANIM_set_active_channel(bAnimContext *ac, void *data, short datatype, int filter, void *channel_data, short channel_type); - -/* --------------- Settings and/or Defines -------------- */ +/* ------------------------ Drawing TypeInfo -------------------------- */ /* flag-setting behaviour */ -enum { +typedef enum eAnimChannels_SetFlag { ACHANNEL_SETFLAG_CLEAR = 0, ACHANNEL_SETFLAG_ADD, ACHANNEL_SETFLAG_TOGGLE } eAnimChannels_SetFlag; +/* types of settings for AnimChanels */ +typedef enum eAnimChannel_Settings { + ACHANNEL_SETTING_SELECT = 0, + ACHANNEL_SETTING_PROTECT, // warning: for drawing UI's, need to check if this is off (maybe inverse this later) + ACHANNEL_SETTING_MUTE, + ACHANNEL_SETTING_EXPAND, + ACHANNEL_SETTING_VISIBLE, /* only for Graph Editor */ + ACHANNEL_SETTING_SOLO, /* only for NLA Tracks */ +} eAnimChannel_Settings; + + +/* Drawing, mouse handling, and flag setting behaviour... */ +typedef struct bAnimChannelType { + /* drawing */ + /* draw backdrop strip for channel */ + void (*draw_backdrop)(bAnimContext *ac, bAnimListElem *ale, float yminc, float ymaxc); + /* get depth of indention (relative to the depth channel is nested at) */ + short (*get_indent_level)(bAnimContext *ac, bAnimListElem *ale); + /* get offset in pixels for the start of the channel (in addition to the indent depth) */ + short (*get_offset)(bAnimContext *ac, bAnimListElem *ale); + + + /* get name (for channel lists) */ + void (*name)(bAnimListElem *ale, char *name); + /* get icon (for channel lists) */ + int (*icon)(bAnimListElem *ale); + + /* settings */ + /* check if the given setting is valid in the current context */ + short (*has_setting)(bAnimContext *ac, bAnimListElem *ale, int setting); + /* get the flag used for this setting */ + int (*setting_flag)(int setting, short *neg); + /* get the pointer to int/short where data is stored, + * with type being sizeof(ptr_data) which should be fine for runtime use... + * - assume that setting has been checked to be valid for current context + */ + void *(*setting_ptr)(bAnimListElem *ale, int setting, short *type); +} bAnimChannelType; + +/* ------------------------ Drawing API -------------------------- */ + +/* Get typeinfo for the given channel */ +bAnimChannelType *ANIM_channel_get_typeinfo(bAnimListElem *ale); + +/* Draw the given channel */ +void ANIM_channel_draw(bAnimContext *ac, bAnimListElem *ale, float yminc, float ymaxc); +/* Draw the widgets for the given channel */ +void ANIM_channel_draw_widgets(bAnimContext *ac, bAnimListElem *ale, struct uiBlock *block, float yminc, float ymaxc); + + +/* ------------------------ Editing API -------------------------- */ + +/* Check if some setting for a channel is enabled + * Returns: 1 = On, 0 = Off, -1 = Invalid + * + * - setting: eAnimChannel_Settings + */ +short ANIM_channel_setting_get(bAnimContext *ac, bAnimListElem *ale, int setting); + +/* Change value of some setting for a channel + * - setting: eAnimChannel_Settings + * - mode: eAnimChannels_SetFlag + */ +void ANIM_channel_setting_set(bAnimContext *ac, bAnimListElem *ale, int setting, short mode); + + +/* Deselect all animation channels */ +void ANIM_deselect_anim_channels(void *data, short datatype, short test, short sel); + +/* Set the 'active' channel of type channel_type, in the given action */ +void ANIM_set_active_channel(bAnimContext *ac, void *data, short datatype, int filter, void *channel_data, short channel_type); + /* ************************************************ */ /* DRAWING API */ /* anim_draw.c */ @@ -334,14 +406,16 @@ void ANIM_uiTemplate_fmodifier_draw(struct uiLayout *layout, struct ID *id, List /* ------------ Animation F-Curves <-> Icons/Names Mapping ------------ */ /* anim_ipo_utils.c */ +/* Get icon for type of setting F-Curve is for */ +// XXX include this in the getname() method via RNA? int geticon_anim_blocktype(short blocktype); +/* Get name for channel-list displays for F-Curve */ void getname_anim_fcurve(char *name, struct ID *id, struct FCurve *fcu); - +/* Automatically determine a color for the nth F-Curve */ void ipo_rainbow(int cur, int tot, float *out); - /* ------------- NLA-Mapping ----------------------- */ /* anim_draw.c */ diff --git a/source/blender/editors/include/ED_fileselect.h b/source/blender/editors/include/ED_fileselect.h index c56807ad09a..57ab6a5f8f6 100644 --- a/source/blender/editors/include/ED_fileselect.h +++ b/source/blender/editors/include/ED_fileselect.h @@ -65,6 +65,7 @@ typedef struct FileLayout short height; short flag; short dirty; + short textheight; float column_widths[MAX_FILE_COLUMN]; } FileLayout; diff --git a/source/blender/editors/include/ED_info.h b/source/blender/editors/include/ED_info.h new file mode 100644 index 00000000000..d09e174d71d --- /dev/null +++ b/source/blender/editors/include/ED_info.h @@ -0,0 +1,32 @@ +/** + * $Id: + * + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * The Original Code is Copyright (C) 2009, Blender Foundation + * + * ***** END GPL LICENSE BLOCK ***** + */ + +#ifndef ED_INFO_H +#define ED_INFO_H + +/* info_stats.c */ +void ED_info_stats_clear(struct Scene *scene); +char *ED_info_stats_string(struct Scene *scene); + +#endif /* ED_INFO_H */ diff --git a/source/blender/editors/include/ED_keyframing.h b/source/blender/editors/include/ED_keyframing.h index 64672e3502b..4bc24a0adeb 100644 --- a/source/blender/editors/include/ED_keyframing.h +++ b/source/blender/editors/include/ED_keyframing.h @@ -154,15 +154,6 @@ struct KeyingSet *ANIM_builtin_keyingset_get_named(struct KeyingSet *prevKS, cha /* Initialise builtin KeyingSets on startup */ void init_builtin_keyingsets(void); -/* -------- */ - -/* KeyingSet Editing Operators: - * These can add a new KeyingSet and/or add 'destinations' to the KeyingSets, - * acting as a means by which they can be added outside the Outliner. - */ -void ANIM_OT_keyingset_add_new(struct wmOperatorType *ot); -void ANIM_OT_keyingset_add_destination(struct wmOperatorType *ot); - /* ************ Drivers ********************** */ /* Main Driver Management API calls: diff --git a/source/blender/editors/include/ED_node.h b/source/blender/editors/include/ED_node.h index 0cd5551f17f..bf4632dc3da 100644 --- a/source/blender/editors/include/ED_node.h +++ b/source/blender/editors/include/ED_node.h @@ -28,8 +28,17 @@ #ifndef ED_NODE_H #define ED_NODE_H +struct Material; +struct Scene; +struct Tex; + /* drawnode.c */ void ED_init_node_butfuncs(void); +/* node_edit.c */ +void ED_node_shader_default(struct Material *ma); +void ED_node_composit_default(struct Scene *sce); +void ED_node_texture_default(struct Tex *tex);; + #endif /* ED_NODE_H */ diff --git a/source/blender/editors/include/ED_object.h b/source/blender/editors/include/ED_object.h index c8a72a2aa97..d31f85d08ea 100644 --- a/source/blender/editors/include/ED_object.h +++ b/source/blender/editors/include/ED_object.h @@ -59,6 +59,8 @@ struct Base *ED_object_add_duplicate(struct Scene *scene, struct Base *base, int void ED_object_parent(struct Object *ob, struct Object *parent, int type, const char *substr); +void ED_object_toggle_modes(struct bContext *C, int mode); + /* bitflags for enter/exit editmode */ #define EM_FREEDATA 1 #define EM_FREEUNDO 2 @@ -69,6 +71,8 @@ void ED_object_enter_editmode(struct bContext *C, int flag); void ED_object_base_init_from_view(struct bContext *C, struct Base *base); +void ED_object_single_users(struct Scene *scene, int full); + /* cleanup */ int object_is_libdata(struct Object *ob); int object_data_is_libdata(struct Object *ob); @@ -89,6 +93,9 @@ void ED_object_constraint_set_active(struct Object *ob, struct bConstraint *con) void mouse_lattice(struct bContext *C, short mval[2], int extend); void undo_push_lattice(struct bContext *C, char *name); +/* editmball.c */ +void undo_push_mball(struct bContext *C, char *name); + /* editkey.c */ void insert_shapekey(struct Scene *scene, struct Object *ob); void delete_key(struct Scene *scene, struct Object *ob); diff --git a/source/blender/editors/include/ED_previewrender.h b/source/blender/editors/include/ED_previewrender.h index 41cbecb5353..7e0d71db7e1 100644 --- a/source/blender/editors/include/ED_previewrender.h +++ b/source/blender/editors/include/ED_previewrender.h @@ -34,6 +34,7 @@ struct Image; struct Render; struct bContext; struct ID; +struct MTex; #define PREVIEW_RENDERSIZE 140 @@ -70,9 +71,9 @@ pr_method: void ED_preview_init_dbase(void); void ED_preview_free_dbase(void); -void ED_preview_shader_job(const struct bContext *C, void *owner, struct ID *id, struct ID *parent, int sizex, int sizey); +void ED_preview_shader_job(const struct bContext *C, void *owner, struct ID *id, struct ID *parent, struct MTex *slot, int sizex, int sizey); void ED_preview_iconrender(struct Scene *scene, struct ID *id, unsigned int *rect, int sizex, int sizey); -void ED_preview_draw(const struct bContext *C, void *idp, void *parentp, rcti *rect); +void ED_preview_draw(const struct bContext *C, void *idp, void *parentp, void *slot, rcti *rect); #endif diff --git a/source/blender/editors/include/ED_screen.h b/source/blender/editors/include/ED_screen.h index fc29d64eb37..22a3e737277 100644 --- a/source/blender/editors/include/ED_screen.h +++ b/source/blender/editors/include/ED_screen.h @@ -58,6 +58,7 @@ void ED_region_panels_init(struct wmWindowManager *wm, struct ARegion *ar); void ED_region_panels(const struct bContext *C, struct ARegion *ar, int vertical, char *context, int contextnr); void ED_region_header_init(struct ARegion *ar); void ED_region_header(const struct bContext *C, struct ARegion *ar); +void region_scissor_winrct(struct ARegion *ar, struct rcti *winrct); /* spaces */ void ED_spacetypes_init(void); @@ -89,10 +90,13 @@ void ED_screen_do_listen(struct wmWindow *win, struct wmNotifier *note); bScreen *ED_screen_duplicate(struct wmWindow *win, struct bScreen *sc); bScreen *ED_screen_add(struct wmWindow *win, struct Scene *scene, char *name); void ED_screen_set(struct bContext *C, struct bScreen *sc); +void ED_screen_delete(struct bContext *C, struct bScreen *sc); void ED_screen_set_scene(struct bContext *C, struct Scene *scene); +void ED_screen_delete_scene(struct bContext *C, struct Scene *scene); void ED_screen_set_subwinactive(struct wmWindow *win, struct wmEvent *event); void ED_screen_exit(struct bContext *C, struct wmWindow *window, struct bScreen *screen); -void ED_screen_animation_timer(struct bContext *C, int redraws, int enable); +void ED_screen_animation_timer(struct bContext *C, int redraws, int sync, int enable); +void ED_screen_animation_timer_update(struct bContext *C, int redraws); int ED_screen_full_newspace(struct bContext *C, ScrArea *sa, int type); void ED_screen_full_prevspace(struct bContext *C); diff --git a/source/blender/editors/include/ED_screen_types.h b/source/blender/editors/include/ED_screen_types.h index 76a2a55c29e..72afe7704b4 100644 --- a/source/blender/editors/include/ED_screen_types.h +++ b/source/blender/editors/include/ED_screen_types.h @@ -31,9 +31,9 @@ /* for animplayer */ typedef struct ScreenAnimData { - ARegion *ar; /* do not read from this, only for comparing if region exists */ + ARegion *ar; /* do not read from this, only for comparing if region exists */ int redraws; - int flag; /* flags for playback */ + int flag; /* flags for playback */ } ScreenAnimData; /* for animplayer */ @@ -42,6 +42,10 @@ enum { ANIMPLAY_FLAG_REVERSE = (1<<0), /* temporary - playback just jumped to the start/end */ ANIMPLAY_FLAG_JUMPED = (1<<1), + /* drop frames as needed to maintain framerate */ + ANIMPLAY_FLAG_SYNC = (1<<2), + /* don't drop frames (and ignore AUDIO_SYNC flag) */ + ANIMPLAY_FLAG_NO_SYNC = (1<<3), }; diff --git a/source/blender/editors/include/ED_space_api.h b/source/blender/editors/include/ED_space_api.h index efaf0f56f92..04b6be3bcaa 100644 --- a/source/blender/editors/include/ED_space_api.h +++ b/source/blender/editors/include/ED_space_api.h @@ -52,6 +52,7 @@ void ED_spacetype_text(void); void ED_spacetype_sequencer(void); void ED_spacetype_logic(void); void ED_spacetype_console(void); +void ED_spacetype_userpref(void); /* calls for instancing and freeing spacetype static data called in WM_init_exit */ diff --git a/source/blender/editors/include/ED_view3d.h b/source/blender/editors/include/ED_view3d.h index 6360bf49f1a..07890d88c22 100644 --- a/source/blender/editors/include/ED_view3d.h +++ b/source/blender/editors/include/ED_view3d.h @@ -70,6 +70,7 @@ float *give_cursor(struct Scene *scene, struct View3D *v3d); void initgrabz(struct RegionView3D *rv3d, float x, float y, float z); void window_to_3d(struct ARegion *ar, float *vec, short mx, short my); void window_to_3d_delta(struct ARegion *ar, float *vec, short mx, short my); +void view3d_unproject(struct bglMats *mats, float out[3], const short x, const short y, const float z); /* Depth buffer */ float read_cached_depth(struct ViewContext *vc, int x, int y); @@ -130,8 +131,6 @@ int edge_inside_circle(short centx, short centy, short rad, short x1, short y1, int lasso_inside(short mcords[][2], short moves, short sx, short sy); int lasso_inside_edge(short mcords[][2], short moves, int x0, int y0, int x1, int y1); -/* modes */ -void ED_view3d_exit_paint_modes(struct bContext *C); /* get 3d region from context, also if mouse is in header or toolbar */ struct RegionView3D *ED_view3d_context_rv3d(struct bContext *C); diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h index 70fbad3216d..0cb6964b39e 100644 --- a/source/blender/editors/include/UI_interface.h +++ b/source/blender/editors/include/UI_interface.h @@ -60,6 +60,7 @@ struct Image; struct ImageUser; struct uiWidgetColors; struct Tex; +struct MTex; typedef struct uiBut uiBut; typedef struct uiBlock uiBlock; @@ -99,6 +100,8 @@ typedef struct uiLayout uiLayout; #define UI_BLOCK_KEEP_OPEN 256 #define UI_BLOCK_POPUP 512 #define UI_BLOCK_OUT_1 1024 +#define UI_BLOCK_NO_FLIP 2048 +#define UI_BLOCK_POPUP_MEMORY 4096 /* uiPopupBlockHandle->menuretval */ #define UI_RETURN_CANCEL 1 /* cancel all menus cascading */ @@ -253,8 +256,6 @@ void uiPupMenuNotice(struct bContext *C, char *str, ...); void uiPupMenuError(struct bContext *C, char *str, ...); void uiPupMenuReports(struct bContext *C, struct ReportList *reports); -void uiPupMenuSetActive(int val); - /* Popup Blocks * * Functions used to create popup blocks. These are like popup menus @@ -490,7 +491,7 @@ void uiButSetNFunc (uiBut *but, uiButHandleNFunc func, void *argN, void *arg2) void uiButSetCompleteFunc(uiBut *but, uiButCompleteFunc func, void *arg); -void uiBlockSetDrawExtraFunc(uiBlock *block, void (*func)(const struct bContext *C, void *, void *, struct rcti *rect), void *arg); +void uiBlockSetDrawExtraFunc(uiBlock *block, void (*func)(const struct bContext *C, void *, void *, void *, struct rcti *rect), void *arg1, void *arg2); /* Autocomplete * @@ -545,6 +546,7 @@ void autocomplete_vgroup(struct bContext *C, char *str, void *arg_v); struct rctf; void curvemap_buttons(uiBlock *block, struct CurveMapping *cumap, char labeltype, short event, short redraw, struct rctf *rect); +void curvemap_layout(uiLayout *layout, struct CurveMapping *cumap, char labeltype, short event, short redraw, struct rctf *rect); void colorband_buttons(uiBlock *block, struct ColorBand *coba, struct rctf *rect, int small); @@ -583,16 +585,21 @@ void UI_exit(void); #define UI_LAYOUT_ALIGN_CENTER 2 #define UI_LAYOUT_ALIGN_RIGHT 3 +#define UI_ITEM_O_RETURN_PROPS 1 +#define UI_ITEM_R_EXPAND 2 +#define UI_ITEM_R_SLIDER 4 +#define UI_ITEM_R_TOGGLE 8 + uiLayout *uiBlockLayout(uiBlock *block, int dir, int type, int x, int y, int size, int em, struct uiStyle *style); void uiBlockSetCurLayout(uiBlock *block, uiLayout *layout); void uiBlockLayoutResolve(const struct bContext *C, uiBlock *block, int *x, int *y); uiBlock *uiLayoutGetBlock(uiLayout *layout); -void uiLayoutSetOperatorContext(uiLayout *layout, int opcontext); void uiLayoutSetFunc(uiLayout *layout, uiMenuHandleFunc handlefunc, void *argv); void uiLayoutSetContextPointer(uiLayout *layout, char *name, struct PointerRNA *ptr); +void uiLayoutSetOperatorContext(uiLayout *layout, int opcontext); void uiLayoutSetActive(uiLayout *layout, int active); void uiLayoutSetEnabled(uiLayout *layout, int enabled); void uiLayoutSetRedAlert(uiLayout *layout, int redalert); @@ -607,6 +614,7 @@ int uiLayoutGetEnabled(uiLayout *layout); int uiLayoutGetRedAlert(uiLayout *layout); int uiLayoutGetAlignment(uiLayout *layout); int uiLayoutGetKeepAspect(uiLayout *layout); +int uiLayoutGetWidth(uiLayout *layout); float uiLayoutGetScaleX(uiLayout *layout); float uiLayoutGetScaleY(uiLayout *layout); ListBase *uiLayoutBoxGetList(uiLayout *layout); @@ -623,20 +631,21 @@ uiLayout *uiLayoutSplit(uiLayout *layout, float percentage); uiBlock *uiLayoutFreeBlock(uiLayout *layout); /* templates */ -void uiTemplateHeader(uiLayout *layout, struct bContext *C); +void uiTemplateHeader(uiLayout *layout, struct bContext *C, int menus); void uiTemplateID(uiLayout *layout, struct bContext *C, struct PointerRNA *ptr, char *propname, char *newop, char *unlinkop); uiLayout *uiTemplateModifier(uiLayout *layout, struct PointerRNA *ptr); uiLayout *uiTemplateConstraint(uiLayout *layout, struct PointerRNA *ptr); -void uiTemplatePreview(uiLayout *layout, struct ID *id, struct ID *parent); +void uiTemplatePreview(uiLayout *layout, struct ID *id, struct ID *parent, struct MTex *slot); void uiTemplateColorRamp(uiLayout *layout, struct ColorBand *coba, int expand); -void uiTemplateCurveMapping(uiLayout *layout, struct CurveMapping *cumap, int type); +void uiTemplateCurveMapping(uiLayout *layout, struct CurveMapping *cumap, int type, int compact); void uiTemplateTriColorSet(uiLayout *layout, struct PointerRNA *ptr, char *propname); void uiTemplateLayers(uiLayout *layout, struct PointerRNA *ptr, char *propname); void uiTemplateImageLayers(uiLayout *layout, struct bContext *C, struct Image *ima, struct ImageUser *iuser); void uiTemplateRunningJobs(uiLayout *layout, struct bContext *C); void uiTemplateOperatorSearch(uiLayout *layout); void uiTemplateHeader3D(uiLayout *layout, struct bContext *C); +void uiTemplate_view3d_select_faceselmenu(uiLayout *layout, struct bContext *C); void uiTemplateTextureImage(uiLayout *layout, struct bContext *C, struct Tex *tex); typedef struct uiListItem { @@ -657,10 +666,10 @@ void uiItemBooleanO(uiLayout *layout, char *name, int icon, char *opname, char * void uiItemIntO(uiLayout *layout, char *name, int icon, char *opname, char *propname, int value); void uiItemFloatO(uiLayout *layout, char *name, int icon, char *opname, char *propname, float value); void uiItemStringO(uiLayout *layout, char *name, int icon, char *opname, char *propname, char *value); -void uiItemFullO(uiLayout *layout, char *name, int icon, char *idname, struct IDProperty *properties, int context); +PointerRNA uiItemFullO(uiLayout *layout, char *name, int icon, char *idname, struct IDProperty *properties, int context, int flag); -void uiItemR(uiLayout *layout, char *name, int icon, struct PointerRNA *ptr, char *propname, int expand, int slider, int toggle); -void uiItemFullR(uiLayout *layout, char *name, int icon, struct PointerRNA *ptr, struct PropertyRNA *prop, int index, int value, int expand, int slider, int toggle); +void uiItemR(uiLayout *layout, char *name, int icon, struct PointerRNA *ptr, char *propname, int flag); +void uiItemFullR(uiLayout *layout, char *name, int icon, struct PointerRNA *ptr, struct PropertyRNA *prop, int index, int value, int flag); void uiItemEnumR(uiLayout *layout, char *name, int icon, struct PointerRNA *ptr, char *propname, int value); void uiItemEnumR_string(uiLayout *layout, char *name, int icon, struct PointerRNA *ptr, char *propname, char *value); void uiItemsEnumR(uiLayout *layout, struct PointerRNA *ptr, char *propname); @@ -671,7 +680,7 @@ void uiItemM(uiLayout *layout, struct bContext *C, char *name, int icon, char *m void uiItemV(uiLayout *layout, char *name, int icon, int argval); /* value */ void uiItemS(uiLayout *layout); /* separator */ -void uiItemMenuF(uiLayout *layout, char *name, int icon, uiMenuCreateFunc func); +void uiItemMenuF(uiLayout *layout, char *name, int icon, uiMenuCreateFunc func, void *arg); void uiItemMenuEnumO(uiLayout *layout, char *name, int icon, char *opname, char *propname); void uiItemMenuEnumR(uiLayout *layout, char *name, int icon, struct PointerRNA *ptr, char *propname); diff --git a/source/blender/editors/interface/Makefile b/source/blender/editors/interface/Makefile index a3d0692f1e1..5968660eb91 100644 --- a/source/blender/editors/interface/Makefile +++ b/source/blender/editors/interface/Makefile @@ -48,6 +48,7 @@ CPPFLAGS += -I../../makesdna CPPFLAGS += -I../../makesrna CPPFLAGS += -I../../imbuf CPPFLAGS += -I../../blenfont +CPPFLAGS += -I../../python # own include diff --git a/source/blender/editors/interface/SConscript b/source/blender/editors/interface/SConscript index bac3742c12f..e44de5410f1 100644 --- a/source/blender/editors/interface/SConscript +++ b/source/blender/editors/interface/SConscript @@ -9,6 +9,7 @@ for source in env.Glob('*_api.c'): incs = '../include ../../blenlib ../../blenfont ../../blenkernel ../../makesdna ../../imbuf' incs += ' ../../makesrna ../../windowmanager #/intern/guardedalloc' incs += ' #/extern/glew/include' +incs += ' ../../python/' # python button eval defs = [] diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c index 9e9b6165a73..3c6e12905d6 100644 --- a/source/blender/editors/interface/interface.c +++ b/source/blender/editors/interface/interface.c @@ -48,6 +48,7 @@ #include "BKE_screen.h" #include "BKE_texture.h" #include "BKE_utildefines.h" +#include "BKE_unit.h" #include "BIF_gl.h" #include "BIF_glutil.h" @@ -66,6 +67,8 @@ #include "RNA_access.h" #include "RNA_types.h" +#include "BPY_extern.h" + #include "interface_intern.h" #define MENU_WIDTH 120 @@ -222,6 +225,7 @@ static void ui_text_bounds_block(uiBlock *block, float offset) uiStyle *style= U.uistyles.first; // XXX pass on as arg uiBut *bt; int i = 0, j, x1addval= offset, nextcol; + int lastcol= 0, col= 0; uiStyleFontSet(&style->widget); @@ -234,18 +238,26 @@ static void ui_text_bounds_block(uiBlock *block, float offset) if(j > i) i = j; } + + if(bt->next && bt->x1 < bt->next->x1) + lastcol++; } /* cope with multi collumns */ bt= block->buttons.first; while(bt) { - if(bt->next && bt->x1 < bt->next->x1) + if(bt->next && bt->x1 < bt->next->x1) { nextcol= 1; + col++; + } else nextcol= 0; bt->x1 = x1addval; bt->x2 = bt->x1 + i + block->bounds; + if(col == lastcol) + bt->x2= MAX2(bt->x2, offset + block->minbounds); + ui_check_but(bt); // clips text again if(nextcol) @@ -278,7 +290,7 @@ void ui_bounds_block(uiBlock *block) if(bt->x2 > block->maxx) block->maxx= bt->x2; if(bt->y2 > block->maxy) block->maxy= bt->y2; - + bt= bt->next; } @@ -288,6 +300,8 @@ void ui_bounds_block(uiBlock *block) block->maxy += block->bounds; } + block->maxx= block->minx + MAX2(block->maxx - block->minx, block->minbounds); + /* hardcoded exception... but that one is annoying with larger safety */ bt= block->buttons.first; if(bt && strncmp(bt->str, "ERROR", 5)==0) xof= 10; @@ -1075,7 +1089,7 @@ void ui_get_but_vectorf(uiBut *but, float *vec) vec[0]= vec[1]= vec[2]= 0.0f; if(RNA_property_type(prop) == PROP_FLOAT) { - tot= RNA_property_array_length(prop); + tot= RNA_property_array_length(&but->rnapoin, prop); tot= MIN2(tot, 3); for(a=0; a<tot; a++) @@ -1109,7 +1123,7 @@ void ui_set_but_vectorf(uiBut *but, float *vec) prop= but->rnaprop; if(RNA_property_type(prop) == PROP_FLOAT) { - tot= RNA_property_array_length(prop); + tot= RNA_property_array_length(&but->rnapoin, prop); tot= MIN2(tot, 3); for(a=0; a<tot; a++) @@ -1139,6 +1153,21 @@ int ui_is_but_float(uiBut *but) return 0; } +int ui_is_but_unit(uiBut *but) +{ + Scene *scene= CTX_data_scene((bContext *)but->block->evil_C); + if(scene->unit.system == USER_UNIT_NONE) + return 0; + + if(but->rnaprop==NULL) + return 0; + + if(RNA_SUBTYPE_UNIT_VALUE(RNA_property_subtype(but->rnaprop))==0) + return 0; + + return 1; +} + double ui_get_but_val(uiBut *but) { PropertyRNA *prop; @@ -1152,19 +1181,19 @@ double ui_get_but_val(uiBut *but) switch(RNA_property_type(prop)) { case PROP_BOOLEAN: - if(RNA_property_array_length(prop)) + if(RNA_property_array_length(&but->rnapoin, prop)) value= RNA_property_boolean_get_index(&but->rnapoin, prop, but->rnaindex); else value= RNA_property_boolean_get(&but->rnapoin, prop); break; case PROP_INT: - if(RNA_property_array_length(prop)) + if(RNA_property_array_length(&but->rnapoin, prop)) value= RNA_property_int_get_index(&but->rnapoin, prop, but->rnaindex); else value= RNA_property_int_get(&but->rnapoin, prop); break; case PROP_FLOAT: - if(RNA_property_array_length(prop)) + if(RNA_property_array_length(&but->rnapoin, prop)) value= RNA_property_float_get_index(&but->rnapoin, prop, but->rnaindex); else value= RNA_property_float_get(&but->rnapoin, prop); @@ -1216,19 +1245,19 @@ void ui_set_but_val(uiBut *but, double value) if(RNA_property_editable(&but->rnapoin, prop)) { switch(RNA_property_type(prop)) { case PROP_BOOLEAN: - if(RNA_property_array_length(prop)) + if(RNA_property_array_length(&but->rnapoin, prop)) RNA_property_boolean_set_index(&but->rnapoin, prop, but->rnaindex, value); else RNA_property_boolean_set(&but->rnapoin, prop, value); break; case PROP_INT: - if(RNA_property_array_length(prop)) + if(RNA_property_array_length(&but->rnapoin, prop)) RNA_property_int_set_index(&but->rnapoin, prop, but->rnaindex, value); else RNA_property_int_set(&but->rnapoin, prop, value); break; case PROP_FLOAT: - if(RNA_property_array_length(prop)) + if(RNA_property_array_length(&but->rnapoin, prop)) RNA_property_float_set_index(&but->rnapoin, prop, but->rnaindex, value); else RNA_property_float_set(&but->rnapoin, prop, value); @@ -1305,6 +1334,55 @@ int ui_get_but_string_max_length(uiBut *but) return UI_MAX_DRAW_STR; } +static double ui_get_but_scale_unit(uiBut *but, double value) +{ + Scene *scene= CTX_data_scene((bContext *)but->block->evil_C); + int subtype= RNA_property_subtype(but->rnaprop); + + if(subtype & PROP_UNIT_LENGTH) { + return value * scene->unit.scale_length; + } + else if(subtype & PROP_UNIT_TIME) { /* WARNING - using evil_C :| */ + return FRA2TIME(value); + } + else { + return value; + } +} + +static void ui_get_but_string_unit(uiBut *but, char *str, int len_max, double value, int pad) +{ + Scene *scene= CTX_data_scene((bContext *)but->block->evil_C); + int do_split= scene->unit.flag & USER_UNIT_OPT_SPLIT; + int unit_type= RNA_SUBTYPE_UNIT_VALUE(RNA_property_subtype(but->rnaprop)); + int precission= but->a2; + + if(scene->unit.scale_length<0.0001) scene->unit.scale_length= 1.0; // XXX do_versions + + /* Sanity checks */ + if(precission>4) precission= 4; + else if(precission==0) precission= 2; + + bUnit_AsString(str, len_max, ui_get_but_scale_unit(but, value), precission, scene->unit.system, unit_type, do_split, pad); +} + +static float ui_get_but_step_unit(uiBut *but, double value, float step_default) +{ + Scene *scene= CTX_data_scene((bContext *)but->block->evil_C); + int unit_type= RNA_SUBTYPE_UNIT_VALUE(RNA_property_subtype(but->rnaprop)); + float step; + + step = bUnit_ClosestScalar(ui_get_but_scale_unit(but, value), scene->unit.system, unit_type); + + if(step > 0.0) { /* -1 is an error value */ + return (step/ui_get_but_scale_unit(but, 1.0))*100; + } + else { + return step_default; + } +} + + void ui_get_but_string(uiBut *but, char *str, int maxlen) { if(but->rnaprop && ELEM3(but->type, TEX, IDPOIN, SEARCH_MENU)) { @@ -1360,7 +1438,10 @@ void ui_get_but_string(uiBut *but, char *str, int maxlen) value= ui_get_but_val(but); if(ui_is_but_float(but)) { - if(but->a2) { /* amount of digits defined */ + if(ui_is_but_unit(but)) { + ui_get_but_string_unit(but, str, maxlen, value, 0); + } + else if(but->a2) { /* amount of digits defined */ if(but->a2==1) BLI_snprintf(str, maxlen, "%.1f", value); else if(but->a2==2) BLI_snprintf(str, maxlen, "%.2f", value); else if(but->a2==3) BLI_snprintf(str, maxlen, "%.3f", value); @@ -1433,14 +1514,30 @@ int ui_set_but_string(bContext *C, uiBut *but, const char *str) /* number editing */ double value; - /* XXX 2.50 missing python api */ -#if 0 - if(BPY_button_eval(str, &value)) { - BKE_report(CTX_reports(C), RPT_WARNING, "Invalid Python expression, check console"); - value = 0.0f; /* Zero out value on error */ - - if(str[0]) - return 0; +#ifndef DISABLE_PYTHON + { + char str_unit_convert[256]; + int unit_type; + Scene *scene= CTX_data_scene((bContext *)but->block->evil_C); + + if(but->rnaprop) + unit_type= RNA_SUBTYPE_UNIT_VALUE(RNA_property_subtype(but->rnaprop)); + else + unit_type= 0; + + BLI_strncpy(str_unit_convert, str, sizeof(str_unit_convert)); + + if(scene->unit.system != USER_UNIT_NONE && unit_type) { + /* ugly, use the draw string to get the value, this could cause problems if it includes some text which resolves to a unit */ + bUnit_ReplaceString(str_unit_convert, sizeof(str_unit_convert), but->drawstr, ui_get_but_scale_unit(but, 1.0), scene->unit.system, unit_type); + } + + if(BPY_button_eval(C, str_unit_convert, &value)) { + value = ui_get_but_val(but); /* use its original value */ + + if(str[0]) + return 0; + } } #else value= atof(str); @@ -1786,6 +1883,12 @@ void ui_check_but(uiBut *but) if(ui_is_but_float(but)) { if(value == FLT_MAX) sprintf(but->drawstr, "%sinf", but->str); else if(value == -FLT_MAX) sprintf(but->drawstr, "%s-inf", but->str); + /* support length type buttons */ + else if(ui_is_but_unit(but)) { + char new_str[sizeof(but->drawstr)]; + ui_get_but_string_unit(but, new_str, sizeof(new_str), value, TRUE); + BLI_snprintf(but->drawstr, sizeof(but->drawstr), "%s%s", but->str, new_str); + } else if(but->a2) { /* amount of digits defined */ if(but->a2==1) sprintf(but->drawstr, "%s%.1f", but->str, value); else if(but->a2==2) sprintf(but->drawstr, "%s%.2f", but->str, value); @@ -2194,8 +2297,12 @@ uiBut *ui_def_but_rna(uiBlock *block, int type, int retval, char *str, short x1, dynstr= BLI_dynstr_new(); BLI_dynstr_appendf(dynstr, "%s%%t", RNA_property_ui_name(prop)); for(i=0; i<totitem; i++) { - if(!item[i].identifier[0]) - BLI_dynstr_append(dynstr, "|%l"); + if(!item[i].identifier[0]) { + if(item[i].name) + BLI_dynstr_appendf(dynstr, "|%s%%l", item[i].name); + else + BLI_dynstr_append(dynstr, "|%l"); + } else if(item[i].icon) BLI_dynstr_appendf(dynstr, "|%s %%i%d %%x%d", item[i].name, item[i].icon, item[i].value); else @@ -2307,7 +2414,7 @@ uiBut *ui_def_but_rna(uiBlock *block, int type, int retval, char *str, short x1, but->rnapoin= *ptr; but->rnaprop= prop; - if(RNA_property_array_length(but->rnaprop)) + if(RNA_property_array_length(&but->rnapoin, but->rnaprop)) but->rnaindex= index; else but->rnaindex= 0; @@ -2325,6 +2432,10 @@ uiBut *ui_def_but_rna(uiBlock *block, int type, int retval, char *str, short x1, but->lockstr = ""; } + /* If this button uses units, calculate the step from this */ + if(ui_is_but_unit(but)) + but->a1= ui_get_but_step_unit(but, ui_get_but_val(but), but->a1); + if(freestr) MEM_freeN(str); @@ -2743,6 +2854,8 @@ void uiBlockFlipOrder(uiBlock *block) if(U.uiflag & USER_MENUFIXEDORDER) return; + else if(block->flag & UI_BLOCK_NO_FLIP) + return; for(but= block->buttons.first; but; but= but->next) { if(but->flag & UI_BUT_ALIGN) return; @@ -2835,10 +2948,11 @@ void uiButSetRenameFunc(uiBut *but, uiButHandleRenameFunc func, void *arg1) but->rename_arg1= arg1; } -void uiBlockSetDrawExtraFunc(uiBlock *block, void (*func)(const bContext *C, void *idv, void *argv, rcti *rect), void *arg) +void uiBlockSetDrawExtraFunc(uiBlock *block, void (*func)(const bContext *C, void *idv, void *arg1, void *arg2, rcti *rect), void *arg1, void *arg2) { block->drawextra= func; - block->drawextra_arg= arg; + block->drawextra_arg1= arg1; + block->drawextra_arg2= arg2; } void uiButSetFunc(uiBut *but, uiButHandleFunc func, void *arg1, void *arg2) @@ -2952,7 +3066,6 @@ uiBut *uiDefIconBlockBut(uiBlock *block, uiBlockCreateFunc func, void *arg, int but->flag|= UI_HAS_ICON; but->flag|= UI_ICON_LEFT; - but->flag|= UI_ICON_SUBMENU; but->block_create_func= func; ui_check_but(but); diff --git a/source/blender/editors/interface/interface_anim.c b/source/blender/editors/interface/interface_anim.c index 2993a1aba15..784d820ea52 100644 --- a/source/blender/editors/interface/interface_anim.c +++ b/source/blender/editors/interface/interface_anim.c @@ -217,7 +217,7 @@ void ui_but_anim_menu(bContext *C, uiBut *but) pup= uiPupMenuBegin(C, RNA_property_ui_name(but->rnaprop), 0); layout= uiPupMenuLayout(pup); - length= RNA_property_array_length(but->rnaprop); + length= RNA_property_array_length(&but->rnapoin, but->rnaprop); if(but->flag & UI_BUT_ANIMATED_KEY) { if(length) { diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index 30cfafb24f8..b69e8319956 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -315,6 +315,7 @@ static void ui_apply_autokey_undo(bContext *C, uiBut *but) static void ui_apply_but_funcs_after(bContext *C) { uiAfterFunc *afterf, after; + PointerRNA opptr; ListBase funcs; /* copy to avoid recursive calls */ @@ -328,13 +329,18 @@ static void ui_apply_but_funcs_after(bContext *C) if(after.context) CTX_store_set(C, after.context); - if(after.optype) - WM_operator_name_call(C, after.optype->idname, after.opcontext, after.opptr); if(after.opptr) { - WM_operator_properties_free(after.opptr); + /* free in advance to avoid leak on exit */ + opptr= *after.opptr, MEM_freeN(after.opptr); } + if(after.optype) + WM_operator_name_call(C, after.optype->idname, after.opcontext, (after.opptr)? &opptr: NULL); + + if(after.opptr) + WM_operator_properties_free(&opptr); + if(after.rnapoin.data) RNA_property_update(C, &after.rnapoin, after.rnaprop); @@ -968,7 +974,7 @@ static void ui_but_copy_paste(bContext *C, uiBut *but, uiHandleButtonData *data, char *str; opptr= uiButGetOperatorPtrRNA(but); /* allocated when needed, the button owns it */ - str= WM_operator_pystring(but->optype, opptr, 0); + str= WM_operator_pystring(C, but->optype, opptr, 0); WM_clipboard_text_set(str, 0); @@ -1714,6 +1720,7 @@ static void ui_blockopen_begin(bContext *C, uiBut *but, uiHandleButtonData *data uiBlockCreateFunc func= NULL; uiBlockHandleCreateFunc handlefunc= NULL; uiMenuCreateFunc menufunc= NULL; + char *menustr= NULL; void *arg= NULL; switch(but->type) { @@ -1738,16 +1745,15 @@ static void ui_blockopen_begin(bContext *C, uiBut *but, uiHandleButtonData *data data->value= data->origvalue; but->editval= &data->value; - handlefunc= ui_block_func_MENU; - arg= but; + menustr= but->str; } break; case ICONROW: - handlefunc= ui_block_func_ICONROW; + menufunc= ui_block_func_ICONROW; arg= but; break; case ICONTEXTROW: - handlefunc= ui_block_func_ICONTEXTROW; + menufunc= ui_block_func_ICONTEXTROW; arg= but; break; case COL: @@ -1765,8 +1771,8 @@ static void ui_blockopen_begin(bContext *C, uiBut *but, uiHandleButtonData *data if(but->block->handle) data->menu->popup= but->block->handle->popup; } - else if(menufunc) { - data->menu= ui_popup_menu_create(C, data->region, but, menufunc, arg); + else if(menufunc || menustr) { + data->menu= ui_popup_menu_create(C, data->region, but, menufunc, arg, menustr); if(but->block->handle) data->menu->popup= but->block->handle->popup; } @@ -3723,10 +3729,15 @@ static void button_activate_exit(bContext *C, uiHandleButtonData *data, uiBut *b } } - /* autokey & undo push */ - if(!data->cancel) + if(!data->cancel) { + /* autokey & undo push */ ui_apply_autokey_undo(C, but); + /* popup menu memory */ + if(block->flag & UI_BLOCK_POPUP_MEMORY) + ui_popup_menu_memory(block, but); + } + /* disable tooltips until mousemove + last active flag */ for(block=data->region->uiblocks.first; block; block=block->next) { for(bt=block->buttons.first; bt; bt=bt->next) diff --git a/source/blender/editors/interface/interface_intern.h b/source/blender/editors/interface/interface_intern.h index 04c0c417fdb..806b40b8646 100644 --- a/source/blender/editors/interface/interface_intern.h +++ b/source/blender/editors/interface/interface_intern.h @@ -273,8 +273,9 @@ struct uiBlock { int (*block_event_func)(const struct bContext *C, struct uiBlock *, struct wmEvent *); /* extra draw function for custom blocks */ - void (*drawextra)(const struct bContext *C, void *idv, void *argv, rcti *rect); - void *drawextra_arg; + void (*drawextra)(const struct bContext *C, void *idv, void *arg1, void *arg2, rcti *rect); + void *drawextra_arg1; + void *drawextra_arg2; int afterval, flag; @@ -286,7 +287,8 @@ struct uiBlock { char *lockstr; float xofs, yofs; // offset to parent button - int bounds, dobounds, mx, my; // for doing delayed + int dobounds, mx, my; // for doing delayed + int bounds, minbounds; // for doing delayed int endblock; // uiEndBlock done? rctf safety; // pulldowns, to detect outside, can differ per case how it is created @@ -296,6 +298,7 @@ struct uiBlock { int tooltipdisabled; // to avoid tooltip after click int active; // to keep blocks while drawing and free them afterwards + int puphash; // popup menu hash for memory void *evil_C; // XXX hack for dynamic operator enums }; @@ -337,6 +340,7 @@ extern void ui_set_but_soft_range(uiBut *but, double value); extern void ui_check_but(uiBut *but); extern int ui_is_but_float(uiBut *but); +extern int ui_is_but_unit(uiBut *but); extern void ui_update_block_buts_hsv(uiBlock *block, float *hsv); extern void ui_bounds_block(uiBlock *block); @@ -370,14 +374,15 @@ struct uiPopupBlockHandle { float retvec[3]; }; -uiBlock *ui_block_func_MENU(struct bContext *C, uiPopupBlockHandle *handle, void *arg_but); -uiBlock *ui_block_func_ICONROW(struct bContext *C, uiPopupBlockHandle *handle, void *arg_but); -uiBlock *ui_block_func_ICONTEXTROW(struct bContext *C, uiPopupBlockHandle *handle, void *arg_but); uiBlock *ui_block_func_COL(struct bContext *C, uiPopupBlockHandle *handle, void *arg_but); +void ui_block_func_ICONROW(struct bContext *C, uiLayout *layout, void *arg_but); +void ui_block_func_ICONTEXTROW(struct bContext *C, uiLayout *layout, void *arg_but); struct ARegion *ui_tooltip_create(struct bContext *C, struct ARegion *butregion, uiBut *but); void ui_tooltip_free(struct bContext *C, struct ARegion *ar); +uiBut *ui_popup_menu_memory(uiBlock *block, uiBut *but); + /* searchbox for string button */ ARegion *ui_searchbox_create(struct bContext *C, struct ARegion *butregion, uiBut *but); int ui_searchbox_inside(struct ARegion *ar, int x, int y); @@ -392,7 +397,8 @@ typedef uiBlock* (*uiBlockHandleCreateFunc)(struct bContext *C, struct uiPopupBl uiPopupBlockHandle *ui_popup_block_create(struct bContext *C, struct ARegion *butregion, uiBut *but, uiBlockCreateFunc create_func, uiBlockHandleCreateFunc handle_create_func, void *arg); uiPopupBlockHandle *ui_popup_menu_create(struct bContext *C, struct ARegion *butregion, uiBut *but, - uiMenuCreateFunc create_func, void *arg); + uiMenuCreateFunc create_func, void *arg, char *str); + void ui_popup_block_free(struct bContext *C, uiPopupBlockHandle *handle); void ui_set_name_menu(uiBut *but, int value); diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c index 6932ad350b0..a52afcb1a92 100644 --- a/source/blender/editors/interface/interface_layout.c +++ b/source/blender/editors/interface/interface_layout.c @@ -215,16 +215,16 @@ static int ui_layout_vary_direction(uiLayout *layout) } /* estimated size of text + icon */ -static int ui_text_icon_width(uiLayout *layout, char *name, int icon) +static int ui_text_icon_width(uiLayout *layout, char *name, int icon, int compact) { int variable = ui_layout_vary_direction(layout) == UI_ITEM_VARY_X; if(icon && !name[0]) return UI_UNIT_X; /* icon only */ else if(icon) - return (variable)? UI_GetStringWidth(name) + 4 + UI_UNIT_X: 10*UI_UNIT_X; /* icon + text */ + return (variable)? UI_GetStringWidth(name) + (compact? 5: 10) + UI_UNIT_X: 10*UI_UNIT_X; /* icon + text */ else - return (variable)? UI_GetStringWidth(name) + 4 + UI_UNIT_X: 10*UI_UNIT_X; /* text only */ + return (variable)? UI_GetStringWidth(name) + (compact? 5: 10) + UI_UNIT_X: 10*UI_UNIT_X; /* text only */ } static void ui_item_size(uiItem *item, int *r_w, int *r_h) @@ -379,31 +379,25 @@ static void ui_item_array(uiLayout *layout, uiBlock *block, char *name, int icon but->type= NUMSLI; } } - else if(len <= 4 && ELEM3(subtype, PROP_ROTATION, PROP_VECTOR, PROP_COLOR)) { - if(subtype == PROP_COLOR) + else { + if(ELEM(subtype, PROP_COLOR, PROP_RGB)) uiDefAutoButR(block, ptr, prop, -1, "", 0, 0, 0, w, UI_UNIT_Y); - if(subtype != PROP_COLOR || expand) { + if(!ELEM(subtype, PROP_COLOR, PROP_RGB) || expand) { /* layout for known array subtypes */ - static char vectoritem[4]= {'X', 'Y', 'Z', 'W'}; - static char quatitem[4]= {'W', 'X', 'Y', 'Z'}; - static char coloritem[4]= {'R', 'G', 'B', 'A'}; char str[3]; for(a=0; a<len; a++) { - if(len == 4 && subtype == PROP_ROTATION) - str[0]= quatitem[a]; - else if(subtype == PROP_VECTOR || subtype == PROP_ROTATION) - str[0]= vectoritem[a]; - else - str[0]= coloritem[a]; - - if(type == PROP_BOOLEAN) { - str[1]= '\0'; - } - else { - str[1]= ':'; - str[2]= '\0'; + str[0]= RNA_property_array_item_char(prop, a); + + if(str[0]) { + if(type == PROP_BOOLEAN) { + str[1]= '\0'; + } + else { + str[1]= ':'; + str[2]= '\0'; + } } but= uiDefAutoButR(block, ptr, prop, a, str, 0, 0, 0, w, UI_UNIT_Y); @@ -411,19 +405,12 @@ static void ui_item_array(uiLayout *layout, uiBlock *block, char *name, int icon but->type= NUMSLI; } } - else if(subtype == PROP_COLOR && len == 4) { + else if(ELEM(subtype, PROP_COLOR, PROP_RGB) && len == 4) { but= uiDefAutoButR(block, ptr, prop, 3, "A:", 0, 0, 0, w, UI_UNIT_Y); if(slider && but->type==NUM) but->type= NUMSLI; } } - else { - for(a=0; a<len; a++) { - but= uiDefAutoButR(block, ptr, prop, a, "", 0, 0, 0, w, UI_UNIT_Y); - if(slider && but->type==NUM) - but->type= NUMSLI; - } - } uiBlockSetCurLayout(block, layout); } @@ -446,7 +433,7 @@ static void ui_item_enum_row(uiLayout *layout, uiBlock *block, PointerRNA *ptr, name= (!uiname || uiname[0])? (char*)item[a].name: ""; icon= item[a].icon; value= item[a].value; - itemw= ui_text_icon_width(block->curlayout, name, icon); + itemw= ui_text_icon_width(block->curlayout, name, icon, 0); if(icon && strcmp(name, "") != 0) uiDefIconTextButR(block, ROW, 0, icon, name, 0, 0, itemw, h, ptr, identifier, -1, 0, value, -1, -1, NULL); @@ -539,7 +526,7 @@ static void ui_item_disabled(uiLayout *layout, char *name) if(!name) name= ""; - w= ui_text_icon_width(layout, name, 0); + w= ui_text_icon_width(layout, name, 0, 0); but= uiDefBut(block, LABEL, 0, (char*)name, 0, 0, w, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 0, ""); but->flag |= UI_BUT_DISABLED; @@ -548,7 +535,7 @@ static void ui_item_disabled(uiLayout *layout, char *name) } /* operator items */ -void uiItemFullO(uiLayout *layout, char *name, int icon, char *idname, IDProperty *properties, int context) +PointerRNA uiItemFullO(uiLayout *layout, char *name, int icon, char *idname, IDProperty *properties, int context, int flag) { uiBlock *block= layout->root->block; wmOperatorType *ot= WM_operatortype_find(idname, 0); @@ -557,7 +544,7 @@ void uiItemFullO(uiLayout *layout, char *name, int icon, char *idname, IDPropert if(!ot) { ui_item_disabled(layout, idname); - return; + return PointerRNA_NULL; } if(!name) @@ -568,7 +555,7 @@ void uiItemFullO(uiLayout *layout, char *name, int icon, char *idname, IDPropert /* create button */ uiBlockSetCurLayout(block, layout); - w= ui_text_icon_width(layout, name, icon); + w= ui_text_icon_width(layout, name, icon, 0); if(icon && strcmp(name, "") != 0) but= uiDefIconTextButO(block, BUT, ot->idname, context, icon, (char*)name, 0, 0, w, UI_UNIT_Y, NULL); @@ -578,10 +565,21 @@ void uiItemFullO(uiLayout *layout, char *name, int icon, char *idname, IDPropert but= uiDefButO(block, BUT, ot->idname, context, (char*)name, 0, 0, w, UI_UNIT_Y, NULL); /* assign properties */ - if(properties) { + if(properties || (flag & UI_ITEM_O_RETURN_PROPS)) { PointerRNA *opptr= uiButGetOperatorPtrRNA(but); - opptr->data= properties; + + if(properties) { + opptr->data= properties; + } + else { + IDPropertyTemplate val = {0}; + opptr->data= IDP_New(IDP_GROUP, val, "wmOperatorProperties"); + } + + return *opptr; } + + return PointerRNA_NULL; } static char *ui_menu_enumpropname(uiLayout *layout, char *opname, char *propname, int retval) @@ -624,7 +622,7 @@ void uiItemEnumO(uiLayout *layout, char *name, int icon, char *opname, char *pro if(!name) name= ui_menu_enumpropname(layout, opname, propname, value); - uiItemFullO(layout, name, icon, opname, ptr.data, layout->root->opcontext); + uiItemFullO(layout, name, icon, opname, ptr.data, layout->root->opcontext, 0); } void uiItemsEnumO(uiLayout *layout, char *opname, char *propname) @@ -632,6 +630,8 @@ void uiItemsEnumO(uiLayout *layout, char *opname, char *propname) wmOperatorType *ot= WM_operatortype_find(opname, 0); PointerRNA ptr; PropertyRNA *prop; + uiBut *bt; + uiBlock *block= layout->root->block; if(!ot || !ot->srna) { ui_item_disabled(layout, opname); @@ -644,14 +644,31 @@ void uiItemsEnumO(uiLayout *layout, char *opname, char *propname) if(prop && RNA_property_type(prop) == PROP_ENUM) { EnumPropertyItem *item; int totitem, i, free; + uiLayout *split= uiLayoutSplit(layout, 0); + uiLayout *column= uiLayoutColumn(split, 0); - RNA_property_enum_items(layout->root->block->evil_C, &ptr, prop, &item, &totitem, &free); + RNA_property_enum_items(block->evil_C, &ptr, prop, &item, &totitem, &free); - for(i=0; i<totitem; i++) - if(item[i].identifier[0]) - uiItemEnumO(layout, (char*)item[i].name, item[i].icon, opname, propname, item[i].value); - else - uiItemS(layout); + for(i=0; i<totitem; i++) { + if(item[i].identifier[0]) { + uiItemEnumO(column, (char*)item[i].name, item[i].icon, opname, propname, item[i].value); + } + else { + if(item[i].name) { + if(i != 0) { + column= uiLayoutColumn(split, 0); + /* inconsistent, but menus with labels do not look good flipped */ + block->flag |= UI_BLOCK_NO_FLIP; + } + + uiItemL(column, (char*)item[i].name, 0); + bt= block->buttons.last; + bt->flag= UI_TEXT_LEFT; + } + else + uiItemS(column); + } + } if(free) MEM_freeN(item); @@ -693,7 +710,7 @@ void uiItemEnumO_string(uiLayout *layout, char *name, int icon, char *opname, ch if(!name) name= ui_menu_enumpropname(layout, opname, propname, value); - uiItemFullO(layout, name, icon, opname, ptr.data, layout->root->opcontext); + uiItemFullO(layout, name, icon, opname, ptr.data, layout->root->opcontext, 0); } void uiItemBooleanO(uiLayout *layout, char *name, int icon, char *opname, char *propname, int value) @@ -703,7 +720,7 @@ void uiItemBooleanO(uiLayout *layout, char *name, int icon, char *opname, char * WM_operator_properties_create(&ptr, opname); RNA_boolean_set(&ptr, propname, value); - uiItemFullO(layout, name, icon, opname, ptr.data, layout->root->opcontext); + uiItemFullO(layout, name, icon, opname, ptr.data, layout->root->opcontext, 0); } void uiItemIntO(uiLayout *layout, char *name, int icon, char *opname, char *propname, int value) @@ -713,7 +730,7 @@ void uiItemIntO(uiLayout *layout, char *name, int icon, char *opname, char *prop WM_operator_properties_create(&ptr, opname); RNA_int_set(&ptr, propname, value); - uiItemFullO(layout, name, icon, opname, ptr.data, layout->root->opcontext); + uiItemFullO(layout, name, icon, opname, ptr.data, layout->root->opcontext, 0); } void uiItemFloatO(uiLayout *layout, char *name, int icon, char *opname, char *propname, float value) @@ -723,7 +740,7 @@ void uiItemFloatO(uiLayout *layout, char *name, int icon, char *opname, char *pr WM_operator_properties_create(&ptr, opname); RNA_float_set(&ptr, propname, value); - uiItemFullO(layout, name, icon, opname, ptr.data, layout->root->opcontext); + uiItemFullO(layout, name, icon, opname, ptr.data, layout->root->opcontext, 0); } void uiItemStringO(uiLayout *layout, char *name, int icon, char *opname, char *propname, char *value) @@ -733,17 +750,17 @@ void uiItemStringO(uiLayout *layout, char *name, int icon, char *opname, char *p WM_operator_properties_create(&ptr, opname); RNA_string_set(&ptr, propname, value); - uiItemFullO(layout, name, icon, opname, ptr.data, layout->root->opcontext); + uiItemFullO(layout, name, icon, opname, ptr.data, layout->root->opcontext, 0); } void uiItemO(uiLayout *layout, char *name, int icon, char *opname) { - uiItemFullO(layout, name, icon, opname, NULL, layout->root->opcontext); + uiItemFullO(layout, name, icon, opname, NULL, layout->root->opcontext, 0); } /* RNA property items */ -static void ui_item_rna_size(uiLayout *layout, char *name, int icon, PropertyRNA *prop, int index, int *r_w, int *r_h) +static void ui_item_rna_size(uiLayout *layout, char *name, int icon, PointerRNA *ptr, PropertyRNA *prop, int index, int *r_w, int *r_h) { PropertyType type; PropertySubType subtype; @@ -752,14 +769,14 @@ static void ui_item_rna_size(uiLayout *layout, char *name, int icon, PropertyRNA /* arbitrary extended width by type */ type= RNA_property_type(prop); subtype= RNA_property_subtype(prop); - len= RNA_property_array_length(prop); + len= RNA_property_array_length(ptr, prop); if(ELEM3(type, PROP_STRING, PROP_POINTER, PROP_ENUM) && !name[0]) name= "non-empty text"; else if(type == PROP_BOOLEAN && !name[0]) icon= ICON_DOT; - w= ui_text_icon_width(layout, name, icon); + w= ui_text_icon_width(layout, name, icon, 0); h= UI_UNIT_Y; /* increase height for arrays */ @@ -776,22 +793,24 @@ static void ui_item_rna_size(uiLayout *layout, char *name, int icon, PropertyRNA } else if(ui_layout_vary_direction(layout) == UI_ITEM_VARY_X) { if(type == PROP_BOOLEAN && strcmp(name, "") != 0) - w += UI_UNIT_X; + w += UI_UNIT_X/5; else if(type == PROP_ENUM) w += UI_UNIT_X/2; + else if(type == PROP_FLOAT || type == PROP_INT) + w += UI_UNIT_X*3; } *r_w= w; *r_h= h; } -void uiItemFullR(uiLayout *layout, char *name, int icon, PointerRNA *ptr, PropertyRNA *prop, int index, int value, int expand, int slider, int toggle) +void uiItemFullR(uiLayout *layout, char *name, int icon, PointerRNA *ptr, PropertyRNA *prop, int index, int value, int flag) { uiBlock *block= layout->root->block; uiBut *but; PropertyType type; char namestr[UI_MAX_NAME_STR]; - int len, w, h; + int len, w, h, slider, toggle, expand; if(!ptr->data || !prop) return; @@ -800,7 +819,7 @@ void uiItemFullR(uiLayout *layout, char *name, int icon, PointerRNA *ptr, Proper /* retrieve info */ type= RNA_property_type(prop); - len= RNA_property_array_length(prop); + len= RNA_property_array_length(ptr, prop); /* set name and icon */ if(!name) @@ -822,8 +841,12 @@ void uiItemFullR(uiLayout *layout, char *name, int icon, PointerRNA *ptr, Proper icon= (RNA_property_enum_get(ptr, prop) == value)? ICON_CHECKBOX_HLT: ICON_CHECKBOX_DEHLT; } + slider= (flag & UI_ITEM_R_SLIDER); + toggle= (flag & UI_ITEM_R_TOGGLE); + expand= (flag & UI_ITEM_R_EXPAND); + /* get size */ - ui_item_rna_size(layout, name, icon, prop, index, &w, &h); + ui_item_rna_size(layout, name, icon, ptr, prop, index, &w, &h); /* array property */ if(index == RNA_NO_INDEX && len > 0) @@ -859,7 +882,7 @@ void uiItemFullR(uiLayout *layout, char *name, int icon, PointerRNA *ptr, Proper } } -void uiItemR(uiLayout *layout, char *name, int icon, PointerRNA *ptr, char *propname, int expand, int slider, int toggle) +void uiItemR(uiLayout *layout, char *name, int icon, PointerRNA *ptr, char *propname, int flag) { PropertyRNA *prop; @@ -874,7 +897,7 @@ void uiItemR(uiLayout *layout, char *name, int icon, PointerRNA *ptr, char *prop return; } - uiItemFullR(layout, name, icon, ptr, prop, RNA_NO_INDEX, 0, expand, slider, toggle); + uiItemFullR(layout, name, icon, ptr, prop, RNA_NO_INDEX, 0, flag); } void uiItemEnumR(uiLayout *layout, char *name, int icon, struct PointerRNA *ptr, char *propname, int value) @@ -892,7 +915,7 @@ void uiItemEnumR(uiLayout *layout, char *name, int icon, struct PointerRNA *ptr, return; } - uiItemFullR(layout, name, icon, ptr, prop, RNA_ENUM_VALUE, value, 0, 0, 0); + uiItemFullR(layout, name, icon, ptr, prop, RNA_ENUM_VALUE, value, 0); } void uiItemEnumR_string(uiLayout *layout, char *name, int icon, struct PointerRNA *ptr, char *propname, char *value) @@ -923,7 +946,7 @@ void uiItemEnumR_string(uiLayout *layout, char *name, int icon, struct PointerRN for(a=0; item[a].identifier; a++) { if(item[a].value == ivalue) { - uiItemFullR(layout, (char*)item[a].name, item[a].icon, ptr, prop, RNA_ENUM_VALUE, ivalue, 0, 0, 0); + uiItemFullR(layout, (char*)item[a].name, item[a].icon, ptr, prop, RNA_ENUM_VALUE, ivalue, 0); break; } } @@ -935,6 +958,8 @@ void uiItemEnumR_string(uiLayout *layout, char *name, int icon, struct PointerRN void uiItemsEnumR(uiLayout *layout, struct PointerRNA *ptr, char *propname) { PropertyRNA *prop; + uiBlock *block= layout->root->block; + uiBut *bt; prop= RNA_struct_find_property(ptr, propname); @@ -946,14 +971,31 @@ void uiItemsEnumR(uiLayout *layout, struct PointerRNA *ptr, char *propname) if(RNA_property_type(prop) == PROP_ENUM) { EnumPropertyItem *item; int totitem, i, free; + uiLayout *split= uiLayoutSplit(layout, 0); + uiLayout *column= uiLayoutColumn(split, 0); - RNA_property_enum_items(layout->root->block->evil_C, ptr, prop, &item, &totitem, &free); + RNA_property_enum_items(block->evil_C, ptr, prop, &item, &totitem, &free); - for(i=0; i<totitem; i++) - if(item[i].identifier[0]) - uiItemEnumR(layout, (char*)item[i].name, 0, ptr, propname, item[i].value); - else - uiItemS(layout); + for(i=0; i<totitem; i++) { + if(item[i].identifier[0]) { + uiItemEnumR(column, (char*)item[i].name, 0, ptr, propname, item[i].value); + } + else { + if(item[i].name) { + if(i != 0) { + column= uiLayoutColumn(split, 0); + /* inconsistent, but menus with labels do not look good flipped */ + block->flag |= UI_BLOCK_NO_FLIP; + } + + uiItemL(column, (char*)item[i].name, 0); + bt= block->buttons.last; + bt->flag= UI_TEXT_LEFT; + } + else + uiItemS(column); + } + } if(free) MEM_freeN(item); @@ -1090,7 +1132,7 @@ void uiItemPointerR(uiLayout *layout, char *name, int icon, struct PointerRNA *p /* create button */ block= uiLayoutGetBlock(layout); - ui_item_rna_size(layout, name, icon, prop, 0, &w, &h); + ui_item_rna_size(layout, name, icon, ptr, prop, 0, &w, &h); but= ui_item_with_label(layout, block, name, icon, ptr, prop, 0, 0, 0, w, h); ui_but_add_search(but, ptr, prop, searchptr, searchprop); @@ -1123,7 +1165,7 @@ static void ui_item_menu(uiLayout *layout, char *name, int icon, uiMenuCreateFun if(layout->root->type == UI_LAYOUT_MENU && !icon) icon= ICON_BLANK1; - w= ui_text_icon_width(layout, name, icon); + w= ui_text_icon_width(layout, name, icon, 1); h= UI_UNIT_Y; if(layout->root->type == UI_LAYOUT_HEADER) /* ugly .. */ @@ -1181,7 +1223,7 @@ void uiItemL(uiLayout *layout, char *name, int icon) if(layout->root->type == UI_LAYOUT_MENU && !icon) icon= ICON_BLANK1; - w= ui_text_icon_width(layout, name, icon); + w= ui_text_icon_width(layout, name, icon, 0); if(icon && strcmp(name, "") != 0) but= uiDefIconTextBut(block, LABEL, 0, icon, (char*)name, 0, 0, w, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 0, ""); @@ -1206,7 +1248,7 @@ void uiItemV(uiLayout *layout, char *name, int icon, int argval) if(layout->root->type == UI_LAYOUT_MENU && !icon) icon= ICON_BLANK1; - w= ui_text_icon_width(layout, name, icon); + w= ui_text_icon_width(layout, name, icon, 0); if(icon && strcmp(name, "") != 0) uiDefIconTextButF(block, BUTM, 0, icon, (char*)name, 0, 0, w, UI_UNIT_Y, retvalue, 0.0, 0.0, 0, argval, ""); @@ -1226,12 +1268,12 @@ void uiItemS(uiLayout *layout) } /* level items */ -void uiItemMenuF(uiLayout *layout, char *name, int icon, uiMenuCreateFunc func) +void uiItemMenuF(uiLayout *layout, char *name, int icon, uiMenuCreateFunc func, void *arg) { if(!func) return; - ui_item_menu(layout, name, icon, func, NULL, NULL); + ui_item_menu(layout, name, icon, func, arg, NULL); } typedef struct MenuItemLevel { @@ -1984,6 +2026,11 @@ int uiLayoutGetAlignment(uiLayout *layout) return layout->alignment; } +int uiLayoutGetWidth(uiLayout *layout) +{ + return layout->w; +} + float uiLayoutGetScaleX(uiLayout *layout) { return layout->scale[0]; diff --git a/source/blender/editors/interface/interface_panel.c b/source/blender/editors/interface/interface_panel.c index 846fbe75072..05001109b53 100644 --- a/source/blender/editors/interface/interface_panel.c +++ b/source/blender/editors/interface/interface_panel.c @@ -104,7 +104,7 @@ static int panel_aligned(ScrArea *sa, ARegion *ar) SpaceButs *sbuts= sa->spacedata.first; return sbuts->align; } - else if(sa->spacetype==SPACE_INFO && ar->regiontype == RGN_TYPE_WINDOW) + else if(sa->spacetype==SPACE_USERPREF && ar->regiontype == RGN_TYPE_WINDOW) return BUT_VERTICAL; else if(sa->spacetype==SPACE_FILE && ar->regiontype == RGN_TYPE_CHANNELS) return BUT_VERTICAL; @@ -1247,7 +1247,7 @@ int ui_handler_panel_region(bContext *C, wmEvent *event) if(!pa || pa->paneltab!=NULL) continue; - if(pa->type && pa->type->flag & PNL_NO_HEADER) + if(pa->type && pa->type->flag & PNL_NO_HEADER) // XXX - accessed freed panels when scripts reload, need to fix. continue; if(block->minx <= mx && block->maxx >= mx) diff --git a/source/blender/editors/interface/interface_regions.c b/source/blender/editors/interface/interface_regions.c index b59db055647..1d911fef418 100644 --- a/source/blender/editors/interface/interface_regions.c +++ b/source/blender/editors/interface/interface_regions.c @@ -38,6 +38,7 @@ #include "BLI_arithb.h" #include "BLI_blenlib.h" #include "BLI_dynstr.h" +#include "BLI_ghash.h" #include "BKE_context.h" #include "BKE_icons.h" @@ -75,13 +76,14 @@ /*********************** Menu Data Parsing ********************* */ -typedef struct { +typedef struct MenuEntry { char *str; int retval; int icon; + int sepr; } MenuEntry; -typedef struct { +typedef struct MenuData { char *instr; char *title; int titleicon; @@ -111,7 +113,7 @@ static void menudata_set_title(MenuData *md, char *title, int titleicon) md->titleicon= titleicon; } -static void menudata_add_item(MenuData *md, char *str, int retval, int icon) +static void menudata_add_item(MenuData *md, char *str, int retval, int icon, int sepr) { if (md->nitems==md->itemssize) { int nsize= md->itemssize?(md->itemssize<<1):1; @@ -129,6 +131,7 @@ static void menudata_add_item(MenuData *md, char *str, int retval, int icon) md->items[md->nitems].str= str; md->items[md->nitems].retval= retval; md->items[md->nitems].icon= icon; + md->items[md->nitems].sepr= sepr; md->nitems++; } @@ -142,12 +145,13 @@ void menudata_free(MenuData *md) /** * Parse menu description strings, string is of the - * form "[sss%t|]{(sss[%xNN]|), (%l|)}", ssss%t indicates the + * form "[sss%t|]{(sss[%xNN]|), (%l|), (sss%l|)}", ssss%t indicates the * menu title, sss or sss%xNN indicates an option, * if %xNN is given then NN is the return value if * that option is selected otherwise the return value * is the index of the option (starting with 1). %l - * indicates a seperator. + * indicates a seperator, sss%l indicates a label and + * new column. * * @param str String to be parsed. * @retval new menudata structure, free with menudata_free() @@ -157,7 +161,7 @@ MenuData *decompose_menu_string(char *str) char *instr= BLI_strdup(str); MenuData *md= menudata_new(instr); char *nitem= NULL, *s= instr; - int nicon=0, nretval= 1, nitem_is_title= 0; + int nicon=0, nretval= 1, nitem_is_title= 0, nitem_is_sepr= 0; while (1) { char c= *s; @@ -174,7 +178,10 @@ MenuData *decompose_menu_string(char *str) *s= '\0'; s++; } else if (s[1]=='l') { - nitem= "%l"; + nitem_is_sepr= 1; + if(!nitem) nitem= ""; + + *s= '\0'; s++; } else if (s[1]=='i') { nicon= atoi(s+2); @@ -186,15 +193,18 @@ MenuData *decompose_menu_string(char *str) if (nitem) { *s= '\0'; - if (nitem_is_title) { + if(nitem_is_title) { menudata_set_title(md, nitem, nicon); nitem_is_title= 0; - } else { + } + else if(nitem_is_sepr) { /* prevent separator to get a value */ - if(nitem[0]=='%' && nitem[1]=='l') - menudata_add_item(md, nitem, -1, nicon); - else - menudata_add_item(md, nitem, nretval, nicon); + menudata_add_item(md, nitem, -1, nicon, 1); + nretval= md->nitems+1; + nitem_is_sepr= 0; + } + else { + menudata_add_item(md, nitem, nretval, nicon, 0); nretval= md->nitems+1; } @@ -396,7 +406,7 @@ ARegion *ui_tooltip_create(bContext *C, ARegion *butregion, uiBut *but) char *str; opptr= uiButGetOperatorPtrRNA(but); /* allocated when needed, the button owns it */ - str= WM_operator_pystring(but->optype, opptr, 0); + str= WM_operator_pystring(C, but->optype, opptr, 0); /* operator info */ BLI_snprintf(data->lines[data->totline], sizeof(data->lines[0]), "Python: %s", str); @@ -827,6 +837,8 @@ static void ui_searchbox_region_free(ARegion *ar) ar->regiondata= NULL; } +static void ui_block_position(wmWindow *window, ARegion *butregion, uiBut *but, uiBlock *block); + ARegion *ui_searchbox_create(bContext *C, ARegion *butregion, uiBut *but) { uiStyle *style= U.uistyles.first; // XXX pass on as arg @@ -847,7 +859,7 @@ ARegion *ui_searchbox_create(bContext *C, ARegion *butregion, uiBut *but) /* create searchbox data */ data= MEM_callocN(sizeof(uiSearchboxData), "uiSearchboxData"); - + /* set font, get bb */ data->fstyle= style->widget; /* copy struct */ data->fstyle.align= UI_STYLE_TEXT_CENTER; @@ -929,10 +941,14 @@ ARegion *ui_searchbox_create(bContext *C, ARegion *butregion, uiBut *but) } } if(y1 < 0) { - y1 += 36; - y2 += 36; + int newy1; + UI_view2d_to_region_no_clip(&butregion->v2d, 0, but->y2 + ofsy, 0, &newy1); + newy1 += butregion->winrct.ymin; + + y2= y2-y1 + newy1; + y1= newy1; } - + /* widget rect, in region coords */ data->bbox.xmin= MENU_SHADOW_SIDE; data->bbox.xmax= x2-x1 + MENU_SHADOW_SIDE; @@ -1310,24 +1326,21 @@ void ui_popup_block_free(bContext *C, uiPopupBlockHandle *handle) /***************************** Menu Button ***************************/ -uiBlock *ui_block_func_MENU(bContext *C, uiPopupBlockHandle *handle, void *arg_but) +static void ui_block_func_MENUSTR(bContext *C, uiLayout *layout, void *arg_str) { - uiBut *but= arg_but; - uiBlock *block; + uiBlock *block= uiLayoutGetBlock(layout); + uiPopupBlockHandle *handle= block->handle; + uiLayout *split, *column=NULL; uiBut *bt; MenuData *md; - ListBase lb; - float aspect; - int width, height, boxh, columns, rows, startx, starty, x1, y1, xmax, a; - - /* create the block */ - block= uiBeginBlock(C, handle->region, "menu", UI_EMBOSSP); - block->flag= UI_BLOCK_LOOP|UI_BLOCK_REDRAW|UI_BLOCK_NUMSELECT; + MenuEntry *entry; + char *instr= arg_str; + int columns, rows, a, b; /* compute menu data */ - md= decompose_menu_string(but->str); + md= decompose_menu_string(instr); - /* columns and row calculation */ + /* columns and row estimation */ columns= (md->nitems+20)/20; if(columns<1) columns= 1; @@ -1339,180 +1352,114 @@ uiBlock *ui_block_func_MENU(bContext *C, uiPopupBlockHandle *handle, void *arg_b rows= 1; while(rows*columns<md->nitems) rows++; - - /* prevent scaling up of pupmenu */ - aspect= but->block->aspect; - if(aspect < 1.0f) - aspect = 1.0f; - - /* size and location */ - if(md->title) - width= 1.5*aspect*strlen(md->title)+UI_GetStringWidth(md->title); - else - width= 0; - for(a=0; a<md->nitems; a++) { - xmax= aspect*UI_GetStringWidth(md->items[a].str); - if(md->items[a].icon) - xmax += 20*aspect; - if(xmax>width) - width= xmax; - } - - width+= 10; - if(width < (but->x2 - but->x1)) - width = (but->x2 - but->x1); - if(width<50) - width=50; - - boxh= MENU_BUTTON_HEIGHT; - - height= rows*boxh; - if(md->title) - height+= boxh; - - /* here we go! */ - startx= but->x1; - starty= but->y1; - + /* create title */ if(md->title) { - uiBut *bt; - - if (md->titleicon) { - bt= uiDefIconTextBut(block, LABEL, 0, md->titleicon, md->title, startx, (short)(starty+rows*boxh), (short)width, (short)boxh, NULL, 0.0, 0.0, 0, 0, ""); - } else { - bt= uiDefBut(block, LABEL, 0, md->title, startx, (short)(starty+rows*boxh), (short)width, (short)boxh, NULL, 0.0, 0.0, 0, 0, ""); + if(md->titleicon) { + uiItemL(layout, md->title, md->titleicon); + } + else { + uiItemL(layout, md->title, 0); + bt= block->buttons.last; bt->flag= UI_TEXT_LEFT; } } - for(a=0; a<md->nitems; a++) { + /* inconsistent, but menus with labels do not look good flipped */ + for(a=0, b=0; a<md->nitems; a++, b++) { + entry= &md->items[a]; + + if(entry->sepr && entry->str[0]) + block->flag |= UI_BLOCK_NO_FLIP; + } + + /* create items */ + split= uiLayoutSplit(layout, 0); + + for(a=0, b=0; a<md->nitems; a++, b++) { + if(block->flag & UI_BLOCK_NO_FLIP) + entry= &md->items[a]; + else + entry= &md->items[md->nitems-a-1]; - x1= startx + width*((int)(md->nitems-a-1)/rows); - y1= starty - boxh*(rows - ((md->nitems - a - 1)%rows)) + (rows*boxh); + /* new column on N rows or on separation label */ + if((b % rows == 0) || (entry->sepr && entry->str[0])) { + column= uiLayoutColumn(split, 0); + b= 0; + } - if (strcmp(md->items[md->nitems-a-1].str, "%l")==0) { - bt= uiDefBut(block, SEPR, B_NOP, "", x1, y1,(short)(width-(rows>1)), (short)(boxh-1), NULL, 0.0, 0.0, 0, 0, ""); + if(entry->sepr) { + uiItemL(column, entry->str, entry->icon); + bt= block->buttons.last; + bt->flag= UI_TEXT_LEFT; } - else if(md->items[md->nitems-a-1].icon) { - bt= uiDefIconTextButF(block, BUTM|FLO, B_NOP, md->items[md->nitems-a-1].icon ,md->items[md->nitems-a-1].str, x1, y1,(short)(width-(rows>1)), (short)(boxh-1), &handle->retvalue, (float) md->items[md->nitems-a-1].retval, 0.0, 0, 0, ""); + else if(entry->icon) { + uiDefIconTextButF(block, BUTM|FLO, B_NOP, entry->icon, entry->str, 0, 0, + UI_UNIT_X*5, UI_UNIT_Y, &handle->retvalue, (float) entry->retval, 0.0, 0, 0, ""); } else { - bt= uiDefButF(block, BUTM|FLO, B_NOP, md->items[md->nitems-a-1].str, x1, y1,(short)(width-(rows>1)), (short)(boxh-1), &handle->retvalue, (float) md->items[md->nitems-a-1].retval, 0.0, 0, 0, ""); + uiDefButF(block, BUTM|FLO, B_NOP, entry->str, 0, 0, + UI_UNIT_X*5, UI_UNIT_X, &handle->retvalue, (float) entry->retval, 0.0, 0, 0, ""); } } menudata_free(md); - - /* the code up here has flipped locations, because of change of preferred order */ - /* thats why we have to switch list order too, to make arrowkeys work */ - - lb.first= lb.last= NULL; - bt= block->buttons.first; - while(bt) { - uiBut *next= bt->next; - BLI_remlink(&block->buttons, bt); - BLI_addhead(&lb, bt); - bt= next; - } - block->buttons= lb; - - block->direction= UI_TOP; - uiEndBlock(C, block); - - return block; } -uiBlock *ui_block_func_ICONROW(bContext *C, uiPopupBlockHandle *handle, void *arg_but) +void ui_block_func_ICONROW(bContext *C, uiLayout *layout, void *arg_but) { + uiBlock *block= uiLayoutGetBlock(layout); + uiPopupBlockHandle *handle= block->handle; uiBut *but= arg_but; - uiBlock *block; int a; - block= uiBeginBlock(C, handle->region, "menu", UI_EMBOSSP); - block->flag= UI_BLOCK_LOOP|UI_BLOCK_REDRAW|UI_BLOCK_NUMSELECT; - - for(a=(int)but->hardmin; a<=(int)but->hardmax; a++) { - uiDefIconButF(block, BUTM|FLO, B_NOP, but->icon+(a-but->hardmin), 0, (short)(18*a), (short)(but->x2-but->x1-4), 18, &handle->retvalue, (float)a, 0.0, 0, 0, ""); - } - - block->direction= UI_TOP; - - uiEndBlock(C, block); - - return block; + for(a=(int)but->hardmin; a<=(int)but->hardmax; a++) + uiDefIconButF(block, BUTM|FLO, B_NOP, but->icon+(a-but->hardmin), 0, 0, UI_UNIT_X*5, UI_UNIT_Y, + &handle->retvalue, (float)a, 0.0, 0, 0, ""); } -uiBlock *ui_block_func_ICONTEXTROW(bContext *C, uiPopupBlockHandle *handle, void *arg_but) +void ui_block_func_ICONTEXTROW(bContext *C, uiLayout *layout, void *arg_but) { - uiBut *but= arg_but; - uiBlock *block; + uiBlock *block= uiLayoutGetBlock(layout); + uiPopupBlockHandle *handle= block->handle; + uiBut *but= arg_but, *bt; MenuData *md; - int width, xmax, ypos, a; - - block= uiBeginBlock(C, handle->region, "menu", UI_EMBOSSP); - block->flag= UI_BLOCK_LOOP|UI_BLOCK_REDRAW|UI_BLOCK_NUMSELECT; + MenuEntry *entry; + int a; md= decompose_menu_string(but->str); - /* size and location */ - /* expand menu width to fit labels */ - if(md->title) - width= 2*strlen(md->title)+UI_GetStringWidth(md->title); - else - width= 0; - - for(a=0; a<md->nitems; a++) { - xmax= UI_GetStringWidth(md->items[a].str); - if(xmax>width) width= xmax; + /* title */ + if(md->title) { + bt= uiDefBut(block, LABEL, 0, md->title, 0, 0, UI_UNIT_X*5, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 0, ""); + bt->flag= UI_TEXT_LEFT; } - width+= 30; - if (width<50) width=50; - - ypos = 1; - /* loop through the menu options and draw them out with icons & text labels */ for(a=0; a<md->nitems; a++) { + entry= &md->items[md->nitems-a-1]; - /* add a space if there's a separator (%l) */ - if (strcmp(md->items[a].str, "%l")==0) { - ypos +=3; - } - else { - uiDefIconTextButF(block, BUTM|FLO, B_NOP, (short)((but->icon)+(md->items[a].retval-but->hardmin)), md->items[a].str, 0, ypos,(short)width, 19, &handle->retvalue, (float) md->items[a].retval, 0.0, 0, 0, ""); - ypos += 20; - } + if(entry->sepr) + uiItemS(layout); + else + uiDefIconTextButF(block, BUTM|FLO, B_NOP, (short)((but->icon)+(entry->retval-but->hardmin)), entry->str, + 0, 0, UI_UNIT_X*5, UI_UNIT_Y, &handle->retvalue, (float) entry->retval, 0.0, 0, 0, ""); } - - if(md->title) { - uiBut *bt; - bt= uiDefBut(block, LABEL, 0, md->title, 0, ypos, (short)width, 19, NULL, 0.0, 0.0, 0, 0, ""); - bt->flag= UI_TEXT_LEFT; - } - menudata_free(md); - - block->direction= UI_TOP; - - uiBoundsBlock(block, 3); - uiEndBlock(C, block); - - return block; } +#if 0 static void ui_warp_pointer(short x, short y) { /* XXX 2.50 which function to use for this? */ -#if 0 /* OSX has very poor mousewarp support, it sends events; this causes a menu being pressed immediately ... */ #ifndef __APPLE__ warp_pointer(x, y); #endif -#endif } +#endif /********************* Color Button ****************/ @@ -2158,406 +2105,115 @@ void uiBlockColorbandButtons(uiBlock *block, ColorBand *coba, rctf *butr, int ev } -/* ******************** PUPmenu ****************** */ - -static int pupmenu_set= 0; +/************************ Popup Menu Memory ****************************/ -void uiPupMenuSetActive(int val) +static int ui_popup_menu_hash(char *str) { - pupmenu_set= val; + return BLI_ghashutil_strhash(str); } -/* value== -1 read, otherwise set */ -static int pupmenu_memory(char *str, int value) +/* but == NULL read, otherwise set */ +uiBut *ui_popup_menu_memory(uiBlock *block, uiBut *but) { static char mem[256], first=1; - int val=0, nr=0; + int hash= block->puphash; if(first) { - memset(mem, 0, 256); + /* init */ + memset(mem, -1, sizeof(mem)); first= 0; } - while(str[nr]) { - val+= str[nr]; - nr++; - } - - if(value >= 0) mem[ val & 255 ]= value; - else return mem[ val & 255 ]; - - return 0; -} - -#define PUP_LABELH 6 - -typedef struct uiPupMenuInfo { - char *instr; - int mx, my; - int startx, starty; - int maxrow; -} uiPupMenuInfo; - -uiBlock *ui_block_func_PUPMENU(bContext *C, uiPopupBlockHandle *handle, void *arg_info) -{ - uiBlock *block; - uiPupMenuInfo *info; - int columns, rows, mousemove[2]= {0, 0}, mousewarp= 0; - int width, height, xmax, ymax, maxrow; - int a, startx, starty, endx, endy, x1, y1; - int lastselected; - MenuData *md; - - info= arg_info; - maxrow= info->maxrow; - height= 0; - - /* block stuff first, need to know the font */ - block= uiBeginBlock(C, handle->region, "menu", UI_EMBOSSP); - uiBlockSetFlag(block, UI_BLOCK_LOOP|UI_BLOCK_REDRAW|UI_BLOCK_RET_1|UI_BLOCK_NUMSELECT); - block->direction= UI_DOWN; - - md= decompose_menu_string(info->instr); - - rows= md->nitems; - if(rows<1) - rows= 1; - - columns= 1; - - /* size and location, title slightly bigger for bold */ - if(md->title) { - width= 2*strlen(md->title)+UI_GetStringWidth(md->title); - width /= columns; - } - else width= 0; - - for(a=0; a<md->nitems; a++) { - xmax= UI_GetStringWidth(md->items[a].str); - if(xmax>width) width= xmax; - - if(strcmp(md->items[a].str, "%l")==0) height+= PUP_LABELH; - else height+= MENU_BUTTON_HEIGHT; - } - - width+= 10; - if (width<50) width=50; - - wm_window_get_size(CTX_wm_window(C), &xmax, &ymax); - - /* set first item */ - lastselected= 0; - if(pupmenu_set) { - lastselected= pupmenu_set-1; - pupmenu_set= 0; - } - else if(md->nitems>1) { - lastselected= pupmenu_memory(info->instr, -1); - } - - startx= info->mx-(0.8*(width)); - starty= info->my-height+MENU_BUTTON_HEIGHT/2; - if(lastselected>=0 && lastselected<md->nitems) { - for(a=0; a<md->nitems; a++) { - if(a==lastselected) break; - if( strcmp(md->items[a].str, "%l")==0) starty+= PUP_LABELH; - else starty+=MENU_BUTTON_HEIGHT; - } - - //starty= info->my-height+MENU_BUTTON_HEIGHT/2+lastselected*MENU_BUTTON_HEIGHT; - } - - if(startx<10) { - startx= 10; - } - if(starty<10) { - mousemove[1]= 10-starty; - starty= 10; - } - - endx= startx+width*columns; - endy= starty+height; - if(endx>xmax) { - endx= xmax-10; - startx= endx-width*columns; - } - if(endy>ymax-20) { - mousemove[1]= ymax-endy-20; - endy= ymax-20; - starty= endy-height; - } - - if(mousemove[0] || mousemove[1]) { - ui_warp_pointer(info->mx+mousemove[0], info->my+mousemove[1]); - mousemove[0]= info->mx; - mousemove[1]= info->my; - mousewarp= 1; + if(but) { + /* set */ + mem[hash & 255 ]= BLI_findindex(&block->buttons, but); + return NULL; } - - /* here we go! */ - if(md->title) { - uiBut *bt; - char titlestr[256]; - - if(md->titleicon) { - width+= 20; - sprintf(titlestr, " %s", md->title); - uiDefIconTextBut(block, LABEL, 0, md->titleicon, titlestr, startx, (short)(starty+height), width, MENU_BUTTON_HEIGHT, NULL, 0.0, 0.0, 0, 0, ""); - } - else { - bt= uiDefBut(block, LABEL, 0, md->title, startx, (short)(starty+height), columns*width, MENU_BUTTON_HEIGHT, NULL, 0.0, 0.0, 0, 0, ""); - bt->flag= UI_TEXT_LEFT; - } - - //uiDefBut(block, SEPR, 0, "", startx, (short)(starty+height)-MENU_SEPR_HEIGHT, width, MENU_SEPR_HEIGHT, NULL, 0.0, 0.0, 0, 0, ""); + else { + /* get */ + return BLI_findlink(&block->buttons, mem[hash & 255]); } +} - x1= startx + width*((int)a/rows); - y1= starty + height - MENU_BUTTON_HEIGHT; // - MENU_SEPR_HEIGHT; - - for(a=0; a<md->nitems; a++) { - char *name= md->items[a].str; - int icon = md->items[a].icon; +/******************** Popup Menu with callback or string **********************/ - if(strcmp(name, "%l")==0) { - uiDefBut(block, SEPR, B_NOP, "", x1, y1, width, PUP_LABELH, NULL, 0, 0.0, 0, 0, ""); - y1 -= PUP_LABELH; - } - else if (icon) { - uiDefIconButF(block, BUTM, B_NOP, icon, x1, y1, width+16, MENU_BUTTON_HEIGHT-1, &handle->retvalue, (float) md->items[a].retval, 0.0, 0, 0, ""); - y1 -= MENU_BUTTON_HEIGHT; - } - else { - uiDefButF(block, BUTM, B_NOP, name, x1, y1, width, MENU_BUTTON_HEIGHT-1, &handle->retvalue, (float) md->items[a].retval, 0.0, 0, 0, ""); - y1 -= MENU_BUTTON_HEIGHT; - } - } - - uiBoundsBlock(block, 1); - uiEndBlock(C, block); - - menudata_free(md); +struct uiPopupMenu { + uiBlock *block; + uiLayout *layout; + uiBut *but; - /* XXX 2.5 need to store last selected */ -#if 0 - /* calculate last selected */ - if(event & ui_return_ok) { - lastselected= 0; - for(a=0; a<md->nitems; a++) { - if(val==md->items[a].retval) lastselected= a; - } - - pupmenu_memory(info->instr, lastselected); - } -#endif - - /* XXX 2.5 need to warp back */ -#if 0 - if(mousemove[1] && (event & ui_return_out)==0) - ui_warp_pointer(mousemove[0], mousemove[1]); - return val; -#endif + int mx, my, popup, slideout; + int startx, starty, maxrow; - return block; -} + uiMenuCreateFunc menu_func; + void *menu_arg; +}; -uiBlock *ui_block_func_PUPMENUCOL(bContext *C, uiPopupBlockHandle *handle, void *arg_info) +static uiBlock *ui_block_func_POPUP(bContext *C, uiPopupBlockHandle *handle, void *arg_pup) { uiBlock *block; - uiPupMenuInfo *info; - int columns, rows, mousemove[2]= {0, 0}, mousewarp; - int width, height, xmax, ymax, maxrow; - int a, startx, starty, endx, endy, x1, y1; - float fvalue; - MenuData *md; - - info= arg_info; - maxrow= info->maxrow; - height= 0; - - /* block stuff first, need to know the font */ - block= uiBeginBlock(C, handle->region, "menu", UI_EMBOSSP); - uiBlockSetFlag(block, UI_BLOCK_LOOP|UI_BLOCK_REDRAW|UI_BLOCK_RET_1|UI_BLOCK_NUMSELECT); - block->direction= UI_DOWN; - - md= decompose_menu_string(info->instr); - - /* columns and row calculation */ - columns= (md->nitems+maxrow)/maxrow; - if (columns<1) columns= 1; - - if(columns > 8) { - maxrow += 5; - columns= (md->nitems+maxrow)/maxrow; - } - - rows= (int) md->nitems/columns; - if (rows<1) rows= 1; - - while (rows*columns<(md->nitems+columns) ) rows++; - - /* size and location, title slightly bigger for bold */ - if(md->title) { - width= 2*strlen(md->title)+UI_GetStringWidth(md->title); - width /= columns; - } - else width= 0; - - for(a=0; a<md->nitems; a++) { - xmax= UI_GetStringWidth(md->items[a].str); - if(xmax>width) width= xmax; - } - - width+= 10; - if (width<50) width=50; - - height= rows*MENU_BUTTON_HEIGHT; - if (md->title) height+= MENU_BUTTON_HEIGHT; - - wm_window_get_size(CTX_wm_window(C), &xmax, &ymax); - - /* find active item */ - fvalue= handle->retvalue; - for(a=0; a<md->nitems; a++) { - if( md->items[a].retval== (int)fvalue ) break; - } - - /* no active item? */ - if(a==md->nitems) { - if(md->title) a= -1; - else a= 0; - } - - if(a>0) - startx = info->mx-width/2 - ((int)(a)/rows)*width; - else - startx= info->mx-width/2; - starty = info->my-height + MENU_BUTTON_HEIGHT/2 + ((a)%rows)*MENU_BUTTON_HEIGHT; - - if (md->title) starty+= MENU_BUTTON_HEIGHT; - - if(startx<10) { - mousemove[0]= 10-startx; - startx= 10; - } - if(starty<10) { - mousemove[1]= 10-starty; - starty= 10; - } - - endx= startx+width*columns; - endy= starty+height; - - if(endx>xmax) { - mousemove[0]= xmax-endx-10; - endx= xmax-10; - startx= endx-width*columns; - } - if(endy>ymax) { - mousemove[1]= ymax-endy-10; - endy= ymax-10; - starty= endy-height; - } + uiBut *bt; + ScrArea *sa; + ARegion *ar; + uiPopupMenu *pup= arg_pup; + int offset, direction, minwidth, flip; - if(mousemove[0] || mousemove[1]) { - ui_warp_pointer(info->mx+mousemove[0], info->my+mousemove[1]); - mousemove[0]= info->mx; - mousemove[1]= info->my; - mousewarp= 1; + if(pup->menu_func) { + pup->block->handle= handle; + pup->menu_func(C, pup->layout, pup->menu_arg); + pup->block->handle= NULL; } - /* here we go! */ - if(md->title) { - uiBut *bt; + if(pup->but) { + /* minimum width to enforece */ + minwidth= pup->but->x2 - pup->but->x1; - if(md->titleicon) { + if(pup->but->type == PULLDOWN || pup->but->menu_create_func) { + direction= UI_DOWN; + flip= 1; } else { - bt= uiDefBut(block, LABEL, 0, md->title, startx, (short)(starty+rows*MENU_BUTTON_HEIGHT), columns*width, MENU_BUTTON_HEIGHT, NULL, 0.0, 0.0, 0, 0, ""); - bt->flag= UI_TEXT_LEFT; + direction= UI_TOP; + flip= 0; } } - - for(a=0; a<md->nitems; a++) { - char *name= md->items[a].str; - int icon = md->items[a].icon; - - x1= startx + width*((int)a/rows); - y1= starty - MENU_BUTTON_HEIGHT*(a%rows) + (rows-1)*MENU_BUTTON_HEIGHT; - - if(strcmp(name, "%l")==0) { - uiDefBut(block, SEPR, B_NOP, "", x1, y1, width, PUP_LABELH, NULL, 0, 0.0, 0, 0, ""); - y1 -= PUP_LABELH; - } - else if (icon) { - uiDefIconButF(block, BUTM, B_NOP, icon, x1, y1, width+16, MENU_BUTTON_HEIGHT-1, &handle->retvalue, (float) md->items[a].retval, 0.0, 0, 0, ""); - y1 -= MENU_BUTTON_HEIGHT; - } - else { - uiDefButF(block, BUTM, B_NOP, name, x1, y1, width, MENU_BUTTON_HEIGHT-1, &handle->retvalue, (float) md->items[a].retval, 0.0, 0, 0, ""); - y1 -= MENU_BUTTON_HEIGHT; - } + else { + minwidth= 50; + direction= UI_DOWN; + flip= 1; } - - uiBoundsBlock(block, 1); - uiEndBlock(C, block); - - menudata_free(md); - - /* XXX 2.5 need to warp back */ -#if 0 - if((event & UI_RETURN_OUT)==0) - ui_warp_pointer(mousemove[0], mousemove[1]); -#endif - - return block; -} -/************************** Menu Definitions ***************************/ - -/* prototype */ -static uiBlock *ui_block_func_MENU_ITEM(bContext *C, uiPopupBlockHandle *handle, void *arg_info); - -struct uiPopupMenu { - uiBlock *block; - uiLayout *layout; -}; - -typedef struct uiMenuInfo { - uiPopupMenu *pup; - int mx, my, popup, slideout; - int startx, starty; -} uiMenuInfo; - -/************************ Menu Definitions to uiBlocks ***********************/ - -static uiBlock *ui_block_func_MENU_ITEM(bContext *C, uiPopupBlockHandle *handle, void *arg_info) -{ - uiBlock *block; - uiMenuInfo *info= arg_info; - uiPopupMenu *pup; - ScrArea *sa; - ARegion *ar; - - pup= info->pup; block= pup->block; - /* block stuff first, need to know the font */ - uiBlockSetRegion(block, handle->region); - block->direction= UI_DOWN; + /* in some cases we create the block before the region, + so we set it delayed here if necessary */ + if(BLI_findindex(&handle->region->uiblocks, block) == -1) + uiBlockSetRegion(block, handle->region); + + block->direction= direction; uiBlockLayoutResolve(C, block, NULL, NULL); - if(info->popup) { + if(pup->popup) { uiBlockSetFlag(block, UI_BLOCK_LOOP|UI_BLOCK_REDRAW|UI_BLOCK_NUMSELECT|UI_BLOCK_RET_1); - uiBlockSetDirection(block, UI_DOWN); + uiBlockSetDirection(block, direction); + + /* offset the mouse position, possibly based on earlier selection */ + offset= 1.5*MENU_BUTTON_HEIGHT; - /* here we set an offset for the mouse position */ - uiMenuPopupBoundsBlock(block, 1, 0, 1.5*MENU_BUTTON_HEIGHT); + if(block->flag & UI_BLOCK_POPUP_MEMORY) { + bt= ui_popup_menu_memory(block, NULL); + + if(bt) + offset= -bt->y1 - 0.5f*MENU_BUTTON_HEIGHT; + } + + block->minbounds= minwidth; + uiMenuPopupBoundsBlock(block, 1, 20, offset); } else { /* for a header menu we set the direction automatic */ - if(!info->slideout) { + if(!pup->slideout && flip) { sa= CTX_wm_area(C); ar= CTX_wm_region(C); @@ -2569,59 +2225,77 @@ static uiBlock *ui_block_func_MENU_ITEM(bContext *C, uiPopupBlockHandle *handle, } } - uiTextBoundsBlock(block, 50); + block->minbounds= minwidth; + uiTextBoundsBlock(block, 40); } /* if menu slides out of other menu, override direction */ - if(info->slideout) + if(pup->slideout) uiBlockSetDirection(block, UI_RIGHT); uiEndBlock(C, block); - - return block; + + return pup->block; } -uiPopupBlockHandle *ui_popup_menu_create(bContext *C, ARegion *butregion, uiBut *but, uiMenuCreateFunc menu_func, void *arg) +uiPopupBlockHandle *ui_popup_menu_create(bContext *C, ARegion *butregion, uiBut *but, uiMenuCreateFunc menu_func, void *arg, char *str) { + wmWindow *window= CTX_wm_window(C); uiStyle *style= U.uistyles.first; uiPopupBlockHandle *handle; uiPopupMenu *pup; - uiMenuInfo info; pup= MEM_callocN(sizeof(uiPopupMenu), "menu dummy"); - pup->block= uiBeginBlock(C, NULL, "ui_popup_menu_create", UI_EMBOSSP); + pup->block= uiBeginBlock(C, NULL, "ui_button_menu_create", UI_EMBOSSP); pup->layout= uiBlockLayout(pup->block, UI_LAYOUT_VERTICAL, UI_LAYOUT_MENU, 0, 0, 200, 0, style); + pup->slideout= (but && (but->block->flag & UI_BLOCK_LOOP)); + pup->but= but; uiLayoutSetOperatorContext(pup->layout, WM_OP_INVOKE_REGION_WIN); - /* create in advance so we can let buttons point to retval already */ - pup->block->handle= MEM_callocN(sizeof(uiPopupBlockHandle), "uiPopupBlockHandle"); + if(!but) { + /* no button to start from, means we are a popup */ + pup->mx= window->eventstate->x; + pup->my= window->eventstate->y; + pup->popup= 1; + } - menu_func(C, pup->layout, arg); - - memset(&info, 0, sizeof(info)); - info.pup= pup; - info.slideout= (but && (but->block->flag & UI_BLOCK_LOOP)); + if(str) { + /* menu is created from a string */ + pup->menu_func= ui_block_func_MENUSTR; + pup->menu_arg= str; + } + else { + /* menu is created from a callback */ + pup->menu_func= menu_func; + pup->menu_arg= arg; + } - handle= ui_popup_block_create(C, butregion, but, NULL, ui_block_func_MENU_ITEM, &info); + handle= ui_popup_block_create(C, butregion, but, NULL, ui_block_func_POPUP, pup); + + if(!but) { + handle->popup= 1; + + UI_add_popup_handlers(C, &window->handlers, handle); + WM_event_add_mousemove(C); + } MEM_freeN(pup); return handle; } -/*************************** Menu Creating API **************************/ - - -/*************************** Popup Menu API **************************/ +/******************** Popup Menu API with begin and end ***********************/ /* only return handler, and set optional title */ uiPopupMenu *uiPupMenuBegin(bContext *C, const char *title, int icon) { uiStyle *style= U.uistyles.first; - uiPopupMenu *pup= MEM_callocN(sizeof(uiPopupMenu), "menu start"); + uiPopupMenu *pup= MEM_callocN(sizeof(uiPopupMenu), "popup menu"); uiBut *but; pup->block= uiBeginBlock(C, NULL, "uiPupMenuBegin", UI_EMBOSSP); + pup->block->flag |= UI_BLOCK_POPUP_MEMORY; + pup->block->puphash= ui_popup_menu_hash((char*)title); pup->layout= uiBlockLayout(pup->block, UI_LAYOUT_VERTICAL, UI_LAYOUT_MENU, 0, 0, 200, 0, style); uiLayoutSetOperatorContext(pup->layout, WM_OP_EXEC_REGION_WIN); @@ -2640,8 +2314,6 @@ uiPopupMenu *uiPupMenuBegin(bContext *C, const char *title, int icon) but= uiDefBut(pup->block, LABEL, 0, (char*)title, 0, 0, 200, MENU_BUTTON_HEIGHT, NULL, 0.0, 0.0, 0, 0, ""); but->flag= UI_TEXT_LEFT; } - - //uiDefBut(block, SEPR, 0, "", startx, (short)(starty+height)-MENU_SEPR_HEIGHT, width, MENU_SEPR_HEIGHT, NULL, 0.0, 0.0, 0, 0, ""); } return pup; @@ -2651,16 +2323,13 @@ uiPopupMenu *uiPupMenuBegin(bContext *C, const char *title, int icon) void uiPupMenuEnd(bContext *C, uiPopupMenu *pup) { wmWindow *window= CTX_wm_window(C); - uiMenuInfo info; uiPopupBlockHandle *menu; - memset(&info, 0, sizeof(info)); - info.popup= 1; - info.mx= window->eventstate->x; - info.my= window->eventstate->y; - info.pup= pup; + pup->popup= 1; + pup->mx= window->eventstate->x; + pup->my= window->eventstate->y; - menu= ui_popup_block_create(C, NULL, NULL, NULL, ui_block_func_MENU_ITEM, &info); + menu= ui_popup_block_create(C, NULL, NULL, NULL, ui_block_func_POPUP, pup); menu->popup= 1; UI_add_popup_handlers(C, &window->handlers, menu); @@ -2674,32 +2343,7 @@ uiLayout *uiPupMenuLayout(uiPopupMenu *pup) return pup->layout; } -/* ************** standard pupmenus *************** */ - -/* this one can called with operatortype name and operators */ -static uiPopupBlockHandle *ui_pup_menu(bContext *C, int maxrow, uiMenuHandleFunc func, void *arg, char *str, ...) -{ - wmWindow *window= CTX_wm_window(C); - uiPupMenuInfo info; - uiPopupBlockHandle *menu; - - memset(&info, 0, sizeof(info)); - info.mx= window->eventstate->x; - info.my= window->eventstate->y; - info.maxrow= maxrow; - info.instr= str; - - menu= ui_popup_block_create(C, NULL, NULL, NULL, ui_block_func_PUPMENU, &info); - menu->popup= 1; - - UI_add_popup_handlers(C, &window->handlers, menu); - WM_event_add_mousemove(C); - - menu->popup_func= func; - menu->popup_arg= arg; - - return menu; -} +/*************************** Standard Popup Menus ****************************/ static void operator_name_cb(bContext *C, void *arg, int retval) { @@ -2709,17 +2353,6 @@ static void operator_name_cb(bContext *C, void *arg, int retval) WM_operator_name_call(C, opname, WM_OP_EXEC_DEFAULT, NULL); } -static void vconfirm_opname(bContext *C, char *opname, char *title, char *itemfmt, va_list ap) -{ - char *s, buf[512]; - - s= buf; - if (title) s+= sprintf(s, "%s%%t|", title); - vsprintf(s, itemfmt, ap); - - ui_pup_menu(C, 0, operator_name_cb, opname, buf); -} - static void operator_cb(bContext *C, void *arg, int retval) { wmOperator *op= arg; @@ -2735,6 +2368,21 @@ static void confirm_cancel_operator(void *opv) WM_operator_free(opv); } +static void vconfirm_opname(bContext *C, char *opname, char *title, char *itemfmt, va_list ap) +{ + uiPopupBlockHandle *handle; + char *s, buf[512]; + + s= buf; + if (title) s+= sprintf(s, "%s%%t|", title); + vsprintf(s, itemfmt, ap); + + handle= ui_popup_menu_create(C, NULL, NULL, NULL, NULL, buf); + + handle->popup_func= operator_name_cb; + handle->popup_arg= opname; +} + static void confirm_operator(bContext *C, wmOperator *op, char *title, char *item) { uiPopupBlockHandle *handle; @@ -2743,11 +2391,13 @@ static void confirm_operator(bContext *C, wmOperator *op, char *title, char *ite s= buf; if (title) s+= sprintf(s, "%s%%t|%s", title, item); - handle= ui_pup_menu(C, 0, operator_cb, op, buf); + handle= ui_popup_menu_create(C, NULL, NULL, NULL, NULL, buf); + + handle->popup_func= operator_cb; + handle->popup_arg= op; handle->cancel_func= confirm_cancel_operator; } - void uiPupMenuOkee(bContext *C, char *opname, char *str, ...) { va_list ap; @@ -2760,7 +2410,6 @@ void uiPupMenuOkee(bContext *C, char *opname, char *str, ...) va_end(ap); } - void uiPupMenuSaveOver(bContext *C, wmOperator *op, char *filename) { size_t len= strlen(filename); @@ -2776,7 +2425,7 @@ void uiPupMenuSaveOver(bContext *C, wmOperator *op, char *filename) if(BLI_exists(filename)==0) operator_cb(C, op, 1); else - confirm_operator(C, op, "Save over", filename); + confirm_operator(C, op, "Save Over", filename); } void uiPupMenuNotice(bContext *C, char *str, ...) @@ -2826,7 +2475,7 @@ void uiPupMenuReports(bContext *C, ReportList *reports) } str= BLI_dynstr_get_cstring(ds); - ui_pup_menu(C, 0, NULL, NULL, str); + ui_popup_menu_create(C, NULL, NULL, NULL, NULL, str); MEM_freeN(str); BLI_dynstr_free(ds); @@ -2870,3 +2519,4 @@ void uiPupBlockOperator(bContext *C, uiBlockCreateFunc func, wmOperator *op, int UI_add_popup_handlers(C, &window->handlers, handle); WM_event_add_mousemove(C); } + diff --git a/source/blender/editors/interface/interface_style.c b/source/blender/editors/interface/interface_style.c index 67ee29a1d3c..cb9216ec1c5 100644 --- a/source/blender/editors/interface/interface_style.c +++ b/source/blender/editors/interface/interface_style.c @@ -248,9 +248,6 @@ void uiStyleInit(void) BLF_size(11, U.dpi); BLF_size(12, U.dpi); BLF_size(14, U.dpi); - - if (!(U.transopts & USER_USETEXTUREFONT)) - BLF_mode(BLF_MODE_BITMAP); } } diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c index edf01f4da2c..6aa5f5efc41 100644 --- a/source/blender/editors/interface/interface_templates.c +++ b/source/blender/editors/interface/interface_templates.c @@ -56,12 +56,13 @@ void ui_template_fix_linking() /********************** Header Template *************************/ -void uiTemplateHeader(uiLayout *layout, bContext *C) +void uiTemplateHeader(uiLayout *layout, bContext *C, int menus) { uiBlock *block; block= uiLayoutFreeBlock(layout); - ED_area_header_standardbuttons(C, block, 0); + if(menus) ED_area_header_standardbuttons(C, block, 0); + else ED_area_header_switchbutton(C, block, 0); } /********************** Search Callbacks *************************/ @@ -236,11 +237,11 @@ static void template_ID(bContext *C, uiBlock *block, TemplateID *template, Struc int w= idptr.data?UI_UNIT_X:UI_UNIT_X*6; if(newop) { - but= uiDefIconTextButO(block, BUT, newop, WM_OP_EXEC_REGION_WIN, ICON_ZOOMIN, "Add New", 0, 0, w, UI_UNIT_Y, NULL); + but= uiDefIconTextButO(block, BUT, newop, WM_OP_INVOKE_REGION_WIN, ICON_ZOOMIN, (idptr.data)? "": "Add New", 0, 0, w, UI_UNIT_Y, NULL); uiButSetNFunc(but, template_id_cb, MEM_dupallocN(template), SET_INT_IN_POINTER(UI_ID_ADD_NEW)); } else { - but= uiDefIconTextBut(block, BUT, 0, ICON_ZOOMIN, "Add New", 0, 0, w, UI_UNIT_Y, NULL, 0, 0, 0, 0, NULL); + but= uiDefIconTextBut(block, BUT, 0, ICON_ZOOMIN, (idptr.data)? "": "Add New", 0, 0, w, UI_UNIT_Y, NULL, 0, 0, 0, 0, NULL); uiButSetNFunc(but, template_id_cb, MEM_dupallocN(template), SET_INT_IN_POINTER(UI_ID_ADD_NEW)); } } @@ -248,7 +249,7 @@ static void template_ID(bContext *C, uiBlock *block, TemplateID *template, Struc /* delete button */ if(idptr.data && (flag & UI_ID_DELETE)) { if(unlinkop) { - but= uiDefIconButO(block, BUT, unlinkop, WM_OP_EXEC_REGION_WIN, ICON_X, 0, 0, UI_UNIT_X, UI_UNIT_Y, NULL); + but= uiDefIconButO(block, BUT, unlinkop, WM_OP_INVOKE_REGION_WIN, ICON_X, 0, 0, UI_UNIT_X, UI_UNIT_Y, NULL); } else { but= uiDefIconBut(block, BUT, 0, ICON_X, 0, 0, UI_UNIT_X, UI_UNIT_Y, NULL, 0, 0, 0, 0, NULL); @@ -427,15 +428,15 @@ static uiLayout *draw_modifier(uiLayout *layout, Object *ob, ModifierData *md, i else { /* real modifier */ uiBlockBeginAlign(block); - uiItemR(row, "", 0, &ptr, "name", 0, 0, 0); + uiItemR(row, "", 0, &ptr, "name", 0); /* Softbody not allowed in this situation, enforce! */ if(((md->type!=eModifierType_Softbody && md->type!=eModifierType_Collision) || !(ob->pd && ob->pd->deflect)) && (md->type!=eModifierType_Surface)) { - uiItemR(row, "", ICON_SCENE, &ptr, "render", 0, 0, 0); - uiItemR(row, "", ICON_RESTRICT_VIEW_OFF, &ptr, "realtime", 0, 0, 0); + uiItemR(row, "", ICON_SCENE, &ptr, "render", 0); + uiItemR(row, "", ICON_RESTRICT_VIEW_OFF, &ptr, "realtime", 0); if(mti->flags & eModifierTypeFlag_SupportsEditmode) - uiItemR(row, "", ICON_EDITMODE_HLT, &ptr, "editmode", 0, 0, 0); + uiItemR(row, "", ICON_EDITMODE_HLT, &ptr, "editmode", 0); } @@ -483,7 +484,7 @@ static uiLayout *draw_modifier(uiLayout *layout, Object *ob, ModifierData *md, i if(md->type==eModifierType_ParticleSystem) { ParticleSystem *psys= ((ParticleSystemModifierData *)md)->psys; - if(!(G.f & G_PARTICLEEDIT)) + if(!(ob->mode & OB_MODE_PARTICLE_EDIT)) if(ELEM3(psys->part->ren_as, PART_DRAW_PATH, PART_DRAW_GR, PART_DRAW_OB) && psys->pathcache) uiItemO(row, "Convert", 0, "OBJECT_OT_modifier_convert"); } @@ -628,7 +629,7 @@ static void verify_constraint_name_func (bContext *C, void *con_v, void *name_v) /* some commonly used macros in the constraints drawing code */ #define is_armature_target(target) (target && target->type==OB_ARMATURE) -#define is_armature_owner(ob) ((ob->type == OB_ARMATURE) && (ob->flag & OB_POSEMODE)) +#define is_armature_owner(ob) ((ob->type == OB_ARMATURE) && (ob->mode & OB_MODE_POSE)) #define is_geom_target(target) (target && (ELEM(target->type, OB_MESH, OB_LATTICE)) ) /* Helper function for draw constraint - draws constraint space stuff @@ -911,82 +912,7 @@ static uiLayout *draw_constraint(uiLayout *layout, Object *ob, bConstraint *con) draw_constraint_spaceselect(block, con, xco, yco-(73+theight), is_armature_owner(ob), -1); } break; -#endif /* DISABLE_PYTHON */ - - /*case CONSTRAINT_TYPE_RIGIDBODYJOINT: - { - if (data->type==CONSTRAINT_RB_GENERIC6DOF) { - // Draw Pairs of LimitToggle+LimitValue - uiBlockBeginAlign(block); - uiDefButBitS(block, TOG, 1, B_CONSTRAINT_TEST, "LinMinX", xco, yco-offsetY, togButWidth, 18, &data->flag, 0, 24, 0, 0, "Use minimum x limit"); - uiDefButF(block, NUM, B_CONSTRAINT_TEST, "", xco+togButWidth, yco-offsetY, (textButWidth-5), 18, &(data->minLimit[0]), -extremeLin, extremeLin, 0.1,0.5,"min x limit"); - uiBlockEndAlign(block); - - uiBlockBeginAlign(block); - uiDefButBitS(block, TOG, 1, B_CONSTRAINT_TEST, "LinMaxX", xco+(width-(textButWidth-5)-togButWidth), yco-offsetY, togButWidth, 18, &data->flag, 0, 24, 0, 0, "Use maximum x limit"); - uiDefButF(block, NUM, B_CONSTRAINT_TEST, "", xco+(width-textButWidth-5), yco-offsetY, (textButWidth), 18, &(data->maxLimit[0]), -extremeLin, extremeLin, 0.1,0.5,"max x limit"); - uiBlockEndAlign(block); - - offsetY += 20; - uiBlockBeginAlign(block); - uiDefButBitS(block, TOG, 2, B_CONSTRAINT_TEST, "LinMinY", xco, yco-offsetY, togButWidth, 18, &data->flag, 0, 24, 0, 0, "Use minimum y limit"); - uiDefButF(block, NUM, B_CONSTRAINT_TEST, "", xco+togButWidth, yco-offsetY, (textButWidth-5), 18, &(data->minLimit[1]), -extremeLin, extremeLin, 0.1,0.5,"min y limit"); - uiBlockEndAlign(block); - - uiBlockBeginAlign(block); - uiDefButBitS(block, TOG, 2, B_CONSTRAINT_TEST, "LinMaxY", xco+(width-(textButWidth-5)-togButWidth), yco-offsetY, togButWidth, 18, &data->flag, 0, 24, 0, 0, "Use maximum y limit"); - uiDefButF(block, NUM, B_CONSTRAINT_TEST, "", xco+(width-textButWidth-5), yco-offsetY, (textButWidth), 18, &(data->maxLimit[1]), -extremeLin, extremeLin, 0.1,0.5,"max y limit"); - uiBlockEndAlign(block); - - offsetY += 20; - uiBlockBeginAlign(block); - uiDefButBitS(block, TOG, 4, B_CONSTRAINT_TEST, "LinMinZ", xco, yco-offsetY, togButWidth, 18, &data->flag, 0, 24, 0, 0, "Use minimum z limit"); - uiDefButF(block, NUM, B_CONSTRAINT_TEST, "", xco+togButWidth, yco-offsetY, (textButWidth-5), 18, &(data->minLimit[2]), -extremeLin, extremeLin, 0.1,0.5,"min z limit"); - uiBlockEndAlign(block); - - uiBlockBeginAlign(block); - uiDefButBitS(block, TOG, 4, B_CONSTRAINT_TEST, "LinMaxZ", xco+(width-(textButWidth-5)-togButWidth), yco-offsetY, togButWidth, 18, &data->flag, 0, 24, 0, 0, "Use maximum z limit"); - uiDefButF(block, NUM, B_CONSTRAINT_TEST, "", xco+(width-textButWidth-5), yco-offsetY, (textButWidth), 18, &(data->maxLimit[2]), -extremeLin, extremeLin, 0.1,0.5,"max z limit"); - uiBlockEndAlign(block); - offsetY += 20; - } - if ((data->type==CONSTRAINT_RB_GENERIC6DOF) || (data->type==CONSTRAINT_RB_CONETWIST)) { - // Draw Pairs of LimitToggle+LimitValue / - uiBlockBeginAlign(block); - uiDefButBitS(block, TOG, 8, B_CONSTRAINT_TEST, "AngMinX", xco, yco-offsetY, togButWidth, 18, &data->flag, 0, 24, 0, 0, "Use minimum x limit"); - uiDefButF(block, NUM, B_CONSTRAINT_TEST, "", xco+togButWidth, yco-offsetY, (textButWidth-5), 18, &(data->minLimit[3]), -extremeAngX, extremeAngX, 0.1,0.5,"min x limit"); - uiBlockEndAlign(block); - uiBlockBeginAlign(block); - uiDefButBitS(block, TOG, 8, B_CONSTRAINT_TEST, "AngMaxX", xco+(width-(textButWidth-5)-togButWidth), yco-offsetY, togButWidth, 18, &data->flag, 0, 24, 0, 0, "Use maximum x limit"); - uiDefButF(block, NUM, B_CONSTRAINT_TEST, "", xco+(width-textButWidth-5), yco-offsetY, (textButWidth), 18, &(data->maxLimit[3]), -extremeAngX, extremeAngX, 0.1,0.5,"max x limit"); - uiBlockEndAlign(block); - - offsetY += 20; - uiBlockBeginAlign(block); - uiDefButBitS(block, TOG, 16, B_CONSTRAINT_TEST, "AngMinY", xco, yco-offsetY, togButWidth, 18, &data->flag, 0, 24, 0, 0, "Use minimum y limit"); - uiDefButF(block, NUM, B_CONSTRAINT_TEST, "", xco+togButWidth, yco-offsetY, (textButWidth-5), 18, &(data->minLimit[4]), -extremeAngY, extremeAngY, 0.1,0.5,"min y limit"); - uiBlockEndAlign(block); - - uiBlockBeginAlign(block); - uiDefButBitS(block, TOG, 16, B_CONSTRAINT_TEST, "AngMaxY", xco+(width-(textButWidth-5)-togButWidth), yco-offsetY, togButWidth, 18, &data->flag, 0, 24, 0, 0, "Use maximum y limit"); - uiDefButF(block, NUM, B_CONSTRAINT_TEST, "", xco+(width-textButWidth-5), yco-offsetY, (textButWidth), 18, &(data->maxLimit[4]), -extremeAngY, extremeAngY, 0.1,0.5,"max y limit"); - uiBlockEndAlign(block); - - offsetY += 20; - uiBlockBeginAlign(block); - uiDefButBitS(block, TOG, 32, B_CONSTRAINT_TEST, "AngMinZ", xco, yco-offsetY, togButWidth, 18, &data->flag, 0, 24, 0, 0, "Use minimum z limit"); - uiDefButF(block, NUM, B_CONSTRAINT_TEST, "", xco+togButWidth, yco-offsetY, (textButWidth-5), 18, &(data->minLimit[5]), -extremeAngZ, extremeAngZ, 0.1,0.5,"min z limit"); - uiBlockEndAlign(block); - - uiBlockBeginAlign(block); - uiDefButBitS(block, TOG, 32, B_CONSTRAINT_TEST, "AngMaxZ", xco+(width-(textButWidth-5)-togButWidth), yco-offsetY, togButWidth, 18, &data->flag, 0, 24, 0, 0, "Use maximum z limit"); - uiDefButF(block, NUM, B_CONSTRAINT_TEST, "", xco+(width-textButWidth-5), yco-offsetY, (textButWidth), 18, &(data->maxLimit[5]), -extremeAngZ, extremeAngZ, 0.1,0.5,"max z limit"); - uiBlockEndAlign(block); - } - - } - break; - */ +#endif case CONSTRAINT_TYPE_NULL: { @@ -1162,7 +1088,7 @@ static void do_preview_buttons(bContext *C, void *arg, int event) } } -void uiTemplatePreview(uiLayout *layout, ID *id, ID *parent) +void uiTemplatePreview(uiLayout *layout, ID *id, ID *parent, MTex *slot) { uiLayout *row, *col; uiBlock *block; @@ -1203,7 +1129,7 @@ void uiTemplatePreview(uiLayout *layout, ID *id, ID *parent) /* add preview */ uiDefBut(block, BUT_EXTRA, 0, "", 0, 0, UI_UNIT_X*6, UI_UNIT_Y*6, pid, 0.0, 0.0, 0, 0, ""); - uiBlockSetDrawExtraFunc(block, ED_preview_draw, pparent); + uiBlockSetDrawExtraFunc(block, ED_preview_draw, pparent, slot); uiBlockSetHandleFunc(block, do_preview_buttons, NULL); /* add buttons */ @@ -1257,17 +1183,21 @@ void uiTemplateColorRamp(uiLayout *layout, ColorBand *coba, int expand) #include "DNA_color_types.h" -void uiTemplateCurveMapping(uiLayout *layout, CurveMapping *cumap, int type) +void uiTemplateCurveMapping(uiLayout *layout, CurveMapping *cumap, int type, int compact) { - uiBlock *block; rctf rect; if(cumap) { - rect.xmin= 0; rect.xmax= 200; - rect.ymin= 0; rect.ymax= 190; + if(compact) { + rect.xmin= 0; rect.xmax= 150; + rect.ymin= 0; rect.ymax= 140; + } + else { + rect.xmin= 0; rect.xmax= 200; + rect.ymin= 0; rect.ymax= 190; + } - block= uiLayoutFreeBlock(layout); - curvemap_buttons(block, cumap, type, 0, 0, &rect); + curvemap_layout(layout, cumap, type, 0, 0, &rect); } } @@ -1294,9 +1224,9 @@ void uiTemplateTriColorSet(uiLayout *layout, PointerRNA *ptr, char *propname) /* nselected, selected, active color swatches */ csPtr= RNA_property_pointer_get(ptr, prop); - uiItemR(row, "", 0, &csPtr, "normal", 0, 0, 0); - uiItemR(row, "", 0, &csPtr, "selected", 0, 0, 0); - uiItemR(row, "", 0, &csPtr, "active", 0, 0, 0); + uiItemR(row, "", 0, &csPtr, "normal", 0); + uiItemR(row, "", 0, &csPtr, "selected", 0); + uiItemR(row, "", 0, &csPtr, "active", 0); } /********************* Layer Buttons Template ************************/ @@ -1328,7 +1258,7 @@ void uiTemplateLayers(uiLayout *layout, PointerRNA *ptr, char *propname) * the 'remainder' is added to this, as it will be ok to have first row slightly wider if need be * - for now, only split into groups if if group will have at least 5 items */ - layers= RNA_property_array_length(prop); + layers= RNA_property_array_length(ptr, prop); cols= (layers / 2) + (layers % 2); groups= ((cols / 2) < 5) ? (1) : (cols / 2); @@ -1348,7 +1278,7 @@ void uiTemplateLayers(uiLayout *layout, PointerRNA *ptr, char *propname) /* add layers as toggle buts */ for (col= 0; (col < cols) && (layer < layers); col++, layer++) { int icon=0; // XXX - add some way of setting this... - uiItemFullR(uRow, "", icon, ptr, prop, layer, 0, 0, 0, 1); + uiItemFullR(uRow, "", icon, ptr, prop, layer, 0, UI_ITEM_R_TOGGLE); } } } @@ -1388,7 +1318,7 @@ ListBase uiTemplateList(uiLayout *layout, bContext *C, PointerRNA *ptr, char *pr Panel *pa; ListBase lb, *itemlb; char *name, str[32]; - int icon=0, i= 0, activei= 0, len, items, found, min, max; + int icon=0, i= 0, activei= 0, len= 0, items, found, min, max; lb.first= lb.last= NULL; @@ -1524,7 +1454,8 @@ ListBase uiTemplateList(uiLayout *layout, bContext *C, PointerRNA *ptr, char *pr /* init numbers */ RNA_property_int_range(activeptr, activeprop, &min, &max); - len= max - min + 1; + if(prop) + len= RNA_property_collection_length(ptr, prop); items= CLAMPIS(len, rows, 5); pa->list_scroll= MIN2(pa->list_scroll, len-items); @@ -1650,7 +1581,7 @@ static void do_running_jobs(bContext *C, void *arg, int event) WM_jobs_stop(CTX_wm_manager(C), CTX_wm_screen(C)); break; case B_STOPANIM: - ED_screen_animation_timer(C, 0, 0); + WM_operator_name_call(C, "SCREEN_OT_animation_play", WM_OP_INVOKE_SCREEN, NULL); break; } } diff --git a/source/blender/editors/interface/interface_utils.c b/source/blender/editors/interface/interface_utils.c index 8ff9e857407..5b44f6544d1 100644 --- a/source/blender/editors/interface/interface_utils.c +++ b/source/blender/editors/interface/interface_utils.c @@ -72,7 +72,7 @@ uiBut *uiDefAutoButR(uiBlock *block, PointerRNA *ptr, PropertyRNA *prop, int ind { uiBut *but=NULL; const char *propname= RNA_property_identifier(prop); - int arraylen= RNA_property_array_length(prop); + int arraylen= RNA_property_array_length(ptr, prop); switch(RNA_property_type(prop)) { case PROP_BOOLEAN: { @@ -81,7 +81,7 @@ uiBut *uiDefAutoButR(uiBlock *block, PointerRNA *ptr, PropertyRNA *prop, int ind if(arraylen && index == -1) return NULL; - length= RNA_property_array_length(prop); + length= RNA_property_array_length(ptr, prop); if(length) value= RNA_property_boolean_get_index(ptr, prop, index); @@ -152,8 +152,6 @@ void uiDefAutoButsRNA(const bContext *C, uiLayout *layout, PointerRNA *ptr, int uiLayout *split, *col; char *name; - uiItemL(layout, (char*)RNA_struct_ui_name(ptr->type), 0); - RNA_STRUCT_BEGIN(ptr, prop) { if(strcmp(RNA_property_identifier(prop), "rna_type") == 0) continue; @@ -177,7 +175,7 @@ void uiDefAutoButsRNA(const bContext *C, uiLayout *layout, PointerRNA *ptr, int if(strcmp(name, "Axis")==0) { uiDefButR(uiLayoutGetBlock(col), BUT_NORMAL, 0, name, 0, 0, 100, 100, ptr, "axis", -1, 0, 0, -1, -1, NULL); } - else uiItemFullR(col, "", 0, ptr, prop, -1, 0, 0, 0, 0); + else uiItemFullR(col, "", 0, ptr, prop, -1, 0, 0); } RNA_STRUCT_END; } @@ -446,6 +444,20 @@ int uiDefIDPoinButs(uiBlock *block, Main *bmain, ID *parid, ID *id, int id_code, uiBlockClearButLock(block); } + /* 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); + } + /* delete button */ if(events & UI_ID_DELETE) { uiBlockSetButLock(block, (events & UI_ID_PIN) && *pin_p, "Can't unlink pinned data"); @@ -945,6 +957,72 @@ void curvemap_buttons(uiBlock *block, CurveMapping *cumap, char labeltype, short cumap, 0.0f, 1.0f, 0, 0, ""); } +/* 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, ""); +} + + #define B_BANDCOL 1 static int vergcband(const void *a1, const void *a2) diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c index eed4425b7ad..f0085f71373 100644 --- a/source/blender/editors/interface/interface_widgets.c +++ b/source/blender/editors/interface/interface_widgets.c @@ -835,9 +835,11 @@ static void widget_draw_text(uiFontStyle *fstyle, uiWidgetColors *wcol, uiBut *b // else transopts= ui_translate_buttons(); /* cut string in 2 parts - only for menu entries */ - if(ELEM5(but->type, SLI, NUM, TEX, NUMSLI, NUMABS)==0) { - cpoin= strchr(but->drawstr, '|'); - if(cpoin) *cpoin= 0; + if((but->block->flag & UI_BLOCK_LOOP)) { + if(ELEM5(but->type, SLI, NUM, TEX, NUMSLI, NUMABS)==0) { + cpoin= strchr(but->drawstr, '|'); + if(cpoin) *cpoin= 0; + } } glColor3ubv((unsigned char*)wcol->text); @@ -889,7 +891,7 @@ static void widget_draw_text_icon(uiFontStyle *fstyle, uiWidgetColors *wcol, uiB rect->xmin += UI_icon_get_width(but->icon+but->iconadd); if(but->editstr || (but->flag & UI_TEXT_LEFT)) - rect->xmin += 10; + rect->xmin += 5; } else if((but->flag & UI_TEXT_LEFT)) rect->xmin += 5; @@ -1083,7 +1085,7 @@ static struct uiWidgetColors wcol_tool= { {255, 255, 255, 255}, 1, - 25, -25 + 15, -15 }; static struct uiWidgetColors wcol_box= { @@ -1895,7 +1897,7 @@ static void widget_swatch(uiBut *but, uiWidgetColors *wcol, rcti *rect, int stat widget_init(&wtb); /* half rounded */ - round_box_edges(&wtb, roundboxalign, rect, 4.0f); + round_box_edges(&wtb, roundboxalign, rect, 5.0f); ui_get_but_vectorf(but, col); wcol->inner[0]= FTOCHAR(col[0]); @@ -1914,7 +1916,7 @@ static void widget_textbut(uiWidgetColors *wcol, rcti *rect, int state, int roun widget_init(&wtb); /* half rounded */ - round_box_edges(&wtb, roundboxalign, rect, 5.0f); + round_box_edges(&wtb, roundboxalign, rect, 4.0f); widgetbase_draw(&wtb, wcol); @@ -1944,12 +1946,12 @@ static void widget_pulldownbut(uiWidgetColors *wcol, rcti *rect, int state, int { if(state & UI_ACTIVE) { uiWidgetBase wtb; - float rad= 0.5f*(rect->ymax - rect->ymin); + float rad= 0.5f*(rect->ymax - rect->ymin); // 4.0f widget_init(&wtb); - /* fully rounded */ - round_box_edges(&wtb, roundboxalign, rect, rad); + /* half rounded */ + round_box_edges(&wtb, 15, rect, rad); widgetbase_draw(&wtb, wcol); } @@ -2043,11 +2045,11 @@ static void widget_but(uiWidgetColors *wcol, rcti *rect, int state, int roundbox static void widget_roundbut(uiWidgetColors *wcol, rcti *rect, int state, int roundboxalign) { uiWidgetBase wtb; - float rad= 0.5f*(rect->ymax - rect->ymin); + float rad= 5.0f; //0.5f*(rect->ymax - rect->ymin); widget_init(&wtb); - /* fully rounded */ + /* half rounded */ round_box_edges(&wtb, roundboxalign, rect, rad); widgetbase_draw(&wtb, wcol); @@ -2065,7 +2067,7 @@ static void widget_draw_extra_mask(const bContext *C, uiBut *but, uiWidgetType * if(but->block->drawextra) { /* note: drawextra can change rect +1 or -1, to match round errors of existing previews */ - but->block->drawextra(C, but->poin, but->block->drawextra_arg, rect); + but->block->drawextra(C, but->poin, but->block->drawextra_arg1, but->block->drawextra_arg2, rect); /* make mask to draw over image */ UI_GetThemeColor3ubv(TH_BACK, col); diff --git a/source/blender/editors/interface/resources.c b/source/blender/editors/interface/resources.c index 297e22610a6..8aaede7515a 100644 --- a/source/blender/editors/interface/resources.c +++ b/source/blender/editors/interface/resources.c @@ -150,6 +150,9 @@ char *UI_ThemeGetColorPtr(bTheme *btheme, int spacetype, int colorid) case SPACE_INFO: ts= &btheme->tinfo; break; + case SPACE_USERPREF: + ts= &btheme->tuserpref; + break; case SPACE_TIME: ts= &btheme->ttime; break; @@ -402,6 +405,7 @@ static void ui_theme_init_new(bTheme *btheme) ui_theme_init_new_do(&btheme->ttime); ui_theme_init_new_do(&btheme->tnode); ui_theme_init_new_do(&btheme->tlogic); + ui_theme_init_new_do(&btheme->tuserpref); } @@ -441,6 +445,7 @@ void ui_theme_init_userdef(void) SETCOL(btheme->tv3d.text_hi, 255, 255, 255, 255); SETCOLF(btheme->tv3d.header, 0.45, 0.45, 0.45, 1.0); + SETCOLF(btheme->tv3d.button, 0.45, 0.45, 0.45, 1.0); SETCOL(btheme->tv3d.panel, 165, 165, 165, 127); SETCOL(btheme->tv3d.shade1, 160, 160, 160, 100); @@ -583,6 +588,10 @@ void ui_theme_init_userdef(void) btheme->tinfo= btheme->tv3d; SETCOLF(btheme->tinfo.back, 0.45, 0.45, 0.45, 1.0); + /* space user preferences */ + btheme->tuserpref= btheme->tv3d; + SETCOLF(btheme->tuserpref.back, 0.45, 0.45, 0.45, 1.0); + /* space sound */ btheme->tsnd= btheme->tv3d; SETCOLF(btheme->tsnd.back, 0.45, 0.45, 0.45, 1.0); @@ -1233,6 +1242,7 @@ void init_userdef_do_versions(void) } SETCOLF(btheme->tinfo.back, 0.45, 0.45, 0.45, 1.0); + SETCOLF(btheme->tuserpref.back, 0.45, 0.45, 0.45, 1.0); } } diff --git a/source/blender/editors/mesh/bmesh_select.c b/source/blender/editors/mesh/bmesh_select.c index cd14b5c1e33..8eeb209ad63 100644 --- a/source/blender/editors/mesh/bmesh_select.c +++ b/source/blender/editors/mesh/bmesh_select.c @@ -245,7 +245,7 @@ int EDBM_mask_init_backbuf_border(ViewContext *vc, short mcords[][2], short tot, /* method in use for face selecting too */ if(vc->obedit==NULL) { - if(FACESEL_PAINT_TEST); + if(paint_facesel_test(vc->obact)); else return 0; } else if(vc->v3d->drawtype<OB_SOLID || (vc->v3d->flag & V3D_ZBUF_SELECT)==0) return 0; @@ -300,7 +300,7 @@ int EDBM_init_backbuf_circle(ViewContext *vc, short xs, short ys, short rads) /* method in use for face selecting too */ if(vc->obedit==NULL) { - if(FACESEL_PAINT_TEST); + if(paint_facesel_test(vc->obact)); else return 0; } else if(vc->v3d->drawtype<OB_SOLID || (vc->v3d->flag & V3D_ZBUF_SELECT)==0) return 0; @@ -1163,6 +1163,7 @@ void MESH_OT_select_similar(wmOperatorType *ot) ot->invoke= WM_menu_invoke; ot->exec= select_similar_exec; ot->poll= ED_operator_editmesh; + ot->description= "Select similar vertices, edges or faces by property types."; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; @@ -1406,6 +1407,7 @@ void MESH_OT_loop_multi_select(wmOperatorType *ot) /* api callbacks */ ot->exec= loop_multiselect; ot->poll= ED_operator_editmesh; + ot->description= "Select a loop of connected edges by connection type."; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; @@ -1484,6 +1486,7 @@ void MESH_OT_loop_select(wmOperatorType *ot) /* api callbacks */ ot->invoke= mesh_select_loop_invoke; ot->poll= ED_operator_editmesh; + ot->description= "Select a loop of connected edges."; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; @@ -1585,6 +1588,7 @@ void MESH_OT_select_shortest_path(wmOperatorType *ot) /* api callbacks */ ot->invoke= mesh_shortest_path_select_invoke; ot->poll= ED_operator_editmesh; + ot->description= "Select shortest path between two selections."; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; @@ -1705,9 +1709,9 @@ void EDBM_selectmode_set(BMEditMesh *em) EDBM_strip_selections(em); /*strip BMEditSelections from em->selected that are not relevant to new mode*/ if(em->selectmode & SCE_SELECT_VERTEX) { - BMIter iter; + /*BMIter iter; - /*eed = BMIter_New(&iter, em->bm, BM_EDGES_OF_MESH, NULL); + eed = BMIter_New(&iter, em->bm, BM_EDGES_OF_MESH, NULL); for ( ; eed; eed=BMIter_Step(&iter)) BM_Select(em->bm, eed, 0); efa = BMIter_New(&iter, em->bm, BM_FACES_OF_MESH, NULL); @@ -1847,6 +1851,7 @@ void MESH_OT_select_inverse(wmOperatorType *ot) /* identifiers */ ot->name= "Select Inverse"; ot->idname= "MESH_OT_select_inverse"; + ot->description= "Select inverse of (un)selected vertices, edges or faces."; /* api callbacks */ ot->exec= select_inverse_mesh_exec; @@ -1928,6 +1933,7 @@ void MESH_OT_select_linked_pick(wmOperatorType *ot) /* api callbacks */ ot->invoke= select_linked_pick_invoke; ot->poll= ED_operator_editmesh; + ot->description= "select/deselect all vertices linked to the edge under the mouse cursor."; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; @@ -1983,6 +1989,7 @@ void MESH_OT_select_linked(wmOperatorType *ot) /* api callbacks */ ot->exec= select_linked_exec; ot->poll= ED_operator_editmesh; + ot->description= "Select all vertices linked to the active mesh."; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; @@ -2019,6 +2026,7 @@ void MESH_OT_select_more(wmOperatorType *ot) /* identifiers */ ot->name= "Select More"; ot->idname= "MESH_OT_select_more"; + ot->description= "Select more vertices, edges or faces connected to initial selection."; /* api callbacks */ ot->exec= select_more; @@ -2055,6 +2063,7 @@ void MESH_OT_select_less(wmOperatorType *ot) /* identifiers */ ot->name= "Select Less"; ot->idname= "MESH_OT_select_less"; + ot->description= "Deselect vertices, edges or faces at the boundary of each selection region."; /* api callbacks */ ot->exec= select_less; diff --git a/source/blender/editors/mesh/bmesh_tools.c b/source/blender/editors/mesh/bmesh_tools.c index 5e5452c5cc9..85d48a7c605 100644 --- a/source/blender/editors/mesh/bmesh_tools.c +++ b/source/blender/editors/mesh/bmesh_tools.c @@ -138,6 +138,7 @@ void MESH_OT_subdivide(wmOperatorType *ot) { /* identifiers */ ot->name= "Subdivide"; + ot->description= "Subdivide selected edges."; ot->idname= "MESH_OT_subdivide"; /* api callbacks */ @@ -554,6 +555,7 @@ void MESH_OT_extrude_repeat(wmOperatorType *ot) { /* identifiers */ ot->name= "Extrude Repeat Mesh"; + ot->description= "Extrude selected vertices, edges or faces repeatedly."; ot->idname= "MESH_OT_extrude_repeat"; /* api callbacks */ @@ -993,6 +995,7 @@ void MESH_OT_extrude(wmOperatorType *ot) { /* identifiers */ ot->name= "Extrude"; + ot->description= "Extrude selected vertices, edges or faces."; ot->idname= "MESH_OT_extrude"; /* api callbacks */ @@ -1027,6 +1030,7 @@ void MESH_OT_select_all_toggle(wmOperatorType *ot) /* identifiers */ ot->name= "Select/Deselect All"; ot->idname= "MESH_OT_select_all_toggle"; + ot->description= "(de)select all vertices, edges or faces."; /* api callbacks */ ot->exec= toggle_select_all_exec; @@ -1156,6 +1160,7 @@ void MESH_OT_dupli_extrude_cursor(wmOperatorType *ot) /* api callbacks */ ot->invoke= dupli_extrude_cursor; + ot->description= "Duplicate and extrude selected vertices, edges or faces towards the mouse cursor."; ot->poll= ED_operator_editmesh; /* flags */ @@ -1247,6 +1252,7 @@ void MESH_OT_delete(wmOperatorType *ot) { /* identifiers */ ot->name= "Delete"; + ot->description= "Delete selected vertices, edges or faces."; ot->idname= "MESH_OT_delete"; /* api callbacks */ @@ -1288,6 +1294,7 @@ void MESH_OT_edge_face_add(wmOperatorType *ot) { /* identifiers */ ot->name= "Make Edge/Face"; + ot->description= "Add an edge or face to selected."; ot->idname= "MESH_OT_edge_face_add"; /* api callbacks */ @@ -1337,6 +1344,7 @@ void MESH_OT_selection_type(wmOperatorType *ot) { /* identifiers */ ot->name= "Selection Mode"; + ot->description= "Set the selection mode type."; ot->idname= "MESH_OT_selection_type"; /* api callbacks */ @@ -1393,6 +1401,7 @@ void MESH_OT_mark_seam(wmOperatorType *ot) /* identifiers */ ot->name= "Mark Seam"; ot->idname= "MESH_OT_mark_seam"; + ot->description= "(un)mark selected edges as a seam."; /* api callbacks */ ot->exec= editbmesh_mark_seam; @@ -1442,6 +1451,7 @@ void MESH_OT_mark_sharp(wmOperatorType *ot) /* identifiers */ ot->name= "Mark Sharp"; ot->idname= "MESH_OT_mark_sharp"; + ot->description= "(un)mark selected edges as sharp."; /* api callbacks */ ot->exec= editbmesh_mark_sharp; @@ -1564,6 +1574,7 @@ void MESH_OT_duplicate(wmOperatorType *ot) { /* identifiers */ ot->name= "Duplicate"; + ot->description= "Duplicate selected vertices, edges or faces."; ot->idname= "MESH_OT_duplicate"; /* api callbacks */ @@ -1595,6 +1606,7 @@ void MESH_OT_flip_normals(wmOperatorType *ot) { /* identifiers */ ot->name= "Flip Normals"; + ot->description= "Flip the direction of selected face's vertex and face normals"; ot->idname= "MESH_OT_flip_normals"; /* api callbacks */ @@ -1678,6 +1690,7 @@ void MESH_OT_edge_rotate(wmOperatorType *ot) { /* identifiers */ ot->name= "Rotate Selected Edge"; + ot->description= "Rotate selected edge or adjoining faces."; ot->idname= "MESH_OT_edge_rotate"; /* api callbacks */ @@ -1745,7 +1758,8 @@ void MESH_OT_hide(wmOperatorType *ot) /* api callbacks */ ot->exec= hide_mesh_exec; ot->poll= ED_operator_editmesh; - + ot->description= "Hide (un)selected vertices, edges or faces."; + /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; @@ -1794,6 +1808,7 @@ void MESH_OT_reveal(wmOperatorType *ot) /* identifiers */ ot->name= "Reveal Hidden"; ot->idname= "MESH_OT_reveal"; + ot->description= "Reveal all hidden vertices, edges and faces."; /* api callbacks */ ot->exec= reveal_mesh_exec; @@ -1825,6 +1840,7 @@ void MESH_OT_normals_make_consistent(wmOperatorType *ot) { /* identifiers */ ot->name= "Make Normals Consistent"; + ot->description= "Make face and vertex normals point either outside or inside the mesh"; ot->idname= "MESH_OT_normals_make_consistent"; /* api callbacks */ @@ -1891,6 +1907,7 @@ void MESH_OT_vertices_smooth(wmOperatorType *ot) { /* identifiers */ ot->name= "Smooth Vertex"; + ot->description= "Flatten angles of selected vertices."; ot->idname= "MESH_OT_vertices_smooth"; /* api callbacks */ @@ -2003,6 +2020,7 @@ void MESH_OT_faces_shade_smooth(wmOperatorType *ot) { /* identifiers */ ot->name= "Shade Smooth"; + ot->description= "Display faces smooth (using vertex normals)."; ot->idname= "MESH_OT_faces_shade_smooth"; /* api callbacks */ @@ -2031,6 +2049,7 @@ void MESH_OT_faces_shade_flat(wmOperatorType *ot) { /* identifiers */ ot->name= "Shade Flat"; + ot->description= "Display faces flat."; ot->idname= "MESH_OT_faces_shade_flat"; /* api callbacks */ diff --git a/source/blender/editors/mesh/editmesh.c b/source/blender/editors/mesh/editmesh.c index 5892af0060b..d8bcf43e978 100644 --- a/source/blender/editors/mesh/editmesh.c +++ b/source/blender/editors/mesh/editmesh.c @@ -68,6 +68,7 @@ #include "BKE_mesh.h" #include "BKE_modifier.h" #include "BKE_object.h" +#include "BKE_paint.h" #include "BKE_pointcache.h" #include "BKE_softbody.h" #include "BKE_texture.h" @@ -821,11 +822,11 @@ EditMesh *make_editMesh(Scene *scene, Object *ob) if(cacheedit) { if(pid.type == PTCACHE_TYPE_CLOTH) { - cloth= ((ClothModifierData*)pid.data)->clothObject; + cloth= ((ClothModifierData*)pid.calldata)->clothObject; VECCOPY(cacheco, cloth->verts[a].x) } else if(pid.type == PTCACHE_TYPE_SOFTBODY) { - sb= (SoftBody*)pid.data; + sb= (SoftBody*)pid.calldata; VECCOPY(cacheco, sb->bpoint[a].pos) } @@ -839,7 +840,7 @@ EditMesh *make_editMesh(Scene *scene, Object *ob) evlist[a]= eve; // face select sets selection in next loop - if( (FACESEL_PAINT_TEST)==0 ) + if(!paint_facesel_test(ob)) eve->f |= (mvert->flag & 1); if (mvert->flag & ME_HIDE) eve->h= 1; @@ -914,7 +915,7 @@ EditMesh *make_editMesh(Scene *scene, Object *ob) if(mface->flag & ME_FACE_SEL) { efa->f |= SELECT; - if(FACESEL_PAINT_TEST) { + if(paint_facesel_test(ob)) { EM_select_face(efa, 1); /* flush down */ } } @@ -1041,7 +1042,7 @@ void load_editMesh(Scene *scene, Object *ob, EditMesh *em) while(eve) { if(cacheedit) { if(pid.type == PTCACHE_TYPE_CLOTH) { - clmd= (ClothModifierData*)pid.data; + clmd= (ClothModifierData*)pid.calldata; cloth= clmd->clothObject; /* assign position */ @@ -1056,7 +1057,7 @@ void load_editMesh(Scene *scene, Object *ob, EditMesh *em) VECADD(cloth->verts[a].v, cloth->verts[a].v, cacheco); } else if(pid.type == PTCACHE_TYPE_SOFTBODY) { - sb= (SoftBody*)pid.data; + sb= (SoftBody*)pid.calldata; /* assign position */ VECCOPY(cacheco, sb->bpoint[a].pos) @@ -1102,12 +1103,8 @@ void load_editMesh(Scene *scene, Object *ob, EditMesh *em) } /* write changes to cache */ - if(cacheedit) { - if(pid.type == PTCACHE_TYPE_CLOTH) - cloth_write_cache(ob, pid.data, pid.cache->editframe); - else if(pid.type == PTCACHE_TYPE_SOFTBODY) - softbody_write_cache(ob, pid.data, pid.cache->editframe); - } + if(cacheedit) + BKE_ptcache_write_cache(&pid, pid.cache->editframe); /* the edges */ a= 0; @@ -1572,6 +1569,7 @@ void MESH_OT_separate(wmOperatorType *ot) { /* identifiers */ ot->name= "Separate"; + ot->description= "Separate selected geometry into a new mesh."; ot->idname= "MESH_OT_separate"; /* api callbacks */ diff --git a/source/blender/editors/mesh/editmesh_add.c b/source/blender/editors/mesh/editmesh_add.c index ff0814661eb..fbeb1636114 100644 --- a/source/blender/editors/mesh/editmesh_add.c +++ b/source/blender/editors/mesh/editmesh_add.c @@ -119,7 +119,6 @@ static short icoface[20][3] = { {10,9,11} }; - /* ********************** */ /* selected faces get hidden edges */ @@ -240,6 +239,7 @@ void MESH_OT_fgon_make(struct wmOperatorType *ot) { /* identifiers */ ot->name= "Make F-gon"; + ot->description= "Make fgon from selected faces."; ot->idname= "MESH_OT_fgon_make"; /* api callbacks */ @@ -272,6 +272,7 @@ void MESH_OT_fgon_clear(struct wmOperatorType *ot) { /* identifiers */ ot->name= "Clear F-gon"; + ot->description= "Clear fgon from selected face."; ot->idname= "MESH_OT_fgon_clear"; /* api callbacks */ @@ -711,6 +712,7 @@ static void addedgeface_mesh(Mesh *me, BMEditMesh *bem, wmOperator *op) BKE_mesh_end_editmesh(me, em); } + /* ************************ primitives ******************* */ // HACK: these can also be found in cmoview.tga.c, but are here so that they can be found by linker @@ -1226,6 +1228,7 @@ void MESH_OT_primitive_plane_add(wmOperatorType *ot) { /* identifiers */ ot->name= "Add Plane"; + ot->description= "Construct a filled planar mesh with 4 vertices."; ot->idname= "MESH_OT_primitive_plane_add"; /* api callbacks */ @@ -1258,6 +1261,7 @@ void MESH_OT_primitive_cube_add(wmOperatorType *ot) { /* identifiers */ ot->name= "Add Cube"; + ot->description= "Construct a cube mesh."; ot->idname= "MESH_OT_primitive_cube_add"; /* api callbacks */ @@ -1290,6 +1294,7 @@ void MESH_OT_primitive_circle_add(wmOperatorType *ot) { /* identifiers */ ot->name= "Add Circle"; + ot->description= "Construct a circle mesh."; ot->idname= "MESH_OT_primitive_circle_add"; /* api callbacks */ @@ -1327,6 +1332,7 @@ void MESH_OT_primitive_cylinder_add(wmOperatorType *ot) { /* identifiers */ ot->name= "Add Cylinder"; + ot->description= "Construct a cylindrical mesh (ends filled)."; ot->idname= "MESH_OT_primitive_cylinder_add"; /* api callbacks */ @@ -1364,6 +1370,7 @@ void MESH_OT_primitive_tube_add(wmOperatorType *ot) { /* identifiers */ ot->name= "Add Tube"; + ot->description= "Construct a cylindrical mesh (ends not filled)."; ot->idname= "MESH_OT_primitive_tube_add"; /* api callbacks */ @@ -1401,6 +1408,7 @@ void MESH_OT_primitive_cone_add(wmOperatorType *ot) { /* identifiers */ ot->name= "Add Cone"; + ot->description= "Construct a conic mesh (ends filled)."; ot->idname= "MESH_OT_primitive_cone_add"; /* api callbacks */ @@ -1440,6 +1448,7 @@ void MESH_OT_primitive_grid_add(wmOperatorType *ot) { /* identifiers */ ot->name= "Add Grid"; + ot->description= "Construct a grid mesh."; ot->idname= "MESH_OT_primitive_grid_add"; /* api callbacks */ @@ -1475,6 +1484,7 @@ void MESH_OT_primitive_monkey_add(wmOperatorType *ot) { /* identifiers */ ot->name= "Add Monkey"; + ot->description= "Construct a Suzanne mesh."; ot->idname= "MESH_OT_primitive_monkey_add"; /* api callbacks */ @@ -1507,6 +1517,7 @@ void MESH_OT_primitive_uv_sphere_add(wmOperatorType *ot) { /* identifiers */ ot->name= "Add UV Sphere"; + ot->description= "Construct a UV sphere mesh."; ot->idname= "MESH_OT_primitive_uv_sphere_add"; /* api callbacks */ @@ -1544,6 +1555,7 @@ void MESH_OT_primitive_ico_sphere_add(wmOperatorType *ot) { /* identifiers */ ot->name= "Add Ico Sphere"; + ot->description= "Construct an Icosphere mesh."; ot->idname= "MESH_OT_primitive_ico_sphere_add"; /* api callbacks */ diff --git a/source/blender/editors/mesh/editmesh_loop.c b/source/blender/editors/mesh/editmesh_loop.c index b59c46a8068..7e741831133 100644 --- a/source/blender/editors/mesh/editmesh_loop.c +++ b/source/blender/editors/mesh/editmesh_loop.c @@ -882,6 +882,7 @@ void MESH_OT_knife_cut(wmOperatorType *ot) PropertyRNA *prop; ot->name= "Knife Cut"; + ot->description= "Cut selected edges and faces into parts."; ot->idname= "MESH_OT_knife_cut"; ot->invoke= WM_gesture_lines_invoke; diff --git a/source/blender/editors/mesh/editmesh_mods.c b/source/blender/editors/mesh/editmesh_mods.c index 06870915e1d..b38f35ed529 100644 --- a/source/blender/editors/mesh/editmesh_mods.c +++ b/source/blender/editors/mesh/editmesh_mods.c @@ -65,6 +65,7 @@ editmesh_mods.c, UI level access, no geometry changes #include "BKE_global.h" #include "BKE_mesh.h" #include "BKE_material.h" +#include "BKE_paint.h" #include "BKE_texture.h" #include "BKE_utildefines.h" #include "BKE_report.h" @@ -245,7 +246,7 @@ int EM_mask_init_backbuf_border(ViewContext *vc, short mcords[][2], short tot, s /* method in use for face selecting too */ if(vc->obedit==NULL) { - if(FACESEL_PAINT_TEST); + if(paint_facesel_test(vc->obact)); else return 0; } else if(vc->v3d->drawtype<OB_SOLID || (vc->v3d->flag & V3D_ZBUF_SELECT)==0) return 0; @@ -300,7 +301,7 @@ int EM_init_backbuf_circle(ViewContext *vc, short xs, short ys, short rads) /* method in use for face selecting too */ if(vc->obedit==NULL) { - if(FACESEL_PAINT_TEST); + if(paint_facesel_test(vc->obact)); else return 0; } else if(vc->v3d->drawtype<OB_SOLID || (vc->v3d->flag & V3D_ZBUF_SELECT)==0) return 0; @@ -1044,6 +1045,7 @@ void MESH_OT_loop_multi_select(wmOperatorType *ot) { /* identifiers */ ot->name= "Multi Select Loops"; + ot->description= "Select a loop of connected edges by connection type."; ot->idname= "MESH_OT_loop_multi_select"; /* api callbacks */ @@ -1061,8 +1063,6 @@ void MESH_OT_loop_multi_select(wmOperatorType *ot) /* ***************** MAIN MOUSE SELECTION ************** */ -/* ******************* mesh shortest path select, uses prev-selected edge ****************** */ - /* ************************************************** */ /* *********** select linked ************* */ @@ -1272,6 +1272,7 @@ void MESH_OT_select_by_number_vertices(wmOperatorType *ot) /* identifiers */ ot->name= "Select by Number of Vertices"; + ot->description= "Select vertices or faces by vertex count."; ot->idname= "MESH_OT_select_by_number_vertices"; /* api callbacks */ @@ -1392,6 +1393,7 @@ void MESH_OT_edges_select_sharp(wmOperatorType *ot) { /* identifiers */ ot->name= "Select Sharp Edges"; + ot->description= "Marked selected edges as sharp."; ot->idname= "MESH_OT_edges_select_sharp"; /* api callbacks */ @@ -1559,6 +1561,7 @@ void MESH_OT_faces_select_linked_flat(wmOperatorType *ot) { /* identifiers */ ot->name= "Select Linked Flat Faces"; + ot->description= "Select linked faces by angle."; ot->idname= "MESH_OT_faces_select_linked_flat"; /* api callbacks */ @@ -1659,6 +1662,7 @@ void MESH_OT_select_non_manifold(wmOperatorType *ot) { /* identifiers */ ot->name= "Select Non Manifold"; + ot->description= "Select all non-manifold vertices or edges."; ot->idname= "MESH_OT_select_non_manifold"; /* api callbacks */ @@ -1687,7 +1691,6 @@ void MESH_OT_bmesh_test(wmOperatorType *ot) ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; } - static void selectrandom_mesh(EditMesh *em, float perc) /* randomly selects a user-set % of vertices/edges/faces */ { EditVert *eve; @@ -1747,6 +1750,7 @@ void MESH_OT_select_random(wmOperatorType *ot) { /* identifiers */ ot->name= "Select Random"; + ot->description= "Randomly select vertices."; ot->idname= "MESH_OT_select_random"; /* api callbacks */ @@ -1814,7 +1818,6 @@ static void mesh_selection_type(Scene *scene, EditMesh *em, int val) } /* **************** NORMALS ************** */ - /* XXX value of select is messed up, it means two things */ void righthandfaces(EditMesh *em, int select) /* makes faces righthand turning */ { @@ -2457,6 +2460,8 @@ void MESH_OT_vertices_transform_to_sphere(wmOperatorType *ot) { /* identifiers */ ot->name= "Vertices to Sphere"; + //added "around cursor" to differentiate between "TFM_OT_tosphere()" + ot->description= "Move selected vertices outward in a spherical shape around cursor."; ot->idname= "MESH_OT_vertices_transform_to_sphere"; /* api callbacks */ diff --git a/source/blender/editors/mesh/mesh_layers.c b/source/blender/editors/mesh/mesh_layers.c index 302251dde9f..2b4ba03270f 100644 --- a/source/blender/editors/mesh/mesh_layers.c +++ b/source/blender/editors/mesh/mesh_layers.c @@ -55,14 +55,16 @@ #include "WM_types.h" #include "ED_mesh.h" +#include "ED_object.h" #include "ED_view3d.h" #include "mesh_intern.h" #include "bmesh.h" -static void delete_customdata_layer(Mesh *me, CustomDataLayer *layer, int loop) +static void delete_customdata_layer(bContext *C, Object *ob, CustomDataLayer *layer, int loop) { CustomData *data; + Mesh *me = ob->data; void *actlayerdata, *rndlayerdata, *clonelayerdata, *masklayerdata, *layerdata=layer->data; int type= layer->type; int index; @@ -96,9 +98,8 @@ static void delete_customdata_layer(Mesh *me, CustomDataLayer *layer, int loop) mesh_update_customdata_pointers(me); } - if(!CustomData_has_layer(data, type)) - if(type == CD_MLOOPCOL && (G.f & G_VERTEXPAINT)) - G.f &= ~G_VERTEXPAINT; /* get out of vertexpaint mode */ + if(!CustomData_has_layer(data, type) && (type == CD_MLOOPCOL && (ob->mode & OB_MODE_VERTEX_PAINT))) + ED_object_toggle_modes(C, OB_MODE_VERTEX_PAINT); /* reconstruct active layer */ if (actlayerdata != layerdata) { @@ -211,6 +212,7 @@ void MESH_OT_uv_texture_add(wmOperatorType *ot) { /* identifiers */ ot->name= "Add UV Texture"; + ot->description= "Add UV texture layer."; ot->idname= "MESH_OT_uv_texture_add"; /* api callbacks */ @@ -241,8 +243,8 @@ static int uv_texture_remove_exec(bContext *C, wmOperator *op) if(!cdl) return OPERATOR_CANCELLED; - delete_customdata_layer(me, cdl, 0); - delete_customdata_layer(me, cdl2, 1); + delete_customdata_layer(C, ob, cdl, 0); + delete_customdata_layer(C, ob, cdl2, 1); DAG_object_flush_update(scene, ob, OB_RECALC_DATA); WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_DATA, ob); @@ -254,6 +256,7 @@ void MESH_OT_uv_texture_remove(wmOperatorType *ot) { /* identifiers */ ot->name= "Remove UV Texture"; + ot->description= "Remove UV texture layer."; ot->idname= "MESH_OT_uv_texture_remove"; /* api callbacks */ @@ -318,6 +321,7 @@ void MESH_OT_vertex_color_add(wmOperatorType *ot) { /* identifiers */ ot->name= "Add Vertex Color"; + ot->description= "Add vertex color layer."; ot->idname= "MESH_OT_vertex_color_add"; /* api callbacks */ @@ -345,7 +349,7 @@ static int vertex_color_remove_exec(bContext *C, wmOperator *op) if(!cdl) return OPERATOR_CANCELLED; - delete_customdata_layer(me, cdl, 1); + delete_customdata_layer(C, ob, cdl, 1); DAG_object_flush_update(scene, ob, OB_RECALC_DATA); WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_DATA, ob); @@ -357,6 +361,7 @@ void MESH_OT_vertex_color_remove(wmOperatorType *ot) { /* identifiers */ ot->name= "Remove Vertex Color"; + ot->description= "Remove vertex color layer."; ot->idname= "MESH_OT_vertex_color_remove"; /* api callbacks */ @@ -394,6 +399,7 @@ void MESH_OT_sticky_add(wmOperatorType *ot) { /* identifiers */ ot->name= "Add Sticky"; + ot->description= "Add sticky UV texture layer."; ot->idname= "MESH_OT_sticky_add"; /* api callbacks */ @@ -430,6 +436,7 @@ void MESH_OT_sticky_remove(wmOperatorType *ot) { /* identifiers */ ot->name= "Remove Sticky"; + ot->description= "Remove sticky UV texture layer."; ot->idname= "MESH_OT_sticky_remove"; /* api callbacks */ diff --git a/source/blender/editors/mesh/mesh_ops.c b/source/blender/editors/mesh/mesh_ops.c index 01cf15cb9f1..1498f3573f1 100644 --- a/source/blender/editors/mesh/mesh_ops.c +++ b/source/blender/editors/mesh/mesh_ops.c @@ -91,6 +91,7 @@ static void MESH_OT_vertex_specials(wmOperatorType *ot) { /* identifiers */ ot->name= "Vertex Specials"; + //ot->description= "Perform special vertex operations."; ot->idname= "MESH_OT_vertex_specials"; /* api callbacks */ @@ -129,6 +130,7 @@ static void MESH_OT_edge_specials(wmOperatorType *ot) { /* identifiers */ ot->name= "Edge Specials"; + //ot->description= "Perform special edge operations."; ot->idname= "MESH_OT_edge_specials"; /* api callbacks */ @@ -179,6 +181,7 @@ static void MESH_OT_face_specials(wmOperatorType *ot) { /* identifiers */ ot->name= "Face Specials"; + //ot->description= "Perform special face operations."; ot->idname= "MESH_OT_face_specials"; /* api callbacks */ @@ -220,6 +223,7 @@ static void MESH_OT_specials(wmOperatorType *ot) { /* identifiers */ ot->name= "Specials"; + //ot->description= "Perform special vertice, edge or face operations."; ot->idname= "MESH_OT_specials"; /* api callbacks */ diff --git a/source/blender/editors/object/editconstraint.c b/source/blender/editors/object/editconstraint.c index 9e8205e58ab..23b3caf8e26 100644 --- a/source/blender/editors/object/editconstraint.c +++ b/source/blender/editors/object/editconstraint.c @@ -87,7 +87,7 @@ ListBase *get_active_constraints (Object *ob) if (ob == NULL) return NULL; - if (ob->flag & OB_POSEMODE) { + if (ob->mode & OB_MODE_POSE) { bPoseChannel *pchan; pchan = get_active_posechannel(ob); @@ -1065,7 +1065,7 @@ static int constraint_add_exec(bContext *C, wmOperator *op, Object *ob, ListBase { /* if this constraint is being added to a posechannel, make sure * the constraint gets evaluated in pose-space */ - if (ob->flag & OB_POSEMODE) { + if (ob->mode & OB_MODE_POSE) { con->ownspace = CONSTRAINT_SPACE_POSE; con->flag |= CONSTRAINT_SPACEONCE; } diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c index 780fa526b33..db94dfb1ec8 100644 --- a/source/blender/editors/object/object_edit.c +++ b/source/blender/editors/object/object_edit.c @@ -99,6 +99,7 @@ #include "BKE_tessmesh.h" #include "BKE_nla.h" #include "BKE_object.h" +#include "BKE_paint.h" #include "BKE_particle.h" #include "BKE_property.h" #include "BKE_report.h" @@ -127,6 +128,7 @@ #include "RNA_access.h" #include "RNA_define.h" +#include "RNA_enum_types.h" /* for menu/popup icons etc etc*/ #include "UI_interface.h" @@ -178,10 +180,6 @@ void ED_base_object_activate(bContext *C, Base *base) Scene *scene= CTX_data_scene(C); Base *tbase; - /* activating a non-mesh, should end a couple of modes... */ - if(base && base->object->type!=OB_MESH) - ED_view3d_exit_paint_modes(C); - /* sets scene->basact */ BASACT= base; @@ -273,9 +271,6 @@ static Object *object_add_type(bContext *C, int type) Scene *scene= CTX_data_scene(C); Object *ob; - /* XXX hrms, this is editor level operator, remove? */ - ED_view3d_exit_paint_modes(C); - /* for as long scene has editmode... */ if (CTX_data_edit_object(C)) ED_object_exit_editmode(C, EM_FREEDATA|EM_FREEUNDO|EM_WAITCURSOR); /* freedata, and undo */ @@ -752,8 +747,6 @@ static int object_delete_exec(bContext *C, wmOperator *op) if(CTX_data_edit_object(C)) return OPERATOR_CANCELLED; - ED_view3d_exit_paint_modes(C); - CTX_DATA_BEGIN(C, Base*, base, selected_editable_bases) { if(base->object->type==OB_LAMP) islamp= 1; @@ -989,6 +982,8 @@ static void select_editmesh_hook(Object *ob, HookModifierData *hmd) BMIter iter; int index=0, nr=0; + if (hmd->indexar == NULL) + return; BM_ITER(eve, &iter, em->bm, BM_VERTS_OF_MESH, NULL) { if(nr==hmd->indexar[index]) { BM_Select(em->bm, eve, 1); @@ -1158,7 +1153,7 @@ void ED_object_apply_obmat(Object *ob) } -int hook_getIndexArray(Object *obedit, int *tot, int **indexar, char *name, float *cent_r) +int object_hook_index_array(Object *obedit, int *tot, int **indexar, char *name, float *cent_r) { *indexar= NULL; *tot= 0; @@ -1237,9 +1232,8 @@ static void select_editcurve_hook(Object *obedit, HookModifierData *hmd) } } -void obedit_hook_select(Object *ob, HookModifierData *hmd) +void object_hook_select(Object *ob, HookModifierData *hmd) { - if(ob->type==OB_MESH) select_editmesh_hook(ob, hmd); else if(ob->type==OB_LATTICE) select_editlattice_hook(ob, hmd); else if(ob->type==OB_CURVE) select_editcurve_hook(ob, hmd); @@ -1323,7 +1317,7 @@ void add_hook(Scene *scene, View3D *v3d, int mode) int tot, ok, *indexar; char name[32]; - ok = hook_getIndexArray(obedit, &tot, &indexar, name, cent); + ok = object_hook_index_array(obedit, &tot, &indexar, name, cent); if(ok==0) { error("Requires selected vertices or active Vertex Group"); @@ -1367,6 +1361,7 @@ void add_hook(Scene *scene, View3D *v3d, int mode) hmd->totindex= tot; BLI_strncpy(hmd->name, name, 32); + // TODO: need to take into account bone targets here too now... if(mode==1 || mode==2) { /* matrix calculus */ /* vert x (obmat x hook->imat) x hook->obmat x ob->imat */ @@ -1386,9 +1381,11 @@ void add_hook(Scene *scene, View3D *v3d, int mode) modifier_free(md); } else if(mode==5) { /* select */ - obedit_hook_select(obedit, hmd); + // FIXME: this is now OBJECT_OT_hook_select + object_hook_select(obedit, hmd); } else if(mode==6) { /* clear offset */ + // FIXME: this is now OBJECT_OT_hook_reset operator where_is_object(scene, ob); /* ob is hook->parent */ Mat4Invert(ob->imat, ob->obmat); @@ -1400,6 +1397,25 @@ void add_hook(Scene *scene, View3D *v3d, int mode) DAG_scene_sort(scene); } +void add_hook_menu(Scene *scene, View3D *v3d) +{ + Object *obedit= scene->obedit; // XXX get from context + int mode; + + if(obedit==NULL) return; + + if(modifiers_findByType(obedit, eModifierType_Hook)) + mode= pupmenu("Hooks %t|Add, To New Empty %x1|Add, To Selected Object %x2|Remove... %x3|Reassign... %x4|Select... %x5|Clear Offset...%x6"); + else + mode= pupmenu("Hooks %t|Add, New Empty %x1|Add, To Selected Object %x2"); + + if(mode<1) return; + + /* do operations */ + add_hook(scene, v3d, mode); +} + + /* use this when the loc/size/rot of the parent has changed but the children should stay in the same place * apply-size-rot or object center for eg */ @@ -1418,25 +1434,6 @@ static void ignore_parent_tx(Scene *scene, Object *ob ) } } - -void add_hook_menu(Scene *scene, View3D *v3d) -{ - Object *obedit= scene->obedit; // XXX get from context - int mode; - - if(obedit==NULL) return; - - if(modifiers_findByType(obedit, eModifierType_Hook)) - mode= pupmenu("Hooks %t|Add, To New Empty %x1|Add, To Selected Object %x2|Remove... %x3|Reassign... %x4|Select... %x5|Clear Offset...%x6"); - else - mode= pupmenu("Hooks %t|Add, New Empty %x1|Add, To Selected Object %x2"); - - if(mode<1) return; - - /* do operations */ - add_hook(scene, v3d, mode); -} - /* ******************** clear parent operator ******************* */ static EnumPropertyItem prop_clear_parent_types[] = { @@ -2244,7 +2241,7 @@ static int object_location_clear_exec(bContext *C, wmOperator *op) int armature_clear= 0; CTX_DATA_BEGIN(C, Object*, ob, selected_editable_objects) { - if((G.f & G_WEIGHTPAINT)==0) { + if(!(ob->mode & OB_MODE_WEIGHT_PAINT)) { if ((ob->protectflag & OB_LOCK_LOCX)==0) ob->loc[0]= ob->dloc[0]= 0.0f; if ((ob->protectflag & OB_LOCK_LOCY)==0) @@ -2287,7 +2284,7 @@ static int object_rotation_clear_exec(bContext *C, wmOperator *op) int armature_clear= 0; CTX_DATA_BEGIN(C, Object*, ob, selected_editable_objects) { - if((G.f & G_WEIGHTPAINT)==0) { + if(!(ob->mode & OB_MODE_WEIGHT_PAINT)) { /* eulers can only get cleared if they are not protected */ if ((ob->protectflag & OB_LOCK_ROTX)==0) ob->rot[0]= ob->drot[0]= 0.0f; @@ -2331,7 +2328,7 @@ static int object_scale_clear_exec(bContext *C, wmOperator *op) int armature_clear= 0; CTX_DATA_BEGIN(C, Object*, ob, selected_editable_objects) { - if((G.f & G_WEIGHTPAINT)==0) { + if(!(ob->mode & OB_MODE_WEIGHT_PAINT)) { if ((ob->protectflag & OB_LOCK_SCALEX)==0) { ob->dsize[0]= 0.0f; ob->size[0]= 1.0f; @@ -2758,13 +2755,10 @@ static void proxy_group_objects_menu (bContext *C, wmOperator *op, Object *ob, G if (go->ob) { PointerRNA props_ptr; - /* create operator properties, and assign the relevant pointers to that, - * and add a menu entry which uses these props - */ - WM_operator_properties_create(&props_ptr, op->idname); + /* create operator menu item with relevant properties filled in */ + props_ptr= uiItemFullO(layout, go->ob->id.name+2, 0, op->idname, NULL, WM_OP_EXEC_REGION_WIN, UI_ITEM_O_RETURN_PROPS); RNA_string_set(&props_ptr, "object", go->ob->id.name+2); RNA_string_set(&props_ptr, "group_object", go->ob->id.name+2); - uiItemFullO(layout, go->ob->id.name+2, 0, op->idname, props_ptr.data, WM_OP_EXEC_REGION_WIN); } } @@ -2792,12 +2786,9 @@ static int make_proxy_invoke (bContext *C, wmOperator *op, wmEvent *evt) uiLayout *layout= uiPupMenuLayout(pup); PointerRNA props_ptr; - /* create operator properties, and assign the relevant pointers to that, - * and add a menu entry which uses these props - */ - WM_operator_properties_create(&props_ptr, op->idname); + /* create operator menu item with relevant properties filled in */ + props_ptr= uiItemFullO(layout, op->type->name, 0, op->idname, props_ptr.data, WM_OP_EXEC_REGION_WIN, UI_ITEM_O_RETURN_PROPS); RNA_string_set(&props_ptr, "object", ob->id.name+2); - uiItemFullO(layout, op->type->name, 0, op->idname, props_ptr.data, WM_OP_EXEC_REGION_WIN); /* present the menu and be done... */ uiPupMenuEnd(C, pup); @@ -3696,7 +3687,7 @@ void ED_object_exit_editmode(bContext *C, int flag) me->edit_btmesh= NULL; } - if(G.f & G_WEIGHTPAINT) + if(obedit->restore_mode & OB_MODE_WEIGHT_PAINT) mesh_octree_table(obedit, NULL, NULL, 'e'); } else if (obedit->type==OB_ARMATURE) { @@ -3735,6 +3726,9 @@ void ED_object_exit_editmode(bContext *C, int flag) WM_event_add_notifier(C, NC_SCENE|ND_MODE|NS_MODE_OBJECT, scene); } + + obedit->mode &= ~OB_MODE_EDIT; + ED_object_toggle_modes(C, obedit->restore_mode); } @@ -3768,7 +3762,10 @@ void ED_object_enter_editmode(bContext *C, int flag) if(flag & EM_WAITCURSOR) waitcursor(1); - ED_view3d_exit_paint_modes(C); + ob->restore_mode = ob->mode; + ED_object_toggle_modes(C, ob->mode); + + ob->mode |= OB_MODE_EDIT; if(ob->type==OB_MESH) { Mesh *me= ob->data; @@ -3856,6 +3853,16 @@ static int editmode_toggle_exec(bContext *C, wmOperator *op) return OPERATOR_FINISHED; } +static int editmode_toggle_poll(bContext *C) +{ + Object *ob = CTX_data_active_object(C); + + return ob && (ob->type == OB_MESH || ob->type == OB_ARMATURE || + ob->type == OB_FONT || ob->type == OB_MBALL || + ob->type == OB_LATTICE || ob->type == OB_SURF || + ob->type == OB_CURVE); +} + void OBJECT_OT_editmode_toggle(wmOperatorType *ot) { @@ -3867,7 +3874,7 @@ void OBJECT_OT_editmode_toggle(wmOperatorType *ot) /* api callbacks */ ot->exec= editmode_toggle_exec; - ot->poll= ED_operator_object_active; + ot->poll= editmode_toggle_poll; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; @@ -3884,7 +3891,7 @@ static int posemode_exec(bContext *C, wmOperator *op) ED_object_exit_editmode(C, EM_FREEDATA); ED_armature_enter_posemode(C, base); } - else if(base->object->flag & OB_POSEMODE) + else if(base->object->mode & OB_MODE_POSE) ED_armature_exit_posemode(C, base); else ED_armature_enter_posemode(C, base); @@ -4107,10 +4114,10 @@ void special_editmenu(Scene *scene, View3D *v3d) if(obedit==NULL) { - if(ob->flag & OB_POSEMODE) { + if(ob->mode & OB_MODE_POSE) { // XXX pose_special_editmenu(); } - else if(FACESEL_PAINT_TEST) { + else if(paint_facesel_test(ob)) { Mesh *me= get_mesh(ob); MTFace *tface; MFace *mface; @@ -4156,7 +4163,7 @@ void special_editmenu(Scene *scene, View3D *v3d) } DAG_object_flush_update(scene, ob, OB_RECALC_DATA); } - else if(G.f & G_VERTEXPAINT) { + else if(ob->mode & OB_MODE_VERTEX_PAINT) { Mesh *me= get_mesh(ob); if(me==0 || (me->mcol==NULL && me->mtface==NULL) ) return; @@ -4169,17 +4176,17 @@ void special_editmenu(Scene *scene, View3D *v3d) DAG_object_flush_update(scene, ob, OB_RECALC_DATA); } } - else if(G.f & G_WEIGHTPAINT) { + else if(ob->mode & OB_MODE_WEIGHT_PAINT) { Object *par= modifiers_isDeformedByArmature(ob); - if(par && (par->flag & OB_POSEMODE)) { + if(par && (par->mode & OB_MODE_POSE)) { nr= pupmenu("Specials%t|Apply Bone Envelopes to Vertex Groups %x1|Apply Bone Heat Weights to Vertex Groups %x2"); // XXX if(nr==1 || nr==2) // XXX pose_adds_vgroups(ob, (nr == 2)); } } - else if(G.f & G_PARTICLEEDIT) { + else if(ob->mode & OB_MODE_PARTICLE_EDIT) { #if 0 // XXX ParticleSystem *psys = PE_get_current(ob); @@ -5721,7 +5728,7 @@ void new_id_matar(Material **matar, int totcol) } } -void single_obdata_users(Scene *scene, View3D *v3d, int flag) +void single_obdata_users(Scene *scene, int flag) { Object *ob; Lamp *la; @@ -5844,7 +5851,7 @@ void single_obdata_users(Scene *scene, View3D *v3d, int flag) } } -void single_ipo_users(Scene *scene, View3D *v3d, int flag) +void single_ipo_users(Scene *scene, int flag) { #if 0 // XXX old animation system Object *ob; @@ -5867,7 +5874,7 @@ void single_ipo_users(Scene *scene, View3D *v3d, int flag) #endif // XXX old animation system } -void single_mat_users(Scene *scene, View3D *v3d, int flag) +void single_mat_users(Scene *scene, int flag) { Object *ob; Base *base; @@ -6053,19 +6060,19 @@ void single_user(Scene *scene, View3D *v3d) else if(nr==2) { single_object_users(scene, v3d, 1); - single_obdata_users(scene, v3d, 1); + single_obdata_users(scene, 1); } else if(nr==3) { single_object_users(scene, v3d, 1); - single_obdata_users(scene, v3d, 1); - single_mat_users(scene, v3d, 1); /* also tex */ + single_obdata_users(scene, 1); + single_mat_users(scene, 1); /* also tex */ } else if(nr==4) { - single_mat_users(scene, v3d, 1); + single_mat_users(scene, 1); } else if(nr==5) { - single_ipo_users(scene, v3d, 1); + single_ipo_users(scene, 1); } @@ -6074,6 +6081,20 @@ void single_user(Scene *scene, View3D *v3d) } } +/* used for copying scenes */ +void ED_object_single_users(Scene *scene, int full) +{ + single_object_users(scene, NULL, 0); + + if(full) { + single_obdata_users(scene, 0); + single_mat_users_expand(); + single_tex_users_expand(); + } + + clear_id_newpoins(); +} + /* ************************************************************* */ /* helper for below, ma was checked to be not NULL */ @@ -6278,7 +6299,7 @@ static Base *object_add_duplicate_internal(Scene *scene, Base *base, int dupflag int a, didit; ob= base->object; - if(ob->flag & OB_POSEMODE) { + if(ob->mode & OB_MODE_POSE) { ; /* nothing? */ } else { @@ -7014,3 +7035,124 @@ void hookmenu(Scene *scene, View3D *v3d) if (changed) { } } + +static EnumPropertyItem *object_mode_set_itemsf(bContext *C, PointerRNA *ptr, int *free) +{ + EnumPropertyItem *input = object_mode_items; + EnumPropertyItem *item= NULL; + Object *ob; + int totitem= 0; + + if(!C) /* needed for docs */ + return object_mode_items; + + ob = CTX_data_active_object(C); + while(ob && input->identifier) { + if((input->value == OB_MODE_EDIT && ((ob->type == OB_MESH) || (ob->type == OB_ARMATURE) || + (ob->type == OB_CURVE) || (ob->type == OB_SURF) || + (ob->type == OB_FONT) || (ob->type == OB_MBALL) || (ob->type == OB_LATTICE))) || + (input->value == OB_MODE_POSE && (ob->type == OB_ARMATURE)) || + (input->value == OB_MODE_PARTICLE_EDIT && ob->particlesystem.first) || + ((input->value == OB_MODE_SCULPT || input->value == OB_MODE_VERTEX_PAINT || + input->value == OB_MODE_WEIGHT_PAINT || input->value == OB_MODE_TEXTURE_PAINT) && (ob->type == OB_MESH)) || + (input->value == OB_MODE_OBJECT)) + RNA_enum_item_add(&item, &totitem, input); + ++input; + } + + RNA_enum_item_end(&item, &totitem); + + *free= 1; + + return item; +} + +static const char *object_mode_op_string(int mode) +{ + if(mode == OB_MODE_EDIT) + return "OBJECT_OT_editmode_toggle"; + if(mode == OB_MODE_SCULPT) + return "SCULPT_OT_sculptmode_toggle"; + if(mode == OB_MODE_VERTEX_PAINT) + return "PAINT_OT_vertex_paint_toggle"; + if(mode == OB_MODE_WEIGHT_PAINT) + return "PAINT_OT_weight_paint_toggle"; + if(mode == OB_MODE_TEXTURE_PAINT) + return "PAINT_OT_texture_paint_toggle"; + if(mode == OB_MODE_PARTICLE_EDIT) + return "PARTICLE_OT_particle_edit_toggle"; + if(mode == OB_MODE_POSE) + return "OBJECT_OT_posemode_toggle"; + return NULL; +} + +static int object_mode_set_exec(bContext *C, wmOperator *op) +{ + Object *ob= CTX_data_active_object(C); + ObjectMode mode = RNA_enum_get(op->ptr, "mode"); + ObjectMode restore_mode = ob->mode; + int toggle = RNA_boolean_get(op->ptr, "toggle"); + + if(!ob) + return OPERATOR_CANCELLED; + + /* Exit current mode if it's not the mode we're setting */ + if(ob->mode != OB_MODE_OBJECT && ob->mode != mode) + WM_operator_name_call(C, object_mode_op_string(ob->mode), WM_OP_EXEC_REGION_WIN, NULL); + + if(mode != OB_MODE_OBJECT) { + /* Enter new mode */ + if(ob->mode != mode || toggle) + WM_operator_name_call(C, object_mode_op_string(mode), WM_OP_EXEC_REGION_WIN, NULL); + + if(toggle) { + if(ob->mode == mode) + /* For toggling, store old mode so we know what to go back to */ + ob->restore_mode = restore_mode; + else if(ob->restore_mode != OB_MODE_OBJECT && ob->restore_mode != mode) { + WM_operator_name_call(C, object_mode_op_string(ob->restore_mode), WM_OP_EXEC_REGION_WIN, NULL); + } + } + } + + return OPERATOR_FINISHED; +} + +void OBJECT_OT_mode_set(wmOperatorType *ot) +{ + PropertyRNA *prop; + + /* identifiers */ + ot->name= "Set Object Mode"; + ot->description = "Sets the object interaction mode."; + ot->idname= "OBJECT_OT_mode_set"; + + /* api callbacks */ + ot->exec= object_mode_set_exec; + + ot->poll= ED_operator_object_active; + + /* flags */ + ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; + + prop= RNA_def_enum(ot->srna, "mode", object_mode_items, 0, "Mode", ""); + RNA_def_enum_funcs(prop, object_mode_set_itemsf); + + RNA_def_boolean(ot->srna, "toggle", 0, "Toggle", ""); +} + + + +void ED_object_toggle_modes(bContext *C, int mode) +{ + if(mode & OB_MODE_SCULPT) + WM_operator_name_call(C, "SCULPT_OT_sculptmode_toggle", WM_OP_EXEC_REGION_WIN, NULL); + if(mode & OB_MODE_VERTEX_PAINT) + WM_operator_name_call(C, "PAINT_OT_vertex_paint_toggle", WM_OP_EXEC_REGION_WIN, NULL); + if(mode & OB_MODE_WEIGHT_PAINT) + WM_operator_name_call(C, "PAINT_OT_weight_paint_toggle", WM_OP_EXEC_REGION_WIN, NULL); + if(mode & OB_MODE_TEXTURE_PAINT) + WM_operator_name_call(C, "PAINT_OT_texture_paint_toggle", WM_OP_EXEC_REGION_WIN, NULL); + if(mode & OB_MODE_PARTICLE_EDIT) + WM_operator_name_call(C, "PARTICLE_OT_particle_edit_toggle", WM_OP_EXEC_REGION_WIN, NULL); +} diff --git a/source/blender/editors/object/object_intern.h b/source/blender/editors/object/object_intern.h index 17d4f5deaae..2f164102be2 100644 --- a/source/blender/editors/object/object_intern.h +++ b/source/blender/editors/object/object_intern.h @@ -34,11 +34,13 @@ struct Lattice; struct Curve; struct Object; struct Mesh; +struct HookModifierData; /* internal exports only */ /* object_edit.c */ +void OBJECT_OT_mode_set(struct wmOperatorType *ot); void OBJECT_OT_editmode_toggle(struct wmOperatorType *ot); void OBJECT_OT_posemode_toggle(struct wmOperatorType *ot); void OBJECT_OT_parent_set(struct wmOperatorType *ot); @@ -79,6 +81,9 @@ void OBJECT_OT_armature_add(struct wmOperatorType *ot); /* only used as menu */ void OBJECT_OT_primitive_add(struct wmOperatorType *ot); +int object_hook_index_array(Object *obedit, int *tot, int **indexar, char *name, float *cent_r); +void object_hook_select(Object *obedit, struct HookModifierData *hmd); + /* editlattice.c */ void free_editLatt(Object *ob); void make_editLatt(Object *obedit); @@ -103,7 +108,12 @@ void OBJECT_OT_modifier_apply(struct wmOperatorType *ot); void OBJECT_OT_modifier_convert(struct wmOperatorType *ot); void OBJECT_OT_modifier_copy(struct wmOperatorType *ot); void OBJECT_OT_multires_subdivide(struct wmOperatorType *ot); -void OBJECT_OT_modifier_mdef_bind(struct wmOperatorType *ot); +void OBJECT_OT_meshdeform_bind(struct wmOperatorType *ot); +void OBJECT_OT_hook_reset(struct wmOperatorType *ot); +void OBJECT_OT_hook_recenter(struct wmOperatorType *ot); +void OBJECT_OT_hook_select(struct wmOperatorType *ot); +void OBJECT_OT_hook_assign(struct wmOperatorType *ot); +void OBJECT_OT_explode_refresh(struct wmOperatorType *ot); /* editconstraint.c */ void OBJECT_OT_constraint_add(struct wmOperatorType *ot); diff --git a/source/blender/editors/object/object_modifier.c b/source/blender/editors/object/object_modifier.c index 6b9f2db0d96..0b8fedd2eda 100644 --- a/source/blender/editors/object/object_modifier.c +++ b/source/blender/editors/object/object_modifier.c @@ -31,6 +31,7 @@ #include "MEM_guardedalloc.h" +#include "DNA_action_types.h" #include "DNA_curve_types.h" #include "DNA_mesh_types.h" #include "DNA_meshdata_types.h" @@ -39,8 +40,10 @@ #include "DNA_object_force.h" #include "DNA_scene_types.h" +#include "BLI_arithb.h" #include "BLI_listbase.h" +#include "BKE_action.h" #include "BKE_curve.h" #include "BKE_context.h" #include "BKE_depsgraph.h" @@ -226,7 +229,7 @@ int ED_object_modifier_convert(ReportList *reports, Scene *scene, Object *ob, Mo int totpart=0, totchild=0; if(md->type != eModifierType_ParticleSystem) return 0; - if(G.f & G_PARTICLEEDIT) return 0; + if(ob && ob->mode & OB_MODE_PARTICLE_EDIT) return 0; psys=((ParticleSystemModifierData *)md)->psys; part= psys->part; @@ -403,6 +406,11 @@ int ED_object_modifier_copy(ReportList *reports, Object *ob, ModifierData *md) /***************************** OPERATORS ****************************/ +static int modifier_poll(bContext *C) +{ + return (CTX_data_pointer_get_type(C, "modifier", &RNA_Modifier).data != NULL); +} + /************************ add modifier operator *********************/ static int modifier_add_exec(bContext *C, wmOperator *op) @@ -419,8 +427,46 @@ static int modifier_add_exec(bContext *C, wmOperator *op) return OPERATOR_FINISHED; } +static EnumPropertyItem *modifier_add_itemf(bContext *C, PointerRNA *ptr, int *free) +{ + EnumPropertyItem *item= NULL, *md_item; + ModifierTypeInfo *mti; + Object *ob; + int totitem= 0, a; + + if(!C) /* needed for docs */ + return modifier_type_items; + + ob= CTX_data_active_object(C); + + for(a=0; modifier_type_items[a].identifier; a++) { + md_item= &modifier_type_items[a]; + + if(md_item->identifier[0]) { + mti= modifierType_getInfo(md_item->value); + + if(mti->flags & eModifierTypeFlag_NoUserAdd) + continue; + + if(!((mti->flags & eModifierTypeFlag_AcceptsCVs) || + (ob->type==OB_MESH && (mti->flags & eModifierTypeFlag_AcceptsMesh)))) + continue; + } + + RNA_enum_item_add(&item, &totitem, md_item); + } + + RNA_enum_item_end(&item, &totitem); + + *free= 1; + + return item; +} + void OBJECT_OT_modifier_add(wmOperatorType *ot) { + PropertyRNA *prop; + /* identifiers */ ot->name= "Add Modifier"; ot->description = "Add a modifier to the active object."; @@ -429,14 +475,14 @@ void OBJECT_OT_modifier_add(wmOperatorType *ot) /* api callbacks */ ot->invoke= WM_menu_invoke; ot->exec= modifier_add_exec; - ot->poll= ED_operator_object_active; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; - /* XXX only some types should be here */ - RNA_def_enum(ot->srna, "type", modifier_type_items, 0, "Type", ""); + /* properties */ + prop= RNA_def_enum(ot->srna, "type", modifier_type_items, eModifierType_Subsurf, "Type", ""); + RNA_def_enum_funcs(prop, modifier_add_itemf); } /************************ remove modifier operator *********************/ @@ -448,7 +494,7 @@ static int modifier_remove_exec(bContext *C, wmOperator *op) Object *ob= ptr.id.data; ModifierData *md= ptr.data; - if(!ob || !md || !ED_object_modifier_remove(op->reports, scene, ob, md)) + if(!ED_object_modifier_remove(op->reports, scene, ob, md)) return OPERATOR_CANCELLED; WM_event_add_notifier(C, NC_OBJECT|ND_MODIFIER, ob); @@ -464,6 +510,7 @@ void OBJECT_OT_modifier_remove(wmOperatorType *ot) ot->poll= ED_operator_object_active; ot->exec= modifier_remove_exec; + ot->poll= modifier_poll; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; @@ -478,7 +525,7 @@ static int modifier_move_up_exec(bContext *C, wmOperator *op) Object *ob= ptr.id.data; ModifierData *md= ptr.data; - if(!ob || !md || !ED_object_modifier_move_up(op->reports, ob, md)) + if(!ED_object_modifier_move_up(op->reports, ob, md)) return OPERATOR_CANCELLED; DAG_object_flush_update(scene, ob, OB_RECALC_DATA); @@ -495,6 +542,7 @@ void OBJECT_OT_modifier_move_up(wmOperatorType *ot) ot->poll= ED_operator_object_active; ot->exec= modifier_move_up_exec; + ot->poll= modifier_poll; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; @@ -526,6 +574,7 @@ void OBJECT_OT_modifier_move_down(wmOperatorType *ot) ot->poll= ED_operator_object_active; ot->exec= modifier_move_down_exec; + ot->poll= modifier_poll; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; @@ -557,6 +606,7 @@ void OBJECT_OT_modifier_apply(wmOperatorType *ot) ot->poll= ED_operator_object_active; ot->exec= modifier_apply_exec; + ot->poll= modifier_poll; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; @@ -588,6 +638,7 @@ void OBJECT_OT_modifier_convert(wmOperatorType *ot) ot->poll= ED_operator_object_active; ot->exec= modifier_convert_exec; + ot->poll= modifier_poll; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; @@ -619,6 +670,7 @@ void OBJECT_OT_modifier_copy(wmOperatorType *ot) ot->poll= ED_operator_object_active; ot->exec= modifier_copy_exec; + ot->poll= modifier_poll; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; @@ -632,22 +684,26 @@ static int multires_subdivide_exec(bContext *C, wmOperator *op) Object *ob= ptr.id.data; MultiresModifierData *mmd= ptr.data; - if(mmd) { - multiresModifier_subdivide(mmd, ob, 1, 0, mmd->simple); - WM_event_add_notifier(C, NC_OBJECT|ND_MODIFIER, ob); - } + multiresModifier_subdivide(mmd, ob, 1, 0, mmd->simple); + WM_event_add_notifier(C, NC_OBJECT|ND_MODIFIER, ob); return OPERATOR_FINISHED; } +static int multires_subdivide_poll(bContext *C) +{ + return (CTX_data_pointer_get_type(C, "modifier", &RNA_MultiresModifier).data != NULL) && + CTX_data_edit_object(C) == NULL; +} + void OBJECT_OT_multires_subdivide(wmOperatorType *ot) { ot->name= "Multires Subdivide"; ot->description= "Add a new level of subdivision."; ot->idname= "OBJECT_OT_multires_subdivide"; - ot->poll= ED_operator_object_active; ot->exec= multires_subdivide_exec; + ot->poll= multires_subdivide_poll; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; @@ -655,12 +711,12 @@ void OBJECT_OT_multires_subdivide(wmOperatorType *ot) /************************ mdef bind operator *********************/ -static int modifier_mdef_bind_poll(bContext *C) +static int meshdeform_poll(bContext *C) { return CTX_data_pointer_get_type(C, "modifier", &RNA_MeshDeformModifier).data != NULL; } -static int modifier_mdef_bind_exec(bContext *C, wmOperator *op) +static int meshdeform_bind_exec(bContext *C, wmOperator *op) { Scene *scene= CTX_data_scene(C); PointerRNA ptr= CTX_data_pointer_get(C, "modifier"); @@ -711,41 +767,22 @@ static int modifier_mdef_bind_exec(bContext *C, wmOperator *op) return OPERATOR_FINISHED; } -void OBJECT_OT_modifier_mdef_bind(wmOperatorType *ot) +void OBJECT_OT_meshdeform_bind(wmOperatorType *ot) { /* identifiers */ ot->name= "Mesh Deform Bind"; ot->description = "Bind mesh to cage in mesh deform modifier."; - ot->idname= "OBJECT_OT_modifier_mdef_bind"; + ot->idname= "OBJECT_OT_meshdeform_bind"; /* api callbacks */ - ot->poll= modifier_mdef_bind_poll; - ot->exec= modifier_mdef_bind_exec; + ot->poll= meshdeform_poll; + ot->exec= meshdeform_bind_exec; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; } #if 0 -static void modifiers_add(void *ob_v, int type) -{ - Object *ob = ob_v; - ModifierTypeInfo *mti = modifierType_getInfo(type); - - if (mti->flags&eModifierTypeFlag_RequiresOriginalData) { - ModifierData *md = ob->modifiers.first; - - while (md && modifierType_getInfo(md->type)->type==eModifierTypeType_OnlyDeform) { - md = md->next; - } - - BLI_insertlinkbefore(&ob->modifiers, md, modifier_new(type)); - } else { - BLI_addtail(&ob->modifiers, modifier_new(type)); - } - ED_undo_push("Add modifier"); -} - typedef struct MenuEntry { char *name; int ID; @@ -797,89 +834,189 @@ static uiBlock *modifiers_add_menu(void *ob_v) } #endif -#if 0 -static void modifiers_clearHookOffset(bContext *C, void *ob_v, void *md_v) +/******************** hook operators ************************/ + +static int hook_poll(bContext *C) { - Object *ob = ob_v; - ModifierData *md = md_v; - HookModifierData *hmd = (HookModifierData*) md; - - if (hmd->object) { - Mat4Invert(hmd->object->imat, hmd->object->obmat); - Mat4MulSerie(hmd->parentinv, hmd->object->imat, ob->obmat, NULL, NULL, NULL, NULL, NULL, NULL); - ED_undo_push(C, "Clear hook offset"); + return CTX_data_pointer_get_type(C, "modifier", &RNA_HookModifier).data != NULL; +} + +static int hook_reset_exec(bContext *C, wmOperator *op) +{ + Scene *scene= CTX_data_scene(C); + PointerRNA ptr= CTX_data_pointer_get_type(C, "modifier", &RNA_HookModifier); + Object *ob= ptr.id.data; + HookModifierData *hmd= ptr.data; + + if(hmd->object) { + bPoseChannel *pchan= get_pose_channel(hmd->object->pose, hmd->subtarget); + + if(hmd->subtarget[0] && pchan) { + float imat[4][4], mat[4][4]; + + /* calculate the world-space matrix for the pose-channel target first, then carry on as usual */ + Mat4MulMat4(mat, pchan->pose_mat, hmd->object->obmat); + + Mat4Invert(imat, mat); + Mat4MulSerie(hmd->parentinv, imat, ob->obmat, NULL, NULL, NULL, NULL, NULL, NULL); + } + else { + Mat4Invert(hmd->object->imat, hmd->object->obmat); + Mat4MulSerie(hmd->parentinv, hmd->object->imat, ob->obmat, NULL, NULL, NULL, NULL, NULL, NULL); + } } + + DAG_object_flush_update(scene, ob, OB_RECALC_DATA); + WM_event_add_notifier(C, NC_OBJECT|ND_MODIFIER, ob); + + return OPERATOR_FINISHED; } -static void modifiers_cursorHookCenter(bContext *C, void *ob_v, void *md_v) +void OBJECT_OT_hook_reset(wmOperatorType *ot) { - /* XXX - Object *ob = ob_v; - ModifierData *md = md_v; - HookModifierData *hmd = (HookModifierData*) md; + ot->name= "Hook Reset"; + ot->description= "Recalculate and and clear offset transformation."; + ot->idname= "OBJECT_OT_hook_reset"; - if(G.vd) { - float *curs = give_cursor(); - float bmat[3][3], imat[3][3]; + ot->exec= hook_reset_exec; + ot->poll= hook_poll; + + /* flags */ + ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; +} - where_is_object(ob); +static int hook_recenter_exec(bContext *C, wmOperator *op) +{ + Scene *scene= CTX_data_scene(C); + PointerRNA ptr= CTX_data_pointer_get_type(C, "modifier", &RNA_HookModifier); + Object *ob= ptr.id.data; + HookModifierData *hmd= ptr.data; + float bmat[3][3], imat[3][3]; + + Mat3CpyMat4(bmat, ob->obmat); + Mat3Inv(imat, bmat); + + VECSUB(hmd->cent, scene->cursor, ob->obmat[3]); + Mat3MulVecfl(imat, hmd->cent); + + DAG_object_flush_update(scene, ob, OB_RECALC_DATA); + WM_event_add_notifier(C, NC_OBJECT|ND_MODIFIER, ob); - Mat3CpyMat4(bmat, ob->obmat); - Mat3Inv(imat, bmat); + return OPERATOR_FINISHED; +} - curs= give_cursor(); - hmd->cent[0]= curs[0]-ob->obmat[3][0]; - hmd->cent[1]= curs[1]-ob->obmat[3][1]; - hmd->cent[2]= curs[2]-ob->obmat[3][2]; - Mat3MulVecfl(imat, hmd->cent); +void OBJECT_OT_hook_recenter(wmOperatorType *ot) +{ + ot->name= "Hook Recenter"; + ot->description= "Set hook center to cursor position."; + ot->idname= "OBJECT_OT_hook_recenter"; - ED_undo_push(C, "Hook cursor center"); - }*/ + ot->exec= hook_recenter_exec; + ot->poll= hook_poll; + + /* flags */ + ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; } -static void modifiers_selectHook(bContext *C, void *ob_v, void *md_v) +static int hook_select_exec(bContext *C, wmOperator *op) { - /* XXX ModifierData *md = md_v; - HookModifierData *hmd = (HookModifierData*) md; + PointerRNA ptr= CTX_data_pointer_get_type(C, "modifier", &RNA_HookModifier); + Object *ob= ptr.id.data; + HookModifierData *hmd= ptr.data; + + object_hook_select(ob, hmd); - hook_select(hmd);*/ + WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, ob); + + return OPERATOR_FINISHED; +} + +void OBJECT_OT_hook_select(wmOperatorType *ot) +{ + ot->name= "Hook Select"; + ot->description= "Selects effected vertices on mesh."; + ot->idname= "OBJECT_OT_hook_select"; + + ot->exec= hook_select_exec; + ot->poll= hook_poll; + + /* flags */ + ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; } -static void modifiers_reassignHook(bContext *C, void *ob_v, void *md_v) +static int hook_assign_exec(bContext *C, wmOperator *op) { - /* XXX ModifierData *md = md_v; - HookModifierData *hmd = (HookModifierData*) md; + Scene *scene= CTX_data_scene(C); + PointerRNA ptr= CTX_data_pointer_get_type(C, "modifier", &RNA_HookModifier); + Object *ob= ptr.id.data; + HookModifierData *hmd= ptr.data; float cent[3]; - int *indexar, tot, ok; char name[32]; + int *indexar, tot; - ok= hook_getIndexArray(&tot, &indexar, name, cent); + if(!object_hook_index_array(ob, &tot, &indexar, name, cent)) { + BKE_report(op->reports, RPT_WARNING, "Requires selected vertices or active vertex group"); + return OPERATOR_CANCELLED; + } - if (!ok) { - uiPupMenuError(C, "Requires selected vertices or active Vertex Group"); - } else { - if (hmd->indexar) { - MEM_freeN(hmd->indexar); - } + if(hmd->indexar) + MEM_freeN(hmd->indexar); - VECCOPY(hmd->cent, cent); - hmd->indexar = indexar; - hmd->totindex = tot; - }*/ + VECCOPY(hmd->cent, cent); + hmd->indexar= indexar; + hmd->totindex= tot; + + DAG_object_flush_update(scene, ob, OB_RECALC_DATA); + WM_event_add_notifier(C, NC_OBJECT|ND_MODIFIER, ob); + + return OPERATOR_FINISHED; } -void modifiers_explodeFacepa(bContext *C, void *arg1, void *arg2) +void OBJECT_OT_hook_assign(wmOperatorType *ot) { - ExplodeModifierData *emd=arg1; + ot->name= "Hook Assign"; + ot->description= "Reassigns selected vertices to hook."; + ot->idname= "OBJECT_OT_hook_assign"; - emd->flag |= eExplodeFlag_CalcFaces; + ot->exec= hook_assign_exec; + ot->poll= hook_poll; + + /* flags */ + ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; } -void modifiers_explodeDelVg(bContext *C, void *arg1, void *arg2) +/****************** explode refresh operator *********************/ + +static int explode_refresh_poll(bContext *C) { - ExplodeModifierData *emd=arg1; - emd->vgroup = 0; + return CTX_data_pointer_get_type(C, "modifier", &RNA_ExplodeModifier).data != NULL; } -#endif +static int explode_refresh_exec(bContext *C, wmOperator *op) +{ + Scene *scene= CTX_data_scene(C); + PointerRNA ptr= CTX_data_pointer_get_type(C, "modifier", &RNA_ExplodeModifier); + Object *ob= ptr.id.data; + ExplodeModifierData *emd= ptr.data; + + emd->flag |= eExplodeFlag_CalcFaces; + + DAG_object_flush_update(scene, ob, OB_RECALC_DATA); + WM_event_add_notifier(C, NC_OBJECT|ND_MODIFIER, ob); + + return OPERATOR_FINISHED; +} + +void OBJECT_OT_explode_refresh(wmOperatorType *ot) +{ + ot->name= "Explode Refresh"; + ot->description= "Refresh data in the Explode modifier."; + ot->idname= "OBJECT_OT_explode_refresh"; + + ot->exec= explode_refresh_exec; + ot->poll= explode_refresh_poll; + + /* flags */ + ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; +} diff --git a/source/blender/editors/object/object_ops.c b/source/blender/editors/object/object_ops.c index c1509e78502..239b162c14f 100644 --- a/source/blender/editors/object/object_ops.c +++ b/source/blender/editors/object/object_ops.c @@ -65,6 +65,7 @@ void ED_operatortypes_object(void) { wmOperatorType *ot; + WM_operatortype_append(OBJECT_OT_mode_set); WM_operatortype_append(OBJECT_OT_editmode_toggle); WM_operatortype_append(OBJECT_OT_posemode_toggle); WM_operatortype_append(OBJECT_OT_parent_set); @@ -117,7 +118,12 @@ void ED_operatortypes_object(void) WM_operatortype_append(OBJECT_OT_modifier_convert); WM_operatortype_append(OBJECT_OT_modifier_copy); WM_operatortype_append(OBJECT_OT_multires_subdivide); - WM_operatortype_append(OBJECT_OT_modifier_mdef_bind); + WM_operatortype_append(OBJECT_OT_meshdeform_bind); + WM_operatortype_append(OBJECT_OT_hook_reset); + WM_operatortype_append(OBJECT_OT_hook_recenter); + WM_operatortype_append(OBJECT_OT_hook_select); + WM_operatortype_append(OBJECT_OT_hook_assign); + WM_operatortype_append(OBJECT_OT_explode_refresh); WM_operatortype_append(OBJECT_OT_constraint_add); WM_operatortype_append(OBJECT_OT_constraint_add_with_targets); @@ -161,10 +167,19 @@ void ED_operatortypes_object(void) void ED_keymap_object(wmWindowManager *wm) { ListBase *keymap= WM_keymap_listbase(wm, "Object Non-modal", 0, 0); + wmKeymapItem *kmi; /* Note: this keymap works disregarding mode */ WM_keymap_add_item(keymap, "OBJECT_OT_editmode_toggle", TABKEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "OBJECT_OT_posemode_toggle", TABKEY, KM_PRESS, KM_CTRL, 0); + + kmi = WM_keymap_add_item(keymap, "OBJECT_OT_mode_set", VKEY, KM_PRESS, 0, 0); + RNA_enum_set(kmi->ptr, "mode", OB_MODE_VERTEX_PAINT); + RNA_boolean_set(kmi->ptr, "toggle", 1); + kmi = WM_keymap_add_item(keymap, "OBJECT_OT_mode_set", TABKEY, KM_PRESS, KM_CTRL, 0); + RNA_enum_set(kmi->ptr, "mode", OB_MODE_WEIGHT_PAINT); + RNA_boolean_set(kmi->ptr, "toggle", 1); + WM_keymap_add_item(keymap, "OBJECT_OT_center_set", CKEY, KM_PRESS, KM_ALT|KM_SHIFT|KM_CTRL, 0); /* Note: this keymap gets disabled in non-objectmode, */ diff --git a/source/blender/editors/object/object_vgroup.c b/source/blender/editors/object/object_vgroup.c index 3d3e29bcc22..154ab14df60 100644 --- a/source/blender/editors/object/object_vgroup.c +++ b/source/blender/editors/object/object_vgroup.c @@ -57,6 +57,7 @@ #include "BKE_global.h" #include "BKE_lattice.h" #include "BKE_mesh.h" +#include "BKE_paint.h" #include "BKE_utildefines.h" #include "RNA_access.h" @@ -1028,11 +1029,11 @@ void vgroup_assign_with_menu(Scene *scene, Object *ob) switch (mode) { case 1: /* add to new group */ add_defgroup(ob); - assign_verts_defgroup(ob, wp->brush->alpha); + assign_verts_defgroup(ob, paint_brush(&wp->paint)->alpha); BIF_undo_push("Assign to vertex group"); break; case 2: /* add to current group */ - assign_verts_defgroup(ob, wp->brush->alpha); + assign_verts_defgroup(ob, paint_brush(&wp->paint)->alpha); BIF_undo_push("Assign to vertex group"); break; case 3: /* remove from current group */ diff --git a/source/blender/editors/physics/ed_pointcache.c b/source/blender/editors/physics/ed_pointcache.c index 5d0a6d21fac..917e2b40d72 100644 --- a/source/blender/editors/physics/ed_pointcache.c +++ b/source/blender/editors/physics/ed_pointcache.c @@ -61,7 +61,6 @@ static int cache_break_test(void *cbd) { return G.afbreek==1; } -/**************************** general **********************************/ static int ptcache_bake_all_poll(bContext *C) { Scene *scene= CTX_data_scene(C); @@ -130,7 +129,7 @@ void PTCACHE_OT_bake_all(wmOperatorType *ot) /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; - RNA_def_boolean(ot->srna, "bake", 0, "Bake", ""); + RNA_def_boolean(ot->srna, "bake", 1, "Bake", ""); } void PTCACHE_OT_free_bake_all(wmOperatorType *ot) { @@ -145,32 +144,25 @@ void PTCACHE_OT_free_bake_all(wmOperatorType *ot) /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; } - -/**************************** softbody **********************************/ -static int ptcache_bake_softbody_poll(bContext *C) -{ - Scene *scene= CTX_data_scene(C); - Object *ob= CTX_data_active_object(C); - SoftBody *sb = ob->soft; - - if(!scene || !ob || ob->id.lib || !sb) - return 0; - - return 1; -} - -static int ptcache_bake_softbody_exec(bContext *C, wmOperator *op) +static int ptcache_bake_exec(bContext *C, wmOperator *op) { - Scene *scene= CTX_data_scene(C); - Object *ob= CTX_data_active_object(C); - SoftBody *sb = ob->soft; - PTCacheID pid; + Scene *scene = CTX_data_scene(C); + PointerRNA ptr= CTX_data_pointer_get_type(C, "PointCache", &RNA_PointCache); + Object *ob= ptr.id.data; + PointCache *cache= ptr.data; PTCacheBaker baker; + PTCacheID *pid; + ListBase pidlist; - BKE_ptcache_id_from_softbody(&pid, ob, sb); + BKE_ptcache_ids_from_object(&pidlist, ob); + + for(pid=pidlist.first; pid; pid=pid->next) { + if(pid->cache == cache) + break; + } baker.scene = scene; - baker.pid = &pid; + baker.pid = pid; baker.bake = RNA_boolean_get(op->ptr, "bake"); baker.render = 0; baker.anim_init = 0; @@ -182,305 +174,160 @@ static int ptcache_bake_softbody_exec(bContext *C, wmOperator *op) BKE_ptcache_make_cache(&baker); - WM_event_add_notifier(C, NC_SCENE|ND_FRAME, scene); - - return OPERATOR_FINISHED; -} -static int ptcache_free_bake_softbody_exec(bContext *C, wmOperator *op) -{ - Scene *scene= CTX_data_scene(C); - Object *ob= CTX_data_active_object(C); - SoftBody *sb = ob->soft; - PTCacheID pid; - - BKE_ptcache_id_from_softbody(&pid, ob, sb); - pid.cache->flag &= ~PTCACHE_BAKED; + BLI_freelistN(&pidlist); WM_event_add_notifier(C, NC_SCENE|ND_FRAME, scene); return OPERATOR_FINISHED; } -void PTCACHE_OT_cache_softbody(wmOperatorType *ot) +static int ptcache_free_bake_exec(bContext *C, wmOperator *op) { - /* identifiers */ - ot->name= "Bake Softbody"; - ot->idname= "PTCACHE_OT_cache_softbody"; + PointerRNA ptr= CTX_data_pointer_get_type(C, "PointCache", &RNA_PointCache); + PointCache *cache= ptr.data; - /* api callbacks */ - ot->exec= ptcache_bake_softbody_exec; - ot->poll= ptcache_bake_softbody_poll; - - /* flags */ - ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; - - RNA_def_boolean(ot->srna, "bake", 0, "Bake", ""); -} -void PTCACHE_OT_free_bake_softbody(wmOperatorType *ot) -{ - /* identifiers */ - ot->name= "Free SoftBody Bake"; - ot->idname= "PTCACHE_OT_free_bake_softbody"; - - /* api callbacks */ - ot->exec= ptcache_free_bake_softbody_exec; - ot->poll= ptcache_bake_softbody_poll; - - /* flags */ - ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; -} -static int ptcache_bake_from_softbody_cache_exec(bContext *C, wmOperator *op) -{ - Object *ob= CTX_data_active_object(C); - SoftBody *sb = ob->soft; - PTCacheID pid; - - BKE_ptcache_id_from_softbody(&pid, ob, sb); - pid.cache->flag |= PTCACHE_BAKED; + cache->flag &= ~PTCACHE_BAKED; return OPERATOR_FINISHED; } -void PTCACHE_OT_bake_from_softbody_cache(wmOperatorType *ot) +static int ptcache_bake_from_cache_exec(bContext *C, wmOperator *op) { - /* identifiers */ - ot->name= "Bake From Cache"; - ot->idname= "PTCACHE_OT_bake_from_softbody_cache"; - - /* api callbacks */ - ot->exec= ptcache_bake_from_softbody_cache_exec; - ot->poll= ptcache_bake_softbody_poll; - - /* flags */ - ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; -} - -/**************************** cloth **********************************/ -static int ptcache_bake_cloth_poll(bContext *C) -{ - Scene *scene= CTX_data_scene(C); - Object *ob= CTX_data_active_object(C); - ClothModifierData *clmd = (ClothModifierData *)modifiers_findByType(ob, eModifierType_Cloth); - - if(!scene || !ob || ob->id.lib || !clmd) - return 0; + PointerRNA ptr= CTX_data_pointer_get_type(C, "PointCache", &RNA_PointCache); + PointCache *cache= ptr.data; - return 1; -} - -static int ptcache_bake_cloth_exec(bContext *C, wmOperator *op) -{ - Scene *scene= CTX_data_scene(C); - Object *ob= CTX_data_active_object(C); - ClothModifierData *clmd = (ClothModifierData *)modifiers_findByType(ob, eModifierType_Cloth); - PTCacheID pid; - PTCacheBaker baker; - - BKE_ptcache_id_from_cloth(&pid, ob, clmd); - - baker.scene = scene; - baker.pid = &pid; - baker.bake = RNA_boolean_get(op->ptr, "bake"); - baker.render = 0; - baker.anim_init = 0; - baker.quick_step = 1; - baker.break_test = cache_break_test; - baker.break_data = NULL; - baker.progressbar = (void (*)(void *, int))WM_timecursor; - baker.progresscontext = CTX_wm_window(C); - - BKE_ptcache_make_cache(&baker); - - WM_event_add_notifier(C, NC_SCENE|ND_FRAME, scene); + cache->flag |= PTCACHE_BAKED; return OPERATOR_FINISHED; } -static int ptcache_free_bake_cloth_exec(bContext *C, wmOperator *op) -{ - Scene *scene= CTX_data_scene(C); - Object *ob= CTX_data_active_object(C); - ClothModifierData *clmd = (ClothModifierData *)modifiers_findByType(ob, eModifierType_Cloth); - PTCacheID pid; - - BKE_ptcache_id_from_cloth(&pid, ob, clmd); - pid.cache->flag &= ~PTCACHE_BAKED; - - WM_event_add_notifier(C, NC_SCENE|ND_FRAME, scene); - - return OPERATOR_FINISHED; -} -void PTCACHE_OT_cache_cloth(wmOperatorType *ot) +void PTCACHE_OT_bake(wmOperatorType *ot) { /* identifiers */ - ot->name= "Bake Cloth"; - ot->idname= "PTCACHE_OT_cache_cloth"; + ot->name= "Bake Physics"; + ot->idname= "PTCACHE_OT_bake"; /* api callbacks */ - ot->exec= ptcache_bake_cloth_exec; - ot->poll= ptcache_bake_cloth_poll; + ot->exec= ptcache_bake_exec; + ot->poll= ptcache_bake_all_poll; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; - RNA_def_boolean(ot->srna, "bake", 0, "Bake", ""); + RNA_def_boolean(ot->srna, "bake", 1, "Bake", ""); } -void PTCACHE_OT_free_bake_cloth(wmOperatorType *ot) +void PTCACHE_OT_free_bake(wmOperatorType *ot) { /* identifiers */ - ot->name= "Free Cloth Bake"; - ot->idname= "PTCACHE_OT_free_bake_cloth"; + ot->name= "Free Physics Bake"; + ot->idname= "PTCACHE_OT_free_bake"; /* api callbacks */ - ot->exec= ptcache_free_bake_cloth_exec; - ot->poll= ptcache_bake_cloth_poll; + ot->exec= ptcache_free_bake_exec; + ot->poll= ptcache_bake_all_poll; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; } -static int ptcache_bake_from_cloth_cache_exec(bContext *C, wmOperator *op) -{ - Object *ob= CTX_data_active_object(C); - ClothModifierData *clmd = (ClothModifierData *)modifiers_findByType(ob, eModifierType_Cloth); - PTCacheID pid; - - BKE_ptcache_id_from_cloth(&pid, ob, clmd); - pid.cache->flag |= PTCACHE_BAKED; - - return OPERATOR_FINISHED; -} -void PTCACHE_OT_bake_from_cloth_cache(wmOperatorType *ot) +void PTCACHE_OT_bake_from_cache(wmOperatorType *ot) { /* identifiers */ ot->name= "Bake From Cache"; - ot->idname= "PTCACHE_OT_bake_from_cloth_cache"; + ot->idname= "PTCACHE_OT_bake_from_cache"; /* api callbacks */ - ot->exec= ptcache_bake_from_cloth_cache_exec; - ot->poll= ptcache_bake_cloth_poll; + ot->exec= ptcache_bake_from_cache_exec; + ot->poll= ptcache_bake_all_poll; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; } -/**************************** particles **********************************/ -static int ptcache_bake_particle_system_poll(bContext *C) +static int ptcache_add_new_exec(bContext *C, wmOperator *op) { - Scene *scene= CTX_data_scene(C); - Object *ob= CTX_data_active_object(C); + Scene *scene = CTX_data_scene(C); + PointerRNA ptr= CTX_data_pointer_get_type(C, "PointCache", &RNA_PointCache); + Object *ob= ptr.id.data; + PointCache *cache= ptr.data; + PTCacheID *pid; + ListBase pidlist; - if(!scene || !ob || ob->id.lib) - return 0; + BKE_ptcache_ids_from_object(&pidlist, ob); - return (ob->particlesystem.first != NULL); -} - -static int ptcache_bake_particle_system_exec(bContext *C, wmOperator *op) -{ - Scene *scene= CTX_data_scene(C); - Object *ob= CTX_data_active_object(C); - ParticleSystem *psys =psys_get_current(ob); - PTCacheID pid; - PTCacheBaker baker; - - BKE_ptcache_id_from_particles(&pid, ob, psys); - - baker.scene = scene; - baker.pid = &pid; - baker.bake = RNA_boolean_get(op->ptr, "bake"); - baker.render = 0; - baker.anim_init = 0; - baker.quick_step = 1; - baker.break_test = cache_break_test; - baker.break_data = NULL; - baker.progressbar = (void (*)(void *, int))WM_timecursor; - baker.progresscontext = CTX_wm_window(C); + for(pid=pidlist.first; pid; pid=pid->next) { + if(pid->cache == cache) { + *(pid->cache_ptr) = BKE_ptcache_add(pid->ptcaches); + break; + } + } - BKE_ptcache_make_cache(&baker); + BLI_freelistN(&pidlist); WM_event_add_notifier(C, NC_SCENE|ND_FRAME, scene); return OPERATOR_FINISHED; } -static int ptcache_free_bake_particle_system_exec(bContext *C, wmOperator *op) +static int ptcache_remove_exec(bContext *C, wmOperator *op) { - Scene *scene= CTX_data_scene(C); - Object *ob= CTX_data_active_object(C); - ParticleSystem *psys= psys_get_current(ob); - PTCacheID pid; + PointerRNA ptr= CTX_data_pointer_get_type(C, "PointCache", &RNA_PointCache); + Object *ob= ptr.id.data; + PointCache *cache= ptr.data; + PTCacheID *pid; + ListBase pidlist; - BKE_ptcache_id_from_particles(&pid, ob, psys); - psys->pointcache->flag &= ~PTCACHE_BAKED; + BKE_ptcache_ids_from_object(&pidlist, ob); + + for(pid=pidlist.first; pid; pid=pid->next) { + if(pid->cache == cache) { + if(pid->ptcaches->first == pid->ptcaches->last) + continue; /* don't delete last cache */ - WM_event_add_notifier(C, NC_SCENE|ND_FRAME, scene); + BLI_remlink(pid->ptcaches, pid->cache); + BKE_ptcache_free(pid->cache); + *(pid->cache_ptr) = pid->ptcaches->first; - return OPERATOR_FINISHED; -} -void PTCACHE_OT_cache_particle_system(wmOperatorType *ot) -{ - /* identifiers */ - ot->name= "Bake Particles"; - ot->idname= "PTCACHE_OT_cache_particle_system"; - - /* api callbacks */ - ot->exec= ptcache_bake_particle_system_exec; - ot->poll= ptcache_bake_particle_system_poll; + break; + } + } - /* flags */ - ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; + BLI_freelistN(&pidlist); - RNA_def_boolean(ot->srna, "bake", 0, "Bake", ""); + return OPERATOR_FINISHED; } -void PTCACHE_OT_free_bake_particle_system(wmOperatorType *ot) +void PTCACHE_OT_add_new(wmOperatorType *ot) { /* identifiers */ - ot->name= "Free Particles Bake"; - ot->idname= "PTCACHE_OT_free_bake_particle_system"; + ot->name= "Add new cache"; + ot->idname= "PTCACHE_OT_add_new"; /* api callbacks */ - ot->exec= ptcache_free_bake_particle_system_exec; - ot->poll= ptcache_bake_particle_system_poll; + ot->exec= ptcache_add_new_exec; + ot->poll= ptcache_bake_all_poll; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; } -static int ptcache_bake_from_particles_cache_exec(bContext *C, wmOperator *op) -{ - Object *ob= CTX_data_active_object(C); - ParticleSystem *psys= psys_get_current(ob); - PTCacheID pid; - - BKE_ptcache_id_from_particles(&pid, ob, psys); - psys->pointcache->flag |= PTCACHE_BAKED; - - return OPERATOR_FINISHED; -} -void PTCACHE_OT_bake_from_particles_cache(wmOperatorType *ot) +void PTCACHE_OT_remove(wmOperatorType *ot) { /* identifiers */ - ot->name= "Bake From Cache"; - ot->idname= "PTCACHE_OT_bake_from_particles_cache"; + ot->name= "Delete current cache"; + ot->idname= "PTCACHE_OT_remove"; /* api callbacks */ - ot->exec= ptcache_bake_from_particles_cache_exec; - ot->poll= ptcache_bake_particle_system_poll; + ot->exec= ptcache_remove_exec; + ot->poll= ptcache_bake_all_poll; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; } - /**************************** registration **********************************/ void ED_operatortypes_pointcache(void) { WM_operatortype_append(PTCACHE_OT_bake_all); WM_operatortype_append(PTCACHE_OT_free_bake_all); - WM_operatortype_append(PTCACHE_OT_cache_particle_system); - WM_operatortype_append(PTCACHE_OT_free_bake_particle_system); - WM_operatortype_append(PTCACHE_OT_bake_from_particles_cache); - WM_operatortype_append(PTCACHE_OT_cache_cloth); - WM_operatortype_append(PTCACHE_OT_free_bake_cloth); - WM_operatortype_append(PTCACHE_OT_bake_from_cloth_cache); - WM_operatortype_append(PTCACHE_OT_cache_softbody); - WM_operatortype_append(PTCACHE_OT_free_bake_softbody); - WM_operatortype_append(PTCACHE_OT_bake_from_softbody_cache); + WM_operatortype_append(PTCACHE_OT_bake); + WM_operatortype_append(PTCACHE_OT_free_bake); + WM_operatortype_append(PTCACHE_OT_bake_from_cache); + WM_operatortype_append(PTCACHE_OT_add_new); + WM_operatortype_append(PTCACHE_OT_remove); } //void ED_keymap_pointcache(wmWindowManager *wm) diff --git a/source/blender/editors/physics/editparticle.c b/source/blender/editors/physics/editparticle.c index 499162ecdb8..faf03d1f0e2 100644 --- a/source/blender/editors/physics/editparticle.c +++ b/source/blender/editors/physics/editparticle.c @@ -104,21 +104,13 @@ static int PE_poll(bContext *C) psys= PE_get_current(scene, ob); - return (psys && psys->edit && (G.f & G_PARTICLEEDIT)); + return (psys && psys->edit && (ob && ob->mode & OB_MODE_PARTICLE_EDIT)); } static int PE_poll_3dview(bContext *C) { - Scene *scene= CTX_data_scene(C); - Object *ob= CTX_data_active_object(C); - ParticleSystem *psys; - - if(!scene || !ob || !CTX_wm_region_view3d(C)) - return 0; - - psys= PE_get_current(scene, ob); - - return (psys && psys->edit && (G.f & G_PARTICLEEDIT)); + return PE_poll(C) && CTX_wm_area(C)->spacetype == SPACE_VIEW3D && + CTX_wm_region(C)->regiontype == RGN_TYPE_WINDOW; } static void PE_free_particle_edit(ParticleSystem *psys) @@ -164,7 +156,7 @@ static void PE_free_particle_edit(ParticleSystem *psys) int PE_can_edit(ParticleSystem *psys) { - return (psys && psys->edit && (G.f & G_PARTICLEEDIT)); + return (psys && psys->edit); } ParticleEditSettings *PE_settings(Scene *scene) @@ -194,7 +186,7 @@ ParticleSystem *PE_get_current(Scene *scene, Object *ob) /* this happens when Blender is started with particle * edit mode enabled XXX there's a draw error then? */ - if(psys && psys_check_enabled(ob, psys) && (ob == OBACT) && (G.f & G_PARTICLEEDIT)) + if(psys && psys_check_enabled(ob, psys) && (ob == OBACT) && (ob->mode & OB_MODE_PARTICLE_EDIT)) if(psys->part->type == PART_HAIR && psys->flag & PSYS_EDITED) if(psys->edit == NULL) PE_create_particle_edit(scene, ob, psys); @@ -2269,7 +2261,7 @@ static void toggle_particle_cursor(bContext *C, int enable) pset->paintcursor = NULL; } else if(enable) - pset->paintcursor= WM_paint_cursor_activate(CTX_wm_manager(C), PE_poll, brush_drawcursor, NULL); + pset->paintcursor= WM_paint_cursor_activate(CTX_wm_manager(C), PE_poll_3dview, brush_drawcursor, NULL); } /********************* radial control operator *********************/ @@ -3076,11 +3068,13 @@ static void brush_edit_apply(bContext *C, wmOperator *op, PointerRNA *itemptr) ParticleSystemModifierData *psmd= psys_get_modifier(ob, psys); ParticleBrushData *brush= &pset->brush[pset->brushtype]; ARegion *ar= CTX_wm_region(C); - float vec1[3], vec2[3]; + float vec1[3], vec2[3], mousef[2]; short mval[2], mvalo[2]; int flip, mouse[2], dx, dy, removed= 0, selected= 0; - RNA_int_get_array(itemptr, "mouse", mouse); + RNA_float_get_array(itemptr, "mouse", mousef); + mouse[0] = mousef[0]; + mouse[1] = mousef[1]; flip= RNA_boolean_get(itemptr, "flip"); if(bedit->first) { @@ -3291,7 +3285,7 @@ static void brush_edit_apply_event(bContext *C, wmOperator *op, wmEvent *event) { ARegion *ar= CTX_wm_region(C); PointerRNA itemptr; - int mouse[2]; + float mouse[2]; mouse[0]= event->x - ar->winrct.xmin; mouse[1]= event->y - ar->winrct.ymin; @@ -3299,7 +3293,7 @@ static void brush_edit_apply_event(bContext *C, wmOperator *op, wmEvent *event) /* fill in stroke */ RNA_collection_add(op->ptr, "stroke", &itemptr); - RNA_int_set_array(&itemptr, "mouse", mouse); + RNA_float_set_array(&itemptr, "mouse", mouse); RNA_boolean_set(&itemptr, "flip", event->shift != 0); // XXX hardcoded /* apply */ @@ -3710,7 +3704,7 @@ static int particle_edit_toggle_exec(bContext *C, wmOperator *op) psys->flag |= PSYS_CURRENT; } - if(!(G.f & G_PARTICLEEDIT)) { + if(!(ob->mode & OB_MODE_PARTICLE_EDIT)) { if(psys && psys->part->type == PART_HAIR && psys->flag & PSYS_EDITED) { if(psys_check_enabled(ob, psys)) { if(psys->edit==NULL) @@ -3720,12 +3714,12 @@ static int particle_edit_toggle_exec(bContext *C, wmOperator *op) } } - G.f |= G_PARTICLEEDIT; + ob->mode |= OB_MODE_PARTICLE_EDIT; toggle_particle_cursor(C, 1); WM_event_add_notifier(C, NC_SCENE|ND_MODE|NS_MODE_PARTICLE, NULL); } else { - G.f &= ~G_PARTICLEEDIT; + ob->mode &= ~OB_MODE_PARTICLE_EDIT; toggle_particle_cursor(C, 0); WM_event_add_notifier(C, NC_SCENE|ND_MODE|NS_MODE_OBJECT, NULL); } @@ -3773,7 +3767,7 @@ static int set_editable_exec(bContext *C, wmOperator *op) if(psys_check_enabled(ob, psys)) { psys->flag |= PSYS_EDITED; - if(G.f & G_PARTICLEEDIT) + if(ob->mode & OB_MODE_PARTICLE_EDIT) PE_create_particle_edit(scene, ob, psys); } else @@ -3814,7 +3808,7 @@ void PE_change_act(void *ob_v, void *act_v) psys->flag |= PSYS_CURRENT; if(psys_check_enabled(ob, psys)) { - if(G.f & G_PARTICLEEDIT && !psys->edit) + if(ob->mode & OB_MODE_PARTICLE_EDIT && !psys->edit) PE_create_particle_edit(scene, ob, psys); psys_update_world_cos(ob, psys); } @@ -3832,7 +3826,7 @@ void PE_change_act_psys(Scene *scene, Object *ob, ParticleSystem *psys) psys->flag |= PSYS_CURRENT; if(psys_check_enabled(ob, psys)) { - if(G.f & G_PARTICLEEDIT && !psys->edit) + if(ob->mode & OB_MODE_PARTICLE_EDIT && !psys->edit) PE_create_particle_edit(scene, ob, psys); psys_update_world_cos(ob, psys); diff --git a/source/blender/editors/physics/physics_boids.c b/source/blender/editors/physics/physics_boids.c index 2d3b11080e7..148359068ad 100644 --- a/source/blender/editors/physics/physics_boids.c +++ b/source/blender/editors/physics/physics_boids.c @@ -249,7 +249,6 @@ void BOID_OT_boidrule_move_down(wmOperatorType *ot) /************************ add/del boid state operators *********************/ static int boidstate_add_exec(bContext *C, wmOperator *op) { - Scene *scene = CTX_data_scene(C); PointerRNA ptr = CTX_data_pointer_get_type(C, "particle_system", &RNA_ParticleSystem); ParticleSystem *psys= ptr.data; Object *ob= ptr.id.data; @@ -344,7 +343,6 @@ void BOID_OT_boidstate_del(wmOperatorType *ot) /************************ move up/down boid state operators *********************/ static int boidstate_move_up_exec(bContext *C, wmOperator *op) { - Scene *scene= CTX_data_scene(C); PointerRNA ptr = CTX_data_pointer_get_type(C, "particle_system", &RNA_ParticleSystem); ParticleSystem *psys= ptr.data; Object *ob = ptr.id.data; @@ -385,7 +383,6 @@ static int boidstate_move_down_exec(bContext *C, wmOperator *op) Scene *scene= CTX_data_scene(C); PointerRNA ptr = CTX_data_pointer_get_type(C, "particle_system", &RNA_ParticleSystem); ParticleSystem *psys= ptr.data; - Object *ob = ptr.id.data; BoidSettings *boids; BoidState *state; @@ -430,4 +427,4 @@ void ED_operatortypes_boids(void) WM_operatortype_append(BOID_OT_boidstate_del); WM_operatortype_append(BOID_OT_boidstate_move_up); WM_operatortype_append(BOID_OT_boidstate_move_down); -}
\ No newline at end of file +} diff --git a/source/blender/editors/preview/previewrender.c b/source/blender/editors/preview/previewrender.c index c5a741b11ed..d17391811bb 100644 --- a/source/blender/editors/preview/previewrender.c +++ b/source/blender/editors/preview/previewrender.c @@ -113,6 +113,7 @@ typedef struct ShaderPreview { Scene *scene; ID *id; ID *parent; + MTex *slot; int sizex, sizey; int *pr_rect; @@ -304,7 +305,11 @@ static Scene *preview_prepare_scene(Scene *scene, ID *id, int id_type, ShaderPre end_render_material(mat); /* turn on raytracing if needed */ - if(mat->mode_l & (MA_RAYTRANSP|MA_RAYMIRROR)) + if(mat->mode_l & MA_RAYMIRROR) + sce->r.mode |= R_RAYTRACE; + if(mat->material_type == MA_TYPE_VOLUME) + sce->r.mode |= R_RAYTRACE; + if((mat->mode_l & MA_RAYTRANSP) && (mat->mode_l & MA_TRANSP)) sce->r.mode |= R_RAYTRACE; if(mat->sss_flag & MA_DIFF_SSS) sce->r.mode |= R_SSS; @@ -362,6 +367,10 @@ static Scene *preview_prepare_scene(Scene *scene, ID *id, int id_type, ShaderPre Material *mat= give_current_material(base->object, base->object->actcol); if(mat && mat->mtex[0]) { mat->mtex[0]->tex= tex; + + if(sp && sp->slot) + mat->mtex[0]->which_output = sp->slot->which_output; + /* show alpha in this case */ if(tex==NULL || (tex->flag & TEX_PRV_ALPHA)) { mat->mtex[0]->mapto |= MAP_ALPHA; @@ -455,13 +464,14 @@ static int ed_preview_draw_rect(ScrArea *sa, Scene *sce, ID *id, int split, int return 0; } -void ED_preview_draw(const bContext *C, void *idp, void *parentp, rcti *rect) +void ED_preview_draw(const bContext *C, void *idp, void *parentp, void *slotp, rcti *rect) { if(idp) { ScrArea *sa= CTX_wm_area(C); Scene *sce = CTX_data_scene(C); ID *id = (ID *)idp; ID *parent= (ID *)parentp; + MTex *slot= (MTex *)slotp; SpaceButs *sbuts= sa->spacedata.first; rcti newrect; int ok; @@ -489,7 +499,7 @@ void ED_preview_draw(const bContext *C, void *idp, void *parentp, rcti *rect) } if(ok==0) { - ED_preview_shader_job(C, sa, id, parent, newx, newy); + ED_preview_shader_job(C, sa, id, parent, slot, newx, newy); } } } @@ -930,7 +940,7 @@ static void shader_preview_free(void *customdata) MEM_freeN(sp); } -void ED_preview_shader_job(const bContext *C, void *owner, ID *id, ID *parent, int sizex, int sizey) +void ED_preview_shader_job(const bContext *C, void *owner, ID *id, ID *parent, MTex *slot, int sizex, int sizey) { wmJob *steve; ShaderPreview *sp; @@ -938,7 +948,11 @@ void ED_preview_shader_job(const bContext *C, void *owner, ID *id, ID *parent, i /* XXX ugly global still, but we can't do preview while rendering */ if(G.rendering) return; - + + if(GS(id->name) == ID_TE) { + ntreeTexSetPreviewFlag(1); + } + steve= WM_jobs_get(CTX_wm_manager(C), CTX_wm_window(C), owner); sp= MEM_callocN(sizeof(ShaderPreview), "shader preview"); @@ -950,6 +964,7 @@ void ED_preview_shader_job(const bContext *C, void *owner, ID *id, ID *parent, i sp->pr_method= PR_DO_RENDER; sp->id = id; sp->parent= parent; + sp->slot= slot; /* setup job */ WM_jobs_customdata(steve, sp, shader_preview_free); diff --git a/source/blender/editors/screen/CMakeLists.txt b/source/blender/editors/screen/CMakeLists.txt index 4ed1e59a87f..7429f45c00f 100644 --- a/source/blender/editors/screen/CMakeLists.txt +++ b/source/blender/editors/screen/CMakeLists.txt @@ -35,13 +35,11 @@ SET(INC ../../windowmanager ../../blenlib ../../makesdna ../../makesrna ../../blenkernel ../../include ../../imbuf ../../render/extern/include ../../../../intern/bsp/extern - ../../radiosity/extern/include ../../../intern/decimation/extern ../../blenloader - ../../../kernel/gen_system ../../../../intern/SoundSystem ../../readstreamglue - ../../quicktime ../../../../intern/elbeem/extern + ../../../kernel/gen_system ../../readstreamglue + ../../../../intern/elbeem/extern ../../../../intern/ghost ../../../../intern/opennl/extern ../../nodes - ${SDL_INC} ) IF(WITH_INTERNATIONAL) @@ -53,7 +51,7 @@ IF(WITH_OPENEXR) ENDIF(WITH_OPENEXR) IF(WITH_QUICKTIME) - SET(INC ${INC} ${QUICKTIME_INC}) + SET(INC ${INC} ../../quicktime ${QUICKTIME_INC}) ADD_DEFINITIONS(-DWITH_QUICKTIME) ENDIF(WITH_QUICKTIME) diff --git a/source/blender/editors/screen/Makefile b/source/blender/editors/screen/Makefile index ce6c59b69ed..c88e53f5f97 100644 --- a/source/blender/editors/screen/Makefile +++ b/source/blender/editors/screen/Makefile @@ -55,3 +55,8 @@ CPPFLAGS += -I$(NAN_GUARDEDALLOC)/include # own include CPPFLAGS += -I../include + +ifeq ($(WITH_OPENEXR), true) + CPPFLAGS += -DWITH_OPENEXR +endif + diff --git a/source/blender/editors/screen/SConscript b/source/blender/editors/screen/SConscript index affc6192290..00a5f08b70d 100644 --- a/source/blender/editors/screen/SConscript +++ b/source/blender/editors/screen/SConscript @@ -12,5 +12,7 @@ defs = '' if not env['WITH_BF_PYTHON']: defs += 'DISABLE_PYTHON' +if env['WITH_BF_OPENEXR']: + defs += ' WITH_OPENEXR' env.BlenderLib ( 'bf_editors_screen', sources, Split(incs), Split(defs), libtype=['core'], priority=[105] ) diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c index 79ba11a5c55..f714a291bd7 100644 --- a/source/blender/editors/screen/area.c +++ b/source/blender/editors/screen/area.c @@ -249,7 +249,7 @@ void ED_area_overdraw(bContext *C) } /* get scissor rect, checking overlapping regions */ -static void region_scissor_winrct(ARegion *ar, rcti *winrct) +void region_scissor_winrct(ARegion *ar, rcti *winrct) { *winrct= ar->winrct; @@ -499,7 +499,7 @@ static void region_azone_initialize(ScrArea *sa, ARegion *ar, char edge) /* if more azones on 1 spot, set offset */ for(azt= sa->actionzones.first; azt; azt= azt->next) { if(az!=azt) { - if(az->x1==azt->x1 && az->y1==azt->y1) { + if( ABS(az->x1-azt->x1) < 2 && ABS(az->y1-azt->y1) < 2) { if(edge=='t' || edge=='b') { az->x1+= AZONESPOT; az->x2+= AZONESPOT; @@ -1041,39 +1041,38 @@ void ED_area_prevspace(bContext *C) static char *windowtype_pup(void) { return( - "Window type:%t" //14 - "|3D View %x1" //30 - - "|%l" // 33 - - "|Graph Editor %x2" //54 - "|DopeSheet %x12" //73 - "|NLA Editor %x13" //94 - - "|%l" //97 - - "|UV/Image Editor %x6" //117 + "Window type:%t" + "|3D View %x1" + + "|%l" - "|Video Sequence Editor %x8" //143 - "|Timeline %x15" //163 - // "|Audio Window %x11" //163 - "|Text Editor %x9" //179 + "|Timeline %x15" + "|Graph Editor %x2" + "|DopeSheet %x12" + "|NLA Editor %x13" - "|%l" //192 + "|%l" + "|UV/Image Editor %x6" - "|User Preferences %x7" //213 - "|Outliner %x3" //232 - "|Buttons Window %x4" //251 + "|Video Sequence Editor %x8" + "|Text Editor %x9" "|Node Editor %x16" "|Logic Editor %x17" - "|%l" //254 - "|File Browser %x5" //290 + "|%l" - "|%l" //293 + "|Properties %x4" + "|Outliner %x3" + "|User Preferences %x19" + "|Info%x7" + + "|%l" + + "|File Browser %x5" + + "|%l" - // "|Scripts Window %x14"//313 "|Console %x18" ); } @@ -1309,7 +1308,7 @@ void ED_region_header(const bContext *C, ARegion *ar) HeaderType *ht; Header header = {0}; float col[3]; - int xco, yco; + int maxco, xco, yco; /* clear */ if(ED_screen_area_active(C)) @@ -1323,7 +1322,7 @@ void ED_region_header(const bContext *C, ARegion *ar) /* set view2d view matrix for scrolling (without scrollers) */ UI_view2d_view_ortho(C, &ar->v2d); - xco= 8; + xco= maxco= 8; yco= HEADERY-3; /* draw all headers types */ @@ -1335,15 +1334,25 @@ void ED_region_header(const bContext *C, ARegion *ar) header.type= ht; header.layout= layout; ht->draw(C, &header); + + /* for view2d */ + xco= uiLayoutGetWidth(layout); + if(xco > maxco) + maxco= xco; } uiBlockLayoutResolve(C, block, &xco, &yco); + + /* for view2d */ + if(xco > maxco) + maxco= xco; + uiEndBlock(C, block); uiDrawBlock(C, block); } /* always as last */ - UI_view2d_totRect_set(&ar->v2d, xco+XIC+80, ar->v2d.tot.ymax-ar->v2d.tot.ymin); + UI_view2d_totRect_set(&ar->v2d, maxco+XIC+80, ar->v2d.tot.ymax-ar->v2d.tot.ymin); /* restore view matrix? */ UI_view2d_view_restore(C); diff --git a/source/blender/editors/screen/screen_context.c b/source/blender/editors/screen/screen_context.c index 3842dd3d62f..1e36a32b9e1 100644 --- a/source/blender/editors/screen/screen_context.c +++ b/source/blender/editors/screen/screen_context.c @@ -44,6 +44,10 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult bScreen *sc= CTX_wm_screen(C); Scene *scene= sc->scene; Base *base; + Object *ob = NULL; + + if(scene && scene->basact) + ob = scene->basact->object; if(CTX_data_dir(member)) { static const char *dir[] = { @@ -112,32 +116,32 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult return 1; } else if(CTX_data_equals(member, "sculpt_object")) { - if(G.f & G_SCULPTMODE && scene->basact) - CTX_data_id_pointer_set(result, &scene->basact->object->id); + if(ob && (ob->mode & OB_MODE_SCULPT)) + CTX_data_id_pointer_set(result, &ob->id); return 1; } else if(CTX_data_equals(member, "vertex_paint_object")) { - if(G.f & G_VERTEXPAINT && scene->basact) - CTX_data_id_pointer_set(result, &scene->basact->object->id); + if(ob && (ob->mode & OB_MODE_VERTEX_PAINT)) + CTX_data_id_pointer_set(result, &ob->id); return 1; } else if(CTX_data_equals(member, "weight_paint_object")) { - if(G.f & G_WEIGHTPAINT && scene->basact) - CTX_data_id_pointer_set(result, &scene->basact->object->id); + if(ob && (ob->mode & OB_MODE_WEIGHT_PAINT)) + CTX_data_id_pointer_set(result, &ob->id); return 1; } else if(CTX_data_equals(member, "texture_paint_object")) { - if(G.f & G_TEXTUREPAINT && scene->basact) - CTX_data_id_pointer_set(result, &scene->basact->object->id); + if(ob && (ob->mode & OB_MODE_TEXTURE_PAINT)) + CTX_data_id_pointer_set(result, &ob->id); return 1; } else if(CTX_data_equals(member, "particle_edit_object")) { - if(G.f & G_PARTICLEEDIT && scene->basact) - CTX_data_id_pointer_set(result, &scene->basact->object->id); + if(ob && (ob->mode & OB_MODE_PARTICLE_EDIT)) + CTX_data_id_pointer_set(result, &ob->id); return 1; } diff --git a/source/blender/editors/screen/screen_edit.c b/source/blender/editors/screen/screen_edit.c index 926768c98ab..aa36675fb90 100644 --- a/source/blender/editors/screen/screen_edit.c +++ b/source/blender/editors/screen/screen_edit.c @@ -923,12 +923,6 @@ bScreen *ED_screen_duplicate(wmWindow *win, bScreen *sc) newsc= ED_screen_add(win, sc->scene, sc->id.name+2); /* copy all data */ screen_copy(newsc, sc); - /* set in window */ - win->screen= newsc; - - /* store identifier */ - win->screen->winid= win->winid; - BLI_strncpy(win->screenname, win->screen->id.name+2, 21); return newsc; } @@ -1289,6 +1283,49 @@ void ED_screen_set(bContext *C, bScreen *sc) } } +static int ed_screen_used(wmWindowManager *wm, bScreen *sc) +{ + wmWindow *win; + + for(win=wm->windows.first; win; win=win->next) + if(win->screen == sc) + return 1; + + return 0; +} + +/* only call outside of area/region loops */ +void ED_screen_delete(bContext *C, bScreen *sc) +{ + Main *bmain= CTX_data_main(C); + wmWindowManager *wm= CTX_wm_manager(C); + wmWindow *win= CTX_wm_window(C); + bScreen *newsc; + int delete= 1; + + /* screen can only be in use by one window at a time, so as + long as we are able to find a screen that is unused, we + can safely assume ours is not in use anywhere an delete it */ + + for(newsc= sc->id.prev; newsc; newsc=newsc->id.prev) + if(!ed_screen_used(wm, newsc)) + break; + + if(!newsc) { + for(newsc= sc->id.next; newsc; newsc=newsc->id.next) + if(!ed_screen_used(wm, newsc)) + break; + } + + if(!newsc) + return; + + ED_screen_set(C, newsc); + + if(delete && win->screen != sc) + free_libblock(&bmain->screen, sc); +} + /* only call outside of area/region loops */ void ED_screen_set_scene(bContext *C, Scene *scene) { @@ -1346,6 +1383,24 @@ void ED_screen_set_scene(bContext *C, Scene *scene) } +/* only call outside of area/region loops */ +void ED_screen_delete_scene(bContext *C, Scene *scene) +{ + Main *bmain= CTX_data_main(C); + Scene *newscene; + + if(scene->id.prev) + newscene= scene->id.prev; + else if(scene->id.next) + newscene= scene->id.next; + else + return; + + ED_screen_set_scene(C, newscene); + + unlink_scene(bmain, scene, newscene); +} + /* this function toggles: if area is full then the parent will be restored */ void ed_screen_fullarea(bContext *C, ScrArea *sa) { @@ -1461,7 +1516,7 @@ void ED_screen_full_prevspace(bContext *C) /* redraws: uses defines from stime->redraws * enable: 1 - forward on, -1 - backwards on, 0 - off */ -void ED_screen_animation_timer(bContext *C, int redraws, int enable) +void ED_screen_animation_timer(bContext *C, int redraws, int sync, int enable) { bScreen *screen= CTX_wm_screen(C); wmWindow *win= CTX_wm_window(C); @@ -1472,12 +1527,13 @@ void ED_screen_animation_timer(bContext *C, int redraws, int enable) screen->animtimer= NULL; if(enable) { - struct ScreenAnimData *sad= MEM_mallocN(sizeof(ScreenAnimData), "ScreenAnimData"); + struct ScreenAnimData *sad= MEM_callocN(sizeof(ScreenAnimData), "ScreenAnimData"); screen->animtimer= WM_event_add_window_timer(win, TIMER0, (1.0/FPS)); sad->ar= CTX_wm_region(C); sad->redraws= redraws; - sad->flag= (enable < 0) ? ANIMPLAY_FLAG_REVERSE : 0; + sad->flag |= (enable < 0)? ANIMPLAY_FLAG_REVERSE: 0; + sad->flag |= (sync == 0)? ANIMPLAY_FLAG_NO_SYNC: (sync == 1)? ANIMPLAY_FLAG_SYNC: 0; screen->animtimer->customdata= sad; } @@ -1485,6 +1541,45 @@ void ED_screen_animation_timer(bContext *C, int redraws, int enable) WM_event_add_notifier(C, NC_SCREEN|ND_ANIMPLAY, screen); } +/* helper for screen_animation_play() - only to be used for TimeLine */ +static ARegion *time_top_left_3dwindow(bScreen *screen) +{ + ARegion *aret= NULL; + ScrArea *sa; + int min= 10000; + + for(sa= screen->areabase.first; sa; sa= sa->next) { + if(sa->spacetype==SPACE_VIEW3D) { + ARegion *ar; + for(ar= sa->regionbase.first; ar; ar= ar->next) { + if(ar->regiontype==RGN_TYPE_WINDOW) { + if(ar->winrct.xmin - ar->winrct.ymin < min) { + aret= ar; + min= ar->winrct.xmin - ar->winrct.ymin; + } + } + } + } + } + + return aret; +} + +void ED_screen_animation_timer_update(bContext *C, int redraws) +{ + bScreen *screen= CTX_wm_screen(C); + + if(screen && screen->animtimer) { + wmTimer *wt= screen->animtimer; + ScreenAnimData *sad= wt->customdata; + + sad->redraws= redraws; + sad->ar= NULL; + if(redraws & TIME_REGION) + sad->ar= time_top_left_3dwindow(screen); + } +} + unsigned int ED_screen_view3d_layers(bScreen *screen) { if(screen) { @@ -1503,7 +1598,6 @@ unsigned int ED_screen_view3d_layers(bScreen *screen) /* results in fully updated anim system */ -/* in future sound should be on WM level, only 1 sound can play! */ void ED_update_for_newframe(const bContext *C, int mute) { bScreen *screen= CTX_wm_screen(C); @@ -1515,7 +1609,7 @@ void ED_update_for_newframe(const bContext *C, int mute) /* XXX future: do all windows */ scene_update_for_newframe(scene, ED_screen_view3d_layers(screen)); /* BKE_scene.h */ - //if ( (CFRA>1) && (!mute) && (scene->audio.flag & AUDIO_SCRUB)) + //if ( (CFRA>1) && (!mute) && (scene->r.audio.flag & AUDIO_SCRUB)) // audiostream_scrub( CFRA ); /* 3d window, preview */ diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c index 57fd96c8b39..bcf4ab16f81 100644 --- a/source/blender/editors/screen/screen_ops.c +++ b/source/blender/editors/screen/screen_ops.c @@ -54,9 +54,11 @@ #include "BKE_mesh.h" #include "BKE_multires.h" #include "BKE_report.h" +#include "BKE_scene.h" #include "BKE_screen.h" #include "BKE_utildefines.h" #include "BKE_tessmesh.h" +#include "BKE_sound.h" #include "WM_api.h" #include "WM_types.h" @@ -231,7 +233,7 @@ int ED_operator_posemode(bContext *C) Object *obedit= CTX_data_edit_object(C); if ((obact != obedit) && (obact) && (obact->type==OB_ARMATURE)) - return (obact->flag & OB_POSEMODE)!=0; + return (obact->mode & OB_MODE_POSE)!=0; return 0; } @@ -1572,7 +1574,6 @@ static void SCREEN_OT_screen_set(wmOperatorType *ot) ot->poll= ED_operator_screenactive; /* rna */ - RNA_def_pointer_runtime(ot->srna, "screen", &RNA_Screen, "Screen", ""); RNA_def_int(ot->srna, "delta", 0, INT_MIN, INT_MAX, "Delta", "", INT_MIN, INT_MAX); } @@ -2217,8 +2218,15 @@ static int screen_animation_step(bContext *C, wmOperator *op, wmEvent *event) wmTimer *wt= screen->animtimer; ScreenAnimData *sad= wt->customdata; ScrArea *sa; + int sync; - if(scene->audio.flag & AUDIO_SYNC) { + /* sync, don't sync, or follow scene setting */ + if(sad->flag & ANIMPLAY_FLAG_SYNC) sync= 1; + else if(sad->flag & ANIMPLAY_FLAG_NO_SYNC) sync= 0; + else sync= (scene->r.audio.flag & AUDIO_SYNC); + + if(sync) { + /* skip frames */ int step = floor(wt->duration * FPS); if (sad->flag & ANIMPLAY_FLAG_REVERSE) // XXX does this option work with audio? scene->r.cfra -= step; @@ -2227,6 +2235,7 @@ static int screen_animation_step(bContext *C, wmOperator *op, wmEvent *event) wt->duration -= ((float)step)/FPS; } else { + /* one frame +/- */ if (sad->flag & ANIMPLAY_FLAG_REVERSE) scene->r.cfra--; else @@ -2270,6 +2279,8 @@ static int screen_animation_step(bContext *C, wmOperator *op, wmEvent *event) /* since we follow drawflags, we can't send notifier but tag regions ourselves */ ED_update_for_newframe(C, 1); + sound_update_playing(C); + for(sa= screen->areabase.first; sa; sa= sa->next) { ARegion *ar; for(ar= sa->regionbase.first; ar; ar= ar->next) { @@ -2303,38 +2314,34 @@ static void SCREEN_OT_animation_step(wmOperatorType *ot) /* ****************** anim player, starts or ends timer ***************** */ -/* helper for screen_animation_play() - only to be used for TimeLine */ -// NOTE: defined in time_header.c for now... -extern ARegion *time_top_left_3dwindow(bScreen *screen); - /* toggle operator */ static int screen_animation_play(bContext *C, wmOperator *op, wmEvent *event) { bScreen *screen= CTX_wm_screen(C); if(screen->animtimer) { - ED_screen_animation_timer(C, 0, 0); + ED_screen_animation_timer(C, 0, 0, 0); + sound_stop_all(C); } else { ScrArea *sa= CTX_wm_area(C); int mode= (RNA_boolean_get(op->ptr, "reverse")) ? -1 : 1; + int sync= -1; + + if(RNA_property_is_set(op->ptr, "sync")) + sync= (RNA_boolean_get(op->ptr, "sync")); /* timeline gets special treatment since it has it's own menu for determining redraws */ if ((sa) && (sa->spacetype == SPACE_TIME)) { SpaceTime *stime= (SpaceTime *)sa->spacedata.first; - ED_screen_animation_timer(C, stime->redraws, mode); + ED_screen_animation_timer(C, stime->redraws, sync, mode); /* update region if TIME_REGION was set, to leftmost 3d window */ - if(screen->animtimer && (stime->redraws & TIME_REGION)) { - wmTimer *wt= screen->animtimer; - ScreenAnimData *sad= wt->customdata; - - sad->ar= time_top_left_3dwindow(screen); + ED_screen_animation_timer_update(C, stime->redraws); } - } else { - ED_screen_animation_timer(C, TIME_REGION|TIME_ALL_3D_WIN, mode); + ED_screen_animation_timer(C, TIME_REGION|TIME_ALL_3D_WIN, sync, mode); if(screen->animtimer) { wmTimer *wt= screen->animtimer; @@ -2360,6 +2367,7 @@ static void SCREEN_OT_animation_play(wmOperatorType *ot) ot->poll= ED_operator_screenactive; RNA_def_boolean(ot->srna, "reverse", 0, "Play in Reverse", "Animation is played backwards"); + RNA_def_boolean(ot->srna, "sync", 0, "Sync", "Drop frames to maintain framerate and stay in sync with audio."); } /* ************** border select operator (template) ***************************** */ @@ -2868,10 +2876,13 @@ static int screen_render_invoke(bContext *C, wmOperator *op, wmEvent *event) RenderJob *rj; Image *ima; - /* only one job at a time */ + /* only one render job at a time */ if(WM_jobs_test(CTX_wm_manager(C), scene)) return OPERATOR_CANCELLED; + /* stop all running jobs, currently previews frustrate Render */ + WM_jobs_stop_all(CTX_wm_manager(C)); + /* handle UI stuff */ WM_cursor_wait(1); @@ -3075,7 +3086,124 @@ static void SCREEN_OT_userpref_show(struct wmOperatorType *ot) ot->poll= ED_operator_screenactive; } +/********************* new screen operator *********************/ + +static int screen_new_exec(bContext *C, wmOperator *op) +{ + wmWindow *win= CTX_wm_window(C); + bScreen *sc= CTX_wm_screen(C); + + sc= ED_screen_duplicate(win, sc); + WM_event_add_notifier(C, NC_SCREEN|ND_SCREENBROWSE, sc); + + return OPERATOR_FINISHED; +} + +void SCREEN_OT_new(wmOperatorType *ot) +{ + /* identifiers */ + ot->name= "New Screen"; + ot->idname= "SCREEN_OT_new"; + + /* api callbacks */ + ot->exec= screen_new_exec; + + /* flags */ + ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; +} + +/********************* delete screen operator *********************/ + +static int screen_delete_exec(bContext *C, wmOperator *op) +{ + bScreen *sc= CTX_wm_screen(C); + + WM_event_add_notifier(C, NC_SCREEN|ND_SCREENDELETE, sc); + return OPERATOR_FINISHED; +} + +void SCREEN_OT_delete(wmOperatorType *ot) +{ + /* identifiers */ + ot->name= "Delete Scene"; + ot->idname= "SCREEN_OT_delete"; + + /* api callbacks */ + ot->exec= screen_delete_exec; + + /* flags */ + ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; +} + +/********************* new scene operator *********************/ + +static int scene_new_exec(bContext *C, wmOperator *op) +{ + Scene *newscene, *scene= CTX_data_scene(C); + Main *bmain= CTX_data_main(C); + int type= RNA_enum_get(op->ptr, "type"); + + newscene= copy_scene(bmain, scene, type); + + /* these can't be handled in blenkernel curently, so do them here */ + if(type == SCE_COPY_LINK_DATA) + ED_object_single_users(newscene, 0); + else if(type == SCE_COPY_FULL) + ED_object_single_users(newscene, 1); + + WM_event_add_notifier(C, NC_SCENE|ND_SCENEBROWSE, newscene); + + return OPERATOR_FINISHED; +} + +void SCENE_OT_new(wmOperatorType *ot) +{ + static EnumPropertyItem type_items[]= { + {SCE_COPY_EMPTY, "EMPTY", 0, "Empty", "Add empty scene."}, + {SCE_COPY_LINK_OB, "LINK_OBJECTS", 0, "Link Objects", "Link to the objects from the current scene."}, + {SCE_COPY_LINK_DATA, "LINK_OBJECT_DATA", 0, "Link Object Data", "Copy objects linked to data from the current scene."}, + {SCE_COPY_FULL, "FULL_COPY", 0, "Full Copy", "Make a full copy of the current scene."}, + {0, NULL, 0, NULL, NULL}}; + + /* identifiers */ + ot->name= "New Scene"; + ot->idname= "SCENE_OT_new"; + + /* api callbacks */ + ot->exec= scene_new_exec; + ot->invoke= WM_menu_invoke; + + /* flags */ + ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; + + /* properties */ + RNA_def_enum(ot->srna, "type", type_items, 0, "Type", ""); +} + +/********************* delete scene operator *********************/ + +static int scene_delete_exec(bContext *C, wmOperator *op) +{ + Scene *scene= CTX_data_scene(C); + + WM_event_add_notifier(C, NC_SCENE|ND_SCENEDELETE, scene); + + return OPERATOR_FINISHED; +} + +void SCENE_OT_delete(wmOperatorType *ot) +{ + /* identifiers */ + ot->name= "Delete Scene"; + ot->idname= "SCENE_OT_delete"; + + /* api callbacks */ + ot->exec= scene_delete_exec; + + /* flags */ + ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; +} /* **************** Assigning operatortypes to global list, adding handlers **************** */ @@ -3117,6 +3245,12 @@ void ED_operatortypes_screen(void) WM_operatortype_append(SCREEN_OT_render_view_cancel); WM_operatortype_append(SCREEN_OT_render_view_show); + /* new/delete */ + WM_operatortype_append(SCREEN_OT_new); + WM_operatortype_append(SCREEN_OT_delete); + WM_operatortype_append(SCENE_OT_new); + WM_operatortype_append(SCENE_OT_delete); + /* tools shared by more space types */ WM_operatortype_append(ED_OT_undo); WM_operatortype_append(ED_OT_redo); @@ -3156,6 +3290,7 @@ void ED_keymap_screen(wmWindowManager *wm) /* Screen General ------------------------------------------------ */ keymap= WM_keymap_listbase(wm, "Screen", 0, 0); + /* standard timers */ WM_keymap_add_item(keymap, "SCREEN_OT_animation_step", TIMER0, KM_ANY, KM_ANY, 0); @@ -3184,7 +3319,8 @@ void ED_keymap_screen(wmWindowManager *wm) WM_keymap_add_item(keymap, "SCREEN_OT_region_foursplit", SKEY, KM_PRESS, KM_CTRL|KM_ALT|KM_SHIFT, 0); WM_keymap_verify_item(keymap, "SCREEN_OT_repeat_history", F3KEY, KM_PRESS, 0, 0); - WM_keymap_verify_item(keymap, "SCREEN_OT_repeat_last", F4KEY, KM_PRESS, 0, 0); + WM_keymap_add_item(keymap, "SCREEN_OT_repeat_last", RKEY, KM_PRESS, KM_CTRL, 0); + WM_keymap_add_item(keymap, "SCREEN_OT_repeat_last", RKEY, KM_PRESS, KM_OSKEY, 0); WM_keymap_add_item(keymap, "SCREEN_OT_region_flip", F5KEY, KM_PRESS, 0, 0); WM_keymap_verify_item(keymap, "SCREEN_OT_redo_last", F6KEY, KM_PRESS, 0, 0); @@ -3203,12 +3339,17 @@ void ED_keymap_screen(wmWindowManager *wm) /* render */ WM_keymap_add_item(keymap, "SCREEN_OT_render", F12KEY, KM_PRESS, 0, 0); +// WM_keymap_add_item(keymap, "SCREEN_OT_render", RETKEY, KM_PRESS, KM_CTRL, 0); +// WM_keymap_add_item(keymap, "SCREEN_OT_render", RETKEY, KM_PRESS, KM_OSKEY, 0); RNA_boolean_set(WM_keymap_add_item(keymap, "SCREEN_OT_render", F12KEY, KM_PRESS, KM_CTRL, 0)->ptr, "animation", 1); +// RNA_boolean_set(WM_keymap_add_item(keymap, "SCREEN_OT_render", RETKEY, KM_PRESS, KM_CTRL|KM_SHIFT, 0)->ptr, "animation", 1); +// RNA_boolean_set(WM_keymap_add_item(keymap, "SCREEN_OT_render", RETKEY, KM_PRESS, KM_OSKEY|KM_SHIFT, 0)->ptr, "animation", 1); WM_keymap_add_item(keymap, "SCREEN_OT_render_view_cancel", ESCKEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "SCREEN_OT_render_view_show", F11KEY, KM_PRESS, 0, 0); /* user prefs */ - WM_keymap_add_item(keymap, "SCREEN_OT_userpref_show", UKEY, KM_PRESS, KM_ALT, 0); + WM_keymap_add_item(keymap, "SCREEN_OT_userpref_show", COMMAKEY, KM_PRESS, KM_CTRL, 0); + WM_keymap_add_item(keymap, "SCREEN_OT_userpref_show", COMMAKEY, KM_PRESS, KM_OSKEY, 0); /* Anim Playback ------------------------------------------------ */ keymap= WM_keymap_listbase(wm, "Frames", 0, 0); @@ -3220,13 +3361,15 @@ void ED_keymap_screen(wmWindowManager *wm) RNA_int_set(WM_keymap_add_item(keymap, "SCREEN_OT_frame_offset", RIGHTARROWKEY, KM_PRESS, 0, 0)->ptr, "delta", 1); WM_keymap_add_item(keymap, "SCREEN_OT_frame_jump", DOWNARROWKEY, KM_PRESS, KM_SHIFT, 0); - RNA_boolean_set(WM_keymap_add_item(keymap, "SCREEN_OT_frame_jump", UPARROWKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "end", 1); + RNA_boolean_set(WM_keymap_add_item(keymap, "SCREEN_OT_frame_jump", RIGHTARROWKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "end", 1); + RNA_boolean_set(WM_keymap_add_item(keymap, "SCREEN_OT_frame_jump", LEFTARROWKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "end", 0); WM_keymap_add_item(keymap, "SCREEN_OT_keyframe_jump", PAGEUPKEY, KM_PRESS, KM_CTRL, 0); RNA_boolean_set(WM_keymap_add_item(keymap, "SCREEN_OT_keyframe_jump", PAGEDOWNKEY, KM_PRESS, KM_CTRL, 0)->ptr, "next", 0); /* play (forward and backwards) */ WM_keymap_add_item(keymap, "SCREEN_OT_animation_play", AKEY, KM_PRESS, KM_ALT, 0); + WM_keymap_add_item(keymap, "SCREEN_OT_animation_play", KKEY, KM_PRESS, 0, LKEY); RNA_boolean_set(WM_keymap_add_item(keymap, "SCREEN_OT_animation_play", AKEY, KM_PRESS, KM_ALT|KM_SHIFT, 0)->ptr, "reverse", 1); keymap_modal_set(wm); diff --git a/source/blender/editors/screen/screendump.c b/source/blender/editors/screen/screendump.c index 2ae2712d02d..5ae1bdf84aa 100644 --- a/source/blender/editors/screen/screendump.c +++ b/source/blender/editors/screen/screendump.c @@ -228,7 +228,7 @@ static void screenshot_startjob(void *sjv, short *stop, short *do_update) rd.frs_sec_base= 1.0f; if(BKE_imtype_is_movie(rd.imtype)) - mh->start_movie(&rd, sj->dumpsx, sj->dumpsy); + mh->start_movie(sj->scene, &rd, sj->dumpsx, sj->dumpsy); else mh= NULL; diff --git a/source/blender/editors/sculpt_paint/paint_image.c b/source/blender/editors/sculpt_paint/paint_image.c index 1b33f340d5e..128455a8487 100644 --- a/source/blender/editors/sculpt_paint/paint_image.c +++ b/source/blender/editors/sculpt_paint/paint_image.c @@ -71,6 +71,7 @@ #include "BKE_main.h" #include "BKE_mesh.h" #include "BKE_node.h" +#include "BKE_paint.h" #include "BKE_utildefines.h" #include "BKE_DerivedMesh.h" #include "BKE_report.h" @@ -3706,7 +3707,7 @@ static void *do_projectpaint_thread(void *ph_v) ProjPaintImage *last_projIma= NULL; ImagePaintPartialRedraw *last_partial_redraw_cell; - float rgba[4], alpha, dist_nosqrt; + float rgba[4], alpha, dist_nosqrt, dist; float brush_size_sqared; float falloff; @@ -3720,6 +3721,7 @@ static void *do_projectpaint_thread(void *ph_v) float co[2]; float mask = 1.0f; /* airbrush wont use mask */ unsigned short mask_short; + float size_half = ((float)ps->brush->size) * 0.5f; LinkNode *smearPixels = NULL; LinkNode *smearPixels_f = NULL; @@ -3754,8 +3756,8 @@ static void *do_projectpaint_thread(void *ph_v) dist_nosqrt = Vec2Lenf_nosqrt(projPixel->projCoSS, pos); /*if (dist < s->brush->size) {*/ /* correct but uses a sqrtf */ - if (dist_nosqrt < brush_size_sqared) { - falloff = brush_sample_falloff_noalpha(ps->brush, sqrtf(dist_nosqrt)); + if (dist_nosqrt < brush_size_sqared && (dist=sqrtf(dist_nosqrt)) < size_half) { + falloff = brush_curve_strength(ps->brush, dist, size_half); if (falloff > 0.0f) { if (ps->is_texbrush) { brush_sample_tex(ps->brush, projPixel->projCoSS, rgba); @@ -4023,7 +4025,7 @@ static void imapaint_image_update(SpaceImage *sima, Image *image, ImBuf *ibuf, s if(texpaint || (sima && sima->lock)) { int w = imapaintpartial.x2 - imapaintpartial.x1; int h = imapaintpartial.y2 - imapaintpartial.y1; - GPU_paint_update_image(image, imapaintpartial.x1, imapaintpartial.y1, w, h); + GPU_paint_update_image(image, imapaintpartial.x1, imapaintpartial.y1, w, h, !texpaint); } } @@ -4375,15 +4377,17 @@ static Brush *image_paint_brush(bContext *C) Scene *scene= CTX_data_scene(C); ToolSettings *settings= scene->toolsettings; - return settings->imapaint.brush; + return paint_brush(&settings->imapaint.paint); } static int image_paint_poll(bContext *C) { + Object *obact = CTX_data_active_object(C); + if(!image_paint_brush(C)) return 0; - if((G.f & G_TEXTUREPAINT) && CTX_wm_region_view3d(C)) { + if((obact && obact->mode & OB_MODE_TEXTURE_PAINT) && CTX_wm_region_view3d(C)) { return 1; } else { @@ -4484,11 +4488,12 @@ static void paint_redraw(bContext *C, ImagePaintState *s, int final) } } -static int paint_init(bContext *C, wmOperator *op) +static int texture_paint_init(bContext *C, wmOperator *op) { Scene *scene= CTX_data_scene(C); ToolSettings *settings= scene->toolsettings; PaintOperation *pop; + Brush *brush; pop= MEM_callocN(sizeof(PaintOperation), "PaintOperation"); pop->first= 1; @@ -4516,10 +4521,11 @@ static int paint_init(bContext *C, wmOperator *op) pop->ps.ar= CTX_wm_region(C); /* intialize brush */ - if(!settings->imapaint.brush) + brush= paint_brush(&settings->imapaint.paint); + if(!brush) return 0; - pop->s.brush = settings->imapaint.brush; + pop->s.brush = brush; pop->s.tool = settings->imapaint.tool; if(pop->mode == PAINT_MODE_3D && (pop->s.tool == PAINT_TOOL_CLONE)) pop->s.tool = PAINT_TOOL_DRAW; @@ -4607,11 +4613,13 @@ static int paint_init(bContext *C, wmOperator *op) static void paint_apply(bContext *C, wmOperator *op, PointerRNA *itemptr) { PaintOperation *pop= op->customdata; - float time; + float time, mousef[2]; float pressure; int mouse[2], redraw; - RNA_int_get_array(itemptr, "mouse", mouse); + RNA_float_get_array(itemptr, "mouse", mousef); + mouse[0] = mousef[0]; + mouse[1] = mousef[1]; time= RNA_float_get(itemptr, "time"); pressure= RNA_float_get(itemptr, "pressure"); @@ -4670,7 +4678,7 @@ static void paint_exit(bContext *C, wmOperator *op) static int paint_exec(bContext *C, wmOperator *op) { - if(!paint_init(C, op)) { + if(!texture_paint_init(C, op)) { MEM_freeN(op->customdata); return OPERATOR_CANCELLED; } @@ -4691,7 +4699,7 @@ static void paint_apply_event(bContext *C, wmOperator *op, wmEvent *event) PaintOperation *pop= op->customdata; wmTabletData *wmtab; PointerRNA itemptr; - float pressure; + float pressure, mousef[2]; double time; int tablet, mouse[2]; @@ -4712,7 +4720,7 @@ static void paint_apply_event(bContext *C, wmOperator *op, wmEvent *event) tablet= (wmtab->Active != EVT_TABLET_NONE); pressure= wmtab->Pressure; if(wmtab->Active == EVT_TABLET_ERASER) - pop->s.blend= BRUSH_BLEND_ERASE_ALPHA; + pop->s.blend= IMB_BLEND_ERASE_ALPHA; } else pressure= 1.0f; @@ -4732,7 +4740,9 @@ static void paint_apply_event(bContext *C, wmOperator *op, wmEvent *event) /* fill in stroke */ RNA_collection_add(op->ptr, "stroke", &itemptr); - RNA_int_set_array(&itemptr, "mouse", mouse); + mousef[0] = mouse[0]; + mousef[1] = mouse[1]; + RNA_float_set_array(&itemptr, "mouse", mousef); RNA_float_set(&itemptr, "time", (float)(time - pop->starttime)); RNA_float_set(&itemptr, "pressure", pressure); @@ -4744,7 +4754,7 @@ static int paint_invoke(bContext *C, wmOperator *op, wmEvent *event) { PaintOperation *pop; - if(!paint_init(C, op)) { + if(!texture_paint_init(C, op)) { MEM_freeN(op->customdata); return OPERATOR_CANCELLED; } @@ -4872,7 +4882,7 @@ static int paint_radial_control_invoke(bContext *C, wmOperator *op, wmEvent *eve ToolSettings *ts = CTX_data_scene(C)->toolsettings; get_imapaint_zoom(C, &zoom, &zoom); toggle_paint_cursor(C, !ts->imapaint.paintcursor); - brush_radial_control_invoke(op, ts->imapaint.brush, 0.5 * zoom); + brush_radial_control_invoke(op, paint_brush(&ts->imapaint.paint), 0.5 * zoom); return WM_radial_control_invoke(C, op, event); } @@ -4891,7 +4901,7 @@ static int paint_radial_control_exec(bContext *C, wmOperator *op) int ret; char str[256]; get_imapaint_zoom(C, &zoom, &zoom); - ret = brush_radial_control_exec(op, CTX_data_scene(C)->toolsettings->imapaint.brush, 2.0 / zoom); + ret = brush_radial_control_exec(op, paint_brush(&CTX_data_scene(C)->toolsettings->imapaint.paint), 2.0 / zoom); WM_radial_control_string(op, str, 256); return ret; @@ -5144,13 +5154,13 @@ static int texture_paint_toggle_exec(bContext *C, wmOperator *op) me= get_mesh(ob); - if(!(G.f & G_TEXTUREPAINT) && !me) { + if(!(ob->mode & OB_MODE_TEXTURE_PAINT) && !me) { BKE_report(op->reports, RPT_ERROR, "Can only enter texture paint mode for mesh objects."); return OPERATOR_CANCELLED; } - if(G.f & G_TEXTUREPAINT) { - G.f &= ~G_TEXTUREPAINT; + if(ob->mode & OB_MODE_TEXTURE_PAINT) { + ob->mode &= ~OB_MODE_TEXTURE_PAINT; if(U.glreslimit != 0) GPU_free_images(); @@ -5159,13 +5169,13 @@ static int texture_paint_toggle_exec(bContext *C, wmOperator *op) toggle_paint_cursor(C, 0); } else { - G.f |= G_TEXTUREPAINT; + ob->mode |= OB_MODE_TEXTURE_PAINT; if(me->mtface==NULL) me->mtface= CustomData_add_layer(&me->fdata, CD_MTFACE, CD_DEFAULT, NULL, me->totface); - brush_check_exists(&scene->toolsettings->imapaint.brush); + paint_init(&scene->toolsettings->imapaint.paint, PAINT_CURSOR_TEXTURE_PAINT); if(U.glreslimit != 0) GPU_free_images(); @@ -5200,13 +5210,13 @@ static int texture_paint_radial_control_invoke(bContext *C, wmOperator *op, wmEv { ToolSettings *ts = CTX_data_scene(C)->toolsettings; toggle_paint_cursor(C, !ts->imapaint.paintcursor); - brush_radial_control_invoke(op, ts->imapaint.brush, 0.5); + brush_radial_control_invoke(op, paint_brush(&ts->imapaint.paint), 0.5); return WM_radial_control_invoke(C, op, event); } static int texture_paint_radial_control_exec(bContext *C, wmOperator *op) { - int ret = brush_radial_control_exec(op, CTX_data_scene(C)->toolsettings->imapaint.brush, 2); + int ret = brush_radial_control_exec(op, paint_brush(&CTX_data_scene(C)->toolsettings->imapaint.paint), 2); char str[256]; WM_radial_control_string(op, str, 256); @@ -5216,7 +5226,7 @@ static int texture_paint_radial_control_exec(bContext *C, wmOperator *op) static int texture_paint_poll(bContext *C) { if(texture_paint_toggle_poll(C)) - if(G.f & G_TEXTUREPAINT) + if(CTX_data_active_object(C)->mode & OB_MODE_TEXTURE_PAINT) return 1; return 0; diff --git a/source/blender/editors/sculpt_paint/paint_intern.h b/source/blender/editors/sculpt_paint/paint_intern.h index b630975c934..ba1b57a1bef 100644 --- a/source/blender/editors/sculpt_paint/paint_intern.h +++ b/source/blender/editors/sculpt_paint/paint_intern.h @@ -29,14 +29,37 @@ #ifndef ED_PAINT_INTERN_H #define ED_PAINT_INTERN_H +struct bContext; struct Scene; struct Object; struct Mesh; +struct PaintStroke; +struct PointerRNA; struct ViewContext; +struct wmEvent; +struct wmOperator; struct wmOperatorType; struct ARegion; +/* paint_stroke.c */ +typedef int (*StrokeTestStart)(struct bContext *C, struct wmOperator *op, struct wmEvent *event); +typedef void (*StrokeUpdateStep)(struct bContext *C, struct PaintStroke *stroke, struct PointerRNA *itemptr); +typedef void (*StrokeDone)(struct bContext *C, struct PaintStroke *stroke); + +struct PaintStroke *paint_stroke_new(bContext *C, StrokeTestStart test_start, + StrokeUpdateStep update_step, StrokeDone done); +int paint_stroke_modal(struct bContext *C, struct wmOperator *op, struct wmEvent *event); +int paint_stroke_exec(struct bContext *C, struct wmOperator *op); +struct ViewContext *paint_stroke_view_context(struct PaintStroke *stroke); +void *paint_stroke_mode_data(struct PaintStroke *stroke); +void paint_stroke_set_mode_data(struct PaintStroke *stroke, void *mode_data); +int paint_poll(bContext *C); +void paint_cursor_start(struct bContext *C, int (*poll)(struct bContext *C)); + /* paint_vertex.c */ +int vertex_paint_mode_poll(bContext *C); +void clear_vpaint(Scene *scene, int selected); + void PAINT_OT_weight_paint_toggle(struct wmOperatorType *ot); void PAINT_OT_weight_paint_radial_control(struct wmOperatorType *ot); void PAINT_OT_weight_paint(struct wmOperatorType *ot); @@ -59,6 +82,7 @@ int imapaint_pick_face(struct ViewContext *vc, struct Mesh *me, int *mval, unsig void imapaint_pick_uv(struct Scene *scene, struct Object *ob, struct Mesh *mesh, unsigned int faceindex, int *xy, float *uv); void paint_sample_color(struct Scene *scene, struct ARegion *ar, int x, int y); +void BRUSH_OT_curve_preset(struct wmOperatorType *ot); #endif /* ED_PAINT_INTERN_H */ diff --git a/source/blender/editors/sculpt_paint/paint_ops.c b/source/blender/editors/sculpt_paint/paint_ops.c index e9263ddabf0..c38b36007e9 100644 --- a/source/blender/editors/sculpt_paint/paint_ops.c +++ b/source/blender/editors/sculpt_paint/paint_ops.c @@ -1,15 +1,116 @@ +/** + * + * ***** 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. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +#include "DNA_brush_types.h" +#include "DNA_object_types.h" +#include "DNA_scene_types.h" + +#include "BKE_brush.h" +#include "BKE_context.h" +#include "BKE_paint.h" #include "ED_sculpt.h" +#include "UI_resources.h" #include "WM_api.h" #include "WM_types.h" +#include "RNA_access.h" +#include "RNA_define.h" +#include "RNA_enum_types.h" + #include "paint_intern.h" +#include <string.h> + +/* Brush operators */ +static int brush_add_exec(bContext *C, wmOperator *op) +{ + /*int type = RNA_enum_get(op->ptr, "type");*/ + Brush *br = NULL; + + br = add_brush("Brush"); + + if(br) + paint_brush_set(paint_get_active(CTX_data_scene(C)), br); + + return OPERATOR_FINISHED; +} + +static EnumPropertyItem brush_type_items[] = { + {OB_MODE_SCULPT, "SCULPT", ICON_SCULPTMODE_HLT, "Sculpt", ""}, + {OB_MODE_VERTEX_PAINT, "VERTEX_PAINT", ICON_VPAINT_HLT, "Vertex Paint", ""}, + {OB_MODE_WEIGHT_PAINT, "WEIGHT_PAINT", ICON_WPAINT_HLT, "Weight Paint", ""}, + {OB_MODE_TEXTURE_PAINT, "TEXTURE_PAINT", ICON_TPAINT_HLT, "Texture Paint", ""}, + {0, NULL, 0, NULL, NULL}}; + +void BRUSH_OT_add(wmOperatorType *ot) +{ + /* identifiers */ + ot->name= "Add Brush"; + ot->idname= "BRUSH_OT_add"; + + /* api callbacks */ + ot->exec= brush_add_exec; + + /* flags */ + ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; + + RNA_def_enum(ot->srna, "type", brush_type_items, OB_MODE_VERTEX_PAINT, "Type", "Which paint mode to create the brush for."); +} + +static int vertex_color_set_exec(bContext *C, wmOperator *op) +{ + int selected = RNA_boolean_get(op->ptr, "selected"); + Scene *scene = CTX_data_scene(C); + + clear_vpaint(scene, selected); + + return OPERATOR_FINISHED; +} + +void PAINT_OT_vertex_color_set(wmOperatorType *ot) +{ + /* identifiers */ + ot->name= "Set Vertex Colors"; + ot->idname= "PAINT_OT_vertex_color_set"; + + /* api callbacks */ + ot->exec= vertex_color_set_exec; + ot->poll= vertex_paint_mode_poll; + + /* flags */ + ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; + + RNA_def_boolean(ot->srna, "selected", 0, "Type", "Only color selected faces."); +} + /**************************** registration **********************************/ void ED_operatortypes_paint(void) { + /* brush */ + WM_operatortype_append(BRUSH_OT_add); + WM_operatortype_append(BRUSH_OT_curve_preset); + /* image */ WM_operatortype_append(PAINT_OT_texture_paint_toggle); WM_operatortype_append(PAINT_OT_texture_paint_radial_control); @@ -28,5 +129,6 @@ void ED_operatortypes_paint(void) WM_operatortype_append(PAINT_OT_vertex_paint_radial_control); WM_operatortype_append(PAINT_OT_vertex_paint_toggle); WM_operatortype_append(PAINT_OT_vertex_paint); + WM_operatortype_append(PAINT_OT_vertex_color_set); } diff --git a/source/blender/editors/sculpt_paint/paint_stroke.c b/source/blender/editors/sculpt_paint/paint_stroke.c new file mode 100644 index 00000000000..bd9ea50e0f8 --- /dev/null +++ b/source/blender/editors/sculpt_paint/paint_stroke.c @@ -0,0 +1,330 @@ +/* + * ***** 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 by Nicholas Bishop + * All rights reserved. + * + * The Original Code is: all of this file. + * + * Contributor(s): none yet. + * + * ***** END GPL LICENSE BLOCK ***** + * + */ + +#include "MEM_guardedalloc.h" + +#include "DNA_brush_types.h" +#include "DNA_object_types.h" +#include "DNA_scene_types.h" +#include "DNA_screen_types.h" + +#include "RNA_access.h" + +#include "BKE_context.h" +#include "BKE_paint.h" + +#include "WM_api.h" +#include "WM_types.h" + +#include "BLI_arithb.h" + +#include "PIL_time.h" + +#include "BIF_gl.h" +#include "BIF_glutil.h" + +#include "ED_screen.h" +#include "ED_view3d.h" + +#include "paint_intern.h" + +#include <float.h> +#include <math.h> + +typedef struct PaintStroke { + void *mode_data; + void *smooth_stroke_cursor; + wmTimer *timer; + + /* Cached values */ + ViewContext vc; + bglMats mats; + Brush *brush; + + float last_mouse_position[2]; + + /* Set whether any stroke step has yet occured + e.g. in sculpt mode, stroke doesn't start until cursor + passes over the mesh */ + int stroke_started; + + StrokeTestStart test_start; + StrokeUpdateStep update_step; + StrokeDone done; +} PaintStroke; + +/*** Cursor ***/ +static void paint_draw_smooth_stroke(bContext *C, int x, int y, void *customdata) +{ + Brush *brush = paint_brush(paint_get_active(CTX_data_scene(C))); + PaintStroke *stroke = customdata; + + glColor4ubv(paint_get_active(CTX_data_scene(C))->paint_cursor_col); + glEnable(GL_LINE_SMOOTH); + glEnable(GL_BLEND); + + if(stroke && brush && (brush->flag & BRUSH_SMOOTH_STROKE)) { + ARegion *ar = CTX_wm_region(C); + sdrawline(x, y, (int)stroke->last_mouse_position[0] - ar->winrct.xmin, + (int)stroke->last_mouse_position[1] - ar->winrct.ymin); + } + + glDisable(GL_BLEND); + glDisable(GL_LINE_SMOOTH); +} + +static void paint_draw_cursor(bContext *C, int x, int y, void *customdata) +{ + Brush *brush = paint_brush(paint_get_active(CTX_data_scene(C))); + + glColor4ubv(paint_get_active(CTX_data_scene(C))->paint_cursor_col); + glEnable(GL_LINE_SMOOTH); + glEnable(GL_BLEND); + + glTranslatef((float)x, (float)y, 0.0f); + glutil_draw_lined_arc(0.0, M_PI*2.0, brush->size, 40); + glTranslatef((float)-x, (float)-y, 0.0f); + + glDisable(GL_BLEND); + glDisable(GL_LINE_SMOOTH); +} + +/* Put the location of the next stroke dot into the stroke RNA and apply it to the mesh */ +static void paint_brush_stroke_add_step(bContext *C, wmOperator *op, wmEvent *event, float mouse[2]) +{ + PointerRNA itemptr; + float cur_depth, pressure = 1; + float center[3]; + PaintStroke *stroke = op->customdata; + + cur_depth = read_cached_depth(&stroke->vc, mouse[0], mouse[1]); + view3d_unproject(&stroke->mats, center, mouse[0], mouse[1], cur_depth); + + /* Tablet */ + if(event->custom == EVT_DATA_TABLET) { + wmTabletData *wmtab= event->customdata; + if(wmtab->Active != EVT_TABLET_NONE) + pressure= wmtab->Pressure; + } + + /* Add to stroke */ + RNA_collection_add(op->ptr, "stroke", &itemptr); + RNA_float_set_array(&itemptr, "location", center); + RNA_float_set_array(&itemptr, "mouse", mouse); + RNA_boolean_set(&itemptr, "flip", event->shift); + RNA_float_set(&itemptr, "pressure", pressure); + + stroke->last_mouse_position[0] = mouse[0]; + stroke->last_mouse_position[1] = mouse[1]; + + stroke->update_step(C, stroke, &itemptr); +} + +/* Returns zero if no sculpt changes should be made, non-zero otherwise */ +static int paint_smooth_stroke(PaintStroke *stroke, float output[2], wmEvent *event) +{ + output[0] = event->x; + output[1] = event->y; + + if(stroke->brush->flag & BRUSH_SMOOTH_STROKE && stroke->brush->sculpt_tool != SCULPT_TOOL_GRAB) { + float u = stroke->brush->smooth_stroke_factor, v = 1.0 - u; + float dx = stroke->last_mouse_position[0] - event->x, dy = stroke->last_mouse_position[1] - event->y; + + /* If the mouse is moving within the radius of the last move, + don't update the mouse position. This allows sharp turns. */ + if(dx*dx + dy*dy < stroke->brush->smooth_stroke_radius * stroke->brush->smooth_stroke_radius) + return 0; + + output[0] = event->x * v + stroke->last_mouse_position[0] * u; + output[1] = event->y * v + stroke->last_mouse_position[1] * u; + } + + return 1; +} + +/* Returns zero if the stroke dots should not be spaced, non-zero otherwise */ +static int paint_space_stroke_enabled(Brush *br) +{ + return (br->flag & BRUSH_SPACE) && !(br->flag & BRUSH_ANCHORED) && (br->sculpt_tool != SCULPT_TOOL_GRAB); +} + +/* For brushes with stroke spacing enabled, moves mouse in steps + towards the final mouse location. */ +static int paint_space_stroke(bContext *C, wmOperator *op, wmEvent *event, const float final_mouse[2]) +{ + PaintStroke *stroke = op->customdata; + int cnt = 0; + + if(paint_space_stroke_enabled(stroke->brush)) { + float mouse[2] = {stroke->last_mouse_position[0], stroke->last_mouse_position[1]}; + float vec[2] = {final_mouse[0] - mouse[0], final_mouse[1] - mouse[1]}; + float length, scale; + int steps = 0, i; + + /* Normalize the vector between the last stroke dot and the goal */ + length = sqrt(vec[0]*vec[0] + vec[1]*vec[1]); + + if(length > FLT_EPSILON) { + scale = stroke->brush->spacing / length; + vec[0] *= scale; + vec[1] *= scale; + + steps = (int)(length / stroke->brush->spacing); + for(i = 0; i < steps; ++i, ++cnt) { + mouse[0] += vec[0]; + mouse[1] += vec[1]; + paint_brush_stroke_add_step(C, op, event, mouse); + } + } + } + + return cnt; +} + +/**** Public API ****/ + +PaintStroke *paint_stroke_new(bContext *C, StrokeTestStart test_start, + StrokeUpdateStep update_step, StrokeDone done) +{ + PaintStroke *stroke = MEM_callocN(sizeof(PaintStroke), "PaintStroke"); + + stroke->brush = paint_brush(paint_get_active(CTX_data_scene(C))); + view3d_set_viewcontext(C, &stroke->vc); + view3d_get_transformation(&stroke->vc, stroke->vc.obact, &stroke->mats); + + stroke->test_start = test_start; + stroke->update_step = update_step; + stroke->done = done; + + return stroke; +} + +int paint_stroke_modal(bContext *C, wmOperator *op, wmEvent *event) +{ + ARegion *ar = CTX_wm_region(C); + PaintStroke *stroke = op->customdata; + float mouse[2]; + + if(event->type == TIMER && (event->customdata != stroke->timer)) + return OPERATOR_RUNNING_MODAL; + + if(!stroke->stroke_started) { + stroke->last_mouse_position[0] = event->x; + stroke->last_mouse_position[1] = event->y; + stroke->stroke_started = stroke->test_start(C, op, event); + + if(stroke->stroke_started) { + stroke->smooth_stroke_cursor = + WM_paint_cursor_activate(CTX_wm_manager(C), paint_poll, paint_draw_smooth_stroke, stroke); + + if(stroke->brush->flag & BRUSH_AIRBRUSH) + stroke->timer = WM_event_add_window_timer(CTX_wm_window(C), TIMER, stroke->brush->rate); + } + + ED_region_tag_redraw(ar); + } + + if(stroke->stroke_started) { + if(paint_smooth_stroke(stroke, mouse, event)) { + if(paint_space_stroke_enabled(stroke->brush)) { + if(!paint_space_stroke(C, op, event, mouse)) + ED_region_tag_redraw(ar); + } + else + paint_brush_stroke_add_step(C, op, event, mouse); + } + else + ED_region_tag_redraw(ar); + } + + /* TODO: fix hardcoded event here */ + if(event->type == LEFTMOUSE && event->val == 0) { + /* Exit stroke, free data */ + + if(stroke->smooth_stroke_cursor) + WM_paint_cursor_end(CTX_wm_manager(C), stroke->smooth_stroke_cursor); + + if(stroke->timer) + WM_event_remove_window_timer(CTX_wm_window(C), stroke->timer); + + stroke->done(C, stroke); + MEM_freeN(stroke); + return OPERATOR_FINISHED; + } + else + return OPERATOR_RUNNING_MODAL; +} + +int paint_stroke_exec(bContext *C, wmOperator *op) +{ + PaintStroke *stroke = op->customdata; + + RNA_BEGIN(op->ptr, itemptr, "stroke") { + stroke->update_step(C, stroke, &itemptr); + } + RNA_END; + + MEM_freeN(stroke); + op->customdata = NULL; + + return OPERATOR_FINISHED; +} + +ViewContext *paint_stroke_view_context(PaintStroke *stroke) +{ + return &stroke->vc; +} + +void *paint_stroke_mode_data(struct PaintStroke *stroke) +{ + return stroke->mode_data; +} + +void paint_stroke_set_mode_data(PaintStroke *stroke, void *mode_data) +{ + stroke->mode_data = mode_data; +} + +int paint_poll(bContext *C) +{ + Paint *p = paint_get_active(CTX_data_scene(C)); + Object *ob = CTX_data_active_object(C); + + return p && ob && paint_brush(p) && + CTX_wm_area(C)->spacetype == SPACE_VIEW3D && + CTX_wm_region(C)->regiontype == RGN_TYPE_WINDOW; +} + +void paint_cursor_start(bContext *C, int (*poll)(bContext *C)) +{ + Paint *p = paint_get_active(CTX_data_scene(C)); + + if(p && !p->paint_cursor) + p->paint_cursor = WM_paint_cursor_activate(CTX_wm_manager(C), poll, paint_draw_cursor, NULL); +} + diff --git a/source/blender/editors/sculpt_paint/paint_utils.c b/source/blender/editors/sculpt_paint/paint_utils.c index 46d41c043bd..68c5232e249 100644 --- a/source/blender/editors/sculpt_paint/paint_utils.c +++ b/source/blender/editors/sculpt_paint/paint_utils.c @@ -5,21 +5,31 @@ #include "DNA_mesh_types.h" #include "DNA_meshdata_types.h" #include "DNA_object_types.h" + #include "DNA_scene_types.h" #include "DNA_screen_types.h" #include "DNA_view3d_types.h" +#include "RNA_access.h" +#include "RNA_define.h" + #include "BLI_arithb.h" #include "BKE_brush.h" +#include "BKE_context.h" #include "BKE_DerivedMesh.h" #include "BKE_global.h" +#include "BKE_paint.h" + #include "BKE_utildefines.h" #include "BIF_gl.h" #include "ED_view3d.h" +#include "WM_api.h" +#include "WM_types.h" + #include "paint_intern.h" /* 3D Paint */ @@ -160,7 +170,7 @@ int imapaint_pick_face(ViewContext *vc, Mesh *me, int *mval, unsigned int *index /* used for both 3d view and image window */ void paint_sample_color(Scene *scene, ARegion *ar, int x, int y) /* frontbuf */ { - Brush **br = current_brush_source(scene); + Brush *br = paint_brush(paint_get_active(scene)); unsigned int col; char *cp; @@ -173,10 +183,43 @@ void paint_sample_color(Scene *scene, ARegion *ar, int x, int y) /* frontbuf */ cp = (char *)&col; - if(br && *br) { - (*br)->rgb[0]= cp[0]/255.0f; - (*br)->rgb[1]= cp[1]/255.0f; - (*br)->rgb[2]= cp[2]/255.0f; + if(br) { + br->rgb[0]= cp[0]/255.0f; + br->rgb[1]= cp[1]/255.0f; + br->rgb[2]= cp[2]/255.0f; } } +static int brush_curve_preset_exec(bContext *C, wmOperator *op) +{ + Brush *br = paint_brush(paint_get_active(CTX_data_scene(C))); + brush_curve_preset(br, RNA_enum_get(op->ptr, "shape")); + + return OPERATOR_FINISHED; +} + +static int brush_curve_preset_poll(bContext *C) +{ + Brush *br = paint_brush(paint_get_active(CTX_data_scene(C))); + + return br && br->curve; +} + +void BRUSH_OT_curve_preset(wmOperatorType *ot) +{ + static EnumPropertyItem prop_shape_items[] = { + {BRUSH_PRESET_SHARP, "SHARP", 0, "Sharp", ""}, + {BRUSH_PRESET_SMOOTH, "SMOOTH", 0, "Smooth", ""}, + {BRUSH_PRESET_MAX, "MAX", 0, "Max", ""}, + {0, NULL, 0, NULL, NULL}}; + + ot->name= "Preset"; + ot->idname= "BRUSH_OT_curve_preset"; + + ot->exec= brush_curve_preset_exec; + ot->poll= brush_curve_preset_poll; + + ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; + + RNA_def_enum(ot->srna, "shape", prop_shape_items, BRUSH_PRESET_SHARP, "Mode", ""); +} diff --git a/source/blender/editors/sculpt_paint/paint_vertex.c b/source/blender/editors/sculpt_paint/paint_vertex.c index 812c41f430e..ee3d9e5baa1 100644 --- a/source/blender/editors/sculpt_paint/paint_vertex.c +++ b/source/blender/editors/sculpt_paint/paint_vertex.c @@ -62,6 +62,7 @@ #include "DNA_userdef_types.h" #include "RNA_access.h" +#include "RNA_define.h" #include "BKE_armature.h" #include "BKE_brush.h" @@ -76,6 +77,7 @@ #include "BKE_mesh.h" #include "BKE_modifier.h" #include "BKE_object.h" +#include "BKE_paint.h" #include "BKE_utildefines.h" #include "WM_api.h" @@ -90,6 +92,8 @@ #include "ED_util.h" #include "ED_view3d.h" +#include "paint_intern.h" + /* vp->mode */ #define VP_MIX 0 #define VP_ADD 1 @@ -106,9 +110,19 @@ static void error() {} /* polling - retrieve whether cursor should be set or operator should be done */ + +/* Returns true if vertex paint mode is active */ +int vertex_paint_mode_poll(bContext *C) +{ + Object *ob = CTX_data_active_object(C); + + return ob && ob->mode == OB_MODE_VERTEX_PAINT; +} + static int vp_poll(bContext *C) { - if(G.f & G_VERTEXPAINT) { + if(vertex_paint_mode_poll(C) && + paint_brush(&CTX_data_tool_settings(C)->vpaint->paint)) { ScrArea *sa= CTX_wm_area(C); if(sa->spacetype==SPACE_VIEW3D) { ARegion *ar= CTX_wm_region(C); @@ -121,7 +135,10 @@ static int vp_poll(bContext *C) static int wp_poll(bContext *C) { - if(G.f & G_WEIGHTPAINT) { + Object *ob = CTX_data_active_object(C); + + if(ob && ob->mode & OB_MODE_WEIGHT_PAINT && + paint_brush(&CTX_data_tool_settings(C)->wpaint->paint)) { ScrArea *sa= CTX_wm_area(C); if(sa->spacetype==SPACE_VIEW3D) { ARegion *ar= CTX_wm_region(C); @@ -132,56 +149,6 @@ static int wp_poll(bContext *C) return 0; } - -/* Cursors */ -static void vp_drawcursor(bContext *C, int x, int y, void *customdata) -{ - ToolSettings *ts= CTX_data_tool_settings(C); - - glTranslatef((float)x, (float)y, 0.0f); - - glColor4ub(255, 255, 255, 128); - glEnable( GL_LINE_SMOOTH ); - glEnable(GL_BLEND); - glutil_draw_lined_arc(0.0, M_PI*2.0, ts->vpaint->brush->size, 40); - glDisable(GL_BLEND); - glDisable( GL_LINE_SMOOTH ); - - glTranslatef((float)-x, (float)-y, 0.0f); -} - -static void wp_drawcursor(bContext *C, int x, int y, void *customdata) -{ - ToolSettings *ts= CTX_data_tool_settings(C); - - glTranslatef((float)x, (float)y, 0.0f); - - glColor4ub(200, 200, 255, 128); - glEnable( GL_LINE_SMOOTH ); - glEnable(GL_BLEND); - glutil_draw_lined_arc(0.0, M_PI*2.0, ts->wpaint->brush->size, 40); - glDisable(GL_BLEND); - glDisable( GL_LINE_SMOOTH ); - - glTranslatef((float)-x, (float)-y, 0.0f); -} - -static void toggle_paint_cursor(bContext *C, int wpaint) -{ - ToolSettings *ts = CTX_data_scene(C)->toolsettings; - VPaint *vp = wpaint ? ts->wpaint : ts->vpaint; - - if(vp->paintcursor) { - WM_paint_cursor_end(CTX_wm_manager(C), vp->paintcursor); - vp->paintcursor = NULL; - } - else { - vp->paintcursor = wpaint ? - WM_paint_cursor_activate(CTX_wm_manager(C), wp_poll, wp_drawcursor, NULL) : - WM_paint_cursor_activate(CTX_wm_manager(C), vp_poll, vp_drawcursor, NULL); - } -} - static VPaint *new_vpaint(int wpaint) { VPaint *vp= MEM_callocN(sizeof(VPaint), "VPaint"); @@ -232,7 +199,8 @@ unsigned int rgba_to_mcol(float r, float g, float b, float a) static unsigned int vpaint_get_current_col(VPaint *vp) { - return rgba_to_mcol(vp->brush->rgb[0], vp->brush->rgb[1], vp->brush->rgb[2], 1.0f); + Brush *brush = paint_brush(&vp->paint); + return rgba_to_mcol(brush->rgb[0], brush->rgb[1], brush->rgb[2], 1.0f); } void do_shared_vertexcol(Mesh *me) @@ -362,34 +330,7 @@ static void copy_wpaint_prev (VPaint *wp, MDeformVert *dverts, int dcount) } -void clear_vpaint(Scene *scene) -{ - Mesh *me; - Object *ob; - unsigned int *to, paintcol; - int a; - - if((G.f & G_VERTEXPAINT)==0) return; - - ob= OBACT; - me= get_mesh(ob); - if(!ob || ob->id.lib) return; - - if(me==0 || me->mcol==0 || me->totface==0) return; - - paintcol= vpaint_get_current_col(scene->toolsettings->vpaint); - - to= (unsigned int *)me->mcol; - a= 4*me->totface; - while(a--) { - *to= paintcol; - to++; - } - DAG_object_flush_update(scene, ob, OB_RECALC_DATA); - -} - -void clear_vpaint_selectedfaces(Scene *scene) +void clear_vpaint(Scene *scene, int selected) { Mesh *me; MFace *mf; @@ -409,7 +350,7 @@ void clear_vpaint_selectedfaces(Scene *scene) mf = me->mface; mcol = (unsigned int*)me->mcol; for (i = 0; i < me->totface; i++, mf++, mcol+=4) { - if (mf->flag & ME_FACE_SEL) { + if (!selected || mf->flag & ME_FACE_SEL) { mcol[0] = paintcol; mcol[1] = paintcol; mcol[2] = paintcol; @@ -540,10 +481,10 @@ void vpaint_dogamma(Scene *scene) int a, temp; unsigned char *cp, gamtab[256]; - if((G.f & G_VERTEXPAINT)==0) return; - ob= OBACT; me= get_mesh(ob); + + if(!(ob->mode & OB_MODE_VERTEX_PAINT)) return; if(me==0 || me->mcol==0 || me->totface==0) return; igam= 1.0/vp->gamma; @@ -721,6 +662,7 @@ static unsigned int mcol_darken(unsigned int col1, unsigned int col2, int fac) static void vpaint_blend(VPaint *vp, unsigned int *col, unsigned int *colorig, unsigned int paintcol, int alpha) { + Brush *brush = paint_brush(&vp->paint); if(vp->mode==VP_MIX || vp->mode==VP_BLUR) *col= mcol_blend( *col, paintcol, alpha); else if(vp->mode==VP_ADD) *col= mcol_add( *col, paintcol, alpha); @@ -734,7 +676,7 @@ static void vpaint_blend(VPaint *vp, unsigned int *col, unsigned int *colorig, u unsigned int testcol=0, a; char *cp, *ct, *co; - alpha= (int)(255.0*vp->brush->alpha); + alpha= (int)(255.0*brush->alpha); if(vp->mode==VP_MIX || vp->mode==VP_BLUR) testcol= mcol_blend( *colorig, paintcol, alpha); else if(vp->mode==VP_ADD) testcol= mcol_add( *colorig, paintcol, alpha); @@ -798,8 +740,9 @@ static int sample_backbuf_area(ViewContext *vc, int *indexar, int totface, int x return tot; } -static int calc_vp_alpha_dl(VPaint *vp, ViewContext *vc, float vpimat[][3], float *vert_nor, short *mval) +static int calc_vp_alpha_dl(VPaint *vp, ViewContext *vc, float vpimat[][3], float *vert_nor, float *mval) { + Brush *brush = paint_brush(&vp->paint); float fac, dx, dy; int alpha; short vertco[2]; @@ -810,14 +753,14 @@ static int calc_vp_alpha_dl(VPaint *vp, ViewContext *vc, float vpimat[][3], floa dy= mval[1]-vertco[1]; fac= sqrt(dx*dx + dy*dy); - if(fac > vp->brush->size) return 0; + if(fac > brush->size) return 0; if(vp->flag & VP_HARD) alpha= 255; else - alpha= 255.0*vp->brush->alpha*(1.0-fac/vp->brush->size); + alpha= 255.0*brush->alpha*(1.0-fac/brush->size); } else { - alpha= 255.0*vp->brush->alpha; + alpha= 255.0*brush->alpha; } if(vp->flag & VP_NORMALS) { @@ -839,6 +782,7 @@ static int calc_vp_alpha_dl(VPaint *vp, ViewContext *vc, float vpimat[][3], floa static void wpaint_blend(VPaint *wp, MDeformWeight *dw, MDeformWeight *uw, float alpha, float paintval) { + Brush *brush = paint_brush(&wp->paint); if(dw==NULL || uw==NULL) return; @@ -864,7 +808,7 @@ static void wpaint_blend(VPaint *wp, MDeformWeight *dw, MDeformWeight *uw, float if((wp->flag & VP_SPRAY)==0) { float testw=0.0f; - alpha= wp->brush->alpha; + alpha= brush->alpha; if(wp->mode==VP_MIX || wp->mode==VP_BLUR) testw = paintval*alpha + uw->weight*(1.0-alpha); else if(wp->mode==VP_ADD) @@ -1092,12 +1036,12 @@ static int set_wpaint(bContext *C, wmOperator *op) /* toggle */ if(me && me->totface>=MAXINDEX) { error("Maximum number of faces: %d", MAXINDEX-1); - G.f &= ~G_WEIGHTPAINT; + ob->mode &= ~OB_MODE_WEIGHT_PAINT; return OPERATOR_CANCELLED; } - if(G.f & G_WEIGHTPAINT) G.f &= ~G_WEIGHTPAINT; - else G.f |= G_WEIGHTPAINT; + if(ob->mode & OB_MODE_WEIGHT_PAINT) ob->mode &= ~OB_MODE_WEIGHT_PAINT; + else ob->mode |= OB_MODE_WEIGHT_PAINT; /* Weightpaint works by overriding colors in mesh, @@ -1107,21 +1051,20 @@ static int set_wpaint(bContext *C, wmOperator *op) /* toggle */ */ DAG_object_flush_update(scene, ob, OB_RECALC_DATA); - if(G.f & G_WEIGHTPAINT) { + if(ob->mode & OB_MODE_WEIGHT_PAINT) { Object *par; if(wp==NULL) wp= scene->toolsettings->wpaint= new_vpaint(1); - brush_check_exists(&wp->brush); - - toggle_paint_cursor(C, 1); + paint_init(&wp->paint, PAINT_CURSOR_WEIGHT_PAINT); + paint_cursor_start(C, wp_poll); mesh_octree_table(ob, NULL, NULL, 's'); /* verify if active weight group is also active bone */ par= modifiers_isDeformedByArmature(ob); - if(par && (par->flag & OB_POSEMODE)) { + if(par && (par->mode & OB_MODE_POSE)) { bPoseChannel *pchan; for(pchan= par->pose->chanbase.first; pchan; pchan= pchan->next) if(pchan->bone->flag & BONE_ACTIVE) @@ -1131,9 +1074,6 @@ static int set_wpaint(bContext *C, wmOperator *op) /* toggle */ } } else { - if(wp) - toggle_paint_cursor(C, 1); - mesh_octree_table(ob, NULL, NULL, 'e'); } @@ -1174,8 +1114,12 @@ void PAINT_OT_weight_paint_toggle(wmOperatorType *ot) static int vpaint_radial_control_invoke(bContext *C, wmOperator *op, wmEvent *event) { - toggle_paint_cursor(C, 0); - brush_radial_control_invoke(op, CTX_data_scene(C)->toolsettings->vpaint->brush, 1); + Paint *p = paint_get_active(CTX_data_scene(C)); + Brush *brush = paint_brush(p); + + WM_paint_cursor_end(CTX_wm_manager(C), p->paint_cursor); + p->paint_cursor = NULL; + brush_radial_control_invoke(op, brush, 1); return WM_radial_control_invoke(C, op, event); } @@ -1183,19 +1127,24 @@ static int vpaint_radial_control_modal(bContext *C, wmOperator *op, wmEvent *eve { int ret = WM_radial_control_modal(C, op, event); if(ret != OPERATOR_RUNNING_MODAL) - toggle_paint_cursor(C, 0); + paint_cursor_start(C, vp_poll); return ret; } static int vpaint_radial_control_exec(bContext *C, wmOperator *op) { - return brush_radial_control_exec(op, CTX_data_scene(C)->toolsettings->vpaint->brush, 1); + Brush *brush = paint_brush(&CTX_data_scene(C)->toolsettings->vpaint->paint); + return brush_radial_control_exec(op, brush, 1); } static int wpaint_radial_control_invoke(bContext *C, wmOperator *op, wmEvent *event) { - toggle_paint_cursor(C, 1); - brush_radial_control_invoke(op, CTX_data_scene(C)->toolsettings->wpaint->brush, 1); + Paint *p = paint_get_active(CTX_data_scene(C)); + Brush *brush = paint_brush(p); + + WM_paint_cursor_end(CTX_wm_manager(C), p->paint_cursor); + p->paint_cursor = NULL; + brush_radial_control_invoke(op, brush, 1); return WM_radial_control_invoke(C, op, event); } @@ -1203,13 +1152,14 @@ static int wpaint_radial_control_modal(bContext *C, wmOperator *op, wmEvent *eve { int ret = WM_radial_control_modal(C, op, event); if(ret != OPERATOR_RUNNING_MODAL) - toggle_paint_cursor(C, 1); + paint_cursor_start(C, wp_poll); return ret; } static int wpaint_radial_control_exec(bContext *C, wmOperator *op) { - return brush_radial_control_exec(op, CTX_data_scene(C)->toolsettings->wpaint->brush, 1); + Brush *brush = paint_brush(&CTX_data_scene(C)->toolsettings->wpaint->paint); + return brush_radial_control_exec(op, brush, 1); } void PAINT_OT_weight_paint_radial_control(wmOperatorType *ot) @@ -1254,206 +1204,10 @@ struct WPaintData { float wpimat[3][3]; }; -static void wpaint_exit(bContext *C, wmOperator *op) -{ - ToolSettings *ts= CTX_data_tool_settings(C); - Object *ob= CTX_data_active_object(C); - struct WPaintData *wpd= op->customdata; - - if(wpd->vertexcosnos) - MEM_freeN(wpd->vertexcosnos); - MEM_freeN(wpd->indexar); - - /* frees prev buffer */ - copy_wpaint_prev(ts->wpaint, NULL, 0); - - /* and particles too */ - if(ob->particlesystem.first) { - ParticleSystem *psys; - int i; - - for(psys= ob->particlesystem.first; psys; psys= psys->next) { - for(i=0; i<PSYS_TOT_VG; i++) { - if(psys->vgroup[i]==ob->actdef) { - psys->recalc |= PSYS_RECALC_RESET; - break; - } - } - } - } - - DAG_object_flush_update(CTX_data_scene(C), ob, OB_RECALC_DATA); - - MEM_freeN(wpd); - op->customdata= NULL; -} - - -static int wpaint_modal(bContext *C, wmOperator *op, wmEvent *event) -{ - ToolSettings *ts= CTX_data_tool_settings(C); - VPaint *wp= ts->wpaint; - - switch(event->type) { - case LEFTMOUSE: - if(event->val==0) { /* release */ - wpaint_exit(C, op); - return OPERATOR_FINISHED; - } - /* pass on, first press gets painted too */ - - case MOUSEMOVE: - { - struct WPaintData *wpd= op->customdata; - ViewContext *vc= &wpd->vc; - Object *ob= vc->obact; - Mesh *me= ob->data; - float mat[4][4]; - float paintweight= ts->vgroup_weight; - int *indexar= wpd->indexar; - int totindex, index, alpha, totw; - short mval[2]; - - view3d_operator_needs_opengl(C); - - /* load projection matrix */ - wmMultMatrix(ob->obmat); - wmGetSingleMatrix(mat); - wmLoadMatrix(wpd->vc.rv3d->viewmat); - - MTC_Mat4SwapMat4(wpd->vc.rv3d->persmat, mat); - - mval[0]= event->x - vc->ar->winrct.xmin; - mval[1]= event->y - vc->ar->winrct.ymin; - - /* which faces are involved */ - if(wp->flag & VP_AREA) { - totindex= sample_backbuf_area(vc, indexar, me->totface, mval[0], mval[1], wp->brush->size); - } - else { - indexar[0]= view3d_sample_backbuf(vc, mval[0], mval[1]); - if(indexar[0]) totindex= 1; - else totindex= 0; - } - - if(wp->flag & VP_COLINDEX) { - for(index=0; index<totindex; index++) { - if(indexar[index] && indexar[index]<=me->totface) { - MFace *mface= ((MFace *)me->mface) + (indexar[index]-1); - - if(mface->mat_nr!=ob->actcol-1) { - indexar[index]= 0; - } - } - } - } - - if((G.f & G_FACESELECT) && me->mface) { - for(index=0; index<totindex; index++) { - if(indexar[index] && indexar[index]<=me->totface) { - MFace *mface= ((MFace *)me->mface) + (indexar[index]-1); - - if((mface->flag & ME_FACE_SEL)==0) { - indexar[index]= 0; - } - } - } - } - - /* make sure each vertex gets treated only once */ - /* and calculate filter weight */ - totw= 0; - if(wp->mode==VP_BLUR) - paintweight= 0.0f; - else - paintweight= ts->vgroup_weight; - - for(index=0; index<totindex; index++) { - if(indexar[index] && indexar[index]<=me->totface) { - MFace *mface= me->mface + (indexar[index]-1); - - (me->dvert+mface->v1)->flag= 1; - (me->dvert+mface->v2)->flag= 1; - (me->dvert+mface->v3)->flag= 1; - if(mface->v4) (me->dvert+mface->v4)->flag= 1; - - if(wp->mode==VP_BLUR) { - MDeformWeight *dw, *(*dw_func)(MDeformVert *, int) = verify_defweight; - - if(wp->flag & VP_ONLYVGROUP) - dw_func= get_defweight; - - dw= dw_func(me->dvert+mface->v1, ob->actdef-1); - if(dw) {paintweight+= dw->weight; totw++;} - dw= dw_func(me->dvert+mface->v2, ob->actdef-1); - if(dw) {paintweight+= dw->weight; totw++;} - dw= dw_func(me->dvert+mface->v3, ob->actdef-1); - if(dw) {paintweight+= dw->weight; totw++;} - if(mface->v4) { - dw= dw_func(me->dvert+mface->v4, ob->actdef-1); - if(dw) {paintweight+= dw->weight; totw++;} - } - } - } - } - - if(wp->mode==VP_BLUR) - paintweight/= (float)totw; - - for(index=0; index<totindex; index++) { - - if(indexar[index] && indexar[index]<=me->totface) { - MFace *mface= me->mface + (indexar[index]-1); - - if((me->dvert+mface->v1)->flag) { - alpha= calc_vp_alpha_dl(wp, vc, wpd->wpimat, wpd->vertexcosnos+6*mface->v1, mval); - if(alpha) { - do_weight_paint_vertex(wp, ob, mface->v1, alpha, paintweight, wpd->vgroup_mirror); - } - (me->dvert+mface->v1)->flag= 0; - } - - if((me->dvert+mface->v2)->flag) { - alpha= calc_vp_alpha_dl(wp, vc, wpd->wpimat, wpd->vertexcosnos+6*mface->v2, mval); - if(alpha) { - do_weight_paint_vertex(wp, ob, mface->v2, alpha, paintweight, wpd->vgroup_mirror); - } - (me->dvert+mface->v2)->flag= 0; - } - - if((me->dvert+mface->v3)->flag) { - alpha= calc_vp_alpha_dl(wp, vc, wpd->wpimat, wpd->vertexcosnos+6*mface->v3, mval); - if(alpha) { - do_weight_paint_vertex(wp, ob, mface->v3, alpha, paintweight, wpd->vgroup_mirror); - } - (me->dvert+mface->v3)->flag= 0; - } - - if((me->dvert+mface->v4)->flag) { - if(mface->v4) { - alpha= calc_vp_alpha_dl(wp, vc, wpd->wpimat, wpd->vertexcosnos+6*mface->v4, mval); - if(alpha) { - do_weight_paint_vertex(wp, ob, mface->v4, alpha, paintweight, wpd->vgroup_mirror); - } - (me->dvert+mface->v4)->flag= 0; - } - } - } - } - - MTC_Mat4SwapMat4(vc->rv3d->persmat, mat); - - DAG_object_flush_update(vc->scene, ob, OB_RECALC_DATA); - ED_region_tag_redraw(vc->ar); - } - } - - return OPERATOR_RUNNING_MODAL; -} - -static int wpaint_invoke(bContext *C, wmOperator *op, wmEvent *event) +static int wpaint_stroke_test_start(bContext *C, wmOperator *op, wmEvent *event) { Scene *scene= CTX_data_scene(C); + struct PaintStroke *stroke = op->customdata; ToolSettings *ts= CTX_data_tool_settings(C); VPaint *wp= ts->wpaint; Object *ob= CTX_data_active_object(C); @@ -1462,7 +1216,6 @@ static int wpaint_invoke(bContext *C, wmOperator *op, wmEvent *event) float mat[4][4], imat[4][4]; if(scene->obedit) return OPERATOR_CANCELLED; - // XXX if(multires_level1_test()) return; me= get_mesh(ob); if(me==NULL || me->totface==0) return OPERATOR_PASS_THROUGH; @@ -1471,8 +1224,9 @@ static int wpaint_invoke(bContext *C, wmOperator *op, wmEvent *event) if (!me->dvert) create_dverts(&me->id); - /* make customdata storage */ - op->customdata= wpd= MEM_callocN(sizeof(struct WPaintData), "WPaintData"); + /* make mode data storage */ + wpd= MEM_callocN(sizeof(struct WPaintData), "WPaintData"); + paint_stroke_set_mode_data(stroke, wpd); view3d_set_viewcontext(C, &wpd->vc); wpd->vgroup_mirror= -1; @@ -1544,11 +1298,203 @@ static int wpaint_invoke(bContext *C, wmOperator *op, wmEvent *event) } } - /* do paint once for click only paint */ - wpaint_modal(C, op, event); + return 1; +} + +static void wpaint_stroke_update_step(bContext *C, struct PaintStroke *stroke, PointerRNA *itemptr) +{ + ToolSettings *ts= CTX_data_tool_settings(C); + VPaint *wp= ts->wpaint; + Brush *brush = paint_brush(&wp->paint); + struct WPaintData *wpd= paint_stroke_mode_data(stroke); + ViewContext *vc= &wpd->vc; + Object *ob= vc->obact; + Mesh *me= ob->data; + float mat[4][4]; + float paintweight= ts->vgroup_weight; + int *indexar= wpd->indexar; + int totindex, index, alpha, totw; + float mval[2]; + + view3d_operator_needs_opengl(C); + + /* load projection matrix */ + wmMultMatrix(ob->obmat); + wmGetSingleMatrix(mat); + wmLoadMatrix(wpd->vc.rv3d->viewmat); + + RNA_float_get_array(itemptr, "mouse", mval); + mval[0]-= vc->ar->winrct.xmin; + mval[1]-= vc->ar->winrct.ymin; + + MTC_Mat4SwapMat4(wpd->vc.rv3d->persmat, mat); + + /* which faces are involved */ + if(wp->flag & VP_AREA) { + totindex= sample_backbuf_area(vc, indexar, me->totface, mval[0], mval[1], brush->size); + } + else { + indexar[0]= view3d_sample_backbuf(vc, mval[0], mval[1]); + if(indexar[0]) totindex= 1; + else totindex= 0; + } + + if(wp->flag & VP_COLINDEX) { + for(index=0; index<totindex; index++) { + if(indexar[index] && indexar[index]<=me->totface) { + MFace *mface= ((MFace *)me->mface) + (indexar[index]-1); + + if(mface->mat_nr!=ob->actcol-1) { + indexar[index]= 0; + } + } + } + } + + if((G.f & G_FACESELECT) && me->mface) { + for(index=0; index<totindex; index++) { + if(indexar[index] && indexar[index]<=me->totface) { + MFace *mface= ((MFace *)me->mface) + (indexar[index]-1); + + if((mface->flag & ME_FACE_SEL)==0) { + indexar[index]= 0; + } + } + } + } + + /* make sure each vertex gets treated only once */ + /* and calculate filter weight */ + totw= 0; + if(wp->mode==VP_BLUR) + paintweight= 0.0f; + else + paintweight= ts->vgroup_weight; + + for(index=0; index<totindex; index++) { + if(indexar[index] && indexar[index]<=me->totface) { + MFace *mface= me->mface + (indexar[index]-1); + + (me->dvert+mface->v1)->flag= 1; + (me->dvert+mface->v2)->flag= 1; + (me->dvert+mface->v3)->flag= 1; + if(mface->v4) (me->dvert+mface->v4)->flag= 1; + + if(wp->mode==VP_BLUR) { + MDeformWeight *dw, *(*dw_func)(MDeformVert *, int) = verify_defweight; + + if(wp->flag & VP_ONLYVGROUP) + dw_func= get_defweight; + + dw= dw_func(me->dvert+mface->v1, ob->actdef-1); + if(dw) {paintweight+= dw->weight; totw++;} + dw= dw_func(me->dvert+mface->v2, ob->actdef-1); + if(dw) {paintweight+= dw->weight; totw++;} + dw= dw_func(me->dvert+mface->v3, ob->actdef-1); + if(dw) {paintweight+= dw->weight; totw++;} + if(mface->v4) { + dw= dw_func(me->dvert+mface->v4, ob->actdef-1); + if(dw) {paintweight+= dw->weight; totw++;} + } + } + } + } + + if(wp->mode==VP_BLUR) + paintweight/= (float)totw; + + for(index=0; index<totindex; index++) { + + if(indexar[index] && indexar[index]<=me->totface) { + MFace *mface= me->mface + (indexar[index]-1); + + if((me->dvert+mface->v1)->flag) { + alpha= calc_vp_alpha_dl(wp, vc, wpd->wpimat, wpd->vertexcosnos+6*mface->v1, mval); + if(alpha) { + do_weight_paint_vertex(wp, ob, mface->v1, alpha, paintweight, wpd->vgroup_mirror); + } + (me->dvert+mface->v1)->flag= 0; + } + + if((me->dvert+mface->v2)->flag) { + alpha= calc_vp_alpha_dl(wp, vc, wpd->wpimat, wpd->vertexcosnos+6*mface->v2, mval); + if(alpha) { + do_weight_paint_vertex(wp, ob, mface->v2, alpha, paintweight, wpd->vgroup_mirror); + } + (me->dvert+mface->v2)->flag= 0; + } + + if((me->dvert+mface->v3)->flag) { + alpha= calc_vp_alpha_dl(wp, vc, wpd->wpimat, wpd->vertexcosnos+6*mface->v3, mval); + if(alpha) { + do_weight_paint_vertex(wp, ob, mface->v3, alpha, paintweight, wpd->vgroup_mirror); + } + (me->dvert+mface->v3)->flag= 0; + } + + if((me->dvert+mface->v4)->flag) { + if(mface->v4) { + alpha= calc_vp_alpha_dl(wp, vc, wpd->wpimat, wpd->vertexcosnos+6*mface->v4, mval); + if(alpha) { + do_weight_paint_vertex(wp, ob, mface->v4, alpha, paintweight, wpd->vgroup_mirror); + } + (me->dvert+mface->v4)->flag= 0; + } + } + } + } + + MTC_Mat4SwapMat4(vc->rv3d->persmat, mat); + + DAG_object_flush_update(vc->scene, ob, OB_RECALC_DATA); + ED_region_tag_redraw(vc->ar); +} + +static void wpaint_stroke_done(bContext *C, struct PaintStroke *stroke) +{ + ToolSettings *ts= CTX_data_tool_settings(C); + Object *ob= CTX_data_active_object(C); + struct WPaintData *wpd= paint_stroke_mode_data(stroke); + + if(wpd->vertexcosnos) + MEM_freeN(wpd->vertexcosnos); + MEM_freeN(wpd->indexar); + + /* frees prev buffer */ + copy_wpaint_prev(ts->wpaint, NULL, 0); + + /* and particles too */ + if(ob->particlesystem.first) { + ParticleSystem *psys; + int i; + + for(psys= ob->particlesystem.first; psys; psys= psys->next) { + for(i=0; i<PSYS_TOT_VG; i++) { + if(psys->vgroup[i]==ob->actdef) { + psys->recalc |= PSYS_RECALC_RESET; + break; + } + } + } + } + + DAG_object_flush_update(CTX_data_scene(C), ob, OB_RECALC_DATA); + + MEM_freeN(wpd); +} + + +static int wpaint_invoke(bContext *C, wmOperator *op, wmEvent *event) +{ + + op->customdata = paint_stroke_new(C, wpaint_stroke_test_start, + wpaint_stroke_update_step, + wpaint_stroke_done); /* add modal handler */ WM_event_add_modal_handler(C, &CTX_wm_window(C)->handlers, op); + + op->type->modal(C, op, event); return OPERATOR_RUNNING_MODAL; } @@ -1562,13 +1508,14 @@ void PAINT_OT_weight_paint(wmOperatorType *ot) /* api callbacks */ ot->invoke= wpaint_invoke; - ot->modal= wpaint_modal; + ot->modal= paint_stroke_modal; /* ot->exec= vpaint_exec; <-- needs stroke property */ ot->poll= wp_poll; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO|OPTYPE_BLOCKING; - + + RNA_def_collection_runtime(ot->srna, "stroke", &RNA_OperatorStrokeElement, "Stroke", ""); } /* ************ set / clear vertex paint mode ********** */ @@ -1584,40 +1531,35 @@ static int set_vpaint(bContext *C, wmOperator *op) /* toggle */ me= get_mesh(ob); if(me==NULL || object_data_is_libdata(ob)) { - G.f &= ~G_VERTEXPAINT; + ob->mode &= ~OB_MODE_VERTEX_PAINT; return OPERATOR_PASS_THROUGH; } if(me && me->totface>=MAXINDEX) { error("Maximum number of faces: %d", MAXINDEX-1); - G.f &= ~G_VERTEXPAINT; + ob->mode &= ~OB_MODE_VERTEX_PAINT; return OPERATOR_FINISHED; } if(me && me->mcol==NULL) make_vertexcol(scene, 0); /* toggle: end vpaint */ - if(G.f & G_VERTEXPAINT) { + if(ob->mode & OB_MODE_VERTEX_PAINT) { - G.f &= ~G_VERTEXPAINT; - - if(vp) { - toggle_paint_cursor(C, 0); - vp->paintcursor= NULL; - } + ob->mode &= ~OB_MODE_VERTEX_PAINT; } else { - - G.f |= G_VERTEXPAINT; + ob->mode |= OB_MODE_VERTEX_PAINT; /* Turn off weight painting */ - if (G.f & G_WEIGHTPAINT) + if (ob->mode & OB_MODE_WEIGHT_PAINT) set_wpaint(C, op); if(vp==NULL) vp= scene->toolsettings->vpaint= new_vpaint(0); - toggle_paint_cursor(C, 0); - brush_check_exists(&scene->toolsettings->vpaint->brush); + paint_cursor_start(C, vp_poll); + + paint_init(&vp->paint, PAINT_CURSOR_VERTEX_PAINT); } if (me) @@ -1676,177 +1618,175 @@ struct VPaintData { float vpimat[3][3]; }; -static void vpaint_exit(bContext *C, wmOperator *op) +static int vpaint_stroke_test_start(bContext *C, struct wmOperator *op, wmEvent *event) { ToolSettings *ts= CTX_data_tool_settings(C); - struct VPaintData *vpd= op->customdata; + struct PaintStroke *stroke = op->customdata; + VPaint *vp= ts->vpaint; + struct VPaintData *vpd; + Object *ob= CTX_data_active_object(C); + Mesh *me; + float mat[4][4], imat[4][4]; + + /* context checks could be a poll() */ + me= get_mesh(ob); + if(me==NULL || me->totface==0) return OPERATOR_PASS_THROUGH; - if(vpd->vertexcosnos) - MEM_freeN(vpd->vertexcosnos); - MEM_freeN(vpd->indexar); + if(me->mcol==NULL) make_vertexcol(CTX_data_scene(C), 0); + if(me->mcol==NULL) return OPERATOR_CANCELLED; - /* frees prev buffer */ - copy_vpaint_prev(ts->vpaint, NULL, 0); + /* make mode data storage */ + vpd= MEM_callocN(sizeof(struct VPaintData), "VPaintData"); + paint_stroke_set_mode_data(stroke, vpd); + view3d_set_viewcontext(C, &vpd->vc); - MEM_freeN(vpd); - op->customdata= NULL; + vpd->vertexcosnos= mesh_get_mapped_verts_nors(vpd->vc.scene, ob); + vpd->indexar= get_indexarray(); + vpd->paintcol= vpaint_get_current_col(vp); + + /* for filtering */ + copy_vpaint_prev(vp, (unsigned int *)me->mcol, me->totface); + + /* some old cruft to sort out later */ + Mat4MulMat4(mat, ob->obmat, vpd->vc.rv3d->viewmat); + Mat4Invert(imat, mat); + Mat3CpyMat4(vpd->vpimat, imat); + + return 1; } -static int vpaint_modal(bContext *C, wmOperator *op, wmEvent *event) +static void vpaint_stroke_update_step(bContext *C, struct PaintStroke *stroke, PointerRNA *itemptr) { ToolSettings *ts= CTX_data_tool_settings(C); + struct VPaintData *vpd = paint_stroke_mode_data(stroke); VPaint *vp= ts->vpaint; - - switch(event->type) { - case LEFTMOUSE: - if(event->val==0) { /* release */ - vpaint_exit(C, op); - return OPERATOR_FINISHED; - } - /* pass on, first press gets painted too */ - - case MOUSEMOVE: - { - struct VPaintData *vpd= op->customdata; - ViewContext *vc= &vpd->vc; - Object *ob= vc->obact; - Mesh *me= ob->data; - float mat[4][4]; - int *indexar= vpd->indexar; - int totindex, index; - short mval[2]; + Brush *brush = paint_brush(&vp->paint); + ViewContext *vc= &vpd->vc; + Object *ob= vc->obact; + Mesh *me= ob->data; + float mat[4][4]; + int *indexar= vpd->indexar; + int totindex, index; + float mval[2]; + + RNA_float_get_array(itemptr, "mouse", mval); - view3d_operator_needs_opengl(C); + view3d_operator_needs_opengl(C); - /* load projection matrix */ - wmMultMatrix(ob->obmat); - wmGetSingleMatrix(mat); - wmLoadMatrix(vc->rv3d->viewmat); + /* load projection matrix */ + wmMultMatrix(ob->obmat); + wmGetSingleMatrix(mat); + wmLoadMatrix(vc->rv3d->viewmat); + + mval[0]-= vc->ar->winrct.xmin; + mval[1]-= vc->ar->winrct.ymin; + - mval[0]= event->x - vc->ar->winrct.xmin; - mval[1]= event->y - vc->ar->winrct.ymin; - - /* which faces are involved */ - if(vp->flag & VP_AREA) { - totindex= sample_backbuf_area(vc, indexar, me->totface, mval[0], mval[1], vp->brush->size); - } - else { - indexar[0]= view3d_sample_backbuf(vc, mval[0], mval[1]); - if(indexar[0]) totindex= 1; - else totindex= 0; - } + /* which faces are involved */ + if(vp->flag & VP_AREA) { + totindex= sample_backbuf_area(vc, indexar, me->totface, mval[0], mval[1], brush->size); + } + else { + indexar[0]= view3d_sample_backbuf(vc, mval[0], mval[1]); + if(indexar[0]) totindex= 1; + else totindex= 0; + } - MTC_Mat4SwapMat4(vc->rv3d->persmat, mat); + MTC_Mat4SwapMat4(vc->rv3d->persmat, mat); - if(vp->flag & VP_COLINDEX) { - for(index=0; index<totindex; index++) { - if(indexar[index] && indexar[index]<=me->totface) { - MFace *mface= ((MFace *)me->mface) + (indexar[index]-1); + if(vp->flag & VP_COLINDEX) { + for(index=0; index<totindex; index++) { + if(indexar[index] && indexar[index]<=me->totface) { + MFace *mface= ((MFace *)me->mface) + (indexar[index]-1); - if(mface->mat_nr!=ob->actcol-1) { - indexar[index]= 0; - } - } + if(mface->mat_nr!=ob->actcol-1) { + indexar[index]= 0; } - } - if((G.f & G_FACESELECT) && me->mface) { - for(index=0; index<totindex; index++) { - if(indexar[index] && indexar[index]<=me->totface) { - MFace *mface= ((MFace *)me->mface) + (indexar[index]-1); + } + } + } + if((G.f & G_FACESELECT) && me->mface) { + for(index=0; index<totindex; index++) { + if(indexar[index] && indexar[index]<=me->totface) { + MFace *mface= ((MFace *)me->mface) + (indexar[index]-1); - if((mface->flag & ME_FACE_SEL)==0) - indexar[index]= 0; - } - } - } + if((mface->flag & ME_FACE_SEL)==0) + indexar[index]= 0; + } + } + } - for(index=0; index<totindex; index++) { + for(index=0; index<totindex; index++) { - if(indexar[index] && indexar[index]<=me->totface) { - MFace *mface= ((MFace *)me->mface) + (indexar[index]-1); - unsigned int *mcol= ( (unsigned int *)me->mcol) + 4*(indexar[index]-1); - unsigned int *mcolorig= ( (unsigned int *)vp->vpaint_prev) + 4*(indexar[index]-1); - int alpha; + if(indexar[index] && indexar[index]<=me->totface) { + MFace *mface= ((MFace *)me->mface) + (indexar[index]-1); + unsigned int *mcol= ( (unsigned int *)me->mcol) + 4*(indexar[index]-1); + unsigned int *mcolorig= ( (unsigned int *)vp->vpaint_prev) + 4*(indexar[index]-1); + int alpha; - if(vp->mode==VP_BLUR) { - unsigned int fcol1= mcol_blend( mcol[0], mcol[1], 128); - if(mface->v4) { - unsigned int fcol2= mcol_blend( mcol[2], mcol[3], 128); - vpd->paintcol= mcol_blend( fcol1, fcol2, 128); - } - else { - vpd->paintcol= mcol_blend( mcol[2], fcol1, 170); - } + if(vp->mode==VP_BLUR) { + unsigned int fcol1= mcol_blend( mcol[0], mcol[1], 128); + if(mface->v4) { + unsigned int fcol2= mcol_blend( mcol[2], mcol[3], 128); + vpd->paintcol= mcol_blend( fcol1, fcol2, 128); + } + else { + vpd->paintcol= mcol_blend( mcol[2], fcol1, 170); + } - } + } - alpha= calc_vp_alpha_dl(vp, vc, vpd->vpimat, vpd->vertexcosnos+6*mface->v1, mval); - if(alpha) vpaint_blend(vp, mcol, mcolorig, vpd->paintcol, alpha); + alpha= calc_vp_alpha_dl(vp, vc, vpd->vpimat, vpd->vertexcosnos+6*mface->v1, mval); + if(alpha) vpaint_blend(vp, mcol, mcolorig, vpd->paintcol, alpha); - alpha= calc_vp_alpha_dl(vp, vc, vpd->vpimat, vpd->vertexcosnos+6*mface->v2, mval); - if(alpha) vpaint_blend(vp, mcol+1, mcolorig+1, vpd->paintcol, alpha); + alpha= calc_vp_alpha_dl(vp, vc, vpd->vpimat, vpd->vertexcosnos+6*mface->v2, mval); + if(alpha) vpaint_blend(vp, mcol+1, mcolorig+1, vpd->paintcol, alpha); - alpha= calc_vp_alpha_dl(vp, vc, vpd->vpimat, vpd->vertexcosnos+6*mface->v3, mval); - if(alpha) vpaint_blend(vp, mcol+2, mcolorig+2, vpd->paintcol, alpha); + alpha= calc_vp_alpha_dl(vp, vc, vpd->vpimat, vpd->vertexcosnos+6*mface->v3, mval); + if(alpha) vpaint_blend(vp, mcol+2, mcolorig+2, vpd->paintcol, alpha); - if(mface->v4) { - alpha= calc_vp_alpha_dl(vp, vc, vpd->vpimat, vpd->vertexcosnos+6*mface->v4, mval); - if(alpha) vpaint_blend(vp, mcol+3, mcolorig+3, vpd->paintcol, alpha); - } - } + if(mface->v4) { + alpha= calc_vp_alpha_dl(vp, vc, vpd->vpimat, vpd->vertexcosnos+6*mface->v4, mval); + if(alpha) vpaint_blend(vp, mcol+3, mcolorig+3, vpd->paintcol, alpha); } + } + } - MTC_Mat4SwapMat4(vc->rv3d->persmat, mat); + MTC_Mat4SwapMat4(vc->rv3d->persmat, mat); - do_shared_vertexcol(me); + do_shared_vertexcol(me); - ED_region_tag_redraw(vc->ar); + ED_region_tag_redraw(vc->ar); - DAG_object_flush_update(vc->scene, ob, OB_RECALC_DATA); - } - break; - } - - return OPERATOR_RUNNING_MODAL; + DAG_object_flush_update(vc->scene, ob, OB_RECALC_DATA); } -static int vpaint_invoke(bContext *C, wmOperator *op, wmEvent *event) +static void vpaint_stroke_done(bContext *C, struct PaintStroke *stroke) { ToolSettings *ts= CTX_data_tool_settings(C); - VPaint *vp= ts->vpaint; - struct VPaintData *vpd; - Object *ob= CTX_data_active_object(C); - Mesh *me; - float mat[4][4], imat[4][4]; + struct VPaintData *vpd= paint_stroke_mode_data(stroke); - /* context checks could be a poll() */ - me= get_mesh(ob); - if(me==NULL || me->totface==0) return OPERATOR_PASS_THROUGH; - - if(me->mcol==NULL) make_vertexcol(CTX_data_scene(C), 0); - if(me->mcol==NULL) return OPERATOR_CANCELLED; - - /* make customdata storage */ - op->customdata= vpd= MEM_callocN(sizeof(struct VPaintData), "VPaintData"); - view3d_set_viewcontext(C, &vpd->vc); - - vpd->vertexcosnos= mesh_get_mapped_verts_nors(vpd->vc.scene, ob); - vpd->indexar= get_indexarray(); - vpd->paintcol= vpaint_get_current_col(vp); + if(vpd->vertexcosnos) + MEM_freeN(vpd->vertexcosnos); + MEM_freeN(vpd->indexar); - /* for filtering */ - copy_vpaint_prev(vp, (unsigned int *)me->mcol, me->totface); + /* frees prev buffer */ + copy_vpaint_prev(ts->vpaint, NULL, 0); - /* some old cruft to sort out later */ - Mat4MulMat4(mat, ob->obmat, vpd->vc.rv3d->viewmat); - Mat4Invert(imat, mat); - Mat3CpyMat4(vpd->vpimat, imat); + MEM_freeN(vpd); +} + +static int vpaint_invoke(bContext *C, wmOperator *op, wmEvent *event) +{ - /* do paint once for click only paint */ - vpaint_modal(C, op, event); + op->customdata = paint_stroke_new(C, vpaint_stroke_test_start, + vpaint_stroke_update_step, + vpaint_stroke_done); /* add modal handler */ WM_event_add_modal_handler(C, &CTX_wm_window(C)->handlers, op); + + op->type->modal(C, op, event); return OPERATOR_RUNNING_MODAL; } @@ -1859,11 +1799,13 @@ void PAINT_OT_vertex_paint(wmOperatorType *ot) /* api callbacks */ ot->invoke= vpaint_invoke; - ot->modal= vpaint_modal; + ot->modal= paint_stroke_modal; /* ot->exec= vpaint_exec; <-- needs stroke property */ ot->poll= vp_poll; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO|OPTYPE_BLOCKING; + + RNA_def_collection_runtime(ot->srna, "stroke", &RNA_OperatorStrokeElement, "Stroke", ""); } diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c index 8cca135d99d..ba48bebce78 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -64,6 +64,7 @@ #include "BKE_mesh.h" #include "BKE_modifier.h" #include "BKE_multires.h" +#include "BKE_paint.h" #include "BKE_sculpt.h" #include "BKE_texture.h" #include "BKE_utildefines.h" @@ -79,6 +80,7 @@ #include "ED_space_api.h" #include "ED_util.h" #include "ED_view3d.h" +#include "paint_intern.h" #include "sculpt_intern.h" #include "RNA_access.h" @@ -124,29 +126,27 @@ typedef enum StrokeFlags { */ typedef struct StrokeCache { /* Invariants */ - float radius; + float initial_radius; float scale[3]; int flag; float clip_tolerance[3]; - int initial_mouse[2]; + float initial_mouse[2]; float depth; /* Variants */ + float radius; float true_location[3]; float location[3]; float flip; float pressure; - int mouse[2]; + float mouse[2]; /* The rest is temporary storage that isn't saved as a property */ int first_time; /* Beginning of stroke may do some things special */ - ViewContext vc; bglMats *mats; - float *layer_disps; /* Displacements for each vertex */ - float (*mesh_store)[3]; /* Copy of the mesh vertices' locations */ short (*orig_norms)[3]; /* Copy of the mesh vertices' normals */ float (*face_norms)[3]; /* Copy of the mesh faces' normals */ float rotation; /* Texture rotation (radians) for anchored and rake modes */ @@ -178,19 +178,6 @@ typedef struct ProjVert { * Simple functions to get data from the GL */ -/* Uses window coordinates (x,y) and depth component z to find a point in - modelspace */ -static void unproject(bglMats *mats, float out[3], const short x, const short y, const float z) -{ - double ux, uy, uz; - - gluUnProject(x,y,z, mats->modelview, mats->projection, - (GLint *)mats->viewport, &ux, &uy, &uz ); - out[0] = ux; - out[1] = uy; - out[2] = uz; -} - /* Convert a point in model coordinates to 2D screen coordinates. */ static void projectf(bglMats *mats, const float v[3], float p[2]) { @@ -215,36 +202,23 @@ static void project(bglMats *mats, const float v[3], short p[2]) * */ -/* Return modified brush size. Uses current tablet pressure (if available) to - shrink the brush. Skipped for grab brush because only the first mouse down - size is used, which is small if the user has just touched the pen to the - tablet */ -static char brush_size(Sculpt *sd) -{ - float size= sd->brush->size; - - if((sd->brush->sculpt_tool != SCULPT_TOOL_GRAB) && (sd->brush->flag & BRUSH_SIZE_PRESSURE)) - size *= sd->session->cache->pressure; - - return size; -} - /* Return modified brush strength. Includes the direction of the brush, positive values pull vertices, negative values push. Uses tablet pressure and a special multiplier found experimentally to scale the strength factor. */ static float brush_strength(Sculpt *sd, StrokeCache *cache) { + Brush *brush = paint_brush(&sd->paint); /* Primary strength input; square it to make lower values more sensitive */ - float alpha = sd->brush->alpha * sd->brush->alpha; + float alpha = brush->alpha * brush->alpha; - float dir= sd->brush->flag & BRUSH_DIR_IN ? -1 : 1; + float dir= brush->flag & BRUSH_DIR_IN ? -1 : 1; float pressure= 1; float flip= cache->flip ? -1:1; - if(sd->brush->flag & BRUSH_ALPHA_PRESSURE) + if(brush->flag & BRUSH_ALPHA_PRESSURE) pressure *= cache->pressure; - switch(sd->brush->sculpt_tool){ + switch(brush->sculpt_tool){ case SCULPT_TOOL_DRAW: case SCULPT_TOOL_INFLATE: case SCULPT_TOOL_CLAY: @@ -263,7 +237,7 @@ static float brush_strength(Sculpt *sd, StrokeCache *cache) } /* Handles clipping against a mirror modifier and SCULPT_LOCK axis flags */ -static void sculpt_clip(Sculpt *sd, float *co, const float val[3]) +static void sculpt_clip(Sculpt *sd, SculptSession *ss, float *co, const float val[3]) { int i; @@ -271,7 +245,7 @@ static void sculpt_clip(Sculpt *sd, float *co, const float val[3]) if(sd->flags & (SCULPT_LOCK_X << i)) continue; - if((sd->session->cache->flag & (CLIP_X << i)) && (fabs(co[i]) <= sd->session->cache->clip_tolerance[i])) + if((ss->cache->flag & (CLIP_X << i)) && (fabs(co[i]) <= ss->cache->clip_tolerance[i])) co[i]= 0.0f; else co[i]= val[i]; @@ -293,23 +267,24 @@ static void add_norm_if(float view_vec[3], float out[3], float out_flip[3], cons /* Currently only for the draw brush; finds average normal for all active vertices */ -static void calc_area_normal(Sculpt *sd, float out[3], const ListBase* active_verts) +static void calc_area_normal(Sculpt *sd, SculptSession *ss, float out[3], const ListBase* active_verts) { - StrokeCache *cache = sd->session->cache; + Brush *brush = paint_brush(&sd->paint); + StrokeCache *cache = ss->cache; ActiveData *node = active_verts->first; - const int view = 0; /* XXX: should probably be a flag, not number: sd->brush_type==SCULPT_TOOL_DRAW ? sculptmode_brush()->view : 0; */ + const int view = 0; /* XXX: should probably be a flag, not number: brush_type==SCULPT_TOOL_DRAW ? sculptmode_brush()->view : 0; */ float out_flip[3]; float *out_dir = cache->view_normal_symmetry; out[0]=out[1]=out[2] = out_flip[0]=out_flip[1]=out_flip[2] = 0; - if(sd->brush->flag & BRUSH_ANCHORED) { + if(brush->flag & BRUSH_ANCHORED) { for(; node; node = node->next) add_norm_if(out_dir, out, out_flip, cache->orig_norms[node->Index]); } else { for(; node; node = node->next) - add_norm_if(out_dir, out, out_flip, sd->session->mvert[node->Index].no); + add_norm_if(out_dir, out, out_flip, ss->mvert[node->Index].no); } if (out[0]==0.0 && out[1]==0.0 && out[2]==0.0) { @@ -332,7 +307,7 @@ static void do_draw_brush(Sculpt *sd, SculptSession *ss, const ListBase* active_ float area_normal[3]; ActiveData *node= active_verts->first; - calc_area_normal(sd, area_normal, active_verts); + calc_area_normal(sd, ss, area_normal, active_verts); while(node){ float *co= ss->mvert[node->Index].co; @@ -341,7 +316,7 @@ static void do_draw_brush(Sculpt *sd, SculptSession *ss, const ListBase* active_ co[1]+area_normal[1]*ss->cache->radius*node->Fade*ss->cache->scale[1], co[2]+area_normal[2]*ss->cache->radius*node->Fade*ss->cache->scale[2]}; - sculpt_clip(sd, co, val); + sculpt_clip(sd, ss, co, val); node= node->next; } @@ -391,37 +366,37 @@ static void neighbor_average(SculptSession *ss, float avg[3], const int vert) VecCopyf(avg, ss->mvert[vert].co); } -static void do_smooth_brush(Sculpt *s, const ListBase* active_verts) +static void do_smooth_brush(Sculpt *s, SculptSession *ss, const ListBase* active_verts) { ActiveData *node= active_verts->first; int i; for(i = 0; i < 2; ++i) { while(node){ - float *co= s->session->mvert[node->Index].co; + float *co= ss->mvert[node->Index].co; float avg[3], val[3]; - neighbor_average(s->session, avg, node->Index); + neighbor_average(ss, avg, node->Index); val[0] = co[0]+(avg[0]-co[0])*node->Fade; val[1] = co[1]+(avg[1]-co[1])*node->Fade; val[2] = co[2]+(avg[2]-co[2])*node->Fade; - sculpt_clip(s, co, val); + sculpt_clip(s, ss, co, val); node= node->next; } } } -static void do_pinch_brush(Sculpt *s, const ListBase* active_verts) +static void do_pinch_brush(Sculpt *s, SculptSession *ss, const ListBase* active_verts) { ActiveData *node= active_verts->first; while(node) { - float *co= s->session->mvert[node->Index].co; - const float val[3]= {co[0]+(s->session->cache->location[0]-co[0])*node->Fade, - co[1]+(s->session->cache->location[1]-co[1])*node->Fade, - co[2]+(s->session->cache->location[2]-co[2])*node->Fade}; - sculpt_clip(s, co, val); + float *co= ss->mvert[node->Index].co; + const float val[3]= {co[0]+(ss->cache->location[0]-co[0])*node->Fade, + co[1]+(ss->cache->location[1]-co[1])*node->Fade, + co[2]+(ss->cache->location[2]-co[2])*node->Fade}; + sculpt_clip(s, ss, co, val); node= node->next; } } @@ -440,7 +415,7 @@ static void do_grab_brush(Sculpt *sd, SculptSession *ss) VecCopyf(add, grab_delta); VecMulf(add, node->Fade); VecAddf(add, add, co); - sculpt_clip(sd, co, add); + sculpt_clip(sd, ss, co, add); node= node->next; } @@ -456,10 +431,10 @@ static void do_layer_brush(Sculpt *sd, SculptSession *ss, const ListBase *active if(ss->cache->flip) lim = -lim; - calc_area_normal(sd, area_normal, active_verts); + calc_area_normal(sd, ss, area_normal, active_verts); while(node){ - float *disp= &ss->cache->layer_disps[node->Index]; + float *disp= &ss->layer_disps[node->Index]; float *co= ss->mvert[node->Index].co; float val[3]; @@ -469,20 +444,19 @@ static void do_layer_brush(Sculpt *sd, SculptSession *ss, const ListBase *active if((lim < 0 && *disp < lim) || (lim > 0 && *disp > lim)) *disp = lim; - val[0] = ss->cache->mesh_store[node->Index][0]+area_normal[0] * *disp*ss->cache->scale[0]; - val[1] = ss->cache->mesh_store[node->Index][1]+area_normal[1] * *disp*ss->cache->scale[1]; - val[2] = ss->cache->mesh_store[node->Index][2]+area_normal[2] * *disp*ss->cache->scale[2]; + val[0] = ss->mesh_co_orig[node->Index][0]+area_normal[0] * *disp*ss->cache->scale[0]; + val[1] = ss->mesh_co_orig[node->Index][1]+area_normal[1] * *disp*ss->cache->scale[1]; + val[2] = ss->mesh_co_orig[node->Index][2]+area_normal[2] * *disp*ss->cache->scale[2]; - sculpt_clip(sd, co, val); + sculpt_clip(sd, ss, co, val); node= node->next; } } -static void do_inflate_brush(Sculpt *s, const ListBase *active_verts) +static void do_inflate_brush(Sculpt *s, SculptSession *ss, const ListBase *active_verts) { ActiveData *node= active_verts->first; - SculptSession *ss = s->session; float add[3]; while(node) { @@ -498,7 +472,7 @@ static void do_inflate_brush(Sculpt *s, const ListBase *active_verts) add[2]*= ss->cache->scale[2]; VecAddf(add, add, co); - sculpt_clip(s, co, add); + sculpt_clip(s, ss, co, add); node= node->next; } @@ -527,46 +501,86 @@ static void calc_flatten_center(SculptSession *ss, ActiveData *node, float co[3] VecMulf(co, 1.0f / FLATTEN_SAMPLE_SIZE); } +/* Projects a point onto a plane along the plane's normal */ +static void point_plane_project(float intr[3], float co[3], float plane_normal[3], float plane_center[3]) +{ + float p1[3], sub1[3], sub2[3]; + + /* Find the intersection between squash-plane and vertex (along the area normal) */ + VecSubf(p1, co, plane_normal); + VecSubf(sub1, plane_center, p1); + VecSubf(sub2, co, p1); + VecSubf(intr, co, p1); + VecMulf(intr, Inpf(plane_normal, sub1) / Inpf(plane_normal, sub2)); + VecAddf(intr, intr, p1); +} + +static int plane_point_side(float co[3], float plane_normal[3], float plane_center[3], int flip) +{ + float delta[3]; + float d; + + VecSubf(delta, co, plane_center); + d = Inpf(plane_normal, delta); + + if(flip) + d = -d; + + return d <= 0.0f; +} + static void do_flatten_clay_brush(Sculpt *sd, SculptSession *ss, const ListBase *active_verts, int clay) { ActiveData *node= active_verts->first; /* area_normal and cntr define the plane towards which vertices are squashed */ float area_normal[3]; - float cntr[3]; + float cntr[3], cntr2[3], bstr = 0; + int flip = 0; - calc_area_normal(sd, area_normal, active_verts); + calc_area_normal(sd, ss, area_normal, active_verts); calc_flatten_center(ss, node, cntr); + if(clay) { + bstr= brush_strength(sd, ss->cache); + /* Limit clay application to here */ + cntr2[0]=cntr[0]+area_normal[0]*bstr*ss->cache->scale[0]; + cntr2[1]=cntr[1]+area_normal[1]*bstr*ss->cache->scale[1]; + cntr2[2]=cntr[2]+area_normal[2]*bstr*ss->cache->scale[2]; + flip = bstr < 0; + } + while(node){ float *co= ss->mvert[node->Index].co; - float p1[3], sub1[3], sub2[3], intr[3], val[3]; - - /* Find the intersection between squash-plane and vertex (along the area normal) */ - VecSubf(p1, co, area_normal); - VecSubf(sub1, cntr, p1); - VecSubf(sub2, co, p1); - VecSubf(intr, co, p1); - VecMulf(intr, Inpf(area_normal, sub1) / Inpf(area_normal, sub2)); - VecAddf(intr, intr, p1); - - VecSubf(val, intr, co); - VecMulf(val, fabs(node->Fade)); - VecAddf(val, val, co); + float intr[3], val[3]; - if(clay) { - /* Clay brush displaces after flattening */ - float tmp[3]; - VecCopyf(tmp, area_normal); - VecMulf(tmp, ss->cache->radius * node->Fade * 0.1); - VecAddf(val, val, tmp); - } + if(!clay || plane_point_side(co, area_normal, cntr2, flip)) { + /* Find the intersection between squash-plane and vertex (along the area normal) */ + point_plane_project(intr, co, area_normal, cntr); + + VecSubf(val, intr, co); - sculpt_clip(sd, co, val); + if(clay) { + if(bstr > FLT_EPSILON) + VecMulf(val, node->Fade / bstr); + else + VecMulf(val, node->Fade); + /* Clay displacement */ + val[0]+=area_normal[0] * ss->cache->scale[0]*node->Fade; + val[1]+=area_normal[1] * ss->cache->scale[1]*node->Fade; + val[2]+=area_normal[2] * ss->cache->scale[2]*node->Fade; + } + else + VecMulf(val, fabs(node->Fade)); + + VecAddf(val, val, co); + + sculpt_clip(sd, ss, co, val); + } node= node->next; } } - + /* Uses symm to selectively flip any axis of a coordinate. */ static void flip_coord(float out[3], float in[3], const char symm) { @@ -622,35 +636,29 @@ static float get_texcache_pixel_bilinear(const SculptSession *ss, float u, float } /* Return a multiplier for brush strength on a particular vertex. */ -static float tex_strength(Sculpt *sd, float *point, const float len) +static float tex_strength(Sculpt *sd, SculptSession *ss, float *point, const float len) { - SculptSession *ss= sd->session; - Brush *br = sd->brush; + Brush *br = paint_brush(&sd->paint); + MTex *tex = NULL; float avg= 1; - if(br->texact==-1 || !br->mtex[br->texact]) + if(br->texact >= 0) + tex = br->mtex[br->texact]; + + if(!tex) { avg= 1; - else if(br->tex_mode==BRUSH_TEX_3D) { - /* Get strength by feeding the vertex location directly - into a texture */ + } + else if(tex->brush_map_mode == MTEX_MAP_MODE_3D) { float jnk; - const float factor= 0.01; - MTex mtex; - memset(&mtex,0,sizeof(MTex)); - mtex.tex= br->mtex[br->texact]->tex; - mtex.projx= 1; - mtex.projy= 2; - mtex.projz= 3; - VecCopyf(mtex.size, br->mtex[br->texact]->size); - VecMulf(mtex.size, factor); - if(!sd->texsep) - mtex.size[1]= mtex.size[2]= mtex.size[0]; - - externtex(&mtex,point,&avg,&jnk,&jnk,&jnk,&jnk); + + /* Get strength by feeding the vertex + location directly into a texture */ + externtex(tex, point, &avg, + &jnk, &jnk, &jnk, &jnk); } else if(ss->texcache) { const float bsize= ss->cache->pixel_radius * 2; - const float rot= sd->brush->rot + ss->cache->rotation; + const float rot= tex->rot + ss->cache->rotation; int px, py; float flip[3], point_2d[2]; @@ -663,9 +671,9 @@ static float tex_strength(Sculpt *sd, float *point, const float len) /* For Tile and Drag modes, get the 2D screen coordinates of the and scale them up or down to the texture size. */ - if(br->tex_mode==BRUSH_TEX_TILE) { - const int sx= (const int)br->mtex[br->texact]->size[0]; - const int sy= (const int)sd->texsep ? br->mtex[br->texact]->size[1] : sx; + if(tex->brush_map_mode == MTEX_MAP_MODE_TILED) { + const int sx= (const int)tex->size[0]; + const int sy= (const int)tex->size[1]; float fx= point_2d[0]; float fy= point_2d[1]; @@ -685,7 +693,8 @@ static float tex_strength(Sculpt *sd, float *point, const float len) if(sy != 1) py %= sy-1; avg= get_texcache_pixel_bilinear(ss, ss->texcache_side*px/sx, ss->texcache_side*py/sy); - } else { + } + else if(tex->brush_map_mode == MTEX_MAP_MODE_FIXED) { float fx= (point_2d[0] - ss->cache->mouse[0]) / bsize; float fy= (point_2d[1] - ss->cache->mouse[1]) / bsize; @@ -699,7 +708,7 @@ static float tex_strength(Sculpt *sd, float *point, const float len) } } - avg*= brush_curve_strength(sd->brush, len, ss->cache->radius); /* Falloff curve */ + avg*= brush_curve_strength(br, len, ss->cache->radius); /* Falloff curve */ return avg; } @@ -737,9 +746,9 @@ static void sculpt_add_damaged_rect(SculptSession *ss) } } -static void do_brush_action(Sculpt *sd, StrokeCache *cache) +static void do_brush_action(Sculpt *sd, SculptSession *ss, StrokeCache *cache) { - SculptSession *ss = sd->session; + Brush *brush = paint_brush(&sd->paint); float av_dist; ListBase active_verts={0,0}; ListBase *grab_active_verts = &ss->cache->grab_active_verts[ss->cache->symmetry]; @@ -748,7 +757,7 @@ static void do_brush_action(Sculpt *sd, StrokeCache *cache) Mesh *me= NULL; /*XXX: get_mesh(OBACT); */ const float bstrength= brush_strength(sd, cache); KeyBlock *keyblock= NULL; /*XXX: ob_get_keyblock(OBACT); */ - Brush *b = sd->brush; + Brush *b = brush; int i; sculpt_add_damaged_rect(ss); @@ -768,7 +777,7 @@ static void do_brush_action(Sculpt *sd, StrokeCache *cache) adata->Index = i; /* Fade is used to store the final strength at which the brush should modify a particular vertex. */ - adata->Fade= tex_strength(sd, vert, av_dist) * bstrength; + adata->Fade= tex_strength(sd, ss, vert, av_dist) * bstrength; adata->dist = av_dist; if(b->sculpt_tool == SCULPT_TOOL_GRAB && cache->first_time) @@ -788,13 +797,13 @@ static void do_brush_action(Sculpt *sd, StrokeCache *cache) do_draw_brush(sd, ss, &active_verts); break; case SCULPT_TOOL_SMOOTH: - do_smooth_brush(sd, &active_verts); + do_smooth_brush(sd, ss, &active_verts); break; case SCULPT_TOOL_PINCH: - do_pinch_brush(sd, &active_verts); + do_pinch_brush(sd, ss, &active_verts); break; case SCULPT_TOOL_INFLATE: - do_inflate_brush(sd, &active_verts); + do_inflate_brush(sd, ss, &active_verts); break; case SCULPT_TOOL_GRAB: do_grab_brush(sd, ss); @@ -843,20 +852,21 @@ static void calc_brushdata_symm(StrokeCache *cache, const char symm) cache->symmetry= symm; } -static void do_symmetrical_brush_actions(Sculpt *sd, StrokeCache *cache) +static void do_symmetrical_brush_actions(Sculpt *sd, SculptSession *ss) { + StrokeCache *cache = ss->cache; const char symm = sd->flags & 7; int i; VecCopyf(cache->location, cache->true_location); VecCopyf(cache->grab_delta_symmetry, cache->grab_delta); cache->symmetry = 0; - do_brush_action(sd, cache); + do_brush_action(sd, ss, cache); for(i = 1; i <= symm; ++i) { if(symm & i && (symm != 5 || i != 3) && (symm != 6 || (i != 3 && i != 5))) { calc_brushdata_symm(cache, i); - do_brush_action(sd, cache); + do_brush_action(sd, ss, cache); } } @@ -929,9 +939,9 @@ static void projverts_clear_inside(SculptSession *ss) } #endif -static void sculpt_update_tex(Sculpt *sd) +static void sculpt_update_tex(Sculpt *sd, SculptSession *ss) { - SculptSession *ss= sd->session; + Brush *brush = paint_brush(&sd->paint); if(ss->texcache) { MEM_freeN(ss->texcache); @@ -939,9 +949,9 @@ static void sculpt_update_tex(Sculpt *sd) } /* Need to allocate a bigger buffer for bigger brush size */ - ss->texcache_side = sd->brush->size * 2; + ss->texcache_side = brush->size * 2; if(!ss->texcache || ss->texcache_side > ss->texcache_actual) { - ss->texcache = brush_gen_texture_cache(sd->brush, sd->brush->size); + ss->texcache = brush_gen_texture_cache(brush, brush->size); ss->texcache_actual = ss->texcache_side; } } @@ -992,8 +1002,8 @@ static struct MultiresModifierData *sculpt_multires_active(Object *ob) static void sculpt_update_mesh_elements(bContext *C) { - SculptSession *ss = CTX_data_tool_settings(C)->sculpt->session; Object *ob = CTX_data_active_object(C); + SculptSession *ss = ob->sculpt; int oldtotvert = ss->totvert; if((ss->multires = sculpt_multires_active(ob))) { @@ -1026,54 +1036,20 @@ static void sculpt_update_mesh_elements(bContext *C) static int sculpt_mode_poll(bContext *C) { - return G.f & G_SCULPTMODE; + Object *ob = CTX_data_active_object(C); + return ob && ob->mode & OB_MODE_SCULPT; } static int sculpt_poll(bContext *C) { - return G.f & G_SCULPTMODE && CTX_wm_area(C)->spacetype == SPACE_VIEW3D && - CTX_wm_region(C)->regiontype == RGN_TYPE_WINDOW; -} - -/*** Sculpt Cursor ***/ -static void draw_paint_cursor(bContext *C, int x, int y, void *customdata) -{ - Sculpt *sd= CTX_data_tool_settings(C)->sculpt; - - glColor4ub(255, 100, 100, 128); - glEnable( GL_LINE_SMOOTH ); - glEnable(GL_BLEND); - - glTranslatef((float)x, (float)y, 0.0f); - glutil_draw_lined_arc(0.0, M_PI*2.0, sd->brush->size, 40); - glTranslatef((float)-x, (float)-y, 0.0f); - - if(sd->session && sd->session->cache && sd->brush && (sd->brush->flag & BRUSH_SMOOTH_STROKE)) { - ARegion *ar = CTX_wm_region(C); - sdrawline(x, y, sd->session->cache->mouse[0] - ar->winrct.xmin, sd->session->cache->mouse[1] - ar->winrct.ymin); - } - - glDisable(GL_BLEND); - glDisable( GL_LINE_SMOOTH ); -} - -static void toggle_paint_cursor(bContext *C) -{ - Sculpt *s = CTX_data_scene(C)->toolsettings->sculpt; - - if(s->session->cursor) { - WM_paint_cursor_end(CTX_wm_manager(C), s->session->cursor); - s->session->cursor = NULL; - } - else { - s->session->cursor = - WM_paint_cursor_activate(CTX_wm_manager(C), sculpt_poll, draw_paint_cursor, NULL); - } + return sculpt_mode_poll(C) && paint_poll(C); } static void sculpt_undo_push(bContext *C, Sculpt *sd) { - switch(sd->brush->sculpt_tool) { + Brush *brush = paint_brush(&sd->paint); + + switch(brush->sculpt_tool) { case SCULPT_TOOL_DRAW: ED_undo_push(C, "Draw Brush"); break; case SCULPT_TOOL_SMOOTH: @@ -1093,36 +1069,15 @@ static void sculpt_undo_push(bContext *C, Sculpt *sd) } } -static int sculpt_brush_curve_preset_exec(bContext *C, wmOperator *op) -{ - brush_curve_preset(CTX_data_scene(C)->toolsettings->sculpt->brush, RNA_enum_get(op->ptr, "mode")); - return OPERATOR_FINISHED; -} - -static void SCULPT_OT_brush_curve_preset(wmOperatorType *ot) -{ - static EnumPropertyItem prop_mode_items[] = { - {BRUSH_PRESET_SHARP, "SHARP", 0, "Sharp Curve", ""}, - {BRUSH_PRESET_SMOOTH, "SMOOTH", 0, "Smooth Curve", ""}, - {BRUSH_PRESET_MAX, "MAX", 0, "Max Curve", ""}, - {0, NULL, 0, NULL, NULL}}; - - ot->name= "Preset"; - ot->idname= "SCULPT_OT_brush_curve_preset"; - - ot->exec= sculpt_brush_curve_preset_exec; - ot->poll= sculpt_mode_poll; - - ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; - - RNA_def_enum(ot->srna, "mode", prop_mode_items, BRUSH_PRESET_SHARP, "Mode", ""); -} - /**** Radial control ****/ static int sculpt_radial_control_invoke(bContext *C, wmOperator *op, wmEvent *event) { - toggle_paint_cursor(C); - brush_radial_control_invoke(op, CTX_data_scene(C)->toolsettings->sculpt->brush, 1); + Paint *p = paint_get_active(CTX_data_scene(C)); + Brush *brush = paint_brush(p); + + WM_paint_cursor_end(CTX_wm_manager(C), p->paint_cursor); + p->paint_cursor = NULL; + brush_radial_control_invoke(op, brush, 1); return WM_radial_control_invoke(C, op, event); } @@ -1130,13 +1085,15 @@ static int sculpt_radial_control_modal(bContext *C, wmOperator *op, wmEvent *eve { int ret = WM_radial_control_modal(C, op, event); if(ret != OPERATOR_RUNNING_MODAL) - toggle_paint_cursor(C); + paint_cursor_start(C, sculpt_poll); return ret; } static int sculpt_radial_control_exec(bContext *C, wmOperator *op) { - return brush_radial_control_exec(op, CTX_data_scene(C)->toolsettings->sculpt->brush, 1); + Brush *brush = paint_brush(&CTX_data_tool_settings(C)->sculpt->paint); + + return brush_radial_control_exec(op, brush, 1); } static void SCULPT_OT_radial_control(wmOperatorType *ot) @@ -1162,7 +1119,7 @@ static float unproject_brush_radius(SculptSession *ss, float offset) float brush_edge[3]; /* In anchored mode, brush size changes with mouse loc, otherwise it's fixed using the brush radius */ - unproject(ss->cache->mats, brush_edge, ss->cache->initial_mouse[0] + offset, + view3d_unproject(ss->cache->mats, brush_edge, ss->cache->initial_mouse[0] + offset, ss->cache->initial_mouse[1], ss->cache->depth); return VecLenf(ss->cache->true_location, brush_edge); @@ -1170,31 +1127,32 @@ static float unproject_brush_radius(SculptSession *ss, float offset) static void sculpt_cache_free(StrokeCache *cache) { - if(cache->layer_disps) - MEM_freeN(cache->layer_disps); - if(cache->mesh_store) - MEM_freeN(cache->mesh_store); + int i; if(cache->orig_norms) MEM_freeN(cache->orig_norms); if(cache->face_norms) MEM_freeN(cache->face_norms); if(cache->mats) MEM_freeN(cache->mats); + for(i = 0; i < 8; ++i) + BLI_freelistN(&cache->grab_active_verts[i]); MEM_freeN(cache); } /* Initialize the stroke cache invariants from operator properties */ -static void sculpt_update_cache_invariants(Sculpt *sd, bContext *C, wmOperator *op) +static void sculpt_update_cache_invariants(Sculpt *sd, SculptSession *ss, bContext *C, wmOperator *op) { StrokeCache *cache = MEM_callocN(sizeof(StrokeCache), "stroke cache"); + Brush *brush = paint_brush(&sd->paint); + ViewContext *vc = paint_stroke_view_context(op->customdata); int i; - sd->session->cache = cache; + ss->cache = cache; RNA_float_get_array(op->ptr, "scale", cache->scale); cache->flag = RNA_int_get(op->ptr, "flag"); RNA_float_get_array(op->ptr, "clip_tolerance", cache->clip_tolerance); - RNA_int_get_array(op->ptr, "initial_mouse", cache->initial_mouse); + RNA_float_get_array(op->ptr, "initial_mouse", cache->initial_mouse); cache->depth = RNA_float_get(op->ptr, "depth"); cache->mouse[0] = cache->initial_mouse[0]; @@ -1202,70 +1160,88 @@ static void sculpt_update_cache_invariants(Sculpt *sd, bContext *C, wmOperator * /* Truly temporary data that isn't stored in properties */ - view3d_set_viewcontext(C, &cache->vc); - cache->mats = MEM_callocN(sizeof(bglMats), "sculpt bglMats"); - view3d_get_transformation(&cache->vc, cache->vc.obact, cache->mats); + view3d_get_transformation(vc, vc->obact, cache->mats); sculpt_update_mesh_elements(C); - if(sd->brush->sculpt_tool == SCULPT_TOOL_LAYER) - cache->layer_disps = MEM_callocN(sizeof(float) * sd->session->totvert, "layer brush displacements"); + /* Initialize layer brush displacements */ + if(brush->sculpt_tool == SCULPT_TOOL_LAYER && + (!ss->layer_disps || !(brush->flag & BRUSH_PERSISTENT))) { + if(ss->layer_disps) + MEM_freeN(ss->layer_disps); + ss->layer_disps = MEM_callocN(sizeof(float) * ss->totvert, "layer brush displacements"); + } /* Make copies of the mesh vertex locations and normals for some tools */ - if(sd->brush->sculpt_tool == SCULPT_TOOL_LAYER || (sd->brush->flag & BRUSH_ANCHORED)) { - cache->mesh_store= MEM_mallocN(sizeof(float) * 3 * sd->session->totvert, "sculpt mesh vertices copy"); - for(i = 0; i < sd->session->totvert; ++i) - VecCopyf(cache->mesh_store[i], sd->session->mvert[i].co); - - if(sd->brush->flag & BRUSH_ANCHORED) { - cache->orig_norms= MEM_mallocN(sizeof(short) * 3 * sd->session->totvert, "Sculpt orig norm"); - for(i = 0; i < sd->session->totvert; ++i) { - cache->orig_norms[i][0] = sd->session->mvert[i].no[0]; - cache->orig_norms[i][1] = sd->session->mvert[i].no[1]; - cache->orig_norms[i][2] = sd->session->mvert[i].no[2]; + if(brush->sculpt_tool == SCULPT_TOOL_LAYER || (brush->flag & BRUSH_ANCHORED)) { + if(brush->sculpt_tool != SCULPT_TOOL_LAYER || + !ss->mesh_co_orig || !(brush->flag & BRUSH_PERSISTENT)) { + if(!ss->mesh_co_orig) + ss->mesh_co_orig= MEM_mallocN(sizeof(float) * 3 * ss->totvert, + "sculpt mesh vertices copy"); + for(i = 0; i < ss->totvert; ++i) + VecCopyf(ss->mesh_co_orig[i], ss->mvert[i].co); + } + + if(brush->flag & BRUSH_ANCHORED) { + cache->orig_norms= MEM_mallocN(sizeof(short) * 3 * ss->totvert, "Sculpt orig norm"); + for(i = 0; i < ss->totvert; ++i) { + cache->orig_norms[i][0] = ss->mvert[i].no[0]; + cache->orig_norms[i][1] = ss->mvert[i].no[1]; + cache->orig_norms[i][2] = ss->mvert[i].no[2]; } - if(sd->session->face_normals) { - float *fn = sd->session->face_normals; - cache->face_norms= MEM_mallocN(sizeof(float) * 3 * sd->session->totface, "Sculpt face norms"); - for(i = 0; i < sd->session->totface; ++i, fn += 3) + if(ss->face_normals) { + float *fn = ss->face_normals; + cache->face_norms= MEM_mallocN(sizeof(float) * 3 * ss->totface, "Sculpt face norms"); + for(i = 0; i < ss->totface; ++i, fn += 3) VecCopyf(cache->face_norms[i], fn); } } } - unproject(cache->mats, cache->true_location, cache->initial_mouse[0], cache->initial_mouse[1], cache->depth); - cache->radius = unproject_brush_radius(sd->session, brush_size(sd)); + view3d_unproject(cache->mats, cache->true_location, cache->initial_mouse[0], cache->initial_mouse[1], cache->depth); + cache->initial_radius = unproject_brush_radius(ss, brush->size); cache->rotation = 0; cache->first_time = 1; } /* Initialize the stroke cache variants from operator properties */ -static void sculpt_update_cache_variants(Sculpt *sd, PointerRNA *ptr) +static void sculpt_update_cache_variants(Sculpt *sd, SculptSession *ss, PointerRNA *ptr) { - StrokeCache *cache = sd->session->cache; + StrokeCache *cache = ss->cache; + Brush *brush = paint_brush(&sd->paint); float grab_location[3]; + int dx, dy; - if(!(sd->brush->flag & BRUSH_ANCHORED)) + if(!(brush->flag & BRUSH_ANCHORED)) RNA_float_get_array(ptr, "location", cache->true_location); cache->flip = RNA_boolean_get(ptr, "flip"); - RNA_int_get_array(ptr, "mouse", cache->mouse); + RNA_float_get_array(ptr, "mouse", cache->mouse); + cache->pressure = RNA_float_get(ptr, "pressure"); /* Truly temporary data that isn't stored in properties */ cache->previous_pixel_radius = cache->pixel_radius; - cache->pixel_radius = brush_size(sd); + cache->pixel_radius = brush->size; + + if(brush->flag & BRUSH_SIZE_PRESSURE) { + cache->pixel_radius *= cache->pressure; + cache->radius = cache->initial_radius * cache->pressure; + } + else + cache->radius = cache->initial_radius; - if(sd->brush->flag & BRUSH_ANCHORED) { + if(brush->flag & BRUSH_ANCHORED) { dx = cache->mouse[0] - cache->initial_mouse[0]; dy = cache->mouse[1] - cache->initial_mouse[1]; cache->pixel_radius = sqrt(dx*dx + dy*dy); - cache->radius = unproject_brush_radius(sd->session, cache->pixel_radius); + cache->radius = unproject_brush_radius(ss, cache->pixel_radius); cache->rotation = atan2(dy, dx); } - else if(sd->brush->flag & BRUSH_RAKE) { + else if(brush->flag & BRUSH_RAKE) { int update; dx = cache->last_rake[0] - cache->mouse[0]; @@ -1284,8 +1260,8 @@ static void sculpt_update_cache_variants(Sculpt *sd, PointerRNA *ptr) } /* Find the grab delta */ - if(sd->brush->sculpt_tool == SCULPT_TOOL_GRAB) { - unproject(cache->mats, grab_location, cache->mouse[0], cache->mouse[1], cache->depth); + if(brush->sculpt_tool == SCULPT_TOOL_GRAB) { + view3d_unproject(cache->mats, grab_location, cache->mouse[0], cache->mouse[1], cache->depth); if(!cache->first_time) VecSubf(cache->grab_delta, grab_location, cache->old_grab_location); VecCopyf(cache->old_grab_location, grab_location); @@ -1298,9 +1274,9 @@ static void sculpt_brush_stroke_init_properties(bContext *C, wmOperator *op, wmE Sculpt *sd = CTX_data_tool_settings(C)->sculpt; Object *ob= CTX_data_active_object(C); ModifierData *md; - ViewContext vc; float scale[3], clip_tolerance[3] = {0,0,0}; - int mouse[2], flag = 0; + float mouse[2]; + int flag = 0; /* Set scaling adjustment */ scale[0] = 1.0f / ob->size[0]; @@ -1327,42 +1303,39 @@ static void sculpt_brush_stroke_init_properties(bContext *C, wmOperator *op, wmE /* Initial mouse location */ mouse[0] = event->x; mouse[1] = event->y; - RNA_int_set_array(op->ptr, "initial_mouse", mouse); + RNA_float_set_array(op->ptr, "initial_mouse", mouse); /* Initial screen depth under the mouse */ - view3d_set_viewcontext(C, &vc); - RNA_float_set(op->ptr, "depth", read_cached_depth(&vc, event->x, event->y)); + RNA_float_set(op->ptr, "depth", read_cached_depth(paint_stroke_view_context(op->customdata), event->x, event->y)); - sculpt_update_cache_invariants(sd, C, op); + sculpt_update_cache_invariants(sd, ss, C, op); } -static int sculpt_brush_stroke_invoke(bContext *C, wmOperator *op, wmEvent *event) +static void sculpt_brush_stroke_init(bContext *C) { Sculpt *sd = CTX_data_tool_settings(C)->sculpt; + SculptSession *ss = CTX_data_active_object(C)->sculpt; view3d_operator_needs_opengl(C); /* TODO: Shouldn't really have to do this at the start of every stroke, but sculpt would need some sort of notification when changes are made to the texture. */ - sculpt_update_tex(sd); + sculpt_update_tex(sd, ss); - /* add modal handler */ - WM_event_add_modal_handler(C, &CTX_wm_window(C)->handlers, op); - - return OPERATOR_RUNNING_MODAL; + sculpt_update_mesh_elements(C); } -static void sculpt_restore_mesh(Sculpt *sd) +static void sculpt_restore_mesh(Sculpt *sd, SculptSession *ss) { - SculptSession *ss = sd->session; StrokeCache *cache = ss->cache; + Brush *brush = paint_brush(&sd->paint); int i; /* Restore the mesh before continuing with anchored stroke */ - if((sd->brush->flag & BRUSH_ANCHORED) && cache->mesh_store) { + if((brush->flag & BRUSH_ANCHORED) && ss->mesh_co_orig) { for(i = 0; i < ss->totvert; ++i) { - VecCopyf(ss->mvert[i].co, cache->mesh_store[i]); + VecCopyf(ss->mvert[i].co, ss->mesh_co_orig[i]); ss->mvert[i].no[0] = cache->orig_norms[i][0]; ss->mvert[i].no[1] = cache->orig_norms[i][1]; ss->mvert[i].no[2] = cache->orig_norms[i][2]; @@ -1374,8 +1347,8 @@ static void sculpt_restore_mesh(Sculpt *sd) VecCopyf(fn, cache->face_norms[i]); } - if(sd->brush->sculpt_tool == SCULPT_TOOL_LAYER) - memset(cache->layer_disps, 0, sizeof(float) * ss->totvert); + if(brush->sculpt_tool == SCULPT_TOOL_LAYER) + memset(ss->layer_disps, 0, sizeof(float) * ss->totvert); } } @@ -1387,187 +1360,107 @@ static void sculpt_post_stroke_free(SculptSession *ss) static void sculpt_flush_update(bContext *C) { - Sculpt *s = CTX_data_tool_settings(C)->sculpt; + Object *ob = CTX_data_active_object(C); + SculptSession *ss = ob->sculpt; ARegion *ar = CTX_wm_region(C); - MultiresModifierData *mmd = s->session->multires; + MultiresModifierData *mmd = ss->multires; - calc_damaged_verts(s->session); + calc_damaged_verts(ss); if(mmd) { - if(mmd->undo_verts && mmd->undo_verts != s->session->mvert) + if(mmd->undo_verts && mmd->undo_verts != ss->mvert) MEM_freeN(mmd->undo_verts); - mmd->undo_verts = s->session->mvert; - mmd->undo_verts_tot = s->session->totvert; - multires_mark_as_modified(CTX_data_active_object(C)); + mmd->undo_verts = ss->mvert; + mmd->undo_verts_tot = ss->totvert; + multires_mark_as_modified(ob); } ED_region_tag_redraw(ar); } -/* Returns zero if no sculpt changes should be made, non-zero otherwise */ -static int sculpt_smooth_stroke(Sculpt *s, int output[2], wmEvent *event) +static int sculpt_stroke_test_start(bContext *C, struct wmOperator *op, wmEvent *event) { - output[0] = event->x; - output[1] = event->y; - - if(s->brush->flag & BRUSH_SMOOTH_STROKE && s->brush->sculpt_tool != SCULPT_TOOL_GRAB) { - StrokeCache *cache = s->session->cache; - float u = .9, v = 1.0 - u; - int dx = cache->mouse[0] - event->x, dy = cache->mouse[1] - event->y; - int radius = 50; - - /* If the mouse is moving within the radius of the last move, - don't update the mouse position. This allows sharp turns. */ - if(dx*dx + dy*dy < radius*radius) - return 0; - - output[0] = event->x * v + cache->mouse[0] * u; - output[1] = event->y * v + cache->mouse[1] * u; - } + ViewContext vc; + float cur_depth; - return 1; -} + view3d_set_viewcontext(C, &vc); + cur_depth = read_cached_depth(&vc, event->x, event->y); + + /* Don't start the stroke until a valid depth is found */ + if(cur_depth < 1.0 - FLT_EPSILON) { + SculptSession *ss = CTX_data_active_object(C)->sculpt; -/* Returns zero if the stroke dots should not be spaced, non-zero otherwise */ -int sculpt_space_stroke_enabled(Sculpt *s) -{ - Brush *br = s->brush; - return (br->flag & BRUSH_SPACE) && !(br->flag & BRUSH_ANCHORED) && (br->sculpt_tool != SCULPT_TOOL_GRAB); + sculpt_brush_stroke_init_properties(C, op, event, ss); + sculptmode_update_all_projverts(ss); + + return 1; + } + else + return 0; } -/* Put the location of the next sculpt stroke dot into the stroke RNA and apply it to the mesh */ -static void sculpt_brush_stroke_add_step(bContext *C, wmOperator *op, wmEvent *event, int mouse[2]) +static void sculpt_stroke_update_step(bContext *C, struct PaintStroke *stroke, PointerRNA *itemptr) { Sculpt *sd = CTX_data_tool_settings(C)->sculpt; - StrokeCache *cache = sd->session->cache; - PointerRNA itemptr; - float cur_depth; - float center[3]; - - cur_depth = read_cached_depth(&cache->vc, mouse[0], mouse[1]); - unproject(sd->session->cache->mats, center, mouse[0], mouse[1], cur_depth); - - /* Add to stroke */ - RNA_collection_add(op->ptr, "stroke", &itemptr); - RNA_float_set_array(&itemptr, "location", center); - RNA_int_set_array(&itemptr, "mouse", mouse); - RNA_boolean_set(&itemptr, "flip", event->shift); - sculpt_update_cache_variants(sd, &itemptr); - - sculpt_restore_mesh(sd); - do_symmetrical_brush_actions(sd, cache); -} + SculptSession *ss = CTX_data_active_object(C)->sculpt; -/* For brushes with stroke spacing enabled, moves mouse in steps - towards the final mouse location. */ -static int sculpt_space_stroke(bContext *C, wmOperator *op, wmEvent *event, Sculpt *s, const int final_mouse[2]) -{ - StrokeCache *cache = s->session->cache; - int cnt = 0; - - if(sculpt_space_stroke_enabled(s)) { - float vec[2] = {final_mouse[0] - cache->mouse[0], final_mouse[1] - cache->mouse[1]}; - int mouse[2] = {cache->mouse[0], cache->mouse[1]}; - float length, scale; - int steps = 0, i; - - /* Normalize the vector between the last stroke dot and the goal */ - length = sqrt(vec[0]*vec[0] + vec[1]*vec[1]); - - if(length > FLT_EPSILON) { - scale = s->brush->spacing / length; - vec[0] *= scale; - vec[1] *= scale; - - steps = (int)(length / s->brush->spacing); - for(i = 0; i < steps; ++i, ++cnt) { - mouse[0] += vec[0]; - mouse[1] += vec[1]; - sculpt_brush_stroke_add_step(C, op, event, mouse); - } - } - } + sculpt_update_cache_variants(sd, ss, itemptr); + sculpt_restore_mesh(sd, ss); + do_symmetrical_brush_actions(sd, ss); - return cnt; + /* Cleanup */ + sculpt_flush_update(C); + sculpt_post_stroke_free(ss); } -static int sculpt_brush_stroke_modal(bContext *C, wmOperator *op, wmEvent *event) +static void sculpt_stroke_done(bContext *C, struct PaintStroke *stroke) { - Sculpt *sd = CTX_data_tool_settings(C)->sculpt; - ARegion *ar = CTX_wm_region(C); - float cur_depth; - - sculpt_update_mesh_elements(C); + SculptSession *ss = CTX_data_active_object(C)->sculpt; - if(!sd->session->cache) { - ViewContext vc; - view3d_set_viewcontext(C, &vc); - cur_depth = read_cached_depth(&vc, event->x, event->y); - - /* Don't start the stroke until a valid depth is found */ - if(cur_depth < 1.0 - FLT_EPSILON) { - sculpt_brush_stroke_init_properties(C, op, event, sd->session); - sculptmode_update_all_projverts(sd->session); - } + /* Finished */ + if(ss->cache) { + Sculpt *sd = CTX_data_tool_settings(C)->sculpt; - ED_region_tag_redraw(ar); + request_depth_update(paint_stroke_view_context(stroke)->rv3d); + sculpt_cache_free(ss->cache); + ss->cache = NULL; + sculpt_undo_push(C, sd); } +} - if(sd->session->cache) { - int mouse[2]; - - if(sculpt_smooth_stroke(sd, mouse, event)) { - if(sculpt_space_stroke_enabled(sd)) { - if(!sculpt_space_stroke(C, op, event, sd, mouse)) - ED_region_tag_redraw(ar); - } - else - sculpt_brush_stroke_add_step(C, op, event, mouse); - - sculpt_flush_update(C); - sculpt_post_stroke_free(sd->session); - } - else - ED_region_tag_redraw(ar); - } +static int sculpt_brush_stroke_invoke(bContext *C, wmOperator *op, wmEvent *event) +{ + sculpt_brush_stroke_init(C); - /* Finished */ - if(event->type == LEFTMOUSE && event->val == 0) { - if(sd->session->cache) { - request_depth_update(sd->session->cache->vc.rv3d); - sculpt_cache_free(sd->session->cache); - sd->session->cache = NULL; - sculpt_undo_push(C, sd); - } + op->customdata = paint_stroke_new(C, sculpt_stroke_test_start, + sculpt_stroke_update_step, + sculpt_stroke_done); - return OPERATOR_FINISHED; - } + /* add modal handler */ + WM_event_add_modal_handler(C, &CTX_wm_window(C)->handlers, op); + op->type->modal(C, op, event); + return OPERATOR_RUNNING_MODAL; } static int sculpt_brush_stroke_exec(bContext *C, wmOperator *op) { Sculpt *sd = CTX_data_tool_settings(C)->sculpt; + SculptSession *ss = CTX_data_active_object(C)->sculpt; - view3d_operator_needs_opengl(C); - sculpt_update_cache_invariants(sd, C, op); - sculptmode_update_all_projverts(sd->session); - sculpt_update_tex(sd); + op->customdata = paint_stroke_new(C, sculpt_stroke_test_start, sculpt_stroke_update_step, sculpt_stroke_done); - RNA_BEGIN(op->ptr, itemptr, "stroke") { - sculpt_update_cache_variants(sd, &itemptr); + sculpt_brush_stroke_init(C); - sculpt_restore_mesh(sd); - do_symmetrical_brush_actions(sd, sd->session->cache); + sculpt_update_cache_invariants(sd, ss, C, op); + sculptmode_update_all_projverts(ss); - sculpt_post_stroke_free(sd->session); - } - RNA_END; + paint_stroke_exec(C, op); sculpt_flush_update(C); - sculpt_cache_free(sd->session->cache); + sculpt_cache_free(ss->cache); sculpt_undo_push(C, sd); @@ -1584,7 +1477,7 @@ static void SCULPT_OT_brush_stroke(wmOperatorType *ot) /* api callbacks */ ot->invoke= sculpt_brush_stroke_invoke; - ot->modal= sculpt_brush_stroke_modal; + ot->modal= paint_stroke_modal; ot->exec= sculpt_brush_stroke_exec; ot->poll= sculpt_poll; @@ -1604,46 +1497,76 @@ static void SCULPT_OT_brush_stroke(wmOperatorType *ot) RNA_def_float_vector(ot->srna, "clip_tolerance", 3, NULL, 0.0f, FLT_MAX, "clip_tolerance", "", 0.0f, 1000.0f); /* The initial 2D location of the mouse */ - RNA_def_int_vector(ot->srna, "initial_mouse", 2, NULL, INT_MIN, INT_MAX, "initial_mouse", "", INT_MIN, INT_MAX); + RNA_def_float_vector(ot->srna, "initial_mouse", 2, NULL, INT_MIN, INT_MAX, "initial_mouse", "", INT_MIN, INT_MAX); /* The initial screen depth of the mouse */ RNA_def_float(ot->srna, "depth", 0.0f, 0.0f, FLT_MAX, "depth", "", 0.0f, FLT_MAX); } +/**** Reset the copy of the mesh that is being sculpted on (currently just for the layer brush) ****/ + +static int sculpt_set_persistent_base(bContext *C, wmOperator *op) +{ + SculptSession *ss = CTX_data_active_object(C)->sculpt; + + if(ss) { + if(ss->layer_disps) + MEM_freeN(ss->layer_disps); + ss->layer_disps = NULL; + + if(ss->mesh_co_orig) + MEM_freeN(ss->mesh_co_orig); + ss->mesh_co_orig = NULL; + } + + return OPERATOR_FINISHED; +} + +static void SCULPT_OT_set_persistent_base(wmOperatorType *ot) +{ + /* identifiers */ + ot->name= "Set Persistent Base"; + ot->idname= "SCULPT_OT_set_persistent_base"; + + /* api callbacks */ + ot->exec= sculpt_set_persistent_base; + ot->poll= sculpt_mode_poll; + + ot->flag= OPTYPE_REGISTER; +} + /**** Toggle operator for turning sculpt mode on or off ****/ static int sculpt_toggle_mode(bContext *C, wmOperator *op) { ToolSettings *ts = CTX_data_tool_settings(C); + Object *ob = CTX_data_active_object(C); - if(G.f & G_SCULPTMODE) { - multires_force_update(CTX_data_active_object(C)); + if(ob->mode & OB_MODE_SCULPT) { + multires_force_update(ob); /* Leave sculptmode */ - G.f &= ~G_SCULPTMODE; - - toggle_paint_cursor(C); + ob->mode &= ~OB_MODE_SCULPT; - sculptsession_free(ts->sculpt); + free_sculptsession(&ob->sculpt); } else { /* Enter sculptmode */ - G.f |= G_SCULPTMODE; + ob->mode |= OB_MODE_SCULPT; /* Create persistent sculpt mode data */ if(!ts->sculpt) ts->sculpt = MEM_callocN(sizeof(Sculpt), "sculpt mode data"); /* Create sculpt mode session data */ - if(ts->sculpt->session) - MEM_freeN(ts->sculpt->session); - ts->sculpt->session = MEM_callocN(sizeof(SculptSession), "sculpt session"); + if(ob->sculpt) + free_sculptsession(&ob->sculpt); + ob->sculpt = MEM_callocN(sizeof(SculptSession), "sculpt session"); - toggle_paint_cursor(C); - - /* If there's no brush, create one */ - brush_check_exists(&ts->sculpt->brush); + paint_init(&ts->sculpt->paint, PAINT_CURSOR_SCULPT); + + paint_cursor_start(C, sculpt_poll); WM_event_add_notifier(C, NC_SCENE|ND_MODE, CTX_data_scene(C)); } @@ -1669,5 +1592,5 @@ void ED_operatortypes_sculpt() WM_operatortype_append(SCULPT_OT_radial_control); WM_operatortype_append(SCULPT_OT_brush_stroke); WM_operatortype_append(SCULPT_OT_sculptmode_toggle); - WM_operatortype_append(SCULPT_OT_brush_curve_preset); + WM_operatortype_append(SCULPT_OT_set_persistent_base); } diff --git a/source/blender/editors/sculpt_paint/sculpt_stroke.c b/source/blender/editors/sculpt_paint/sculpt_stroke.c deleted file mode 100644 index 554ff580358..00000000000 --- a/source/blender/editors/sculpt_paint/sculpt_stroke.c +++ /dev/null @@ -1,274 +0,0 @@ -/* - * $Id$ - * - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * - * The Original Code is Copyright (C) 2007 by Nicholas Bishop - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): none yet. - * - * ***** END GPL LICENSE BLOCK ***** - * - * Storage and manipulation of sculptmode brush strokes. - * - */ - -#include "MEM_guardedalloc.h" - -#include "DNA_listBase.h" -#include "DNA_scene_types.h" - -#include "BKE_sculpt.h" -#include "BLI_blenlib.h" -#include "BIF_gl.h" - -#include "sculpt_intern.h" - -#include <math.h> - -/* Temporary storage of input stroke control points */ -typedef struct StrokePoint { - struct StrokePoint *next, *prev; - short x, y; -} StrokePoint; -typedef struct SculptStroke { - short (*loc)[2]; - int max; - int index; - float length; - ListBase final; - StrokePoint *final_mem; - float offset; -} SculptStroke; - -SculptStroke *sculpt_stroke_new(const int max) -{ - SculptStroke *stroke = MEM_callocN(sizeof(SculptStroke), "SculptStroke"); - stroke->loc = MEM_callocN(sizeof(short) * 4 * max, "SculptStroke.loc"); - stroke->max = max; - stroke->index = -1; - return stroke; -} - -void sculpt_stroke_free(SculptStroke *stroke) -{ - if(stroke) { - if(stroke->loc) MEM_freeN(stroke->loc); - if(stroke->final_mem) MEM_freeN(stroke->final_mem); - - MEM_freeN(stroke); - } -} - -void sculpt_stroke_add_point(SculptStroke *stroke, const short x, const short y) -{ - const int next = stroke->index + 1; - - if(stroke->index == -1) { - stroke->loc[0][0] = x; - stroke->loc[0][1] = y; - stroke->index = 0; - } - else if(next < stroke->max) { - const int dx = x - stroke->loc[stroke->index][0]; - const int dy = y - stroke->loc[stroke->index][1]; - stroke->loc[next][0] = x; - stroke->loc[next][1] = y; - stroke->length += sqrt(dx*dx + dy*dy); - stroke->index = next; - } -} - -static void sculpt_stroke_smooth(SculptStroke *stroke) -{ - /* Apply smoothing (exclude the first and last points)*/ - StrokePoint *p = stroke->final.first; - if(p && p->next && p->next->next) { - for(p = p->next->next; p && p->next && p->next->next; p = p->next) { - p->x = p->prev->prev->x*0.1 + p->prev->x*0.2 + p->x*0.4 + p->next->x*0.2 + p->next->next->x*0.1; - p->y = p->prev->prev->y*0.1 + p->prev->y*0.2 + p->y*0.4 + p->next->y*0.2 + p->next->next->y*0.1; - } - } -} - -static void sculpt_stroke_create_final(SculptStroke *stroke) -{ - if(stroke) { - StrokePoint *p, *pnext; - int i; - - /* Copy loc into final */ - if(stroke->final_mem) - MEM_freeN(stroke->final_mem); - stroke->final_mem = MEM_callocN(sizeof(StrokePoint) * (stroke->index + 1) * 2, "SculptStroke.final"); - stroke->final.first = stroke->final.last = NULL; - for(i = 0; i <= stroke->index; ++i) { - p = &stroke->final_mem[i]; - p->x = stroke->loc[i][0]; - p->y = stroke->loc[i][1]; - BLI_addtail(&stroke->final, p); - } - - /* Remove shortest edges */ - if(stroke->final.first) { - for(p = ((StrokePoint*)stroke->final.first)->next; p && p->next; p = pnext) { - const int dx = p->x - p->prev->x; - const int dy = p->y - p->prev->y; - const float len = sqrt(dx*dx + dy*dy); - pnext = p->next; - if(len < 10) { - BLI_remlink(&stroke->final, p); - } - } - } - - sculpt_stroke_smooth(stroke); - - /* Subdivide edges */ - for(p = stroke->final.first; p && p->next; p = pnext) { - StrokePoint *np = &stroke->final_mem[i++]; - - pnext = p->next; - np->x = (p->x + p->next->x) / 2; - np->y = (p->y + p->next->y) / 2; - BLI_insertlink(&stroke->final, p, np); - } - - sculpt_stroke_smooth(stroke); - } -} - -static float sculpt_stroke_seglen(StrokePoint *p1, StrokePoint *p2) -{ - int dx = p2->x - p1->x; - int dy = p2->y - p1->y; - return sqrt(dx*dx + dy*dy); -} - -static float sculpt_stroke_final_length(SculptStroke *stroke) -{ - StrokePoint *p; - float len = 0; - for(p = stroke->final.first; p && p->next; ++p) - len += sculpt_stroke_seglen(p, p->next); - return len; -} - -/* If partial is nonzero, cuts off apply after that length has been processed */ -static StrokePoint *sculpt_stroke_apply_generic(Sculpt *sd, SculptStroke *stroke, const int partial) -{ - const int sdspace = 0; //XXX: sd->spacing; - const short spacing = sdspace > 0 ? sdspace : 2; - const int dots = sculpt_stroke_final_length(stroke) / spacing; - int i; - StrokePoint *p = stroke->final.first; - float startloc = stroke->offset; - - for(i = 0; i < dots && p && p->next; ++i) { - const float dotloc = spacing * i; - short co[2]; - float len = sculpt_stroke_seglen(p, p->next); - float u, v; - - /* Find edge containing dot */ - while(dotloc > startloc + len && p && p->next && p->next->next) { - p = p->next; - startloc += len; - len = sculpt_stroke_seglen(p, p->next); - } - - if(!p || !p->next || dotloc > startloc + len) - break; - - if(partial && startloc > partial) { - /* Calculate offset for next stroke segment */ - stroke->offset = startloc + len - dotloc; - break; - } - - u = (dotloc - startloc) / len; - v = 1 - u; - - co[0] = p->x*v + p->next->x*u; - co[1] = p->y*v + p->next->y*u; - - //do_symmetrical_brush_actions(sd, a, co, NULL); - } - - return p ? p->next : NULL; -} - -void sculpt_stroke_apply(Sculpt *sd, SculptStroke *stroke) -{ - /* TODO: make these values user-modifiable? */ - const int partial_len = 100; - const int min_len = 200; - - if(stroke) { - sculpt_stroke_create_final(stroke); - - if(sculpt_stroke_final_length(stroke) > min_len) { - StrokePoint *p = sculpt_stroke_apply_generic(sd, stroke, partial_len); - - /* Replace remaining values in stroke->loc with remaining stroke->final values */ - stroke->index = -1; - stroke->length = 0; - for(; p; p = p->next) { - ++stroke->index; - stroke->loc[stroke->index][0] = p->x; - stroke->loc[stroke->index][1] = p->y; - if(p->next) { - stroke->length += sculpt_stroke_seglen(p, p->next); - } - } - } - } -} - -void sculpt_stroke_apply_all(Sculpt *sd, SculptStroke *stroke) -{ - sculpt_stroke_create_final(stroke); - - if(stroke) { - sculpt_stroke_apply_generic(sd, stroke, 0); - } -} - -/* XXX: drawing goes elsewhere */ -void sculpt_stroke_draw(SculptStroke *stroke) -{ - if(stroke) { - StrokePoint *p; - - /* Draws the original stroke */ - /*glColor3f(1, 0, 0); - glBegin(GL_LINE_STRIP); - for(i = 0; i <= stroke->index; ++i) - glVertex2s(stroke->loc[i][0], stroke->loc[i][1]); - glEnd();*/ - - /* Draws the smoothed stroke */ - glColor3f(0, 1, 0); - glBegin(GL_LINE_STRIP); - for(p = stroke->final.first; p; p = p->next) - glVertex2s(p->x, p->y); - glEnd(); - } -} diff --git a/source/blender/editors/space_action/action_draw.c b/source/blender/editors/space_action/action_draw.c index 6e86748adae..4288cc10a26 100644 --- a/source/blender/editors/space_action/action_draw.c +++ b/source/blender/editors/space_action/action_draw.c @@ -92,319 +92,19 @@ #include "ED_screen.h" #include "ED_space_api.h" -#if 0 // XXX old includes for reference only - #include "BIF_editaction.h" - #include "BIF_editkey.h" - #include "BIF_editnla.h" - #include "BIF_drawgpencil.h" - #include "BIF_keyframing.h" - #include "BIF_language.h" - #include "BIF_space.h" - - #include "BDR_editcurve.h" - #include "BDR_gpencil.h" - - #include "BSE_drawnla.h" - #include "BSE_drawipo.h" - #include "BSE_drawview.h" - #include "BSE_editaction_types.h" - #include "BSE_editipo.h" - #include "BSE_headerbuttons.h" - #include "BSE_time.h" - #include "BSE_view.h" -#endif // XXX old defines for reference only - -/* XXX */ -extern void gl_round_box(int mode, float minx, float miny, float maxx, float maxy, float rad); - -/********************************** Slider Stuff **************************** */ - -#if 0 // XXX all of this slider stuff will need a rethink! -/* sliders for shapekeys */ -static void meshactionbuts(SpaceAction *saction, Object *ob, Key *key) -{ - int i; - char str[64]; - float x, y; - uiBlock *block; - uiBut *but; - - /* lets make the shapekey sliders */ - - /* reset the damn myortho2 or the sliders won't draw/redraw - * correctly *grumble* - */ - mywinset(curarea->win); - myortho2(-0.375f, curarea->winx-0.375f, G.v2d->cur.ymin, G.v2d->cur.ymax); - - sprintf(str, "actionbuttonswin %d", curarea->win); - block= uiNewBlock (&curarea->uiblocks, str, UI_EMBOSS); - - x = ACHANNEL_NAMEWIDTH + 1; - y = 0.0f; - - uiBlockSetEmboss(block, UI_EMBOSSN); - - if (!(G.saction->flag & SACTION_SLIDERS)) { - ACTWIDTH = ACHANNEL_NAMEWIDTH; - but=uiDefIconButBitS(block, TOG, SACTION_SLIDERS, B_REDR, - ICON_DISCLOSURE_TRI_RIGHT, - ACHANNEL_NAMEWIDTH - XIC - 5, (short)y + CHANNELHEIGHT, - XIC,YIC-2, - &(G.saction->flag), 0, 0, 0, 0, - "Show action window sliders"); - /* no hilite, the winmatrix is not correct later on... */ - uiButSetFlag(but, UI_NO_HILITE); - } - else { - but= uiDefIconButBitS(block, TOG, SACTION_SLIDERS, B_REDR, - ICON_DISCLOSURE_TRI_DOWN, - ACHANNEL_NAMEWIDTH - XIC - 5, (short)y + CHANNELHEIGHT, - XIC,YIC-2, - &(G.saction->flag), 0, 0, 0, 0, - "Hide action window sliders"); - /* no hilite, the winmatrix is not correct later on... */ - uiButSetFlag(but, UI_NO_HILITE); - - ACTWIDTH = ACHANNEL_NAMEWIDTH + SLIDERWIDTH; - - /* sliders are open so draw them */ - BIF_ThemeColor(TH_FACE); - - glRects(ACHANNEL_NAMEWIDTH, 0, ACHANNEL_NAMEWIDTH+SLIDERWIDTH, curarea->winy); - uiBlockSetEmboss(block, UI_EMBOSS); - for (i=1; i < key->totkey; i++) { - make_rvk_slider(block, ob, i, - (int)x, (int)y, SLIDERWIDTH-2, CHANNELHEIGHT-1, "Slider to control Shape Keys"); - - y-=CHANNELHEIGHT+CHANNELSKIP; - - /* see sliderval array in editkey.c */ - if (i >= 255) break; - } - } - uiDrawBlock(C, block); -} - -static void icu_slider_func(void *voidicu, void *voidignore) -{ - /* the callback for the icu sliders ... copies the - * value from the icu->curval into a bezier at the - * right frame on the right ipo curve (creating both the - * ipo curve and the bezier if needed). - */ - IpoCurve *icu= voidicu; - BezTriple *bezt=NULL; - float cfra, icuval; - - cfra = frame_to_float(CFRA); - if (G.saction->pin==0 && OBACT) - cfra= get_action_frame(OBACT, cfra); - - /* if the ipocurve exists, try to get a bezier - * for this frame - */ - bezt = get_bezt_icu_time(icu, &cfra, &icuval); - - /* create the bezier triple if one doesn't exist, - * otherwise modify it's value - */ - if (bezt == NULL) { - insert_vert_icu(icu, cfra, icu->curval, 0); - } - else { - bezt->vec[1][1] = icu->curval; - } - - /* make sure the Ipo's are properly processed and - * redraw as necessary - */ - sort_time_ipocurve(icu); - testhandles_ipocurve(icu); - - /* nla-update (in case this affects anything) */ - synchronize_action_strips(); - - /* do redraw pushes, and also the depsgraph flushes */ - if (OBACT->pose || ob_get_key(OBACT)) - DAG_object_flush_update(G.scene, OBACT, OB_RECALC); - else - DAG_object_flush_update(G.scene, OBACT, OB_RECALC_OB); - - allqueue(REDRAWVIEW3D, 0); - allqueue(REDRAWACTION, 0); - allqueue(REDRAWNLA, 0); - allqueue(REDRAWIPO, 0); - allspace(REMAKEIPO, 0); - allqueue(REDRAWBUTSALL, 0); -} - -static void make_icu_slider(uiBlock *block, IpoCurve *icu, - int x, int y, int w, int h, char *tip) -{ - /* create a slider for the ipo-curve*/ - uiBut *but; - - if(icu == NULL) return; - - if (IS_EQ(icu->slide_max, icu->slide_min)) { - if (IS_EQ(icu->ymax, icu->ymin)) { - if (ELEM(icu->blocktype, ID_CO, ID_KE)) { - /* hack for constraints and shapekeys (and maybe a few others) */ - icu->slide_min= 0.0; - icu->slide_max= 1.0; - } - else { - icu->slide_min= -100; - icu->slide_max= 100; - } - } - else { - icu->slide_min= icu->ymin; - icu->slide_max= icu->ymax; - } - } - if (icu->slide_min >= icu->slide_max) { - SWAP(float, icu->slide_min, icu->slide_max); - } - - but=uiDefButF(block, NUMSLI, REDRAWVIEW3D, "", - x, y , w, h, - &(icu->curval), icu->slide_min, icu->slide_max, - 10, 2, tip); - - uiButSetFunc(but, icu_slider_func, icu, NULL); - - // no hilite, the winmatrix is not correct later on... - uiButSetFlag(but, UI_NO_HILITE); -} - -/* sliders for ipo-curves of active action-channel */ -static void action_icu_buts(SpaceAction *saction) -{ - ListBase act_data = {NULL, NULL}; - bActListElem *ale; - int filter; - void *data; - short datatype; - - char str[64]; - float x, y; - uiBlock *block; - - /* lets make the action sliders */ - - /* reset the damn myortho2 or the sliders won't draw/redraw - * correctly *grumble* - */ - mywinset(curarea->win); - myortho2(-0.375f, curarea->winx-0.375f, G.v2d->cur.ymin, G.v2d->cur.ymax); - - sprintf(str, "actionbuttonswin %d", curarea->win); - block= uiNewBlock (&curarea->uiblocks, str, UI_EMBOSS); - - x = (float)ACHANNEL_NAMEWIDTH + 1; - y = 0.0f; - - uiBlockSetEmboss(block, UI_EMBOSSN); - - if (G.saction->flag & SACTION_SLIDERS) { - /* sliders are open so draw them */ - - /* get editor data */ - data= get_action_context(&datatype); - if (data == NULL) return; - - /* build list of channels to draw */ - filter= (ACTFILTER_FORDRAWING|ACTFILTER_VISIBLE|ACTFILTER_CHANNELS); - actdata_filter(&act_data, filter, data, datatype); - - /* draw backdrop first */ - BIF_ThemeColor(TH_FACE); // change this color... it's ugly - glRects(ACHANNEL_NAMEWIDTH, (short)G.v2d->cur.ymin, ACHANNEL_NAMEWIDTH+SLIDERWIDTH, (short)G.v2d->cur.ymax); - - uiBlockSetEmboss(block, UI_EMBOSS); - for (ale= act_data.first; ale; ale= ale->next) { - const float yminc= y-CHANNELHEIGHT/2; - const float ymaxc= y+CHANNELHEIGHT/2; - - /* check if visible */ - if ( IN_RANGE(yminc, G.v2d->cur.ymin, G.v2d->cur.ymax) || - IN_RANGE(ymaxc, G.v2d->cur.ymin, G.v2d->cur.ymax) ) - { - /* determine what needs to be drawn */ - switch (ale->type) { - case ACTTYPE_CONCHAN: /* constraint channel */ - { - bActionChannel *achan = (bActionChannel *)ale->owner; - IpoCurve *icu = (IpoCurve *)ale->key_data; - - /* only show if owner is selected */ - if ((ale->ownertype == ACTTYPE_OBJECT) || SEL_ACHAN(achan)) { - make_icu_slider(block, icu, - (int)x, (int)y, SLIDERWIDTH-2, CHANNELHEIGHT-2, - "Slider to control current value of Constraint Influence"); - } - } - break; - case ACTTYPE_ICU: /* ipo-curve channel */ - { - bActionChannel *achan = (bActionChannel *)ale->owner; - IpoCurve *icu = (IpoCurve *)ale->key_data; - - /* only show if owner is selected */ - if ((ale->ownertype == ACTTYPE_OBJECT) || SEL_ACHAN(achan)) { - make_icu_slider(block, icu, - (int)x, (int)y, SLIDERWIDTH-2, CHANNELHEIGHT-2, - "Slider to control current value of IPO-Curve"); - } - } - break; - case ACTTYPE_SHAPEKEY: /* shapekey channel */ - { - Object *ob= (Object *)ale->id; - IpoCurve *icu= (IpoCurve *)ale->key_data; - - // TODO: only show if object is active - if (icu) { - make_icu_slider(block, icu, - (int)x, (int)y, SLIDERWIDTH-2, CHANNELHEIGHT-2, - "Slider to control ShapeKey"); - } - else if (ob && ale->index) { - make_rvk_slider(block, ob, ale->index, - (int)x, (int)y, SLIDERWIDTH-2, CHANNELHEIGHT-1, "Slider to control Shape Keys"); - } - } - break; - } - } - - /* adjust y-position for next one */ - y-=CHANNELHEIGHT+CHANNELSKIP; - } - - /* free tempolary channels */ - BLI_freelistN(&act_data); - } - uiDrawBlock(C, block); -} - -#endif // XXX all of this slider stuff will need a rethink - /* ************************************************************************* */ /* Channel List */ /* left hand part */ -void draw_channel_names(bAnimContext *ac, SpaceAction *saction, ARegion *ar) +void draw_channel_names(bContext *C, bAnimContext *ac, SpaceAction *saction, ARegion *ar) { ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; View2D *v2d= &ar->v2d; - float x= 0.0f, y= 0.0f; + float y= 0.0f; int items, height; /* build list of channels to draw */ @@ -428,582 +128,48 @@ void draw_channel_names(bAnimContext *ac, SpaceAction *saction, ARegion *ar) UI_view2d_sync(NULL, ac->sa, v2d, V2D_VIEWSYNC_AREA_VERTICAL); /* loop through channels, and set up drawing depending on their type */ - y= (float)ACHANNEL_FIRST; - - for (ale= anim_data.first; ale; ale= ale->next) { - const float yminc= (float)(y - ACHANNEL_HEIGHT_HALF); - const float ymaxc= (float)(y + ACHANNEL_HEIGHT_HALF); + { /* first pass: just the standard GL-drawing for backdrop + text */ + y= (float)ACHANNEL_FIRST; - /* check if visible */ - if ( IN_RANGE(yminc, v2d->cur.ymin, v2d->cur.ymax) || - IN_RANGE(ymaxc, v2d->cur.ymin, v2d->cur.ymax) ) - { - bActionGroup *grp = NULL; - short indent= 0, offset= 0, sel= 0, group= 0; - int expand= -1, protect = -1, special= -1, mute = -1; - char name[128]; - - /* determine what needs to be drawn */ - switch (ale->type) { - case ANIMTYPE_SCENE: /* scene */ - { - Scene *sce= (Scene *)ale->data; - - group= 4; - indent= 0; - - special= ICON_SCENE_DATA; - - /* only show expand if there are any channels */ - if (EXPANDED_SCEC(sce)) - expand= ICON_TRIA_DOWN; - else - expand= ICON_TRIA_RIGHT; - - sel = SEL_SCEC(sce); - strcpy(name, sce->id.name+2); - } - break; - case ANIMTYPE_OBJECT: /* object */ - { - Base *base= (Base *)ale->data; - Object *ob= base->object; - - group= 4; - indent= 0; - - /* icon depends on object-type */ - if (ob->type == OB_ARMATURE) - special= ICON_ARMATURE_DATA; - else - special= ICON_OBJECT_DATA; - - /* only show expand if there are any channels */ - if (EXPANDED_OBJC(ob)) - expand= ICON_TRIA_DOWN; - else - expand= ICON_TRIA_RIGHT; - - sel = SEL_OBJC(base); - strcpy(name, ob->id.name+2); - } - break; - case ANIMTYPE_FILLACTD: /* action widget */ - { - bAction *act= (bAction *)ale->data; - - group = 4; - indent= 1; - special= ICON_ACTION; - - if (EXPANDED_ACTC(act)) - expand= ICON_TRIA_DOWN; - else - expand= ICON_TRIA_RIGHT; - - sel = SEL_ACTC(act); - strcpy(name, act->id.name+2); - } - break; - case ANIMTYPE_FILLMATD: /* object materials (dopesheet) expand widget */ - { - Object *ob = (Object *)ale->data; - - group = 4; - indent = 1; - special = ICON_MATERIAL_DATA; - - if (FILTER_MAT_OBJC(ob)) - expand = ICON_TRIA_DOWN; - else - expand = ICON_TRIA_RIGHT; - - strcpy(name, "Materials"); - } - break; - case ANIMTYPE_FILLPARTD: /* object particles (dopesheet) expand widget */ - { - Object *ob = (Object *)ale->data; - - group = 4; - indent = 1; - special = ICON_PARTICLE_DATA; - - if (FILTER_PART_OBJC(ob)) - expand = ICON_TRIA_DOWN; - else - expand = ICON_TRIA_RIGHT; - - strcpy(name, "Particles"); - } - break; - - - case ANIMTYPE_DSMAT: /* single material (dopesheet) expand widget */ - { - Material *ma = (Material *)ale->data; - - group = 0; - indent = 0; - special = ICON_MATERIAL_DATA; - offset = 21; - - if (FILTER_MAT_OBJD(ma)) - expand = ICON_TRIA_DOWN; - else - expand = ICON_TRIA_RIGHT; - - strcpy(name, ma->id.name+2); - } - break; - case ANIMTYPE_DSLAM: /* lamp (dopesheet) expand widget */ - { - Lamp *la = (Lamp *)ale->data; - - group = 4; - indent = 1; - special = ICON_LAMP_DATA; - - if (FILTER_LAM_OBJD(la)) - expand = ICON_TRIA_DOWN; - else - expand = ICON_TRIA_RIGHT; - - strcpy(name, la->id.name+2); - } - break; - case ANIMTYPE_DSCAM: /* camera (dopesheet) expand widget */ - { - Camera *ca = (Camera *)ale->data; - - group = 4; - indent = 1; - special = ICON_CAMERA_DATA; - - if (FILTER_CAM_OBJD(ca)) - expand = ICON_TRIA_DOWN; - else - expand = ICON_TRIA_RIGHT; - - strcpy(name, ca->id.name+2); - } - break; - case ANIMTYPE_DSCUR: /* curve (dopesheet) expand widget */ - { - Curve *cu = (Curve *)ale->data; - - group = 4; - indent = 1; - special = ICON_CURVE_DATA; - - if (FILTER_CUR_OBJD(cu)) - expand = ICON_TRIA_DOWN; - else - expand = ICON_TRIA_RIGHT; - - strcpy(name, cu->id.name+2); - } - break; - case ANIMTYPE_DSSKEY: /* shapekeys (dopesheet) expand widget */ - { - Key *key= (Key *)ale->data; - - group = 4; - indent = 1; - special = ICON_SHAPEKEY_DATA; // XXX - - if (FILTER_SKE_OBJD(key)) - expand = ICON_TRIA_DOWN; - else - expand = ICON_TRIA_RIGHT; - - //sel = SEL_OBJC(base); - strcpy(name, "Shape Keys"); - } - break; - case ANIMTYPE_DSWOR: /* world (dopesheet) expand widget */ - { - World *wo= (World *)ale->data; - - group = 4; - indent = 1; - special = ICON_WORLD_DATA; - - if (FILTER_WOR_SCED(wo)) - expand = ICON_TRIA_DOWN; - else - expand = ICON_TRIA_RIGHT; - - strcpy(name, wo->id.name+2); - } - break; - case ANIMTYPE_DSPART: /* particle (dopesheet) expand widget */ - { - ParticleSettings *part= (ParticleSettings*)ale->data; - - group = 0; - indent = 0; - special = ICON_PARTICLE_DATA; - offset = 21; - - if (FILTER_PART_OBJD(part)) - expand = ICON_TRIA_DOWN; - else - expand = ICON_TRIA_RIGHT; - - strcpy(name, part->id.name+2); - } - break; - case ANIMTYPE_DSMBALL: /* metaball (dopesheet) expand widget */ - { - MetaBall *mb = (MetaBall *)ale->data; - - group = 4; - indent = 1; - special = ICON_META_DATA; - - if (FILTER_MBALL_OBJD(mb)) - expand = ICON_TRIA_DOWN; - else - expand = ICON_TRIA_RIGHT; - - strcpy(name, mb->id.name+2); - } - break; - - - case ANIMTYPE_GROUP: /* action group */ - { - bActionGroup *agrp= (bActionGroup *)ale->data; - - group= 2; - indent= 0; - special= -1; - - if (ale->id) { - /* special exception for materials */ - if (GS(ale->id->name) == ID_MA) - offset= 25; - else - offset= 14; - } - else - offset= 0; - - /* only show expand if there are any channels */ - if (agrp->channels.first) { - if (EXPANDED_AGRP(agrp)) - expand = ICON_TRIA_DOWN; - else - expand = ICON_TRIA_RIGHT; - } - - if (agrp->flag & AGRP_MUTED) - mute = ICON_MUTE_IPO_ON; - else - mute = ICON_MUTE_IPO_OFF; - - if (EDITABLE_AGRP(agrp)) - protect = ICON_UNLOCKED; - else - protect = ICON_LOCKED; - - sel = SEL_AGRP(agrp); - strcpy(name, agrp->name); - } - break; - case ANIMTYPE_FCURVE: /* F-Curve channel */ - { - FCurve *fcu = (FCurve *)ale->data; - - indent = 0; - - group= (fcu->grp) ? 1 : 0; - grp= fcu->grp; - - if (ale->id) { - /* special exception for materials and particles */ - if (ELEM(GS(ale->id->name),ID_MA,ID_PA)) { - offset= 21; - indent= 1; - } - else - offset= 14; - } - else - offset= 0; - - if (fcu->flag & FCURVE_MUTED) - mute = ICON_MUTE_IPO_ON; - else - mute = ICON_MUTE_IPO_OFF; - - if (fcu->bezt) { - if (EDITABLE_FCU(fcu)) - protect = ICON_UNLOCKED; - else - protect = ICON_LOCKED; - } - else - protect = ICON_ZOOMOUT; // XXX editability is irrelevant here, but this icon is temp... - - sel = SEL_FCU(fcu); - - getname_anim_fcurve(name, ale->id, fcu); - } - break; - - case ANIMTYPE_SHAPEKEY: /* shapekey channel */ - { - KeyBlock *kb = (KeyBlock *)ale->data; - - indent = 0; - special = -1; - - offset= (ale->id) ? 21 : 0; - - if (kb->name[0] == '\0') - sprintf(name, "Key %d", ale->index); - else - strcpy(name, kb->name); - } - break; - - case ANIMTYPE_GPDATABLOCK: /* gpencil datablock */ - { - bGPdata *gpd = (bGPdata *)ale->data; - ScrArea *sa = (ScrArea *)ale->owner; - - indent = 0; - group= 3; - - /* only show expand if there are any channels */ - if (gpd->layers.first) { - if (gpd->flag & GP_DATA_EXPAND) - expand = ICON_TRIA_DOWN; - else - expand = ICON_TRIA_RIGHT; - } - - switch (sa->spacetype) { - case SPACE_VIEW3D: - { - /* this shouldn't cause any overflow... */ - //sprintf(name, "3DView:%s", view3d_get_name(sa->spacedata.first)); // XXX missing func.. - strcpy(name, "3dView"); - special= ICON_VIEW3D; - } - break; - case SPACE_NODE: - { - SpaceNode *snode= sa->spacedata.first; - char treetype[12]; - - if (snode->treetype == 1) - strcpy(treetype, "Composite"); - else - strcpy(treetype, "Material"); - sprintf(name, "Nodes:%s", treetype); - - special= ICON_NODE; - } - break; - case SPACE_SEQ: - { - SpaceSeq *sseq= sa->spacedata.first; - char imgpreview[10]; - - switch (sseq->mainb) { - case 1: sprintf(imgpreview, "Image..."); break; - case 2: sprintf(imgpreview, "Luma..."); break; - case 3: sprintf(imgpreview, "Chroma..."); break; - case 4: sprintf(imgpreview, "Histogram"); break; - - default: sprintf(imgpreview, "Sequence"); break; - } - sprintf(name, "Sequencer:%s", imgpreview); - - special= ICON_SEQUENCE; - } - break; - case SPACE_IMAGE: - { - SpaceImage *sima= sa->spacedata.first; - - if (sima->image) - sprintf(name, "Image:%s", sima->image->id.name+2); - else - strcpy(name, "Image:<None>"); - - special= ICON_IMAGE_COL; - } - break; - - default: - { - sprintf(name, "<Unknown GP-Data Source>"); - special= -1; - } - break; - } - } - break; - case ANIMTYPE_GPLAYER: /* gpencil layer */ - { - bGPDlayer *gpl = (bGPDlayer *)ale->data; - - indent = 0; - special = -1; - expand = -1; - group = 1; - - if (EDITABLE_GPL(gpl)) - protect = ICON_UNLOCKED; - else - protect = ICON_LOCKED; - - if (gpl->flag & GP_LAYER_HIDE) - mute = ICON_MUTE_IPO_ON; - else - mute = ICON_MUTE_IPO_OFF; - - sel = SEL_GPL(gpl); - BLI_snprintf(name, 32, gpl->info); - } - break; - } + for (ale= anim_data.first; ale; ale= ale->next) { + float yminc= (float)(y - ACHANNEL_HEIGHT_HALF); + float ymaxc= (float)(y + ACHANNEL_HEIGHT_HALF); - /* now, start drawing based on this information */ - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - glEnable(GL_BLEND); - - /* draw backing strip behind channel name */ - if (group == 4) { - /* only used in dopesheet... */ - if (ELEM(ale->type, ANIMTYPE_SCENE, ANIMTYPE_OBJECT)) { - /* object channel - darker */ - UI_ThemeColor(TH_DOPESHEET_CHANNELOB); - uiSetRoundBox((expand == ICON_TRIA_DOWN)? (1):(1|8)); - gl_round_box(GL_POLYGON, x+offset, yminc, (float)ACHANNEL_NAMEWIDTH, ymaxc, 8); - } - else { - /* sub-object folders - lighter */ - UI_ThemeColor(TH_DOPESHEET_CHANNELSUBOB); - - offset += 7 * indent; - glBegin(GL_QUADS); - glVertex2f(x+offset, yminc); - glVertex2f(x+offset, ymaxc); - glVertex2f((float)ACHANNEL_NAMEWIDTH, ymaxc); - glVertex2f((float)ACHANNEL_NAMEWIDTH, yminc); - glEnd(); - - /* clear group value, otherwise we cause errors... */ - group = 0; - } - } - else if (group == 3) { - /* only for gp-data channels */ - UI_ThemeColorShade(TH_GROUP, 20); - uiSetRoundBox((expand == ICON_TRIA_DOWN)? (1):(1|8)); - gl_round_box(GL_POLYGON, x+offset, yminc, (float)ACHANNEL_NAMEWIDTH, ymaxc, 8); - } - else if (group == 2) { - /* only for action group channels */ - if (ale->flag & AGRP_ACTIVE) - UI_ThemeColorShade(TH_GROUP_ACTIVE, 10); - else - UI_ThemeColorShade(TH_GROUP, 20); - uiSetRoundBox((expand == ICON_TRIA_DOWN)? (1):(1|8)); - gl_round_box(GL_POLYGON, x+offset, yminc, (float)ACHANNEL_NAMEWIDTH, ymaxc, 8); - } - else { - /* for normal channels - * - use 3 shades of color group/standard color for 3 indention level - * - only use group colors if allowed to, and if actually feasible - */ - if ( !(saction->flag & SACTION_NODRAWGCOLORS) && - (grp) && (grp->customCol) ) - { - char cp[3]; - - if (indent == 2) { - VECCOPY(cp, grp->cs.solid); - } - else if (indent == 1) { - VECCOPY(cp, grp->cs.select); - } - else { - VECCOPY(cp, grp->cs.active); - } - - glColor3ub(cp[0], cp[1], cp[2]); - } - else - UI_ThemeColorShade(TH_HEADER, ((indent==0)?20: (indent==1)?-20: -40)); - - indent += group; - offset += 7 * indent; - glBegin(GL_QUADS); - glVertex2f(x+offset, yminc); - glVertex2f(x+offset, ymaxc); - glVertex2f((float)ACHANNEL_NAMEWIDTH, ymaxc); - glVertex2f((float)ACHANNEL_NAMEWIDTH, yminc); - glEnd(); - } - - /* draw expand/collapse triangle */ - if (expand > 0) { - UI_icon_draw(x+offset, yminc, expand); - offset += 17; - } - - /* draw special icon indicating certain data-types */ - if (special > -1) { - if (ELEM(group, 3, 4)) { - /* for gpdatablock channels */ - UI_icon_draw(x+offset, yminc, special); - offset += 17; - } - else { - /* for normal channels */ - UI_icon_draw(x+offset, yminc, special); - offset += 17; - } + /* check if visible */ + if ( IN_RANGE(yminc, v2d->cur.ymin, v2d->cur.ymax) || + IN_RANGE(ymaxc, v2d->cur.ymin, v2d->cur.ymax) ) + { + /* draw all channels using standard channel-drawing API */ + ANIM_channel_draw(ac, ale, yminc, ymaxc); } - glDisable(GL_BLEND); - - /* draw name */ - if (sel) - UI_ThemeColor(TH_TEXT_HI); - else - UI_ThemeColor(TH_TEXT); - offset += 3; - UI_DrawString(x+offset, y-4, name); - /* reset offset - for RHS of panel */ - offset = 0; - - /* set blending again, as text drawing may clear it */ - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - glEnable(GL_BLEND); + /* adjust y-position for next one */ + y -= ACHANNEL_STEP; + } + } + { /* second pass: widgets */ + uiBlock *block= uiBeginBlock(C, ar, "dopesheet channel buttons", UI_EMBOSS); + + y= (float)ACHANNEL_FIRST; + + for (ale= anim_data.first; ale; ale= ale->next) { + float yminc= (float)(y - ACHANNEL_HEIGHT_HALF); + float ymaxc= (float)(y + ACHANNEL_HEIGHT_HALF); - /* draw protect 'lock' */ - if (protect > -1) { - offset = 16; - UI_icon_draw((float)ACHANNEL_NAMEWIDTH-offset, yminc, protect); + /* check if visible */ + if ( IN_RANGE(yminc, v2d->cur.ymin, v2d->cur.ymax) || + IN_RANGE(ymaxc, v2d->cur.ymin, v2d->cur.ymax) ) + { + /* draw all channels using standard channel-drawing API */ + ANIM_channel_draw_widgets(ac, ale, block, yminc, ymaxc); } - /* draw mute 'eye' */ - if (mute > -1) { - offset += 16; - UI_icon_draw((float)(ACHANNEL_NAMEWIDTH-offset), yminc, mute); - } - glDisable(GL_BLEND); + /* adjust y-position for next one */ + y -= ACHANNEL_STEP; } - /* adjust y-position for next one */ - y -= ACHANNEL_STEP; + uiEndBlock(C, block); + uiDrawBlock(C, block); } /* free tempolary channels */ @@ -1052,7 +218,6 @@ void draw_channel_strips(bAnimContext *ac, SpaceAction *saction, ARegion *ar) adt= ANIM_nla_mapping_get(ac, NULL); /* start and end of action itself */ - // TODO: this has not had scaling applied calc_action_range(ac->data, &act_start, &act_end, 0); } @@ -1084,43 +249,14 @@ void draw_channel_strips(bAnimContext *ac, SpaceAction *saction, ARegion *ar) if ( IN_RANGE(yminc, v2d->cur.ymin, v2d->cur.ymax) || IN_RANGE(ymaxc, v2d->cur.ymin, v2d->cur.ymax) ) { + bAnimChannelType *acf= ANIM_channel_get_typeinfo(ale); int sel=0; /* determine if any need to draw channel */ if (ale->datatype != ALE_NONE) { /* determine if channel is selected */ - switch (ale->type) { - case ANIMTYPE_SCENE: - { - Scene *sce= (Scene *)ale->data; - sel = SEL_SCEC(sce); - } - break; - case ANIMTYPE_OBJECT: - { - Base *base= (Base *)ale->data; - sel = SEL_OBJC(base); - } - break; - case ANIMTYPE_GROUP: - { - bActionGroup *agrp = (bActionGroup *)ale->data; - sel = SEL_AGRP(agrp); - } - break; - case ANIMTYPE_FCURVE: - { - FCurve *fcu = (FCurve *)ale->data; - sel = SEL_FCU(fcu); - } - break; - case ANIMTYPE_GPLAYER: - { - bGPDlayer *gpl = (bGPDlayer *)ale->data; - sel = SEL_GPL(gpl); - } - break; - } + if (acf->has_setting(ac, ale, ACHANNEL_SETTING_SELECT)) + sel= ANIM_channel_setting_get(ac, ale, ACHANNEL_SETTING_SELECT); if (ELEM(ac->datatype, ANIMCONT_ACTION, ANIMCONT_DOPESHEET)) { switch (ale->type) { diff --git a/source/blender/editors/space_action/action_header.c b/source/blender/editors/space_action/action_header.c index d3929a22342..e2a725164c9 100644 --- a/source/blender/editors/space_action/action_header.c +++ b/source/blender/editors/space_action/action_header.c @@ -43,6 +43,7 @@ #include "BLI_blenlib.h" #include "BKE_animsys.h" +#include "BKE_action.h" #include "BKE_context.h" #include "BKE_screen.h" @@ -88,9 +89,9 @@ static void act_viewmenu(bContext *C, uiLayout *layout, void *arg_unused) //uiItemS(layout); - uiItemR(layout, NULL, 0, &spaceptr, "show_cframe_indicator", 0, 0, 0); - uiItemR(layout, NULL, 0, &spaceptr, "show_sliders", 0, 0, 0); - uiItemR(layout, NULL, 0, &spaceptr, "automerge_keyframes", 0, 0, 0); + uiItemR(layout, NULL, 0, &spaceptr, "show_cframe_indicator", 0); + uiItemR(layout, NULL, 0, &spaceptr, "show_sliders", 0); + uiItemR(layout, NULL, 0, &spaceptr, "automerge_keyframes", 0); if (sact->flag & SACTION_DRAWTIME) uiItemO(layout, "Show Frames", 0, "ANIM_OT_time_toggle"); @@ -153,7 +154,7 @@ static void act_channelmenu(bContext *C, uiLayout *layout, void *arg_unused) static void act_gplayermenu(bContext *C, uiLayout *layout, void *arg_unused) { - //uiItemMenuF(layout, "Transform", 0, nla_edit_transformmenu); + //uiItemMenuF(layout, "Transform", 0, nla_edit_transformmenu, NULL, NULL); //uiItemS(layout); //uiItemO(layout, NULL, 0, "NLAEDIT_OT_duplicate"); } @@ -210,9 +211,9 @@ static void act_edit_expomenu(bContext *C, uiLayout *layout, void *arg_unused) static void act_editmenu(bContext *C, uiLayout *layout, void *arg_unused) { - uiItemMenuF(layout, "Transform", 0, act_edit_transformmenu); - uiItemMenuF(layout, "Snap", 0, act_edit_snapmenu); - uiItemMenuF(layout, "Mirror", 0, act_edit_mirrormenu); + uiItemMenuF(layout, "Transform", 0, act_edit_transformmenu, NULL); + uiItemMenuF(layout, "Snap", 0, act_edit_snapmenu, NULL); + uiItemMenuF(layout, "Mirror", 0, act_edit_mirrormenu, NULL); uiItemS(layout); @@ -225,9 +226,9 @@ static void act_editmenu(bContext *C, uiLayout *layout, void *arg_unused) uiItemS(layout); - uiItemMenuF(layout, "Handle Type", 0, act_edit_handlesmenu); - uiItemMenuF(layout, "Interpolation Mode", 0, act_edit_ipomenu); - uiItemMenuF(layout, "Extrapolation Mode", 0, act_edit_expomenu); + uiItemMenuF(layout, "Handle Type", 0, act_edit_handlesmenu, NULL); + uiItemMenuF(layout, "Interpolation Mode", 0, act_edit_ipomenu, NULL); + uiItemMenuF(layout, "Extrapolation Mode", 0, act_edit_expomenu, NULL); uiItemS(layout); @@ -272,6 +273,7 @@ static void saction_idpoin_handle(bContext *C, ID *id, int event) /* set action */ printf("\tset action \n"); adt->action= saction->action; + adt->action->id.us++; } ED_area_tag_redraw(CTX_wm_area(C)); @@ -282,7 +284,14 @@ static void saction_idpoin_handle(bContext *C, ID *id, int event) break; case UI_ID_ADD_NEW: printf("actedit addnew \n"); - /* XXX not implemented */ + if (saction->pin == 0) { + AnimData *adt= BKE_id_add_animdata(&obact->id); /* this only adds if non-existant */ + + /* set new action */ + // XXX need to restore behaviour to copy old actions... + printf("\tset new action \n"); + adt->action= saction->action= add_empty_action("Action"); + } break; case UI_ID_OPEN: printf("actedit open \n"); @@ -404,13 +413,13 @@ void action_header_buttons(const bContext *C, ARegion *ar) if (saction->flag & SACTION_DRAWTIME) { uiDefButC(block, MENU, B_REDR, "Auto-Snap Keyframes %t|No Snap %x0|Second Step %x1|Nearest Second %x2|Nearest Marker %x3", - xco,yco,70,YIC, &(saction->autosnap), 0, 1, 0, 0, + xco,yco,90,YIC, &(saction->autosnap), 0, 1, 0, 0, "Auto-snapping mode for keyframes when transforming"); } else { uiDefButC(block, MENU, B_REDR, "Auto-Snap Keyframes %t|No Snap %x0|Frame Step %x1|Nearest Frame %x2|Nearest Marker %x3", - xco,yco,70,YIC, &(saction->autosnap), 0, 1, 0, 0, + xco,yco,90,YIC, &(saction->autosnap), 0, 1, 0, 0, "Auto-snapping mode for keyframes when transforming"); } diff --git a/source/blender/editors/space_action/action_intern.h b/source/blender/editors/space_action/action_intern.h index 26655892176..1aeeeff0c80 100644 --- a/source/blender/editors/space_action/action_intern.h +++ b/source/blender/editors/space_action/action_intern.h @@ -41,7 +41,7 @@ struct bAnimListElem; /* ***************************************** */ /* action_draw.c */ -void draw_channel_names(struct bAnimContext *ac, struct SpaceAction *saction, struct ARegion *ar); +void draw_channel_names(struct bContext *C, struct bAnimContext *ac, struct SpaceAction *saction, struct ARegion *ar); void draw_channel_strips(struct bAnimContext *ac, struct SpaceAction *saction, struct ARegion *ar); struct ActKeysInc *init_aki_data(struct bAnimContext *ac, struct bAnimListElem *ale); diff --git a/source/blender/editors/space_action/space_action.c b/source/blender/editors/space_action/space_action.c index 55e035cfced..2977d07d845 100644 --- a/source/blender/editors/space_action/space_action.c +++ b/source/blender/editors/space_action/space_action.c @@ -243,7 +243,7 @@ static void action_channel_area_draw(const bContext *C, ARegion *ar) /* data */ if (ANIM_animdata_get_context(C, &ac)) { - draw_channel_names(&ac, saction, ar); + draw_channel_names((bContext *)C, &ac, saction, ar); } /* reset view matrix */ @@ -294,6 +294,7 @@ static void action_channel_area_listener(ARegion *ar, wmNotifier *wmn) case NC_SCENE: switch(wmn->data) { case ND_OB_ACTIVE: + case ND_FRAME: ED_region_tag_redraw(ar); break; } diff --git a/source/blender/editors/space_api/spacetypes.c b/source/blender/editors/space_api/spacetypes.c index 5c33b648947..041e6a09323 100644 --- a/source/blender/editors/space_api/spacetypes.c +++ b/source/blender/editors/space_api/spacetypes.c @@ -77,6 +77,7 @@ void ED_spacetypes_init(void) ED_spacetype_sequencer(); ED_spacetype_logic(); ED_spacetype_console(); + ED_spacetype_userpref(); // ... /* register operator types for screen and all spaces */ diff --git a/source/blender/editors/space_buttons/buttons_context.c b/source/blender/editors/space_buttons/buttons_context.c index 614017cc4c6..8306487013a 100644 --- a/source/blender/editors/space_buttons/buttons_context.c +++ b/source/blender/editors/space_buttons/buttons_context.c @@ -49,6 +49,7 @@ #include "BKE_global.h" #include "BKE_material.h" #include "BKE_modifier.h" +#include "BKE_paint.h" #include "BKE_particle.h" #include "BKE_screen.h" #include "BKE_utildefines.h" @@ -304,7 +305,7 @@ static int buttons_context_path_particle(ButsContextPath *path) return 0; } -static int buttons_context_path_brush(ButsContextPath *path) +static int buttons_context_path_brush(const bContext *C, ButsContextPath *path) { Scene *scene; ToolSettings *ts; @@ -320,14 +321,8 @@ static int buttons_context_path_brush(ButsContextPath *path) scene= path->ptr[path->len-1].data; ts= scene->toolsettings; - if(G.f & G_SCULPTMODE) - br= ts->sculpt->brush; - else if(G.f & G_VERTEXPAINT) - br= ts->vpaint->brush; - else if(G.f & G_WEIGHTPAINT) - br= ts->wpaint->brush; - else if(G.f & G_TEXTUREPAINT) - br= ts->imapaint.brush; + if(scene) + br= paint_brush(paint_get_active(scene)); if(br) { RNA_id_pointer_create(&br->id, &path->ptr[path->len]); @@ -337,11 +332,11 @@ static int buttons_context_path_brush(ButsContextPath *path) } } - /* no path to a world possible */ + /* no path to a brush possible */ return 0; } -static int buttons_context_path_texture(ButsContextPath *path) +static int buttons_context_path_texture(const bContext *C, ButsContextPath *path) { Material *ma; Lamp *la; @@ -356,7 +351,7 @@ static int buttons_context_path_texture(ButsContextPath *path) return 1; } /* try brush */ - else if((path->flag & SB_BRUSH_TEX) && buttons_context_path_brush(path)) { + else if((path->flag & SB_BRUSH_TEX) && buttons_context_path_brush(C, path)) { br= path->ptr[path->len-1].data; if(br) { @@ -465,7 +460,7 @@ static int buttons_context_path(const bContext *C, ButsContextPath *path, int ma found= buttons_context_path_material(path); break; case BCONTEXT_TEXTURE: - found= buttons_context_path_texture(path); + found= buttons_context_path_texture(C, path); break; case BCONTEXT_BONE: found= buttons_context_path_bone(path); @@ -558,7 +553,7 @@ int buttons_context(const bContext *C, const char *member, bContextDataResult *r "world", "object", "mesh", "armature", "lattice", "curve", "meta_ball", "lamp", "camera", "material", "material_slot", "texture", "texture_slot", "bone", "edit_bone", "particle_system", - "cloth", "soft_body", "fluid", "collision", "brush", NULL}; + "cloth", "soft_body", "fluid", "smoke", "smoke_hr", "collision", "brush", NULL}; CTX_data_dir_set(result, dir); return 1; @@ -691,6 +686,17 @@ int buttons_context(const bContext *C, const char *member, bContextDataResult *r return 1; } } + + else if(CTX_data_equals(member, "smoke")) { + PointerRNA *ptr= get_pointer_type(path, &RNA_Object); + + if(ptr && ptr->data) { + Object *ob= ptr->data; + ModifierData *md= modifiers_findByType(ob, eModifierType_Smoke); + CTX_data_pointer_set(result, &ob->id, &RNA_SmokeModifier, md); + return 1; + } + } else if(CTX_data_equals(member, "collision")) { PointerRNA *ptr= get_pointer_type(path, &RNA_Object); diff --git a/source/blender/editors/space_buttons/buttons_ops.c b/source/blender/editors/space_buttons/buttons_ops.c index 4e9715538a0..d4b5997ed95 100644 --- a/source/blender/editors/space_buttons/buttons_ops.c +++ b/source/blender/editors/space_buttons/buttons_ops.c @@ -920,7 +920,7 @@ static int toolbox_invoke(bContext *C, wmOperator *op, wmEvent *event) uiPopupMenu *pup; uiLayout *layout; - RNA_pointer_create(&sc->id, &RNA_SpaceButtonsWindow, sbuts, &ptr); + RNA_pointer_create(&sc->id, &RNA_SpaceProperties, sbuts, &ptr); pup= uiPupMenuBegin(C, "Align", 0); layout= uiPupMenuLayout(pup); diff --git a/source/blender/editors/space_console/console_ops.c b/source/blender/editors/space_console/console_ops.c index fa9055f2d8d..f8dbe0c3dd4 100644 --- a/source/blender/editors/space_console/console_ops.c +++ b/source/blender/editors/space_console/console_ops.c @@ -280,6 +280,7 @@ void CONSOLE_OT_move(wmOperatorType *ot) { /* identifiers */ ot->name= "Move Cursor"; + ot->description= "Move cursor position."; ot->idname= "CONSOLE_OT_move"; /* api callbacks */ @@ -324,6 +325,7 @@ void CONSOLE_OT_insert(wmOperatorType *ot) { /* identifiers */ ot->name= "Insert"; + ot->description= "Insert text at cursor position."; ot->idname= "CONSOLE_OT_insert"; /* api callbacks */ @@ -391,6 +393,7 @@ void CONSOLE_OT_delete(wmOperatorType *ot) { /* identifiers */ ot->name= "Delete"; + ot->description= "Delete text by cursor position."; ot->idname= "CONSOLE_OT_delete"; /* api callbacks */ @@ -434,6 +437,7 @@ void CONSOLE_OT_clear(wmOperatorType *ot) { /* identifiers */ ot->name= "Clear"; + ot->description= "Clear text by type."; ot->idname= "CONSOLE_OT_clear"; /* api callbacks */ @@ -478,6 +482,7 @@ void CONSOLE_OT_history_cycle(wmOperatorType *ot) { /* identifiers */ ot->name= "History Cycle"; + ot->description= "Cycle through history."; ot->idname= "CONSOLE_OT_history_cycle"; /* api callbacks */ @@ -525,6 +530,7 @@ void CONSOLE_OT_history_append(wmOperatorType *ot) { /* identifiers */ ot->name= "History Append"; + ot->description= "Append history at cursor position."; ot->idname= "CONSOLE_OT_history_append"; /* api callbacks */ @@ -572,6 +578,7 @@ void CONSOLE_OT_scrollback_append(wmOperatorType *ot) /* identifiers */ ot->name= "Scrollback Append"; + ot->description= "Append scrollback text by type."; ot->idname= "CONSOLE_OT_scrollback_append"; /* api callbacks */ @@ -614,6 +621,7 @@ void CONSOLE_OT_copy(wmOperatorType *ot) { /* identifiers */ ot->name= "Copy to Clipboard"; + ot->description= "Copy selected text to clipboard."; ot->idname= "CONSOLE_OT_copy"; /* api callbacks */ @@ -648,6 +656,7 @@ void CONSOLE_OT_paste(wmOperatorType *ot) { /* identifiers */ ot->name= "Paste from Clipboard"; + ot->description= "Paste text from clipboard."; ot->idname= "CONSOLE_OT_paste"; /* api callbacks */ @@ -679,6 +688,9 @@ void CONSOLE_OT_zoom(wmOperatorType *ot) { /* identifiers */ ot->name= "Console Zoom"; + /*optionals - + "Zoom view font." */ + ot->description= "Zoom screen area."; ot->idname= "CONSOLE_OT_zoom"; /* api callbacks */ diff --git a/source/blender/editors/space_console/console_report.c b/source/blender/editors/space_console/console_report.c index 2e23c4039f1..08d003f0706 100644 --- a/source/blender/editors/space_console/console_report.c +++ b/source/blender/editors/space_console/console_report.c @@ -114,6 +114,7 @@ void CONSOLE_OT_report_replay(wmOperatorType *ot) { /* identifiers */ ot->name= "Replay Operators"; + ot->description= "Replay selected reports."; ot->idname= "CONSOLE_OT_report_replay"; /* api callbacks */ @@ -160,6 +161,7 @@ void CONSOLE_OT_select_pick(wmOperatorType *ot) { /* identifiers */ ot->name= "Select report"; + ot->description= "Select reports by index."; ot->idname= "CONSOLE_OT_select_pick"; /* api callbacks */ @@ -213,6 +215,7 @@ void CONSOLE_OT_select_all_toggle(wmOperatorType *ot) { /* identifiers */ ot->name= "(De)Select All"; + ot->description= "(de)select all reports."; ot->idname= "CONSOLE_OT_select_all_toggle"; /* api callbacks */ @@ -304,6 +307,7 @@ void CONSOLE_OT_select_border(wmOperatorType *ot) { /* identifiers */ ot->name= "Border Select"; + ot->description= "Toggle border selection."; ot->idname= "CONSOLE_OT_select_border"; /* api callbacks */ @@ -357,6 +361,7 @@ void CONSOLE_OT_report_delete(wmOperatorType *ot) { /* identifiers */ ot->name= "Delete Reports"; + ot->description= "Delete selected reports."; ot->idname= "CONSOLE_OT_report_delete"; /* api callbacks */ @@ -401,6 +406,7 @@ void CONSOLE_OT_report_copy(wmOperatorType *ot) { /* identifiers */ ot->name= "Copy Reports to Clipboard"; + ot->description= "Copy selected reports to Clipboard."; ot->idname= "CONSOLE_OT_report_copy"; /* api callbacks */ diff --git a/source/blender/editors/space_file/Makefile b/source/blender/editors/space_file/Makefile index 2f4180448e5..43b2f09ed2d 100644 --- a/source/blender/editors/space_file/Makefile +++ b/source/blender/editors/space_file/Makefile @@ -59,3 +59,7 @@ ifeq ($(WITH_OPENJPEG),true) CPPFLAGS += -DWITH_OPENJPEG endif +ifeq ($(WITH_OPENEXR), true) + CPPFLAGS += -DWITH_OPENEXR +endif + diff --git a/source/blender/editors/space_file/SConscript b/source/blender/editors/space_file/SConscript index 36e042bdaa6..e6fba38fb8f 100644 --- a/source/blender/editors/space_file/SConscript +++ b/source/blender/editors/space_file/SConscript @@ -12,5 +12,7 @@ defs = [] if env['WITH_BF_OPENJPEG']: defs.append('WITH_OPENJPEG') +if env['WITH_BF_OPENEXR']: + defs.append('WITH_OPENEXR') env.BlenderLib ( 'bf_editors_space_file', sources, Split(incs), defs, libtype=['core'], priority=[115] ) diff --git a/source/blender/editors/space_file/file_draw.c b/source/blender/editors/space_file/file_draw.c index 5a07c6a7550..00024ffa961 100644 --- a/source/blender/editors/space_file/file_draw.c +++ b/source/blender/editors/space_file/file_draw.c @@ -353,59 +353,9 @@ void file_calc_previews(const bContext *C, ARegion *ar) UI_view2d_totRect_set(v2d, sfile->layout->width, sfile->layout->height); } -void file_draw_previews(const bContext *C, ARegion *ar) +static void file_draw_preview(short sx, short sy, ImBuf *imb, FileLayout *layout, short dropshadow) { - SpaceFile *sfile= CTX_wm_space_file(C); - FileSelectParams* params= ED_fileselect_get_params(sfile); - FileLayout* layout= ED_fileselect_get_layout(sfile, ar); - View2D *v2d= &ar->v2d; - struct FileList* files = sfile->files; - int numfiles; - struct direntry *file; - short sx, sy; - ImBuf* imb=0; - int i; - int colorid = 0; - int offset; - int is_icon; - - if (!files) return; - - filelist_imgsize(files,sfile->layout->prv_w,sfile->layout->prv_h); - numfiles = filelist_numfiles(files); - - sx = v2d->cur.xmin + layout->tile_border_x; - sy = v2d->cur.ymax - layout->tile_border_y; - - offset = ED_fileselect_layout_offset(layout, 0, 0); - if (offset<0) offset=0; - for (i=offset; (i < numfiles) && (i < (offset+(layout->rows+2)*layout->columns)); ++i) - { - ED_fileselect_layout_tilepos(layout, i, &sx, &sy); - sx += v2d->tot.xmin+2; - sy = v2d->tot.ymax - sy; - file = filelist_file(files, i); - - if (file->flags & ACTIVE) { - colorid = TH_HILITE; - draw_tile(sx - 1, sy, sfile->layout->tile_w + 1, sfile->layout->tile_h, colorid,0); - } else if (params->active_file == i) { - colorid = TH_ACTIVE; - draw_tile(sx - 1, sy, sfile->layout->tile_w + 1, sfile->layout->tile_h, colorid,0); - } - - if ( (file->flags & IMAGEFILE) /* || (file->flags & MOVIEFILE) */) - { - filelist_loadimage(files, i); - } - is_icon = 0; - imb = filelist_getimage(files, i); - if (!imb) { - imb = filelist_geticon(files,i); - is_icon = 1; - } - - if (imb) { + if (imb) { float fx, fy; float dx, dy; short xco, yco; @@ -433,15 +383,15 @@ void file_draw_previews(const bContext *C, ARegion *ar) ey = (short)scaledy; fx = ((float)layout->prv_w - (float)ex)/2.0f; fy = ((float)layout->prv_h - (float)ey)/2.0f; - dx = (fx + 0.5f + sfile->layout->prv_border_x); - dy = (fy + 0.5f - sfile->layout->prv_border_y); + dx = (fx + 0.5f + layout->prv_border_x); + dy = (fy + 0.5f - layout->prv_border_y); xco = (float)sx + dx; - yco = (float)sy - sfile->layout->prv_h + dy; + yco = (float)sy - layout->prv_h + dy; glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); /* shadow */ - if (!is_icon && (file->flags & IMAGEFILE)) + if (dropshadow) uiDrawBoxShadow(220, xco, yco, xco + ex, yco + ey); glEnable(GL_BLEND); @@ -451,7 +401,7 @@ void file_draw_previews(const bContext *C, ARegion *ar) glaDrawPixelsTexScaled(xco, yco, imb->x, imb->y, GL_UNSIGNED_BYTE, imb->rect, scale, scale); /* border */ - if (!is_icon && (file->flags & IMAGEFILE)) { + if (dropshadow) { glColor4f(0.0f, 0.0f, 0.0f, 0.4f); fdrawbox(xco, yco, xco + ex, yco + ey); } @@ -459,41 +409,6 @@ void file_draw_previews(const bContext *C, ARegion *ar) glDisable(GL_BLEND); imb = 0; } - - /* shadow */ - UI_ThemeColorShade(TH_BACK, -20); - - - if (S_ISDIR(file->type)) { - glColor4f(1.0f, 1.0f, 0.9f, 1.0f); - } - else if (file->flags & IMAGEFILE) { - UI_ThemeColor(TH_SEQ_IMAGE); - } - else if (file->flags & MOVIEFILE) { - UI_ThemeColor(TH_SEQ_MOVIE); - } - else if (file->flags & BLENDERFILE) { - UI_ThemeColor(TH_SEQ_SCENE); - } - else { - if (params->active_file == i) { - UI_ThemeColor(TH_GRID); /* grid used for active text */ - } else if (file->flags & ACTIVE) { - UI_ThemeColor(TH_TEXT_HI); - } else { - UI_ThemeColor(TH_TEXT); - } - } - - file_draw_string(sx + layout->prv_border_x, sy+4, file->relname, layout->tile_w, layout->tile_h, FILE_SHORTEN_END); - - if (!sfile->loadimage_timer) - sfile->loadimage_timer= WM_event_add_window_timer(CTX_wm_window(C), TIMER1, 1.0/30.0); /* max 30 frames/sec. */ - - } - - uiSetRoundBox(0); } static void renamebutton_cb(bContext *C, void *arg1, char *oldname) @@ -523,6 +438,39 @@ static void renamebutton_cb(bContext *C, void *arg1, char *oldname) } } + +static void draw_background(FileLayout *layout, View2D *v2d) +{ + int i; + short sy; + + /* alternating flat shade background */ + for (i=0; (i <= layout->rows); i+=2) + { + sy = v2d->cur.ymax - i*(layout->tile_h+2*layout->tile_border_y) - layout->tile_border_y; + + UI_ThemeColorShade(TH_BACK, -7); + glRectf(v2d->cur.xmin, sy, v2d->cur.xmax, sy+layout->tile_h+2*layout->tile_border_y); + + } +} + +static void draw_dividers(FileLayout *layout, View2D *v2d) +{ + short sx; + + /* vertical column dividers */ + sx = v2d->tot.xmin; + while (sx < v2d->cur.xmax) { + sx += (layout->tile_w+2*layout->tile_border_x); + + UI_ThemeColorShade(TH_BACK, 30); + sdrawline(sx+1, v2d->cur.ymax - layout->tile_border_y , sx+1, v2d->cur.ymin); + UI_ThemeColorShade(TH_BACK, -30); + sdrawline(sx, v2d->cur.ymax - layout->tile_border_y , sx, v2d->cur.ymin); + } +} + void file_draw_list(const bContext *C, ARegion *ar) { SpaceFile *sfile= CTX_wm_space_file(C); @@ -531,6 +479,7 @@ void file_draw_list(const bContext *C, ARegion *ar) View2D *v2d= &ar->v2d; struct FileList* files = sfile->files; struct direntry *file; + ImBuf *imb; int numfiles; int numfiles_layout; int colorid = 0; @@ -538,6 +487,7 @@ void file_draw_list(const bContext *C, ARegion *ar) int offset; int i; float sw, spos; + short is_icon; numfiles = filelist_numfiles(files); @@ -547,26 +497,11 @@ void file_draw_list(const bContext *C, ARegion *ar) offset = ED_fileselect_layout_offset(layout, 0, 0); if (offset<0) offset=0; - /* alternating flat shade background */ - for (i=0; (i <= layout->rows); i+=2) - { - sx = v2d->cur.xmin; - sy = v2d->cur.ymax - i*(layout->tile_h+2*layout->tile_border_y) - layout->tile_border_y; + if (params->display != FILE_IMGDISPLAY) { - UI_ThemeColorShade(TH_BACK, -7); - glRectf(v2d->cur.xmin, sy, v2d->cur.xmax, sy+layout->tile_h+2*layout->tile_border_y); - - } + draw_background(layout, v2d); - /* vertical column dividers */ - sx = v2d->tot.xmin; - while (sx < ar->v2d.cur.xmax) { - sx += (sfile->layout->tile_w+2*sfile->layout->tile_border_x); - - UI_ThemeColorShade(TH_BACK, 30); - sdrawline(sx+1, ar->v2d.cur.ymax - layout->tile_border_y , sx+1, ar->v2d.cur.ymin); - UI_ThemeColorShade(TH_BACK, -30); - sdrawline(sx, ar->v2d.cur.ymax - layout->tile_border_y , sx, ar->v2d.cur.ymin); + draw_dividers(layout, v2d); } sx = ar->v2d.cur.xmin + layout->tile_border_x; @@ -594,16 +529,33 @@ void file_draw_list(const bContext *C, ARegion *ar) } spos = sx; - file_draw_icon(spos, sy-3, get_file_icon(file), ICON_DEFAULT_WIDTH, ICON_DEFAULT_WIDTH); - spos += ICON_DEFAULT_WIDTH + 4; - + + if ( FILE_IMGDISPLAY == params->display ) { + if ( (file->flags & IMAGEFILE) /* || (file->flags & MOVIEFILE) */) { + filelist_loadimage(files, i); + } + is_icon = 0; + imb = filelist_getimage(files, i); + if (!imb) { + imb = filelist_geticon(files,i); + is_icon = 1; + } + + file_draw_preview(sx, sy, imb, layout, !is_icon && (file->flags & IMAGEFILE)); + + } else { + file_draw_icon(spos, sy-3, get_file_icon(file), ICON_DEFAULT_WIDTH, ICON_DEFAULT_WIDTH); + spos += ICON_DEFAULT_WIDTH + 4; + } + UI_ThemeColor4(TH_TEXT); - + sw = file_string_width(file->relname); if (file->flags & EDITING) { + short but_width = (FILE_IMGDISPLAY == params->display) ? layout->tile_w : layout->column_widths[COLUMN_NAME]; uiBlock *block = uiBeginBlock(C, ar, "FileName", UI_EMBOSS); uiBut *but = uiDefBut(block, TEX, 1, "", spos, sy-layout->tile_h-3, - layout->column_widths[COLUMN_NAME], layout->tile_h, file->relname, 1.0f, (float)FILE_MAX,0,0,""); + but_width, layout->textheight*2, file->relname, 1.0f, (float)FILE_MAX,0,0,""); uiButSetRenameFunc(but, renamebutton_cb, file); if ( 0 == uiButActiveOnly(C, block, but)) { file->flags &= ~EDITING; @@ -611,36 +563,42 @@ void file_draw_list(const bContext *C, ARegion *ar) uiEndBlock(C, block); uiDrawBlock(C, block); } else { - file_draw_string(spos, sy, file->relname, sw, layout->tile_h, FILE_SHORTEN_END); + float name_width = (FILE_IMGDISPLAY == params->display) ? layout->tile_w : sw; + file_draw_string(spos, sy, file->relname, name_width, layout->tile_h, FILE_SHORTEN_END); } - spos += layout->column_widths[COLUMN_NAME] + 12; - if (params->display == FILE_SHOWSHORT) { + + uiSetRoundBox(0); + + if (params->display == FILE_SHORTDISPLAY) { + spos += layout->column_widths[COLUMN_NAME] + 12; if (!(file->type & S_IFDIR)) { sw = file_string_width(file->size); spos += layout->column_widths[COLUMN_SIZE] + 12 - sw; file_draw_string(spos, sy, file->size, sw+1, layout->tile_h, FILE_SHORTEN_END); } - } else { -#if 0 // XXX TODO: add this for non-windows systems + } else if (params->display == FILE_LONGDISPLAY) { + spos += layout->column_widths[COLUMN_NAME] + 12; + +#ifndef WIN32 /* rwx rwx rwx */ spos += 20; - sw = UI_GetStringWidth(file->mode1); - file_draw_string(spos, sy, file->mode1, sw, layout->tile_h); - - spos += 30; - sw = UI_GetStringWidth(file->mode2); - file_draw_string(spos, sy, file->mode2, sw, layout->tile_h); + sw = file_string_width(file->mode1); + file_draw_string(spos, sy, file->mode1, sw, layout->tile_h, FILE_SHORTEN_END); + spos += layout->column_widths[COLUMN_MODE1] + 12; - spos += 30; - sw = UI_GetStringWidth(file->mode3); - file_draw_string(spos, sy, file->mode3, sw, layout->tile_h); - - spos += 30; - sw = UI_GetStringWidth(file->owner); - file_draw_string(spos, sy, file->owner, sw, layout->tile_h); + sw = file_string_width(file->mode2); + file_draw_string(spos, sy, file->mode2, sw, layout->tile_h, FILE_SHORTEN_END); + spos += layout->column_widths[COLUMN_MODE2] + 12; + + sw = file_string_width(file->mode3); + file_draw_string(spos, sy, file->mode3, sw, layout->tile_h, FILE_SHORTEN_END); + spos += layout->column_widths[COLUMN_MODE3] + 12; + + sw = file_string_width(file->owner); + file_draw_string(spos, sy, file->owner, sw, layout->tile_h, FILE_SHORTEN_END); + spos += layout->column_widths[COLUMN_OWNER] + 12; #endif - sw = file_string_width(file->date); file_draw_string(spos, sy, file->date, sw, layout->tile_h, FILE_SHORTEN_END); spos += layout->column_widths[COLUMN_DATE] + 12; @@ -656,6 +614,9 @@ void file_draw_list(const bContext *C, ARegion *ar) } } } + + if (!sfile->loadimage_timer) + sfile->loadimage_timer= WM_event_add_window_timer(CTX_wm_window(C), TIMER1, 1.0/30.0); /* max 30 frames/sec. */ } diff --git a/source/blender/editors/space_file/file_panels.c b/source/blender/editors/space_file/file_panels.c index f3c18859fb0..c48b3529389 100644 --- a/source/blender/editors/space_file/file_panels.c +++ b/source/blender/editors/space_file/file_panels.c @@ -170,23 +170,28 @@ static void file_panel_operator(const bContext *C, Panel *pa) wmOperator *op= sfile->op; int empty= 1; - RNA_STRUCT_BEGIN(op->ptr, prop) { - if(strcmp(RNA_property_identifier(prop), "rna_type") == 0) - continue; - if(strcmp(RNA_property_identifier(prop), "filename") == 0) - continue; - if(strcmp(RNA_property_identifier(prop), "display") == 0) - continue; - if(strncmp(RNA_property_identifier(prop), "filter", 6) == 0) - continue; - - uiItemFullR(pa->layout, NULL, 0, op->ptr, prop, -1, 0, 0, 0, 0); - empty= 0; + if(op->type->ui) { + op->type->ui((bContext*)C, op->ptr, pa->layout); } - RNA_STRUCT_END; + else { + RNA_STRUCT_BEGIN(op->ptr, prop) { + if(strcmp(RNA_property_identifier(prop), "rna_type") == 0) + continue; + if(strcmp(RNA_property_identifier(prop), "filename") == 0) + continue; + if(strcmp(RNA_property_identifier(prop), "display") == 0) + continue; + if(strncmp(RNA_property_identifier(prop), "filter", 6) == 0) + continue; + + uiItemFullR(pa->layout, NULL, 0, op->ptr, prop, -1, 0, 0); + empty= 0; + } + RNA_STRUCT_END; - if(empty) - uiItemL(pa->layout, "No properties.", 0); + if(empty) + uiItemL(pa->layout, "No properties.", 0); + } } void file_panels_register(ARegionType *art) diff --git a/source/blender/editors/space_file/filelist.c b/source/blender/editors/space_file/filelist.c index 7ebc8c4338f..538c1e4fce7 100644 --- a/source/blender/editors/space_file/filelist.c +++ b/source/blender/editors/space_file/filelist.c @@ -840,7 +840,16 @@ void filelist_setfiletypes(struct FileList* filelist, short has_quicktime) || BLI_testextensie(file->relname, ".mv")) { file->flags |= MOVIEFILE; } - else if(BLI_testextensie(file->relname, ".wav")) { + else if(BLI_testextensie(file->relname, ".wav") + || BLI_testextensie(file->relname, ".ogg") + || BLI_testextensie(file->relname, ".oga") + || BLI_testextensie(file->relname, ".mp3") + || BLI_testextensie(file->relname, ".mp2") + || BLI_testextensie(file->relname, ".ac3") + || BLI_testextensie(file->relname, ".aac") + || BLI_testextensie(file->relname, ".flac") + || BLI_testextensie(file->relname, ".wma") + || BLI_testextensie(file->relname, ".eac3")) { file->flags |= SOUNDFILE; } } else { // no quicktime @@ -875,7 +884,16 @@ void filelist_setfiletypes(struct FileList* filelist, short has_quicktime) || BLI_testextensie(file->relname, ".mv")) { file->flags |= MOVIEFILE; } - else if(BLI_testextensie(file->relname, ".wav")) { + else if(BLI_testextensie(file->relname, ".wav") + || BLI_testextensie(file->relname, ".ogg") + || BLI_testextensie(file->relname, ".oga") + || BLI_testextensie(file->relname, ".mp3") + || BLI_testextensie(file->relname, ".mp2") + || BLI_testextensie(file->relname, ".ac3") + || BLI_testextensie(file->relname, ".aac") + || BLI_testextensie(file->relname, ".flac") + || BLI_testextensie(file->relname, ".wma") + || BLI_testextensie(file->relname, ".eac3")) { file->flags |= SOUNDFILE; } } diff --git a/source/blender/editors/space_file/filesel.c b/source/blender/editors/space_file/filesel.c index 8ee7d3515b5..f300505933f 100644 --- a/source/blender/editors/space_file/filesel.c +++ b/source/blender/editors/space_file/filesel.c @@ -287,6 +287,7 @@ void ED_fileselect_init_layout(struct SpaceFile *sfile, struct ARegion *ar) numfiles = filelist_numfiles(sfile->files); textheight = file_font_pointsize(); layout = sfile->layout; + layout->textheight = textheight; if (params->display == FILE_IMGDISPLAY) { layout->prv_w = 96; diff --git a/source/blender/editors/space_file/space_file.c b/source/blender/editors/space_file/space_file.c index ea640eab090..22ad03f3523 100644 --- a/source/blender/editors/space_file/space_file.c +++ b/source/blender/editors/space_file/space_file.c @@ -310,12 +310,7 @@ static void file_main_area_draw(const bContext *C, ARegion *ar) file_hilight_set(sfile, ar, event->x, event->y); } - if (params->display == FILE_IMGDISPLAY) { - file_draw_previews(C, ar); - } else { - file_draw_list(C, ar); - } - + file_draw_list(C, ar); /* reset view matrix */ UI_view2d_view_restore(C); diff --git a/source/blender/editors/space_graph/graph_buttons.c b/source/blender/editors/space_graph/graph_buttons.c index 82babb70c53..fb995285ab7 100644 --- a/source/blender/editors/space_graph/graph_buttons.c +++ b/source/blender/editors/space_graph/graph_buttons.c @@ -160,7 +160,7 @@ static void graph_panel_properties(const bContext *C, Panel *pa) } getname_anim_fcurve(name, ale->id, fcu); - uiDefBut(block, LABEL, 1, name, 30, 180, 300, 19, NULL, 0.0, 0.0, 0, 0, "Name of Active F-Curve"); + uiDefBut(block, LABEL, 1, name, 40, 180, 300, 19, NULL, 0.0, 0.0, 0, 0, "Name of Active F-Curve"); /* TODO: the following settings could be added here * - F-Curve coloring mode - mode selector + color selector diff --git a/source/blender/editors/space_graph/graph_draw.c b/source/blender/editors/space_graph/graph_draw.c index f6915c4db01..f3aa0fac42b 100644 --- a/source/blender/editors/space_graph/graph_draw.c +++ b/source/blender/editors/space_graph/graph_draw.c @@ -877,19 +877,15 @@ void graph_draw_curves (bAnimContext *ac, SpaceIpo *sipo, ARegion *ar, View2DGri /* ************************************************************************* */ /* Channel List */ -// XXX quite a few of these need to be kept in sync with their counterparts in Action Editor -// as they're the same. We have 2 separate copies of this for now to make it easier to develop -// the diffences between the two editors, but one day these should be merged! - /* left hand part */ -void graph_draw_channel_names(bAnimContext *ac, SpaceIpo *sipo, ARegion *ar) +void graph_draw_channel_names(bContext *C, bAnimContext *ac, SpaceIpo *sipo, ARegion *ar) { ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; View2D *v2d= &ar->v2d; - float x= 0.0f, y= 0.0f, height; + float y= 0.0f, height; int items, i=0; /* build list of channels to draw */ @@ -903,537 +899,57 @@ void graph_draw_channel_names(bAnimContext *ac, SpaceIpo *sipo, ARegion *ar) * start of list offset, and the second is as a correction for the scrollers. */ height= (float)((items*ACHANNEL_STEP) + (ACHANNEL_HEIGHT*2)); - -#if 0 - if (height > (v2d->mask.ymax - v2d->mask.ymin)) { - /* don't use totrect set, as the width stays the same - * (NOTE: this is ok here, the configuration is pretty straightforward) - */ - v2d->tot.ymin= (float)(-height); - } - - /* XXX I would call the below line! (ton) */ -#endif UI_view2d_totRect_set(v2d, ar->winx, height); /* loop through channels, and set up drawing depending on their type */ - y= (float)ACHANNEL_FIRST; - - for (ale= anim_data.first, i=0; ale; ale= ale->next, i++) { - const float yminc= (float)(y - ACHANNEL_HEIGHT_HALF); - const float ymaxc= (float)(y + ACHANNEL_HEIGHT_HALF); + { /* first pass: just the standard GL-drawing for backdrop + text */ + y= (float)ACHANNEL_FIRST; - /* check if visible */ - if ( IN_RANGE(yminc, v2d->cur.ymin, v2d->cur.ymax) || - IN_RANGE(ymaxc, v2d->cur.ymin, v2d->cur.ymax) ) - { - bActionGroup *grp = NULL; - short indent= 0, offset= 0, sel= 0, group= 0; - int expand= -1, protect = -1, special= -1, mute = -1; - char name[128]; + for (ale= anim_data.first, i=0; ale; ale= ale->next, i++) { + const float yminc= (float)(y - ACHANNEL_HEIGHT_HALF); + const float ymaxc= (float)(y + ACHANNEL_HEIGHT_HALF); - /* determine what needs to be drawn */ - switch (ale->type) { - case ANIMTYPE_SCENE: /* scene */ - { - Scene *sce= (Scene *)ale->data; - - group= 4; - indent= 0; - - special= ICON_SCENE_DATA; - - /* only show expand if there are any channels */ - if (EXPANDED_SCEC(sce)) - expand= ICON_TRIA_DOWN; - else - expand= ICON_TRIA_RIGHT; - - sel = SEL_SCEC(sce); - strcpy(name, sce->id.name+2); - } - break; - case ANIMTYPE_OBJECT: /* object */ - { - Base *base= (Base *)ale->data; - Object *ob= base->object; - - group= 4; - indent= 0; - - /* icon depends on object-type */ - if (ob->type == OB_ARMATURE) - special= ICON_ARMATURE_DATA; - else - special= ICON_OBJECT_DATA; - - /* only show expand if there are any channels */ - if (EXPANDED_OBJC(ob)) - expand= ICON_TRIA_DOWN; - else - expand= ICON_TRIA_RIGHT; - - sel = SEL_OBJC(base); - strcpy(name, ob->id.name+2); - } - break; - case ANIMTYPE_FILLACTD: /* action widget */ - { - bAction *act= (bAction *)ale->data; - - group = 4; - indent= 1; - special= ICON_ACTION; - - if (EXPANDED_ACTC(act)) - expand= ICON_TRIA_DOWN; - else - expand= ICON_TRIA_RIGHT; - - sel = SEL_ACTC(act); - strcpy(name, act->id.name+2); - } - break; - case ANIMTYPE_FILLDRIVERS: /* drivers widget */ - { - AnimData *adt= (AnimData *)ale->data; - - group = 4; - indent= 1; - special= ICON_ANIM_DATA; - - if (EXPANDED_DRVD(adt)) - expand= ICON_TRIA_DOWN; - else - expand= ICON_TRIA_RIGHT; - - strcpy(name, "Drivers"); - } - break; - case ANIMTYPE_FILLMATD: /* object materials (dopesheet) expand widget */ - { - Object *ob = (Object *)ale->data; - - group = 4; - indent = 1; - special = ICON_MATERIAL_DATA; - - if (FILTER_MAT_OBJC(ob)) - expand = ICON_TRIA_DOWN; - else - expand = ICON_TRIA_RIGHT; - - strcpy(name, "Materials"); - } - break; - case ANIMTYPE_FILLPARTD: /* object particles (dopesheet) expand widget */ - { - Object *ob = (Object *)ale->data; - - group = 4; - indent = 1; - special = ICON_PARTICLE_DATA; - - if (FILTER_PART_OBJC(ob)) - expand = ICON_TRIA_DOWN; - else - expand = ICON_TRIA_RIGHT; - - strcpy(name, "Particles"); - } - break; - - - case ANIMTYPE_DSMAT: /* single material (dopesheet) expand widget */ - { - Material *ma = (Material *)ale->data; - - group = 0; - indent = 0; - special = ICON_MATERIAL_DATA; - offset = 21; - - if (FILTER_MAT_OBJD(ma)) - expand = ICON_TRIA_DOWN; - else - expand = ICON_TRIA_RIGHT; - - strcpy(name, ma->id.name+2); - } - break; - case ANIMTYPE_DSLAM: /* lamp (dopesheet) expand widget */ - { - Lamp *la = (Lamp *)ale->data; - - group = 4; - indent = 1; - special = ICON_LAMP_DATA; - - if (FILTER_LAM_OBJD(la)) - expand = ICON_TRIA_DOWN; - else - expand = ICON_TRIA_RIGHT; - - strcpy(name, la->id.name+2); - } - break; - case ANIMTYPE_DSCAM: /* camera (dopesheet) expand widget */ - { - Camera *ca = (Camera *)ale->data; - - group = 4; - indent = 1; - special = ICON_CAMERA_DATA; - - if (FILTER_CAM_OBJD(ca)) - expand = ICON_TRIA_DOWN; - else - expand = ICON_TRIA_RIGHT; - - strcpy(name, ca->id.name+2); - } - break; - case ANIMTYPE_DSCUR: /* curve (dopesheet) expand widget */ - { - Curve *cu = (Curve *)ale->data; - - group = 4; - indent = 1; - special = ICON_CURVE_DATA; - - if (FILTER_CUR_OBJD(cu)) - expand = ICON_TRIA_DOWN; - else - expand = ICON_TRIA_RIGHT; - - strcpy(name, cu->id.name+2); - } - break; - case ANIMTYPE_DSSKEY: /* shapekeys (dopesheet) expand widget */ - { - Key *key= (Key *)ale->data; - - group = 4; - indent = 1; - special = ICON_SHAPEKEY_DATA; - - if (FILTER_SKE_OBJD(key)) - expand = ICON_TRIA_DOWN; - else - expand = ICON_TRIA_RIGHT; - - //sel = SEL_OBJC(base); - strcpy(name, "Shape Keys"); - } - break; - case ANIMTYPE_DSWOR: /* world (dopesheet) expand widget */ - { - World *wo= (World *)ale->data; - - group = 4; - indent = 1; - special = ICON_WORLD_DATA; - - if (FILTER_WOR_SCED(wo)) - expand = ICON_TRIA_DOWN; - else - expand = ICON_TRIA_RIGHT; - - strcpy(name, wo->id.name+2); - } - break; - case ANIMTYPE_DSPART: /* particle (dopesheet) expand widget */ - { - ParticleSettings *part= (ParticleSettings*)ale->data; - - group = 0; - indent = 0; - special = ICON_PARTICLE_DATA; - offset = 21; - - if (FILTER_PART_OBJD(part)) - expand = ICON_TRIA_DOWN; - else - expand = ICON_TRIA_RIGHT; - - strcpy(name, part->id.name+2); - } - break; - case ANIMTYPE_DSMBALL: /* metaball (dopesheet) expand widget */ - { - MetaBall *mb = (MetaBall *)ale->data; - - group = 4; - indent = 1; - special = ICON_META_DATA; - - if (FILTER_MBALL_OBJD(mb)) - expand = ICON_TRIA_DOWN; - else - expand = ICON_TRIA_RIGHT; - - strcpy(name, mb->id.name+2); - } - break; - - - case ANIMTYPE_GROUP: /* action group */ - { - bActionGroup *agrp= (bActionGroup *)ale->data; - - group= 2; - indent= 0; - special= -1; - - if (ale->id) { - /* special exception for materials */ - if (GS(ale->id->name) == ID_MA) - offset= 25; - else - offset= 14; - } - else - offset= 0; - - /* only show expand if there are any channels */ - if (agrp->channels.first) { - if (EXPANDED_AGRP(agrp)) - expand = ICON_TRIA_DOWN; - else - expand = ICON_TRIA_RIGHT; - } - - /* for now, 'special' (i.e. in front of name) is used to show visibility status */ - if (agrp->flag & AGRP_NOTVISIBLE) - special= ICON_CHECKBOX_DEHLT; - else - special= ICON_CHECKBOX_HLT; - - if (agrp->flag & AGRP_MUTED) - mute = ICON_MUTE_IPO_ON; - else - mute = ICON_MUTE_IPO_OFF; - - if (EDITABLE_AGRP(agrp)) - protect = ICON_UNLOCKED; - else - protect = ICON_LOCKED; - - sel = SEL_AGRP(agrp); - strcpy(name, agrp->name); - } - break; - case ANIMTYPE_FCURVE: /* F-Curve channel */ - { - FCurve *fcu = (FCurve *)ale->data; - - indent = 0; - - group= (fcu->grp) ? 1 : 0; - grp= fcu->grp; - - if (ale->id) { - /* special exception for materials and particles */ - if (ELEM(GS(ale->id->name),ID_MA,ID_PA)) { - offset= 21; - indent= 1; - } - else - offset= 14; - } - else - offset= 0; - - /* for now, 'special' (i.e. in front of name) is used to show visibility status */ - if (fcu->flag & FCURVE_VISIBLE) - special= ICON_CHECKBOX_HLT; - else - special= ICON_CHECKBOX_DEHLT; - - if (fcu->flag & FCURVE_MUTED) - mute = ICON_MUTE_IPO_ON; - else - mute = ICON_MUTE_IPO_OFF; - - if (fcu->bezt) { - if (EDITABLE_FCU(fcu)) - protect = ICON_UNLOCKED; - else - protect = ICON_LOCKED; - } - else - protect = ICON_ZOOMOUT; // XXX editability is irrelevant here, but this icon is temp... - - sel = SEL_FCU(fcu); - - getname_anim_fcurve(name, ale->id, fcu); - } - break; - - case ANIMTYPE_SHAPEKEY: /* shapekey channel */ - { - KeyBlock *kb = (KeyBlock *)ale->data; - - indent = 0; - special = -1; - - offset= (ale->id) ? 21 : 0; - - if (kb->name[0] == '\0') - sprintf(name, "Key %d", ale->index); - else - strcpy(name, kb->name); - } - break; - } - - /* now, start drawing based on this information */ - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - glEnable(GL_BLEND); - - /* draw backing strip behind channel name */ - if (group == 4) { - /* only used in dopesheet... */ - if (ELEM(ale->type, ANIMTYPE_SCENE, ANIMTYPE_OBJECT)) { - /* object channel - darker */ - UI_ThemeColor(TH_DOPESHEET_CHANNELOB); - uiSetRoundBox((expand == ICON_TRIA_DOWN)? (1):(1|8)); - gl_round_box(GL_POLYGON, x+offset, yminc, (float)ACHANNEL_NAMEWIDTH, ymaxc, 8); - } - else { - /* sub-object folders - lighter */ - UI_ThemeColor(TH_DOPESHEET_CHANNELSUBOB); - - offset += 7 * indent; - glBegin(GL_QUADS); - glVertex2f(x+offset, yminc); - glVertex2f(x+offset, ymaxc); - glVertex2f((float)ACHANNEL_NAMEWIDTH, ymaxc); - glVertex2f((float)ACHANNEL_NAMEWIDTH, yminc); - glEnd(); - - /* clear group value, otherwise we cause errors... */ - group = 0; - } - } - else if (group == 3) { - /* only for gp-data channels */ - UI_ThemeColorShade(TH_GROUP, 20); - uiSetRoundBox((expand == ICON_TRIA_DOWN)? (1):(1|8)); - gl_round_box(GL_POLYGON, x+offset, yminc, (float)ACHANNEL_NAMEWIDTH, ymaxc, 8); - } - else if (group == 2) { - /* only for action group channels */ - if (ale->flag & AGRP_ACTIVE) - UI_ThemeColorShade(TH_GROUP_ACTIVE, 10); - else - UI_ThemeColorShade(TH_GROUP, 20); - uiSetRoundBox((expand == ICON_TRIA_DOWN)? (1):(1|8)); - gl_round_box(GL_POLYGON, x+offset, yminc, (float)ACHANNEL_NAMEWIDTH, ymaxc, 8); - } - else { - short shadefac= ((indent==0)?20: (indent==1)?-20: -40); - - indent += group; - offset += 7 * indent; - - /* draw channel backdrop */ - UI_ThemeColorShade(TH_HEADER, shadefac); - - glBegin(GL_QUADS); - glVertex2f(x+offset, yminc); - glVertex2f(x+offset, ymaxc); - glVertex2f((float)ACHANNEL_NAMEWIDTH, ymaxc); - glVertex2f((float)ACHANNEL_NAMEWIDTH, yminc); - glEnd(); - - /* most of the time, only F-Curves are going to be drawn here */ - if (ale->type == ANIMTYPE_FCURVE) { - /* F-Curve channels need to have a special 'color code' box drawn, which is colored with whatever - * color the curve has stored - */ - FCurve *fcu= (FCurve *)ale->data; - glColor3fv(fcu->color); - - // NOTE: only enable the following line for the fading-out gradient - //glShadeModel(GL_SMOOTH); - - glBegin(GL_QUADS); - /* solid color for the area around the checkbox */ - glVertex2f(x+offset, yminc); - glVertex2f(x+offset, ymaxc); - glVertex2f(x+offset+18, ymaxc); - glVertex2f(x+offset+18, yminc); - -#if 0 // fading out gradient - /* fading out gradient for the rest of the box */ - glVertex2f(x+offset+18, yminc); - glVertex2f(x+offset+18, ymaxc); - - UI_ThemeColorShade(TH_HEADER, shadefac); // XXX does this cause any problems on some cards? - - glVertex2f(x+offset+20, ymaxc); - glVertex2f(x+offset+20, yminc); -#endif // fading out gradient - glEnd(); - - // NOTE: only enable the following line for the fading-out gradient - //glShadeModel(GL_FLAT); - } + /* check if visible */ + if ( IN_RANGE(yminc, v2d->cur.ymin, v2d->cur.ymax) || + IN_RANGE(ymaxc, v2d->cur.ymin, v2d->cur.ymax) ) + { + /* draw all channels using standard channel-drawing API */ + ANIM_channel_draw(ac, ale, yminc, ymaxc); } - /* draw expand/collapse triangle */ - if (expand > 0) { - UI_icon_draw(x+offset, yminc, expand); - offset += 17; - } - - /* draw special icon indicating certain data-types */ - if (special > -1) { - if (ELEM(group, 3, 4)) { - /* for gpdatablock channels */ - UI_icon_draw(x+offset, yminc, special); - offset += 17; - } - else { - /* for normal channels */ - UI_icon_draw(x+offset, yminc, special); - offset += 17; - } - } - glDisable(GL_BLEND); - - /* draw name */ - if (sel) - UI_ThemeColor(TH_TEXT_HI); - else - UI_ThemeColor(TH_TEXT); - offset += 3; - UI_DrawString(x+offset, y-4, name); - - /* reset offset - for RHS of panel */ - offset = 0; - - /* set blending again, as text drawing may clear it */ - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - glEnable(GL_BLEND); + /* adjust y-position for next one */ + y -= ACHANNEL_STEP; + } + } + { /* second pass: widgets */ + uiBlock *block= uiBeginBlock(C, ar, "graph channel buttons", UI_EMBOSS); + + y= (float)ACHANNEL_FIRST; + + /* set blending again, as may not be set in previous step */ + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glEnable(GL_BLEND); + + for (ale= anim_data.first, i=0; ale; ale= ale->next, i++) { + const float yminc= (float)(y - ACHANNEL_HEIGHT_HALF); + const float ymaxc= (float)(y + ACHANNEL_HEIGHT_HALF); - /* draw protect 'lock' */ - if (protect > -1) { - offset = 16; - UI_icon_draw((float)ACHANNEL_NAMEWIDTH-offset, yminc, protect); + /* check if visible */ + if ( IN_RANGE(yminc, v2d->cur.ymin, v2d->cur.ymax) || + IN_RANGE(ymaxc, v2d->cur.ymin, v2d->cur.ymax) ) + { + /* draw all channels using standard channel-drawing API */ + ANIM_channel_draw_widgets(ac, ale, block, yminc, ymaxc); } - /* draw mute 'eye' */ - if (mute > -1) { - offset += 16; - UI_icon_draw((float)(ACHANNEL_NAMEWIDTH-offset), yminc, mute); - } - glDisable(GL_BLEND); + /* adjust y-position for next one */ + y -= ACHANNEL_STEP; } - /* adjust y-position for next one */ - y -= ACHANNEL_STEP; + uiEndBlock(C, block); + uiDrawBlock(C, block); + + glDisable(GL_BLEND); } /* free tempolary channels */ diff --git a/source/blender/editors/space_graph/graph_header.c b/source/blender/editors/space_graph/graph_header.c index 2c9017db649..06d48fe20f3 100644 --- a/source/blender/editors/space_graph/graph_header.c +++ b/source/blender/editors/space_graph/graph_header.c @@ -80,15 +80,17 @@ static void graph_viewmenu(bContext *C, uiLayout *layout, void *arg_unused) uiItemS(layout); - uiItemR(layout, NULL, 0, &spaceptr, "show_cframe_indicator", 0, 0, 0); + uiItemR(layout, NULL, 0, &spaceptr, "show_cframe_indicator", 0); + uiItemR(layout, NULL, 0, &spaceptr, "show_sliders", 0); + uiItemR(layout, NULL, 0, &spaceptr, "automerge_keyframes", 0); if (sipo->flag & SIPO_NOHANDLES) uiItemO(layout, "Show Handles", ICON_CHECKBOX_DEHLT, "GRAPH_OT_handles_view_toggle"); else uiItemO(layout, "Show Handles", ICON_CHECKBOX_HLT, "GRAPH_OT_handles_view_toggle"); - uiItemR(layout, NULL, 0, &spaceptr, "only_selected_curves_handles", 0, 0, 0); - uiItemR(layout, NULL, 0, &spaceptr, "automerge_keyframes", 0, 0, 0); + uiItemR(layout, NULL, 0, &spaceptr, "only_selected_curves_handles", 0); + if (sipo->flag & SIPO_DRAWTIME) uiItemO(layout, "Show Frames", 0, "ANIM_OT_time_toggle"); @@ -201,9 +203,9 @@ static void graph_edit_expomenu(bContext *C, uiLayout *layout, void *arg_unused) static void graph_editmenu(bContext *C, uiLayout *layout, void *arg_unused) { - uiItemMenuF(layout, "Transform", 0, graph_edit_transformmenu); - uiItemMenuF(layout, "Snap", 0, graph_edit_snapmenu); - uiItemMenuF(layout, "Mirror", 0, graph_edit_mirrormenu); + uiItemMenuF(layout, "Transform", 0, graph_edit_transformmenu, NULL); + uiItemMenuF(layout, "Snap", 0, graph_edit_snapmenu, NULL); + uiItemMenuF(layout, "Mirror", 0, graph_edit_mirrormenu, NULL); uiItemS(layout); @@ -217,9 +219,9 @@ static void graph_editmenu(bContext *C, uiLayout *layout, void *arg_unused) uiItemS(layout); - uiItemMenuF(layout, "Handle Type", 0, graph_edit_handlesmenu); - uiItemMenuF(layout, "Interpolation Mode", 0, graph_edit_ipomenu); - uiItemMenuF(layout, "Extrapolation Mode", 0, graph_edit_expomenu); + uiItemMenuF(layout, "Handle Type", 0, graph_edit_handlesmenu, NULL); + uiItemMenuF(layout, "Interpolation Mode", 0, graph_edit_ipomenu, NULL); + uiItemMenuF(layout, "Extrapolation Mode", 0, graph_edit_expomenu, NULL); uiItemS(layout); diff --git a/source/blender/editors/space_graph/graph_intern.h b/source/blender/editors/space_graph/graph_intern.h index 31f1c6d4301..2e8d0655d2d 100644 --- a/source/blender/editors/space_graph/graph_intern.h +++ b/source/blender/editors/space_graph/graph_intern.h @@ -48,7 +48,7 @@ struct ARegion *graph_has_buttons_region(struct ScrArea *sa); /* ***************************************** */ /* graph_draw.c */ -void graph_draw_channel_names(struct bAnimContext *ac, struct SpaceIpo *sipo, struct ARegion *ar); +void graph_draw_channel_names(struct bContext *C, struct bAnimContext *ac, struct SpaceIpo *sipo, struct ARegion *ar); void graph_draw_curves(struct bAnimContext *ac, struct SpaceIpo *sipo, struct ARegion *ar, struct View2DGrid *grid, short sel); void graph_draw_ghost_curves(struct bAnimContext *ac, struct SpaceIpo *sipo, struct ARegion *ar, struct View2DGrid *grid); diff --git a/source/blender/editors/space_graph/space_graph.c b/source/blender/editors/space_graph/space_graph.c index 0390586951b..3717ccc8244 100644 --- a/source/blender/editors/space_graph/space_graph.c +++ b/source/blender/editors/space_graph/space_graph.c @@ -309,7 +309,7 @@ static void graph_channel_area_draw(const bContext *C, ARegion *ar) /* draw channels */ if (ANIM_animdata_get_context(C, &ac)) { - graph_draw_channel_names(&ac, sipo, ar); + graph_draw_channel_names((bContext*)C, &ac, sipo, ar); } /* reset view matrix */ diff --git a/source/blender/editors/space_image/Makefile b/source/blender/editors/space_image/Makefile index 5a69cb7fc65..a55b4e58dfa 100644 --- a/source/blender/editors/space_image/Makefile +++ b/source/blender/editors/space_image/Makefile @@ -54,3 +54,7 @@ CPPFLAGS += -I$(NAN_GUARDEDALLOC)/include CPPFLAGS += -I../include +ifeq ($(WITH_OPENEXR), true) + CPPFLAGS += -DWITH_OPENEXR +endif + diff --git a/source/blender/editors/space_image/SConscript b/source/blender/editors/space_image/SConscript index 5fa2509bf5f..2b1d5589cb3 100644 --- a/source/blender/editors/space_image/SConscript +++ b/source/blender/editors/space_image/SConscript @@ -11,5 +11,7 @@ defs = [] if env['WITH_BF_LCMS']: defs.append('WITH_LCMS') +if env['WITH_BF_OPENEXR']: + defs.append('WITH_OPENEXR') env.BlenderLib ( 'bf_editors_space_image', sources, Split(incs), defs, libtype=['core'], priority=[40] ) diff --git a/source/blender/editors/space_image/image_buttons.c b/source/blender/editors/space_image/image_buttons.c index 4dcaa96caf7..ac0a5c7f53a 100644 --- a/source/blender/editors/space_image/image_buttons.c +++ b/source/blender/editors/space_image/image_buttons.c @@ -58,6 +58,7 @@ #include "BKE_mesh.h" #include "BKE_node.h" #include "BKE_packedFile.h" +#include "BKE_paint.h" #include "BKE_screen.h" #include "BKE_utildefines.h" @@ -450,7 +451,7 @@ void brush_buttons(const bContext *C, uiBlock *block, short fromsima, { // SpaceImage *sima= CTX_wm_space_image(C); ToolSettings *settings= CTX_data_tool_settings(C); - Brush *brush= settings->imapaint.brush; + Brush *brush= paint_brush(&settings->imapaint.paint); ID *id; int yco, xco, butw, but_idx; // short *menupoin = &(sima->menunr); // XXX : &(G.buts->menunr); @@ -472,7 +473,7 @@ void brush_buttons(const bContext *C, uiBlock *block, short fromsima, uiBlockEndAlign(block); yco -= 30; - id= (ID*)settings->imapaint.brush; + id= (ID*)brush; xco= 200; // std_libbuttons(block, 0, yco, 0, NULL, evt_browse, ID_BR, 0, id, NULL, menupoin, 0, evt_local, evt_del, 0, evt_keepdata); if(brush && !brush->id.lib) { @@ -574,7 +575,7 @@ static void image_panel_paintcolor(const bContext *C, Panel *pa) { SpaceImage *sima= CTX_wm_space_image(C); ToolSettings *settings= CTX_data_tool_settings(C); - Brush *brush= settings->imapaint.brush; + Brush *brush= paint_brush(&settings->imapaint.paint); uiBlock *block; static float hsv[3], old[3]; // used as temp mem for picker static char hexcol[128]; @@ -1318,7 +1319,7 @@ void ED_image_uiblock_panel(const bContext *C, uiBlock *block, Image **ima_pp, I } /* exception, let's do because we only use this panel 3 times in blender... but not real good code! */ - if( (FACESEL_PAINT_TEST) && sima && &sima->iuser==iuser) + if( (paint_facesel_test(CTX_data_active_object(C))) && sima && &sima->iuser==iuser) return; /* left side default per-image options, right half the additional options */ diff --git a/source/blender/editors/space_image/image_draw.c b/source/blender/editors/space_image/image_draw.c index ff25a2635d2..2f5fc805367 100644 --- a/source/blender/editors/space_image/image_draw.c +++ b/source/blender/editors/space_image/image_draw.c @@ -47,6 +47,7 @@ #include "BKE_colortools.h" #include "BKE_global.h" #include "BKE_image.h" +#include "BKE_paint.h" #include "BKE_utildefines.h" #include "BIF_gl.h" @@ -577,7 +578,7 @@ static void draw_image_view_tool(Scene *scene) static unsigned char *get_alpha_clone_image(Scene *scene, int *width, int *height) { - Brush *brush = scene->toolsettings->imapaint.brush; + Brush *brush = paint_brush(&scene->toolsettings->imapaint.paint); ImBuf *ibuf; unsigned int size, alpha; unsigned char *rect, *cp; @@ -615,7 +616,7 @@ static void draw_image_paint_helpers(SpaceImage *sima, ARegion *ar, Scene *scene int x, y, w, h; unsigned char *clonerect; - brush= scene->toolsettings->imapaint.brush; + brush= paint_brush(&scene->toolsettings->imapaint.paint); if(brush && (scene->toolsettings->imapaint.tool == PAINT_TOOL_CLONE)) { /* this is not very efficient, but glDrawPixels doesn't allow diff --git a/source/blender/editors/space_info/info_intern.h b/source/blender/editors/space_info/info_intern.h index 519364b58d9..070b627af07 100644 --- a/source/blender/editors/space_info/info_intern.h +++ b/source/blender/editors/space_info/info_intern.h @@ -32,9 +32,6 @@ struct wmOperatorType; -/* info_header.c */ -void info_header_buttons(const bContext *C, ARegion *ar); - void FILE_OT_pack_all(struct wmOperatorType *ot); void FILE_OT_unpack_all(struct wmOperatorType *ot); void FILE_OT_make_paths_relative(struct wmOperatorType *ot); diff --git a/source/blender/editors/space_info/info_stats.c b/source/blender/editors/space_info/info_stats.c new file mode 100644 index 00000000000..2d14fbc515e --- /dev/null +++ b/source/blender/editors/space_info/info_stats.c @@ -0,0 +1,434 @@ +/** + * $Id$ + * + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * Contributor(s): Blender Foundation + * + * ***** END GPL LICENSE BLOCK ***** + */ + +#include <stdio.h> +#include <string.h> + +#include "MEM_guardedalloc.h" + +#include "DNA_action_types.h" +#include "DNA_armature_types.h" +#include "DNA_curve_types.h" +#include "DNA_group_types.h" +#include "DNA_lattice_types.h" +#include "DNA_mesh_types.h" +#include "DNA_meta_types.h" +#include "DNA_object_types.h" +#include "DNA_particle_types.h" +#include "DNA_scene_types.h" + +#include "BKE_anim.h" +#include "BKE_context.h" +#include "BKE_displist.h" +#include "BKE_DerivedMesh.h" +#include "BKE_key.h" +#include "BKE_mesh.h" +#include "BKE_particle.h" +#include "BKE_utildefines.h" + +#include "ED_armature.h" +#include "ED_mesh.h" + +#include "BLI_editVert.h" + +typedef struct SceneStats { + int totvert, totvertsel; + int totedge, totedgesel; + int totface, totfacesel; + int totbone, totbonesel; + int totobj, totobjsel; + int totmesh, totlamp, totcurve; + + char infostr[512]; +} SceneStats; + +static void stats_object(Object *ob, int sel, int totob, SceneStats *stats) +{ + switch(ob->type) { + case OB_MESH: { + /* we assume derivedmesh is already built, this strictly does stats now. */ + DerivedMesh *dm= ob->derivedFinal; + int totvert, totedge, totface; + + stats->totmesh +=totob; + + if(dm) { + totvert = dm->getNumVerts(dm); + totedge = dm->getNumEdges(dm); + totface = dm->getNumFaces(dm); + + stats->totvert += totvert*totob; + stats->totedge += totedge*totob; + stats->totface += totface*totob; + + if(sel) { + stats->totvertsel += totvert; + stats->totfacesel += totface; + } + } + break; + } + case OB_LAMP: + stats->totlamp += totob; + break; + case OB_SURF: + case OB_CURVE: + case OB_FONT: { + Curve *cu= ob->data; + int tot= 0, totf= 0; + + stats->totcurve += totob; + + if(cu->disp.first) + count_displist(&cu->disp, &tot, &totf); + + tot *= totob; + totf *= totob; + + stats->totvert+= tot; + stats->totface+= totf; + + if(sel) { + stats->totvertsel += tot; + stats->totfacesel += totf; + } + break; + } + case OB_MBALL: { + int tot= 0, totf= 0; + + count_displist(&ob->disp, &tot, &totf); + + tot *= totob; + totf *= totob; + + stats->totvert += tot; + stats->totface += totf; + + if(sel) { + stats->totvertsel += tot; + stats->totfacesel += totf; + } + break; + } + } +} + +static void stats_object_edit(Object *obedit, SceneStats *stats) +{ + if(obedit->type==OB_MESH) { + /* Mesh Edit */ + EditMesh *em= BKE_mesh_get_editmesh(obedit->data); + EditVert *eve; + EditEdge *eed; + EditFace *efa; + + for(eve= em->verts.first; eve; eve=eve->next) { + stats->totvert++; + if(eve->f & SELECT) stats->totvertsel++; + } + for(eed= em->edges.first; eed; eed=eed->next) { + stats->totedge++; + if(eed->f & SELECT) stats->totedgesel++; + } + for(efa= em->faces.first; efa; efa=efa->next) { + stats->totface++; + if(efa->f & SELECT) stats->totfacesel++; + } + + EM_validate_selections(em); + } + else if(obedit->type==OB_ARMATURE){ + /* Armature Edit */ + bArmature *arm= obedit->data; + EditBone *ebo; + + for(ebo=arm->edbo->first; ebo; ebo=ebo->next){ + stats->totbone++; + + if((ebo->flag & BONE_CONNECTED) && ebo->parent) + stats->totvert--; + + if(ebo->flag & BONE_TIPSEL) + stats->totvertsel++; + if(ebo->flag & BONE_ROOTSEL) + stats->totvertsel++; + + if(ebo->flag & BONE_SELECTED) stats->totbonesel++; + + /* if this is a connected child and it's parent is being moved, remove our root */ + if((ebo->flag & BONE_CONNECTED)&& (ebo->flag & BONE_ROOTSEL) && ebo->parent && (ebo->parent->flag & BONE_TIPSEL)) + stats->totvertsel--; + + stats->totvert+=2; + } + } + else if ELEM3(obedit->type, OB_CURVE, OB_SURF, OB_FONT) { + /* Curve Edit */ + Curve *cu= obedit->data; + Nurb *nu; + BezTriple *bezt; + BPoint *bp; + int a; + + for(nu=cu->editnurb->first; nu; nu=nu->next) { + if((nu->type & 7)==CU_BEZIER) { + bezt= nu->bezt; + a= nu->pntsu; + while(a--) { + stats->totvert+=3; + if(bezt->f1) stats->totvertsel++; + if(bezt->f2) stats->totvertsel++; + if(bezt->f3) stats->totvertsel++; + bezt++; + } + } + else { + bp= nu->bp; + a= nu->pntsu*nu->pntsv; + while(a--) { + stats->totvert++; + if(bp->f1 & SELECT) stats->totvertsel++; + bp++; + } + } + } + } + else if(obedit->type==OB_MBALL) { + /* MetaBall Edit */ + MetaBall *mball= obedit->data; + MetaElem *ml; + + for(ml= mball->editelems->first; ml; ml=ml->next) { + stats->totvert++; + if(ml->flag & SELECT) stats->totvertsel++; + } + } + else if(obedit->type==OB_LATTICE) { + /* Lattice Edit */ + Lattice *lt= obedit->data; + Lattice *editlatt= lt->editlatt; + BPoint *bp; + int a; + + bp= editlatt->def; + + a= editlatt->pntsu*editlatt->pntsv*editlatt->pntsw; + while(a--) { + stats->totvert++; + if(bp->f1 & SELECT) stats->totvertsel++; + bp++; + } + } +} + +static void stats_object_pose(Object *ob, SceneStats *stats) +{ + if(ob->pose) { + bArmature *arm= ob->data; + bPoseChannel *pchan; + + for(pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) { + stats->totbone++; + if(pchan->bone && (pchan->bone->flag & BONE_SELECTED)) + if(pchan->bone->layer & arm->layer) + stats->totbonesel++; + } + } +} + +static void stats_object_paint(Object *ob, SceneStats *stats) +{ + if(ob->type == OB_MESH) { + Mesh *me= ob->data; + + stats->totface= me->totface; + stats->totvert= me->totvert; + } +} + +static void stats_dupli_object(Base *base, Object *ob, SceneStats *stats) +{ + if(base->flag & SELECT) stats->totobjsel++; + + if(ob->transflag & OB_DUPLIPARTS) { + /* Dupli Particles */ + ParticleSystem *psys; + ParticleSettings *part; + + for(psys=ob->particlesystem.first; psys; psys=psys->next){ + part=psys->part; + + if(part->draw_as==PART_DRAW_OB && part->dup_ob){ + int tot=count_particles(psys); + stats_object(part->dup_ob, 0, tot, stats); + } + else if(part->draw_as==PART_DRAW_GR && part->dup_group){ + GroupObject *go; + int tot, totgroup=0, cur=0; + + for(go= part->dup_group->gobject.first; go; go=go->next) + totgroup++; + + for(go= part->dup_group->gobject.first; go; go=go->next) { + tot=count_particles_mod(psys,totgroup,cur); + stats_object(go->ob, 0, tot, stats); + cur++; + } + } + } + + stats_object(ob, base->flag & SELECT, 1, stats); + stats->totobj++; + } + else if(ob->parent && (ob->parent->transflag & (OB_DUPLIVERTS|OB_DUPLIFACES))) { + /* Dupli Verts/Faces */ + int tot= count_duplilist(ob->parent); + stats->totobj+=tot; + stats_object(ob, base->flag & SELECT, tot, stats); + } + else if(ob->transflag & OB_DUPLIFRAMES) { + /* Dupli Frames */ + int tot= count_duplilist(ob); + stats->totobj+=tot; + stats_object(ob, base->flag & SELECT, tot, stats); + } + else if((ob->transflag & OB_DUPLIGROUP) && ob->dup_group) { + /* Dupli Group */ + int tot= count_duplilist(ob); + stats->totobj+=tot; + stats_object(ob, base->flag & SELECT, tot, stats); + } + else { + /* No Dupli */ + stats_object(ob, base->flag & SELECT, 1, stats); + stats->totobj++; + } +} + +/* Statistics displayed in info header. Called regularly on scene changes. */ +static void stats_update(Scene *scene) +{ + SceneStats stats; + Object *ob= (scene->basact)? scene->basact->object: NULL; + Base *base; + + memset(&stats, 0, sizeof(stats)); + + if(scene->obedit) { + /* Edit Mode */ + stats_object_edit(scene->obedit, &stats); + } + else if(ob && (ob->mode & OB_MODE_POSE)) { + /* Pose Mode */ + stats_object_pose(ob, &stats); + } + else if(ob && (ob->flag & (OB_MODE_SCULPT|OB_MODE_VERTEX_PAINT|OB_MODE_WEIGHT_PAINT|OB_MODE_TEXTURE_PAINT))) { + /* Sculpt and Paint Mode */ + stats_object_paint(ob, &stats); + } + else { + /* Objects */ + for(base= scene->base.first; base; base=base->next) + if(scene->lay & base->lay) + stats_dupli_object(base, base->object, &stats); + } + + if(!scene->stats) + scene->stats= MEM_mallocN(sizeof(SceneStats), "SceneStats"); + + *(scene->stats)= stats; +} + +static void stats_string(Scene *scene) +{ + SceneStats *stats= scene->stats; + Object *ob= (scene->basact)? scene->basact->object: NULL; + uintptr_t mem_in_use, mmap_in_use; + char memstr[64]; + char *s; + + mem_in_use= MEM_get_memory_in_use(); + mmap_in_use= MEM_get_mapped_memory_in_use(); + + /* get memory statistics */ + s= memstr + sprintf(memstr, " | Mem:%.2fM", ((mem_in_use-mmap_in_use)>>10)/1024.0); + if(mmap_in_use) + sprintf(s, " (%.2fM)", ((mmap_in_use)>>10)/1024.0); + + s= stats->infostr; + + if(scene->obedit) { + if(ob_get_keyblock(scene->obedit)) + s+= sprintf(s, "(Key) "); + + if(scene->obedit->type==OB_MESH) { + if(scene->toolsettings->selectmode & SCE_SELECT_VERTEX) + s+= sprintf(s, "Ve:%d-%d | Ed:%d-%d | Fa:%d-%d", + stats->totvertsel, stats->totvert, stats->totedgesel, stats->totedge, stats->totfacesel, stats->totface); + else if(scene->toolsettings->selectmode & SCE_SELECT_EDGE) + s+= sprintf(s, "Ed:%d-%d | Fa:%d-%d", + stats->totedgesel, stats->totedge, stats->totfacesel, stats->totface); + else + s+= sprintf(s, "Fa:%d-%d", stats->totfacesel, stats->totface); + } + else if(scene->obedit->type==OB_ARMATURE) { + s+= sprintf(s, "Ve:%d-%d | Bo:%d-%d", stats->totvertsel, stats->totvert, stats->totbonesel, stats->totbone); + } + else { + s+= sprintf(s, "Ve:%d-%d", stats->totvertsel, stats->totvert); + } + + strcat(s, memstr); + } + else if(ob && (ob->mode & OB_MODE_POSE)) { + s += sprintf(s, "Bo:%d-%d %s", + stats->totbonesel, stats->totbone, memstr); + } + else { + s += sprintf(s, "Ve:%d | Fa:%d | Ob:%d-%d | La:%d%s", + stats->totvert, stats->totface, stats->totobj, stats->totobjsel, stats->totlamp, memstr); + } + + if(ob) + sprintf(s, " | %s", ob->id.name+2); +} + +void ED_info_stats_clear(Scene *scene) +{ + if(scene->stats) { + MEM_freeN(scene->stats); + scene->stats= NULL; + } +} + +char *ED_info_stats_string(Scene *scene) +{ + if(!scene->stats) + stats_update(scene); + stats_string(scene); + + return scene->stats->infostr; +} + diff --git a/source/blender/editors/space_info/space_info.c b/source/blender/editors/space_info/space_info.c index fe5bbf04af1..b6f9cbeabb5 100644 --- a/source/blender/editors/space_info/space_info.c +++ b/source/blender/editors/space_info/space_info.c @@ -1,5 +1,5 @@ /** - * $Id: + * $Id$ * * ***** BEGIN GPL LICENSE BLOCK ***** * @@ -58,6 +58,7 @@ #include "UI_view2d.h" #include "ED_markers.h" +#include "ED_object.h" #include "info_intern.h" // own include @@ -166,6 +167,9 @@ static void info_header_listener(ARegion *ar, wmNotifier *wmn) if(wmn->data==ND_RENDER_RESULT) ED_region_tag_redraw(ar); break; + case NC_INFO: + ED_region_tag_redraw(ar); + break; } } diff --git a/source/blender/editors/space_logic/logic_window.c b/source/blender/editors/space_logic/logic_window.c index 274f5f47e43..06bd95f060f 100644 --- a/source/blender/editors/space_logic/logic_window.c +++ b/source/blender/editors/space_logic/logic_window.c @@ -708,8 +708,6 @@ static char *actuator_name(int type) return "Material"; case ACT_SOUND: return "Sound"; - case ACT_CD: - return "CD"; case ACT_PROPERTY: return "Property"; case ACT_EDIT_OBJECT: @@ -748,21 +746,21 @@ static char *actuator_pup(Object *owner) case OB_ARMATURE: return "Actuators %t|Action %x15|Motion %x0|Constraint %x9|Ipo %x1" "|Camera %x3|Sound %x5|Property %x6|Edit Object %x10" - "|Scene %x11|Random %x13|Message %x14|CD %x16|Game %x17" + "|Scene %x11|Random %x13|Message %x14|Game %x17" "|Visibility %x18|2D Filter %x19|Parent %x20|State %x22"; break; case OB_MESH: return "Actuators %t|Shape Action %x21|Motion %x0|Constraint %x9|Ipo %x1" "|Camera %x3|Sound %x5|Property %x6|Edit Object %x10" - "|Scene %x11|Random %x13|Message %x14|CD %x16|Game %x17" + "|Scene %x11|Random %x13|Message %x14|Game %x17" "|Visibility %x18|2D Filter %x19|Parent %x20|State %x22"; break; default: return "Actuators %t|Motion %x0|Constraint %x9|Ipo %x1" "|Camera %x3|Sound %x5|Property %x6|Edit Object %x10" - "|Scene %x11|Random %x13|Message %x14|CD %x16|Game %x17" + "|Scene %x11|Random %x13|Message %x14|Game %x17" "|Visibility %x18|2D Filter %x19|Parent %x20|State %x22"; } } @@ -1316,10 +1314,16 @@ static short draw_sensorbuttons(bSensor *sens, uiBlock *block, short xco, short * proper compatibility with older .blend files. */ str= "Type %t|Left button %x1|Middle button %x2|" "Right button %x4|Wheel Up %x5|Wheel Down %x6|Movement %x8|Mouse over %x16|Mouse over any%x32"; - uiDefButS(block, MENU, B_REDR, str, xco+10, yco-44, width-20, 19, + uiDefButS(block, MENU, B_REDR, str, xco+10, yco-44, (width*0.8f)-20, 19, &ms->type, 0, 31, 0, 0, "Specify the type of event this mouse sensor should trigger on"); + if(ms->type==32) { + uiDefButBitS(block, TOG, SENS_MOUSE_FOCUS_PULSE, B_REDR, "Pulse",(short)(xco + 10) + (width*0.8f)-20,(short)(yco - 44), + (short)(0.20 * (width-20)), 19, &ms->flag, 0.0, 0.0, 0, 0, + "Moving the mouse over a different object generates a pulse"); + } + yco-= ysize; break; } @@ -1581,7 +1585,6 @@ static int get_col_actuator(int type) case ACT_IPO: return TH_PANEL; case ACT_PROPERTY: return TH_PANEL; case ACT_SOUND: return TH_PANEL; - case ACT_CD: return TH_PANEL; case ACT_CAMERA: return TH_PANEL; case ACT_EDIT_OBJECT: return TH_PANEL; case ACT_GROUP: return TH_PANEL; @@ -1674,7 +1677,6 @@ static void check_state_mask(bContext *C, void *arg1_but, void *arg2_mask) static short draw_actuatorbuttons(Object *ob, bActuator *act, uiBlock *block, short xco, short yco, short width) { bSoundActuator *sa = NULL; - bCDActuator *cda = NULL; bObjectActuator *oa = NULL; bIpoActuator *ia = NULL; bPropertyActuator *pa = NULL; @@ -1984,11 +1986,14 @@ static short draw_actuatorbuttons(Object *ob, bActuator *act, uiBlock *block, sh } case ACT_SOUND: { - ysize = 70; - sa = act->data; sa->sndnr = 0; + if(sa->flag & ACT_SND_3D_SOUND) + ysize = 114; + else + ysize = 92; + wval = (width-20)/2; glRects(xco, yco-ysize, xco+width, yco); uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); @@ -2003,8 +2008,14 @@ static short draw_actuatorbuttons(Object *ob, bActuator *act, uiBlock *block, sh char dummy_str[] = "Sound mode %t|Play Stop %x0|Play End %x1|Loop Stop %x2|Loop End %x3|Loop Ping Pong Stop %x5|Loop Ping Pong %x4"; uiDefBut(block, TEX, B_IDNAME, "SO:",xco+30,yco-22,width-40,19, sa->sound->id.name+2, 0.0, 21.0, 0, 0, ""); uiDefButS(block, MENU, 1, dummy_str,xco+10,yco-44,width-20, 19, &sa->type, 0.0, 0.0, 0, 0, ""); - uiDefButF(block, NUM, 0, "Volume:", xco+10,yco-66,wval, 19, &sa->sound->volume, 0.0, 1.0, 0, 0, "Sets the volume of this sound"); - uiDefButF(block, NUM, 0, "Pitch:",xco+wval+10,yco-66,wval, 19, &sa->sound->pitch,-12.0, 12.0, 0, 0, "Sets the pitch of this sound"); + uiDefButF(block, NUM, 0, "Volume:", xco+10,yco-66,wval, 19, &sa->volume, 0.0, 1.0, 0, 0, "Sets the volume of this sound"); + uiDefButF(block, NUM, 0, "Pitch:",xco+wval+10,yco-66,wval, 19, &sa->pitch,-12.0, 12.0, 0, 0, "Sets the pitch of this sound"); + uiDefButS(block, TOG | BIT, 0, "3D Sound", xco+10, yco-88, width-20, 19, &sa->flag, 0.0, 1.0, 0.0, 0.0, "Plays the sound positioned in 3D space."); + if(sa->flag & ACT_SND_3D_SOUND) + { + uiDefButF(block, NUM, 0, "Rolloff: ", xco+10, yco-110, wval, 19, &sa->sound3D.rolloff_factor, 0.0, 5.0, 0.0, 0.0, "The rolloff factor defines the influence factor on volume depending on distance."); + uiDefButF(block, NUM, 0, "Reference distance: ", xco+wval+10, yco-110, wval, 19, &sa->sound3D.reference_distance, 0.0, 1000.0, 0.0, 0.0, "The reference distance is the distance where the sound has a gain of 1.0."); + } } MEM_freeN(str); } @@ -2016,41 +2027,6 @@ static short draw_actuatorbuttons(Object *ob, bActuator *act, uiBlock *block, sh break; } - case ACT_CD: - { - char cd_type_str[] = "Sound mode %t|Play all tracks %x0|Play one track %x1|" - "Volume %x3|Stop %x4|Pause %x5|Resume %x6"; - cda = act->data; - - if (cda) { - if (cda->track == 0) { - cda->track = 1; - cda->volume = 1; - cda->type = ACT_CD_PLAY_ALL; - } - - if (cda->type == ACT_CD_PLAY_TRACK || cda->type == ACT_CD_LOOP_TRACK) { - ysize = 48; - glRects(xco, yco-ysize, xco+width, yco); - uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); - uiDefButS(block, NUM, 0, "Track:", xco+10,yco-44,width-20, 19, &cda->track, 1, 99, 0, 0, "Select the track to be played"); - } - else if (cda->type == ACT_CD_VOLUME) { - ysize = 48; - glRects(xco, yco-ysize, xco+width, yco); - uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); - uiDefButF(block, NUM, 0, "Volume:", xco+10,yco-44,width-20, 19, &cda->volume, 0, 1, 0, 0, "Set the volume for CD playback"); - } - else { - ysize = 28; - glRects(xco, yco-ysize, xco+width, yco); - uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); - } - uiDefButS(block, MENU, B_REDR, cd_type_str,xco+10,yco-22,width-20, 19, &cda->type, 0.0, 0.0, 0, 0, ""); - } - yco-= ysize; - break; - } case ACT_CAMERA: ysize= 48; diff --git a/source/blender/editors/space_nla/nla_buttons.c b/source/blender/editors/space_nla/nla_buttons.c index 7184737e0ba..2ffca5185f2 100644 --- a/source/blender/editors/space_nla/nla_buttons.c +++ b/source/blender/editors/space_nla/nla_buttons.c @@ -210,19 +210,19 @@ static void nla_panel_animdata (const bContext *C, Panel *pa) /* Active Action Properties ------------------------------------- */ /* action */ row= uiLayoutRow(layout, 1); - uiItemR(row, NULL, 0, &adt_ptr, "action", 0, 0, 0); + uiItemR(row, NULL, 0, &adt_ptr, "action", 0); /* extrapolation */ row= uiLayoutRow(layout, 1); - uiItemR(row, NULL, 0, &adt_ptr, "action_extrapolation", 0, 0, 0); + uiItemR(row, NULL, 0, &adt_ptr, "action_extrapolation", 0); /* blending */ row= uiLayoutRow(layout, 1); - uiItemR(row, NULL, 0, &adt_ptr, "action_blending", 0, 0, 0); + uiItemR(row, NULL, 0, &adt_ptr, "action_blending", 0); /* influence */ row= uiLayoutRow(layout, 1); - uiItemR(row, NULL, 0, &adt_ptr, "action_influence", 0, 0, 0); + uiItemR(row, NULL, 0, &adt_ptr, "action_influence", 0); } /* active NLA-Track */ @@ -242,7 +242,7 @@ static void nla_panel_track (const bContext *C, Panel *pa) /* Info - Active NLA-Context:Track ---------------------- */ row= uiLayoutRow(layout, 1); - uiItemR(row, NULL, ICON_NLA, &nlt_ptr, "name", 0, 0, 0); + uiItemR(row, NULL, ICON_NLA, &nlt_ptr, "name", 0); } /* generic settings for active NLA-Strip */ @@ -262,41 +262,41 @@ static void nla_panel_properties(const bContext *C, Panel *pa) /* Strip Properties ------------------------------------- */ /* strip type */ row= uiLayoutColumn(layout, 1); - uiItemR(row, NULL, ICON_NLA, &strip_ptr, "name", 0, 0, 0); // XXX icon? - uiItemR(row, NULL, 0, &strip_ptr, "type", 0, 0, 0); + uiItemR(row, NULL, ICON_NLA, &strip_ptr, "name", 0); // XXX icon? + uiItemR(row, NULL, 0, &strip_ptr, "type", 0); /* strip extents */ column= uiLayoutColumn(layout, 1); uiItemL(column, "Strip Extents:", 0); - uiItemR(column, NULL, 0, &strip_ptr, "start_frame", 0, 0, 0); - uiItemR(column, NULL, 0, &strip_ptr, "end_frame", 0, 0, 0); + uiItemR(column, NULL, 0, &strip_ptr, "start_frame", 0); + uiItemR(column, NULL, 0, &strip_ptr, "end_frame", 0); /* extrapolation */ row= uiLayoutRow(layout, 1); - uiItemR(row, NULL, 0, &strip_ptr, "extrapolation", 0, 0, 0); + uiItemR(row, NULL, 0, &strip_ptr, "extrapolation", 0); /* blending */ row= uiLayoutRow(layout, 1); - uiItemR(row, NULL, 0, &strip_ptr, "blending", 0, 0, 0); + uiItemR(row, NULL, 0, &strip_ptr, "blending", 0); /* blend in/out + autoblending * - blend in/out can only be set when autoblending is off */ column= uiLayoutColumn(layout, 1); uiLayoutSetActive(column, RNA_boolean_get(&strip_ptr, "animated_influence")==0); - uiItemR(column, NULL, 0, &strip_ptr, "auto_blending", 0, 0, 0); // XXX as toggle? + uiItemR(column, NULL, 0, &strip_ptr, "auto_blending", 0); // XXX as toggle? subcol= uiLayoutColumn(column, 1); uiLayoutSetActive(subcol, RNA_boolean_get(&strip_ptr, "auto_blending")==0); - uiItemR(subcol, NULL, 0, &strip_ptr, "blend_in", 0, 0, 0); - uiItemR(subcol, NULL, 0, &strip_ptr, "blend_out", 0, 0, 0); + uiItemR(subcol, NULL, 0, &strip_ptr, "blend_in", 0); + uiItemR(subcol, NULL, 0, &strip_ptr, "blend_out", 0); /* settings */ column= uiLayoutColumn(layout, 1); uiLayoutSetActive(column, !(RNA_boolean_get(&strip_ptr, "animated_influence") || RNA_boolean_get(&strip_ptr, "animated_time"))); uiItemL(column, "Playback Settings:", 0); - uiItemR(column, NULL, 0, &strip_ptr, "muted", 0, 0, 0); - uiItemR(column, NULL, 0, &strip_ptr, "reversed", 0, 0, 0); + uiItemR(column, NULL, 0, &strip_ptr, "muted", 0); + uiItemR(column, NULL, 0, &strip_ptr, "reversed", 0); } @@ -318,21 +318,21 @@ static void nla_panel_actclip(const bContext *C, Panel *pa) /* Strip Properties ------------------------------------- */ /* action pointer */ row= uiLayoutRow(layout, 1); - uiItemR(row, NULL, ICON_ACTION, &strip_ptr, "action", 0, 0, 0); + uiItemR(row, NULL, ICON_ACTION, &strip_ptr, "action", 0); /* action extents */ // XXX custom names were used here (to avoid the prefixes)... probably not necessary in future? column= uiLayoutColumn(layout, 1); uiItemL(column, "Action Extents:", 0); - uiItemR(column, "Start Frame", 0, &strip_ptr, "action_start_frame", 0, 0, 0); - uiItemR(column, "End Frame", 0, &strip_ptr, "action_end_frame", 0, 0, 0); + uiItemR(column, "Start Frame", 0, &strip_ptr, "action_start_frame", 0); + uiItemR(column, "End Frame", 0, &strip_ptr, "action_end_frame", 0); /* action usage */ column= uiLayoutColumn(layout, 1); uiLayoutSetActive(column, RNA_boolean_get(&strip_ptr, "animated_time")==0); uiItemL(column, "Playback Settings:", 0); - uiItemR(column, NULL, 0, &strip_ptr, "scale", 0, 0, 0); - uiItemR(column, NULL, 0, &strip_ptr, "repeat", 0, 0, 0); + uiItemR(column, NULL, 0, &strip_ptr, "scale", 0); + uiItemR(column, NULL, 0, &strip_ptr, "repeat", 0); } /* evaluation settings for active NLA-Strip */ @@ -351,19 +351,19 @@ static void nla_panel_evaluation(const bContext *C, Panel *pa) uiBlockSetHandleFunc(block, do_nla_region_buttons, NULL); column= uiLayoutColumn(layout, 1); - uiItemR(column, NULL, 0, &strip_ptr, "animated_influence", 0, 0, 0); + uiItemR(column, NULL, 0, &strip_ptr, "animated_influence", 0); subcolumn= uiLayoutColumn(column, 1); uiLayoutSetEnabled(subcolumn, RNA_boolean_get(&strip_ptr, "animated_influence")); - uiItemR(subcolumn, NULL, 0, &strip_ptr, "influence", 0, 0, 0); + uiItemR(subcolumn, NULL, 0, &strip_ptr, "influence", 0); column= uiLayoutColumn(layout, 1); - uiItemR(column, NULL, 0, &strip_ptr, "animated_time", 0, 0, 0); + uiItemR(column, NULL, 0, &strip_ptr, "animated_time", 0); subcolumn= uiLayoutColumn(column, 1); uiLayoutSetEnabled(subcolumn, RNA_boolean_get(&strip_ptr, "animated_time")); - uiItemR(subcolumn, NULL, 0, &strip_ptr, "strip_time", 0, 0, 0); + uiItemR(subcolumn, NULL, 0, &strip_ptr, "strip_time", 0); } /* F-Modifiers for active NLA-Strip */ diff --git a/source/blender/editors/space_nla/nla_channels.c b/source/blender/editors/space_nla/nla_channels.c index ab918519ec0..ccf23266427 100644 --- a/source/blender/editors/space_nla/nla_channels.c +++ b/source/blender/editors/space_nla/nla_channels.c @@ -89,6 +89,7 @@ * part of the channel is relevant. * * NOTE: eventually, this should probably be phased out when many of these things are replaced with buttons + * --> Most channels are now selection only... */ static int mouse_nla_channels (bAnimContext *ac, float x, int channel_index, short selectmode) @@ -96,6 +97,7 @@ static int mouse_nla_channels (bAnimContext *ac, float x, int channel_index, sho ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; + View2D *v2d= &ac->ar->v2d; int notifierFlags = 0; /* get the channel that was clicked on */ @@ -118,32 +120,17 @@ static int mouse_nla_channels (bAnimContext *ac, float x, int channel_index, sho case ANIMTYPE_SCENE: { Scene *sce= (Scene *)ale->data; - AnimData *adt= ale->data; - if (x < 16) { - /* toggle expand */ - sce->flag ^= SCE_DS_COLLAPSED; - - notifierFlags |= ND_ANIMCHAN_EDIT; - } - else if ( (adt) && (x >= (NLACHANNEL_NAMEWIDTH-NLACHANNEL_BUTTON_WIDTH)) ) { - /* toggle mute */ - adt->flag ^= ADT_NLA_EVAL_OFF; - - notifierFlags |= ND_ANIMCHAN_EDIT; + /* set selection status */ + if (selectmode == SELECT_INVERT) { + /* swap select */ + sce->flag ^= SCE_DS_SELECTED; } else { - /* set selection status */ - if (selectmode == SELECT_INVERT) { - /* swap select */ - sce->flag ^= SCE_DS_SELECTED; - } - else { - sce->flag |= SCE_DS_SELECTED; - } - - notifierFlags |= ND_ANIMCHAN_SELECT; + sce->flag |= SCE_DS_SELECTED; } + + notifierFlags |= ND_ANIMCHAN_SELECT; } break; case ANIMTYPE_OBJECT: @@ -152,20 +139,8 @@ static int mouse_nla_channels (bAnimContext *ac, float x, int channel_index, sho Scene *sce= (Scene *)ads->source; Base *base= (Base *)ale->data; Object *ob= base->object; - AnimData *adt= ale->adt; - if (x < 16) { - /* toggle expand */ - ob->nlaflag ^= OB_ADS_COLLAPSED; // XXX - notifierFlags |= ND_ANIMCHAN_EDIT; - } - else if ( (adt) && (x >= (NLACHANNEL_NAMEWIDTH-NLACHANNEL_BUTTON_WIDTH)) ) { - /* toggle mute */ - adt->flag ^= ADT_NLA_EVAL_OFF; - - notifierFlags |= ND_ANIMCHAN_EDIT; - } - else if (nlaedit_is_tweakmode_on(ac) == 0) { + if (nlaedit_is_tweakmode_on(ac) == 0) { /* set selection status */ if (selectmode == SELECT_INVERT) { /* swap select */ @@ -194,149 +169,6 @@ static int mouse_nla_channels (bAnimContext *ac, float x, int channel_index, sho } } break; - case ANIMTYPE_FILLMATD: - { - Object *ob= (Object *)ale->data; - ob->nlaflag ^= OB_ADS_SHOWMATS; // XXX - notifierFlags |= ND_ANIMCHAN_EDIT; - } - break; - case ANIMTYPE_FILLPARTD: - { - Object *ob= (Object *)ale->data; - ob->nlaflag ^= OB_ADS_SHOWPARTS; // XXX - notifierFlags |= ND_ANIMCHAN_EDIT; - } - break; - - case ANIMTYPE_DSMAT: - { - Material *ma= (Material *)ale->data; - AnimData *adt= ale->adt; - - if ( (adt) && (x >= (NLACHANNEL_NAMEWIDTH-NLACHANNEL_BUTTON_WIDTH)) ) { - /* toggle mute */ - adt->flag ^= ADT_NLA_EVAL_OFF; - } - else { - /* toggle expand */ - ma->flag ^= MA_DS_EXPAND; - } - notifierFlags |= ND_ANIMCHAN_EDIT; - } - break; - case ANIMTYPE_DSLAM: - { - Lamp *la= (Lamp *)ale->data; - AnimData *adt= ale->adt; - - if ( (adt) && (x >= (NLACHANNEL_NAMEWIDTH-NLACHANNEL_BUTTON_WIDTH)) ) { - /* toggle mute */ - adt->flag ^= ADT_NLA_EVAL_OFF; - } - else { - /* toggle expand */ - la->flag ^= LA_DS_EXPAND; - } - notifierFlags |= ND_ANIMCHAN_EDIT; - } - break; - case ANIMTYPE_DSCAM: - { - Camera *ca= (Camera *)ale->data; - AnimData *adt= ale->adt; - - if ( (adt) && (x >= (NLACHANNEL_NAMEWIDTH-NLACHANNEL_BUTTON_WIDTH)) ) { - /* toggle mute */ - adt->flag ^= ADT_NLA_EVAL_OFF; - } - else { - /* toggle expand */ - ca->flag ^= CAM_DS_EXPAND; - } - notifierFlags |= ND_ANIMCHAN_EDIT; - } - break; - case ANIMTYPE_DSCUR: - { - Curve *cu= (Curve *)ale->data; - AnimData *adt= ale->adt; - - if ( (adt) && (x >= (NLACHANNEL_NAMEWIDTH-NLACHANNEL_BUTTON_WIDTH)) ) { - /* toggle mute */ - adt->flag ^= ADT_NLA_EVAL_OFF; - } - else { - /* toggle expand */ - cu->flag ^= CU_DS_EXPAND; - } - notifierFlags |= ND_ANIMCHAN_EDIT; - } - break; - case ANIMTYPE_DSSKEY: - { - Key *key= (Key *)ale->data; - AnimData *adt= ale->adt; - - if ( (adt) && (x >= (NLACHANNEL_NAMEWIDTH-NLACHANNEL_BUTTON_WIDTH)) ) { - /* toggle mute */ - adt->flag ^= ADT_NLA_EVAL_OFF; - } - else { - /* toggle expand */ - key->flag ^= KEYBLOCK_DS_EXPAND; - } - notifierFlags |= ND_ANIMCHAN_EDIT; - } - break; - case ANIMTYPE_DSWOR: - { - World *wo= (World *)ale->data; - AnimData *adt= ale->adt; - - if ( (adt) && (x >= (NLACHANNEL_NAMEWIDTH-NLACHANNEL_BUTTON_WIDTH)) ) { - /* toggle mute */ - adt->flag ^= ADT_NLA_EVAL_OFF; - } - else { - /* toggle expand */ - wo->flag ^= WO_DS_EXPAND; - } - notifierFlags |= ND_ANIMCHAN_EDIT; - } - break; - case ANIMTYPE_DSPART: - { - ParticleSettings *part= (ParticleSettings *)ale->data; - AnimData *adt= ale->adt; - - if ( (adt) && (x >= (NLACHANNEL_NAMEWIDTH-NLACHANNEL_BUTTON_WIDTH)) ) { - /* toggle mute */ - adt->flag ^= ADT_NLA_EVAL_OFF; - } - else { - /* toggle expand */ - part->flag ^= PART_DS_EXPAND; - } - notifierFlags |= ND_ANIMCHAN_EDIT; - } - break; - case ANIMTYPE_DSMBALL: - { - MetaBall *mb= (MetaBall *)ale->data; - AnimData *adt= ale->adt; - - if ( (adt) && (x >= (NLACHANNEL_NAMEWIDTH-NLACHANNEL_BUTTON_WIDTH)) ) { - /* toggle mute */ - adt->flag ^= ADT_NLA_EVAL_OFF; - } - else { - /* toggle expand */ - mb->flag2 ^= MB_DS_EXPAND; - } - notifierFlags |= ND_ANIMCHAN_EDIT; - } - break; case ANIMTYPE_NLATRACK: { @@ -355,14 +187,14 @@ static int mouse_nla_channels (bAnimContext *ac, float x, int channel_index, sho else offset= 0; - if (x >= (NLACHANNEL_NAMEWIDTH-NLACHANNEL_BUTTON_WIDTH)) { + if (x >= (v2d->cur.xmax-NLACHANNEL_BUTTON_WIDTH)) { /* toggle protection (only if there's a toggle there) */ nlt->flag ^= NLATRACK_PROTECTED; /* notifier flags - channel was edited */ notifierFlags |= ND_ANIMCHAN_EDIT; } - else if (x >= (NLACHANNEL_NAMEWIDTH-2*NLACHANNEL_BUTTON_WIDTH)) { + else if (x >= (v2d->cur.xmax-2*NLACHANNEL_BUTTON_WIDTH)) { /* toggle mute */ nlt->flag ^= NLATRACK_MUTED; @@ -401,7 +233,7 @@ static int mouse_nla_channels (bAnimContext *ac, float x, int channel_index, sho { AnimData *adt= BKE_animdata_from_id(ale->owner); /* this won't crash, right? */ - if (x >= (NLACHANNEL_NAMEWIDTH-NLACHANNEL_BUTTON_WIDTH)) { + if (x >= (v2d->cur.xmax-NLACHANNEL_BUTTON_WIDTH)) { if (nlaedit_is_tweakmode_on(ac) == 0) { /* 'push-down' action - only usable when not in TweakMode */ // TODO: make this use the operator instead of calling the function directly diff --git a/source/blender/editors/space_nla/nla_draw.c b/source/blender/editors/space_nla/nla_draw.c index a7a854a7277..f30954292b4 100644 --- a/source/blender/editors/space_nla/nla_draw.c +++ b/source/blender/editors/space_nla/nla_draw.c @@ -411,7 +411,7 @@ static void nla_draw_strip (SpaceNla *snla, AnimData *adt, NlaTrack *nlt, NlaStr /* don't draw if line would end up on or after the end of the strip */ if (repeatPos < strip->end) - fdrawline(repeatPos, yminc, repeatPos, ymaxc); + fdrawline(repeatPos, yminc+4, repeatPos, ymaxc-4); } } /* or if meta-strip, draw lines delimiting extents of sub-strips (in same color as outline, if more than 1 exists) */ @@ -592,36 +592,15 @@ void draw_nla_main_data (bAnimContext *ac, SpaceNla *snla, ARegion *ar) /* *********************************************** */ /* Channel List */ -void draw_nla_channel_list (bAnimContext *ac, SpaceNla *snla, ARegion *ar) +/* old code for drawing NLA channels using GL only */ +// TODO: depreceate this code... +static void draw_nla_channel_list_gl (bAnimContext *ac, ListBase *anim_data, View2D *v2d, float y) { - ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; - int filter; - - View2D *v2d= &ar->v2d; - float x= 0.0f, y= 0.0f; - int items, height; - - /* build list of channels to draw */ - filter= (ANIMFILTER_VISIBLE|ANIMFILTER_CHANNELS); - items= ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); - - /* Update max-extent of channels here (taking into account scrollers): - * - this is done to allow the channel list to be scrollable, but must be done here - * to avoid regenerating the list again and/or also because channels list is drawn first - * - offset of NLACHANNEL_HEIGHT*2 is added to the height of the channels, as first is for - * start of list offset, and the second is as a correction for the scrollers. - */ - height= ((items*NLACHANNEL_STEP) + (NLACHANNEL_HEIGHT*2)); - /* don't use totrect set, as the width stays the same - * (NOTE: this is ok here, the configuration is pretty straightforward) - */ - v2d->tot.ymin= (float)(-height); + float x = 0.0f; /* loop through channels, and set up drawing depending on their type */ - y= (float)(-NLACHANNEL_HEIGHT); - - for (ale= anim_data.first; ale; ale= ale->next) { + for (ale= anim_data->first; ale; ale= ale->next) { const float yminc= (float)(y - NLACHANNEL_HEIGHT_HALF); const float ymaxc= (float)(y + NLACHANNEL_HEIGHT_HALF); const float ydatac= (float)(y - 7); @@ -633,308 +612,10 @@ void draw_nla_channel_list (bAnimContext *ac, SpaceNla *snla, ARegion *ar) short indent= 0, offset= 0, sel= 0, group= 0; int expand= -1, protect = -1, special= -1, mute = -1; char name[128]; + short doDraw=0; /* determine what needs to be drawn */ switch (ale->type) { - case ANIMTYPE_SCENE: /* scene */ - { - Scene *sce= (Scene *)ale->data; - AnimData *adt= ale->adt; - - group= 4; - indent= 0; - - special= ICON_SCENE_DATA; - - /* only show expand if there are any channels */ - if (EXPANDED_SCEC(sce)) - expand= ICON_TRIA_DOWN; - else - expand= ICON_TRIA_RIGHT; - - /* NLA evaluation on/off button */ - if (adt) { - if (adt->flag & ADT_NLA_EVAL_OFF) - mute = ICON_MUTE_IPO_ON; - else - mute = ICON_MUTE_IPO_OFF; - } - - sel = SEL_SCEC(sce); - strcpy(name, sce->id.name+2); - } - break; - case ANIMTYPE_OBJECT: /* object */ - { - Base *base= (Base *)ale->data; - Object *ob= base->object; - AnimData *adt= ale->adt; - - group= 4; - indent= 0; - - /* icon depends on object-type */ - if (ob->type == OB_ARMATURE) - special= ICON_ARMATURE_DATA; - else - special= ICON_OBJECT_DATA; - - /* only show expand if there are any channels */ - if (EXPANDED_OBJC(ob)) - expand= ICON_TRIA_DOWN; - else - expand= ICON_TRIA_RIGHT; - - /* NLA evaluation on/off button */ - if (adt) { - if (adt->flag & ADT_NLA_EVAL_OFF) - mute = ICON_MUTE_IPO_ON; - else - mute = ICON_MUTE_IPO_OFF; - } - - sel = SEL_OBJC(base); - strcpy(name, ob->id.name+2); - } - break; - case ANIMTYPE_FILLMATD: /* object materials (dopesheet) expand widget */ - { - Object *ob = (Object *)ale->data; - - group = 4; - indent = 1; - special = ICON_MATERIAL_DATA; - - if (FILTER_MAT_OBJC(ob)) - expand = ICON_TRIA_DOWN; - else - expand = ICON_TRIA_RIGHT; - - strcpy(name, "Materials"); - } - break; - case ANIMTYPE_FILLPARTD: /* object particles (dopesheet) expand widget */ - { - Object *ob = (Object *)ale->data; - - group = 4; - indent = 1; - special = ICON_PARTICLE_DATA; - - if (FILTER_PART_OBJC(ob)) - expand = ICON_TRIA_DOWN; - else - expand = ICON_TRIA_RIGHT; - - strcpy(name, "Particles"); - } - break; - - - case ANIMTYPE_DSMAT: /* single material (dopesheet) expand widget */ - { - Material *ma = (Material *)ale->data; - AnimData *adt= ale->adt; - - group = 0; - indent = 0; - special = ICON_MATERIAL_DATA; - offset = 21; - - if (FILTER_MAT_OBJD(ma)) - expand = ICON_TRIA_DOWN; - else - expand = ICON_TRIA_RIGHT; - - /* NLA evaluation on/off button */ - if (adt) { - if (adt->flag & ADT_NLA_EVAL_OFF) - mute = ICON_MUTE_IPO_ON; - else - mute = ICON_MUTE_IPO_OFF; - } - - strcpy(name, ma->id.name+2); - } - break; - case ANIMTYPE_DSLAM: /* lamp (dopesheet) expand widget */ - { - Lamp *la = (Lamp *)ale->data; - AnimData *adt= ale->adt; - - group = 4; - indent = 1; - special = ICON_LAMP_DATA; - - if (FILTER_LAM_OBJD(la)) - expand = ICON_TRIA_DOWN; - else - expand = ICON_TRIA_RIGHT; - - /* NLA evaluation on/off button */ - if (adt) { - if (adt->flag & ADT_NLA_EVAL_OFF) - mute = ICON_MUTE_IPO_ON; - else - mute = ICON_MUTE_IPO_OFF; - } - - strcpy(name, la->id.name+2); - } - break; - case ANIMTYPE_DSCAM: /* camera (dopesheet) expand widget */ - { - Camera *ca = (Camera *)ale->data; - AnimData *adt= ale->adt; - - group = 4; - indent = 1; - special = ICON_CAMERA_DATA; - - if (FILTER_CAM_OBJD(ca)) - expand = ICON_TRIA_DOWN; - else - expand = ICON_TRIA_RIGHT; - - /* NLA evaluation on/off button */ - if (adt) { - if (adt->flag & ADT_NLA_EVAL_OFF) - mute = ICON_MUTE_IPO_ON; - else - mute = ICON_MUTE_IPO_OFF; - } - - strcpy(name, ca->id.name+2); - } - break; - case ANIMTYPE_DSCUR: /* curve (dopesheet) expand widget */ - { - Curve *cu = (Curve *)ale->data; - AnimData *adt= ale->adt; - - group = 4; - indent = 1; - special = ICON_CURVE_DATA; - - if (FILTER_CUR_OBJD(cu)) - expand = ICON_TRIA_DOWN; - else - expand = ICON_TRIA_RIGHT; - - /* NLA evaluation on/off button */ - if (adt) { - if (adt->flag & ADT_NLA_EVAL_OFF) - mute = ICON_MUTE_IPO_ON; - else - mute = ICON_MUTE_IPO_OFF; - } - - strcpy(name, cu->id.name+2); - } - break; - case ANIMTYPE_DSSKEY: /* shapekeys (dopesheet) expand widget */ - { - Key *key= (Key *)ale->data; - AnimData *adt= ale->adt; - - group = 4; - indent = 1; - special = ICON_SHAPEKEY_DATA; - - if (FILTER_SKE_OBJD(key)) - expand = ICON_TRIA_DOWN; - else - expand = ICON_TRIA_RIGHT; - - /* NLA evaluation on/off button */ - if (adt) { - if (adt->flag & ADT_NLA_EVAL_OFF) - mute = ICON_MUTE_IPO_ON; - else - mute = ICON_MUTE_IPO_OFF; - } - - //sel = SEL_OBJC(base); - strcpy(name, "Shape Keys"); - } - break; - case ANIMTYPE_DSWOR: /* world (dopesheet) expand widget */ - { - World *wo= (World *)ale->data; - AnimData *adt= ale->adt; - - group = 4; - indent = 1; - special = ICON_WORLD_DATA; - - if (FILTER_WOR_SCED(wo)) - expand = ICON_TRIA_DOWN; - else - expand = ICON_TRIA_RIGHT; - - /* NLA evaluation on/off button */ - if (adt) { - if (adt->flag & ADT_NLA_EVAL_OFF) - mute = ICON_MUTE_IPO_ON; - else - mute = ICON_MUTE_IPO_OFF; - } - - strcpy(name, wo->id.name+2); - } - break; - case ANIMTYPE_DSPART: /* particle (dopesheet) expand widget */ - { - ParticleSettings *part= (ParticleSettings*)ale->data; - AnimData *adt= ale->adt; - - group = 0; - indent = 0; - special = ICON_PARTICLE_DATA; - offset = 21; - - if (FILTER_PART_OBJD(part)) - expand = ICON_TRIA_DOWN; - else - expand = ICON_TRIA_RIGHT; - - /* NLA evaluation on/off button */ - if (adt) { - if (adt->flag & ADT_NLA_EVAL_OFF) - mute = ICON_MUTE_IPO_ON; - else - mute = ICON_MUTE_IPO_OFF; - } - - strcpy(name, part->id.name+2); - } - break; - case ANIMTYPE_DSMBALL: /* metaball (dopesheet) expand widget */ - { - MetaBall *mb = (MetaBall *)ale->data; - AnimData *adt= ale->adt; - - group = 4; - indent = 1; - special = ICON_META_DATA; - - if (FILTER_MBALL_OBJD(mb)) - expand = ICON_TRIA_DOWN; - else - expand = ICON_TRIA_RIGHT; - - /* NLA evaluation on/off button */ - if (adt) { - if (adt->flag & ADT_NLA_EVAL_OFF) - mute = ICON_MUTE_IPO_ON; - else - mute = ICON_MUTE_IPO_OFF; - } - - strcpy(name, mb->id.name+2); - } - break; - case ANIMTYPE_NLATRACK: /* NLA Track */ { NlaTrack *nlt= (NlaTrack *)ale->data; @@ -978,6 +659,9 @@ void draw_nla_channel_list (bAnimContext *ac, SpaceNla *snla, ARegion *ar) sel = SEL_NLT(nlt); strcpy(name, nlt->name); + + // draw manually still + doDraw= 1; } break; case ANIMTYPE_NLAACTION: /* NLA Action-Line */ @@ -1004,167 +688,219 @@ void draw_nla_channel_list (bAnimContext *ac, SpaceNla *snla, ARegion *ar) sprintf(name, "ActAction: <%s>", act->id.name+2); else sprintf(name, "<No Action>"); + + // draw manually still + doDraw= 1; } break; + + default: /* handled by standard channel-drawing API */ + // draw backdrops only... + ANIM_channel_draw(ac, ale, yminc, ymaxc); + break; } - /* now, start drawing based on this information */ - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - glEnable(GL_BLEND); - - /* draw backing strip behind channel name */ - if (group == 4) { - /* only used in dopesheet... */ - if (ELEM(ale->type, ANIMTYPE_SCENE, ANIMTYPE_OBJECT)) { - /* object channel - darker */ - UI_ThemeColor(TH_DOPESHEET_CHANNELOB); - uiSetRoundBox((expand == ICON_TRIA_DOWN)? (8):(1|8)); - gl_round_box(GL_POLYGON, x+offset, yminc, (float)NLACHANNEL_NAMEWIDTH, ymaxc, 10); + /* if special types, draw manually for now... */ + if (doDraw) { + /* now, start drawing based on this information */ + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glEnable(GL_BLEND); + + /* draw backing strip behind channel name */ + if (group == 5) { + /* Action Line */ + AnimData *adt= ale->adt; + + // TODO: if tweaking some action, use the same color as for the tweaked track (quick hack done for now) + if (adt && (adt->flag & ADT_NLA_EDIT_ON)) { + // greenish color (same as tweaking strip) - hardcoded for now + glColor3f(0.3f, 0.95f, 0.1f); + } + else { + if (ale->data) + glColor3f(0.8f, 0.2f, 0.0f); // reddish color - hardcoded for now + else + glColor3f(0.6f, 0.5f, 0.5f); // greyish-red color - hardcoded for now + } + + offset += 7 * indent; + + /* only on top two corners, to show that this channel sits on top of the preceeding ones */ + uiSetRoundBox((1|2)); + + /* draw slightly shifted up vertically to look like it has more separtion from other channels, + * but we then need to slightly shorten it so that it doesn't look like it overlaps + */ + gl_round_box(GL_POLYGON, x+offset, yminc+NLACHANNEL_SKIP, (float)v2d->cur.xmax, ymaxc+NLACHANNEL_SKIP-1, 8); + + /* clear group value, otherwise we cause errors... */ + group = 0; } else { - /* sub-object folders - lighter */ - UI_ThemeColor(TH_DOPESHEET_CHANNELSUBOB); + /* for normal channels + * - use 3 shades of color group/standard color for 3 indention level + */ + UI_ThemeColorShade(TH_HEADER, ((indent==0)?20: (indent==1)?-20: -40)); + indent += group; offset += 7 * indent; glBegin(GL_QUADS); glVertex2f(x+offset, yminc); glVertex2f(x+offset, ymaxc); - glVertex2f((float)ACHANNEL_NAMEWIDTH, ymaxc); - glVertex2f((float)ACHANNEL_NAMEWIDTH, yminc); + glVertex2f((float)v2d->cur.xmax, ymaxc); + glVertex2f((float)v2d->cur.xmax, yminc); glEnd(); - - /* clear group value, otherwise we cause errors... */ - group = 0; } - } - else if (group == 5) { - /* Action Line */ - AnimData *adt= ale->adt; - // TODO: if tweaking some action, use the same color as for the tweaked track (quick hack done for now) - if (adt && (adt->flag & ADT_NLA_EDIT_ON)) { - // greenish color (same as tweaking strip) - hardcoded for now - glColor3f(0.3f, 0.95f, 0.1f); - } - else { - if (ale->data) - glColor3f(0.8f, 0.2f, 0.0f); // reddish color - hardcoded for now - else - glColor3f(0.6f, 0.5f, 0.5f); // greyish-red color - hardcoded for now + /* draw expand/collapse triangle */ + if (expand > 0) { + UI_icon_draw(x+offset, ydatac, expand); + offset += 17; } - offset += 7 * indent; + /* draw special icon indicating certain data-types */ + if (special > -1) { + /* for normal channels */ + UI_icon_draw(x+offset, ydatac, special); + offset += 17; + } + glDisable(GL_BLEND); - /* only on top two corners, to show that this channel sits on top of the preceeding ones */ - uiSetRoundBox((1|2)); + /* draw name */ + if (sel) + UI_ThemeColor(TH_TEXT_HI); + else + UI_ThemeColor(TH_TEXT); + offset += 3; + UI_DrawString(x+offset, y-4, name); - /* draw slightly shifted up vertically to look like it has more separtion from other channels, - * but we then need to slightly shorten it so that it doesn't look like it overlaps - */ - gl_round_box(GL_POLYGON, x+offset, yminc+NLACHANNEL_SKIP, (float)NLACHANNEL_NAMEWIDTH, ymaxc+NLACHANNEL_SKIP-1, 8); + /* reset offset - for RHS of panel */ + offset = 0; - /* clear group value, otherwise we cause errors... */ - group = 0; - } - else { - /* for normal channels - * - use 3 shades of color group/standard color for 3 indention level - */ - UI_ThemeColorShade(TH_HEADER, ((indent==0)?20: (indent==1)?-20: -40)); + /* set blending again, as text drawing may clear it */ + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glEnable(GL_BLEND); - indent += group; - offset += 7 * indent; - glBegin(GL_QUADS); - glVertex2f(x+offset, yminc); - glVertex2f(x+offset, ymaxc); - glVertex2f((float)NLACHANNEL_NAMEWIDTH, ymaxc); - glVertex2f((float)NLACHANNEL_NAMEWIDTH, yminc); - glEnd(); - } - - /* draw expand/collapse triangle */ - if (expand > 0) { - UI_icon_draw(x+offset, ydatac, expand); - offset += 17; - } - - /* draw special icon indicating certain data-types */ - if (special > -1) { - /* for normal channels */ - UI_icon_draw(x+offset, ydatac, special); - offset += 17; - } - glDisable(GL_BLEND); - - /* draw name */ - if (sel) - UI_ThemeColor(TH_TEXT_HI); - else - UI_ThemeColor(TH_TEXT); - offset += 3; - UI_DrawString(x+offset, y-4, name); - - /* reset offset - for RHS of panel */ - offset = 0; - - /* set blending again, as text drawing may clear it */ - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - glEnable(GL_BLEND); - - /* draw protect 'lock' */ - if (protect > -1) { - offset = 16; - UI_icon_draw((float)NLACHANNEL_NAMEWIDTH-offset, ydatac, protect); - } - - /* draw mute 'eye' */ - if (mute > -1) { - offset += 16; - UI_icon_draw((float)(NLACHANNEL_NAMEWIDTH-offset), ydatac, mute); - } - - /* draw NLA-action line 'status-icons' - only when there's an action */ - if ((ale->type == ANIMTYPE_NLAACTION) && (ale->data)) { - AnimData *adt= ale->adt; + /* draw protect 'lock' */ + if (protect > -1) { + offset = 16; + UI_icon_draw((float)(v2d->cur.xmax-offset), ydatac, protect); + } - offset += 16; + /* draw mute 'eye' */ + if (mute > -1) { + offset += 16; + UI_icon_draw((float)(v2d->cur.xmax-offset), ydatac, mute); + } - /* now draw some indicator icons */ - if ((adt) && (adt->flag & ADT_NLA_EDIT_ON)) { - /* toggle for tweaking with mapping/no-mapping (i.e. 'in place editing' toggle) */ - // for now, use pin icon to symbolise this - if (adt->flag & ADT_NLA_EDIT_NOMAP) - UI_icon_draw((float)(NLACHANNEL_NAMEWIDTH-offset), ydatac, ICON_PINNED); - else - UI_icon_draw((float)(NLACHANNEL_NAMEWIDTH-offset), ydatac, ICON_UNPINNED); + /* draw NLA-action line 'status-icons' - only when there's an action */ + if ((ale->type == ANIMTYPE_NLAACTION) && (ale->data)) { + AnimData *adt= ale->adt; - fdrawline((float)(NLACHANNEL_NAMEWIDTH-offset), yminc, - (float)(NLACHANNEL_NAMEWIDTH-offset), ymaxc); - offset += 16;; + offset += 16; - /* 'tweaking action' indicator - not a button */ - UI_icon_draw((float)NLACHANNEL_NAMEWIDTH-offset, ydatac, ICON_EDIT); - } - else { - /* XXX firstly draw a little rect to help identify that it's different from the toggles */ - glBegin(GL_LINE_LOOP); - glVertex2f((float)NLACHANNEL_NAMEWIDTH-offset-1, y-7); - glVertex2f((float)NLACHANNEL_NAMEWIDTH-offset-1, y+9); - glVertex2f((float)NLACHANNEL_NAMEWIDTH-1, y+9); - glVertex2f((float)NLACHANNEL_NAMEWIDTH-1, y-7); - glEnd(); // GL_LINES - - /* 'push down' icon for normal active-actions */ - UI_icon_draw((float)NLACHANNEL_NAMEWIDTH-offset, ydatac, ICON_FREEZE); + /* now draw some indicator icons */ + if ((adt) && (adt->flag & ADT_NLA_EDIT_ON)) { + /* toggle for tweaking with mapping/no-mapping (i.e. 'in place editing' toggle) */ + // for now, use pin icon to symbolise this + if (adt->flag & ADT_NLA_EDIT_NOMAP) + UI_icon_draw((float)(v2d->cur.xmax-offset), ydatac, ICON_PINNED); + else + UI_icon_draw((float)(v2d->cur.xmax-offset), ydatac, ICON_UNPINNED); + + fdrawline((float)(v2d->cur.xmax-offset), yminc, + (float)(v2d->cur.xmax-offset), ymaxc); + offset += 16;; + + /* 'tweaking action' indicator - not a button */ + UI_icon_draw((float)(v2d->cur.xmax-offset), ydatac, ICON_EDIT); + } + else { + /* XXX firstly draw a little rect to help identify that it's different from the toggles */ + glBegin(GL_LINE_LOOP); + glVertex2f((float)v2d->cur.xmax-offset-1, y-7); + glVertex2f((float)v2d->cur.xmax-offset-1, y+9); + glVertex2f((float)v2d->cur.xmax-1, y+9); + glVertex2f((float)v2d->cur.xmax-1, y-7); + glEnd(); // GL_LINES + + /* 'push down' icon for normal active-actions */ + UI_icon_draw((float)NLACHANNEL_NAMEWIDTH-offset, ydatac, ICON_FREEZE); + } } + + glDisable(GL_BLEND); } - - glDisable(GL_BLEND); } /* adjust y-position for next one */ y -= NLACHANNEL_STEP; } +} + +void draw_nla_channel_list (bContext *C, bAnimContext *ac, SpaceNla *snla, ARegion *ar) +{ + ListBase anim_data = {NULL, NULL}; + bAnimListElem *ale; + int filter; + + View2D *v2d= &ar->v2d; + float y= 0.0f; + int items, height; + + /* build list of channels to draw */ + filter= (ANIMFILTER_VISIBLE|ANIMFILTER_CHANNELS); + items= ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); + + /* Update max-extent of channels here (taking into account scrollers): + * - this is done to allow the channel list to be scrollable, but must be done here + * to avoid regenerating the list again and/or also because channels list is drawn first + * - offset of NLACHANNEL_HEIGHT*2 is added to the height of the channels, as first is for + * start of list offset, and the second is as a correction for the scrollers. + */ + height= ((items*NLACHANNEL_STEP) + (NLACHANNEL_HEIGHT*2)); + /* don't use totrect set, as the width stays the same + * (NOTE: this is ok here, the configuration is pretty straightforward) + */ + v2d->tot.ymin= (float)(-height); + + /* draw channels */ + { /* first pass: backdrops + oldstyle drawing */ + y= (float)(-NLACHANNEL_HEIGHT); + + draw_nla_channel_list_gl(ac, &anim_data, v2d, y); + } + { /* second pass: UI widgets */ + uiBlock *block= uiBeginBlock(C, ar, "NLA channel buttons", UI_EMBOSS); + + y= (float)(-NLACHANNEL_HEIGHT); + + /* set blending again, as may not be set in previous step */ + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glEnable(GL_BLEND); + + /* loop through channels, and set up drawing depending on their type */ + for (ale= anim_data.first; ale; ale= ale->next) { + const float yminc= (float)(y - NLACHANNEL_HEIGHT_HALF); + const float ymaxc= (float)(y + NLACHANNEL_HEIGHT_HALF); + + /* check if visible */ + if ( IN_RANGE(yminc, v2d->cur.ymin, v2d->cur.ymax) || + IN_RANGE(ymaxc, v2d->cur.ymin, v2d->cur.ymax) ) + { + /* draw all channels using standard channel-drawing API */ + ANIM_channel_draw_widgets(ac, ale, block, yminc, ymaxc); + } + + /* adjust y-position for next one */ + y -= NLACHANNEL_STEP; + } + + uiEndBlock(C, block); + uiDrawBlock(C, block); + + glDisable(GL_BLEND); + } /* free tempolary channels */ BLI_freelistN(&anim_data); diff --git a/source/blender/editors/space_nla/nla_edit.c b/source/blender/editors/space_nla/nla_edit.c index d476852ef2d..e53ccd004db 100644 --- a/source/blender/editors/space_nla/nla_edit.c +++ b/source/blender/editors/space_nla/nla_edit.c @@ -919,6 +919,58 @@ void NLA_OT_split (wmOperatorType *ot) ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; } +/* ******************** Bake Strips Operator ***************************** */ +/* Bakes the NLA Strips for the active AnimData blocks */ + +static int nlaedit_bake_exec (bContext *C, wmOperator *op) +{ + bAnimContext ac; + + ListBase anim_data = {NULL, NULL}; + bAnimListElem *ale; + int filter; + + /* get editor data */ + if (ANIM_animdata_get_context(C, &ac) == 0) + return OPERATOR_CANCELLED; + + /* get a list of the editable tracks being shown in the NLA */ + filter= (ANIMFILTER_VISIBLE | ANIMFILTER_ANIMDATA | ANIMFILTER_FOREDIT); + ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); + + /* for each AnimData block, bake strips to animdata... */ + for (ale= anim_data.first; ale; ale= ale->next) { + // FIXME + } + + /* free temp data */ + BLI_freelistN(&anim_data); + + /* refresh auto strip properties */ + ED_nla_postop_refresh(&ac); + + /* set notifier that things have changed */ + WM_event_add_notifier(C, NC_ANIMATION|ND_NLA_EDIT, NULL); + + /* done */ + return OPERATOR_FINISHED; +} + +void NLA_OT_bake (wmOperatorType *ot) +{ + /* identifiers */ + ot->name= "Bake Strips"; + ot->idname= "NLA_OT_bake"; + ot->description= "Bake all strips of selected AnimData blocks."; + + /* api callbacks */ + ot->exec= nlaedit_bake_exec; + ot->poll= nlaop_poll_tweakmode_off; + + /* flags */ + ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; +} + /* *********************************************** */ /* NLA Editing Operations (Modifying) */ @@ -1197,7 +1249,7 @@ static int nlaedit_apply_scale_exec (bContext *C, wmOperator *op) * but leave everything else alone */ strip->scale= 1.0f; - calc_action_range(strip->act, &strip->actstart, &strip->actend, 1); + calc_action_range(strip->act, &strip->actstart, &strip->actend, 0); } } } diff --git a/source/blender/editors/space_nla/nla_header.c b/source/blender/editors/space_nla/nla_header.c index 04c2db08bda..0d3bf2cb6b1 100644 --- a/source/blender/editors/space_nla/nla_header.c +++ b/source/blender/editors/space_nla/nla_header.c @@ -94,14 +94,14 @@ static void nla_viewmenu(bContext *C, uiLayout *layout, void *arg_unused) uiItemS(layout); - uiItemR(layout, NULL, 0, &spaceptr, "show_cframe_indicator", 0, 0, 0); + uiItemR(layout, NULL, 0, &spaceptr, "show_cframe_indicator", 0); if (snla->flag & SNLA_DRAWTIME) uiItemO(layout, "Show Frames", 0, "ANIM_OT_time_toggle"); else uiItemO(layout, "Show Seconds", 0, "ANIM_OT_time_toggle"); - uiItemR(layout, NULL, 0, &spaceptr, "show_strip_curves", 0, 0, 0); + uiItemR(layout, NULL, 0, &spaceptr, "show_strip_curves", 0); uiItemS(layout); @@ -151,8 +151,8 @@ static void nla_editmenu(bContext *C, uiLayout *layout, void *arg_unused) { Scene *scene= CTX_data_scene(C); - uiItemMenuF(layout, "Transform", 0, nla_edit_transformmenu); - uiItemMenuF(layout, "Snap", 0, nla_edit_snapmenu); + uiItemMenuF(layout, "Transform", 0, nla_edit_transformmenu, NULL); + uiItemMenuF(layout, "Snap", 0, nla_edit_snapmenu, NULL); uiItemS(layout); diff --git a/source/blender/editors/space_nla/nla_intern.h b/source/blender/editors/space_nla/nla_intern.h index 7cc09707ba7..e4557ec878f 100644 --- a/source/blender/editors/space_nla/nla_intern.h +++ b/source/blender/editors/space_nla/nla_intern.h @@ -45,7 +45,7 @@ void NLA_OT_properties(wmOperatorType *ot); /* nla_draw.c */ void draw_nla_main_data(bAnimContext *ac, SpaceNla *snla, ARegion *ar); -void draw_nla_channel_list(bAnimContext *ac, SpaceNla *snla, ARegion *ar); +void draw_nla_channel_list(bContext *C, bAnimContext *ac, SpaceNla *snla, ARegion *ar); /* **************************************** */ /* nla_header.c */ diff --git a/source/blender/editors/space_nla/space_nla.c b/source/blender/editors/space_nla/space_nla.c index 6f377aabd4e..c4f929274c7 100644 --- a/source/blender/editors/space_nla/space_nla.c +++ b/source/blender/editors/space_nla/space_nla.c @@ -238,7 +238,7 @@ static void nla_channel_area_draw(const bContext *C, ARegion *ar) /* data */ if (ANIM_animdata_get_context(C, &ac)) { - draw_nla_channel_list(&ac, snla, ar); + draw_nla_channel_list((bContext *)C, &ac, snla, ar); } /* reset view matrix */ diff --git a/source/blender/editors/space_node/drawnode.c b/source/blender/editors/space_node/drawnode.c index 50cf193f37b..1fb8cb3452b 100644 --- a/source/blender/editors/space_node/drawnode.c +++ b/source/blender/editors/space_node/drawnode.c @@ -253,7 +253,7 @@ static int node_buts_mix_rgb(uiBlock *block, bNodeTree *ntree, bNode *node, rctf uiButSetFunc(bt, node_but_title_cb, node, bt); /* Alpha option, composite */ if(a_but) - uiDefButS(block, TOG, B_NODE_EXEC, "A", + uiDefIconButS(block, TOG, B_NODE_EXEC, ICON_IMAGE_RGB_ALPHA, (short)butr->xmax-20, (short)butr->ymin, 20, 20, &node->custom2, 0, 0, 0, 0, "Include Alpha of 2nd input in this operation"); } @@ -1077,7 +1077,7 @@ static int node_composit_buts_renderlayers(uiBlock *block, bNodeTree *ntree, bNo /* browse button layer */ strp= scene_layer_menu(node->id?(Scene *)node->id:scene); if(node->id) - bt= uiDefIconTextButS(block, MENU, B_NODE_EXEC, ICON_SCENE_DATA, strp, + bt= uiDefIconTextButS(block, MENU, B_NODE_EXEC, ICON_RENDERLAYERS, strp, butr->xmin+20, butr->ymin, (butr->xmax-butr->xmin)-40, 19, &node->custom1, 0, 0, 0, 0, "Choose Render Layer"); else @@ -1473,7 +1473,7 @@ static int node_composit_buts_vecblur(uiBlock *block, bNodeTree *ntree, bNode *n uiDefButS(block, NUM, B_NODE_EXEC, "MaxSpeed:", butr->xmin, dy+38, dx, 19, &nbd->maxspeed, 0, 1024, 0, 0, "If not zero, maximum speed in pixels"); - uiDefButF(block, NUM, B_NODE_EXEC, "BlurFac:", + uiDefButF(block, NUM, B_NODE_EXEC, "Blur:", butr->xmin, dy+19, dx, 19, &nbd->fac, 0.0f, 2.0f, 10, 2, "Scaling factor for motion vectors, actually 'shutter speed' in frames"); uiDefButS(block, TOG, B_NODE_EXEC, "Curved", diff --git a/source/blender/editors/space_node/node_draw.c b/source/blender/editors/space_node/node_draw.c index 70e2167c1e4..f3df7a29c2e 100644 --- a/source/blender/editors/space_node/node_draw.c +++ b/source/blender/editors/space_node/node_draw.c @@ -607,9 +607,9 @@ static void do_node_internal_buttons(bContext *C, void *node_v, int event) } WM_event_add_notifier(C, NC_SCENE|ND_NODES, CTX_data_scene(C)); } - - // else if(snode->treetype==NTREE_TEXTURE) - // texture_node_event(snode, val); + else if(snode->treetype==NTREE_TEXTURE) { + WM_event_add_notifier(C, NC_TEXTURE|ND_NODES, snode->id); + } } } diff --git a/source/blender/editors/space_node/node_edit.c b/source/blender/editors/space_node/node_edit.c index fe68a56dea5..bc81c25d106 100644 --- a/source/blender/editors/space_node/node_edit.c +++ b/source/blender/editors/space_node/node_edit.c @@ -56,6 +56,7 @@ #include "BKE_main.h" #include "BKE_node.h" #include "BKE_material.h" +#include "BKE_paint.h" #include "BKE_texture.h" #include "BKE_scene.h" #include "BKE_utildefines.h" @@ -212,10 +213,8 @@ void snode_handle_recalc(bContext *C, SpaceNode *snode) WM_event_add_notifier(C, NC_MATERIAL|ND_NODES, snode->id); else if(snode->treetype==NTREE_COMPOSIT) WM_event_add_notifier(C, NC_SCENE|ND_NODES, snode->id); - else if(snode->treetype==NTREE_TEXTURE) { - // ntreeTexUpdatePreviews(snode->nodetree); /* XXX texture nodes should follow shader node methods (ton) */ - // XXX BIF_preview_changed(ID_TE); - } + else if(snode->treetype==NTREE_TEXTURE) + WM_event_add_notifier(C, NC_TEXTURE|ND_NODES, snode->id); } #if 0 @@ -486,7 +485,7 @@ static void texture_node_event(SpaceNode *snode, short event) #endif /* 0 */ /* assumes nothing being done in ntree yet, sets the default in/out node */ /* called from shading buttons or header */ -void node_shader_default(Material *ma) +void ED_node_shader_default(Material *ma) { bNode *in, *out; bNodeSocket *fromsock, *tosock; @@ -516,7 +515,7 @@ void node_shader_default(Material *ma) /* assumes nothing being done in ntree yet, sets the default in/out node */ /* called from shading buttons or header */ -void node_composit_default(Scene *sce) +void ED_node_composit_default(Scene *sce) { bNode *in, *out; bNodeSocket *fromsock, *tosock; @@ -550,7 +549,7 @@ void node_composit_default(Scene *sce) /* assumes nothing being done in ntree yet, sets the default in/out node */ /* called from shading buttons or header */ -void node_texture_default(Tex *tx) +void ED_node_texture_default(Tex *tx) { bNode *in, *out; bNodeSocket *fromsock, *tosock; @@ -575,7 +574,6 @@ void node_texture_default(Tex *tx) nodeAddLink(tx->nodetree, in, fromsock, out, tosock); ntreeSolveOrder(tx->nodetree); /* needed for pointers */ - ntreeTexUpdatePreviews(tx->nodetree); /* XXX texture nodes should follow shader node methods (ton) */ } /* Here we set the active tree(s), even called for each redraw now, so keep it fast :) */ @@ -592,7 +590,7 @@ void snode_set_context(SpaceNode *snode, Scene *scene) if(ob) { Material *ma= give_current_material(ob, ob->actcol); if(ma) { - snode->from= material_from(ob, ob->actcol); + snode->from= &ob->id; snode->id= &ma->id; snode->nodetree= ma->nodetree; } @@ -614,7 +612,13 @@ void snode_set_context(SpaceNode *snode, Scene *scene) if(snode->texfrom==SNODE_TEX_OBJECT) { if(ob) { tx= give_current_texture(ob, ob->actcol); - snode->from= (ID *)ob; + + if(ob->type == OB_LAMP) + snode->from= (ID*)ob->data; + else + snode->from= (ID*)give_current_material(ob, ob->actcol); + + /* from is not set fully for material nodes, should be ID + Node then */ } } else if(snode->texfrom==SNODE_TEX_WORLD) { @@ -623,23 +627,20 @@ void snode_set_context(SpaceNode *snode, Scene *scene) } else { MTex *mtex= NULL; + Brush *brush= NULL; - if(G.f & G_SCULPTMODE) { - Sculpt *sd= scene->toolsettings->sculpt; - if(sd && sd->brush) - if(sd->brush->texact != -1) - mtex= sd->brush->mtex[sd->brush->texact]; - } - else { - Brush *br= scene->toolsettings->imapaint.brush; - if(br) - mtex= br->mtex[br->texact]; - } - - if(mtex) { - snode->from= (ID *)scene; + if(ob && (ob->mode & OB_MODE_SCULPT)) + brush= paint_brush(&scene->toolsettings->sculpt->paint); + else + brush= paint_brush(&scene->toolsettings->imapaint.paint); + + if(brush && brush->texact != -1) + mtex= brush->mtex[brush->texact]; + + snode->from= (ID *)brush; + + if(mtex) tx= mtex->tex; - } } if(tx) { @@ -1109,9 +1110,6 @@ static int node_resize_modal(bContext *C, wmOperator *op, wmEvent *event) node->width= nsw->oldwidth + mx - nsw->mxstart; CLAMP(node->width, node->typeinfo->minwidth, node->typeinfo->maxwidth); } - // XXX - if(snode->nodetree->type == NTREE_TEXTURE) - ntreeTexUpdatePreviews(snode->nodetree); /* XXX texture nodes should follow shader node methods (ton) */ ED_region_tag_redraw(ar); @@ -1657,7 +1655,6 @@ bNode *node_add_node(SpaceNode *snode, Scene *scene, int type, float locx, float if(snode->nodetree->type==NTREE_TEXTURE) { ntreeTexCheckCyclics(snode->edittree); - ntreeTexUpdatePreviews(snode->edittree); /* XXX texture nodes should follow shader node methods (ton) */ } return node; @@ -2270,34 +2267,6 @@ void node_read_fullsamplelayers(SpaceNode *snode) WM_cursor_wait(0); } -/* called from header_info, when deleting a scene - * goes over all scenes other than the input, checks if they have - * render layer nodes referencing the to-be-deleted scene, and - * resets them to NULL. */ - -/* XXX needs to get current scene then! */ -void clear_scene_in_nodes(Scene *sce) -{ - Scene *sce1; - bNode *node; - - sce1= G.main->scene.first; - while(sce1) { - if(sce1!=sce) { - if (sce1->nodetree) { - for(node= sce1->nodetree->nodes.first; node; node= node->next) { - if(node->type==CMP_NODE_R_LAYERS) { - Scene *nodesce= (Scene *)node->id; - - if (nodesce==sce) node->id = NULL; - } - } - } - } - sce1= sce1->id.next; - } -} - void imagepaint_composite_tags(bNodeTree *ntree, Image *image, ImageUser *iuser) { bNode *node; diff --git a/source/blender/editors/space_node/node_header.c b/source/blender/editors/space_node/node_header.c index 367242d1262..2abcd2f2135 100644 --- a/source/blender/editors/space_node/node_header.c +++ b/source/blender/editors/space_node/node_header.c @@ -45,6 +45,7 @@ #include "BKE_screen.h" #include "BKE_node.h" #include "BKE_main.h" +#include "BKE_utildefines.h" #include "ED_screen.h" #include "ED_types.h" @@ -62,67 +63,9 @@ #include "node_intern.h" -/* ************************ header area region *********************** */ +/* ************************ add menu *********************** */ -static void do_node_selectmenu(bContext *C, void *arg, int event) -{ - ScrArea *curarea= CTX_wm_area(C); - SpaceNode *snode= CTX_wm_space_node(C); - - /* functions in editnode.c assume there's a tree */ - if(snode->nodetree==NULL) - return; - - switch(event) { - case 1: /* border select */ - WM_operator_name_call(C, "NODE_OT_select_border", WM_OP_INVOKE_REGION_WIN, NULL); - break; - case 2: /* select/deselect all */ - // XXX node_deselectall(snode, 1); - break; - case 3: /* select linked in */ - // XXX node_select_linked(snode, 0); - break; - case 4: /* select linked out */ - // XXX node_select_linked(snode, 1); - break; - } - - ED_area_tag_redraw(curarea); -} - -static uiBlock *node_selectmenu(bContext *C, ARegion *ar, void *arg_unused) -{ - ScrArea *curarea= CTX_wm_area(C); - uiBlock *block; - short yco= 0, menuwidth=120; - - block= uiBeginBlock(C, ar, "node_selectmenu", UI_EMBOSSP); - uiBlockSetButmFunc(block, do_node_selectmenu, NULL); - - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Border Select|B", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 1, ""); - - uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, ""); - - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Select/Deselect All|A", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 2, ""); - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Select Linked From|L", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 3, ""); - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Select Linked To|Shift L", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 4, ""); - - if(curarea->headertype==HEADERTOP) { - uiBlockSetDirection(block, UI_DOWN); - } - else { - uiBlockSetDirection(block, UI_TOP); - uiBlockFlipOrder(block); - } - - uiTextBoundsBlock(block, 50); - uiEndBlock(C, block); - - return block; -} - -void do_node_addmenu(bContext *C, void *arg, int event) +static void do_node_add(bContext *C, void *arg, int event) { SpaceNode *snode= CTX_wm_space_node(C); bNode *node; @@ -141,311 +84,125 @@ void do_node_addmenu(bContext *C, void *arg, int event) snode_handle_recalc(C, snode); } -static void node_make_addmenu(bContext *C, int nodeclass, uiBlock *block) +static void node_auto_add_menu(bContext *C, uiLayout *layout, void *arg_nodeclass) { Main *bmain= CTX_data_main(C); SpaceNode *snode= CTX_wm_space_node(C); bNodeTree *ntree; + int nodeclass= GET_INT_FROM_POINTER(arg_nodeclass); int tot= 0, a; - short yco= 0, menuwidth=120; ntree = snode->nodetree; - if(ntree) { - /* mostly taken from toolbox.c, node_add_sublevel() */ - if(ntree) { - if(nodeclass==NODE_CLASS_GROUP) { - bNodeTree *ngroup= bmain->nodetree.first; - for(; ngroup; ngroup= ngroup->id.next) - if(ngroup->type==ntree->type) - tot++; - } - else { - bNodeType *type = ntree->alltypes.first; - while(type) { - if(type->nclass == nodeclass) - tot++; - type= type->next; - } - } - } - - if(tot==0) { - uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, ""); - return; + + if(!ntree) { + uiItemS(layout); + return; + } + + /* mostly taken from toolbox.c, node_add_sublevel() */ + if(nodeclass==NODE_CLASS_GROUP) { + bNodeTree *ngroup= bmain->nodetree.first; + for(; ngroup; ngroup= ngroup->id.next) + if(ngroup->type==ntree->type) + tot++; + } + else { + bNodeType *type = ntree->alltypes.first; + while(type) { + if(type->nclass == nodeclass) + tot++; + type= type->next; } - - if(nodeclass==NODE_CLASS_GROUP) { - bNodeTree *ngroup= bmain->nodetree.first; - for(tot=0, a=0; ngroup; ngroup= ngroup->id.next, tot++) { - if(ngroup->type==ntree->type) { - - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, (ngroup->id.name+2), 0, - yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1.0f, (float)(NODE_GROUP_MENU+tot), ""); - a++; - } + } + + if(tot==0) { + uiItemS(layout); + return; + } + + uiLayoutSetFunc(layout, do_node_add, NULL); + + if(nodeclass==NODE_CLASS_GROUP) { + bNodeTree *ngroup= bmain->nodetree.first; + + for(tot=0, a=0; ngroup; ngroup= ngroup->id.next, tot++) { + if(ngroup->type==ntree->type) { + uiItemV(layout, ngroup->id.name+2, 0, NODE_GROUP_MENU+tot); + a++; } } - else { - bNodeType *type; - int script=0; - for(a=0, type= ntree->alltypes.first; type; type=type->next) { - if( type->nclass == nodeclass && type->name) { - if(type->type == NODE_DYNAMIC) { - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, type->name, 0, - yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1.0f, (float)(NODE_DYNAMIC_MENU+script), ""); - script++; - } else { - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, type->name, 0, - yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1.0f, (float)(type->type), ""); - } - a++; + } + else { + bNodeType *type; + int script=0; + + for(a=0, type= ntree->alltypes.first; type; type=type->next) { + if(type->nclass == nodeclass && type->name) { + if(type->type == NODE_DYNAMIC) { + uiItemV(layout, type->name, 0, NODE_DYNAMIC_MENU+script); + script++; } + else + uiItemV(layout, type->name, 0, type->type); + + a++; } } - } else { - uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, ""); - return; } } -static uiBlock *node_add_inputmenu(bContext *C, ARegion *ar, void *arg_unused) -{ - uiBlock *block; - - block= uiBeginBlock(C, ar, "node_add_inputmenu", UI_EMBOSSP); - uiBlockSetButmFunc(block, do_node_addmenu, NULL); - - node_make_addmenu(C, NODE_CLASS_INPUT, block); - - uiBlockSetDirection(block, UI_RIGHT); - uiTextBoundsBlock(block, 60); - uiEndBlock(C, block); - - return block; -} -static uiBlock *node_add_outputmenu(bContext *C, ARegion *ar, void *arg_unused) -{ - uiBlock *block; - - block= uiBeginBlock(C, ar, "node_add_outputmenu", UI_EMBOSSP); - uiBlockSetButmFunc(block, do_node_addmenu, NULL); - - node_make_addmenu(C, NODE_CLASS_OUTPUT, block); - - uiBlockSetDirection(block, UI_RIGHT); - uiTextBoundsBlock(block, 60); - uiEndBlock(C, block); - - return block; -} -static uiBlock *node_add_colormenu(bContext *C, ARegion *ar, void *arg_unused) -{ - uiBlock *block; - - block= uiBeginBlock(C, ar, "node_add_colormenu", UI_EMBOSSP); - uiBlockSetButmFunc(block, do_node_addmenu, NULL); - - node_make_addmenu(C, NODE_CLASS_OP_COLOR, block); - - uiBlockSetDirection(block, UI_RIGHT); - uiTextBoundsBlock(block, 60); - uiEndBlock(C, block); - - return block; -} -static uiBlock *node_add_vectormenu(bContext *C, ARegion *ar, void *arg_unused) -{ - uiBlock *block; - - block= uiBeginBlock(C, ar, "node_add_vectormenu", UI_EMBOSSP); - uiBlockSetButmFunc(block, do_node_addmenu, NULL); - - node_make_addmenu(C, NODE_CLASS_OP_VECTOR, block); - - uiBlockSetDirection(block, UI_RIGHT); - uiTextBoundsBlock(block, 60); - uiEndBlock(C, block); - - return block; -} -static uiBlock *node_add_filtermenu(bContext *C, ARegion *ar, void *arg_unused) -{ - uiBlock *block; - - block= uiBeginBlock(C, ar, "node_add_filtermenu", UI_EMBOSSP); - uiBlockSetButmFunc(block, do_node_addmenu, NULL); - - node_make_addmenu(C, NODE_CLASS_OP_FILTER, block); - - uiBlockSetDirection(block, UI_RIGHT); - uiTextBoundsBlock(block, 60); - uiEndBlock(C, block); - - return block; -} -static uiBlock *node_add_convertermenu(bContext *C, ARegion *ar, void *arg_unused) -{ - uiBlock *block; - - block= uiBeginBlock(C, ar, "node_add_convertermenu", UI_EMBOSSP); - uiBlockSetButmFunc(block, do_node_addmenu, NULL); - - node_make_addmenu(C, NODE_CLASS_CONVERTOR, block); - - uiBlockSetDirection(block, UI_RIGHT); - uiTextBoundsBlock(block, 60); - uiEndBlock(C, block); - - return block; -} -static uiBlock *node_add_mattemenu(bContext *C, ARegion *ar, void *arg_unused) -{ - uiBlock *block; - - block= uiBeginBlock(C, ar, "node_add_mattemenu", UI_EMBOSSP); - uiBlockSetButmFunc(block, do_node_addmenu, NULL); - - node_make_addmenu(C, NODE_CLASS_MATTE, block); - - uiBlockSetDirection(block, UI_RIGHT); - uiTextBoundsBlock(block, 60); - uiEndBlock(C, block); - - return block; -} -static uiBlock *node_add_distortmenu(bContext *C, ARegion *ar, void *arg_unused) -{ - uiBlock *block; - - block= uiBeginBlock(C, ar, "node_add_distortmenu", UI_EMBOSSP); - uiBlockSetButmFunc(block, do_node_addmenu, NULL); - - node_make_addmenu(C, NODE_CLASS_DISTORT, block); - - uiBlockSetDirection(block, UI_RIGHT); - uiTextBoundsBlock(block, 60); - uiEndBlock(C, block); - - return block; -} -static uiBlock *node_add_patternmenu(bContext *C, ARegion *ar, void *arg_unused) -{ - uiBlock *block; - - block= uiBeginBlock(C, ar, "node_add_patternmenu", UI_EMBOSSP); - uiBlockSetButmFunc(block, do_node_addmenu, NULL); - - node_make_addmenu(C, NODE_CLASS_PATTERN, block); - - uiBlockSetDirection(block, UI_RIGHT); - uiTextBoundsBlock(block, 60); - uiEndBlock(C, block); - - return block; -} -static uiBlock *node_add_texturemenu(bContext *C, ARegion *ar, void *arg_unused) +static void node_menu_add(const bContext *C, Menu *menu) { - uiBlock *block; - - block= uiBeginBlock(C, ar, "node_add_texturemenu", UI_EMBOSSP); - uiBlockSetButmFunc(block, do_node_addmenu, NULL); - - node_make_addmenu(C, NODE_CLASS_TEXTURE, block); - - uiBlockSetDirection(block, UI_RIGHT); - uiTextBoundsBlock(block, 60); - uiEndBlock(C, block); - - return block; -} -static uiBlock *node_add_groupmenu(bContext *C, ARegion *ar, void *arg_unused) -{ - uiBlock *block; - - block= uiBeginBlock(C, ar, "node_add_groupmenu", UI_EMBOSSP); - uiBlockSetButmFunc(block, do_node_addmenu, NULL); - - node_make_addmenu(C, NODE_CLASS_GROUP, block); - - uiBlockSetDirection(block, UI_RIGHT); - uiTextBoundsBlock(block, 60); - uiEndBlock(C, block); - - return block; -} + uiLayout *layout= menu->layout; + SpaceNode *snode= CTX_wm_space_node(C); -static uiBlock *node_add_dynamicmenu(bContext *C, ARegion *ar, void *arg_unused) -{ - uiBlock *block; - - block= uiBeginBlock(C, ar, "node_add_dynamicmenu", UI_EMBOSSP); - uiBlockSetButmFunc(block, do_node_addmenu, NULL); - - node_make_addmenu(C, NODE_CLASS_OP_DYNAMIC, block); - - uiBlockSetDirection(block, UI_RIGHT); - uiTextBoundsBlock(block, 60); - uiEndBlock(C, block); - - return block; -} + if(!snode->nodetree) + uiLayoutSetActive(layout, 0); -static uiBlock *node_addmenu(bContext *C, ARegion *ar, void *arg_unused) -{ - ScrArea *curarea= CTX_wm_area(C); - SpaceNode *snode= CTX_wm_space_node(C); - uiBlock *block; - short yco= 0, menuwidth=120; - - block= uiBeginBlock(C, ar, "node_addmenu", UI_EMBOSSP); - uiBlockSetButmFunc(block, do_node_addmenu, NULL); - if(snode->treetype==NTREE_SHADER) { - uiDefIconTextBlockBut(block, node_add_inputmenu, NULL, ICON_RIGHTARROW_THIN, "Input", 0, yco-=20, 120, 19, ""); - uiDefIconTextBlockBut(block, node_add_outputmenu, NULL, ICON_RIGHTARROW_THIN, "Output", 0, yco-=20, 120, 19, ""); - uiDefIconTextBlockBut(block, node_add_colormenu, NULL, ICON_RIGHTARROW_THIN, "Color", 0, yco-=20, 120, 19, ""); - uiDefIconTextBlockBut(block, node_add_vectormenu, NULL, ICON_RIGHTARROW_THIN, "Vector", 0, yco-=20, 120, 19, ""); - uiDefIconTextBlockBut(block, node_add_convertermenu, NULL, ICON_RIGHTARROW_THIN, "Convertor", 0, yco-=20, 120, 19, ""); - uiDefIconTextBlockBut(block, node_add_groupmenu, NULL, ICON_RIGHTARROW_THIN, "Group", 0, yco-=20, 120, 19, ""); - uiDefIconTextBlockBut(block, node_add_dynamicmenu, NULL, ICON_RIGHTARROW_THIN, "Dynamic", 0, yco-=20, 120, 19, ""); + uiItemMenuF(layout, "Input", 0, node_auto_add_menu, SET_INT_IN_POINTER(NODE_CLASS_INPUT)); + uiItemMenuF(layout, "Output", 0, node_auto_add_menu, SET_INT_IN_POINTER(NODE_CLASS_OUTPUT)); + uiItemMenuF(layout, "Color", 0, node_auto_add_menu, SET_INT_IN_POINTER(NODE_CLASS_OP_COLOR)); + uiItemMenuF(layout, "Vector", 0, node_auto_add_menu, SET_INT_IN_POINTER(NODE_CLASS_OP_VECTOR)); + uiItemMenuF(layout, "Convertor", 0, node_auto_add_menu, SET_INT_IN_POINTER(NODE_CLASS_CONVERTOR)); + uiItemMenuF(layout, "Group", 0, node_auto_add_menu, SET_INT_IN_POINTER(NODE_CLASS_GROUP)); + uiItemMenuF(layout, "Dynamic", 0, node_auto_add_menu, SET_INT_IN_POINTER(NODE_CLASS_OP_DYNAMIC)); } else if(snode->treetype==NTREE_COMPOSIT) { - uiDefIconTextBlockBut(block, node_add_inputmenu, NULL, ICON_RIGHTARROW_THIN, "Input", 0, yco-=20, 120, 19, ""); - uiDefIconTextBlockBut(block, node_add_outputmenu, NULL, ICON_RIGHTARROW_THIN, "Output", 0, yco-=20, 120, 19, ""); - uiDefIconTextBlockBut(block, node_add_colormenu, NULL, ICON_RIGHTARROW_THIN, "Color", 0, yco-=20, 120, 19, ""); - uiDefIconTextBlockBut(block, node_add_vectormenu, NULL, ICON_RIGHTARROW_THIN, "Vector", 0, yco-=20, 120, 19, ""); - uiDefIconTextBlockBut(block, node_add_filtermenu, NULL, ICON_RIGHTARROW_THIN, "Filter", 0, yco-=20, 120, 19, ""); - uiDefIconTextBlockBut(block, node_add_convertermenu, NULL, ICON_RIGHTARROW_THIN, "Convertor", 0, yco-=20, 120, 19, ""); - uiDefIconTextBlockBut(block, node_add_mattemenu, NULL, ICON_RIGHTARROW_THIN, "Matte", 0, yco-=20, 120, 19, ""); - uiDefIconTextBlockBut(block, node_add_distortmenu, NULL, ICON_RIGHTARROW_THIN, "Distort", 0, yco-=20, 120, 19, ""); - uiDefIconTextBlockBut(block, node_add_groupmenu, NULL, ICON_RIGHTARROW_THIN, "Group", 0, yco-=20, 120, 19, ""); - - } else if(snode->treetype==NTREE_TEXTURE) { - uiDefIconTextBlockBut(block, node_add_inputmenu, NULL, ICON_RIGHTARROW_THIN, "Input", 0, yco-=20, 120, 19, ""); - uiDefIconTextBlockBut(block, node_add_outputmenu, NULL, ICON_RIGHTARROW_THIN, "Output", 0, yco-=20, 120, 19, ""); - uiDefIconTextBlockBut(block, node_add_colormenu, NULL, ICON_RIGHTARROW_THIN, "Color", 0, yco-=20, 120, 19, ""); - uiDefIconTextBlockBut(block, node_add_patternmenu, NULL, ICON_RIGHTARROW_THIN, "Patterns", 0, yco-=20, 120, 19, ""); - uiDefIconTextBlockBut(block, node_add_texturemenu, NULL, ICON_RIGHTARROW_THIN, "Textures", 0, yco-=20, 120, 19, ""); - uiDefIconTextBlockBut(block, node_add_convertermenu, NULL, ICON_RIGHTARROW_THIN, "Convertor", 0, yco-=20, 120, 19, ""); - uiDefIconTextBlockBut(block, node_add_distortmenu, NULL, ICON_RIGHTARROW_THIN, "Distort", 0, yco-=20, 120, 19, ""); - uiDefIconTextBlockBut(block, node_add_groupmenu, NULL, ICON_RIGHTARROW_THIN, "Group", 0, yco-=20, 120, 19, ""); + uiItemMenuF(layout, "Input", 0, node_auto_add_menu, SET_INT_IN_POINTER(NODE_CLASS_INPUT)); + uiItemMenuF(layout, "Output", 0, node_auto_add_menu, SET_INT_IN_POINTER(NODE_CLASS_OUTPUT)); + uiItemMenuF(layout, "Color", 0, node_auto_add_menu, SET_INT_IN_POINTER(NODE_CLASS_OP_COLOR)); + uiItemMenuF(layout, "Vector", 0, node_auto_add_menu, SET_INT_IN_POINTER(NODE_CLASS_OP_VECTOR)); + uiItemMenuF(layout, "Filter", 0, node_auto_add_menu, SET_INT_IN_POINTER(NODE_CLASS_OP_FILTER)); + uiItemMenuF(layout, "Convertor", 0, node_auto_add_menu, SET_INT_IN_POINTER(NODE_CLASS_CONVERTOR)); + uiItemMenuF(layout, "Matte", 0, node_auto_add_menu, SET_INT_IN_POINTER(NODE_CLASS_MATTE)); + uiItemMenuF(layout, "Distort", 0, node_auto_add_menu, SET_INT_IN_POINTER(NODE_CLASS_DISTORT)); + uiItemMenuF(layout, "Group", 0, node_auto_add_menu, SET_INT_IN_POINTER(NODE_CLASS_GROUP)); } - else - uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, ""); - - if(curarea->headertype==HEADERTOP) { - uiBlockSetDirection(block, UI_DOWN); - } - else { - uiBlockSetDirection(block, UI_TOP); - uiBlockFlipOrder(block); + else if(snode->treetype==NTREE_TEXTURE) { + uiItemMenuF(layout, "Input", 0, node_auto_add_menu, SET_INT_IN_POINTER(NODE_CLASS_INPUT)); + uiItemMenuF(layout, "Output", 0, node_auto_add_menu, SET_INT_IN_POINTER(NODE_CLASS_OUTPUT)); + uiItemMenuF(layout, "Color", 0, node_auto_add_menu, SET_INT_IN_POINTER(NODE_CLASS_OP_COLOR)); + uiItemMenuF(layout, "Patterns", 0, node_auto_add_menu, SET_INT_IN_POINTER(NODE_CLASS_PATTERN)); + uiItemMenuF(layout, "Textures", 0, node_auto_add_menu, SET_INT_IN_POINTER(NODE_CLASS_TEXTURE)); + uiItemMenuF(layout, "Convertor", 0, node_auto_add_menu, SET_INT_IN_POINTER(NODE_CLASS_CONVERTOR)); + uiItemMenuF(layout, "Distort", 0, node_auto_add_menu, SET_INT_IN_POINTER(NODE_CLASS_DISTORT)); + uiItemMenuF(layout, "Group", 0, node_auto_add_menu, SET_INT_IN_POINTER(NODE_CLASS_GROUP)); } - - uiTextBoundsBlock(block, 50); - - return block; } +void node_menus_register(ARegionType *art) +{ + MenuType *mt; + + mt= MEM_callocN(sizeof(MenuType), "spacetype node menu add"); + strcpy(mt->idname, "NODE_MT_add"); + strcpy(mt->label, "Add"); + mt->draw= node_menu_add; + BLI_addtail(&art->menutypes, mt); +} + +#if 0 static void do_node_nodemenu(bContext *C, void *arg, int event) { ScrArea *curarea= CTX_wm_area(C); @@ -571,218 +328,5 @@ static uiBlock *node_nodemenu(bContext *C, ARegion *ar, void *arg_unused) return block; } - -static void do_node_viewmenu(bContext *C, void *arg, int event) -{ -// SpaceNode *snode= CTX_wm_space_node(C); -// ARegion *ar= CTX_wm_region(C); - ScrArea *sa= CTX_wm_area(C); - - switch(event) { - case 1: /* Zoom in */ - WM_operator_name_call(C, "VIEW2D_OT_zoom_in", WM_OP_EXEC_REGION_WIN, NULL); - break; - case 2: /* View all */ - WM_operator_name_call(C, "VIEW2D_OT_zoom_out", WM_OP_EXEC_REGION_WIN, NULL); - break; - case 3: /* View all */ - WM_operator_name_call(C, "NODE_OT_view_all", WM_OP_EXEC_REGION_WIN, NULL); - break; - case 4: /* Grease Pencil */ - // XXX add_blockhandler(sa, NODES_HANDLER_GREASEPENCIL, UI_PNL_UNSTOW); - break; - } - ED_area_tag_redraw(sa); -} - -static uiBlock *node_viewmenu(bContext *C, ARegion *ar, void *arg_unused) -{ - ScrArea *curarea= CTX_wm_area(C); - SpaceNode *snode= CTX_wm_space_node(C); - uiBlock *block; - short yco= 0, menuwidth=120; - - block= uiBeginBlock(C, ar, "node_viewmenu", UI_EMBOSSP); - uiBlockSetButmFunc(block, do_node_viewmenu, NULL); - - if (snode->nodetree) { - uiDefIconTextBut(block, BUTM, 1, ICON_MENU_PANEL, "Grease Pencil...", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 4, ""); - - uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, ""); - } - - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Zoom In|NumPad +", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 1, ""); - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Zoom Out|NumPad -", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 2, ""); - - uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, ""); - - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "View All|Home", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 3, ""); - - /* XXX if (!curarea->full) - uiDefIconTextBut(block, BUTM, B_FULL, ICON_BLANK1, "Maximize Window|Ctrl UpArrow", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 4, ""); - else - uiDefIconTextBut(block, BUTM, B_FULL, ICON_BLANK1, "Tile Window|Ctrl DownArrow", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 4, ""); - */ - if(curarea->headertype==HEADERTOP) { - uiBlockSetDirection(block, UI_DOWN); - } - else { - uiBlockSetDirection(block, UI_TOP); - uiBlockFlipOrder(block); - } - - uiTextBoundsBlock(block, 50); - uiEndBlock(C, block); - - return block; -} - -static void do_node_buttons(bContext *C, void *arg, int event) -{ - // NODE_FIX_ME : instead of using "current material/texture/scene", node editor can also pin context? - // note: scene context better not gets overridden, that'll clash too much (ton) - SpaceNode *snode= CTX_wm_space_node(C); - Scene *scene= CTX_data_scene(C); - Material *ma; - Tex *tx; - - switch(event) { - case B_REDR: - ED_area_tag_redraw(CTX_wm_area(C)); - break; - case B_NODE_USEMAT: - ma= (Material *)snode->id; - if(ma) { - if(ma->use_nodes && ma->nodetree==NULL) { - node_shader_default(ma); - snode_set_context(snode, scene); - } - } - ED_area_tag_redraw(CTX_wm_area(C)); - break; - - case B_NODE_USESCENE: - if(scene->use_nodes) { - if(scene->nodetree==NULL) - node_composit_default(scene); - } - snode_set_context(snode, scene); - ED_area_tag_redraw(CTX_wm_area(C)); - break; - - case B_NODE_USETEX: - tx = (Tex *)snode->id; - if(tx) { - tx->type = 0; - if(tx->use_nodes && tx->nodetree==NULL) { - node_texture_default(tx); - snode_set_context(snode, scene); - } - } - ED_area_tag_redraw(CTX_wm_area(C)); - break; - } -} - -void node_header_buttons(const bContext *C, ARegion *ar) -{ - ScrArea *sa= CTX_wm_area(C); - SpaceNode *snode= CTX_wm_space_node(C); - Scene *scene= CTX_data_scene(C); - uiBlock *block; - short xco, yco= 3; - - block= uiBeginBlock(C, ar, "header node", UI_EMBOSS); - uiBlockSetHandleFunc(block, do_node_buttons, NULL); - - xco= ED_area_header_standardbuttons(C, block, yco); - - if((sa->flag & HEADER_NO_PULLDOWN)==0) { - int xmax; - - xmax= GetButStringLength("View"); - uiDefPulldownBut(block, node_viewmenu, NULL, - "View", xco, yco, xmax-3, 20, ""); - xco+= xmax; - - xmax= GetButStringLength("Select"); - uiDefPulldownBut(block, node_selectmenu, NULL, - "Select", xco, yco, xmax-3, 20, ""); - xco+= xmax; - - xmax= GetButStringLength("Add"); - uiDefPulldownBut(block, node_addmenu, NULL, - "Add", xco, yco, xmax-3, 20, ""); - xco+= xmax; - - xmax= GetButStringLength("Node"); - uiDefPulldownBut(block, node_nodemenu, NULL, - "Node", xco, yco, xmax-3, 20, ""); - xco+= xmax; - } - - uiBlockSetEmboss(block, UI_EMBOSS); - - uiBlockSetEmboss(block, UI_EMBOSS); - - /* main type choosing */ - uiBlockBeginAlign(block); - uiDefIconButI(block, ROW, B_REDR, ICON_MATERIAL_DATA, xco,yco,XIC,YIC-2, - &(snode->treetype), 2.0f, 0.0f, 0.0f, 0.0f, "Material Nodes"); - xco+= XIC; - uiDefIconButI(block, ROW, B_REDR, ICON_IMAGE_DATA, xco,yco,XIC,YIC-2, - &(snode->treetype), 2.0f, 1.0f, 0.0f, 0.0f, "Composite Nodes"); - xco+= XIC; - uiDefIconButI(block, ROW, B_REDR, ICON_TEXTURE_DATA, xco,yco,XIC,YIC-2, - &(snode->treetype), 2.0f, 2.0f, 0.0f, 0.0f, "Texture Nodes"); - xco+= 2*XIC; - uiBlockEndAlign(block); - - /* find and set the context */ - snode_set_context(snode, scene); - - if(snode->treetype==NTREE_SHADER) { - if(snode->from) { - /* 0, NULL -> pin */ - // XXX xco= std_libbuttons(block, xco, 0, 0, NULL, B_MATBROWSE, ID_MA, 1, snode->id, snode->from, &(snode->menunr), - // B_MATALONE, B_MATLOCAL, B_MATDELETE, B_AUTOMATNAME, B_KEEPDATA); - - if(snode->id) { - Material *ma= (Material *)snode->id; - uiDefButC(block, TOG, B_NODE_USEMAT, "Use Nodes", xco+5,yco,90,19, &ma->use_nodes, 0.0f, 0.0f, 0, 0, ""); - xco+=80; - } - } - } - else if(snode->treetype==NTREE_COMPOSIT) { - int icon; - - if(WM_jobs_test(CTX_wm_manager(C), sa)) icon= ICON_REC; else icon= ICON_BLANK1; - uiDefIconTextButS(block, TOG, B_NODE_USESCENE, icon, "Use Nodes", xco+5,yco,100,19, &scene->use_nodes, 0.0f, 0.0f, 0, 0, "Indicate this Scene will use Nodes and execute them while editing"); - xco+= 100; - uiDefButBitI(block, TOG, R_COMP_FREE, B_NOP, "Free Unused", xco+5,yco,100,19, &scene->r.scemode, 0.0f, 0.0f, 0, 0, "Free Nodes that are not used while composite"); - xco+= 100; - uiDefButBitS(block, TOG, SNODE_BACKDRAW, B_REDR, "Backdrop", xco+5,yco,90,19, &snode->flag, 0.0f, 0.0f, 0, 0, "Use active Viewer Node output as backdrop"); - xco+= 90; - } - else if(snode->treetype==NTREE_TEXTURE) { - if(snode->from) { - - // XXX xco= std_libbuttons(block, xco, 0, 0, NULL, B_TEXBROWSE, ID_TE, 1, snode->id, snode->from, &(snode->menunr), - // B_TEXALONE, B_TEXLOCAL, B_TEXDELETE, B_AUTOTEXNAME, B_KEEPDATA); - - if(snode->id) { - Tex *tx= (Tex *)snode->id; - uiDefButC(block, TOG, B_NODE_USETEX, "Use Nodes", xco+5,yco,90,19, &tx->use_nodes, 0.0f, 0.0f, 0, 0, ""); - xco+=80; - } - } - } - - UI_view2d_totRect_set(&ar->v2d, xco+XIC+100, (int)(ar->v2d.tot.ymax-ar->v2d.tot.ymin)); - - uiEndBlock(C, block); - uiDrawBlock(C, block); -} - +#endif diff --git a/source/blender/editors/space_node/node_intern.h b/source/blender/editors/space_node/node_intern.h index d6680457376..5c66c902797 100644 --- a/source/blender/editors/space_node/node_intern.h +++ b/source/blender/editors/space_node/node_intern.h @@ -31,6 +31,7 @@ /* internal exports only */ struct ARegion; +struct ARegionType; struct View2D; struct bContext; struct wmWindowManager; @@ -45,6 +46,7 @@ struct wmWindowManager; /* node_header.c */ void node_header_buttons(const bContext *C, ARegion *ar); +void node_menus_register(struct ARegionType *art); /* node_draw.c */ void drawnodespace(const bContext *C, ARegion *ar, View2D *v2d); @@ -75,9 +77,6 @@ void snode_make_group_editable(SpaceNode *snode, bNode *gnode); void snode_home(ScrArea *sa, ARegion *ar, SpaceNode *snode); void node_set_active(SpaceNode *snode, bNode *node); void node_deselectall(SpaceNode *snode, int swap); -void node_shader_default(Material *ma); -void node_composit_default(Scene *sce); -void node_texture_default(Tex *tx); void snode_composite_job(const struct bContext *C, ScrArea *sa); bNode *snode_get_editgroup(SpaceNode *snode); void snode_autoconnect(SpaceNode *snode, bNode *node_to, int flag); diff --git a/source/blender/editors/space_node/node_state.c b/source/blender/editors/space_node/node_state.c index 8d805490942..dcab3dc0895 100644 --- a/source/blender/editors/space_node/node_state.c +++ b/source/blender/editors/space_node/node_state.c @@ -183,7 +183,7 @@ void NODE_OT_visibility_toggle(wmOperatorType *ot) RNA_def_int(ot->srna, "mouse_y", 0, INT_MIN, INT_MAX, "Mouse Y", "", INT_MIN, INT_MAX); } -static int node_fit_all_exec(bContext *C, wmOperator *op) +static int node_view_all_exec(bContext *C, wmOperator *op) { ScrArea *sa= CTX_wm_area(C); ARegion *ar= CTX_wm_region(C); @@ -196,11 +196,11 @@ static int node_fit_all_exec(bContext *C, wmOperator *op) void NODE_OT_view_all(wmOperatorType *ot) { /* identifiers */ - ot->name= "Fit All"; + ot->name= "View All"; ot->idname= "NODE_OT_view_all"; /* api callbacks */ - ot->exec= node_fit_all_exec; + ot->exec= node_view_all_exec; ot->poll= ED_operator_node_active; /* flags */ diff --git a/source/blender/editors/space_node/space_node.c b/source/blender/editors/space_node/space_node.c index 25e1b368ccb..2233a4db3a0 100644 --- a/source/blender/editors/space_node/space_node.c +++ b/source/blender/editors/space_node/space_node.c @@ -46,6 +46,7 @@ #include "BKE_colortools.h" #include "BKE_context.h" #include "BKE_screen.h" +#include "BKE_node.h" #include "ED_previewrender.h" #include "ED_space_api.h" @@ -152,12 +153,16 @@ static void node_area_listener(ScrArea *sa, wmNotifier *wmn) if(wmn->data==ND_FILEREAD) ED_area_tag_refresh(sa); break; - + + /* future: add ID checks? */ case NC_MATERIAL: - /* future: add ID check? */ if(wmn->data==ND_SHADING) ED_area_tag_refresh(sa); break; + case NC_TEXTURE: + if(wmn->data==ND_NODES) + ED_area_tag_refresh(sa); + break; } } @@ -170,13 +175,19 @@ static void node_area_refresh(const struct bContext *C, struct ScrArea *sa) if(snode->treetype==NTREE_SHADER) { Material *ma= (Material *)snode->id; if(ma->use_nodes) - ED_preview_shader_job(C, sa, snode->id, NULL, 100, 100); + ED_preview_shader_job(C, sa, snode->id, NULL, NULL, 100, 100); } else if(snode->treetype==NTREE_COMPOSIT) { Scene *scene= (Scene *)snode->id; if(scene->use_nodes) snode_composite_job(C, sa); } + else if(snode->treetype==NTREE_TEXTURE) { + Tex *tex= (Tex *)snode->id; + if(tex->use_nodes) { + ED_preview_shader_job(C, sa, snode->id, NULL, NULL, 100, 100); + } + } } } @@ -244,29 +255,18 @@ static void node_main_area_draw(const bContext *C, ARegion *ar) /* add handlers, stuff you only do once or on area/region changes */ static void node_header_area_init(wmWindowManager *wm, ARegion *ar) { - UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_HEADER, ar->winx, ar->winy); + ED_region_header_init(ar); } static void node_header_area_draw(const bContext *C, ARegion *ar) { - float col[3]; - - /* clear */ - if(ED_screen_area_active(C)) - UI_GetThemeColor3fv(TH_HEADER, col); - else - UI_GetThemeColor3fv(TH_HEADERDESEL, col); - - glClearColor(col[0], col[1], col[2], 0.0); - glClear(GL_COLOR_BUFFER_BIT); - - /* set view2d view matrix for scrolling (without scrollers) */ - UI_view2d_view_ortho(C, &ar->v2d); - - node_header_buttons(C, ar); - - /* restore view matrix? */ - UI_view2d_view_restore(C); + SpaceNode *snode= CTX_wm_space_node(C); + Scene *scene= CTX_data_scene(C); + + /* find and set the context */ + snode_set_context(snode, scene); + + ED_region_header(C, ar); } /* used for header + main area */ @@ -275,9 +275,9 @@ static void node_region_listener(ARegion *ar, wmNotifier *wmn) /* context changes */ switch(wmn->category) { case NC_SCENE: - ED_region_tag_redraw(ar); - break; case NC_MATERIAL: + case NC_TEXTURE: + case NC_NODE: ED_region_tag_redraw(ar); break; } @@ -344,6 +344,8 @@ void ED_spacetype_node(void) art->draw= node_header_area_draw; BLI_addhead(&st->regiontypes, art); + + node_menus_register(art); #if 0 /* regions: channels */ diff --git a/source/blender/editors/space_outliner/outliner.c b/source/blender/editors/space_outliner/outliner.c index 84dea679767..fca5b0cc59a 100644 --- a/source/blender/editors/space_outliner/outliner.c +++ b/source/blender/editors/space_outliner/outliner.c @@ -620,7 +620,7 @@ static TreeElement *outliner_add_element(SpaceOops *soops, ListBase *lb, void *i tenla->name= "Pose"; - if(arm->edbo==NULL && (ob->flag & OB_POSEMODE)) { // channels undefined in editmode, but we want the 'tenla' pose icon itself + if(arm->edbo==NULL && (ob->mode & OB_MODE_POSE)) { // channels undefined in editmode, but we want the 'tenla' pose icon itself int a= 0, const_index= 1000; /* ensure unique id for bone constraints */ for(pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next, a++) { @@ -887,7 +887,7 @@ static TreeElement *outliner_add_element(SpaceOops *soops, ListBase *lb, void *i else { /* do not extend Armature when we have posemode */ tselem= TREESTORE(te->parent); - if( GS(tselem->id->name)==ID_OB && ((Object *)tselem->id)->flag & OB_POSEMODE); + if( GS(tselem->id->name)==ID_OB && ((Object *)tselem->id)->mode & OB_MODE_POSE); else { Bone *curBone; for (curBone=arm->bonebase.first; curBone; curBone=curBone->next){ @@ -1016,7 +1016,6 @@ static TreeElement *outliner_add_element(SpaceOops *soops, ListBase *lb, void *i PointerRNA pptr, propptr, *ptr= (PointerRNA*)idv; PropertyRNA *prop, *iterprop; PropertyType proptype; - PropertySubType propsubtype; int a, tot; /* we do lazy build, for speed and to avoid infinite recusion */ @@ -1085,7 +1084,7 @@ static TreeElement *outliner_add_element(SpaceOops *soops, ListBase *lb, void *i te->flag |= TE_LAZY_CLOSED; } else if(ELEM3(proptype, PROP_BOOLEAN, PROP_INT, PROP_FLOAT)) { - tot= RNA_property_array_length(prop); + tot= RNA_property_array_length(ptr, prop); if(!(tselem->flag & TSE_CLOSED)) { for(a=0; a<tot; a++) @@ -1096,31 +1095,20 @@ static TreeElement *outliner_add_element(SpaceOops *soops, ListBase *lb, void *i } } else if(type == TSE_RNA_ARRAY_ELEM) { - /* array property element */ - static char *vectoritem[4]= {" x", " y", " z", " w"}; - static char *quatitem[4]= {" w", " x", " y", " z"}; - static char *coloritem[4]= {" r", " g", " b", " a"}; + char c; prop= parent->directdata; - proptype= RNA_property_type(prop); - propsubtype= RNA_property_subtype(prop); - tot= RNA_property_array_length(prop); te->directdata= prop; te->rnaptr= *ptr; te->index= index; - if(tot == 4 && propsubtype == PROP_ROTATION) - te->name= quatitem[index]; - else if(tot <= 4 && (propsubtype == PROP_VECTOR || propsubtype == PROP_ROTATION)) - te->name= vectoritem[index]; - else if(tot <= 4 && propsubtype == PROP_COLOR) - te->name= coloritem[index]; - else { - te->name= MEM_callocN(sizeof(char)*20, "OutlinerRNAArrayName"); - sprintf(te->name, " %d", index+1); - te->flag |= TE_FREE_NAME; - } + c= RNA_property_array_item_char(prop, index); + + te->name= MEM_callocN(sizeof(char)*20, "OutlinerRNAArrayName"); + if(c) sprintf(te->name, " %c", c); + else sprintf(te->name, " %d", index+1); + te->flag |= TE_FREE_NAME; } } else if(type == TSE_KEYMAP) { @@ -2189,13 +2177,13 @@ static int tree_element_active_pose(bContext *C, Scene *scene, TreeElement *te, if(scene->obedit) ED_object_exit_editmode(C, EM_FREEDATA|EM_FREEUNDO|EM_WAITCURSOR); - if(ob->flag & OB_POSEMODE) + if(ob->mode & OB_MODE_POSE) ED_armature_exit_posemode(C, base); else ED_armature_enter_posemode(C, base); } else { - if(ob->flag & OB_POSEMODE) return 1; + if(ob->mode & OB_MODE_POSE) return 1; } return 0; } @@ -3073,10 +3061,6 @@ static void object_delete_cb(bContext *C, Scene *scene, TreeElement *te, TreeSto if(scene->obedit==base->object) ED_object_exit_editmode(C, EM_FREEDATA|EM_FREEUNDO|EM_WAITCURSOR); - if(base==BASACT) { - ED_view3d_exit_paint_modes(C); - } - ED_base_object_free_and_unlink(scene, base); te->directdata= NULL; tselem->id= NULL; @@ -3250,7 +3234,7 @@ static int outliner_object_operation_exec(bContext *C, wmOperator *op) Scene *scene= CTX_data_scene(C); SpaceOops *soops= CTX_wm_space_outliner(C); int event; - char *str; + char *str= NULL; /* check for invalid states */ if (soops == NULL) @@ -3674,7 +3658,7 @@ static void tree_element_to_path(SpaceOops *soops, TreeElement *te, TreeStoreEle } else if(RNA_property_type(prop) == PROP_COLLECTION) { char buf[128], *name; - + temnext= (TreeElement*)(ld->next->data); tsenext= TREESTORE(temnext); @@ -3737,7 +3721,7 @@ static void tree_element_to_path(SpaceOops *soops, TreeElement *te, TreeStoreEle /* item is part of an array, so must set the array_index */ *array_index= te->index; } - else if (RNA_property_array_length(prop)) { + else if (RNA_property_array_length(ptr, prop)) { /* entire array was selected, so keyframe all */ *flag |= KSP_FLAG_WHOLE_ARRAY; } @@ -3917,7 +3901,7 @@ static KeyingSet *verify_active_keyingset(Scene *scene, short add) /* add if none found */ // XXX the default settings have yet to evolve if ((add) && (ks==NULL)) { - ks= BKE_keyingset_add(&scene->keyingsets, "Keying Set", KEYINGSET_ABSOLUTE, 0); + ks= BKE_keyingset_add(&scene->keyingsets, NULL, KEYINGSET_ABSOLUTE, 0); scene->active_keyingset= BLI_countlist(&scene->keyingsets); } @@ -3942,7 +3926,7 @@ static void do_outliner_keyingset_editop(SpaceOops *soops, KeyingSet *ks, ListBa short groupmode= KSP_GROUP_KSNAME; /* check if RNA-property described by this selected element is an animateable prop */ - if ((tselem->type == TSE_RNA_PROPERTY) && RNA_property_animateable(&te->rnaptr, te->directdata)) { + if (ELEM(tselem->type, TSE_RNA_PROPERTY, TSE_RNA_ARRAY_ELEM) && RNA_property_animateable(&te->rnaptr, te->directdata)) { /* get id + path + index info from the selected element */ tree_element_to_path(soops, te, tselem, &id, &path, &array_index, &flag, &groupmode); @@ -3979,8 +3963,6 @@ static void do_outliner_keyingset_editop(SpaceOops *soops, KeyingSet *ks, ListBa /* free path, since it had to be generated */ MEM_freeN(path); } - - } /* go over sub-tree */ @@ -4178,13 +4160,13 @@ static void tselem_draw_icon(float x, float y, TreeStoreElem *tselem, TreeElemen case TSE_POSEGRP_BASE: UI_icon_draw(x, y, ICON_VERTEXSEL); break; case TSE_SEQUENCE: - if((te->idcode==SEQ_MOVIE) || (te->idcode==SEQ_MOVIE_AND_HD_SOUND)) + if(te->idcode==SEQ_MOVIE) UI_icon_draw(x, y, ICON_SEQUENCE); else if(te->idcode==SEQ_META) UI_icon_draw(x, y, ICON_DOT); else if(te->idcode==SEQ_SCENE) UI_icon_draw(x, y, ICON_SCENE); - else if((te->idcode==SEQ_RAM_SOUND) || (te->idcode==SEQ_HD_SOUND)) + else if(te->idcode==SEQ_SOUND) UI_icon_draw(x, y, ICON_SOUND); else if(te->idcode==SEQ_IMAGE) UI_icon_draw(x, y, ICON_IMAGE_COL); @@ -5097,6 +5079,28 @@ static char *keymap_tweak_menu(void) return string; } +static char *keymap_tweak_dir_menu(void) +{ + static char string[500]; + static char formatstr[] = "|%s %%x%d"; + char *str= string; + + str += sprintf(str, "Tweak Direction %%t"); + + str += sprintf(str, formatstr, "Any", KM_ANY); + str += sprintf(str, formatstr, "North", EVT_GESTURE_N); + str += sprintf(str, formatstr, "North-East", EVT_GESTURE_NE); + str += sprintf(str, formatstr, "East", EVT_GESTURE_E); + str += sprintf(str, formatstr, "Sout-East", EVT_GESTURE_SE); + str += sprintf(str, formatstr, "South", EVT_GESTURE_S); + str += sprintf(str, formatstr, "South-West", EVT_GESTURE_SW); + str += sprintf(str, formatstr, "West", EVT_GESTURE_W); + str += sprintf(str, formatstr, "North-West", EVT_GESTURE_NW); + + return string; +} + + static void keymap_type_cb(bContext *C, void *kmi_v, void *unused_v) { wmKeymapItem *kmi= kmi_v; @@ -5174,17 +5178,20 @@ static void outliner_draw_keymapbuts(uiBlock *block, ARegion *ar, SpaceOops *soo str= keymap_tweak_menu(); uiDefButS(block, MENU, 0, str, xstart, (int)te->ys+1, butw2, OL_H-1, &kmi->type, 0, 0, 0, 0, "Tweak gesture"); xstart+= butw2+5; + str= keymap_tweak_dir_menu(); + uiDefButS(block, MENU, 0, str, xstart, (int)te->ys+1, butw2, OL_H-1, &kmi->val, 0, 0, 0, 0, "Tweak gesture direction"); + xstart+= butw2+5; break; } /* modifiers */ - uiBlockBeginAlign(block); uiDefButS(block, OPTION, 0, "Shift", xstart, (int)te->ys+1, butw3+5, OL_H-1, &kmi->shift, 0, 0, 0, 0, "Modifier"); xstart+= butw3+5; uiDefButS(block, OPTION, 0, "Ctrl", xstart, (int)te->ys+1, butw3, OL_H-1, &kmi->ctrl, 0, 0, 0, 0, "Modifier"); xstart+= butw3; uiDefButS(block, OPTION, 0, "Alt", xstart, (int)te->ys+1, butw3, OL_H-1, &kmi->alt, 0, 0, 0, 0, "Modifier"); xstart+= butw3; uiDefButS(block, OPTION, 0, "Cmd", xstart, (int)te->ys+1, butw3, OL_H-1, &kmi->oskey, 0, 0, 0, 0, "Modifier"); xstart+= butw3; xstart+= 5; - uiBlockEndAlign(block); + uiDefKeyevtButS(block, 0, "", xstart, (int)te->ys+1, butw3, OL_H-1, &kmi->keymodifier, "Key Modifier code"); + xstart+= butw3+5; /* rna property */ if(kmi->ptr && kmi->ptr->data) @@ -5267,7 +5274,10 @@ void draw_outliner(const bContext *C) sizex_rna= MAX2(OL_RNA_COLX, sizex_rna+OL_RNA_COL_SPACEX); /* get width of data (for setting 'tot' rect, this is column 1 + column 2 + a bit extra) */ - sizex= sizex_rna + OL_RNA_COL_SIZEX + 50; + if (soops->outlinevis == SO_KEYMAP) + sizex= sizex_rna + OL_RNA_COL_SIZEX*3 + 50; // XXX this is only really a quick hack to make this wide enough... + else + sizex= sizex_rna + OL_RNA_COL_SIZEX + 50; } else { /* width must take into account restriction columns (if visible) so that entries will still be visible */ diff --git a/source/blender/editors/space_outliner/outliner_header.c b/source/blender/editors/space_outliner/outliner_header.c index 0c7859ed4e2..d4eeaabd1d3 100644 --- a/source/blender/editors/space_outliner/outliner_header.c +++ b/source/blender/editors/space_outliner/outliner_header.c @@ -177,7 +177,7 @@ static void do_outliner_buttons(bContext *C, void *arg, int event) /* add a new KeyingSet if active is -1 */ if (scene->active_keyingset == -1) { // XXX the default settings have yet to evolve... need to keep this in sync with the - BKE_keyingset_add(&scene->keyingsets, "KeyingSet", KEYINGSET_ABSOLUTE, 0); + BKE_keyingset_add(&scene->keyingsets, NULL, KEYINGSET_ABSOLUTE, 0); scene->active_keyingset= BLI_countlist(&scene->keyingsets); } @@ -196,6 +196,8 @@ static void do_outliner_buttons(bContext *C, void *arg, int event) BLI_freelinkN(&scene->keyingsets, ks); scene->active_keyingset= 0; } + else + scene->active_keyingset= 0; } /* redraw regions with KeyingSet info */ diff --git a/source/blender/editors/space_sequencer/Makefile b/source/blender/editors/space_sequencer/Makefile index 7be0bc9cfef..2fb3de516b4 100644 --- a/source/blender/editors/space_sequencer/Makefile +++ b/source/blender/editors/space_sequencer/Makefile @@ -50,6 +50,7 @@ CPPFLAGS += -I../../imbuf CPPFLAGS += -I../../python CPPFLAGS += -I../../blenfont CPPFLAGS += -I$(NAN_GUARDEDALLOC)/include +CPPFLAGS += -I$(NAN_AUDASPACE)/include # own include diff --git a/source/blender/editors/space_sequencer/SConscript b/source/blender/editors/space_sequencer/SConscript index ab51068a529..7a3fb6982ef 100644 --- a/source/blender/editors/space_sequencer/SConscript +++ b/source/blender/editors/space_sequencer/SConscript @@ -6,5 +6,6 @@ sources = env.Glob('*.c') incs = '../include ../../blenlib ../../blenkernel ../../blenfont ../../makesdna ../../imbuf' incs += ' ../../windowmanager #/intern/guardedalloc #/extern/glew/include' incs += ' ../../makesrna' +incs += ' #/intern/audaspace/intern' env.BlenderLib ( 'bf_editors_space_sequencer', sources, Split(incs), [], libtype=['core'], priority=[100] ) diff --git a/source/blender/editors/space_sequencer/sequencer_add.c b/source/blender/editors/space_sequencer/sequencer_add.c index 99a13c8d9e0..bdedef4b6c8 100644 --- a/source/blender/editors/space_sequencer/sequencer_add.c +++ b/source/blender/editors/space_sequencer/sequencer_add.c @@ -89,6 +89,9 @@ #include "UI_resources.h" #include "UI_view2d.h" +#include "BKE_sound.h" +#include "AUD_C-API.h" + /* own include */ #include "sequencer_intern.h" @@ -224,24 +227,80 @@ void SEQUENCER_OT_scene_strip_add(struct wmOperatorType *ot) RNA_def_string(ot->srna, "scene", "", MAX_ID_NAME-2, "Scene Name", "Scene name to add as a strip"); } +static Sequence* sequencer_add_sound_strip(bContext *C, wmOperator *op, int start_frame, int channel, char* filename) +{ + Scene *scene= CTX_data_scene(C); + Editing *ed= seq_give_editing(scene, TRUE); + + bSound *sound; + + Sequence *seq; /* generic strip vars */ + Strip *strip; + StripElem *se; + + AUD_SoundInfo info; + + sound = sound_new_file(CTX_data_main(C), filename); + + if (sound==NULL || sound->snd_sound == NULL) { + if(op) + BKE_report(op->reports, RPT_ERROR, "Unsupported audio format"); + return NULL; + } + + info = AUD_getInfo(sound->snd_sound); + + if (info.specs.format == AUD_FORMAT_INVALID) { + sound_delete(C, sound); + if(op) + BKE_report(op->reports, RPT_ERROR, "Unsupported audio format"); + return NULL; + } + + seq = alloc_sequence(ed->seqbasep, start_frame, channel); + + seq->type= SEQ_SOUND; + seq->sound= sound; + + /* basic defaults */ + seq->strip= strip= MEM_callocN(sizeof(Strip), "strip"); + strip->len = seq->len = (int) (info.length * FPS); + strip->us= 1; + + strip->stripdata= se= MEM_callocN(seq->len*sizeof(StripElem), "stripelem"); + + BLI_split_dirfile_basic(filename, strip->dir, se->name); + + seq->sound_handle = sound_new_handle(scene, sound, start_frame, start_frame + strip->len, 0); + + calc_sequence_disp(seq); + sort_seq(scene); + + /* last active name */ + strncpy(ed->act_sounddir, strip->dir, FILE_MAXDIR-1); + + return seq; +} + /* add movie operator */ static int sequencer_add_movie_strip_exec(bContext *C, wmOperator *op) { Scene *scene= CTX_data_scene(C); Editing *ed= seq_give_editing(scene, TRUE); - + struct anim *an; char filename[FILE_MAX]; - Sequence *seq; /* generic strip vars */ + Sequence *seq, *soundseq=NULL; /* generic strip vars */ Strip *strip; StripElem *se; - - int start_frame, channel; /* operator props */ - + + int start_frame, channel, sound; /* operator props */ + start_frame= RNA_int_get(op->ptr, "start_frame"); channel= RNA_int_get(op->ptr, "channel"); - + sound = RNA_boolean_get(op->ptr, "sound"); + RNA_string_get(op->ptr, "filename", filename); an = openanim(filename, IB_rect); @@ -271,10 +330,19 @@ static int sequencer_add_movie_strip_exec(bContext *C, wmOperator *op) calc_sequence_disp(seq); sort_seq(scene); + if(sound) + { + soundseq = sequencer_add_sound_strip(C, NULL, start_frame, channel+1, filename); + if(soundseq != NULL) + RNA_string_get(op->ptr, "name", soundseq->name); + } + if (RNA_boolean_get(op->ptr, "replace_sel")) { deselect_all_seq(scene); set_last_seq(scene, seq); seq->flag |= SELECT; + if(soundseq) + soundseq->flag |= SELECT; } ED_area_tag_redraw(CTX_wm_area(C)); @@ -310,24 +378,15 @@ void SEQUENCER_OT_movie_strip_add(struct wmOperatorType *ot) WM_operator_properties_filesel(ot, FOLDERFILE|MOVIEFILE); sequencer_generic_props__internal(ot, SEQPROP_STARTFRAME); - RNA_def_boolean(ot->srna, "sound", TRUE, "Sound", "Load hd sound with the movie"); // XXX need to impliment this + RNA_def_boolean(ot->srna, "sound", TRUE, "Sound", "Load sound with the movie"); } - /* add sound operator */ static int sequencer_add_sound_strip_exec(bContext *C, wmOperator *op) { - Scene *scene= CTX_data_scene(C); - Editing *ed= seq_give_editing(scene, TRUE); - - bSound *sound; - char filename[FILE_MAX]; - + Scene *scene= CTX_data_scene(C); Sequence *seq; /* generic strip vars */ - Strip *strip; - StripElem *se; - int start_frame, channel; /* operator props */ start_frame= RNA_int_get(op->ptr, "start_frame"); @@ -335,47 +394,16 @@ static int sequencer_add_sound_strip_exec(bContext *C, wmOperator *op) RNA_string_get(op->ptr, "filename", filename); - /* XXX if(sfile->flag & FILE_STRINGCODE) { - BLI_makestringcode(G.sce, str); - }*/ - -// XXX sound= sound_new_sound(filename); - sound= NULL; - - if (sound==NULL || sound->sample->type == SAMPLE_INVALID) { - BKE_report(op->reports, RPT_ERROR, "Unsupported audio format"); - return OPERATOR_CANCELLED; - } + seq = sequencer_add_sound_strip(C, op, start_frame, channel, filename); - if (sound==NULL || sound->sample->bits != 16) { - BKE_report(op->reports, RPT_ERROR, "Only 16 bit audio is supported"); + if(seq == NULL) return OPERATOR_CANCELLED; - } - - sound->flags |= SOUND_FLAGS_SEQUENCE; -// XXX audio_makestream(sound); - - seq = alloc_sequence(ed->seqbasep, start_frame, channel); - - seq->type= SEQ_RAM_SOUND; - seq->sound= sound; - - /* basic defaults */ - seq->strip= strip= MEM_callocN(sizeof(Strip), "strip"); - strip->len = seq->len = (int) ( ((float)(sound->streamlen-1) / ( (float)scene->r.audio.mixrate*4.0 ))* FPS); - strip->us= 1; - - strip->stripdata= se= MEM_callocN(seq->len*sizeof(StripElem), "stripelem"); - - BLI_split_dirfile_basic(filename, strip->dir, se->name); RNA_string_get(op->ptr, "name", seq->name); - - calc_sequence_disp(seq); - sort_seq(scene); - - /* last active name */ - strncpy(ed->act_sounddir, strip->dir, FILE_MAXDIR-1); + + if (RNA_boolean_get(op->ptr, "cache")) { + sound_cache(seq->sound, 0); + } if (RNA_boolean_get(op->ptr, "replace_sel")) { deselect_all_seq(scene); @@ -416,7 +444,7 @@ void SEQUENCER_OT_sound_strip_add(struct wmOperatorType *ot) WM_operator_properties_filesel(ot, FOLDERFILE|SOUNDFILE); sequencer_generic_props__internal(ot, SEQPROP_STARTFRAME); - RNA_def_boolean(ot->srna, "cache", FALSE, "Cache", "Load the sound as streaming audio"); // XXX need to impliment this + RNA_def_boolean(ot->srna, "cache", FALSE, "Cache", "Cache the sound in memory."); } /* add image operator */ @@ -585,7 +613,7 @@ static int sequencer_add_effect_strip_exec(bContext *C, wmOperator *op) if(seq->plugin==NULL) { BLI_remlink(ed->seqbasep, seq); - seq_free_sequence(ed, seq); + seq_free_sequence(scene, seq); BKE_reportf(op->reports, RPT_ERROR, "Sequencer plugin \"%s\" could not load.", filename); return OPERATOR_CANCELLED; } diff --git a/source/blender/editors/space_sequencer/sequencer_draw.c b/source/blender/editors/space_sequencer/sequencer_draw.c index 3b90039335e..367bfb68208 100644 --- a/source/blender/editors/space_sequencer/sequencer_draw.c +++ b/source/blender/editors/space_sequencer/sequencer_draw.c @@ -173,8 +173,7 @@ static void get_seq_color3ubv(Scene *curscene, Sequence *seq, char *col) case SEQ_PLUGIN: UI_GetThemeColor3ubv(TH_SEQ_PLUGIN, col); break; - case SEQ_HD_SOUND: - case SEQ_RAM_SOUND: + case SEQ_SOUND: UI_GetThemeColor3ubv(TH_SEQ_AUDIO, col); blendcol[0] = blendcol[1] = blendcol[2] = 128; if(seq->flag & SEQ_MUTE) UI_GetColorPtrBlendShade3ubv(col, blendcol, col, 0.5, 20); @@ -546,11 +545,8 @@ static void draw_seq_text(View2D *v2d, Sequence *seq, float x1, float x2, float else sprintf(str, "%d | %s", seq->len, give_seqname(seq)); } - else if (seq->type == SEQ_RAM_SOUND) { - sprintf(str, "%d | %s", seq->len, seq->strip->stripdata->name); - } - else if (seq->type == SEQ_HD_SOUND) { - sprintf(str, "%d | %s", seq->len, seq->strip->stripdata->name); + else if (seq->type == SEQ_SOUND) { + sprintf(str, "%d | %s", seq->len, seq->sound->name); } else if (seq->type == SEQ_MOVIE) { sprintf(str, "%d | %s%s", seq->len, seq->strip->dir, seq->strip->stripdata->name); @@ -664,7 +660,8 @@ static void draw_seq_strip(Scene *scene, ARegion *ar, SpaceSeq *sseq, Sequence * draw_shadedstrip(seq, background_col, x1, y1, x2, y2); /* draw additional info and controls */ - if (seq->type == SEQ_RAM_SOUND) + // XXX + if(0) // (seq->type == SEQ_SOUND) drawseqwave(scene, v2d, seq, x1, y1, x2, y2, ar->winx); if (!is_single_image) diff --git a/source/blender/editors/space_sequencer/sequencer_edit.c b/source/blender/editors/space_sequencer/sequencer_edit.c index 036c0769c1e..1555784f470 100644 --- a/source/blender/editors/space_sequencer/sequencer_edit.c +++ b/source/blender/editors/space_sequencer/sequencer_edit.c @@ -65,6 +65,7 @@ #include "BKE_scene.h" #include "BKE_utildefines.h" #include "BKE_report.h" +#include "BKE_sound.h" #include "WM_api.h" #include "WM_types.h" @@ -166,7 +167,7 @@ Sequence *get_foreground_frame_seq(Scene *scene, int frame) if(seq->flag & SEQ_MUTE || seq->startdisp > frame || seq->enddisp <= frame) continue; /* only use elements you can see - not */ - if (ELEM6(seq->type, SEQ_IMAGE, SEQ_META, SEQ_SCENE, SEQ_MOVIE, SEQ_MOVIE_AND_HD_SOUND, SEQ_COLOR)) { + if (ELEM5(seq->type, SEQ_IMAGE, SEQ_META, SEQ_SCENE, SEQ_MOVIE, SEQ_COLOR)) { if (seq->machine > best_machine) { best_seq = seq; best_machine = seq->machine; @@ -563,7 +564,7 @@ static void reload_sound_strip(Scene *scene, char *name) calc_sequence(seqact); seq->strip= 0; - seq_free_sequence(ed, seq); + seq_free_sequence(scene, seq); BLI_remlink(ed->seqbasep, seq); seq= ed->seqbasep->first; @@ -603,7 +604,7 @@ static void reload_image_strip(Scene *scene, char *name) calc_sequence(seqact); seq->strip= 0; - seq_free_sequence(ed, seq); + seq_free_sequence(scene, seq); BLI_remlink(ed->seqbasep, seq); update_changed_seq_and_deps(scene, seqact, 1, 1); @@ -722,7 +723,7 @@ int seq_effect_find_selected(Scene *scene, Sequence *activeseq, int type, Sequen for(seq=ed->seqbasep->first; seq; seq=seq->next) { if(seq->flag & SELECT) { - if (seq->type == SEQ_RAM_SOUND || seq->type == SEQ_HD_SOUND) { + if (seq->type == SEQ_SOUND) { *error_str= "Can't apply effects to audio sequence strips"; return 0; } @@ -849,7 +850,6 @@ static Sequence *del_seq_find_replace_recurs(Scene *scene, Sequence *seq) static void recurs_del_seq_flag(Scene *scene, ListBase *lb, short flag, short deleteall) { - Editing *ed= seq_give_editing(scene, FALSE); Sequence *seq, *seqn; Sequence *last_seq = get_last_seq(scene); @@ -857,20 +857,20 @@ static void recurs_del_seq_flag(Scene *scene, ListBase *lb, short flag, short de while(seq) { seqn= seq->next; if((seq->flag & flag) || deleteall) { - if(seq->type==SEQ_RAM_SOUND && seq->sound) + if(seq->type==SEQ_SOUND && seq->sound) seq->sound->id.us--; BLI_remlink(lb, seq); if(seq==last_seq) set_last_seq(scene, NULL); if(seq->type==SEQ_META) recurs_del_seq_flag(scene, &seq->seqbase, flag, 1); if(seq->ipo) seq->ipo->id.us--; - seq_free_sequence(ed, seq); + seq_free_sequence(scene, seq); } seq= seqn; } } -static Sequence *dupli_seq(Sequence *seq) +static Sequence *dupli_seq(struct Scene *scene, Sequence *seq) { Sequence *seqn = MEM_dupallocN(seq); // XXX animato: ID *id; @@ -936,14 +936,13 @@ static Sequence *dupli_seq(Sequence *seq) seqn->strip->stripdata = MEM_dupallocN(seq->strip->stripdata); seqn->anim= 0; - } else if(seq->type == SEQ_RAM_SOUND) { - seqn->strip->stripdata = + } else if(seq->type == SEQ_SOUND) { + seqn->strip->stripdata = MEM_dupallocN(seq->strip->stripdata); + if(seq->sound_handle) + seqn->sound_handle = sound_new_handle(scene, seqn->sound, seq->sound_handle->startframe, seq->sound_handle->endframe, seq->sound_handle->frameskip); + seqn->sound->id.us++; - } else if(seq->type == SEQ_HD_SOUND) { - seqn->strip->stripdata = - MEM_dupallocN(seq->strip->stripdata); - seqn->hdaudio = 0; } else if(seq->type == SEQ_IMAGE) { seqn->strip->stripdata = MEM_dupallocN(seq->strip->stripdata); @@ -970,13 +969,13 @@ static Sequence *dupli_seq(Sequence *seq) return seqn; } -static Sequence * deep_dupli_seq(Sequence * seq) +static Sequence * deep_dupli_seq(struct Scene *scene, Sequence * seq) { - Sequence * seqn = dupli_seq(seq); + Sequence * seqn = dupli_seq(scene, seq); if (seq->type == SEQ_META) { Sequence * s; for(s= seq->seqbase.first; s; s = s->next) { - Sequence * n = deep_dupli_seq(s); + Sequence * n = deep_dupli_seq(scene, s); if (n) { BLI_addtail(&seqn->seqbase, n); } @@ -995,7 +994,7 @@ static void recurs_dupli_seq(Scene *scene, ListBase *old, ListBase *new) for(seq= old->first; seq; seq= seq->next) { seq->tmp= NULL; if(seq->flag & SELECT) { - seqn = dupli_seq(seq); + seqn = dupli_seq(scene, seq); if (seqn) { /*should never fail */ seq->flag &= SEQ_DESEL; seqn->flag &= ~(SEQ_LEFTSEL+SEQ_RIGHTSEL+SEQ_LOCK); @@ -1061,10 +1060,10 @@ static Sequence *cut_seq_hard(Scene *scene, Sequence * seq, int cutframe) reload_sequence_new_file(scene, seq); calc_sequence(seq); - + if (!skip_dup) { /* Duplicate AFTER the first change */ - seqn = deep_dupli_seq(seq); + seqn = deep_dupli_seq(scene, seq); } if (seqn) { @@ -1150,10 +1149,10 @@ static Sequence *cut_seq_soft(Scene *scene, Sequence * seq, int cutframe) } calc_sequence(seq); - + if (!skip_dup) { /* Duplicate AFTER the first change */ - seqn = deep_dupli_seq(seq); + seqn = deep_dupli_seq(scene, seq); } if (seqn) { @@ -1493,11 +1492,13 @@ static int sequencer_mute_exec(bContext *C, wmOperator *op) if(selected){ /* mute unselected */ if (seq->flag & SELECT) { seq->flag |= SEQ_MUTE; + seq_update_sound(seq); } } else { if ((seq->flag & SELECT)==0) { seq->flag |= SEQ_MUTE; + seq_update_sound(seq); } } } @@ -1544,11 +1545,13 @@ static int sequencer_unmute_exec(bContext *C, wmOperator *op) if(selected){ /* unmute unselected */ if (seq->flag & SELECT) { seq->flag &= ~SEQ_MUTE; + seq_update_sound(seq); } } else { if ((seq->flag & SELECT)==0) { seq->flag &= ~SEQ_MUTE; + seq_update_sound(seq); } } } @@ -2007,7 +2010,7 @@ static int sequencer_separate_images_exec(bContext *C, wmOperator *op) start_ofs += step; } - seq_free_sequence(ed, seq); + seq_free_sequence(scene, seq); seq = seq->next; } else { seq = seq->next; @@ -2130,7 +2133,7 @@ static int sequencer_meta_make_exec(bContext *C, wmOperator *op) while(seq) { if(seq->flag & SELECT) { tot++; - if (seq->type == SEQ_RAM_SOUND) { + if (seq->type == SEQ_SOUND) { BKE_report(op->reports, RPT_ERROR, "Can't make Meta Strip from audio"); return OPERATOR_CANCELLED;; } @@ -2242,7 +2245,7 @@ static int sequencer_meta_separate_exec(bContext *C, wmOperator *op) last_seq->seqbase.last= 0; BLI_remlink(ed->seqbasep, last_seq); - seq_free_sequence(ed, last_seq); + seq_free_sequence(scene, last_seq); /* emtpy meta strip, delete all effects depending on it */ for(seq=ed->seqbasep->first; seq; seq=seq->next) diff --git a/source/blender/editors/space_sequencer/sequencer_select.c b/source/blender/editors/space_sequencer/sequencer_select.c index 335652235c6..dda5837e5f5 100644 --- a/source/blender/editors/space_sequencer/sequencer_select.c +++ b/source/blender/editors/space_sequencer/sequencer_select.c @@ -153,7 +153,7 @@ void select_single_seq(Scene *scene, Sequence *seq, int deselect_all) /* BRING B if(seq->strip) strncpy(ed->act_imagedir, seq->strip->dir, FILE_MAXDIR-1); } - else if((seq->type==SEQ_HD_SOUND) || (seq->type==SEQ_RAM_SOUND)) { + else if(seq->type==SEQ_SOUND) { if(seq->strip) strncpy(ed->act_sounddir, seq->strip->dir, FILE_MAXDIR-1); } @@ -336,7 +336,7 @@ static int sequencer_select_invoke(bContext *C, wmOperator *op, wmEvent *event) strncpy(ed->act_imagedir, seq->strip->dir, FILE_MAXDIR-1); } } else - if (seq->type == SEQ_HD_SOUND || seq->type == SEQ_RAM_SOUND) { + if (seq->type == SEQ_SOUND) { if(seq->strip) { strncpy(ed->act_sounddir, seq->strip->dir, FILE_MAXDIR-1); } diff --git a/source/blender/editors/space_text/space_text.c b/source/blender/editors/space_text/space_text.c index a9c0d3ff76b..4394fbfe1f5 100644 --- a/source/blender/editors/space_text/space_text.c +++ b/source/blender/editors/space_text/space_text.c @@ -210,21 +210,28 @@ static void text_keymap(struct wmWindowManager *wm) WM_keymap_add_item(keymap, "TEXT_OT_open", OKEY, KM_PRESS, KM_ALT, 0); WM_keymap_add_item(keymap, "TEXT_OT_reload", RKEY, KM_PRESS, KM_ALT, 0); WM_keymap_add_item(keymap, "TEXT_OT_save", SKEY, KM_PRESS, KM_ALT, 0); + WM_keymap_add_item(keymap, "TEXT_OT_save", SKEY, KM_PRESS, KM_ALT|KM_OSKEY, 0); + WM_keymap_add_item(keymap, "TEXT_OT_save_as", SKEY, KM_PRESS, KM_ALT|KM_SHIFT|KM_CTRL, 0); + WM_keymap_add_item(keymap, "TEXT_OT_save_as", SKEY, KM_PRESS, KM_ALT|KM_SHIFT|KM_OSKEY, 0); WM_keymap_add_item(keymap, "TEXT_OT_run_script", PKEY, KM_PRESS, KM_ALT, 0); WM_keymap_add_item(keymap, "TEXT_OT_cut", XKEY, KM_PRESS, KM_ALT, 0); WM_keymap_add_item(keymap, "TEXT_OT_cut", XKEY, KM_PRESS, KM_CTRL, 0); + WM_keymap_add_item(keymap, "TEXT_OT_cut", XKEY, KM_PRESS, KM_OSKEY, 0); WM_keymap_add_item(keymap, "TEXT_OT_copy", CKEY, KM_PRESS, KM_ALT, 0); WM_keymap_add_item(keymap, "TEXT_OT_copy", CKEY, KM_PRESS, KM_CTRL, 0); + WM_keymap_add_item(keymap, "TEXT_OT_copy", CKEY, KM_PRESS, KM_OSKEY, 0); WM_keymap_add_item(keymap, "TEXT_OT_paste", VKEY, KM_PRESS, KM_ALT, 0); WM_keymap_add_item(keymap, "TEXT_OT_paste", VKEY, KM_PRESS, KM_CTRL, 0); + WM_keymap_add_item(keymap, "TEXT_OT_paste", VKEY, KM_PRESS, KM_OSKEY, 0); if(U.uiflag & USER_MMB_PASTE) // XXX not dynamic RNA_boolean_set(WM_keymap_add_item(keymap, "TEXT_OT_paste", MIDDLEMOUSE, KM_PRESS, 0, 0)->ptr, "selection", 1); WM_keymap_add_item(keymap, "TEXT_OT_jump", JKEY, KM_PRESS, KM_ALT, 0); WM_keymap_add_item(keymap, "TEXT_OT_find", FKEY, KM_PRESS, KM_ALT, 0); + WM_keymap_add_item(keymap, "TEXT_OT_find", FKEY, KM_PRESS, KM_OSKEY, 0); WM_keymap_add_item(keymap, "TEXT_OT_properties", FKEY, KM_PRESS, KM_ALT, 0); WM_keymap_add_item(keymap, "TEXT_OT_properties", FKEY, KM_PRESS, KM_CTRL, 0); WM_keymap_add_item(keymap, "TEXT_OT_replace", HKEY, KM_PRESS, KM_ALT, 0); @@ -233,6 +240,7 @@ static void text_keymap(struct wmWindowManager *wm) WM_keymap_add_item(keymap, "TEXT_OT_to_3d_object", MKEY, KM_PRESS, KM_ALT, 0); WM_keymap_add_item(keymap, "TEXT_OT_select_all", AKEY, KM_PRESS, KM_CTRL, 0); + WM_keymap_add_item(keymap, "TEXT_OT_select_all", AKEY, KM_PRESS, KM_OSKEY, 0); WM_keymap_add_item(keymap, "TEXT_OT_indent", TABKEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "TEXT_OT_unindent", TABKEY, KM_PRESS, KM_SHIFT, 0); diff --git a/source/blender/editors/space_text/text_header.c b/source/blender/editors/space_text/text_header.c index c761587198f..089436cfcf9 100644 --- a/source/blender/editors/space_text/text_header.c +++ b/source/blender/editors/space_text/text_header.c @@ -186,12 +186,18 @@ ARegion *text_has_properties_region(ScrArea *sa) return arnew; } -static int properties_poll(bContext *C) +void text_toggle_properties_region(bContext *C, ScrArea *sa, ARegion *ar) { - SpaceText *st= CTX_wm_space_text(C); - Text *text= CTX_data_edit_text(C); + ar->flag ^= RGN_FLAG_HIDDEN; + ar->v2d.flag &= ~V2D_IS_INITIALISED; /* XXX should become hide/unhide api? */ + + ED_area_initialize(CTX_wm_manager(C), CTX_wm_window(C), sa); + ED_area_tag_redraw(sa); +} - return (st && text); +static int properties_poll(bContext *C) +{ + return (CTX_wm_space_text(C) != NULL); } static int properties_exec(bContext *C, wmOperator *op) @@ -199,13 +205,8 @@ static int properties_exec(bContext *C, wmOperator *op) ScrArea *sa= CTX_wm_area(C); ARegion *ar= text_has_properties_region(sa); - if(ar) { - ar->flag ^= RGN_FLAG_HIDDEN; - ar->v2d.flag &= ~V2D_IS_INITIALISED; /* XXX should become hide/unhide api? */ - - ED_area_initialize(CTX_wm_manager(C), CTX_wm_window(C), sa); - ED_area_tag_redraw(sa); - } + if(ar) + text_toggle_properties_region(C, sa, ar); return OPERATOR_FINISHED; } @@ -214,6 +215,7 @@ void TEXT_OT_properties(wmOperatorType *ot) { /* identifiers */ ot->name= "Properties"; + ot->description= "Toggle text properties panel."; ot->idname= "TEXT_OT_properties"; /* api callbacks */ diff --git a/source/blender/editors/space_text/text_ops.c b/source/blender/editors/space_text/text_ops.c index 4c9f47ed170..7e514ea723a 100644 --- a/source/blender/editors/space_text/text_ops.c +++ b/source/blender/editors/space_text/text_ops.c @@ -176,6 +176,7 @@ void TEXT_OT_new(wmOperatorType *ot) { /* identifiers */ ot->name= "New"; + ot->description= "Create a new text data block."; ot->idname= "TEXT_OT_new"; /* api callbacks */ @@ -223,6 +224,7 @@ void TEXT_OT_open(wmOperatorType *ot) { /* identifiers */ ot->name= "Open"; + ot->description= "Open a new text data block."; ot->idname= "TEXT_OT_open"; /* api callbacks */ @@ -260,6 +262,7 @@ void TEXT_OT_reload(wmOperatorType *ot) { /* identifiers */ ot->name= "Reload"; + ot->description= "Reload active text data block from its file."; ot->idname= "TEXT_OT_reload"; /* api callbacks */ @@ -337,6 +340,7 @@ void TEXT_OT_unlink(wmOperatorType *ot) { /* identifiers */ ot->name= "Unlink"; + ot->description= "Unlink active text data block."; ot->idname= "TEXT_OT_unlink"; /* api callbacks */ @@ -367,6 +371,7 @@ void TEXT_OT_make_internal(wmOperatorType *ot) { /* identifiers */ ot->name= "Make Internal"; + ot->description= "Make active text file internal."; ot->idname= "TEXT_OT_make_internal"; /* api callbacks */ @@ -435,6 +440,7 @@ void TEXT_OT_save(wmOperatorType *ot) { /* identifiers */ ot->name= "Save"; + ot->description= "Save active text data block."; ot->idname= "TEXT_OT_save"; /* api callbacks */ @@ -490,6 +496,7 @@ void TEXT_OT_save_as(wmOperatorType *ot) { /* identifiers */ ot->name= "Save As"; + ot->description= "Save active text file with options."; ot->idname= "TEXT_OT_save_as"; /* api callbacks */ @@ -527,6 +534,7 @@ void TEXT_OT_run_script(wmOperatorType *ot) { /* identifiers */ ot->name= "Run Script"; + ot->description= "Run active script."; ot->idname= "TEXT_OT_run_script"; /* api callbacks */ @@ -583,6 +591,7 @@ void TEXT_OT_refresh_pyconstraints(wmOperatorType *ot) { /* identifiers */ ot->name= "Refresh PyConstraints"; + ot->description= "Refresh all pyconstraints."; ot->idname= "TEXT_OT_refresh_pyconstraints"; /* api callbacks */ @@ -704,6 +713,7 @@ void TEXT_OT_paste(wmOperatorType *ot) { /* identifiers */ ot->name= "Paste"; + ot->description= "Paste text from clipboard."; ot->idname= "TEXT_OT_paste"; /* api callbacks */ @@ -744,6 +754,7 @@ void TEXT_OT_copy(wmOperatorType *ot) { /* identifiers */ ot->name= "Copy"; + ot->description= "Copy selected text to clipboard."; ot->idname= "TEXT_OT_copy"; /* api callbacks */ @@ -774,6 +785,7 @@ void TEXT_OT_cut(wmOperatorType *ot) { /* identifiers */ ot->name= "Cut"; + ot->description= "Cut selected text to clipboard."; ot->idname= "TEXT_OT_cut"; /* api callbacks */ @@ -809,6 +821,7 @@ void TEXT_OT_indent(wmOperatorType *ot) { /* identifiers */ ot->name= "Indent"; + ot->description= "Indent selected text."; ot->idname= "TEXT_OT_indent"; /* api callbacks */ @@ -844,6 +857,7 @@ void TEXT_OT_unindent(wmOperatorType *ot) { /* identifiers */ ot->name= "Unindent"; + ot->description= "Unindent selected text."; ot->idname= "TEXT_OT_unindent"; /* api callbacks */ @@ -884,6 +898,7 @@ void TEXT_OT_line_break(wmOperatorType *ot) { /* identifiers */ ot->name= "Line Break"; + ot->description= "Insert line break at cursor position."; ot->idname= "TEXT_OT_line_break"; /* api callbacks */ @@ -916,6 +931,7 @@ void TEXT_OT_comment(wmOperatorType *ot) { /* identifiers */ ot->name= "Comment"; + ot->description= "Convert selected text to comment."; ot->idname= "TEXT_OT_comment"; /* api callbacks */ @@ -949,6 +965,7 @@ void TEXT_OT_uncomment(wmOperatorType *ot) { /* identifiers */ ot->name= "Uncomment"; + ot->description= "Convert selected comment to text."; ot->idname= "TEXT_OT_uncomment"; /* api callbacks */ @@ -1090,6 +1107,7 @@ void TEXT_OT_convert_whitespace(wmOperatorType *ot) { /* identifiers */ ot->name= "Convert Whitespace"; + ot->description= "Convert whitespaces by type."; ot->idname= "TEXT_OT_convert_whitespace"; /* api callbacks */ @@ -1120,6 +1138,7 @@ void TEXT_OT_select_all(wmOperatorType *ot) { /* identifiers */ ot->name= "Select All"; + ot->description= "Select all text."; ot->idname= "TEXT_OT_select_all"; /* api callbacks */ @@ -1147,6 +1166,7 @@ void TEXT_OT_select_line(wmOperatorType *ot) { /* identifiers */ ot->name= "Select Line"; + ot->description= "Select text by line."; ot->idname= "TEXT_OT_select_line"; /* api clinebacks */ @@ -1184,6 +1204,7 @@ void TEXT_OT_previous_marker(wmOperatorType *ot) { /* identifiers */ ot->name= "Previous Marker"; + ot->description= "Move to previous marker."; ot->idname= "TEXT_OT_previous_marker"; /* api callbacks */ @@ -1221,6 +1242,7 @@ void TEXT_OT_next_marker(wmOperatorType *ot) { /* identifiers */ ot->name= "Next Marker"; + ot->description= "Move to next marker"; ot->idname= "TEXT_OT_next_marker"; /* api callbacks */ @@ -1248,6 +1270,7 @@ void TEXT_OT_markers_clear(wmOperatorType *ot) { /* identifiers */ ot->name= "Clear All Markers"; + ot->description= "Clear all markers."; ot->idname= "TEXT_OT_markers_clear"; /* api callbacks */ @@ -1531,6 +1554,7 @@ void TEXT_OT_move(wmOperatorType *ot) { /* identifiers */ ot->name= "Move Cursor"; + ot->description= "Move cursor to position type."; ot->idname= "TEXT_OT_move"; /* api callbacks */ @@ -1557,6 +1581,7 @@ void TEXT_OT_move_select(wmOperatorType *ot) { /* identifiers */ ot->name= "Move Select"; + ot->description= "Make selection from current cursor position to new cursor position type."; ot->idname= "TEXT_OT_move_select"; /* api callbacks */ @@ -1596,6 +1621,7 @@ void TEXT_OT_jump(wmOperatorType *ot) { /* identifiers */ ot->name= "Jump"; + ot->description= "Jump cursor to line."; ot->idname= "TEXT_OT_jump"; /* api callbacks */ @@ -1648,6 +1674,7 @@ void TEXT_OT_delete(wmOperatorType *ot) { /* identifiers */ ot->name= "Delete"; + ot->description= "Delete text by cursor position."; ot->idname= "TEXT_OT_delete"; /* api callbacks */ @@ -1828,6 +1855,10 @@ void TEXT_OT_scroll(wmOperatorType *ot) { /* identifiers */ ot->name= "Scroll"; + /*don't really see the difference between this and + scroll_bar. Both do basically the same thing (aside + from keymaps).*/ + ot->description= "Scroll text screen."; ot->idname= "TEXT_OT_scroll"; /* api callbacks */ @@ -1876,6 +1907,10 @@ void TEXT_OT_scroll_bar(wmOperatorType *ot) { /* identifiers */ ot->name= "Scrollbar"; + /*don't really see the difference between this and + scroll. Both do basically the same thing (aside + from keymaps).*/ + ot->description= "Scroll text screen."; ot->idname= "TEXT_OT_scroll_bar"; /* api callbacks */ @@ -2151,6 +2186,7 @@ void TEXT_OT_cursor_set(wmOperatorType *ot) { /* identifiers */ ot->name= "Set Cursor"; + ot->description= "Set cursor selection."; ot->idname= "TEXT_OT_cursor_set"; /* api callbacks */ @@ -2274,6 +2310,7 @@ void TEXT_OT_insert(wmOperatorType *ot) { /* identifiers */ ot->name= "Insert"; + ot->description= "Insert text at cursor position."; ot->idname= "TEXT_OT_insert"; /* api callbacks */ @@ -2378,6 +2415,7 @@ void TEXT_OT_find(wmOperatorType *ot) { /* identifiers */ ot->name= "Find"; + ot->description= "Find specified text."; ot->idname= "TEXT_OT_find"; /* api callbacks */ @@ -2396,6 +2434,7 @@ void TEXT_OT_replace(wmOperatorType *ot) { /* identifiers */ ot->name= "Replace"; + ot->description= "Replace text with specified text."; ot->idname= "TEXT_OT_replace"; /* api callbacks */ @@ -2414,6 +2453,7 @@ void TEXT_OT_mark_all(wmOperatorType *ot) { /* identifiers */ ot->name= "Mark All"; + ot->description= "Mark all specified text."; ot->idname= "TEXT_OT_mark_all"; /* api callbacks */ @@ -2443,6 +2483,7 @@ void TEXT_OT_find_set_selected(wmOperatorType *ot) { /* identifiers */ ot->name= "Find Set Selected"; + ot->description= "Find specified text and set as selected."; ot->idname= "TEXT_OT_find_set_selected"; /* api callbacks */ @@ -2469,6 +2510,7 @@ void TEXT_OT_replace_set_selected(wmOperatorType *ot) { /* identifiers */ ot->name= "Replace Set Selected"; + ot->description= "Replace text with specified text and set as selected."; ot->idname= "TEXT_OT_replace_set_selected"; /* api callbacks */ @@ -2631,6 +2673,7 @@ void TEXT_OT_to_3d_object(wmOperatorType *ot) { /* identifiers */ ot->name= "To 3D Object"; + ot->description= "Create 3d text object from active text data block."; ot->idname= "TEXT_OT_to_3d_object"; /* api callbacks */ diff --git a/source/blender/editors/space_time/space_time.c b/source/blender/editors/space_time/space_time.c index 8445f1b47e7..ce6846a4489 100644 --- a/source/blender/editors/space_time/space_time.c +++ b/source/blender/editors/space_time/space_time.c @@ -260,11 +260,15 @@ static void time_main_area_listener(ARegion *ar, wmNotifier *wmn) { /* context changes */ switch(wmn->category) { + case NC_ANIMATION: + ED_region_tag_redraw(ar); + break; case NC_SCENE: /* any scene change for now */ ED_region_tag_redraw(ar); break; + } } @@ -273,29 +277,12 @@ static void time_main_area_listener(ARegion *ar, wmNotifier *wmn) /* add handlers, stuff you only do once or on area/region changes */ static void time_header_area_init(wmWindowManager *wm, ARegion *ar) { - UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_HEADER, ar->winx, ar->winy); + ED_region_header_init(ar); } static void time_header_area_draw(const bContext *C, ARegion *ar) { - float col[3]; - - /* clear */ - if(ED_screen_area_active(C)) - UI_GetThemeColor3fv(TH_HEADER, col); - else - UI_GetThemeColor3fv(TH_HEADERDESEL, col); - - glClearColor(col[0], col[1], col[2], 0.0); - glClear(GL_COLOR_BUFFER_BIT); - - /* set view2d view matrix for scrolling (without scrollers) */ - UI_view2d_view_ortho(C, &ar->v2d); - - time_header_buttons(C, ar); - - /* restore view matrix? */ - UI_view2d_view_restore(C); + ED_region_header(C, ar); } static void time_header_area_listener(ARegion *ar, wmNotifier *wmn) @@ -372,8 +359,6 @@ static SpaceLink *time_new(const bContext *C) static void time_free(SpaceLink *sl) { } - - /* spacetype; init callback in ED_area_initialize() */ /* init is called to (re)initialize an existing editor (file read, screen changes) */ /* validate spacedata, add own area level handlers */ diff --git a/source/blender/editors/space_time/time_header.c b/source/blender/editors/space_time/time_header.c deleted file mode 100644 index b4e3c087360..00000000000 --- a/source/blender/editors/space_time/time_header.c +++ /dev/null @@ -1,572 +0,0 @@ -/** - * $Id$ - * - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * - * The Original Code is Copyright (C) 2008 Blender Foundation. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): none yet. - * - * ***** END GPL LICENSE BLOCK ***** - */ - -#include <string.h> -#include <stdio.h> - -#include "DNA_space_types.h" -#include "DNA_scene_types.h" -#include "DNA_screen_types.h" -#include "DNA_windowmanager_types.h" -#include "DNA_userdef_types.h" - -#include "MEM_guardedalloc.h" - -#include "BLI_blenlib.h" - -#include "BKE_context.h" -#include "BKE_global.h" -#include "BKE_screen.h" - -#include "ED_keyframing.h" -#include "ED_screen.h" -#include "ED_screen_types.h" -#include "ED_types.h" -#include "ED_util.h" - -#include "WM_api.h" -#include "WM_types.h" - -#include "RNA_access.h" - -#include "BIF_gl.h" -#include "BIF_glutil.h" - -#include "UI_interface.h" -#include "UI_resources.h" -#include "UI_view2d.h" - -#include "ED_markers.h" - -#include "time_intern.h" - - -/* ************************ header time area region *********************** */ - -/* exported for use in screen_ops.c */ -ARegion *time_top_left_3dwindow(bScreen *screen) -{ - ARegion *aret= NULL; - ScrArea *sa; - int min= 10000; - - for(sa= screen->areabase.first; sa; sa= sa->next) { - if(sa->spacetype==SPACE_VIEW3D) { - ARegion *ar; - for(ar= sa->regionbase.first; ar; ar= ar->next) { - if(ar->regiontype==RGN_TYPE_WINDOW) { - if(ar->winrct.xmin - ar->winrct.ymin < min) { - aret= ar; - min= ar->winrct.xmin - ar->winrct.ymin; - } - } - } - } - } - return aret; -} - -static void do_time_redrawmenu(bContext *C, void *arg, int event) -{ - - if(event < 1001) { - bScreen *screen= CTX_wm_screen(C); - SpaceTime *stime= CTX_wm_space_time(C); - - stime->redraws ^= event; - - if(screen->animtimer) { - wmTimer *wt= screen->animtimer; - ScreenAnimData *sad= wt->customdata; - - sad->redraws= stime->redraws; - sad->ar= NULL; - if(stime->redraws & TIME_REGION) - sad->ar= time_top_left_3dwindow(screen); - } - } -} - - -static uiBlock *time_redrawmenu(bContext *C, ARegion *ar, void *arg_unused) -{ - ScrArea *curarea= CTX_wm_area(C); - SpaceTime *stime= CTX_wm_space_time(C); - uiBlock *block; - short yco= 0, menuwidth=120, icon; - - block= uiBeginBlock(C, ar, "header time_redrawmenu", UI_EMBOSSP); - uiBlockSetButmFunc(block, do_time_redrawmenu, NULL); - - if(stime->redraws & TIME_REGION) icon= ICON_CHECKBOX_HLT; - else icon= ICON_CHECKBOX_DEHLT; - uiDefIconTextBut(block, BUTM, 1, icon, "Top-Left 3D Window", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, TIME_REGION, ""); - - if(stime->redraws & TIME_ALL_3D_WIN) icon= ICON_CHECKBOX_HLT; - else icon= ICON_CHECKBOX_DEHLT; - uiDefIconTextBut(block, BUTM, 1, icon, "All 3D Windows", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, TIME_ALL_3D_WIN, ""); - - if(stime->redraws & TIME_ALL_ANIM_WIN) icon= ICON_CHECKBOX_HLT; - else icon= ICON_CHECKBOX_DEHLT; - uiDefIconTextBut(block, BUTM, 1, icon, "Animation Windows", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, TIME_ALL_ANIM_WIN, ""); - - if(stime->redraws & TIME_ALL_BUTS_WIN) icon= ICON_CHECKBOX_HLT; - else icon= ICON_CHECKBOX_DEHLT; - uiDefIconTextBut(block, BUTM, 1, icon, "Buttons Windows", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, TIME_ALL_BUTS_WIN, ""); - - if(stime->redraws & TIME_ALL_IMAGE_WIN) icon= ICON_CHECKBOX_HLT; - else icon= ICON_CHECKBOX_DEHLT; - uiDefIconTextBut(block, BUTM, 1, icon, "Image Windows", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, TIME_ALL_IMAGE_WIN, ""); - - /* Add sequencer only redraw*/ - if(stime->redraws & TIME_SEQ) icon= ICON_CHECKBOX_HLT; - else icon= ICON_CHECKBOX_DEHLT; - uiDefIconTextBut(block, BUTM, 1, icon, "Sequencer Windows", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, TIME_SEQ, ""); - - uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, ""); - - if(stime->redraws & TIME_CONTINUE_PHYSICS) icon= ICON_CHECKBOX_HLT; - else icon= ICON_CHECKBOX_DEHLT; - uiDefIconTextBut(block, BUTM, 1, icon, "Continue Physics", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, TIME_CONTINUE_PHYSICS, "During playblack, continue physics simulations regardless of the frame number"); - - if(curarea->headertype==HEADERTOP) { - uiBlockSetDirection(block, UI_DOWN); - } - else { - uiBlockSetDirection(block, UI_TOP); - uiBlockFlipOrder(block); - } - - uiTextBoundsBlock(block, 50); - uiEndBlock(C, block); - - return block; -} - -static void do_time_viewmenu(bContext *C, void *arg, int event) -{ - ScrArea *curarea= CTX_wm_area(C); - SpaceTime *stime= CTX_wm_space_time(C); - View2D *v2d= UI_view2d_fromcontext_rwin(C); - Scene *scene= CTX_data_scene(C); - int first; - - switch(event) { - case 2: /* Play Back Animation */ - //if(!has_screenhandler(G.curscreen, SCREEN_HANDLER_ANIM)) - // start_animated_screen(stime); - break; - case 3: /* View All */ - if(v2d) { - first= scene->r.sfra; - if(first >= scene->r.efra) first= scene->r.efra; - v2d->cur.xmin=v2d->tot.xmin= (float)first-2; - v2d->cur.xmax=v2d->tot.xmax= (float)scene->r.efra+2; - - ED_area_tag_redraw(curarea); - } - break; - case 4: /* Maximize Window */ - /* using event B_FULL */ - break; - case 5: /* show time or frames */ - stime->flag ^= TIME_DRAWFRAMES; - ED_area_tag_redraw(curarea); - break; - case 6: - //nextprev_marker(1); - break; - case 7: - //nextprev_marker(-1); - break; - case 10: - //timeline_frame_to_center(); - break; - case 11: - if(v2d) { - v2d->flag ^= V2D_VIEWSYNC_SCREEN_TIME; - UI_view2d_sync(CTX_wm_screen(C), CTX_wm_area(C), v2d, V2D_LOCK_SET); - } - break; - case 12: /* only show keyframes from selected data */ - stime->flag ^= TIME_ONLYACTSEL; - ED_area_tag_redraw(curarea); - break; - } -} - -static uiBlock *time_viewmenu(bContext *C, ARegion *ar, void *arg_unused) -{ - ScrArea *curarea= CTX_wm_area(C); - SpaceTime *stime= CTX_wm_space_time(C); - View2D *v2d= UI_view2d_fromcontext_rwin(C); - uiBlock *block; - short yco= 0, menuwidth=120; - - block= uiBeginBlock(C, ar, "time_viewmenu", UI_EMBOSSP); - uiBlockSetButmFunc(block, do_time_viewmenu, NULL); - - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Play Back Animation", 0, yco-=20, - menuwidth, 19, NULL, 0.0, 0.0, 1, 2, ""); - - uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, ""); - - if(stime->flag & TIME_DRAWFRAMES) - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Show Seconds|Ctrl T", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 5, ""); - else - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Show Frames|Ctrl T", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 5, ""); - - uiDefIconTextBut(block, BUTM, 1, (stime->flag & TIME_ONLYACTSEL)?ICON_CHECKBOX_HLT:ICON_CHECKBOX_DEHLT, - "Only Selected Data Keys|", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 12, ""); - - uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, ""); - - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Jump To Next Marker|PageUp", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 6, ""); - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Jump To Prev Marker|PageDown", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 7, ""); - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Jump To Next Key|Ctrl PageUp", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 8, ""); - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Jump To Prev Key|Ctrl PageDown", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 9, ""); - - uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, ""); - - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Center View|C", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 10, ""); - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "View All|Home", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 3, ""); - uiDefIconTextBut(block, BUTM, 1, (v2d->flag & V2D_VIEWSYNC_SCREEN_TIME)?ICON_CHECKBOX_HLT:ICON_CHECKBOX_DEHLT, - "Lock Time to Other Windows|", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 11, ""); - -// if (!curarea->full) -// uiDefIconTextBut(block, BUTM, B_FULL, ICON_BLANK1, "Maximize Window|Ctrl UpArrow", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 4, ""); -// else -// uiDefIconTextBut(block, BUTM, B_FULL, ICON_BLANK1, "Tile Window|Ctrl DownArrow", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 4, ""); - - if(curarea->headertype==HEADERTOP) { - uiBlockSetDirection(block, UI_DOWN); - } - else { - uiBlockSetDirection(block, UI_TOP); - uiBlockFlipOrder(block); - } - - uiTextBoundsBlock(block, 50); - uiEndBlock(C, block); - - return block; -} - -static void do_time_framemenu(bContext *C, void *arg, int event) -{ - Scene *scene= CTX_data_scene(C); - - switch(event) { - case 1: /*Set as Start */ - if (scene->r.psfra) { - if (scene->r.pefra < scene->r.cfra) - scene->r.pefra= scene->r.cfra; - scene->r.psfra= scene->r.cfra; - } - else - scene->r.sfra = scene->r.cfra; - WM_event_add_notifier(C, NC_SCENE|ND_RENDER_OPTIONS, scene); - break; - case 2: /* Set as End */ - if (scene->r.psfra) { - if (scene->r.cfra < scene->r.psfra) - scene->r.psfra= scene->r.cfra; - scene->r.pefra= scene->r.cfra; - } - else - scene->r.efra = scene->r.cfra; - WM_event_add_notifier(C, NC_SCENE|ND_RENDER_OPTIONS, scene); - break; - case 3: /* Rename Marker */ - //rename_marker(); - break; - } -} - -static uiBlock *time_framemenu(bContext *C, ARegion *ar, void *arg_unused) -{ - ScrArea *curarea= CTX_wm_area(C); - uiBlock *block; - short yco= 0, menuwidth=120; - - block= uiBeginBlock(C, ar, "time_framemenu", UI_EMBOSSP); - uiBlockSetButmFunc(block, do_time_framemenu, NULL); - - uiDefIconTextButO(block, BUTM, "MARKER_OT_add", WM_OP_EXEC_REGION_WIN, ICON_BLANK1, "Add Marker", - 0, yco-=2, menuwidth, 19, ""); - uiDefIconTextButO(block, BUTM, "MARKER_OT_duplicate", WM_OP_EXEC_REGION_WIN, ICON_BLANK1, "Duplicate Marker", - 0, yco-=20, menuwidth, 19, ""); - uiDefIconTextButO(block, BUTM, "MARKER_OT_delete", WM_OP_EXEC_REGION_WIN, ICON_BLANK1, "Delete Marker", - 0, yco-=20, menuwidth, 19, ""); - - uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, ""); - - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Name Marker|Ctrl M", - 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 3, ""); - uiDefIconTextButO(block, BUTM, "MARKER_OT_move", WM_OP_INVOKE_REGION_WIN, ICON_BLANK1, "Grab/Move Marker", - 0, yco-=20, menuwidth, 19, ""); - - uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, ""); - - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Set as Start|S", - 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 1, ""); - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Set as End|E", - 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 2, ""); - - if(curarea->headertype==HEADERTOP) { - uiBlockSetDirection(block, UI_DOWN); - } - else { - uiBlockSetDirection(block, UI_TOP); - uiBlockFlipOrder(block); - } - - uiTextBoundsBlock(block, 50); - uiEndBlock(C, block); - - return block; -} - - -#define B_REDRAWALL 750 -#define B_TL_PLAY 752 -#define B_TL_RPLAY 760 -#define B_TL_STOP 756 -#define B_TL_PREVIEWON 757 - -#define B_FLIPINFOMENU 0 -#define B_NEWFRAME 0 -#define B_DIFF 0 - - -void do_time_buttons(bContext *C, void *arg, int event) -{ - Scene *scene= CTX_data_scene(C); - - switch(event) { - case B_REDRAWALL: - WM_event_add_notifier(C, NC_SCENE|ND_RENDER_OPTIONS, scene); - break; - case B_NEWFRAME: - WM_event_add_notifier(C, NC_SCENE|ND_FRAME, scene); - break; - case B_TL_PREVIEWON: - if (scene->r.psfra) { - /* turn on preview range */ - scene->r.psfra= scene->r.sfra; - scene->r.pefra= scene->r.efra; - } - else { - /* turn off preview range */ - scene->r.psfra= 0; - scene->r.pefra= 0; - } - //BIF_undo_push("Set anim-preview range"); - WM_event_add_notifier(C, NC_SCENE|ND_RENDER_OPTIONS, scene); - break; - } -} - - -void time_header_buttons(const bContext *C, ARegion *ar) -{ - ScrArea *sa= CTX_wm_area(C); - SpaceTime *stime= CTX_wm_space_time(C); - Scene *scene= CTX_data_scene(C); - wmTimer *animtimer= CTX_wm_screen(C)->animtimer; - uiBlock *block; - uiBut *but; - int xco, yco= 3; - char *menustr= NULL; - - block= uiBeginBlock(C, ar, "header buttons", UI_EMBOSS); - uiBlockSetHandleFunc(block, do_time_buttons, NULL); - - xco= ED_area_header_standardbuttons(C, block, yco); - - if((sa->flag & HEADER_NO_PULLDOWN)==0) { - int xmax; - - xmax= GetButStringLength("View"); - uiDefPulldownBut(block, time_viewmenu, sa, - "View", xco, yco, xmax-3, 20, ""); - xco+= xmax; - xmax= GetButStringLength("Frame"); - uiDefPulldownBut(block, time_framemenu, sa, - "Frame", xco, yco, xmax-3, 20, ""); - xco+= xmax; - - xmax= GetButStringLength("Playback"); - uiDefPulldownBut(block, time_redrawmenu, sa, - "Playback", xco, yco, xmax-3, 20, ""); - xco+= xmax; - } - - uiBlockSetEmboss(block, UI_EMBOSS); - - uiBlockBeginAlign(block); - - uiDefButI(block, TOG, B_TL_PREVIEWON,"PR", - xco,yco, XIC*2, YIC, - &scene->r.psfra,0, 1, 0, 0, - "Show settings for frame range of animation preview"); - - xco += XIC*2; - - if (scene->r.psfra) { - uiDefButI(block, NUM, B_REDRAWALL,"Start:", - xco,yco, (int)4.5*XIC, YIC, - &scene->r.psfra,MINFRAMEF, MAXFRAMEF, 0, 0, - "The start frame of the animation preview (inclusive)"); - - xco += (int)(4.5*XIC); - - uiDefButI(block, NUM, B_REDRAWALL,"End:", - xco,yco, (int)4.5*XIC,YIC, - &scene->r.pefra,(float)PSFRA, MAXFRAMEF, 0, 0, - "The end frame of the animation preview (inclusive)"); - } - else { - uiDefButI(block, NUM, B_REDRAWALL,"Start:", - xco,yco, (int)4.5*XIC, YIC, - &scene->r.sfra,MINFRAMEF, MAXFRAMEF, 0, 0, - "The start frame of the animation (inclusive)"); - - xco += (short)(4.5*XIC); - - uiDefButI(block, NUM, B_REDRAWALL,"End:", - xco,yco, (int)4.5*XIC,YIC, - &scene->r.efra,(float)SFRA, MAXFRAMEF, 0, 0, - "The end frame of the animation (inclusive)"); - } - uiBlockEndAlign(block); - - xco += (short)(4.5 * XIC); - - /* MINAFRAMEF not MINFRAMEF, since MINAFRAMEF allows to set current frame negative - * to facilitate easier keyframing in some situations - */ - uiDefButI(block, NUM, B_NEWFRAME, "", - xco,yco, (int)3.5*XIC,YIC, - &(scene->r.cfra), MINAFRAMEF, MAXFRAMEF, 0, 0, - "Displays Current Frame of animation"); - - xco += (short)(3.5 * XIC); - - uiBlockBeginAlign(block); - - but= uiDefIconButO(block, BUT, "SCREEN_OT_frame_jump", WM_OP_INVOKE_REGION_WIN, ICON_REW, xco,yco,XIC,YIC, "Skip to Start frame (Shift DownArrow)"); - RNA_boolean_set(uiButGetOperatorPtrRNA(but), "end", 0); - xco+= XIC; - - but= uiDefIconButO(block, BUT, "SCREEN_OT_keyframe_jump", WM_OP_INVOKE_REGION_WIN, ICON_PREV_KEYFRAME, xco,yco,XIC,YIC, "Skip to previous keyframe (Ctrl PageDown)"); - RNA_boolean_set(uiButGetOperatorPtrRNA(but), "next", 0); - xco+= XIC; - - if (animtimer) { - /* pause button 2*size to keep buttons in place */ - but=uiDefIconButO(block, BUT, "SCREEN_OT_animation_play", WM_OP_INVOKE_REGION_WIN, ICON_PAUSE, xco,yco,XIC*2,YIC, "Stop Playing Timeline"); - - xco+= XIC; - } - else { - but=uiDefIconButO(block, BUT, "SCREEN_OT_animation_play", WM_OP_INVOKE_REGION_WIN, ICON_PLAY_REVERSE, xco,yco,XIC,YIC, "Play Timeline in Reverse"); - RNA_boolean_set(uiButGetOperatorPtrRNA(but), "reverse", 1); - xco+= XIC; - - but=uiDefIconButO(block, BUT, "SCREEN_OT_animation_play", WM_OP_INVOKE_REGION_WIN, ICON_PLAY, xco,yco,XIC,YIC, "Play Timeline"); - RNA_boolean_set(uiButGetOperatorPtrRNA(but), "reverse", 0); - } - xco+= XIC; - - but= uiDefIconButO(block, BUT, "SCREEN_OT_keyframe_jump", WM_OP_INVOKE_REGION_WIN, ICON_NEXT_KEYFRAME, xco,yco,XIC,YIC, "Skip to next keyframe (Ctrl PageUp)"); - RNA_boolean_set(uiButGetOperatorPtrRNA(but), "next", 1); - xco+= XIC; - - but= uiDefIconButO(block, BUT, "SCREEN_OT_frame_jump", WM_OP_INVOKE_REGION_WIN, ICON_FF, xco,yco,XIC,YIC, "Skip to End frame (Shift UpArrow)"); - RNA_boolean_set(uiButGetOperatorPtrRNA(but), "end", 1); - xco+= XIC; - uiBlockEndAlign(block); - - xco+= 1.5*XIC; - - uiBlockBeginAlign(block); - uiDefIconButBitS(block, TOG, AUTOKEY_ON, B_REDRAWALL, ICON_REC, - xco, yco, XIC, YIC, &(scene->toolsettings->autokey_mode), 0, 0, 0, 0, "Automatic keyframe insertion for Objects and Bones"); - xco+= XIC; - - if (IS_AUTOKEY_ON(scene)) { - uiDefButS(block, MENU, B_REDRAWALL, - "Auto-Keying Mode %t|Add/Replace Keys%x3|Replace Keys %x5", - xco, yco, (int)5.5*XIC, YIC, &(scene->toolsettings->autokey_mode), 0, 1, 0, 0, - "Mode of automatic keyframe insertion for Objects and Bones"); - xco+= (5.5*XIC); - - if (animtimer) { - uiDefButBitS(block, TOG, ANIMRECORD_FLAG_WITHNLA, B_REDRAWALL, "Layered", - xco,yco, XIC*2.5, YIC, - &(scene->toolsettings->autokey_flag),0, 1, 0, 0, - "Add a new NLA Track + Strip for every loop/pass made over the animation to allow non-destructive tweaking."); - xco+= (3*XIC); - } - } - else - xco+= 6; - - uiBlockEndAlign(block); - - menustr= ANIM_build_keyingsets_menu(&scene->keyingsets, 0); - uiDefButI(block, MENU, B_DIFF, - menustr, - xco, yco, (int)5.5*XIC, YIC, &(scene->active_keyingset), 0, 1, 0, 0, - "Active Keying Set (i.e. set of channels to Insert Keyframes for)"); - MEM_freeN(menustr); - xco+= (5.5*XIC); - - uiBlockBeginAlign(block); - uiDefIconButO(block, BUT, "ANIM_OT_delete_keyframe", WM_OP_INVOKE_REGION_WIN, ICON_KEY_DEHLT, xco,yco,XIC,YIC, "Delete Keyframes for the Active Keying Set (Alt-I)"); - xco += XIC; - uiDefIconButO(block, BUT, "ANIM_OT_insert_keyframe", WM_OP_INVOKE_REGION_WIN, ICON_KEY_HLT, xco,yco,XIC,YIC, "Insert Keyframes for the Active Keying Set (I)"); - xco += XIC; - uiBlockEndAlign(block); - - xco+= XIC; - - uiDefIconButBitI(block, TOG, TIME_WITH_SEQ_AUDIO, B_DIFF, ICON_SPEAKER, - xco, yco, XIC, YIC, &(stime->redraws), 0, 0, 0, 0, "Play back and sync with audio from Sequence Editor"); - - - /* always as last */ - UI_view2d_totRect_set(&ar->v2d, xco+XIC+80, (int)(ar->v2d.tot.ymax-ar->v2d.tot.ymin)); - - uiEndBlock(C, block); - uiDrawBlock(C, block); -} - - diff --git a/source/blender/editors/space_userpref/Makefile b/source/blender/editors/space_userpref/Makefile new file mode 100644 index 00000000000..be7206f51ce --- /dev/null +++ b/source/blender/editors/space_userpref/Makefile @@ -0,0 +1,55 @@ +# +# $Id$ +# +# ***** BEGIN GPL LICENSE BLOCK ***** +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software Foundation, +# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# +# The Original Code is Copyright (C) 2007 Blender Foundation +# All rights reserved. +# +# The Original Code is: all of this file. +# +# Contributor(s): none yet. +# +# ***** END GPL LICENSE BLOCK ***** +# +# Makes module object directory and bounces make to subdirectories. + +LIBNAME = ed_userpref +DIR = $(OCGDIR)/blender/$(LIBNAME) + +include nan_compile.mk + +CFLAGS += $(LEVEL_1_C_WARNINGS) + +CPPFLAGS += -I$(NAN_GLEW)/include +CPPFLAGS += -I$(OPENGL_HEADERS) + +# not very neat.... +CPPFLAGS += -I../../windowmanager +CPPFLAGS += -I../../blenloader +CPPFLAGS += -I../../blenkernel +CPPFLAGS += -I../../blenlib +CPPFLAGS += -I../../makesdna +CPPFLAGS += -I../../makesrna +CPPFLAGS += -I../../imbuf +CPPFLAGS += -I../../python +CPPFLAGS += -I../../blenfont +CPPFLAGS += -I$(NAN_GUARDEDALLOC)/include + +# own include + +CPPFLAGS += -I../include diff --git a/source/blender/editors/space_userpref/SConscript b/source/blender/editors/space_userpref/SConscript new file mode 100644 index 00000000000..1b808a5a7c0 --- /dev/null +++ b/source/blender/editors/space_userpref/SConscript @@ -0,0 +1,14 @@ +#!/usr/bin/python +Import ('env') + +sources = env.Glob('*.c') + +incs = '../include ../../blenlib ../../blenkernel ../../makesdna ../../makesrna ../../imbuf ../../blenfont' +incs += ' ../../windowmanager #/intern/guardedalloc #/extern/glew/include' + +defs = [] + +if env['WITH_BF_GAMEENGINE']: + defs.append('GAMEBLENDER=1') + +env.BlenderLib ( 'bf_editors_space_userpref', sources, Split(incs), defs, libtype=['core'], priority=[70] ) diff --git a/source/blender/editors/space_userpref/space_userpref.c b/source/blender/editors/space_userpref/space_userpref.c new file mode 100644 index 00000000000..8c9d723ce2c --- /dev/null +++ b/source/blender/editors/space_userpref/space_userpref.c @@ -0,0 +1,188 @@ +/** + * $Id: + * + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * The Original Code is Copyright (C) 2008 Blender Foundation. + * All rights reserved. + * + * + * Contributor(s): Blender Foundation + * + * ***** END GPL LICENSE BLOCK ***** + */ + +#include <string.h> +#include <stdio.h> + +#include "DNA_space_types.h" +#include "DNA_screen_types.h" + +#include "MEM_guardedalloc.h" + +#include "BLI_blenlib.h" + +#include "BKE_context.h" +#include "BKE_screen.h" + +#include "ED_space_api.h" +#include "ED_screen.h" + +#include "BIF_gl.h" + +#include "WM_api.h" +#include "WM_types.h" + +#include "userpref_intern.h" // own include + +/* ******************** default callbacks for userpref space ***************** */ + +static SpaceLink *userpref_new(const bContext *C) +{ + ARegion *ar; + SpaceUserPref *spref; + + spref= MEM_callocN(sizeof(SpaceUserPref), "inituserpref"); + spref->spacetype= SPACE_USERPREF; + + /* header */ + ar= MEM_callocN(sizeof(ARegion), "header for userpref"); + + BLI_addtail(&spref->regionbase, ar); + ar->regiontype= RGN_TYPE_HEADER; + ar->alignment= RGN_ALIGN_BOTTOM; + + /* main area */ + ar= MEM_callocN(sizeof(ARegion), "main area for userpref"); + + BLI_addtail(&spref->regionbase, ar); + ar->regiontype= RGN_TYPE_WINDOW; + + return (SpaceLink *)spref; +} + +/* not spacelink itself */ +static void userpref_free(SpaceLink *sl) +{ +// SpaceUserPref *spref= (SpaceUserPref*) sl; + +} + + +/* spacetype; init callback */ +static void userpref_init(struct wmWindowManager *wm, ScrArea *sa) +{ + +} + +static SpaceLink *userpref_duplicate(SpaceLink *sl) +{ + SpaceUserPref *sprefn= MEM_dupallocN(sl); + + /* clear or remove stuff from old */ + + return (SpaceLink *)sprefn; +} + + + +/* add handlers, stuff you only do once or on area/region changes */ +static void userpref_main_area_init(wmWindowManager *wm, ARegion *ar) +{ + ED_region_panels_init(wm, ar); +} + +static void userpref_main_area_draw(const bContext *C, ARegion *ar) +{ + ED_region_panels(C, ar, 1, NULL, -1); +} + +void userpref_operatortypes(void) +{ +} + +void userpref_keymap(struct wmWindowManager *wm) +{ + +} + +/* add handlers, stuff you only do once or on area/region changes */ +static void userpref_header_area_init(wmWindowManager *wm, ARegion *ar) +{ + ED_region_header_init(ar); +} + +static void userpref_header_area_draw(const bContext *C, ARegion *ar) +{ + ED_region_header(C, ar); +} + +static void userpref_main_area_listener(ARegion *ar, wmNotifier *wmn) +{ + /* context changes */ +} + +static void userpref_header_listener(ARegion *ar, wmNotifier *wmn) +{ + /* context changes */ + switch(wmn->category) { + default: + break; + } + +} + +/* only called once, from space/spacetypes.c */ +void ED_spacetype_userpref(void) +{ + SpaceType *st= MEM_callocN(sizeof(SpaceType), "spacetype userpref"); + ARegionType *art; + + st->spaceid= SPACE_USERPREF; + + st->new= userpref_new; + st->free= userpref_free; + st->init= userpref_init; + st->duplicate= userpref_duplicate; + st->operatortypes= userpref_operatortypes; + st->keymap= userpref_keymap; + + /* regions: main window */ + art= MEM_callocN(sizeof(ARegionType), "spacetype userpref region"); + art->regionid = RGN_TYPE_WINDOW; + art->init= userpref_main_area_init; + art->draw= userpref_main_area_draw; + art->listener= userpref_main_area_listener; + art->keymapflag= ED_KEYMAP_UI|ED_KEYMAP_VIEW2D; + + BLI_addhead(&st->regiontypes, art); + + /* regions: header */ + art= MEM_callocN(sizeof(ARegionType), "spacetype userpref region"); + art->regionid = RGN_TYPE_HEADER; + art->minsizey= HEADERY; + art->keymapflag= ED_KEYMAP_UI|ED_KEYMAP_VIEW2D; + art->listener= userpref_header_listener; + art->init= userpref_header_area_init; + art->draw= userpref_header_area_draw; + + BLI_addhead(&st->regiontypes, art); + + + BKE_spacetype_register(st); +} + diff --git a/source/blender/editors/space_userpref/userpref_intern.h b/source/blender/editors/space_userpref/userpref_intern.h new file mode 100644 index 00000000000..596c2675b01 --- /dev/null +++ b/source/blender/editors/space_userpref/userpref_intern.h @@ -0,0 +1,34 @@ +/** + * $Id: + * + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * The Original Code is Copyright (C) 2008 Blender Foundation. + * All rights reserved. + * + * + * Contributor(s): Blender Foundation + * + * ***** END GPL LICENSE BLOCK ***** + */ +#ifndef ED_USERPREF_INTERN_H +#define ED_USERPREF_INTERN_H + +/* internal exports only */ + +#endif /* ED_USERPREF_INTERN_H */ + diff --git a/source/blender/editors/space_userpref/userpref_ops.c b/source/blender/editors/space_userpref/userpref_ops.c new file mode 100644 index 00000000000..91a6651bd92 --- /dev/null +++ b/source/blender/editors/space_userpref/userpref_ops.c @@ -0,0 +1,33 @@ +/** + * $Id$ + * + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * The Original Code is Copyright (C) 2008 Blender Foundation. + * All rights reserved. + * + * + * Contributor(s): Blender Foundation + * + * ***** END GPL LICENSE BLOCK ***** + */ + +#include <string.h> +#include <stdio.h> + +#include "userpref_intern.h" + diff --git a/source/blender/editors/space_view3d/drawarmature.c b/source/blender/editors/space_view3d/drawarmature.c index 5a9790390b7..a5718386554 100644 --- a/source/blender/editors/space_view3d/drawarmature.c +++ b/source/blender/editors/space_view3d/drawarmature.c @@ -2271,7 +2271,7 @@ static void draw_ghost_poses_range(Scene *scene, View3D *v3d, RegionView3D *rv3d range= (float)(end - start); /* store values */ - ob->flag &= ~OB_POSEMODE; + ob->mode &= ~OB_MODE_POSE; cfrao= CFRA; flago= arm->flag; arm->flag &= ~(ARM_DRAWNAMES|ARM_DRAWAXES); @@ -2308,7 +2308,7 @@ static void draw_ghost_poses_range(Scene *scene, View3D *v3d, RegionView3D *rv3d ob->pose= poseo; arm->flag= flago; armature_rebuild_pose(ob, ob->data); - ob->flag |= OB_POSEMODE; + ob->mode |= OB_MODE_POSE; ob->ipoflag= ipoflago; } @@ -2349,7 +2349,7 @@ static void draw_ghost_poses_keys(Scene *scene, View3D *v3d, RegionView3D *rv3d, if (range == 0) return; /* store values */ - ob->flag &= ~OB_POSEMODE; + ob->mode &= ~OB_MODE_POSE; cfrao= CFRA; flago= arm->flag; arm->flag &= ~(ARM_DRAWNAMES|ARM_DRAWAXES); @@ -2388,7 +2388,7 @@ static void draw_ghost_poses_keys(Scene *scene, View3D *v3d, RegionView3D *rv3d, ob->pose= poseo; arm->flag= flago; armature_rebuild_pose(ob, ob->data); - ob->flag |= OB_POSEMODE; + ob->mode |= OB_MODE_POSE; } /* draw ghosts around current frame @@ -2415,7 +2415,7 @@ static void draw_ghost_poses(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base range= (float)(arm->ghostep)*stepsize + 0.5f; /* plus half to make the for loop end correct */ /* store values */ - ob->flag &= ~OB_POSEMODE; + ob->mode &= ~OB_MODE_POSE; cfrao= CFRA; actframe= BKE_nla_tweakedit_remap(adt, (float)CFRA, 0); flago= arm->flag; @@ -2474,7 +2474,7 @@ static void draw_ghost_poses(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base ob->pose= poseo; arm->flag= flago; armature_rebuild_pose(ob, ob->data); - ob->flag |= OB_POSEMODE; + ob->mode |= OB_MODE_POSE; } /* ********************************** Armature Drawing - Main ************************* */ @@ -2513,10 +2513,10 @@ int draw_armature(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base, int /* drawing posemode selection indices or colors only in these cases */ if(!(base->flag & OB_FROMDUPLI)) { if(G.f & G_PICKSEL) { - if(ob->flag & OB_POSEMODE) + if(ob->mode & OB_MODE_POSE) arm->flag |= ARM_POSEMODE; } - else if(ob->flag & OB_POSEMODE) { + else if(ob->mode & OB_MODE_POSE) { if (arm->ghosttype == ARM_GHOST_RANGE) { draw_ghost_poses_range(scene, v3d, rv3d, base); } @@ -2530,7 +2530,7 @@ int draw_armature(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base, int if ((flag & DRAW_SCENESET)==0) { if(ob==OBACT) arm->flag |= ARM_POSEMODE; - else if(G.f & G_WEIGHTPAINT) { + else if(ob->mode & OB_MODE_WEIGHT_PAINT) { if(OBACT && ob==modifiers_isDeformedByArmature(OBACT)) arm->flag |= ARM_POSEMODE; } @@ -2541,7 +2541,7 @@ int draw_armature(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base, int draw_pose_channels(scene, v3d, rv3d, base, dt); arm->flag &= ~ARM_POSEMODE; - if(ob->flag & OB_POSEMODE) + if(ob->mode & OB_MODE_POSE) UI_ThemeColor(TH_WIRE); /* restore, for extra draw stuff */ } else retval= 1; diff --git a/source/blender/editors/space_view3d/drawmesh.c b/source/blender/editors/space_view3d/drawmesh.c index 846d45388d3..2e47e2d4483 100644 --- a/source/blender/editors/space_view3d/drawmesh.c +++ b/source/blender/editors/space_view3d/drawmesh.c @@ -60,6 +60,7 @@ #include "BKE_material.h" #include "BKE_mesh.h" #include "BKE_object.h" +#include "BKE_paint.h" #include "BKE_property.h" #include "BKE_utildefines.h" #include "BKE_tessmesh.h" @@ -298,9 +299,9 @@ static int set_draw_settings_cached(int clearcache, int textured, MTFace *texfac if (textured!=c_textured || texface!=c_texface) { if (textured ) { - c_badtex= !GPU_set_tpage(texface); + c_badtex= !GPU_set_tpage(texface, !(litob->mode & OB_MODE_TEXTURE_PAINT)); } else { - GPU_set_tpage(0); + GPU_set_tpage(NULL, 0); c_badtex= 0; } c_textured= textured; @@ -378,7 +379,7 @@ static void draw_textured_begin(Scene *scene, View3D *v3d, RegionView3D *rv3d, O static void draw_textured_end() { /* switch off textures */ - GPU_set_tpage(0); + GPU_set_tpage(NULL, 0); glShadeModel(GL_FLAT); glDisable(GL_CULL_FACE); @@ -506,7 +507,7 @@ void draw_mesh_text(Scene *scene, Object *ob, int glsl) if(ob == scene->obedit) return; else if(ob==OBACT) - if(FACESEL_PAINT_TEST) + if(paint_facesel_test(ob)) return; ddm = mesh_get_derived_deform(scene, ob, CD_MASK_BAREMESH); @@ -586,7 +587,7 @@ void draw_mesh_textured(Scene *scene, View3D *v3d, RegionView3D *rv3d, Object *o if(ob == scene->obedit) { dm->drawMappedFacesTex(dm, draw_em_tf_mapped__set_draw, me->edit_btmesh); } else if(faceselect) { - if(G.f & G_WEIGHTPAINT) + if(ob->mode & OB_MODE_WEIGHT_PAINT) dm->drawMappedFaces(dm, wpaint__setSolidDrawOptions, me, 1); else dm->drawMappedFacesTex(dm, draw_tface_mapped__set_draw, me); diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c index 486ffb3d178..79c4cdc87fb 100644 --- a/source/blender/editors/space_view3d/drawobject.c +++ b/source/blender/editors/space_view3d/drawobject.c @@ -87,9 +87,11 @@ #include "BKE_mball.h" #include "BKE_modifier.h" #include "BKE_object.h" +#include "BKE_paint.h" #include "BKE_particle.h" #include "BKE_property.h" #include "BKE_smoke.h" +#include "BKE_unit.h" #include "BKE_utildefines.h" #include "BKE_tessmesh.h" @@ -213,11 +215,10 @@ int draw_glsl_material(Scene *scene, Object *ob, View3D *v3d, int dt) return 0; if(!CHECK_OB_DRAWTEXTURE(v3d, dt)) return 0; - if(ob==OBACT && (G.f & G_WEIGHTPAINT)) + if(ob==OBACT && (ob && ob->mode & OB_MODE_WEIGHT_PAINT)) return 0; - return ((G.fileflags & G_FILE_GAME_MAT) && - (G.fileflags & G_FILE_GAME_MAT_GLSL) && (dt >= OB_SHADED)); + return (scene->gm.matmode == GAME_MAT_GLSL) && (dt >= OB_SHADED); } static int check_material_alpha(Base *base, Mesh *me, int glsl) @@ -1893,7 +1894,7 @@ static void draw_em_fancy_edges(BMEditMesh *em, Scene *scene, View3D *v3d, } static void draw_em_measure_stats(View3D *v3d, RegionView3D *rv3d, - Object *ob, BMEditMesh *em) + Object *ob, BMEditMesh *em, UnitSettings *unit) { #if 0 Mesh *me= ob->data; @@ -1904,18 +1905,20 @@ static void draw_em_measure_stats(View3D *v3d, RegionView3D *rv3d, char val[32]; /* Stores the measurement display text here */ char conv_float[5]; /* Use a float conversion matching the grid size */ float area, col[3]; /* area of the face, color of the text to draw */ - + float grid= unit->system ? unit->scale_length : v3d->grid; + int do_split= unit->flag & USER_UNIT_OPT_SPLIT; if(G.f & (G_RENDER_OGL|G_RENDER_SHADOW)) return; /* make the precission of the pronted value proportionate to the gridsize */ - if ((v3d->grid) < 0.01) + + if (grid < 0.01f) strcpy(conv_float, "%.6f"); - else if ((v3d->grid) < 0.1) + else if (grid < 0.1f) strcpy(conv_float, "%.5f"); - else if ((v3d->grid) < 1.0) + else if (grid < 1.0f) strcpy(conv_float, "%.4f"); - else if ((v3d->grid) < 10.0) + else if (grid < 10.0f) strcpy(conv_float, "%.3f"); else strcpy(conv_float, "%.2f"); @@ -1924,13 +1927,13 @@ static void draw_em_measure_stats(View3D *v3d, RegionView3D *rv3d, if(v3d->zbuf && (v3d->flag & V3D_ZBUF_SELECT)==0) glDisable(GL_DEPTH_TEST); - if(v3d->zbuf) bglPolygonOffset(rv3d->dist, 5.0); + if(v3d->zbuf) bglPolygonOffset(rv3d->dist, 5.0f); if(me->drawflag & ME_DRAW_EDGELEN) { UI_GetThemeColor3fv(TH_TEXT, col); /* make color a bit more red */ - if(col[0]> 0.5) {col[1]*=0.7; col[2]*= 0.7;} - else col[0]= col[0]*0.7 + 0.3; + if(col[0]> 0.5f) {col[1]*=0.7f; col[2]*= 0.7f;} + else col[0]= col[0]*0.7f + 0.3f; glColor3fv(col); for(eed= em->edges.first; eed; eed= eed->next) { @@ -1939,16 +1942,19 @@ static void draw_em_measure_stats(View3D *v3d, RegionView3D *rv3d, VECCOPY(v1, eed->v1->co); VECCOPY(v2, eed->v2->co); - x= 0.5*(v1[0]+v2[0]); - y= 0.5*(v1[1]+v2[1]); - z= 0.5*(v1[2]+v2[2]); + x= 0.5f*(v1[0]+v2[0]); + y= 0.5f*(v1[1]+v2[1]); + z= 0.5f*(v1[2]+v2[2]); if(v3d->flag & V3D_GLOBAL_STATS) { Mat4MulVecfl(ob->obmat, v1); Mat4MulVecfl(ob->obmat, v2); } + if(unit->system) + bUnit_AsString(val, sizeof(val), VecLenf(v1, v2)*unit->scale_length, 3, unit->system, B_UNIT_LENGTH, do_split, FALSE); + else + sprintf(val, conv_float, VecLenf(v1, v2)); - sprintf(val, conv_float, VecLenf(v1, v2)); view3d_object_text_draw_add(x, y, z, val, 0); } } @@ -1959,8 +1965,8 @@ static void draw_em_measure_stats(View3D *v3d, RegionView3D *rv3d, UI_GetThemeColor3fv(TH_TEXT, col); /* make color a bit more green */ - if(col[1]> 0.5) {col[0]*=0.7; col[2]*= 0.7;} - else col[1]= col[1]*0.7 + 0.3; + if(col[1]> 0.5f) {col[0]*=0.7f; col[2]*= 0.7f;} + else col[1]= col[1]*0.7f + 0.3f; glColor3fv(col); for(efa= em->faces.first; efa; efa= efa->next) { @@ -1983,7 +1989,11 @@ static void draw_em_measure_stats(View3D *v3d, RegionView3D *rv3d, else area = AreaT3Dfl(v1, v2, v3); - sprintf(val, conv_float, area); + if(unit->system) + bUnit_AsString(val, sizeof(val), area*unit->scale_length, 3, unit->system, B_UNIT_LENGTH, do_split, FALSE); // XXX should be B_UNIT_AREA + else + sprintf(val, conv_float, area); + view3d_object_text_draw_add(efa->cent[0], efa->cent[1], efa->cent[2], val, 0); } } @@ -1994,8 +2004,8 @@ static void draw_em_measure_stats(View3D *v3d, RegionView3D *rv3d, UI_GetThemeColor3fv(TH_TEXT, col); /* make color a bit more blue */ - if(col[2]> 0.5) {col[0]*=0.7; col[1]*= 0.7;} - else col[2]= col[2]*0.7 + 0.3; + if(col[2]> 0.5f) {col[0]*=0.7f; col[1]*= 0.7f;} + else col[2]= col[2]*0.7f + 0.3f; glColor3fv(col); for(efa= em->faces.first; efa; efa= efa->next) { @@ -2025,13 +2035,13 @@ static void draw_em_measure_stats(View3D *v3d, RegionView3D *rv3d, if( (e4->f & e1->f & SELECT) || (G.moving && (efa->v1->f & SELECT)) ) { /* Vec 1 */ sprintf(val,"%.3f", VecAngle3(v4, v1, v2)); - VecLerpf(fvec, efa->cent, efa->v1->co, 0.8); + VecLerpf(fvec, efa->cent, efa->v1->co, 0.8f); view3d_object_text_draw_add(efa->cent[0], efa->cent[1], efa->cent[2], val, 0); } if( (e1->f & e2->f & SELECT) || (G.moving && (efa->v2->f & SELECT)) ) { /* Vec 2 */ sprintf(val,"%.3f", VecAngle3(v1, v2, v3)); - VecLerpf(fvec, efa->cent, efa->v2->co, 0.8); + VecLerpf(fvec, efa->cent, efa->v2->co, 0.8f); view3d_object_text_draw_add(fvec[0], fvec[1], fvec[2], val, 0); } if( (e2->f & e3->f & SELECT) || (G.moving && (efa->v3->f & SELECT)) ) { @@ -2040,14 +2050,14 @@ static void draw_em_measure_stats(View3D *v3d, RegionView3D *rv3d, sprintf(val,"%.3f", VecAngle3(v2, v3, v4)); else sprintf(val,"%.3f", VecAngle3(v2, v3, v1)); - VecLerpf(fvec, efa->cent, efa->v3->co, 0.8); + VecLerpf(fvec, efa->cent, efa->v3->co, 0.8f); view3d_object_text_draw_add(fvec[0], fvec[1], fvec[2], val, 0); } /* Vec 4 */ if(efa->v4) { if( (e3->f & e4->f & SELECT) || (G.moving && (efa->v4->f & SELECT)) ) { sprintf(val,"%.3f", VecAngle3(v3, v4, v1)); - VecLerpf(fvec, efa->cent, efa->v4->co, 0.8); + VecLerpf(fvec, efa->cent, efa->v4->co, 0.8f); view3d_object_text_draw_add(fvec[0], fvec[1], fvec[2], val, 0); } } @@ -2056,7 +2066,7 @@ static void draw_em_measure_stats(View3D *v3d, RegionView3D *rv3d, if(v3d->zbuf) { glEnable(GL_DEPTH_TEST); - bglPolygonOffset(rv3d->dist, 0.0); + bglPolygonOffset(rv3d->dist, 0.0f); } #endif } @@ -2144,7 +2154,7 @@ static void draw_em_fancy(Scene *scene, View3D *v3d, RegionView3D *rv3d, Object } } - if((me->drawflag & (ME_DRAWFACES)) || FACESEL_PAINT_TEST) { /* transp faces */ + if((me->drawflag & (ME_DRAWFACES)) || paint_facesel_test(ob)) { /* transp faces */ unsigned char col1[4], col2[4], col3[4]; UI_GetThemeColor4ubv(TH_FACE, (char *)col1); @@ -2232,7 +2242,7 @@ static void draw_em_fancy(Scene *scene, View3D *v3d, RegionView3D *rv3d, Object } if(me->drawflag & (ME_DRAW_EDGELEN|ME_DRAW_FACEAREA|ME_DRAW_EDGEANG)) - draw_em_measure_stats(v3d, rv3d, ob, em); + draw_em_measure_stats(v3d, rv3d, ob, em, &scene->unit); } if(dt>OB_WIRE) { @@ -2303,7 +2313,7 @@ static void draw_mesh_fancy(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base glFrontFace((ob->transflag&OB_NEG_SCALE)?GL_CW:GL_CCW); // Unwanted combination. - if (ob==OBACT && FACESEL_PAINT_TEST) draw_wire = 0; + if (ob==OBACT && paint_facesel_test(ob)) draw_wire = 0; if(dt==OB_BOUNDBOX) { draw_bounding_volume(scene, ob); @@ -2316,12 +2326,12 @@ static void draw_mesh_fancy(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base else if(dt==OB_WIRE || totface==0) { draw_wire = 1; /* draw wire only, no depth buffer stuff */ } - else if( (ob==OBACT && (G.f & G_TEXTUREPAINT || FACESEL_PAINT_TEST)) || + else if( (ob==OBACT && (ob->mode & OB_MODE_TEXTURE_PAINT || paint_facesel_test(ob))) || CHECK_OB_DRAWTEXTURE(v3d, dt)) { - int faceselect= (ob==OBACT && FACESEL_PAINT_TEST); + int faceselect= (ob==OBACT && paint_facesel_test(ob)); - if ((v3d->flag&V3D_SELECT_OUTLINE) && (base->flag&SELECT) && !(G.f&G_PICKSEL || FACESEL_PAINT_TEST) && !draw_wire) { + if ((v3d->flag&V3D_SELECT_OUTLINE) && (base->flag&SELECT) && !(G.f&G_PICKSEL || paint_facesel_test(ob)) && !draw_wire) { draw_mesh_object_outline(v3d, ob, dm); } @@ -2375,7 +2385,7 @@ static void draw_mesh_fancy(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base if(ob==OBACT) { do_draw= 0; - if( (G.f & G_WEIGHTPAINT)) { + if(ob && ob->mode & OB_MODE_WEIGHT_PAINT) { /* enforce default material settings */ GPU_enable_material(0, NULL); @@ -2395,12 +2405,13 @@ static void draw_mesh_fancy(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base GPU_disable_material(); } - else if((G.f & (G_VERTEXPAINT+G_TEXTUREPAINT)) && me->mcol) { - dm->drawMappedFaces(dm, wpaint__setSolidDrawOptions, NULL, 1); - } - else if(G.f & (G_VERTEXPAINT+G_TEXTUREPAINT)) { - glColor3f(1.0f, 1.0f, 1.0f); - dm->drawMappedFaces(dm, wpaint__setSolidDrawOptions, NULL, 0); + else if(ob->mode & (OB_MODE_VERTEX_PAINT|OB_MODE_TEXTURE_PAINT)) { + if(me->mcol) + dm->drawMappedFaces(dm, wpaint__setSolidDrawOptions, NULL, 1); + else { + glColor3f(1.0f, 1.0f, 1.0f); + dm->drawMappedFaces(dm, wpaint__setSolidDrawOptions, NULL, 0); + } } else do_draw= 1; } @@ -3560,7 +3571,7 @@ static void draw_new_particle_system(Scene *scene, View3D *v3d, RegionView3D *rv } if((part->draw&PART_DRAW_NUM || part->draw&PART_DRAW_HEALTH) && !(G.f & G_RENDER_SHADOW)){ - strcpy(val, ""); + val[0]= '\0'; if(part->draw&PART_DRAW_NUM) sprintf(val, " %i", a); @@ -4824,7 +4835,7 @@ static void drawSolidSelect(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base drawDispListwire(&ob->disp); } else if(ob->type==OB_ARMATURE) { - if(!(ob->flag & OB_POSEMODE)) + if(!(ob->mode & OB_MODE_POSE)) draw_armature(scene, v3d, rv3d, base, OB_WIRE, 0); } @@ -4973,7 +4984,7 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag) /* xray delay? */ if((flag & DRAW_PICKING)==0 && (base->flag & OB_FROMDUPLI)==0) { /* don't do xray in particle mode, need the z-buffer */ - if(!(G.f & G_PARTICLEEDIT)) { + if(!(ob->mode & OB_MODE_PARTICLE_EDIT)) { /* xray and transp are set when it is drawing the 2nd/3rd pass */ if(!v3d->xray && !v3d->transp && (ob->dtx & OB_DRAWXRAY) && !(ob->dtx & OB_DRAWTRANSP)) { add_view3d_after(v3d, base, V3D_XRAY, flag); @@ -5060,6 +5071,9 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag) /* patch? children objects with a timeoffs change the parents. How to solve! */ /* if( ((int)ob->ctime) != F_(scene->r.cfra)) where_is_object(scene, ob); */ + + /* draw paths... */ + // TODO... /* multiply view with object matrix */ wmMultMatrix(ob->obmat); @@ -5119,7 +5133,7 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag) dtx= 0; /* faceselect exception: also draw solid when dt==wire, except in editmode */ - if(ob==OBACT && (G.f & (G_VERTEXPAINT+G_TEXTUREPAINT+G_WEIGHTPAINT))) { + if(ob==OBACT && (ob->mode & (OB_MODE_VERTEX_PAINT|OB_MODE_WEIGHT_PAINT|OB_MODE_TEXTURE_PAINT))) { if(ob->type==OB_MESH) { if(ob==scene->obedit); @@ -5332,7 +5346,7 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag) for(psys=ob->particlesystem.first; psys; psys=psys->next) draw_new_particle_system(scene, v3d, rv3d, base, psys, dt); - if(G.f & G_PARTICLEEDIT && ob==OBACT) { + if(ob->mode & OB_MODE_PARTICLE_EDIT && ob==OBACT) { psys= PE_get_current(scene, ob); if(psys && !scene->obedit && psys_in_edit_mode(scene, psys)) draw_particle_edit(scene, v3d, rv3d, ob, psys, dt); @@ -5346,352 +5360,15 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag) } /* draw code for smoke */ - if(md = modifiers_findByType(ob, eModifierType_Smoke)) { - SmokeModifierData *smd = (SmokeModifierData *)md; - - // draw collision objects - if((smd->type & MOD_SMOKE_TYPE_COLL) && smd->coll) - { - SmokeCollSettings *scs = smd->coll; - /* - if(scs->points) - { - size_t i; - - wmLoadMatrix(rv3d->viewmat); - - if(col || (ob->flag & SELECT)) cpack(0xFFFFFF); - glDepthMask(GL_FALSE); - glEnable(GL_BLEND); - - - // glPointSize(3.0); - bglBegin(GL_POINTS); - - for(i = 0; i < scs->numpoints; i++) - { - bglVertex3fv(&scs->points[3*i]); - } - - bglEnd(); - glPointSize(1.0); - - wmMultMatrix(ob->obmat); - glDisable(GL_BLEND); - glDepthMask(GL_TRUE); - if(col) cpack(col); - - } - */ - } - - // only draw domains - if(smd->domain && smd->domain->fluid) - { - int x, y, z, i; - float viewnormal[3]; - int mainaxis[3] = {0,0,0}; - float align = 0, signed_align = 0; - int max_textures = 0, counter_textures = 0; - float *buffer = NULL; - int res[3]; - float bigfactor = 1.0; - int big = smd->domain->flags & MOD_SMOKE_HIGHRES; - int new = 0; - - // GUI sent redraw event - if(smd->domain->flags & MOD_SMOKE_VIEW_REDRAWNICE) - { - new = 1; - smd->domain->flags &= ~MOD_SMOKE_VIEW_REDRAWNICE; - } - - if(!big) - { - res[0] = smd->domain->res[0]; - res[1] = smd->domain->res[1]; - res[2] = smd->domain->res[2]; - } - else - { - smoke_get_bigres(smd->domain->fluid, res); - bigfactor = 1.0 / smd->domain->amplify; - } - - wmLoadMatrix(rv3d->viewmat); - - if(col || (ob->flag & SELECT)) cpack(0xFFFFFF); /* for visibility, also while wpaint */ - glDepthMask(GL_FALSE); - glEnable(GL_BLEND); - - // get view vector - VECCOPY(viewnormal, rv3d->viewinv[2]); - Normalize(viewnormal); - for(i = 0; i < 3; i++) - { - if(ABS(viewnormal[i]) > align) - { - mainaxis[0] = i; - align = ABS(viewnormal[i]); - signed_align = viewnormal[i]; - } - } - mainaxis[1] = (mainaxis[0] + 1) % 3; - mainaxis[2] = (mainaxis[0] + 2) % 3; - - if(!smd->domain->bind) - { - smd->domain->bind = MEM_callocN(sizeof(GLuint)*256, "Smoke_bind"); - if(big) - smd->domain->viewsettings |= MOD_SMOKE_VIEW_CHANGETOBIG; - new = 3; - } - - // check if view axis / mode has been changed - if(smd->domain->viewsettings) - { - if(big) - { - if(!(smd->domain->viewsettings & MOD_SMOKE_VIEW_BIG)) - new = 2; - else if(!(smd->domain->viewsettings & MOD_SMOKE_VIEW_CHANGETOBIG)) - new = 1; - - smd->domain->viewsettings |= MOD_SMOKE_VIEW_CHANGETOBIG; - } - else - { - if(!(smd->domain->viewsettings & MOD_SMOKE_VIEW_SMALL)) - new = 2; - else if(smd->domain->viewsettings & MOD_SMOKE_VIEW_CHANGETOBIG) - new = 1; - - smd->domain->viewsettings &= ~MOD_SMOKE_VIEW_CHANGETOBIG; - } - - if(!new) - { - if((mainaxis[0] == 0) && !(smd->domain->viewsettings & MOD_SMOKE_VIEW_X)) - new = 1; - else if((mainaxis[0] == 1) && !(smd->domain->viewsettings & MOD_SMOKE_VIEW_Y)) - new = 1; - else if((mainaxis[0] == 2) && !(smd->domain->viewsettings & MOD_SMOKE_VIEW_Z)) - new = 1; - - // printf("check axis\n"); - } - } - else - new = 3; - - if(new > 1) - { - float light[3] = {0.0,0.0,2.0}; // TODO: take real LAMP coordinates - dg - Base *base_tmp = NULL; - - for(base_tmp = scene->base.first; base_tmp; base_tmp= base_tmp->next) - { - if(base_tmp->object->type == OB_LAMP) - { - Lamp *la = (Lamp *)base_tmp->object->data; - - if(la->type == LA_LOCAL) - { - VECCOPY(light, base_tmp->object->obmat[3]); - break; - } - } - } - - if(!big && !(smd->domain->viewsettings & MOD_SMOKE_VIEW_SMALL)) - { - smoke_prepare_View(smd, light); - // printf("prepared View!\n"); - } - else if(big && !(smd->domain->viewsettings & MOD_SMOKE_VIEW_BIG)) - { - smoke_prepare_bigView(smd, light); - // printf("prepared bigView!\n"); - } + md = modifiers_findByType(ob, eModifierType_Smoke); + if (md) { + SmokeModifierData *smd = (SmokeModifierData *)md; + if(smd->type & MOD_SMOKE_TYPE_DOMAIN && smd->domain && smd->domain->fluid) { + GPU_create_smoke(smd); + draw_volume(scene, ar, v3d, base, smd->domain->tex, smd->domain->res); + GPU_free_smoke(smd); } - - // printf("big: %d, new: %d\n", big, new); - - // only create buffer if we need to create new textures - if(new) - buffer = MEM_mallocN(sizeof(float)*res[mainaxis[1]]*res[mainaxis[2]]*4, "SmokeDrawBuffer"); - - if(buffer || smd->domain->viewsettings) - { - int mod_texture = 0; - - // printf("if(buffer || smd->domain->viewsettings)\n"); - - max_textures = (res[mainaxis[0]] > 256) ? 256 : res[mainaxis[0]]; - - if(!smd->domain->viewsettings) // new frame or new start - { - smd->domain->max_textures = max_textures; - glGenTextures(smd->domain->max_textures, (GLuint *)smd->domain->bind); - new = 1; - // printf("glGenTextures\n"); - } - else - { - if(new) - { - // printf("glDeleteTextures\n"); - glDeleteTextures(smd->domain->max_textures, (GLuint *)smd->domain->bind); - smd->domain->max_textures = max_textures; - glGenTextures(smd->domain->max_textures, (GLuint *)smd->domain->bind); - } - } - - mod_texture = MAX3(1, smd->domain->visibility, (int)(res[mainaxis[0]] / smd->domain->max_textures )); - - // align order of billboards to be front or backview (e.g. +x or -x axis) - if(signed_align < 0) - { - z = res[mainaxis[0]] - 1; - } - else - { - z = 0; - } - - for (; signed_align > 0 ? (z < res[mainaxis[0]]) : (z >= 0); signed_align > 0 ? z++ : z--) // 2 - { - float quad[4][3]; - - if(new) - { - for (y = 0; y < res[mainaxis[1]]; y++) // 1 - { - for (x = 0; x < res[mainaxis[2]]; x++) // 0 - { - size_t index; - size_t image_index; - float tray, tvox; - - image_index = smoke_get_index2d(y, res[mainaxis[1]], x); - - if(mainaxis[0] == 0) - { - // mainaxis[1] == 1, mainaxis[2] == 2 - index = smoke_get_index(z, res[mainaxis[0]], y, res[mainaxis[1]], x); - } - else if(mainaxis[0] == 1) - { - // mainaxis[1] == 2, mainaxis[2] == 0 - index = smoke_get_index(x, res[mainaxis[2]], z, res[mainaxis[0]], y); - } - else // mainaxis[0] == 2 - { - // mainaxis[1] == 0, mainaxis[2] == 1 - index = smoke_get_index(y, res[mainaxis[1]], x, res[mainaxis[2]], z); - } - - if(!big) - { - tvox = smoke_get_tvox(smd, index); - tray = smoke_get_tray(smd, index); - } - else - { - tvox = smoke_get_bigtvox(smd, index); - tray = smoke_get_bigtray(smd, index); - } - - // fill buffer with luminance and alpha - // 1 - T_vox - buffer[image_index*4 + 3] = 1.0 - tvox; // 0 = transparent => d.h. tvox = 1 - - // L_vox = Omega * L_light * (1 - T_vox) * T_ray - buffer[image_index*4] = buffer[image_index*4 + 1] = buffer[image_index*4 + 2] = smd->domain->omega * 1.0 * tvox * tray; - } - } - } - glBindTexture(GL_TEXTURE_2D, smd->domain->bind[counter_textures]); - glEnable(GL_TEXTURE_2D); - - if(new) - { - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, res[mainaxis[1]], res[mainaxis[2]], 0, GL_RGBA, GL_FLOAT, buffer); - glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR); // Linear Filtering - glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR); // Linear Filtering - } - - if((z % mod_texture) == 0 ) - { - // botttom left - quad[3][mainaxis[0]] = smd->domain->p0[mainaxis[0]] + z * smd->domain->dx * bigfactor + smd->domain->dx * bigfactor * 0.5; - quad[3][mainaxis[1]] = smd->domain->p0[mainaxis[1]] + smd->domain->dx * bigfactor * 0.5; - quad[3][mainaxis[2]] = smd->domain->p0[mainaxis[2]] + smd->domain->dx * bigfactor * 0.5; - - // top right - quad[1][mainaxis[0]] = smd->domain->p0[mainaxis[0]] + z * smd->domain->dx * bigfactor + smd->domain->dx * bigfactor * 0.5; - quad[1][mainaxis[1]] = smd->domain->p0[mainaxis[1]] + (res[mainaxis[1]] - 1) * smd->domain->dx * bigfactor + smd->domain->dx * bigfactor * 0.5; - quad[1][mainaxis[2]] = smd->domain->p0[mainaxis[2]] + (res[mainaxis[2]] - 1) * smd->domain->dx * bigfactor + smd->domain->dx * bigfactor * 0.5; - - // top left - quad[2][mainaxis[0]] = smd->domain->p0[mainaxis[0]] + z * smd->domain->dx * bigfactor + smd->domain->dx * bigfactor * 0.5; - quad[2][mainaxis[1]] = smd->domain->p0[mainaxis[1]] + smd->domain->dx * bigfactor * 0.5; - quad[2][mainaxis[2]] = smd->domain->p0[mainaxis[2]] + (res[mainaxis[2]] - 1) * smd->domain->dx * bigfactor + smd->domain->dx * bigfactor * 0.5; - - // bottom right - quad[0][mainaxis[0]] = smd->domain->p0[mainaxis[0]] + z * smd->domain->dx * bigfactor + smd->domain->dx * bigfactor * 0.5; - quad[0][mainaxis[1]] = smd->domain->p0[mainaxis[1]] + (res[mainaxis[1]] - 1) * smd->domain->dx * bigfactor + smd->domain->dx * bigfactor * 0.5; - quad[0][mainaxis[2]] = smd->domain->p0[mainaxis[2]] + smd->domain->dx * bigfactor * 0.5; - - glBegin(GL_QUADS); // Start Drawing Quads - - glTexCoord2f(1.0f, 0.0f); - glVertex3fv(quad[0]); // Left And Up 1 Unit (Top Left) - glTexCoord2f(1.0f, 1.0f); - glVertex3fv(quad[1]); // Right And Up 1 Unit (Top Right) - glTexCoord2f(0.0f, 1.0f); - glVertex3fv(quad[2]); // Right And Down One Unit (Bottom Right) - glTexCoord2f(0.0f, 0.0f); - glVertex3fv(quad[3]); // Left And Down One Unit (Bottom Left) - - glEnd(); - } - counter_textures++; - } - } - if(buffer) - { - MEM_freeN(buffer); - buffer = NULL; - } - - // set correct flag for viewsettings - if(1) - { - // do not clear BIG/SMALL flag - smd->domain->viewsettings &= ~MOD_SMOKE_VIEW_X; - smd->domain->viewsettings &= ~MOD_SMOKE_VIEW_Y; - smd->domain->viewsettings &= ~MOD_SMOKE_VIEW_Z; - - // set what caches we have - if(big) - smd->domain->viewsettings |= MOD_SMOKE_VIEW_BIG; - else - smd->domain->viewsettings |= MOD_SMOKE_VIEW_SMALL; - - if(mainaxis[0] == 0) - smd->domain->viewsettings |= MOD_SMOKE_VIEW_X; - else if(mainaxis[0] == 1) - smd->domain->viewsettings |= MOD_SMOKE_VIEW_Y; - else if(mainaxis[0] == 2) - smd->domain->viewsettings |= MOD_SMOKE_VIEW_Z; - } - - wmMultMatrix(ob->obmat); - glDisable(GL_BLEND); - glDepthMask(GL_TRUE); - if(col) cpack(col); } } @@ -5753,7 +5430,7 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag) if(G.f & G_RENDER_SHADOW) return; /* object centers, need to be drawn in viewmat space for speed, but OK for picking select */ - if(ob!=OBACT || (G.f & (G_VERTEXPAINT|G_TEXTUREPAINT|G_WEIGHTPAINT))==0) { + if(ob!=OBACT || !(ob->mode & (OB_MODE_VERTEX_PAINT|OB_MODE_WEIGHT_PAINT|OB_MODE_TEXTURE_PAINT))) { int do_draw_center= -1; /* defines below are zero or positive... */ if((scene->basact)==base) diff --git a/source/blender/editors/space_view3d/drawvolume.c b/source/blender/editors/space_view3d/drawvolume.c new file mode 100644 index 00000000000..f4242c70139 --- /dev/null +++ b/source/blender/editors/space_view3d/drawvolume.c @@ -0,0 +1,304 @@ +/** + * $Id$ + * + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. + * All rights reserved. + * + * Contributor(s): Daniel Genrich + * + * ***** END GPL LICENSE BLOCK ***** + */ + + +#include <string.h> +#include <math.h> + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include "MEM_guardedalloc.h" + +#include "IMB_imbuf.h" + + +#include "MTC_matrixops.h" + +#include "DNA_armature_types.h" +#include "DNA_boid_types.h" +#include "DNA_camera_types.h" +#include "DNA_curve_types.h" +#include "DNA_constraint_types.h" // for drawing constraint +#include "DNA_effect_types.h" +#include "DNA_lamp_types.h" +#include "DNA_lattice_types.h" +#include "DNA_material_types.h" +#include "DNA_mesh_types.h" +#include "DNA_meshdata_types.h" +#include "DNA_meta_types.h" +#include "DNA_modifier_types.h" +#include "DNA_object_types.h" +#include "DNA_object_force.h" +#include "DNA_object_fluidsim.h" +#include "DNA_particle_types.h" +#include "DNA_space_types.h" +#include "DNA_scene_types.h" +#include "DNA_screen_types.h" +#include "DNA_smoke_types.h" +#include "DNA_userdef_types.h" +#include "DNA_view3d_types.h" +#include "DNA_world_types.h" + +#include "BLI_blenlib.h" +#include "BLI_arithb.h" +#include "BLI_editVert.h" +#include "BLI_edgehash.h" +#include "BLI_rand.h" + +#include "BKE_anim.h" //for the where_on_path function +#include "BKE_curve.h" +#include "BKE_constraint.h" // for the get_constraint_target function +#include "BKE_DerivedMesh.h" +#include "BKE_deform.h" +#include "BKE_displist.h" +#include "BKE_effect.h" +#include "BKE_font.h" +#include "BKE_global.h" +#include "BKE_image.h" +#include "BKE_key.h" +#include "BKE_lattice.h" +#include "BKE_mesh.h" +#include "BKE_material.h" +#include "BKE_mball.h" +#include "BKE_modifier.h" +#include "BKE_object.h" +#include "BKE_paint.h" +#include "BKE_particle.h" +#include "BKE_property.h" +#include "BKE_smoke.h" +#include "BKE_unit.h" +#include "BKE_utildefines.h" +#include "smoke_API.h" + +#include "BIF_gl.h" +#include "BIF_glutil.h" + +#include "GPU_draw.h" +#include "GPU_material.h" +#include "GPU_extensions.h" + +#include "ED_mesh.h" +#include "ED_particle.h" +#include "ED_screen.h" +#include "ED_types.h" +#include "ED_util.h" + +#include "UI_resources.h" +#include "UI_interface_icons.h" + +#include "WM_api.h" +#include "BLF_api.h" + +#include "GPU_extensions.h" + +#include "view3d_intern.h" // own include + +struct GPUTexture; + +/* draw slices of smoke is adapted from c++ code authored by: Johannes Schmid and Ingemar Rask, 2006, johnny@grob.org */ +static float cv[][3] = { + {1.0f, 1.0f, 1.0f}, {-1.0f, 1.0f, 1.0f}, {-1.0f, -1.0f, 1.0f}, {1.0f, -1.0f, 1.0f}, + {1.0f, 1.0f, -1.0f}, {-1.0f, 1.0f, -1.0f}, {-1.0f, -1.0f, -1.0f}, {1.0f, -1.0f, -1.0f} +}; + +// edges have the form edges[n][0][xyz] + t*edges[n][1][xyz] +static float edges[12][2][3] = { + {{1.0f, 1.0f, -1.0f}, {0.0f, 0.0f, 1.0f}}, + {{-1.0f, 1.0f, -1.0f}, {0.0f, 0.0f, 1.0f}}, + {{-1.0f, -1.0f, -1.0f}, {0.0f, 0.0f, 1.0f}}, + {{1.0f, -1.0f, -1.0f}, {0.0f, 0.0f, 1.0f}}, + + {{1.0f, -1.0f, 1.0f}, {0.0f, 1.0f, 0.0f}}, + {{-1.0f, -1.0f, 1.0f}, {0.0f, 1.0f, 0.0f}}, + {{-1.0f, -1.0f, -1.0f}, {0.0f, 1.0f, 0.0f}}, + {{1.0f, -1.0f, -1.0f}, {0.0f, 1.0f, 0.0f}}, + + {{-1.0f, 1.0f, 1.0f}, {1.0f, 0.0f, 0.0f}}, + {{-1.0f, -1.0f, 1.0f}, {1.0f, 0.0f, 0.0f}}, + {{-1.0f, -1.0f, -1.0f}, {1.0f, 0.0f, 0.0f}}, + {{-1.0f, 1.0f, -1.0f}, {1.0f, 0.0f, 0.0f}} +}; + +int intersect_edges(float *points, float a, float b, float c, float d) +{ + int i; + float t; + int numpoints = 0; + + for (i=0; i<12; i++) { + t = -(a*edges[i][0][0] + b*edges[i][0][1] + c*edges[i][0][2] + d) + / (a*edges[i][1][0] + b*edges[i][1][1] + c*edges[i][1][2]); + if ((t>0)&&(t<2)) { + points[numpoints * 3 + 0] = edges[i][0][0] + edges[i][1][0]*t; + points[numpoints * 3 + 1] = edges[i][0][1] + edges[i][1][1]*t; + points[numpoints * 3 + 2] = edges[i][0][2] + edges[i][1][2]*t; + numpoints++; + } + } + return numpoints; +} + +static int convex(float *p0, float *up, float *a, float *b) +{ + // Vec3 va = a-p0, vb = b-p0; + float va[3], vb[3], tmp[3]; + VECSUB(va, a, p0); + VECSUB(vb, b, p0); + Crossf(tmp, va, vb); + return INPR(up, tmp) >= 0; +} + +// copied from gpu_extension.c +static int is_pow2(int n) +{ + return ((n)&(n-1))==0; +} + +static int larger_pow2(int n) +{ + if (is_pow2(n)) + return n; + + while(!is_pow2(n)) + n= n&(n-1); + + return n*2; +} + +void draw_volume(Scene *scene, ARegion *ar, View3D *v3d, Base *base, GPUTexture *tex, int res[3]) +{ + Object *ob = base->object; + RegionView3D *rv3d= ar->regiondata; + + float viewnormal[3]; + int i, j, n; + float d, d0, dd; + float *points = NULL; + int numpoints = 0; + float cor[3] = {1.,1.,1.}; + int gl_depth = 0, gl_blend = 0; + + glGetBooleanv(GL_BLEND, (GLboolean *)&gl_blend); + glGetBooleanv(GL_DEPTH_TEST, (GLboolean *)&gl_depth); + + wmLoadMatrix(rv3d->viewmat); + wmMultMatrix(ob->obmat); + + glDepthMask(GL_FALSE); + glDisable(GL_DEPTH_TEST); + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + + // get view vector + VECCOPY(viewnormal, rv3d->viewinv[2]); + Normalize(viewnormal); + + // find cube vertex that is closest to the viewer + for (i=0; i<8; i++) { + float x,y,z; + + x = cv[i][0] + viewnormal[0]; + y = cv[i][1] + viewnormal[1]; + z = cv[i][2] + viewnormal[2]; + + if ((x>=-1.0f)&&(x<=1.0f) + &&(y>=-1.0f)&&(y<=1.0f) + &&(z>=-1.0f)&&(z<=1.0f)) { + break; + } + } + + GPU_texture_bind(tex, 0); + + if (!GLEW_ARB_texture_non_power_of_two) { + cor[0] = (float)res[0]/(float)larger_pow2(res[0]); + cor[1] = (float)res[1]/(float)larger_pow2(res[1]); + cor[2] = (float)res[2]/(float)larger_pow2(res[2]); + } + + // our slices are defined by the plane equation a*x + b*y +c*z + d = 0 + // (a,b,c), the plane normal, are given by viewdir + // d is the parameter along the view direction. the first d is given by + // inserting previously found vertex into the plane equation + d0 = -(viewnormal[0]*cv[i][0] + viewnormal[1]*cv[i][1] + viewnormal[2]*cv[i][2]); + dd = 2.0*d0/64.0f; + n = 0; + + // printf("d0: %f, dd: %f\n", d0, dd); + + points = MEM_callocN(sizeof(float)*12*3, "smoke_points_preview"); + + for (d = d0; d > -d0; d -= dd) { + float p0[3]; + // intersect_edges returns the intersection points of all cube edges with + // the given plane that lie within the cube + numpoints = intersect_edges(points, viewnormal[0], viewnormal[1], viewnormal[2], d); + + if (numpoints > 2) { + VECCOPY(p0, points); + + // sort points to get a convex polygon + for(i = 1; i < numpoints - 1; i++) + { + for(j = i + 1; j < numpoints; j++) + { + if(convex(p0, viewnormal, &points[j * 3], &points[i * 3])) + { + float tmp2[3]; + VECCOPY(tmp2, &points[i * 3]); + VECCOPY(&points[i * 3], &points[j * 3]); + VECCOPY(&points[j * 3], tmp2); + } + } + } + + glBegin(GL_POLYGON); + for (i = 0; i < numpoints; i++) { + glColor3f(1.0, 1.0, 1.0); + glTexCoord3d((points[i * 3 + 0] + 1.0)*cor[0]/2.0, (points[i * 3 + 1] + 1)*cor[1]/2.0, (points[i * 3 + 2] + 1.0)*cor[2]/2.0); + glVertex3f(points[i * 3 + 0], points[i * 3 + 1], points[i * 3 + 2]); + } + glEnd(); + } + n++; + } + + GPU_texture_unbind(tex); + + MEM_freeN(points); + + if(!gl_blend) + glDisable(GL_BLEND); + if(gl_depth) + { + glEnable(GL_DEPTH_TEST); + glDepthMask(GL_TRUE); + } +} + diff --git a/source/blender/editors/space_view3d/space_view3d.c b/source/blender/editors/space_view3d/space_view3d.c index e1f0b537241..3dd65a6f796 100644 --- a/source/blender/editors/space_view3d/space_view3d.c +++ b/source/blender/editors/space_view3d/space_view3d.c @@ -280,7 +280,7 @@ static void view3d_modal_keymaps(wmWindowManager *wm, ARegion *ar, int stype) /* copy last mode, then we can re-init the region maps */ rv3d->lastmode= stype; - + keymap= WM_keymap_listbase(wm, "Object Mode", 0, 0); if(ELEM(stype, 0, NS_MODE_OBJECT)) WM_event_add_keymap_handler(&ar->handlers, keymap); @@ -304,6 +304,12 @@ static void view3d_modal_keymaps(wmWindowManager *wm, ARegion *ar, int stype) WM_event_add_keymap_handler(&ar->handlers, keymap); else WM_event_remove_keymap_handler(&ar->handlers, keymap); + + keymap= WM_keymap_listbase(wm, "Pose", 0, 0); + if(stype==NS_MODE_POSE) + WM_event_add_keymap_handler(&ar->handlers, keymap); + else + WM_event_remove_keymap_handler(&ar->handlers, keymap); keymap= WM_keymap_listbase(wm, "Metaball", 0, 0); if(stype==NS_EDITMODE_MBALL) @@ -319,7 +325,7 @@ static void view3d_modal_keymaps(wmWindowManager *wm, ARegion *ar, int stype) /* armature sketching needs to take over mouse */ keymap= WM_keymap_listbase(wm, "Armature_Sketch", 0, 0); - if(stype==NS_EDITMODE_TEXT) + if(stype==NS_EDITMODE_ARMATURE) WM_event_add_keymap_handler_priority(&ar->handlers, keymap, 10); else WM_event_remove_keymap_handler(&ar->handlers, keymap); @@ -595,7 +601,7 @@ static void view3d_tools_area_init(wmWindowManager *wm, ARegion *ar) static void view3d_tools_area_draw(const bContext *C, ARegion *ar) { - ED_region_panels(C, ar, 1, view3d_context_string(C), -1); + ED_region_panels(C, ar, 1, CTX_data_mode_string(C), -1); } static int view3d_context(const bContext *C, const char *member, bContextDataResult *result) @@ -889,7 +895,7 @@ void ED_spacetype_view3d(void) /* regions: tool(bar) */ art= MEM_callocN(sizeof(ARegionType), "spacetype view3d region"); art->regionid = RGN_TYPE_TOOLS; - art->minsizex= 120; // XXX + art->minsizex= 160; // XXX art->minsizey= 50; // XXX art->keymapflag= ED_KEYMAP_UI|ED_KEYMAP_FRAMES; art->listener= view3d_buttons_area_listener; diff --git a/source/blender/editors/space_view3d/view3d_buttons.c b/source/blender/editors/space_view3d/view3d_buttons.c index f64954af6c3..efe23101e6c 100644 --- a/source/blender/editors/space_view3d/view3d_buttons.c +++ b/source/blender/editors/space_view3d/view3d_buttons.c @@ -1000,6 +1000,7 @@ static void view3d_panel_transform_spaces(const bContext *C, Panel *pa) } #endif // XXX not used +#if 0 static void brush_idpoin_handle(bContext *C, ID *id, int event) { Brush **br = current_brush_source(CTX_data_scene(C)); @@ -1030,6 +1031,7 @@ static void brush_idpoin_handle(bContext *C, ID *id, int event) break; } } +#endif static void view3d_panel_object(const bContext *C, Panel *pa) { @@ -1041,7 +1043,6 @@ static void view3d_panel_object(const bContext *C, Panel *pa) Object *ob= OBACT; TransformProperties *tfp; float lim; - static char hexcol[128]; if(ob==NULL) return; @@ -1055,13 +1056,13 @@ static void view3d_panel_object(const bContext *C, Panel *pa) // XXX uiSetButLock(object_is_libdata(ob), ERROR_LIBDATA_MESSAGE); - if(G.f & (G_VERTEXPAINT|G_TEXTUREPAINT|G_WEIGHTPAINT)) { + if(ob->mode & (OB_MODE_VERTEX_PAINT|OB_MODE_WEIGHT_PAINT|OB_MODE_TEXTURE_PAINT)) { } else { //bt= uiDefBut(block, TEX, B_IDNAME, "OB: ", 10,180,140,20, ob->id.name+2, 0.0, 21.0, 0, 0, ""); //uiButSetFunc(bt, test_idbutton_cb, ob->id.name, NULL); - if((G.f & G_PARTICLEEDIT)==0) { + if((ob->mode & OB_MODE_PARTICLE_EDIT)==0) { // uiBlockBeginAlign(block); // uiDefIDPoinBut(block, test_obpoin_but, ID_OB, B_OBJECTPANELPARENT, "Par:", 160, 180, 140, 20, &ob->parent, "Parent Object"); if((ob->parent) && (ob->partype == PARBONE)) { @@ -1082,7 +1083,7 @@ static void view3d_panel_object(const bContext *C, Panel *pa) if(ob->type==OB_MBALL) v3d_editmetaball_buts(block, ob, lim); else v3d_editvertex_buts(C, block, v3d, ob, lim); } - else if(ob->flag & OB_POSEMODE) { + else if(ob->mode & OB_MODE_POSE) { v3d_posearmature_buts(block, v3d, ob, lim); } else { diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c index 5e6bfe89165..905657910b8 100644 --- a/source/blender/editors/space_view3d/view3d_draw.c +++ b/source/blender/editors/space_view3d/view3d_draw.c @@ -59,9 +59,11 @@ #include "BKE_key.h" #include "BKE_object.h" #include "BKE_global.h" +#include "BKE_paint.h" #include "BKE_scene.h" #include "BKE_screen.h" #include "BKE_utildefines.h" +#include "BKE_unit.h" #include "RE_pipeline.h" // make_stars @@ -234,15 +236,18 @@ static void drawgrid_draw(ARegion *ar, float wx, float wy, float x, float y, flo } -static void drawgrid(ARegion *ar, View3D *v3d) +#define GRID_MIN_PX 6.0f + +static void drawgrid(UnitSettings *unit, ARegion *ar, View3D *v3d, char **grid_unit) { /* extern short bgpicmode; */ RegionView3D *rv3d= ar->regiondata; float wx, wy, x, y, fw, fx, fy, dx; float vec4[4]; char col[3], col2[3]; - short sublines = v3d->gridsubdiv; + *grid_unit= NULL; + vec4[0]=vec4[1]=vec4[2]=0.0; vec4[3]= 1.0; Mat4MulVec4fl(rv3d->persmat, vec4); @@ -256,7 +261,8 @@ static void drawgrid(ARegion *ar, View3D *v3d) x= (wx)*fx/fw; y= (wy)*fy/fw; - vec4[0]=vec4[1]=v3d->grid; + vec4[0]=vec4[1]= (unit->system) ? 1.0 : v3d->grid; + vec4[2]= 0.0; vec4[3]= 1.0; Mat4MulVec4fl(rv3d->persmat, vec4); @@ -272,72 +278,115 @@ static void drawgrid(ARegion *ar, View3D *v3d) /* check zoom out */ UI_ThemeColor(TH_GRID); - if(dx<6.0) { - v3d->gridview*= sublines; - dx*= sublines; - - if(dx<6.0) { + if(unit->system) { + /* Use GRID_MIN_PX*2 for units because very very small grid + * items are less useful when dealing with units */ + void *usys; + int len, i; + double scalar; + float dx_scalar; + float blend_fac; + + bUnit_GetSystem(&usys, &len, unit->system, B_UNIT_LENGTH); + + if(usys) { + i= len; + while(i--) { + scalar= bUnit_GetScaler(usys, i); + + dx_scalar = dx * scalar * unit->scale_length; + if (dx_scalar < (GRID_MIN_PX*2)) + continue; + + /* Store the smallest drawn grid size units name so users know how big each grid cell is */ + if(*grid_unit==NULL) { + *grid_unit= bUnit_GetNameDisplay(usys, i); + v3d->gridview= (scalar * unit->scale_length); + } + blend_fac= 1-((GRID_MIN_PX*2)/dx_scalar); + + /* tweak to have the fade a bit nicer */ + blend_fac= (blend_fac * blend_fac) * 2.0f; + CLAMP(blend_fac, 0.3f, 1.0f); + + + UI_ThemeColorBlend(TH_BACK, TH_GRID, blend_fac); + + drawgrid_draw(ar, wx, wy, x, y, dx_scalar); + } + } + } + else { + short sublines = v3d->gridsubdiv; + + if(dx<GRID_MIN_PX) { v3d->gridview*= sublines; dx*= sublines; - if(dx<6.0) { + if(dx<GRID_MIN_PX) { v3d->gridview*= sublines; - dx*=sublines; - if(dx<6.0); - else { - UI_ThemeColor(TH_GRID); + dx*= sublines; + + if(dx<GRID_MIN_PX) { + v3d->gridview*= sublines; + dx*=sublines; + if(dx<GRID_MIN_PX); + else { + UI_ThemeColor(TH_GRID); + drawgrid_draw(ar, wx, wy, x, y, dx); + } + } + else { // start blending out + UI_ThemeColorBlend(TH_BACK, TH_GRID, dx/(GRID_MIN_PX*10)); drawgrid_draw(ar, wx, wy, x, y, dx); + + UI_ThemeColor(TH_GRID); + drawgrid_draw(ar, wx, wy, x, y, sublines*dx); } } - else { // start blending out - UI_ThemeColorBlend(TH_BACK, TH_GRID, dx/60.0); + else { // start blending out (GRID_MIN_PX < dx < (GRID_MIN_PX*10)) + UI_ThemeColorBlend(TH_BACK, TH_GRID, dx/(GRID_MIN_PX*10)); drawgrid_draw(ar, wx, wy, x, y, dx); - + UI_ThemeColor(TH_GRID); drawgrid_draw(ar, wx, wy, x, y, sublines*dx); } } - else { // start blending out (6 < dx < 60) - UI_ThemeColorBlend(TH_BACK, TH_GRID, dx/60.0); - drawgrid_draw(ar, wx, wy, x, y, dx); - - UI_ThemeColor(TH_GRID); - drawgrid_draw(ar, wx, wy, x, y, sublines*dx); - } - } - else { - if(dx>60.0) { // start blending in - v3d->gridview/= sublines; - dx/= sublines; - if(dx>60.0) { // start blending in + else { + if(dx>(GRID_MIN_PX*10)) { // start blending in v3d->gridview/= sublines; dx/= sublines; - if(dx>60.0) { - UI_ThemeColor(TH_GRID); - drawgrid_draw(ar, wx, wy, x, y, dx); + if(dx>(GRID_MIN_PX*10)) { // start blending in + v3d->gridview/= sublines; + dx/= sublines; + if(dx>(GRID_MIN_PX*10)) { + UI_ThemeColor(TH_GRID); + drawgrid_draw(ar, wx, wy, x, y, dx); + } + else { + UI_ThemeColorBlend(TH_BACK, TH_GRID, dx/(GRID_MIN_PX*10)); + drawgrid_draw(ar, wx, wy, x, y, dx); + UI_ThemeColor(TH_GRID); + drawgrid_draw(ar, wx, wy, x, y, dx*sublines); + } } else { - UI_ThemeColorBlend(TH_BACK, TH_GRID, dx/60.0); + UI_ThemeColorBlend(TH_BACK, TH_GRID, dx/(GRID_MIN_PX*10)); drawgrid_draw(ar, wx, wy, x, y, dx); UI_ThemeColor(TH_GRID); drawgrid_draw(ar, wx, wy, x, y, dx*sublines); } } else { - UI_ThemeColorBlend(TH_BACK, TH_GRID, dx/60.0); + UI_ThemeColorBlend(TH_BACK, TH_GRID, dx/(GRID_MIN_PX*10)); drawgrid_draw(ar, wx, wy, x, y, dx); - UI_ThemeColor(TH_GRID); + UI_ThemeColor(TH_GRID); drawgrid_draw(ar, wx, wy, x, y, dx*sublines); } } - else { - UI_ThemeColorBlend(TH_BACK, TH_GRID, dx/60.0); - drawgrid_draw(ar, wx, wy, x, y, dx); - UI_ThemeColor(TH_GRID); - drawgrid_draw(ar, wx, wy, x, y, dx*sublines); - } } + x+= (wx); y+= (wy); UI_GetThemeColor3ubv(TH_GRID, col); @@ -361,7 +410,7 @@ static void drawgrid(ARegion *ar, View3D *v3d) glDepthMask(1); // enable write in zbuffer } - +#undef GRID_MIN_PX static void drawfloor(Scene *scene, View3D *v3d) { @@ -749,7 +798,7 @@ static void draw_selected_name(Scene *scene, Object *ob, View3D *v3d) } } } - else if(ob->pose && (ob->flag & OB_POSEMODE)) { + else if(ob->pose && (ob->mode & OB_MODE_POSE)) { bPoseChannel *pchan; for(pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) { if((pchan->bone->flag & BONE_ACTIVE) && (pchan->bone->layer & arm->layer)) { @@ -1042,7 +1091,8 @@ static void drawviewborder(Scene *scene, ARegion *ar, View3D *v3d) void backdrawview3d(Scene *scene, ARegion *ar, View3D *v3d) { RegionView3D *rv3d= ar->regiondata; - struct Base *base; + struct Base *base = scene->basact; + rcti winrct; /*for 2.43 release, don't use glext and just define the constant. this to avoid possibly breaking platforms before release.*/ @@ -1054,9 +1104,11 @@ void backdrawview3d(Scene *scene, ARegion *ar, View3D *v3d) int m; #endif - if(G.f & G_VERTEXPAINT || G.f & G_WEIGHTPAINT || (FACESEL_PAINT_TEST)); - else if((G.f & G_TEXTUREPAINT) && scene->toolsettings && (scene->toolsettings->imapaint.flag & IMAGEPAINT_PROJECT_DISABLE)); - else if((G.f & G_PARTICLEEDIT) && v3d->drawtype>OB_WIRE && (v3d->flag & V3D_ZBUF_SELECT)); + if(base && (base->object->mode & (OB_MODE_VERTEX_PAINT|OB_MODE_WEIGHT_PAINT) || + paint_facesel_test(base->object))); + else if((base && (base->object->mode & OB_MODE_TEXTURE_PAINT)) && + scene->toolsettings && (scene->toolsettings->imapaint.flag & IMAGEPAINT_PROJECT_DISABLE)); + else if((base && (base->object->mode & OB_MODE_PARTICLE_EDIT)) && v3d->drawtype>OB_WIRE && (v3d->flag & V3D_ZBUF_SELECT)); else if(scene->obedit && v3d->drawtype>OB_WIRE && (v3d->flag & V3D_ZBUF_SELECT)); else { v3d->flag &= ~V3D_NEEDBACKBUFDRAW; @@ -1086,6 +1138,9 @@ void backdrawview3d(Scene *scene, ARegion *ar, View3D *v3d) glDisable(GL_DITHER); + region_scissor_winrct(ar, &winrct); + glScissor(winrct.xmin, winrct.ymin, winrct.xmax - winrct.xmin, winrct.ymax - winrct.ymin); + glClearColor(0.0, 0.0, 0.0, 0.0); if(v3d->zbuf) { glEnable(GL_DEPTH_TEST); @@ -1101,7 +1156,6 @@ void backdrawview3d(Scene *scene, ARegion *ar, View3D *v3d) G.f |= G_BACKBUFSEL; - base= (scene->basact); if(base && (base->lay & v3d->lay)) { draw_object_backbufsel(scene, v3d, rv3d, base->object); } @@ -1805,13 +1859,13 @@ static void gpu_update_lamps_shadows(Scene *scene, View3D *v3d) /* *********************** customdata **************** */ /* goes over all modes and view3d settings */ -static CustomDataMask get_viewedit_datamask(bScreen *screen) +static CustomDataMask get_viewedit_datamask(bScreen *screen, Scene *scene, Object *ob) { CustomDataMask mask = CD_MASK_BAREMESH; ScrArea *sa; /* check if we need tfaces & mcols due to face select or texture paint */ - if(FACESEL_PAINT_TEST || G.f & G_TEXTUREPAINT) + if(paint_facesel_test(ob) || (ob && ob->mode & OB_MODE_TEXTURE_PAINT)) mask |= CD_MASK_MTFACE | CD_MASK_MCOL; /* check if we need tfaces & mcols due to view mode */ @@ -1825,23 +1879,22 @@ static CustomDataMask get_viewedit_datamask(bScreen *screen) if((view->drawtype == OB_TEXTURE) || ((view->drawtype == OB_SOLID) && (view->flag2 & V3D_SOLID_TEX))) { mask |= CD_MASK_MTFACE | CD_MASK_MCOL; - if((G.fileflags & G_FILE_GAME_MAT) && - (G.fileflags & G_FILE_GAME_MAT_GLSL)) { + if(scene->gm.matmode == GAME_MAT_GLSL) mask |= CD_MASK_ORCO; - } } } } /* check if we need mcols due to vertex paint or weightpaint */ - if(G.f & G_VERTEXPAINT) - mask |= CD_MASK_MCOL; - if(G.f & G_WEIGHTPAINT) - mask |= CD_MASK_WEIGHT_MCOL; - - if(G.f & G_SCULPTMODE) - mask |= CD_MASK_MDISPS; - + if(ob) { + if(ob->mode & OB_MODE_VERTEX_PAINT) + mask |= CD_MASK_MCOL; + if(ob->mode & OB_MODE_WEIGHT_PAINT) + mask |= CD_MASK_WEIGHT_MCOL; + if(ob->mode & OB_MODE_SCULPT) + mask |= CD_MASK_MDISPS; + } + return mask; } @@ -1855,9 +1908,10 @@ void view3d_main_area_draw(const bContext *C, ARegion *ar) Object *ob; int retopo= 0, sculptparticle= 0; Object *obact = OBACT; + char *grid_unit= NULL; /* from now on all object derived meshes check this */ - v3d->customdata_mask= get_viewedit_datamask(CTX_wm_screen(C)); + v3d->customdata_mask= get_viewedit_datamask(CTX_wm_screen(C), scene, obact); /* shadow buffers, before we setup matrices */ if(draw_glsl_material(scene, NULL, v3d, v3d->drawtype)) @@ -1929,7 +1983,7 @@ void view3d_main_area_draw(const bContext *C, ARegion *ar) } else { ED_region_pixelspace(ar); - drawgrid(ar, v3d); + drawgrid(&scene->unit, ar, v3d, &grid_unit); /* XXX make function? replaces persp(1) */ glMatrixMode(GL_PROJECTION); wmLoadMatrix(rv3d->winmat); @@ -1983,7 +2037,7 @@ void view3d_main_area_draw(const bContext *C, ARegion *ar) } // retopo= retopo_mesh_check() || retopo_curve_check(); - sculptparticle= (G.f & (G_SCULPTMODE|G_PARTICLEEDIT)) && !scene->obedit; + sculptparticle= (obact && obact->mode & (OB_MODE_SCULPT|OB_MODE_PARTICLE_EDIT)) && !scene->obedit; if(retopo) view3d_update_depths(ar, v3d); @@ -1996,7 +2050,7 @@ void view3d_main_area_draw(const bContext *C, ARegion *ar) } if(!retopo && sculptparticle && !(obact && (obact->dtx & OB_DRAWXRAY))) { - if(G.f & G_SCULPTMODE) + if(obact && obact->mode & OB_MODE_SCULPT) draw_sculpt_depths(scene, ar, v3d); view3d_update_depths(ar, v3d); } @@ -2012,7 +2066,7 @@ void view3d_main_area_draw(const bContext *C, ARegion *ar) view3d_draw_xray(scene, ar, v3d, 1); // clears zbuffer if it is used! if(!retopo && sculptparticle && (obact && (OBACT->dtx & OB_DRAWXRAY))) { - if(G.f & G_SCULPTMODE) + if(obact && obact->mode & OB_MODE_SCULPT) draw_sculpt_depths(scene, ar, v3d); view3d_update_depths(ar, v3d); } @@ -2060,19 +2114,23 @@ void view3d_main_area_draw(const bContext *C, ARegion *ar) if(U.uiflag & USER_SHOW_VIEWPORTNAME) { draw_viewport_name(ar, v3d); } - + if (grid_unit) { /* draw below the viewport name */ + UI_ThemeColor(TH_TEXT_HI); + BLF_draw_default(10, ar->winy-(USER_SHOW_VIEWPORTNAME?40:20), 0.0f, grid_unit); + } + ob= OBACT; if(U.uiflag & USER_DRAWVIEWINFO) draw_selected_name(scene, ob, v3d); /* XXX here was the blockhandlers for floating panels */ - if(G.f & G_VERTEXPAINT || G.f & G_WEIGHTPAINT || G.f & G_TEXTUREPAINT) { + if(ob && ob->mode & (OB_MODE_VERTEX_PAINT|OB_MODE_WEIGHT_PAINT|OB_MODE_TEXTURE_PAINT)) { v3d->flag |= V3D_NEEDBACKBUFDRAW; // XXX addafterqueue(ar->win, BACKBUFDRAW, 1); } - if((G.f & G_PARTICLEEDIT) && v3d->drawtype>OB_WIRE && (v3d->flag & V3D_ZBUF_SELECT)) { + if((ob && ob->mode & OB_MODE_PARTICLE_EDIT) && v3d->drawtype>OB_WIRE && (v3d->flag & V3D_ZBUF_SELECT)) { v3d->flag |= V3D_NEEDBACKBUFDRAW; // XXX addafterqueue(ar->win, BACKBUFDRAW, 1); } diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c index acb3a2257dc..a7ea19e49f9 100644 --- a/source/blender/editors/space_view3d/view3d_edit.c +++ b/source/blender/editors/space_view3d/view3d_edit.c @@ -54,6 +54,7 @@ #include "BKE_depsgraph.h" #include "BKE_object.h" #include "BKE_global.h" +#include "BKE_paint.h" #include "BKE_report.h" #include "BKE_scene.h" #include "BKE_screen.h" @@ -856,6 +857,7 @@ static int viewhome_exec(bContext *C, wmOperator *op) /* was view3d_home() in 2. RegionView3D *rv3d= CTX_wm_region_view3d(C); Scene *scene= CTX_data_scene(C); Base *base; + float *curs; int center= RNA_boolean_get(op->ptr, "center"); @@ -865,6 +867,10 @@ static int viewhome_exec(bContext *C, wmOperator *op) /* was view3d_home() in 2. if(center) { min[0]= min[1]= min[2]= 0.0f; max[0]= max[1]= max[2]= 0.0f; + + /* in 2.4x this also move the cursor to (0, 0, 0) (with shift+c). */ + curs= give_cursor(scene, v3d); + curs[0]= curs[1]= curs[2]= 0.0; } else { INIT_MINMAX(min, max); @@ -904,6 +910,9 @@ static int viewhome_exec(bContext *C, wmOperator *op) /* was view3d_home() in 2. rv3d->persp= V3D_PERSP; smooth_view(C, NULL, v3d->camera, new_ofs, NULL, &new_dist, NULL); } + else { + smooth_view(C, NULL, NULL, new_ofs, NULL, &new_dist, NULL); + } } // XXX BIF_view3d_previewrender_signal(curarea, PR_DBASE|PR_DISPRECT); @@ -947,14 +956,14 @@ static int viewcenter_exec(bContext *C, wmOperator *op) /* like a localview with INIT_MINMAX(min, max); - if (G.f & G_WEIGHTPAINT) { + if (ob && ob->mode & OB_MODE_WEIGHT_PAINT) { /* hardcoded exception, we look for the one selected armature */ /* this is weak code this way, we should make a generic active/selection callback interface once... */ Base *base; for(base=scene->base.first; base; base= base->next) { if(TESTBASELIB(v3d, base)) { if(base->object->type==OB_ARMATURE) - if(base->object->flag & OB_POSEMODE) + if(base->object->mode & OB_MODE_POSE) break; } } @@ -966,7 +975,7 @@ static int viewcenter_exec(bContext *C, wmOperator *op) /* like a localview with if(obedit) { ok = minmax_verts(obedit, min, max); /* only selected */ } - else if(ob && (ob->flag & OB_POSEMODE)) { + else if(ob && (ob->mode & OB_MODE_POSE)) { if(ob->pose) { bArmature *arm= ob->data; bPoseChannel *pchan; @@ -987,10 +996,10 @@ static int viewcenter_exec(bContext *C, wmOperator *op) /* like a localview with } } } - else if (FACESEL_PAINT_TEST) { + else if (paint_facesel_test(ob)) { // XXX ok= minmax_tface(min, max); } - else if (G.f & G_PARTICLEEDIT) { + else if (ob && (ob->mode & OB_MODE_PARTICLE_EDIT)) { ok= PE_minmax(scene, min, max); } else { @@ -2196,7 +2205,7 @@ void viewmoveNDOF(Scene *scene, ARegion *ar, View3D *v3d, int mode) rv3d->view = 0; //printf("passing here \n"); // - if (scene->obedit==NULL && ob && !(ob->flag & OB_POSEMODE)) { + if (scene->obedit==NULL && ob && !(ob->mode & OB_MODE_POSE)) { use_sel = 1; } diff --git a/source/blender/editors/space_view3d/view3d_header.c b/source/blender/editors/space_view3d/view3d_header.c index 2bc9b96281e..53dbe2dc9d9 100644 --- a/source/blender/editors/space_view3d/view3d_header.c +++ b/source/blender/editors/space_view3d/view3d_header.c @@ -61,6 +61,7 @@ #include "BKE_main.h" #include "BKE_mesh.h" #include "BKE_modifier.h" +#include "BKE_paint.h" #include "BKE_particle.h" #include "BKE_screen.h" #include "BKE_utildefines.h" /* for VECCOPY */ @@ -80,6 +81,7 @@ #include "RNA_access.h" #include "RNA_define.h" +#include "RNA_enum_types.h" #include "BIF_gl.h" #include "BIF_glutil.h" @@ -105,16 +107,6 @@ * This can be cleaned when I make some new 'mode' icons. */ -#define V3D_OBJECTMODE_SEL ICON_OBJECT_DATA -#define V3D_EDITMODE_SEL ICON_EDITMODE_HLT -#define V3D_SCULPTMODE_SEL ICON_SCULPTMODE_HLT -#define V3D_FACESELECT_SEL ICON_FACESEL_HLT /* this is not a mode anymore - just a switch */ -#define V3D_VERTEXPAINTMODE_SEL ICON_VPAINT_HLT -#define V3D_TEXTUREPAINTMODE_SEL ICON_TPAINT_HLT -#define V3D_WEIGHTPAINTMODE_SEL ICON_WPAINT_HLT -#define V3D_POSEMODE_SEL ICON_POSE_HLT -#define V3D_PARTICLEEDITMODE_SEL ICON_ANIM - #define TEST_EDITMESH if(obedit==0) return; \ if( (v3d->lay & obedit->lay)==0 ) return; @@ -135,29 +127,6 @@ static int retopo_mesh_paint_check() {return 0;} /* end XXX ************* */ - -/* well... in this file a lot of view mode manipulation happens, so let's have it defined here */ -void ED_view3d_exit_paint_modes(bContext *C) -{ - if(G.f & G_TEXTUREPAINT) - WM_operator_name_call(C, "PAINT_OT_texture_paint_toggle", WM_OP_EXEC_REGION_WIN, NULL); - if(G.f & G_VERTEXPAINT) - WM_operator_name_call(C, "PAINT_OT_vertex_paint_toggle", WM_OP_EXEC_REGION_WIN, NULL); - else if(G.f & G_WEIGHTPAINT) - WM_operator_name_call(C, "PAINT_OT_weight_paint_toggle", WM_OP_EXEC_REGION_WIN, NULL); - - if(G.f & G_SCULPTMODE) - WM_operator_name_call(C, "SCULPT_OT_sculptmode_toggle", WM_OP_EXEC_REGION_WIN, NULL); - if(G.f & G_PARTICLEEDIT) - WM_operator_name_call(C, "PARTICLE_OT_particle_edit_toggle", WM_OP_EXEC_REGION_WIN, NULL); - - G.f &= ~(G_VERTEXPAINT+G_TEXTUREPAINT+G_WEIGHTPAINT+G_SCULPTMODE+G_PARTICLEEDIT); -} - - - - - static void do_view3d_header_buttons(bContext *C, void *arg, int event); #define B_SCENELOCK 101 @@ -220,55 +189,6 @@ static void handle_view3d_lock(bContext *C) } } -/* XXX; all this context stuff... should become operator */ -void do_layer_buttons(bContext *C, short event) -{ - wmWindow *win= CTX_wm_window(C); - Scene *scene= CTX_data_scene(C); - ScrArea *sa= CTX_wm_area(C); - View3D *v3d= sa->spacedata.first; - static int oldlay= 1; - short shift, alt, ctrl; - - shift= win->eventstate->shift; - alt= win->eventstate->alt; - ctrl= win->eventstate->ctrl; - - if(v3d==0) return; - if(v3d->localview) return; - - if(event==-1 && ctrl) { - v3d->scenelock= !v3d->scenelock; - do_view3d_header_buttons(C, NULL, B_SCENELOCK); - } else if (event<0) { - if(v3d->lay== (1<<20)-1) { - if(event==-2 || shift) v3d->lay= oldlay; - } - else { - oldlay= v3d->lay; - v3d->lay= (1<<20)-1; - } - - if(v3d->scenelock) handle_view3d_lock(C); - - /* new layers might need unflushed events events */ - DAG_scene_update_flags(scene, v3d->lay); /* tags all that moves and flushes */ - } - else { - if(alt) { - if(event<11) event+= 10; - } - if(shift) { - if(v3d->lay & (1<<event)) v3d->lay -= (1<<event); - else v3d->lay += (1<<event); - } - do_view3d_header_buttons(C, NULL, event+B_LAY); - } - ED_area_tag_redraw(sa); - - if(v3d->drawtype == OB_SHADED) reshadeall_displist(scene); -} - static int layers_exec(bContext *C, wmOperator *op) { Scene *scene= CTX_data_scene(C); @@ -347,403 +267,6 @@ void VIEW3D_OT_layers(wmOperatorType *ot) RNA_def_boolean(ot->srna, "extend", 0, "Extend", ""); } - -#if 0 -static void do_view3d_view_camerasmenu(bContext *C, void *arg, int event) -{ - Scene *scene= CTX_data_scene(C); - Base *base; - int i=1; - - if (event == 1) { - /* Set Active Object as Active Camera */ - /* XXX ugly hack alert */ -// G.qual |= LR_CTRLKEY; -// persptoetsen(PAD0); -// G.qual &= ~LR_CTRLKEY; - } else { - - for( base = FIRSTBASE; base; base = base->next ) { - if (base->object->type == OB_CAMERA) { - i++; - - if (event==i) { - /* XXX use api call! */ - - break; - } - } - } - } - -} - - -static uiBlock *view3d_view_camerasmenu(bContext *C, ARegion *ar, void *arg_unused) -{ - Scene *scene= CTX_data_scene(C); - Base *base; - uiBlock *block; - short yco= 0, menuwidth=120; - int i=1; - char camname[48]; - - block= uiBeginBlock(C, ar, "view3d_view_camerasmenu", UI_EMBOSSP); - uiBlockSetButmFunc(block, do_view3d_view_camerasmenu, NULL); - - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Set Active Object as Active Camera|Ctrl NumPad 0", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 1, ""); - - uiDefBut(block, SEPR, 0, "", 0, yco-=6, 140, 6, NULL, 0.0, 0.0, 0, 0, ""); - - for( base = FIRSTBASE; base; base = base->next ) { - if (base->object->type == OB_CAMERA) { - i++; - - strcpy(camname, base->object->id.name+2); - if (base->object == scene->camera) strcat(camname, " (Active)"); - - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, camname, 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, i, ""); - } - } - - uiBlockSetDirection(block, UI_RIGHT); - uiTextBoundsBlock(block, 50); - return block; -} -#endif - -#if 0 -static void do_view3d_view_cameracontrolsmenu(bContext *C, void *arg, int event) -{ - switch(event) { - case 0: /* Orbit Left */ - persptoetsen(PAD4); - break; - case 1: /* Orbit Right */ - persptoetsen(PAD6); - break; - case 2: /* Orbit Up */ - persptoetsen(PAD8); - break; - case 3: /* Orbit Down */ - persptoetsen(PAD2); - break; - case 4: /* Pan left */ - /* XXX ugly hack alert */ -// G.qual |= LR_CTRLKEY; - persptoetsen(PAD4); -// G.qual &= ~LR_CTRLKEY; - break; - case 5: /* Pan right */ - /* XXX ugly hack alert */ -// G.qual |= LR_CTRLKEY; - persptoetsen(PAD6); -// G.qual &= ~LR_CTRLKEY; - break; - case 6: /* Pan up */ - /* ugly hack alert */ -// G.qual |= LR_CTRLKEY; - persptoetsen(PAD8); -// G.qual &= ~LR_CTRLKEY; - break; - case 7: /* Pan down */ - /* ugly hack alert */ -// G.qual |= LR_CTRLKEY; - persptoetsen(PAD2); -// G.qual &= ~LR_CTRLKEY; - break; - case 8: /* Zoom In */ - persptoetsen(PADPLUSKEY); - break; - case 9: /* Zoom Out */ - persptoetsen(PADMINUS); - break; - case 10: /* Reset Zoom */ - persptoetsen(PADENTER); - break; - case 11: /* Camera Fly mode */ - fly(); - break; - } -} - - -static uiBlock *view3d_view_cameracontrolsmenu(bContext *C, ARegion *ar, void *arg_unused) -{ -/* static short tog=0; */ - uiBlock *block; - short yco= 0, menuwidth=120; - - block= uiBeginBlock(C, ar, "view3d_view_cameracontrolsmenu", UI_EMBOSSP); - uiBlockSetButmFunc(block, do_view3d_view_cameracontrolsmenu, NULL); - - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Camera Fly Mode|Shift F", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 11, ""); - - uiDefBut(block, SEPR, 0, "", 0, yco-=6, 140, 6, NULL, 0.0, 0.0, 0, 0, ""); - - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Orbit Left|NumPad 4", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 0, ""); - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Orbit Right|NumPad 6", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 1, ""); - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Orbit Up|NumPad 8", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 2, ""); - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Orbit Down|NumPad 2", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 3, ""); - - uiDefBut(block, SEPR, 0, "", 0, yco-=6, 140, 6, NULL, 0.0, 0.0, 0, 0, ""); - - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Pan Left|Ctrl NumPad 4", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 4, ""); - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Pan Right|Ctrl NumPad 6", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 5, ""); - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Pan Up|Ctrl NumPad 8", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 6, ""); - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Pan Down|Ctrl NumPad 2", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 7, ""); - - uiDefBut(block, SEPR, 0, "", 0, yco-=6, 140, 6, NULL, 0.0, 0.0, 0, 0, ""); - - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Zoom In|NumPad +", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 8, ""); - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Zoom Out|NumPad -", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 9, ""); - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Reset Zoom|NumPad Enter", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 10, ""); - - uiBlockSetDirection(block, UI_RIGHT); - uiTextBoundsBlock(block, 50); - return block; -} - -static void do_view3d_view_alignviewmenu(bContext *C, void *arg, int event) -{ - Scene *scene= CTX_data_scene(C); - ScrArea *sa= CTX_wm_area(C); - View3D *v3d= sa->spacedata.first; - Object *obedit = CTX_data_edit_object(C); - float *curs; - - switch(event) { - - case 0: /* Align View to Selected (edit/faceselect mode) */ - case 1: - case 2: - if ((obedit) && (obedit->type == OB_MESH)) { - editmesh_align_view_to_selected(v3d, event + 1); - } - else if (FACESEL_PAINT_TEST) { - Object *obact= OBACT; - if (obact && obact->type==OB_MESH) { - Mesh *me= obact->data; - - if (me->mtface) { -// XXX faceselect_align_view_to_selected(v3d, me, event + 1); - ED_area_tag_redraw(sa); - } - } - } - break; - case 3: /* Center View to Cursor */ - curs= give_cursor(scene, v3d); - v3d->ofs[0]= -curs[0]; - v3d->ofs[1]= -curs[1]; - v3d->ofs[2]= -curs[2]; - ED_area_tag_redraw(sa); - break; - case 4: /* Align Active Camera to View */ - /* XXX This ugly hack is a symptom of the nasty persptoetsen function, - * but at least it works for now. - */ -// G.qual |= LR_CTRLKEY|LR_ALTKEY; - persptoetsen(PAD0); -// G.qual &= ~(LR_CTRLKEY|LR_ALTKEY); - break; - case 5: /* Align View to Selected (object mode) */ -// XXX mainqenter(PADASTERKEY, 1); - break; - case 6: /* Center View and Cursor to Origin */ - WM_operator_name_call(C, "VIEW3D_OT_view_center", WM_OP_EXEC_REGION_WIN, NULL); - curs= give_cursor(scene, v3d); - curs[0]=curs[1]=curs[2]= 0.0; - break; - } -} - -static uiBlock *view3d_view_alignviewmenu(bContext *C, ARegion *ar, void *arg_unused) -{ -/* static short tog=0; */ - uiBlock *block; - Object *obedit = CTX_data_edit_object(C); - short yco= 0, menuwidth=120; - - block= uiBeginBlock(C, ar, "view3d_view_alignviewmenu", UI_EMBOSSP); - uiBlockSetButmFunc(block, do_view3d_view_alignviewmenu, NULL); - - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Center View to Cursor|C", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 3, ""); - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Center Cursor and View All|Shift C", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 6, ""); - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Align Active Camera to View|Ctrl Alt NumPad 0", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 4, ""); - - if (((obedit) && (obedit->type == OB_MESH)) || (FACESEL_PAINT_TEST)) { - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Align View to Selected (Top)|Shift V", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 2, ""); - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Align View to Selected (Front)|Shift V", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 1, ""); - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Align View to Selected (Side)|Shift V", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 0, ""); - } else { - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Align View to Selected|NumPad *", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 5, ""); - } - - uiBlockSetDirection(block, UI_RIGHT); - uiTextBoundsBlock(block, 50); - return block; -} -#endif - -#if 0 -static uiBlock *view3d_view_spacehandlers(bContext *C, ARegion *ar, void *arg_unused) -{ - /* XXX */ - return NULL; -} - - -static void do_view3d_viewmenu(bContext *C, void *arg, int event) -{ - - switch(event) { - case 0: /* User */ - break; - case 1: /* Camera */ - break; - case 2: /* Top */ - break; - case 3: /* Front */ - break; - case 4: /* Side */ - break; - case 5: /* Perspective */ - break; - case 6: /* Orthographic */ - break; - case 7: /* Local View */ - break; - case 8: /* Global View */ - break; - case 9: /* View All (Home) */ - WM_operator_name_call(C, "VIEW3D_OT_view_all", WM_OP_EXEC_REGION_WIN, NULL); - break; - case 11: /* View Selected */ - WM_operator_name_call(C, "VIEW3D_OT_view_center", WM_OP_EXEC_REGION_WIN, NULL); - break; - case 13: /* Play Back Animation */ - break; - case 15: /* Background Image... */ -// add_blockhandler(sa, VIEW3D_HANDLER_BACKGROUND, UI_PNL_UNSTOW); - break; - case 16: /* View Panel */ -// add_blockhandler(sa, VIEW3D_HANDLER_PROPERTIES, UI_PNL_UNSTOW); - break; - case 17: /* Set Clipping Border */ - WM_operator_name_call(C, "VIEW3D_OT_clip_border", WM_OP_INVOKE_REGION_WIN, NULL); - break; - case 18: /* render preview */ -// toggle_blockhandler(sa, VIEW3D_HANDLER_PREVIEW, 0); - break; - case 19: /* zoom within border */ -// view3d_border_zoom(); - break; - case 20: /* Transform Space Panel */ -// add_blockhandler(sa, VIEW3D_HANDLER_TRANSFORM, UI_PNL_UNSTOW); - break; - case 21: /* Grease Pencil */ -// add_blockhandler(sa, VIEW3D_HANDLER_GREASEPENCIL, UI_PNL_UNSTOW); - break; - case 22: /* View all layers */ - do_layer_buttons(C, -2); - break; - } -} -#endif - -#if 0 -static uiBlock *view3d_viewmenu(bContext *C, ARegion *ar, void *arg_unused) -{ - ScrArea *sa= CTX_wm_area(C); - View3D *v3d= sa->spacedata.first; - RegionView3D *rv3d= wm_region_view3d(C); - uiBlock *block; - short yco= 0, menuwidth=120; - - block= uiBeginBlock(C, ar, "view3d_viewmenu", UI_EMBOSSP); - uiBlockSetButmFunc(block, do_view3d_viewmenu, NULL); - - uiDefIconTextBut(block, BUTM, 1, ICON_MENU_PANEL, "Transform Orientations...", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 20, ""); - uiDefIconTextBut(block, BUTM, 1, ICON_MENU_PANEL, "Render Preview...|Shift P", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 18, ""); - uiDefIconTextBut(block, BUTM, 1, ICON_MENU_PANEL, "View Properties...", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 16, ""); - uiDefIconTextBut(block, BUTM, 1, ICON_MENU_PANEL, "Background Image...", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 15, ""); - uiDefIconTextBut(block, BUTM, 1, ICON_MENU_PANEL, "Grease Pencil...", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 21, ""); - - uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, ""); - - if ((rv3d->viewbut == 0) && !(rv3d->persp == V3D_CAMOB)) uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_HLT, "User", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 0, ""); - else uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_DEHLT, "User", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 0, ""); - if (rv3d->persp == V3D_CAMOB) uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_HLT, "Camera|NumPad 0", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 1, ""); - else uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_DEHLT, "Camera|NumPad 0", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 1, ""); - if (rv3d->viewbut == 1) uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_HLT, "Top|NumPad 7", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 2, ""); - else uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_DEHLT, "Top|NumPad 7", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 2, ""); - if (rv3d->viewbut == 2) uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_HLT, "Front|NumPad 1", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 3, ""); - else uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_DEHLT, "Front|NumPad 1", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 3, ""); - if (rv3d->viewbut == 3) uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_HLT, "Side|NumPad 3", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 4, ""); - else uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_DEHLT, "Side|NumPad 3", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 4, ""); - - uiDefIconTextBlockBut(block, view3d_view_camerasmenu, NULL, ICON_RIGHTARROW_THIN, "Cameras", 0, yco-=20, 120, 19, ""); - - uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, ""); - - if(rv3d->persp==V3D_PERSP) uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_HLT, "Perspective|NumPad 5", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 5, ""); - else uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_DEHLT, "Perspective|NumPad 5", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 5, ""); - if(rv3d->persp==V3D_ORTHO) uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_HLT, "Orthographic|NumPad 5", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 6, ""); - else uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_DEHLT, "Orthographic|NumPad 5", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 6, ""); - - uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, ""); - - if(v3d->lay== (1<<20)-1) uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Show Previous Layers|Shift ~", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 22, ""); - else uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Show All Layers| ~", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 22, ""); - - uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, ""); - - if(v3d->localview) uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_HLT, "Local View|NumPad /", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 7, ""); - else uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_DEHLT, "Local View|NumPad /", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 7, ""); - if(!v3d->localview) uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_HLT, "Global View|NumPad /", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 8, ""); - else uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_DEHLT, "Global View|NumPad /", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 8, ""); - - uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, ""); - - uiDefIconTextBlockBut(block, view3d_view_cameracontrolsmenu, NULL, ICON_RIGHTARROW_THIN, "View Navigation", 0, yco-=20, 120, 19, ""); - uiDefIconTextBlockBut(block, view3d_view_alignviewmenu, NULL, ICON_RIGHTARROW_THIN, "Align View", 0, yco-=20, 120, 19, ""); - - uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, ""); - - if(rv3d->rflag & RV3D_CLIPPING) - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Clear Clipping Border|Alt B", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 17, ""); - else - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Set Clipping Border|Alt B", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 17, ""); - if (rv3d->persp==V3D_ORTHO) uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Zoom Within Border...|Shift B", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 19, ""); - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "View Selected|NumPad .", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 11, ""); - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "View All|Home", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 9, ""); - if(!sa->full) uiDefIconTextBut(block, BUTM, B_FULL, ICON_BLANK1, "Maximize Window|Ctrl UpArrow", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 99, ""); - else uiDefIconTextBut(block, BUTM, B_FULL, ICON_BLANK1, "Tile Window|Ctrl DownArrow", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 99, ""); - - uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, ""); - - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Play Back Animation|Alt A", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 13, ""); - -#ifndef DISABLE_PYTHON - uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, ""); - uiDefIconTextBlockBut(block, view3d_view_spacehandlers, NULL, ICON_RIGHTARROW_THIN, "Space Handler Scripts", 0, yco-=20, 120, 19, ""); -#endif - - if(ar->alignment==RGN_ALIGN_TOP) { - uiBlockSetDirection(block, UI_DOWN); - } - else { - uiBlockSetDirection(block, UI_TOP); - uiBlockFlipOrder(block); - } - - uiTextBoundsBlock(block, 50); - - return block; -} -#endif - #if 0 void do_view3d_select_object_typemenu(bContext *C, void *arg, int event) { @@ -964,188 +487,6 @@ static uiBlock *view3d_select_object_groupedmenu(bContext *C, ARegion *ar, void #endif -static void view3d_select_objectmenu(bContext *C, uiLayout *layout, void *arg_unused) -{ - uiItemO(layout, NULL, 0, "VIEW3D_OT_select_border"); - - uiItemS(layout); - - uiItemO(layout, "Select/Deselect All", 0, "OBJECT_OT_select_all_toggle"); - uiItemO(layout, "Inverse", 0, "OBJECT_OT_select_inverse"); - uiItemO(layout, "Random", 0, "OBJECT_OT_select_random"); - uiItemO(layout, "Select All by Layer", 0, "OBJECT_OT_select_by_layer"); - uiItemMenuEnumO(layout, "Select All by Type", 0, "OBJECT_OT_select_by_type", "type"); - uiItemMenuEnumO(layout, "Select Grouped", 0, "OBJECT_OT_select_grouped", "type"); - -#if 0 - uiDefIconTextBlockBut(block, view3d_select_object_layermenu, NULL, ICON_RIGHTARROW_THIN, "Select All by Layer", 0, yco-=20, 120, 19, ""); - uiDefIconTextBlockBut(block, view3d_select_object_typemenu, NULL, ICON_RIGHTARROW_THIN, "Select All by Type", 0, yco-=20, 120, 19, ""); - - uiItemS(layout); - - uiDefIconTextBlockBut(block, view3d_select_object_linkedmenu, NULL, ICON_RIGHTARROW_THIN, "Linked", 0, yco-=20, 120, 19, ""); - uiDefIconTextBlockBut(block, view3d_select_object_groupedmenu, NULL, ICON_RIGHTARROW_THIN, "Grouped", 0, yco-=20, 120, 19, ""); -#endif -} - -static void view3d_select_meshmenu(bContext *C, uiLayout *layout, void *arg_unused) -{ - uiItemO(layout, NULL, 0, "VIEW3D_OT_select_border"); - - uiItemS(layout); - - uiItemO(layout, "Select/Deselect All", 0, "MESH_OT_select_all_toggle"); - uiItemO(layout, "Inverse", 0, "MESH_OT_select_inverse"); - - uiItemS(layout); - - uiItemO(layout, "Random...", 0, "MESH_OT_select_random"); // Random... - uiItemO(layout, "Sharp Edges", 0, "MESH_OT_edges_select_sharp"); - uiItemO(layout, "Linked Flat Faces", 0, "MESH_OT_faces_select_linked_flat"); - - uiItemS(layout); - - uiItemEnumO(layout, "Triangles", 0, "MESH_OT_select_by_number_vertices", "type", 3); // Ctrl Alt Shift 3 - uiItemEnumO(layout, "Quads", 0, "MESH_OT_select_by_number_vertices", "type", 4); // Ctrl Alt Shift 4 - uiItemEnumO(layout, "Loose Verts/Edges", 0, "MESH_OT_select_by_number_vertices", "type", 5); // Ctrl Alt Shift 5 - uiItemO(layout, "Similar...", 0, "MESH_OT_select_similar"); - - uiItemS(layout); - - uiItemO(layout, "Less", 0, "MESH_OT_select_more"); - uiItemO(layout, "More", 0, "MESH_OT_select_less"); - - uiItemS(layout); - - uiItemO(layout, "Linked", 0, "MESH_OT_select_linked"); - uiItemO(layout, "Vertex Path", 0, "MESH_OT_select_vertex_path"); // W, Alt 7 - uiItemO(layout, "Edge Loop", 0, "MESH_OT_loop_multi_select"); - uiItemBooleanO(layout, "Edge Ring", 0, "MESH_OT_loop_multi_select", "ring", 1); - - uiItemS(layout); - - uiItemO(layout, NULL, 0, "MESH_OT_loop_to_region"); // Ctrl E 8 - uiItemO(layout, NULL, 0, "MESH_OT_region_to_loop"); // Ctrl E 9 -} - -static void view3d_select_curvemenu(bContext *C, uiLayout *layout, void *arg_unused) -{ - Object *obedit= CTX_data_edit_object(C); - - uiItemO(layout, NULL, 0, "VIEW3D_OT_select_border"); - uiItemO(layout, NULL, 0, "VIEW3D_OT_select_circle"); - - uiItemS(layout); - - uiItemO(layout, NULL, 0, "CURVE_OT_select_all_toggle"); - uiItemO(layout, NULL, 0, "CURVE_OT_select_inverse"); - uiItemO(layout, NULL, 0, "CURVE_OT_select_random"); // Random... - uiItemO(layout, NULL, 0, "CURVE_OT_select_every_nth"); // Every Nth.. - - uiItemS(layout); - - if(obedit->type == OB_SURF) { - uiItemO(layout, NULL, 0, "CURVE_OT_select_row"); - } - else { - uiItemO(layout, NULL, 0, "CURVE_OT_de_select_first"); - uiItemO(layout, NULL, 0, "CURVE_OT_de_select_last"); - uiItemO(layout, NULL, 0, "CURVE_OT_select_next"); - uiItemO(layout, NULL, 0, "CURVE_OT_select_previous"); - } - - uiItemS(layout); - - uiItemO(layout, NULL, 0, "CURVE_OT_select_more"); - uiItemO(layout, NULL, 0, "CURVE_OT_select_less"); - - /* commented out because it seems to only like the LKEY method - based on mouse pointer position :( */ - /* uiItemO(layout, NULL, 0, "CURVE_OT_select_linked"); */ - -#if 0 - G.qual |= LR_CTRLKEY; - select_connected_nurb(); - G.qual &= ~LR_CTRLKEY; - break;*/ -#endif -} - -static void view3d_select_metaballmenu(bContext *C, uiLayout *layout, void *arg_unused) -{ - uiItemO(layout, NULL, 0, "VIEW3D_OT_select_border"); - uiItemS(layout); - uiItemO(layout, NULL, 0, "MBALL_OT_select_deselect_all_metaelems"); - uiItemO(layout, NULL, 0, "MBALL_OT_select_inverse_metaelems"); - uiItemS(layout); - uiItemO(layout, NULL, 0, "MBALL_OT_select_random_metaelems"); -} - -static void view3d_select_latticemenu(bContext *C, uiLayout *layout, void *arg_unused) -{ - uiItemO(layout, NULL, 0, "VIEW3D_OT_select_border"); - uiItemS(layout); - uiItemO(layout, NULL, 0, "LATTICE_OT_select_all_toggle"); -} - -static void view3d_select_armaturemenu(bContext *C, uiLayout *layout, void *arg_unused) -{ - PointerRNA ptr; - - uiItemO(layout, NULL, 0, "VIEW3D_OT_select_border"); - - uiItemS(layout); - - uiItemO(layout, "Select/Deselect All", 0, "ARMATURE_OT_select_all_toggle"); - uiItemO(layout, "Inverse", 0, "ARMATURE_OT_select_inverse"); - - uiItemS(layout); - - uiItemEnumO(layout, "Parent", 0, "ARMATURE_OT_select_hierarchy", "direction", BONE_SELECT_PARENT); - uiItemEnumO(layout, "Child", 0, "ARMATURE_OT_select_hierarchy", "direction", BONE_SELECT_CHILD); - - uiItemS(layout); - - WM_operator_properties_create(&ptr, "ARMATURE_OT_select_hierarchy"); - RNA_boolean_set(&ptr, "extend", 1); - RNA_enum_set(&ptr, "direction", BONE_SELECT_PARENT); - uiItemFullO(layout, "Extend Parent", 0, "ARMATURE_OT_select_hierarchy", ptr.data, WM_OP_EXEC_REGION_WIN); - - WM_operator_properties_create(&ptr, "ARMATURE_OT_select_hierarchy"); - RNA_boolean_set(&ptr, "extend", 1); - RNA_enum_set(&ptr, "direction", BONE_SELECT_CHILD); - uiItemFullO(layout, "Extend Child", 0, "ARMATURE_OT_select_hierarchy", ptr.data, WM_OP_EXEC_REGION_WIN); -} - -static void view3d_select_posemenu(bContext *C, uiLayout *layout, void *arg_unused) -{ - PointerRNA ptr; - - uiItemO(layout, NULL, 0, "VIEW3D_OT_select_border"); - - uiItemS(layout); - - uiItemO(layout, "Select/Deselect All", 0, "POSE_OT_select_all_toggle"); - uiItemO(layout, "Inverse", 0, "POSE_OT_select_inverse"); - uiItemO(layout, "Constraint Target", 0, "POSE_OT_select_constraint_target"); - - uiItemS(layout); - - uiItemEnumO(layout, "Parent", 0, "POSE_OT_select_hierarchy", "direction", BONE_SELECT_PARENT); - uiItemEnumO(layout, "Child", 0, "POSE_OT_select_hierarchy", "direction", BONE_SELECT_CHILD); - - uiItemS(layout); - - WM_operator_properties_create(&ptr, "POSE_OT_select_hierarchy"); - RNA_boolean_set(&ptr, "extend", 1); - RNA_enum_set(&ptr, "direction", BONE_SELECT_PARENT); - uiItemFullO(layout, "Extend Parent", 0, "POSE_OT_select_hierarchy", ptr.data, WM_OP_EXEC_REGION_WIN); - - WM_operator_properties_create(&ptr, "POSE_OT_select_hierarchy"); - RNA_boolean_set(&ptr, "extend", 1); - RNA_enum_set(&ptr, "direction", BONE_SELECT_CHILD); - uiItemFullO(layout, "Extend Child", 0, "POSE_OT_select_hierarchy", ptr.data, WM_OP_EXEC_REGION_WIN); -} - void do_view3d_select_faceselmenu(bContext *C, void *arg, int event) { #if 0 @@ -1216,19 +557,15 @@ static uiBlock *view3d_select_faceselmenu(bContext *C, ARegion *ar, void *arg_un return block; } -static void view3d_edit_snapmenu(bContext *C, uiLayout *layout, void *arg_unused) +/* wrapper for python layouts */ +void uiTemplate_view3d_select_faceselmenu(uiLayout *layout, bContext *C) { - uiItemO(layout, NULL, 0, "VIEW3D_OT_snap_selected_to_grid"); - uiItemO(layout, NULL, 0, "VIEW3D_OT_snap_selected_to_cursor"); - uiItemO(layout, NULL, 0, "VIEW3D_OT_snap_selected_to_center"); - - uiItemS(layout); - - uiItemO(layout, NULL, 0, "VIEW3D_OT_snap_cursor_to_selected"); - uiItemO(layout, NULL, 0, "VIEW3D_OT_snap_cursor_to_grid"); - uiItemO(layout, NULL, 0, "VIEW3D_OT_snap_cursor_to_active"); + void *arg_unused = NULL; + ARegion *ar= CTX_wm_region(C); + view3d_select_faceselmenu(C, ar, arg_unused); } +#if 0 void do_view3d_transform_moveaxismenu(bContext *C, void *arg, int event) { #if 0 @@ -1429,7 +766,9 @@ static uiBlock *view3d_transform_scaleaxismenu(bContext *C, ARegion *ar, void *a uiTextBoundsBlock(block, 60); return block; } +#endif +#if 0 static void do_view3d_transformmenu(bContext *C, void *arg, int event) { #if 0 @@ -1665,10 +1004,12 @@ static uiBlock *view3d_object_mirrormenu(bContext *C, ARegion *ar, void *arg_unu return block; } #endif +#endif +#if 0 static void view3d_edit_object_transformmenu(bContext *C, uiLayout *layout, void *arg_unused) { -#if 0 +#if 0 // XXX not used anymore uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Apply Scale/Rotation to ObData|Ctrl A, 1", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 6, ""); apply_objects_locrot(); uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Apply Visual Transform|Ctrl A, 2", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 7, ""); @@ -1685,6 +1026,7 @@ static void view3d_edit_object_transformmenu(bContext *C, uiLayout *layout, void uiItemO(layout, NULL, 0, "OBJECT_OT_scale_clear"); uiItemO(layout, NULL, 0, "OBJECT_OT_origin_clear"); } +#endif #if 0 static void do_view3d_edit_object_makelocalmenu(bContext *C, void *arg, int event) @@ -1925,42 +1267,6 @@ static uiBlock *view3d_edit_object_copyattrmenu(bContext *C, ARegion *ar, void * } #endif -static void view3d_edit_object_parentmenu(bContext *C, uiLayout *layout, void *arg_unused) -{ - uiItemO(layout, "Make Parent...", 0, "OBJECT_OT_parent_set"); - uiItemO(layout, "Clear Parent...", 0, "OBJECT_OT_parent_clear"); -} - -static void view3d_edit_object_groupmenu(bContext *C, uiLayout *layout, void *arg_unused) -{ - uiItemO(layout, NULL, 0, "GROUP_OT_group_create"); - uiItemO(layout, NULL, 0, "GROUP_OT_objects_remove"); - - uiItemS(layout); - - uiItemO(layout, NULL, 0, "GROUP_OT_objects_add_active"); - uiItemO(layout, NULL, 0, "GROUP_OT_objects_remove_active"); -} - -static void view3d_edit_object_trackmenu(bContext *C, uiLayout *layout, void *arg_unused) -{ - uiItemO(layout, "Make Track...", 0, "OBJECT_OT_track_set"); - uiItemO(layout, "Clear Track...", 0, "OBJECT_OT_track_clear"); -} - -static void view3d_edit_object_constraintsmenu(bContext *C, uiLayout *layout, void *arg_unused) -{ - uiItemO(layout, NULL, 0, "OBJECT_OT_constraint_add_with_targets"); - uiItemO(layout, NULL, 0, "OBJECT_OT_constraints_clear"); -} - -static void view3d_edit_object_showhidemenu(bContext *C, uiLayout *layout, void *arg_unused) -{ - uiItemO(layout, "Show Hidden", 0, "OBJECT_OT_restrictview_clear"); - uiItemO(layout, "Hide Selected", 0, "OBJECT_OT_restrictview_set"); - uiItemBooleanO(layout, "Hide Unselected", 0, "OBJECT_OT_restrictview_set", "unselected", 1); -} - #if 0 #ifndef DISABLE_PYTHON static void do_view3d_edit_object_scriptsmenu(bContext *C, void *arg, int event) @@ -2034,919 +1340,6 @@ static void do_view3d_edit_objectmenu(bContext *C, void *arg, int event) } #endif -static void view3d_edit_objectmenu(bContext *C, uiLayout *layout, void *arg_unused) -{ -#if 0 - Object *ob= CTX_data_active_object(C); - - uiDefIconTextBlockBut(block, view3d_transformmenu, NULL, ICON_RIGHTARROW_THIN, "Transform", 0, yco-=20, 120, 19, ""); - uiDefIconTextBlockBut(block, view3d_object_mirrormenu, NULL, ICON_RIGHTARROW_THIN, "Mirror", 0, yco-=20, menuwidth, 19, ""); -#endif - - uiItemMenuF(layout, "Clear/Apply", 0, view3d_edit_object_transformmenu); - uiItemMenuF(layout, "Snap", 0, view3d_edit_snapmenu); - - uiItemS(layout); - - // TODO: these operators may get renamed - uiItemO(layout, NULL, 0, "ANIM_OT_insert_keyframe_menu"); - uiItemO(layout, NULL, 0, "ANIM_OT_delete_keyframe_v3d"); - - uiItemS(layout); - - uiItemO(layout, NULL, 0, "OBJECT_OT_duplicate"); - uiItemBooleanO(layout, "Duplicate Linked", 0, "OBJECT_OT_duplicate", "linked", 1); - uiItemO(layout, NULL, 0, "OBJECT_OT_delete"); - - uiItemO(layout, NULL, 0, "OBJECT_OT_proxy_make"); -#if 0 - uiDefIconTextBlockBut(block, view3d_edit_object_makelinksmenu, NULL, ICON_RIGHTARROW_THIN, "Make Links", 0, yco-=20, 120, 19, ""); - uiDefIconTextBlockBut(block, view3d_edit_object_singleusermenu, NULL, ICON_RIGHTARROW_THIN, "Make Single User", 0, yco-=20, 120, 19, ""); - uiDefIconTextBlockBut(block, view3d_edit_object_makelocalmenu, NULL, ICON_RIGHTARROW_THIN, "Make Local", 0, yco-=20, 120, 19, ""); - uiDefIconTextBlockBut(block, view3d_edit_object_copyattrmenu, NULL, ICON_RIGHTARROW_THIN, "Copy Attributes", 0, yco-=20, 120, 19, ""); -#endif - - uiItemS(layout); - - uiItemMenuF(layout, "Parent", 0, view3d_edit_object_parentmenu); - uiItemMenuF(layout, "Track", 0, view3d_edit_object_trackmenu); - uiItemMenuF(layout, "Group", 0, view3d_edit_object_groupmenu); - uiItemMenuF(layout, "Constraints", 0, view3d_edit_object_constraintsmenu); - -#if 0 - if(ob && ob->type == OB_MESH) { - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Boolean Operation...|W", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 7, ""); - } - - // join... (added already) - - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Convert Object Type...|Alt C", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 9, ""); -#endif - uiItemS(layout); - - uiItemO(layout, NULL, 0, "OBJECT_OT_join"); - - uiItemS(layout); - -#if 0 - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Move to Layer...|M", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 10, ""); -#endif - - uiItemMenuF(layout, "Show/Hide", 0, view3d_edit_object_showhidemenu); - -#if 0 -#ifndef DISABLE_PYTHON - uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, ""); - uiDefIconTextBlockBut(block, view3d_edit_object_scriptsmenu, NULL, ICON_RIGHTARROW_THIN, "Scripts", 0, yco-=20, 120, 19, ""); -#endif -#endif -} - -static void view3d_edit_mesh_verticesmenu(bContext *C, uiLayout *layout, void *arg_unused) -{ - uiItemO(layout, "Merge...", 0, "MESH_OT_merge"); - uiItemO(layout, "Rip", 0, "MESH_OT_rip"); - uiItemO(layout, "Split", 0, "MESH_OT_split"); - uiItemO(layout, "Separate", 0, "MESH_OT_separate"); - - uiItemS(layout); - - uiItemO(layout, "Smooth", 0, "MESH_OT_vertices_smooth"); - uiItemO(layout, "Remove Doubles", 0, "MESH_OT_remove_doubles"); - -#if 0 - uiItemS(layout); - - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Make Vertex Parent|Ctrl P", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 0, ""); // add_hook_menu(); - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Add Hook|Ctrl H", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 6, ""); // make_parent(); -#endif -} - -void do_view3d_edit_mesh_edgesmenu(bContext *C, void *arg, int event) -{ -#if 0 - Scene *scene= CTX_data_scene(C); - float fac; - short randfac; - - switch(event) { - case 9: /* Crease SubSurf */ - if(!multires_level1_test()) { - initTransform(TFM_CREASE, CTX_EDGE); - Transform(); - } - break; - case 12: /* Edgeslide */ - EdgeSlide(0,0.0); - break; - case 13: /* Edge Loop Delete */ - if(EdgeLoopDelete()) { - countall(); - ED_undo_push(C, "Erase Edge Loop"); - DAG_object_flush_update(scene, obedit, OB_RECALC_DATA); - } - break; - case 14: /*Collapse Edges*/ - collapseEdges(); - ED_undo_push(C, "Collapse"); - break; - case 17: /* Adjust Bevel Weight */ - if(!multires_level1_test()) { - initTransform(TFM_BWEIGHT, CTX_EDGE); - Transform(); - } - break; - } -#endif -} - -static void view3d_edit_mesh_edgesmenu(bContext *C, uiLayout *layout, void *arg_unused) -{ - uiItemO(layout, NULL, 0, "MESH_OT_edge_face_add"); - -#if 0 - uiItemO(layout, "Bevel", 0, "MESH_OT_bevel"); // bevelmenu(em) - uiItemO(layout, "Loop Subdivide...", 0, "MESH_OT_loop_subdivide"); // Ctr R, CutEdgeloop(1); - uiItemO(layout, "Knife Subdivide...", 0, "MESH_OT_loop_subdivide"); // Shift K, KnifeSubdivide(KNIFE_PROMPT); - - uiItemS(layout); -#endif - - uiItemO(layout, "Subdivide", 0, "MESH_OT_subdivide"); - uiItemFloatO(layout, "Subdivide Smooth", 0, "MESH_OT_subdivide", "smoothness", 1.0f); - - uiItemS(layout); - - uiItemO(layout, "Mark Seam", 0, "MESH_OT_mark_seam"); - uiItemBooleanO(layout, "Clear Seam", 0, "MESH_OT_mark_seam", "clear", 1); - - uiItemS(layout); - - uiItemO(layout, "Mark Sharp", 0, "MESH_OT_mark_sharp"); - uiItemBooleanO(layout, "Clear Sharp", 0, "MESH_OT_mark_sharp", "clear", 1); - -#if 0 - uiItemS(layout); - uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, ""); - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Adjust Bevel Weight|Ctrl Shift E", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 17, ""); - - uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, ""); - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Crease SubSurf|Shift E", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 9, ""); -#endif - - uiItemS(layout); - - uiItemEnumO(layout, "Rotate Edge CW", 0, "MESH_OT_edge_rotate", "direction", 1); - uiItemEnumO(layout, "Rotate Edge CCW", 0, "MESH_OT_edge_rotate", "direction", 2); - -#if 0 - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Slide Edge |Ctrl E", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 12, ""); - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Delete Edge Loop|X", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 13, ""); - - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Collapse", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 14, ""); -#endif -} - -static void view3d_edit_mesh_facesmenu(bContext *C, uiLayout *layout, void *arg_unused) -{ - uiItemO(layout, NULL, 0, "MESH_OT_edge_face_add"); - uiItemO(layout, NULL, 0, "MESH_OT_fill"); - uiItemO(layout, NULL, 0, "MESH_OT_beauty_fill"); - - uiItemS(layout); - - uiItemO(layout, NULL, 0, "MESH_OT_quads_convert_to_tris"); - uiItemO(layout, NULL, 0, "MESH_OT_tris_convert_to_quads"); - uiItemO(layout, NULL, 0, "MESH_OT_edge_flip"); - - uiItemS(layout); - - uiItemO(layout, NULL, 0, "MESH_OT_faces_shade_smooth"); - uiItemO(layout, NULL, 0, "MESH_OT_faces_shade_flat"); -} - -static void view3d_edit_mesh_normalsmenu(bContext *C, uiLayout *layout, void *arg_unused) -{ - uiItemO(layout, "Recalculate Outside", 0, "MESH_OT_normals_make_consistent"); - uiItemBooleanO(layout, "Recalculate Inside", 0, "MESH_OT_normals_make_consistent", "inside", 1); - - uiItemS(layout); - - uiItemO(layout, NULL, 0, "MESH_OT_flip_normals"); -} - -void do_view3d_edit_mirrormenu(bContext *C, void *arg, int event) -{ -#if 0 - float mat[3][3]; - - Mat3One(mat); - - switch(event) { - case 0: - initTransform(TFM_MIRROR, CTX_NO_PET); - Transform(); - break; - case 1: - initTransform(TFM_MIRROR, CTX_NO_PET|CTX_AUTOCONFIRM); - BIF_setSingleAxisConstraint(mat[0], " on global X axis"); - Transform(); - break; - case 2: - initTransform(TFM_MIRROR, CTX_NO_PET|CTX_AUTOCONFIRM); - BIF_setSingleAxisConstraint(mat[1], " on global Y axis"); - Transform(); - break; - case 3: - initTransform(TFM_MIRROR, CTX_NO_PET|CTX_AUTOCONFIRM); - BIF_setSingleAxisConstraint(mat[2], "on global Z axis"); - Transform(); - break; - case 4: - initTransform(TFM_MIRROR, CTX_NO_PET|CTX_AUTOCONFIRM); - BIF_setLocalAxisConstraint('X', " on local X axis"); - Transform(); - break; - case 5: - initTransform(TFM_MIRROR, CTX_NO_PET|CTX_AUTOCONFIRM); - BIF_setLocalAxisConstraint('Y', " on local Y axis"); - Transform(); - break; - case 6: - initTransform(TFM_MIRROR, CTX_NO_PET|CTX_AUTOCONFIRM); - BIF_setLocalAxisConstraint('Z', " on local Z axis"); - Transform(); - break; - } -#endif -} - -static uiBlock *view3d_edit_mirrormenu(bContext *C, ARegion *ar, void *arg_unused) -{ - uiBlock *block; - short yco = 20, menuwidth = 120; - - block= uiBeginBlock(C, ar, "view3d_edit_mirrormenu", UI_EMBOSSP); - uiBlockSetButmFunc(block, do_view3d_edit_mirrormenu, NULL); - - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Interactive Mirror|Ctrl M", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 0, ""); - - uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, ""); - - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "X Global|Ctrl M, X", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 1, ""); - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Y Global|Ctrl M, Y", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 2, ""); - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Z Global|Ctrl M, Z", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 3, ""); - - uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, ""); - - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "X Local|Ctrl M, X X", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 4, ""); - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Y Local|Ctrl M, Y Y", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 5, ""); - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Z Local|Ctrl M, Z Z", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 6, ""); - - uiBlockSetDirection(block, UI_RIGHT); - uiTextBoundsBlock(block, 60); - return block; -} - -static void view3d_edit_mesh_showhidemenu(bContext *C, uiLayout *layout, void *arg_unused) -{ - uiItemO(layout, NULL, 0, "MESH_OT_reveal"); - uiItemO(layout, NULL, 0, "MESH_OT_hide"); - uiItemBooleanO(layout, "Hide Unselected", 0, "MESH_OT_hide", "unselected", 1); -} - -#ifndef DISABLE_PYTHON -#if 0 -static void do_view3d_edit_mesh_scriptsmenu(bContext *C, void *arg, int event) -{ - BPY_menu_do_python(PYMENU_MESH, event); -} - -static uiBlock *view3d_edit_mesh_scriptsmenu(bContext *C, ARegion *ar, void *arg_unused) -{ - uiBlock *block; -// short yco = 20, menuwidth = 120; -// XXX BPyMenu *pym; -// int i = 0; - - block= uiBeginBlock(C, ar, "v3d_emesh_pymenu", UI_EMBOSSP); - uiBlockSetButmFunc(block, do_view3d_edit_mesh_scriptsmenu, NULL); - -// for (pym = BPyMenuTable[PYMENU_MESH]; pym; pym = pym->next, i++) { -// uiDefIconTextBut(block, BUTM, 1, ICON_PYTHON, pym->name, 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, i, pym->tooltip?pym->tooltip:pym->filename); -// } - - uiBlockSetDirection(block, UI_RIGHT); - uiTextBoundsBlock(block, 60); - - return block; -} -#endif -#endif /* DISABLE_PYTHON */ - -#if 0 -static void do_view3d_edit_meshmenu(bContext *C, void *arg, int event) -{ - ScrArea *sa= CTX_wm_area(C); - - switch(event) { - - case 2: /* transform properties */ - add_blockhandler(sa, VIEW3D_HANDLER_OBJECT, 0); - break; - case 4: /* insert keyframe */ - common_insertkey(); - break; - case 16: /* delete keyframe */ - common_deletekey(); - break; - } -} -#endif - -static void view3d_edit_meshmenu(bContext *C, uiLayout *layout, void *arg_unused) -{ - Scene *scene= CTX_data_scene(C); - ToolSettings *ts= CTX_data_tool_settings(C); - PointerRNA tsptr; - - RNA_pointer_create(&scene->id, &RNA_ToolSettings, ts, &tsptr); - - uiItemO(layout, "Undo Editing", 0, "ED_OT_undo"); - uiItemO(layout, "Redo Editing", 0, "ED_OT_redo"); - -#if 0 - uiDefIconTextBlockBut(block, editmode_undohistorymenu, NULL, ICON_RIGHTARROW_THIN, "Undo History", 0, yco-=20, 120, 19, ""); -#endif - - uiItemS(layout); - -#if 0 - uiDefIconTextBlockBut(block, view3d_transformmenu, NULL, ICON_RIGHTARROW_THIN, "Transform", 0, yco-=20, 120, 19, ""); - uiDefIconTextBlockBut(block, view3d_edit_mirrormenu, NULL, ICON_RIGHTARROW_THIN, "Mirror", 0, yco-=20, 120, 19, ""); - uiDefIconTextBlockBut(block, view3d_edit_snapmenu, NULL, ICON_RIGHTARROW_THIN, "Snap", 0, yco-=20, 120, 19, ""); -#endif - - uiItemMenuF(layout, "Snap", 0, view3d_edit_snapmenu); - - uiItemS(layout); - -#if 0 - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Insert Keyframe|I", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 4, ""); - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Delete Keyframe|Alt I", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 16, ""); - - uiItemS(layout); -#endif - - uiItemO(layout, NULL, 0, "UV_OT_mapping_menu"); - - uiItemS(layout); - - uiItemO(layout, NULL, 0, "MESH_OT_extrude"); - uiItemO(layout, NULL, 0, "MESH_OT_duplicate"); - uiItemO(layout, "Delete...", 0, "MESH_OT_delete"); - - uiItemS(layout); - - uiItemMenuF(layout, "Vertices", 0, view3d_edit_mesh_verticesmenu); - uiItemMenuF(layout, "Edges", 0, view3d_edit_mesh_edgesmenu); - uiItemMenuF(layout, "Faces", 0, view3d_edit_mesh_facesmenu); - uiItemMenuF(layout, "Normals", 0, view3d_edit_mesh_normalsmenu); - - uiItemS(layout); - - uiItemR(layout, NULL, 0, &tsptr, "automerge_editing", 0, 0, 0); - uiItemR(layout, NULL, 0, &tsptr, "proportional_editing", 0, 0, 0); // |O - uiItemMenuEnumR(layout, NULL, 0, &tsptr, "proportional_editing_falloff"); // |Shift O - - uiItemS(layout); - - uiItemMenuF(layout, "Show/Hide", 0, view3d_edit_mesh_showhidemenu); - -#if 0 -#ifndef DISABLE_PYTHON - uiItemS(layout); - uiDefIconTextBlockBut(block, view3d_edit_mesh_scriptsmenu, NULL, ICON_RIGHTARROW_THIN, "Scripts", 0, yco-=20, 120, 19, ""); -#endif -#endif -} - -static void view3d_edit_curve_controlpointsmenu(bContext *C, uiLayout *layout, void *arg_unused) -{ - Object *obedit= CTX_data_edit_object(C); - - if(obedit->type == OB_CURVE) { - uiItemEnumO(layout, NULL, 0, "TFM_OT_transform", "mode", TFM_TILT); - uiItemO(layout, NULL, 0, "CURVE_OT_tilt_clear"); - uiItemO(layout, NULL, 0, "CURVE_OT_separate"); - - uiItemS(layout); - - uiItemEnumO(layout, NULL, 0, "CURVE_OT_handle_type_set", "type", 1); - uiItemEnumO(layout, NULL, 0, "CURVE_OT_handle_type_set", "type", 3); - uiItemEnumO(layout, NULL, 0, "CURVE_OT_handle_type_set", "type", 2); - - uiItemS(layout); - } - - // XXX uiItemO(layout, NULL, 0, "OBJECT_OT_make_vertex_parent"); Make VertexParent|Ctrl P - // make_parent() - // XXX uiItemO(layout, NULL, 0, "OBJECT_OT_add_hook"); Add Hook| Ctrl H - // add_hook_menu() -} - -static void view3d_edit_curve_segmentsmenu(bContext *C, uiLayout *layout, void *arg_unused) -{ - uiItemO(layout, NULL, 0, "CURVE_OT_subdivide"); - uiItemO(layout, NULL, 0, "CURVE_OT_switch_direction"); -} - -static void view3d_edit_curve_showhidemenu(bContext *C, uiLayout *layout, void *arg_unused) -{ - uiItemO(layout, NULL, 0, "CURVE_OT_reveal"); - uiItemO(layout, NULL, 0, "CURVE_OT_hide"); - uiItemBooleanO(layout, "Hide Unselected", 0, "CURVE_OT_hide", "unselected", 1); -} - -static void view3d_edit_curvemenu(bContext *C, uiLayout *layout, void *arg_unused) -{ - Scene *scene= CTX_data_scene(C); - ToolSettings *ts= CTX_data_tool_settings(C); - PointerRNA tsptr; - - RNA_pointer_create(&scene->id, &RNA_ToolSettings, ts, &tsptr); - -#if 0 - uiDefIconTextBut(block, BUTM, 1, ICON_MENU_PANEL, "Transform Properties...|N", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 1, ""); - uiDefIconTextBlockBut(block, view3d_transformmenu, NULL, ICON_RIGHTARROW_THIN, "Transform", 0, yco-=20, 120, 19, ""); - uiDefIconTextBlockBut(block, view3d_edit_mirrormenu, NULL, ICON_RIGHTARROW_THIN, "Mirror", 0, yco-=20, menuwidth, 19, ""); -#endif - - uiItemMenuF(layout, "Snap", 0, view3d_edit_snapmenu); - - uiItemS(layout); - - // XXX uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Insert Keyframe|I", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 2, ""); - // common_insertkey(); - // XXX uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Delete Keyframe|Alt I", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 16, ""); - // common_deletekey(); - - - uiItemO(layout, NULL, 0, "CURVE_OT_extrude"); - uiItemO(layout, NULL, 0, "CURVE_OT_duplicate"); - uiItemO(layout, NULL, 0, "CURVE_OT_separate"); - uiItemO(layout, NULL, 0, "CURVE_OT_make_segment"); - uiItemO(layout, NULL, 0, "CURVE_OT_cyclic_toggle"); - uiItemO(layout, NULL, 0, "CURVE_OT_delete"); // Delete... - - uiItemS(layout); - - uiItemMenuF(layout, "Control Points", 0, view3d_edit_curve_controlpointsmenu); - uiItemMenuF(layout, "Segments", 0, view3d_edit_curve_segmentsmenu); - - uiItemS(layout); - - uiItemR(layout, NULL, 0, &tsptr, "proportional_editing", 0, 0, 0); // |O - uiItemMenuEnumR(layout, NULL, 0, &tsptr, "proportional_editing_falloff"); // |Shift O - - uiItemS(layout); - - uiItemMenuF(layout, "Show/Hide Control Points", 0, view3d_edit_curve_showhidemenu); -} - -static void view3d_edit_metaball_showhidemenu(bContext *C, uiLayout *layout, void *arg_unused) -{ - uiItemO(layout, NULL, 0, "MBALL_OT_hide_metaelems"); - uiItemO(layout, NULL, 0, "MBALL_OT_reveal_metaelems"); - uiItemBooleanO(layout, "Hide Unselected", 0, "MBALL_OT_hide_metaelems", "unselected", 1); -} - -static void view3d_edit_metaballmenu(bContext *C, uiLayout *layout, void *arg_unused) -{ - Scene *scene= CTX_data_scene(C); - ToolSettings *ts= CTX_data_tool_settings(C); - PointerRNA tsptr; - - RNA_pointer_create(&scene->id, &RNA_ToolSettings, ts, &tsptr); - - uiItemO(layout, "Undo Editing", 0, "ED_OT_undo"); - uiItemO(layout, "Redo Editing", 0, "ED_OT_redo"); - - uiItemS(layout); - - uiItemMenuF(layout, "Snap", 0, view3d_edit_snapmenu); - - uiItemS(layout); - - uiItemO(layout, NULL, 0, "MBALL_OT_delete_metaelems"); - uiItemO(layout, NULL, 0, "MBALL_OT_duplicate_metaelems"); - - uiItemS(layout); - - uiItemR(layout, NULL, 0, &tsptr, "proportional_editing", 0, 0, 0); // |O - uiItemMenuEnumR(layout, NULL, 0, &tsptr, "proportional_editing_falloff"); // |Shift O - - uiItemS(layout); - - uiItemMenuF(layout, "Show/Hide Control Points", 0, view3d_edit_metaball_showhidemenu); -} - -static void view3d_edit_text_charsmenu(bContext *C, uiLayout *layout, void *arg_unused) -{ - /* the character codes are specified in UTF-8 */ - - uiItemStringO(layout, "Copyright|Alt C", 0, "FONT_OT_text_insert", "text", "\xC2\xA9"); - uiItemStringO(layout, "Registered Trademark|Alt R", 0, "FONT_OT_text_insert", "text", "\xC2\xAE"); - - uiItemS(layout); - - uiItemStringO(layout, "Degree Sign|Alt G", 0, "FONT_OT_text_insert", "text", "\xC2\xB0"); - uiItemStringO(layout, "Multiplication Sign|Alt x", 0, "FONT_OT_text_insert", "text", "\xC3\x97"); - uiItemStringO(layout, "Circle|Alt .", 0, "FONT_OT_text_insert", "text", "\xC2\x8A"); - uiItemStringO(layout, "Superscript 1|Alt 1", 0, "FONT_OT_text_insert", "text", "\xC2\xB9"); - uiItemStringO(layout, "Superscript 2|Alt 2", 0, "FONT_OT_text_insert", "text", "\xC2\xB2"); - uiItemStringO(layout, "Superscript 3|Alt 3", 0, "FONT_OT_text_insert", "text", "\xC2\xB3"); - uiItemStringO(layout, "Double >>|Alt >", 0, "FONT_OT_text_insert", "text", "\xC2\xBB"); - uiItemStringO(layout, "Double <<|Alt <", 0, "FONT_OT_text_insert", "text", "\xC2\xAB"); - uiItemStringO(layout, "Promillage|Alt %", 0, "FONT_OT_text_insert", "text", "\xE2\x80\xB0"); - - uiItemS(layout); - - uiItemStringO(layout, "Dutch Florin|Alt F", 0, "FONT_OT_text_insert", "text", "\xC2\xA4"); - uiItemStringO(layout, "British Pound|Alt L", 0, "FONT_OT_text_insert", "text", "\xC2\xA3"); - uiItemStringO(layout, "Japanese Yen|Alt Y", 0, "FONT_OT_text_insert", "text", "\xC2\xA5"); - - uiItemS(layout); - - uiItemStringO(layout, "German S|Alt S", 0, "FONT_OT_text_insert", "text", "\xC3\x9F"); - uiItemStringO(layout, "Spanish Question Mark|Alt ?", 0, "FONT_OT_text_insert", "text", "\xC2\xBF"); - uiItemStringO(layout, "Spanish Exclamation Mark|Alt !", 0, "FONT_OT_text_insert", "text", "\xC2\xA1"); -} - -static void view3d_edit_textmenu(bContext *C, uiLayout *layout, void *arg_unused) -{ - uiItemO(layout, NULL, 0, "FONT_OT_file_paste"); - uiItemS(layout); - uiItemMenuF(layout, "Special Characters", 0, view3d_edit_text_charsmenu); -} - -static void view3d_edit_latticemenu(bContext *C, uiLayout *layout, void *arg_unused) -{ - Scene *scene= CTX_data_scene(C); - ToolSettings *ts= CTX_data_tool_settings(C); - PointerRNA tsptr; - - RNA_pointer_create(&scene->id, &RNA_ToolSettings, ts, &tsptr); - -#if 0 - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Undo Editing|U", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 0, ""); - - uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, ""); - - uiDefIconTextBlockBut(block, view3d_transformmenu, NULL, ICON_RIGHTARROW_THIN, "Transform", 0, yco-=20, 120, 19, ""); - uiDefIconTextBlockBut(block, view3d_edit_mirrormenu, NULL, ICON_RIGHTARROW_THIN, "Mirror", 0, yco-=20, menuwidth, 19, ""); -#endif - - uiItemMenuF(layout, "Snap", 0, view3d_edit_snapmenu); - - uiItemS(layout); - - // XXX uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Insert Keyframe|I", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 2, ""); - // common_insertkey(); - // XXX uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Delete Keyframe|Alt I", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 16, ""); - // common_deletekey(); - - uiItemO(layout, NULL, 0, "LATTICE_OT_make_regular"); - - uiItemS(layout); - - uiItemR(layout, NULL, 0, &tsptr, "proportional_editing", 0, 0, 0); // |O - uiItemMenuEnumR(layout, NULL, 0, &tsptr, "proportional_editing_falloff"); // |Shift O -} - - -static void view3d_edit_armature_parentmenu(bContext *C, uiLayout *layout, void *arg_unused) -{ - uiItemO(layout, NULL, 0, "ARMATURE_OT_parent_set"); - uiItemO(layout, NULL, 0, "ARMATURE_OT_parent_clear"); -} - -static void view3d_edit_armature_rollmenu(bContext *C, uiLayout *layout, void *arg_unused) -{ - /* 0 = 'Global', 1 = 'Cursor' */ - // TODO: keep these in sync... - uiItemEnumO(layout, "Clear Roll (Z-Axis Up)", 0, "ARMATURE_OT_calculate_roll", "type", 0); - uiItemEnumO(layout, "Roll to Cursor", 0, "ARMATURE_OT_calculate_roll", "type", 1); - - uiItemS(layout); - - uiItemEnumO(layout, "Set Roll", 0, "TFM_OT_transform", "mode", TFM_BONE_ROLL); -} - -static void view3d_edit_armature_settingsmenu(bContext *C, uiLayout *layout, void *arg_unused) -{ - uiItemEnumO(layout, "Toggle a Setting", 0, "ARMATURE_OT_flags_set", "mode", 2); - uiItemEnumO(layout, "Enable a Setting", 0, "ARMATURE_OT_flags_set", "mode", 1); - uiItemEnumO(layout, "Disable a Setting", 0, "ARMATURE_OT_flags_set", "mode", 0); -} - -#if 0 -static void do_view3d_edit_armaturemenu(bContext *C, void *arg, int event) -{ - static short numcuts= 2; - - switch(event) { - case 0: /* Undo Editing */ - remake_editArmature(); - break; - - case 6: /* Shear */ - initTransform(TFM_SHEAR, CTX_NONE); - Transform(); - break; - case 7: /* Warp */ - initTransform(TFM_WARP, CTX_NONE); - Transform(); - case 23: /* bone sketching panel */ - add_blockhandler(curarea, VIEW3D_HANDLER_BONESKETCH, UI_PNL_UNSTOW); - break; - } -} -#endif - -static void view3d_edit_armaturemenu(bContext *C, uiLayout *layout, void *arg_unused) -{ - Object *obedit = CTX_data_edit_object(C); - bArmature *arm= obedit->data; - -#if 0 - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Undo Editing|U", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 0, ""); - uiDefIconTextBut(block, BUTM, 1, ICON_MENU_PANEL, "Bone Sketching|P", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 23, ""); - uiDefIconTextBlockBut(block, view3d_transformmenu, NULL, ICON_RIGHTARROW_THIN, "Transform", 0, yco-=20, 120, 19, ""); - uiDefIconTextBlockBut(block, view3d_edit_mirrormenu, NULL, ICON_RIGHTARROW_THIN, "Mirror", 0, yco-=20, menuwidth, 19, ""); -#endif - uiItemMenuF(layout, "Snap", 0, view3d_edit_snapmenu); - uiItemMenuF(layout, "Bone Roll", 0, view3d_edit_armature_rollmenu); - - if (arm->drawtype == ARM_ENVELOPE) - uiItemEnumO(layout, "Scale Envelope Distance", 0, "TFM_OT_transform", "mode", TFM_BONESIZE); - else - uiItemEnumO(layout, "Scale B-Bone Width", 0, "TFM_OT_transform", "mode", TFM_BONESIZE); - - uiItemS(layout); - - uiItemO(layout, "Extrude", 0, "ARMATURE_OT_extrude"); - if (arm->flag & ARM_MIRROR_EDIT) - uiItemBooleanO(layout, "Extrude Forked", 0, "ARMATURE_OT_extrude", "forked", 1); - - uiItemO(layout, NULL, 0, "ARMATURE_OT_duplicate"); - uiItemO(layout, NULL, 0, "ARMATURE_OT_merge"); - uiItemO(layout, NULL, 0, "ARMATURE_OT_fill"); - uiItemO(layout, NULL, 0, "ARMATURE_OT_delete"); - uiItemO(layout, NULL, 0, "ARMATURE_OT_separate"); - - uiItemS(layout); - - uiItemO(layout, NULL, 0, "ARMATURE_OT_subdivide_simple"); - uiItemO(layout, NULL, 0, "ARMATURE_OT_subdivide_multi"); - - uiItemEnumO(layout, "AutoName Left/Right", 0, "ARMATURE_OT_autoside_names", "axis", 0); - uiItemEnumO(layout, "AutoName Front/Back", 0, "ARMATURE_OT_autoside_names", "axis", 1); - uiItemEnumO(layout, "AutoName Top/Bottom", 0, "ARMATURE_OT_autoside_names", "axis", 2); - - uiItemO(layout, "Flip Left/Right Names", 0, "ARMATURE_OT_flip_names"); - - uiItemS(layout); - - uiItemO(layout, NULL, 0, "ARMATURE_OT_armature_layers"); - uiItemO(layout, NULL, 0, "ARMATURE_OT_bone_layers"); - - uiItemS(layout); - - uiItemMenuF(layout, "Parent", 0, view3d_edit_armature_parentmenu); - - uiItemS(layout); - - uiItemMenuF(layout, "Bone Settings ", 0, view3d_edit_armature_settingsmenu); -} - - -static void view3d_pose_armature_transformmenu(bContext *C, uiLayout *layout, void *arg_unused) -{ - //uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Clear User Transform|W", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 4, ""); - //used: clear_user_transform(scene, ob); - //uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, ""); - - uiItemO(layout, NULL, 0, "POSE_OT_loc_clear"); - uiItemO(layout, NULL, 0, "POSE_OT_rot_clear"); - uiItemO(layout, NULL, 0, "POSE_OT_scale_clear"); - - // ??? - //uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Clear Origin|Alt O", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 0, ""); - //used:clear_object('o'); -} - -static void view3d_pose_armature_showhidemenu(bContext *C, uiLayout *layout, void *arg_unused) -{ - uiItemO(layout, "Show Hidden", 0, "POSE_OT_reveal"); - - uiItemO(layout, "Hide Selected", 0, "POSE_OT_hide"); - uiItemBooleanO(layout, "Hide Unselected", 0, "POSE_OT_hide", "unselected", 1); -} - -static void view3d_pose_armature_ikmenu(bContext *C, uiLayout *layout, void *arg_unused) -{ - uiItemO(layout, NULL, 0, "POSE_OT_ik_add"); - uiItemO(layout, NULL, 0, "POSE_OT_ik_clear"); -} - -static void view3d_pose_armature_constraintsmenu(bContext *C, uiLayout *layout, void *arg_unused) -{ - uiItemO(layout, NULL, 0, "POSE_OT_constraint_add_with_targets"); - uiItemO(layout, NULL, 0, "POSE_OT_constraints_clear"); -} - -static void view3d_pose_armature_groupmenu(bContext *C, uiLayout *layout, void *arg_unused) -{ - uiItemO(layout, "Add Selected to Active Group", 0, "POSE_OT_group_assign"); - //uiItemO(layout, "Add Selected to Group", 0, "POSE_OT_group_assign"); - - uiItemO(layout, "Add New Group", 0, "POSE_OT_group_add"); - - uiItemO(layout, "Remove from All Groups", 0, "POSE_OT_group_unassign"); - uiItemO(layout, "Remove Active Group", 0, "POSE_OT_group_remove"); -} - -static void view3d_pose_armature_motionpathsmenu(bContext *C, uiLayout *layout, void *arg_unused) -{ - uiItemO(layout, NULL, 0, "POSE_OT_paths_calculate"); - uiItemO(layout, NULL, 0, "POSE_OT_paths_clear"); -} - -static void view3d_pose_armature_poselibmenu(bContext *C, uiLayout *layout, void *arg_unused) -{ - uiItemO(layout, NULL, 0, "POSELIB_OT_browse_interactive"); - - uiItemS(layout); - - uiItemO(layout, NULL, 0, "POSELIB_OT_pose_add"); - uiItemO(layout, NULL, 0, "POSELIB_OT_pose_rename"); - uiItemO(layout, NULL, 0, "POSELIB_OT_pose_remove"); -} - -static void view3d_pose_armature_settingsmenu(bContext *C, uiLayout *layout, void *arg_unused) -{ - uiItemEnumO(layout, "Toggle a Setting", 0, "POSE_OT_flags_set", "mode", 2); - uiItemEnumO(layout, "Enable a Setting", 0, "POSE_OT_flags_set", "mode", 1); - uiItemEnumO(layout, "Disable a Setting", 0, "POSE_OT_flags_set", "mode", 0); -} - -#if 0 -static void do_view3d_pose_armaturemenu(bContext *C, void *arg, int event) -{ - Object *ob; - ob=OBACT; - - switch(event) { - case 5: - pose_copy_menu(); - break; - case 15: - pose_relax(); - break; - } -} -#endif - -static void view3d_pose_armaturemenu(bContext *C, uiLayout *layout, void *arg_unused) -{ - Object *ob = CTX_data_active_object(C); - bArmature *arm= ob->data; - -#if 0 // XXX to be ported, using uiItemMenuF(layout, "<Name>", 0, view3d_pose_armature_<category>menu); - uiDefIconTextBlockBut(block, view3d_transformmenu, NULL, ICON_RIGHTARROW_THIN, "Transform", 0, yco-=20, 120, 19, ""); -#endif - if ( (arm) && ((arm->drawtype == ARM_B_BONE) || (arm->drawtype == ARM_ENVELOPE)) ) - uiItemEnumO(layout, "Scale Envelope Distance", 0, "TFM_OT_transform", "mode", TFM_BONESIZE); - uiItemMenuF(layout, "Clear Transform", 0, view3d_pose_armature_transformmenu); - - uiItemS(layout); - - // TODO: these operators may get renamed - uiItemO(layout, NULL, 0, "ANIM_OT_insert_keyframe_menu"); - uiItemO(layout, NULL, 0, "ANIM_OT_delete_keyframe_v3d"); - - uiItemS(layout); - -#if 0 - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Relax Pose|W", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 15, ""); -#endif - uiItemO(layout, NULL, 0, "POSE_OT_apply"); - - uiItemS(layout); - - uiItemO(layout, "Copy Current Pose", 0, "POSE_OT_copy"); - uiItemO(layout, "Paste Pose", 0, "POSE_OT_paste"); - uiItemBooleanO(layout, "Paste X-Flipped Pose", 0, "POSE_OT_paste", "flipped", 1); - - uiItemS(layout); - - uiItemMenuF(layout, "Pose Library", 0, view3d_pose_armature_poselibmenu); - uiItemMenuF(layout, "Motion Paths", 0, view3d_pose_armature_motionpathsmenu); - uiItemMenuF(layout, "Bone Groups", 0, view3d_pose_armature_groupmenu); - - uiItemS(layout); - - uiItemMenuF(layout, "Inverse Kinematics", 0, view3d_pose_armature_ikmenu); - uiItemMenuF(layout, "Constraints", 0, view3d_pose_armature_constraintsmenu); - - uiItemS(layout); - - uiItemEnumO(layout, "AutoName Left/Right", 0, "POSE_OT_autoside_names", "axis", 0); - uiItemEnumO(layout, "AutoName Front/Back", 0, "POSE_OT_autoside_names", "axis", 1); - uiItemEnumO(layout, "AutoName Top/Bottom", 0, "POSE_OT_autoside_names", "axis", 2); - - uiItemO(layout, "Flip Left/Right Names", 0, "POSE_OT_flip_names"); - - uiItemS(layout); - - uiItemO(layout, NULL, 0, "POSE_OT_armature_layers"); - uiItemO(layout, NULL, 0, "POSE_OT_bone_layers"); - - uiItemS(layout); - - uiItemMenuF(layout, "Show/Hide Bones", 0, view3d_pose_armature_showhidemenu); - uiItemMenuF(layout, "Bone Settings", 0, view3d_pose_armature_settingsmenu); - -#if 0 - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Copy Attributes...|Ctrl C", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 5, ""); -#endif -} - - -/* vertex paint menu */ -static void do_view3d_vpaintmenu(bContext *C, void *arg, int event) -{ -#if 0 - /* events >= 3 are registered bpython scripts */ -#ifndef DISABLE_PYTHON - if (event >= 3) BPY_menu_do_python(PYMENU_VERTEXPAINT, event - 3); -#endif - switch(event) { - case 0: /* undo vertex painting */ - BIF_undo(); - break; - case 1: /* set vertex colors/weight */ - if(FACESEL_PAINT_TEST) - clear_vpaint_selectedfaces(); - else /* we know were in vertex paint mode */ - clear_vpaint(); - break; - case 2: - make_vertexcol(1); - break; - } -#endif -} - -static uiBlock *view3d_vpaintmenu(bContext *C, ARegion *ar, void *arg_unused) -{ - uiBlock *block; - short yco= 0, menuwidth=120; -#ifndef DISABLE_PYTHON -// XXX BPyMenu *pym; -// int i=0; -#endif - - block= uiBeginBlock(C, ar, "view3d_paintmenu", UI_EMBOSSP); - uiBlockSetButmFunc(block, do_view3d_vpaintmenu, NULL); - - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Undo Vertex Painting|U", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 0, ""); - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Set Vertex Colors|Shift K", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 1, ""); - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Set Shaded Vertex Colors", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 2, ""); - -#ifndef DISABLE_PYTHON - /* note that we account for the 3 previous entries with i+3: - even if the last item isnt displayed, it dosent matter */ -// for (pym = BPyMenuTable[PYMENU_VERTEXPAINT]; pym; pym = pym->next, i++) { -// uiDefIconTextBut(block, BUTM, 1, ICON_PYTHON, pym->name, 0, yco-=20, -// menuwidth, 19, NULL, 0.0, 0.0, 1, i+3, -// pym->tooltip?pym->tooltip:pym->filename); -// } -#endif - - if(ar->alignment==RGN_ALIGN_TOP) { - uiBlockSetDirection(block, UI_DOWN); - } - else { - uiBlockSetDirection(block, UI_TOP); - uiBlockFlipOrder(block); - } - - uiTextBoundsBlock(block, 50); - return block; -} - /* texture paint menu (placeholder, no items yet??) */ static void do_view3d_tpaintmenu(bContext *C, void *arg, int event) @@ -3032,7 +1425,7 @@ static uiBlock *view3d_wpaintmenu(bContext *C, ARegion *ar, void *arg_unused) uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, ""); - if (FACESEL_PAINT_TEST) { + if (paint_facesel_test(CTX_data_active_object(C))) { uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Set Weight|Shift K", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 1, ""); uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, ""); menunr++; @@ -3060,185 +1453,6 @@ static uiBlock *view3d_wpaintmenu(bContext *C, ARegion *ar, void *arg_unused) return block; } -void do_view3d_sculpt_inputmenu(bContext *C, void *arg, int event) -{ -#if 0 - Scene *scene= CTX_data_scene(C); - SculptData *sd= &scene->sculptdata; - short val; - - switch(event) { - case 0: - sd->flags ^= SCULPT_INPUT_SMOOTH; - ED_undo_push(C, "Smooth stroke"); - break; - case 1: - val= sd->tablet_size; - if(button(&val,0,10,"Tablet Size:")==0) return; - sd->tablet_size= val; - ED_undo_push(C, "Tablet size"); - break; - case 2: - val= sd->tablet_strength; - if(button(&val,0,10,"Tablet Strength:")==0) return; - sd->tablet_strength= val; - ED_undo_push(C, "Tablet strength"); - break; - } - -#endif -} - -void do_view3d_sculptmenu(bContext *C, void *arg, int event) -{ -#if 0 - Scene *scene= CTX_data_scene(C); - ScrArea *sa= CTX_wm_area(C); - View3D *v3d= sa->spacedata.first; - SculptData *sd= &scene->sculptdata; - BrushData *br= sculptmode_brush(); - - switch(event) { - case 0: - case 1: - case 2: - case 3: - case 4: - case 5: - case 6: - sd->brush_type= event+1; - ED_undo_push(C, "Brush type"); - break; - case 11: - if(v3d) - v3d->pivot_last= !v3d->pivot_last; - break; - case 12: - sd->flags ^= SCULPT_DRAW_FAST; - ED_undo_push(C, "Partial Redraw"); - break; - case 13: - sd->flags ^= SCULPT_DRAW_BRUSH; - ED_undo_push(C, "Draw Brush"); - break; - case 14: - add_blockhandler(sa, VIEW3D_HANDLER_OBJECT, UI_PNL_UNSTOW); - break; - case 15: - sculpt_radialcontrol_start(RADIALCONTROL_ROTATION); - break; - case 16: - sculpt_radialcontrol_start(RADIALCONTROL_STRENGTH); - break; - case 17: - sculpt_radialcontrol_start(RADIALCONTROL_SIZE); - break; -#endif -} - -uiBlock *view3d_sculpt_inputmenu(bContext *C, ARegion *ar, void *arg_unused) -{ - uiBlock *block; - short yco= 0, menuwidth= 120; - Sculpt *sd= CTX_data_tool_settings(C)->sculpt; - - block= uiBeginBlock(C, ar, "view3d_sculpt_inputmenu", UI_EMBOSSP); - uiBlockSetButmFunc(block, do_view3d_sculpt_inputmenu, NULL); - - uiDefIconTextBut(block, BUTM, 1, ((sd->flags & SCULPT_INPUT_SMOOTH) ? ICON_CHECKBOX_HLT : ICON_CHECKBOX_DEHLT), "Smooth Stroke|Shift S", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 0, ""); - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Tablet Size Adjust", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 1, ""); - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Tablet Strength Adjust", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 2, ""); - - uiBlockSetDirection(block, UI_RIGHT); - uiTextBoundsBlock(block, 50); - return block; -} - -static void view3d_sculpt_menu(bContext *C, uiLayout *layout, void *arg_unused) -{ - bScreen *sc= CTX_wm_screen(C); - Sculpt *s = CTX_data_tool_settings(C)->sculpt; - PointerRNA rna; - - RNA_pointer_create(&sc->id, &RNA_Sculpt, s, &rna); - - uiItemR(layout, NULL, 0, &rna, "symmetry_x", 0, 0, 0); - uiItemR(layout, NULL, 0, &rna, "symmetry_y", 0, 0, 0); - uiItemR(layout, NULL, 0, &rna, "symmetry_z", 0, 0, 0); - uiItemR(layout, NULL, 0, &rna, "lock_x", 0, 0, 0); - uiItemR(layout, NULL, 0, &rna, "lock_y", 0, 0, 0); - uiItemR(layout, NULL, 0, &rna, "lock_z", 0, 0, 0); - - /* Brush settings */ - RNA_pointer_create(&sc->id, &RNA_Brush, s->brush, &rna); - - /* Curve */ - uiItemS(layout); - uiItemEnumO(layout, NULL, 0, "SCULPT_OT_brush_curve_preset", "mode", BRUSH_PRESET_SHARP); - uiItemEnumO(layout, NULL, 0, "SCULPT_OT_brush_curve_preset", "mode", BRUSH_PRESET_SMOOTH); - uiItemEnumO(layout, NULL, 0, "SCULPT_OT_brush_curve_preset", "mode", BRUSH_PRESET_MAX); - - uiItemS(layout); - - uiItemR(layout, NULL, 0, &rna, "airbrush", 0, 0, 0); - uiItemR(layout, NULL, 0, &rna, "rake", 0, 0, 0); - uiItemR(layout, NULL, 0, &rna, "anchored", 0, 0, 0); - uiItemR(layout, NULL, 0, &rna, "space", 0, 0, 0); - uiItemR(layout, NULL, 0, &rna, "smooth_stroke", 0, 0, 0); - - uiItemR(layout, NULL, 0, &rna, "flip_direction", 0, 0, 0); -} - -uiBlock *view3d_sculptmenu(bContext *C, ARegion *ar, void *arg_unused) -{ - ScrArea *sa= CTX_wm_area(C); - View3D *v3d= sa->spacedata.first; - uiBlock *block; - Sculpt *sd= CTX_data_tool_settings(C)->sculpt; -// XXX const BrushData *br= sculptmode_brush(); - short yco= 0, menuwidth= 120; - - block= uiBeginBlock(C, ar, "view3d_sculptmenu", UI_EMBOSSP); - uiBlockSetButmFunc(block, do_view3d_sculptmenu, NULL); - - uiDefIconTextBut(block, BUTM, 1, ICON_MENU_PANEL, "Sculpt Properties|N", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 14, ""); - uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, ""); - uiDefIconTextBlockBut(block, view3d_sculpt_inputmenu, NULL, ICON_RIGHTARROW_THIN, "Input Settings", 0, yco-=20, 120, 19, ""); - uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, ""); - uiDefIconTextBut(block, BUTM, 1, ((sd->flags & SCULPT_DRAW_BRUSH) ? ICON_CHECKBOX_HLT : ICON_CHECKBOX_DEHLT), "Display Brush", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 13, ""); - uiDefIconTextBut(block, BUTM, 1, ((sd->flags & SCULPT_DRAW_FAST) ? ICON_CHECKBOX_HLT : ICON_CHECKBOX_DEHLT), "Partial Redraw", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 12, ""); - if(v3d) - uiDefIconTextBut(block, BUTM, 1, (v3d->pivot_last ? ICON_CHECKBOX_HLT : ICON_CHECKBOX_DEHLT), "Pivot Last", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 11, ""); - - uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, ""); - - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Scale Brush|F", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 17, ""); - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Strengthen Brush|Shift F", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 16, ""); - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Rotate Brush|Ctrl F", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 15, ""); - - uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, ""); - /* XXX uiDefIconTextBut(block, BUTM, 1, (sd->brush_type==FLATTEN_BRUSH ? ICON_CHECKBOX_HLT : ICON_CHECKBOX_DEHLT), "Flatten|T", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 6, ""); - uiDefIconTextBut(block, BUTM, 1, (sd->brush_type==LAYER_BRUSH ? ICON_CHECKBOX_HLT : ICON_CHECKBOX_DEHLT), "Layer|L", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 5, ""); - uiDefIconTextBut(block, BUTM, 1, (sd->brush_type==GRAB_BRUSH ? ICON_CHECKBOX_HLT : ICON_CHECKBOX_DEHLT), "Grab|G", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 4, ""); - uiDefIconTextBut(block, BUTM, 1, (sd->brush_type==INFLATE_BRUSH ? ICON_CHECKBOX_HLT : ICON_CHECKBOX_DEHLT), "Inflate|I", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 3, ""); - uiDefIconTextBut(block, BUTM, 1, (sd->brush_type==PINCH_BRUSH ? ICON_CHECKBOX_HLT : ICON_CHECKBOX_DEHLT), "Pinch|P", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 2, ""); - uiDefIconTextBut(block, BUTM, 1, (sd->brush_type==SMOOTH_BRUSH ? ICON_CHECKBOX_HLT : ICON_CHECKBOX_DEHLT), "Smooth|S", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 1, ""); - uiDefIconTextBut(block, BUTM, 1, (sd->brush_type==DRAW_BRUSH ? ICON_CHECKBOX_HLT : ICON_CHECKBOX_DEHLT), "Draw|D", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 0, "");*/ - - - if(ar->alignment==RGN_ALIGN_TOP) { - uiBlockSetDirection(block, UI_DOWN); - } - else { - uiBlockSetDirection(block, UI_TOP); - uiBlockFlipOrder(block); - } - - uiTextBoundsBlock(block, 50); - - return block; -} - static void do_view3d_facesel_showhidemenu(bContext *C, void *arg, int event) { #if 0 @@ -3323,61 +1537,6 @@ static uiBlock *view3d_faceselmenu(bContext *C, ARegion *ar, void *arg_unused) return block; } -static void view3d_select_particlemenu(bContext *C, uiLayout *layout, void *arg_unused) -{ - ToolSettings *ts= CTX_data_tool_settings(C); - - uiItemO(layout, NULL, 0, "VIEW3D_OT_select_border"); - - uiItemS(layout); - - uiItemO(layout, NULL, 0, "PARTICLE_OT_select_all_toggle"); - uiItemO(layout, NULL, 0, "PARTICLE_OT_select_linked"); - - if(ts->particle.selectmode & SCE_SELECT_POINT) { - uiItemO(layout, NULL, 0, "PARTICLE_OT_select_last"); // |W, 4 - uiItemO(layout, NULL, 0, "PARTICLE_OT_select_first"); // |W, 3 - } - - uiItemS(layout); - - uiItemO(layout, NULL, 0, "PARTICLE_OT_select_more"); - uiItemO(layout, NULL, 0, "PARTICLE_OT_select_less"); -} - -static void view3d_particle_showhidemenu(bContext *C, uiLayout *layout, void *arg_unused) -{ - uiItemO(layout, NULL, 0, "PARTICLE_OT_reveal"); - uiItemO(layout, NULL, 0, "PARTICLE_OT_hide"); - uiItemBooleanO(layout, "Hide Unselected", 0, "PARTICLE_OT_hide", "unselected", 1); -} - -static void view3d_particlemenu(bContext *C, uiLayout *layout, void *arg_unused) -{ - ToolSettings *ts= CTX_data_tool_settings(C); - - // XXX uiDefIconTextBut(block, BUTM, 1, ICON_MENU_PANEL, "Particle Edit Properties|N", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 1, ""); - // add_blockhandler(sa, VIEW3D_HANDLER_OBJECT, UI_PNL_UNSTOW); - // XXX uiItemS(layout); - // - // XXX uiDefIconTextBut(block, BUTM, 1, (pset->flag & PE_X_MIRROR)? ICON_CHECKBOX_HLT: ICON_CHECKBOX_DEHLT, "X-Axis Mirror Editing", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 6, ""); - // pset->flag ^= PE_X_MIRROR; - - uiItemO(layout, NULL, 0, "PARTICLE_OT_mirror"); // |Ctrl M - - uiItemS(layout); - - uiItemO(layout, NULL, 0, "PARTICLE_OT_remove_doubles"); // |W, 5 - uiItemO(layout, NULL, 0, "PARTICLE_OT_delete"); - if(ts->particle.selectmode & SCE_SELECT_POINT) - uiItemO(layout, NULL, 0, "PARTICLE_OT_subdivide"); // |W, 2 - uiItemO(layout, NULL, 0, "PARTICLE_OT_rekey"); // |W, 1 - - uiItemS(layout); - - uiItemMenuF(layout, "Show/Hide Particles", 0, view3d_particle_showhidemenu); -} - static char *view3d_modeselect_pup(Scene *scene) { Object *ob= OBACT; @@ -3387,10 +1546,7 @@ static char *view3d_modeselect_pup(Scene *scene) str += sprintf(str, "Mode: %%t"); - if(ob) - str += sprintf(str, formatstr, "Object Mode", V3D_OBJECTMODE_SEL, ICON_OBJECT_DATA); - else - str += sprintf(str, formatstr, "Object Mode", V3D_OBJECTMODE_SEL, ICON_OBJECT_DATA); + str += sprintf(str, formatstr, "Object Mode", OB_MODE_OBJECT, ICON_OBJECT_DATA); if(ob==NULL) return string; @@ -3399,26 +1555,25 @@ static char *view3d_modeselect_pup(Scene *scene) || (ob->type == OB_CURVE) || (ob->type == OB_SURF) || (ob->type == OB_FONT) || (ob->type == OB_MBALL) || (ob->type == OB_LATTICE))) { - str += sprintf(str, formatstr, "Edit Mode", V3D_EDITMODE_SEL, ICON_EDITMODE_HLT); + str += sprintf(str, formatstr, "Edit Mode", OB_MODE_EDIT, ICON_EDITMODE_HLT); } if (ob->type == OB_MESH) { - str += sprintf(str, formatstr, "Sculpt Mode", V3D_SCULPTMODE_SEL, ICON_SCULPTMODE_HLT); - /*str += sprintf(str, formatstr, "Face Select", V3D_FACESELECTMODE_SEL, ICON_FACESEL_HLT);*/ - str += sprintf(str, formatstr, "Vertex Paint", V3D_VERTEXPAINTMODE_SEL, ICON_VPAINT_HLT); - str += sprintf(str, formatstr, "Texture Paint", V3D_TEXTUREPAINTMODE_SEL, ICON_TPAINT_HLT); - str += sprintf(str, formatstr, "Weight Paint", V3D_WEIGHTPAINTMODE_SEL, ICON_WPAINT_HLT); + str += sprintf(str, formatstr, "Sculpt Mode", OB_MODE_SCULPT, ICON_SCULPTMODE_HLT); + str += sprintf(str, formatstr, "Vertex Paint", OB_MODE_VERTEX_PAINT, ICON_VPAINT_HLT); + str += sprintf(str, formatstr, "Texture Paint", OB_MODE_TEXTURE_PAINT, ICON_TPAINT_HLT); + str += sprintf(str, formatstr, "Weight Paint", OB_MODE_WEIGHT_PAINT, ICON_WPAINT_HLT); } /* if active object is an armature */ if (ob->type==OB_ARMATURE) { - str += sprintf(str, formatstr, "Pose Mode", V3D_POSEMODE_SEL, ICON_POSE_HLT); + str += sprintf(str, formatstr, "Pose Mode", OB_MODE_POSE, ICON_POSE_HLT); } if (ob->particlesystem.first) { - str += sprintf(str, formatstr, "Particle Mode", V3D_PARTICLEEDITMODE_SEL, ICON_PARTICLEMODE); + str += sprintf(str, formatstr, "Particle Mode", OB_MODE_PARTICLE_EDIT, ICON_PARTICLEMODE); } return (string); @@ -3506,11 +1661,10 @@ static void do_view3d_header_buttons(bContext *C, void *arg, int event) ToolSettings *ts= CTX_data_tool_settings(C); ScrArea *sa= CTX_wm_area(C); View3D *v3d= sa->spacedata.first; - Base *basact= CTX_data_active_base(C); - Object *ob= CTX_data_active_object(C); Object *obedit = CTX_data_edit_object(C); BMEditMesh *em= NULL; int bit, ctrl= win->eventstate->ctrl, shift= win->eventstate->shift; + PointerRNA props_ptr; if(obedit && obedit->type==OB_MESH) { em= ((Mesh *)obedit->data)->edit_btmesh; @@ -3557,79 +1711,10 @@ static void do_view3d_header_buttons(bContext *C, void *arg, int event) // XXX start_game(); break; case B_MODESELECT: - if (v3d->modeselect == V3D_OBJECTMODE_SEL) { - - v3d->flag &= ~V3D_MODE; - ED_view3d_exit_paint_modes(C); - ED_armature_exit_posemode(C, basact); - if(obedit) - ED_object_exit_editmode(C, EM_FREEDATA|EM_FREEUNDO|EM_WAITCURSOR); /* exit editmode and undo */ - } - else if (v3d->modeselect == V3D_EDITMODE_SEL) { - if(!obedit) { - v3d->flag &= ~V3D_MODE; - ED_object_enter_editmode(C, EM_WAITCURSOR); - ED_undo_push(C, "Original"); /* here, because all over code enter_editmode is abused */ - } - } - else if (v3d->modeselect == V3D_SCULPTMODE_SEL) { - if (!(G.f & G_SCULPTMODE)) { - v3d->flag &= ~V3D_MODE; - ED_view3d_exit_paint_modes(C); - if(obedit) ED_object_exit_editmode(C, EM_FREEUNDO|EM_FREEUNDO|EM_WAITCURSOR); /* exit editmode and undo */ - - WM_operator_name_call(C, "SCULPT_OT_sculptmode_toggle", WM_OP_EXEC_REGION_WIN, NULL); - } - } - else if (v3d->modeselect == V3D_VERTEXPAINTMODE_SEL) { - if (!(G.f & G_VERTEXPAINT)) { - v3d->flag &= ~V3D_MODE; - ED_view3d_exit_paint_modes(C); - if(obedit) ED_object_exit_editmode(C, EM_FREEDATA|EM_FREEUNDO|EM_WAITCURSOR); /* exit editmode and undo */ - - WM_operator_name_call(C, "PAINT_OT_vertex_paint_toggle", WM_OP_EXEC_REGION_WIN, NULL); - } - } - else if (v3d->modeselect == V3D_TEXTUREPAINTMODE_SEL) { - if (!(G.f & G_TEXTUREPAINT)) { - v3d->flag &= ~V3D_MODE; - ED_view3d_exit_paint_modes(C); - if(obedit) ED_object_exit_editmode(C, EM_FREEDATA|EM_FREEUNDO|EM_WAITCURSOR); /* exit editmode and undo */ - - WM_operator_name_call(C, "PAINT_OT_texture_paint_toggle", WM_OP_EXEC_REGION_WIN, NULL); - } - } - else if (v3d->modeselect == V3D_WEIGHTPAINTMODE_SEL) { - if (!(G.f & G_WEIGHTPAINT) && (ob && ob->type == OB_MESH) ) { - v3d->flag &= ~V3D_MODE; - ED_view3d_exit_paint_modes(C); - if(obedit) - ED_object_exit_editmode(C, EM_FREEDATA|EM_FREEUNDO|EM_WAITCURSOR); /* exit editmode and undo */ - - WM_operator_name_call(C, "PAINT_OT_weight_paint_toggle", WM_OP_EXEC_REGION_WIN, NULL); - } - } - else if (v3d->modeselect == V3D_POSEMODE_SEL) { - - if (ob) { - v3d->flag &= ~V3D_MODE; - if(obedit) - ED_object_exit_editmode(C, EM_FREEDATA|EM_FREEUNDO|EM_WAITCURSOR); /* exit editmode and undo */ - - ED_armature_enter_posemode(C, basact); - } - } - else if(v3d->modeselect == V3D_PARTICLEEDITMODE_SEL){ - if (!(G.f & G_PARTICLEEDIT)) { - v3d->flag &= ~V3D_MODE; - ED_view3d_exit_paint_modes(C); - if(obedit) ED_object_exit_editmode(C, EM_FREEDATA|EM_FREEUNDO|EM_WAITCURSOR); /* exit editmode and undo */ - - WM_operator_name_call(C, "PARTICLE_OT_particle_edit_toggle", WM_OP_EXEC_REGION_WIN, NULL); - } - } - break; - + WM_operator_properties_create(&props_ptr, "OBJECT_OT_mode_set"); + RNA_enum_set(&props_ptr, "mode", v3d->modeselect); + WM_operator_name_call(C, "OBJECT_OT_mode_set", WM_OP_EXEC_REGION_WIN, &props_ptr); + break; case B_AROUND: // XXX handle_view3d_around(); /* copies to other 3d windows */ break; @@ -3689,20 +1774,20 @@ static void do_view3d_header_buttons(bContext *C, void *arg, int event) case B_MAN_TRANS: if( shift==0 || v3d->twtype==0) { v3d->twtype= V3D_MANIP_TRANSLATE; - ED_area_tag_redraw(sa); } - break; + ED_area_tag_redraw(sa); + break; case B_MAN_ROT: if( shift==0 || v3d->twtype==0) { - v3d->twtype= V3D_MANIP_ROTATE; - ED_area_tag_redraw(sa); + v3d->twtype= V3D_MANIP_ROTATE; } + ED_area_tag_redraw(sa); break; case B_MAN_SCALE: if( shift==0 || v3d->twtype==0) { - v3d->twtype= V3D_MANIP_SCALE; - ED_area_tag_redraw(sa); + v3d->twtype= V3D_MANIP_SCALE; } + ED_area_tag_redraw(sa); break; case B_NDOF: break; @@ -3769,111 +1854,34 @@ static void view3d_header_pulldowns(const bContext *C, uiBlock *block, Object *o * height of the header */ xmax= GetButStringLength("Select"); - if (obedit) { - if (ob && ob->type == OB_MESH) { - uiDefMenuBut(block, view3d_select_meshmenu, NULL, "Select", xco,yco, xmax-3, 20, ""); - } else if (ob && (ob->type == OB_CURVE || ob->type == OB_SURF)) { - uiDefMenuBut(block, view3d_select_curvemenu, NULL, "Select", xco, yco, xmax-3, 20, ""); - } else if (ob && ob->type == OB_FONT) { - xmax= 0; - } else if (ob && ob->type == OB_MBALL) { - uiDefMenuBut(block, view3d_select_metaballmenu, NULL, "Select", xco,yco, xmax-3, 20, ""); - } else if (ob && ob->type == OB_LATTICE) { - uiDefMenuBut(block, view3d_select_latticemenu, NULL, "Select", xco, yco, xmax-3, 20, ""); - } else if (ob && ob->type == OB_ARMATURE) { - uiDefMenuBut(block, view3d_select_armaturemenu, NULL, "Select", xco,yco, xmax-3, 20, ""); - } - } else if (FACESEL_PAINT_TEST) { - if (ob && ob->type == OB_MESH) { - uiDefPulldownBut(block, view3d_select_faceselmenu, NULL, "Select", xco,yco, xmax-3, 20, ""); - } - } else if ((G.f & G_VERTEXPAINT) || (G.f & G_TEXTUREPAINT) || (G.f & G_WEIGHTPAINT)) { - uiDefBut(block, LABEL,0,"", xco, 0, xmax, 20, 0, 0, 0, 0, 0, ""); - } else if (G.f & G_PARTICLEEDIT) { - uiDefMenuBut(block, view3d_select_particlemenu, NULL, "Select", xco,yco, xmax-3, 20, ""); - } else { - - if (ob && (ob->flag & OB_POSEMODE)) - uiDefMenuBut(block, view3d_select_posemenu, NULL, "Select", xco,yco, xmax-3, 20, ""); - else - uiDefMenuBut(block, view3d_select_objectmenu, NULL, "Select", xco,yco, xmax-3, 20, ""); - } + xco+= xmax; if (obedit) { - if (ob && ob->type == OB_MESH) { - xmax= GetButStringLength("Mesh"); - uiDefMenuBut(block, view3d_edit_meshmenu, NULL, "Mesh", xco,yco, xmax-3, 20, ""); - xco+= xmax; - } else if (ob && ob->type == OB_CURVE) { - xmax= GetButStringLength("Curve"); - uiDefMenuBut(block, view3d_edit_curvemenu, NULL, "Curve", xco, yco, xmax-3, 20, ""); - xco+= xmax; - } else if (ob && ob->type == OB_SURF) { - xmax= GetButStringLength("Surface"); - uiDefMenuBut(block, view3d_edit_curvemenu, NULL, "Surface", xco, yco, xmax-3, 20, ""); - xco+= xmax; - } else if (ob && ob->type == OB_FONT) { - xmax= GetButStringLength("Text"); - uiDefMenuBut(block, view3d_edit_textmenu, NULL, "Text", xco, yco, xmax-3, 20, ""); - xco+= xmax; - } else if (ob && ob->type == OB_MBALL) { - xmax= GetButStringLength("Metaball"); - uiDefMenuBut(block, view3d_edit_metaballmenu, NULL, "Metaball", xco,yco, xmax-3, 20, ""); - xco+= xmax; - } else if (ob && ob->type == OB_LATTICE) { - xmax= GetButStringLength("Lattice"); - uiDefMenuBut(block, view3d_edit_latticemenu, NULL, "Lattice", xco, yco, xmax-3, 20, ""); - xco+= xmax; - } else if (ob && ob->type == OB_ARMATURE) { - xmax= GetButStringLength("Armature"); - uiDefMenuBut(block, view3d_edit_armaturemenu, NULL, "Armature", xco,yco, xmax-3, 20, ""); - xco+= xmax; - } - } - else if (G.f & G_WEIGHTPAINT) { + else if (ob && ob->mode & OB_MODE_WEIGHT_PAINT) { xmax= GetButStringLength("Paint"); uiDefPulldownBut(block, view3d_wpaintmenu, NULL, "Paint", xco,yco, xmax-3, 20, ""); xco+= xmax; } - else if (G.f & G_VERTEXPAINT) { - xmax= GetButStringLength("Paint"); - uiDefPulldownBut(block, view3d_vpaintmenu, NULL, "Paint", xco,yco, xmax-3, 20, ""); - xco+= xmax; - } - else if (G.f & G_TEXTUREPAINT) { + else if (ob && ob->mode & OB_MODE_TEXTURE_PAINT) { xmax= GetButStringLength("Paint"); uiDefPulldownBut(block, view3d_tpaintmenu, NULL, "Paint", xco,yco, xmax-3, 20, ""); xco+= xmax; } - else if( G.f & G_SCULPTMODE) { - xmax= GetButStringLength("Sculpt"); - uiDefMenuBut(block, view3d_sculpt_menu, NULL, "Sculpt", xco, yco, xmax-3, 20, ""); - xco+= xmax; - } - else if (FACESEL_PAINT_TEST) { + else if (paint_facesel_test(ob)) { if (ob && ob->type == OB_MESH) { xmax= GetButStringLength("Face"); uiDefPulldownBut(block, view3d_faceselmenu, NULL, "Face", xco,yco, xmax-3, 20, ""); xco+= xmax; } } - else if(G.f & G_PARTICLEEDIT) { - xmax= GetButStringLength("Particle"); - uiDefMenuBut(block, view3d_particlemenu, NULL, "Particle", xco,yco, xmax-3, 20, ""); - xco+= xmax; + else if(ob && ob->mode & OB_MODE_PARTICLE_EDIT) { + /* ported to python */ } else { - if (ob && (ob->flag & OB_POSEMODE)) { - xmax= GetButStringLength("Pose"); - uiDefMenuBut(block, view3d_pose_armaturemenu, NULL, "Pose", xco,yco, xmax-3, 20, ""); - xco+= xmax; - } - else { - xmax= GetButStringLength("Object"); - uiDefMenuBut(block, view3d_edit_objectmenu, NULL, "Object", xco,yco, xmax-3, 20, ""); - xco+= xmax; + if (ob && (ob->mode & OB_MODE_POSE)) { + /* ported to python */ } } @@ -3903,6 +1911,20 @@ static void header_xco_step(ARegion *ar, int *xco, int *yco, int *maxco, int ste } } +/* Returns the icon associated with an object mode */ +static int object_mode_icon(int mode) +{ + EnumPropertyItem *item = object_mode_items; + + while(item->name != NULL) { + if(item->value == mode) + return item->icon; + ++item; + } + + return ICON_OBJECT_DATAMODE; +} + void uiTemplateHeader3D(uiLayout *layout, struct bContext *C) { ARegion *ar= CTX_wm_region(C); @@ -3925,29 +1947,23 @@ void uiTemplateHeader3D(uiLayout *layout, struct bContext *C) uiBlockSetEmboss(block, UI_EMBOSS); /* mode */ - v3d->modeselect = V3D_OBJECTMODE_SEL; - - if (obedit) v3d->modeselect = V3D_EDITMODE_SEL; - else if(ob && (ob->flag & OB_POSEMODE)) v3d->modeselect = V3D_POSEMODE_SEL; - else if (G.f & G_SCULPTMODE) v3d->modeselect = V3D_SCULPTMODE_SEL; - else if (G.f & G_WEIGHTPAINT) v3d->modeselect = V3D_WEIGHTPAINTMODE_SEL; - else if (G.f & G_VERTEXPAINT) v3d->modeselect = V3D_VERTEXPAINTMODE_SEL; - else if (G.f & G_TEXTUREPAINT) v3d->modeselect = V3D_TEXTUREPAINTMODE_SEL; - /*else if(G.f & G_FACESELECT) v3d->modeselect = V3D_FACESELECTMODE_SEL;*/ - else if(G.f & G_PARTICLEEDIT) v3d->modeselect = V3D_PARTICLEEDITMODE_SEL; + if(ob) + v3d->modeselect = ob->mode; + else + v3d->modeselect = OB_MODE_OBJECT; v3d->flag &= ~V3D_MODE; /* not sure what the v3d->flag is useful for now... modeselect is confusing */ if(obedit) v3d->flag |= V3D_EDITMODE; - if(ob && (ob->flag & OB_POSEMODE)) v3d->flag |= V3D_POSEMODE; - if(G.f & G_VERTEXPAINT) v3d->flag |= V3D_VERTEXPAINT; - if(G.f & G_WEIGHTPAINT) v3d->flag |= V3D_WEIGHTPAINT; - if (G.f & G_TEXTUREPAINT) v3d->flag |= V3D_TEXTUREPAINT; - if(FACESEL_PAINT_TEST) v3d->flag |= V3D_FACESELECT; - - uiDefIconTextButS(block, MENU, B_MODESELECT, (v3d->modeselect),view3d_modeselect_pup(scene) , - xco,yco,126,20, &(v3d->modeselect), 0, 0, 0, 0, "Mode (Hotkeys: Tab, V, Ctrl Tab)"); + if(ob && (ob->mode & OB_MODE_POSE)) v3d->flag |= V3D_POSEMODE; + if(ob && (ob->mode & OB_MODE_VERTEX_PAINT)) v3d->flag |= V3D_VERTEXPAINT; + if(ob && (ob->mode & OB_MODE_WEIGHT_PAINT)) v3d->flag |= V3D_WEIGHTPAINT; + if(ob && (ob->mode & OB_MODE_TEXTURE_PAINT)) v3d->flag |= V3D_TEXTUREPAINT; + if(paint_facesel_test(ob)) v3d->flag |= V3D_FACESELECT; + + uiDefIconTextButS(block, MENU, B_MODESELECT, object_mode_icon(v3d->modeselect), view3d_modeselect_pup(scene) , + xco,yco,126,20, &(v3d->modeselect), 0, 0, 0, 0, "Mode (Hotkeys: Tab, V, Ctrl Tab)"); header_xco_step(ar, &xco, &yco, &maxco, 126+8); /* DRAWTYPE */ @@ -3987,7 +2003,7 @@ void uiTemplateHeader3D(uiLayout *layout, struct bContext *C) uiBlockEndAlign(block); } } else { - if (obedit==NULL && (G.f & (G_VERTEXPAINT|G_WEIGHTPAINT|G_TEXTUREPAINT))) { + if (obedit==NULL && ((ob && ob->mode & (OB_MODE_VERTEX_PAINT|OB_MODE_WEIGHT_PAINT|OB_MODE_TEXTURE_PAINT)))) { uiDefIconButBitI(block, TOG, G_FACESELECT, B_VIEW_BUTSEDIT, ICON_FACESEL_HLT,xco,yco,XIC,YIC, &G.f, 0, 0, 0, 0, "Painting Mask (FKey)"); header_xco_step(ar, &xco, &yco, &maxco, XIC+10); } else { @@ -4074,7 +2090,7 @@ void uiTemplateHeader3D(uiLayout *layout, struct bContext *C) } /* proportional falloff */ - if((obedit && (obedit->type == OB_MESH || obedit->type == OB_CURVE || obedit->type == OB_SURF || obedit->type == OB_LATTICE)) || G.f & G_PARTICLEEDIT) { + if((obedit && (obedit->type == OB_MESH || obedit->type == OB_CURVE || obedit->type == OB_SURF || obedit->type == OB_LATTICE)) || (ob && ob->mode & OB_MODE_PARTICLE_EDIT)) { uiBlockBeginAlign(block); uiDefIconTextButS(block, ICONTEXTROW,B_REDR, ICON_PROP_OFF, "Proportional %t|Off %x0|On %x1|Connected %x2", xco,yco,XIC+10,YIC, &(ts->proportional), 0, 1.0, 0, 0, "Proportional Edit Falloff (Hotkeys: O, Alt O) "); @@ -4133,7 +2149,7 @@ void uiTemplateHeader3D(uiLayout *layout, struct bContext *C) uiBlockEndAlign(block); header_xco_step(ar, &xco, &yco, &maxco, XIC); } - else if(G.f & G_PARTICLEEDIT) { + else if(ob && ob->mode & OB_MODE_PARTICLE_EDIT) { uiBlockBeginAlign(block); uiDefIconButBitI(block, TOG, SCE_SELECT_PATH, B_SEL_PATH, ICON_EDGESEL, xco,yco,XIC,YIC, &ts->particle.selectmode, 1.0, 0.0, 0, 0, "Path edit mode"); xco+= XIC; @@ -4153,7 +2169,7 @@ void uiTemplateHeader3D(uiLayout *layout, struct bContext *C) uiDefIconBut(block, BUT, B_VIEWRENDER, ICON_SCENE, xco,yco,XIC,YIC, NULL, 0, 1.0, 0, 0, "Render this window (Ctrl Click for anim)"); - if (ob && (ob->flag & OB_POSEMODE)) { + if (ob && (ob->mode & OB_MODE_POSE)) { xco+= XIC; uiBlockBeginAlign(block); @@ -4170,11 +2186,5 @@ void uiTemplateHeader3D(uiLayout *layout, struct bContext *C) } } - - /* always as last */ - UI_view2d_totRect_set(&ar->v2d, maxco+XIC+80, ar->v2d.tot.ymax-ar->v2d.tot.ymin); - - uiEndBlock(C, block); - uiDrawBlock(C, block); } diff --git a/source/blender/editors/space_view3d/view3d_intern.h b/source/blender/editors/space_view3d/view3d_intern.h index 3e9382509f4..e5e85cf9d16 100644 --- a/source/blender/editors/space_view3d/view3d_intern.h +++ b/source/blender/editors/space_view3d/view3d_intern.h @@ -140,7 +140,6 @@ void view3d_buttons_register(struct ARegionType *art); void VIEW3D_OT_toolbar(struct wmOperatorType *ot); void view3d_toolbar_register(struct ARegionType *art); void view3d_tool_props_register(struct ARegionType *art); -char *view3d_context_string(const struct bContext *C); /* view3d_snap.c */ int minmax_verts(Object *obedit, float *min, float *max); @@ -157,6 +156,9 @@ void VIEW3D_OT_snap_menu(struct wmOperatorType *ot); ARegion *view3d_has_buttons_region(ScrArea *sa); ARegion *view3d_has_tools_region(ScrArea *sa); +/* draw_volume.c */ +void draw_volume(struct Scene *scene, struct ARegion *ar, struct View3D *v3d, struct Base *base, struct GPUTexture *tex, int res[3]); + #endif /* ED_VIEW3D_INTERN_H */ diff --git a/source/blender/editors/space_view3d/view3d_ops.c b/source/blender/editors/space_view3d/view3d_ops.c index 32305b5c76b..57922d78880 100644 --- a/source/blender/editors/space_view3d/view3d_ops.c +++ b/source/blender/editors/space_view3d/view3d_ops.c @@ -106,9 +106,6 @@ void view3d_keymap(wmWindowManager *wm) ListBase *keymap= WM_keymap_listbase(wm, "View3D Generic", SPACE_VIEW3D, 0); wmKeymapItem *km; - WM_keymap_add_item(keymap, "PAINT_OT_vertex_paint_toggle", VKEY, KM_PRESS, 0, 0); - WM_keymap_add_item(keymap, "PAINT_OT_weight_paint_toggle", TABKEY, KM_PRESS, KM_CTRL, 0); - WM_keymap_add_item(keymap, "VIEW3D_OT_properties", NKEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "VIEW3D_OT_toolbar", TKEY, KM_PRESS, 0, 0); @@ -135,7 +132,8 @@ void view3d_keymap(wmWindowManager *wm) km = WM_keymap_add_item(keymap, "SKETCH_OT_draw_preview", MOUSEMOVE, KM_ANY, KM_CTRL, 0); RNA_boolean_set(km->ptr, "snap", 1); - WM_keymap_verify_item(keymap, "VIEW3D_OT_manipulator", ACTIONMOUSE, KM_PRESS, 0, 0); + WM_keymap_verify_item(keymap, "VIEW3D_OT_manipulator", LEFTMOUSE, KM_PRESS, 0, 0); /* manipulator always on left mouse, not on action mouse*/ + WM_keymap_verify_item(keymap, "VIEW3D_OT_cursor3d", ACTIONMOUSE, KM_PRESS, 0, 0); WM_keymap_verify_item(keymap, "VIEW3D_OT_viewrotate", MIDDLEMOUSE, KM_PRESS, 0, 0); diff --git a/source/blender/editors/space_view3d/view3d_select.c b/source/blender/editors/space_view3d/view3d_select.c index d0c0a63eb1a..8cb64a14291 100644 --- a/source/blender/editors/space_view3d/view3d_select.c +++ b/source/blender/editors/space_view3d/view3d_select.c @@ -59,6 +59,7 @@ #include "BKE_depsgraph.h" #include "BKE_object.h" #include "BKE_global.h" +#include "BKE_paint.h" #include "BKE_scene.h" #include "BKE_screen.h" #include "BKE_utildefines.h" @@ -385,7 +386,7 @@ static void do_lasso_select_objects(ViewContext *vc, short mcords[][2], short mo else ED_base_object_select(base, BA_DESELECT); base->object->flag= base->flag; } - if(base->object->flag & OB_POSEMODE) { + if(base->object->mode & OB_MODE_POSE) { do_lasso_select_pose(vc, mcords, moves, select); } } @@ -699,12 +700,14 @@ static void do_lasso_select_node(short mcords[][2], short moves, short select) void view3d_lasso_select(bContext *C, ViewContext *vc, short mcords[][2], short moves, short select) { + Object *ob = CTX_data_active_object(C); + if(vc->obedit==NULL) { - if(FACESEL_PAINT_TEST) + if(paint_facesel_test(ob)) do_lasso_select_facemode(vc, mcords, moves, select); - else if(G.f & (G_VERTEXPAINT|G_TEXTUREPAINT|G_WEIGHTPAINT)) + else if(ob && ob->mode & (OB_MODE_VERTEX_PAINT|OB_MODE_WEIGHT_PAINT|OB_MODE_TEXTURE_PAINT)) ; - else if(G.f & G_PARTICLEEDIT) + else if(ob && ob->mode & OB_MODE_PARTICLE_EDIT) PE_lasso_select(C, mcords, moves, select); else do_lasso_select_objects(vc, mcords, moves, select); @@ -1121,7 +1124,7 @@ static void mouse_select(bContext *C, short *mval, short extend, short obcenter) WM_event_add_notifier(C, NC_OBJECT|ND_BONE_ACTIVE, basact->object); /* in weightpaint, we use selected bone to select vertexgroup, so no switch to new active object */ - if(G.f & G_WEIGHTPAINT) { + if(basact->object->mode & OB_MODE_WEIGHT_PAINT) { /* prevent activating */ basact= NULL; } @@ -1339,6 +1342,7 @@ static int view3d_borderselect_exec(bContext *C, wmOperator *op) ScrArea *sa= CTX_wm_area(C); View3D *v3d= sa->spacedata.first; Object *obedit= CTX_data_edit_object(C); + Object *obact= CTX_data_active_object(C); rcti rect; Base *base; MetaElem *ml; @@ -1357,11 +1361,11 @@ static int view3d_borderselect_exec(bContext *C, wmOperator *op) rect.xmax= RNA_int_get(op->ptr, "xmax"); rect.ymax= RNA_int_get(op->ptr, "ymax"); - if(obedit==NULL && (FACESEL_PAINT_TEST)) { + if(obedit==NULL && (paint_facesel_test(OBACT))) { // XXX face_borderselect(); return OPERATOR_FINISHED; } - else if(obedit==NULL && (G.f & G_PARTICLEEDIT)) { + else if(obedit==NULL && (obact && obact->mode & OB_MODE_PARTICLE_EDIT)) { return PE_border_select(C, &rect, (val==LEFTMOUSE)); } @@ -1468,7 +1472,7 @@ static int view3d_borderselect_exec(bContext *C, wmOperator *op) int bone_only; int totobj= MAXPICKBUF; // XXX solve later - if((ob) && (ob->flag & OB_POSEMODE)) + if((ob) && (ob->mode & OB_MODE_POSE)) bone_only= 1; else bone_only= 0; @@ -1579,6 +1583,7 @@ static int view3d_select_invoke(bContext *C, wmOperator *op, wmEvent *event) { Object *obedit= CTX_data_edit_object(C); short extend= RNA_enum_is_equal(C, op->ptr, "type", "EXTEND"); + Object *obact= CTX_data_active_object(C); view3d_operator_needs_opengl(C); @@ -1595,7 +1600,7 @@ static int view3d_select_invoke(bContext *C, wmOperator *op, wmEvent *event) mouse_mball(C, event->mval, extend); } - else if(G.f & G_PARTICLEEDIT) + else if(obact && obact->mode & OB_MODE_PARTICLE_EDIT) PE_mouse_particles(C, event->mval, extend); else mouse_select(C, event->mval, extend, 0); @@ -1656,9 +1661,9 @@ static void mesh_circle_doSelectFace(void *userData, BMFace *efa, int x, int y, static void mesh_circle_select(ViewContext *vc, int selecting, short *mval, float rad) { int bbsel; + Object *ob= vc->obact; - if(vc->obedit==NULL && (FACESEL_PAINT_TEST)) { - Object *ob= vc->obact; + if(vc->obedit==NULL && paint_facesel_test(ob)) { Mesh *me = ob?ob->data:NULL; if (me) { @@ -1798,12 +1803,13 @@ static int view3d_circle_select_exec(bContext *C, wmOperator *op) ScrArea *sa= CTX_wm_area(C); ARegion *ar= CTX_wm_region(C); Scene *scene= CTX_data_scene(C); + Object *obact= CTX_data_active_object(C); View3D *v3d= sa->spacedata.first; int x= RNA_int_get(op->ptr, "x"); int y= RNA_int_get(op->ptr, "y"); int radius= RNA_int_get(op->ptr, "radius"); - if(CTX_data_edit_object(C) || (G.f & G_PARTICLEEDIT)) { + if(CTX_data_edit_object(C) || (obact && obact->mode & OB_MODE_PARTICLE_EDIT)) { ViewContext vc; short mval[2], selecting; @@ -1814,8 +1820,10 @@ static int view3d_circle_select_exec(bContext *C, wmOperator *op) mval[1]= y; selecting= LEFTMOUSE==RNA_int_get(op->ptr, "event_type"); // XXX solve - if(CTX_data_edit_object(C)) + if(CTX_data_edit_object(C)) { obedit_circle_select(&vc, selecting, mval, (float)radius); + WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obact); + } else return PE_circle_select(C, selecting, mval, (float)radius); } diff --git a/source/blender/editors/space_view3d/view3d_snap.c b/source/blender/editors/space_view3d/view3d_snap.c index 5ec34d35d45..969591b1946 100644 --- a/source/blender/editors/space_view3d/view3d_snap.c +++ b/source/blender/editors/space_view3d/view3d_snap.c @@ -510,7 +510,7 @@ static int snap_sel_to_grid(bContext *C, wmOperator *op) CTX_DATA_BEGIN(C, Base*, base, selected_editable_bases) { ob= base->object; - if(ob->flag & OB_POSEMODE) { + if(ob->mode & OB_MODE_POSE) { bPoseChannel *pchan; bArmature *arm= ob->data; @@ -637,7 +637,7 @@ static int snap_sel_to_curs(bContext *C, wmOperator *op) else { CTX_DATA_BEGIN(C, Base*, base, selected_editable_bases) { ob= base->object; - if(ob->flag & OB_POSEMODE) { + if(ob->mode & OB_MODE_POSE) { bPoseChannel *pchan; bArmature *arm= ob->data; float cursp[3]; @@ -803,7 +803,7 @@ static int snap_curs_to_sel(bContext *C, wmOperator *op) else { Object *ob= OBACT; - if(ob && (ob->flag & OB_POSEMODE)) { + if(ob && (ob->mode & OB_MODE_POSE)) { bArmature *arm= ob->data; bPoseChannel *pchan; for (pchan = ob->pose->chanbase.first; pchan; pchan=pchan->next) { @@ -963,7 +963,7 @@ static int snap_selected_to_center(bContext *C, wmOperator *op) CTX_DATA_BEGIN(C, Base*, base, selected_editable_bases) { ob= base->object; - if(ob->flag & OB_POSEMODE) { + if(ob->mode & OB_MODE_POSE) { bPoseChannel *pchan; bArmature *arm= ob->data; @@ -1032,7 +1032,7 @@ static int snap_selected_to_center(bContext *C, wmOperator *op) CTX_DATA_BEGIN(C, Base*, base, selected_editable_bases) { ob= base->object; - if(ob->flag & OB_POSEMODE) { + if(ob->mode & OB_MODE_POSE) { bPoseChannel *pchan; bArmature *arm= ob->data; diff --git a/source/blender/editors/space_view3d/view3d_toolbar.c b/source/blender/editors/space_view3d/view3d_toolbar.c index 67d8bc3e5ee..c87dd0b7948 100644 --- a/source/blender/editors/space_view3d/view3d_toolbar.c +++ b/source/blender/editors/space_view3d/view3d_toolbar.c @@ -118,6 +118,19 @@ static void redo_cb(bContext *C, void *arg_op, void *arg2) } } +static wmOperator *view3d_last_operator(const bContext *C) +{ + wmWindowManager *wm= CTX_wm_manager(C); + wmOperator *op; + + /* only for operators that are registered and did an undo push */ + for(op= wm->operators.last; op; op= op->prev) + if((op->type->flag & OPTYPE_REGISTER) && (op->type->flag & OPTYPE_UNDO)) + break; + + return op; +} + static void view3d_panel_operator_redo_buts(const bContext *C, Panel *pa, wmOperator *op) { wmWindowManager *wm= CTX_wm_manager(C); @@ -129,28 +142,32 @@ static void view3d_panel_operator_redo_buts(const bContext *C, Panel *pa, wmOper } RNA_pointer_create(&wm->id, op->type->srna, op->properties, &ptr); - uiDefAutoButsRNA(C, pa->layout, &ptr, 1); - + if(op->type->ui) + op->type->ui((bContext*)C, &ptr, pa->layout); + else + uiDefAutoButsRNA(C, pa->layout, &ptr, 1); +} + +static void view3d_panel_operator_redo_header(const bContext *C, Panel *pa) +{ + wmOperator *op= view3d_last_operator(C); + + if(op) BLI_strncpy(pa->drawname, op->type->name, sizeof(pa->drawname)); + else BLI_strncpy(pa->drawname, "Operator", sizeof(pa->drawname)); } static void view3d_panel_operator_redo(const bContext *C, Panel *pa) { - wmWindowManager *wm= CTX_wm_manager(C); - wmOperator *op; + wmOperator *op= view3d_last_operator(C); uiBlock *block; - block= uiLayoutGetBlock(pa->layout); - - /* only for operators that are registered and did an undo push */ - for(op= wm->operators.last; op; op= op->prev) - if((op->type->flag & OPTYPE_REGISTER) && (op->type->flag & OPTYPE_UNDO)) - break; - if(op==NULL) return; if(op->type->poll && op->type->poll((bContext *)C)==0) return; + block= uiLayoutGetBlock(pa->layout); + uiBlockSetFunc(block, redo_cb, op, NULL); if(op->macro.first) { @@ -164,42 +181,6 @@ static void view3d_panel_operator_redo(const bContext *C, Panel *pa) /* ******************* */ -char *view3d_context_string(const bContext *C) -{ - Object *obedit= CTX_data_edit_object(C); - - if(obedit) { - switch(obedit->type) { - case OB_MESH: - return "editmode_mesh"; - case OB_CURVE: - return "editmode_curve"; - case OB_SURF: - return "editmode_surface"; - case OB_FONT: - return "editmode_text"; - case OB_ARMATURE: - return "editmode_armature"; - case OB_MBALL: - return "editmode_mball"; - case OB_LATTICE: - return "editmode_lattice"; - } - } - else { - Object *ob = CTX_data_active_object(C); - - if(ob && (ob->flag & OB_POSEMODE)) return "pose_mode"; - else if (G.f & G_SCULPTMODE) return "sculpt_mode"; - else if (G.f & G_WEIGHTPAINT) return "weight_paint"; - else if (G.f & G_VERTEXPAINT) return "vertex_paint"; - else if (G.f & G_TEXTUREPAINT) return "texture_paint"; - else if(G.f & G_PARTICLEEDIT) return "particle_mode"; - } - - return "objectmode"; -} - typedef struct CustomTool { struct CustomTool *next, *prev; char opname[OP_MAX_TYPENAME]; @@ -215,7 +196,7 @@ static void operator_call_cb(struct bContext *C, void *arg_listbase, void *arg2) BLI_addtail(arg_listbase, ct); BLI_strncpy(ct->opname, ot->idname, OP_MAX_TYPENAME); - BLI_strncpy(ct->context, view3d_context_string(C), OP_MAX_TYPENAME); + BLI_strncpy(ct->context, CTX_data_mode_string(C), OP_MAX_TYPENAME); } } @@ -278,7 +259,7 @@ static void view3d_panel_tool_shelf(const bContext *C, Panel *pa) SpaceLink *sl= CTX_wm_space_data(C); SpaceType *st= NULL; uiLayout *col; - const char *context= view3d_context_string(C); + const char *context= CTX_data_mode_string(C); if(sl) st= BKE_spacetype_from_id(sl->spacetype); @@ -289,7 +270,7 @@ static void view3d_panel_tool_shelf(const bContext *C, Panel *pa) for(ct= st->toolshelf.first; ct; ct= ct->next) { if(0==strncmp(context, ct->context, OP_MAX_TYPENAME)) { col= uiLayoutColumn(pa->layout, 1); - uiItemFullO(col, NULL, 0, ct->opname, NULL, WM_OP_INVOKE_REGION_WIN); + uiItemFullO(col, NULL, 0, ct->opname, NULL, WM_OP_INVOKE_REGION_WIN, 0); } } } @@ -315,7 +296,8 @@ void view3d_tool_props_register(ARegionType *art) pt= MEM_callocN(sizeof(PanelType), "spacetype view3d panel last operator"); strcpy(pt->idname, "VIEW3D_PT_last_operator"); - strcpy(pt->label, "Last Operator"); + strcpy(pt->label, "Operator"); + pt->draw_header= view3d_panel_operator_redo_header; pt->draw= view3d_panel_operator_redo; BLI_addtail(&art->paneltypes, pt); } diff --git a/source/blender/editors/space_view3d/view3d_view.c b/source/blender/editors/space_view3d/view3d_view.c index 20e0a79f0c7..ce7b6ba454d 100644 --- a/source/blender/editors/space_view3d/view3d_view.c +++ b/source/blender/editors/space_view3d/view3d_view.c @@ -63,6 +63,7 @@ #include "RE_pipeline.h" // make_stars #include "BIF_gl.h" +#include "BIF_glutil.h" #include "WM_api.h" #include "WM_types.h" @@ -543,6 +544,18 @@ void view3d_get_object_project_mat(RegionView3D *rv3d, Object *ob, float pmat[4] Mat4MulMat4(pmat, vmat, rv3d->winmat); } +/* Uses window coordinates (x,y) and depth component z to find a point in + modelspace */ +void view3d_unproject(bglMats *mats, float out[3], const short x, const short y, const float z) +{ + double ux, uy, uz; + + gluUnProject(x,y,z, mats->modelview, mats->projection, + (GLint *)mats->viewport, &ux, &uy, &uz ); + out[0] = ux; + out[1] = uy; + out[2] = uz; +} /* use above call to get projecting mat */ void view3d_project_float(ARegion *ar, float *vec, float *adr, float mat[4][4]) @@ -1389,12 +1402,13 @@ static ListBase queue_back; static void SaveState(bContext *C) { wmWindow *win= CTX_wm_window(C); + Object *obact = CTX_data_active_object(C); glPushAttrib(GL_ALL_ATTRIB_BITS); GPU_state_init(); - if(G.f & G_TEXTUREPAINT) + if(obact && obact->mode & OB_MODE_TEXTURE_PAINT) GPU_paint_set_mipmap(1); queue_back= win->queue; @@ -1407,8 +1421,9 @@ static void SaveState(bContext *C) static void RestoreState(bContext *C) { wmWindow *win= CTX_wm_window(C); + Object *obact = CTX_data_active_object(C); - if(G.f & G_TEXTUREPAINT) + if(obact && obact->mode & OB_MODE_TEXTURE_PAINT) GPU_paint_set_mipmap(0); //XXX curarea->win_swap = 0; diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c index 510193fdade..dd7cebdfe3f 100644 --- a/source/blender/editors/transform/transform.c +++ b/source/blender/editors/transform/transform.c @@ -89,6 +89,7 @@ #include "BKE_pointcache.h" #include "BKE_utildefines.h" #include "BKE_context.h" +#include "BKE_unit.h" //#include "BSE_view.h" @@ -3039,12 +3040,22 @@ static void headerTranslation(TransInfo *t, float vec[3], char *str) { applyAspectRatio(t, dvec); dist = VecLength(vec); - sprintf(&tvec[0], "%.4f", dvec[0]); - sprintf(&tvec[20], "%.4f", dvec[1]); - sprintf(&tvec[40], "%.4f", dvec[2]); + if(t->scene->unit.system) { + int i, do_split= t->scene->unit.flag & USER_UNIT_OPT_SPLIT ? 1:0; + + for(i=0; i<3; i++) + bUnit_AsString(&tvec[i*20], 20, dvec[i]*t->scene->unit.scale_length, 4, t->scene->unit.system, B_UNIT_LENGTH, do_split, 1); + } + else { + sprintf(&tvec[0], "%.4f", dvec[0]); + sprintf(&tvec[20], "%.4f", dvec[1]); + sprintf(&tvec[40], "%.4f", dvec[2]); + } } - if( dist > 1e10 || dist < -1e10 ) /* prevent string buffer overflow */ + if(t->scene->unit.system) + bUnit_AsString(distvec, sizeof(distvec), dist*t->scene->unit.scale_length, 4, t->scene->unit.system, B_UNIT_LENGTH, t->scene->unit.flag & USER_UNIT_OPT_SPLIT, 0); + else if( dist > 1e10 || dist < -1e10 ) /* prevent string buffer overflow */ sprintf(distvec, "%.4e", dist); else sprintf(distvec, "%.4f", dist); diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c index 783d98e4c6f..b556ff907da 100644 --- a/source/blender/editors/transform/transform_conversions.c +++ b/source/blender/editors/transform/transform_conversions.c @@ -700,6 +700,8 @@ int count_set_pose_transflags(int *out_mode, short around, Object *ob) bone->flag &= ~BONE_HINGE_CHILD_TRANSFORM; bone->flag &= ~BONE_TRANSFORM_CHILD; } + else + bone->flag &= ~BONE_TRANSFORM; } /* make sure no bone can be transformed when a parent is transformed */ @@ -919,7 +921,7 @@ static short pose_grab_with_ik(Object *ob) Bone *bonec; short tot_ik= 0; - if ((ob==NULL) || (ob->pose==NULL) || (ob->flag & OB_POSEMODE)==0) + if ((ob==NULL) || (ob->pose==NULL) || (ob->mode & OB_MODE_POSE)==0) return 0; arm = ob->data; @@ -4933,7 +4935,7 @@ void special_aftertrans_update(TransInfo *t) // allqueue(REDRAWBUTSEDIT, 0); } - else if(G.f & G_PARTICLEEDIT) { + else if(t->scene->basact && (ob = t->scene->basact->object) && ob->mode & OB_MODE_PARTICLE_EDIT) { ; } else { @@ -4992,9 +4994,9 @@ static void createTransObject(bContext *C, TransInfo *t) set_trans_object_base_flags(C, t); /* count */ +#if 0 // TRANSFORM_FIX_ME CTX_DATA_BEGIN(C, Object*, ob, selected_objects) { -#if 0 // TRANSFORM_FIX_ME /* store ipo keys? */ if ((ob->id.lib == 0) && (ob->ipo) && (ob->ipo->showkey) && (ob->ipoflag & OB_DRAWKEY)) { elems.first= elems.last= NULL; @@ -5008,12 +5010,14 @@ static void createTransObject(bContext *C, TransInfo *t) if(elems.first==NULL) t->total++; } -#endif // else { t->total++; // } } CTX_DATA_END; +#else + t->total= CTX_DATA_COUNT(C, selected_objects); +#endif if(!t->total) { /* clear here, main transform function escapes too */ @@ -5267,18 +5271,18 @@ void createTransData(bContext *C, TransInfo *t) t->poseobj = ob; /* <- tsk tsk, this is going to give issues one day */ } } - else if (ob && (ob->flag & OB_POSEMODE)) { + else if (ob && (ob->mode & OB_MODE_POSE)) { // XXX this is currently limited to active armature only... // XXX active-layer checking isn't done as that should probably be checked through context instead createTransPose(C, t, ob); } - else if (G.f & G_WEIGHTPAINT) { + else if (ob && (ob->mode & OB_MODE_WEIGHT_PAINT)) { /* exception, we look for the one selected armature */ CTX_DATA_BEGIN(C, Object*, ob_armature, selected_objects) { if(ob_armature->type==OB_ARMATURE) { - if(ob_armature->flag & OB_POSEMODE) + if(ob_armature->mode & OB_MODE_POSE) { createTransPose(C, t, ob_armature); break; @@ -5287,7 +5291,7 @@ void createTransData(bContext *C, TransInfo *t) } CTX_DATA_END; } - else if (G.f & G_PARTICLEEDIT && PE_can_edit(PE_get_current(scene, ob))) { + else if (ob && (ob->mode & OB_MODE_PARTICLE_EDIT) && PE_can_edit(PE_get_current(scene, ob))) { createTransParticleVerts(C, t); if(t->data && t->flag & T_PROP_EDIT) { diff --git a/source/blender/editors/transform/transform_generics.c b/source/blender/editors/transform/transform_generics.c index fe3e7b08685..b96cb2601ec 100644 --- a/source/blender/editors/transform/transform_generics.c +++ b/source/blender/editors/transform/transform_generics.c @@ -271,7 +271,7 @@ static void editbmesh_apply_to_mirror(TransInfo *t) /* tags the given ID block for refreshes (if applicable) due to * Animation Editor editing */ -static void animedit_refresh_id_tags (ID *id) +static void animedit_refresh_id_tags (Scene *scene, ID *id) { if (id) { AnimData *adt= BKE_animdata_from_id(id); @@ -281,12 +281,11 @@ static void animedit_refresh_id_tags (ID *id) adt->recalc |= ADT_RECALC_ANIM; /* if ID-block is Object, set recalc flags */ - // TODO: this should probably go through the depsgraph instead... but for now, let's be lazy switch (GS(id->name)) { case ID_OB: { Object *ob= (Object *)id; - ob->recalc |= OB_RECALC; + DAG_object_flush_update(scene, ob, OB_RECALC_DATA); /* sets recalc flags */ } break; } @@ -345,11 +344,11 @@ static void animrecord_check_state (Scene *scene, ID *id, wmTimer *animtimer) void recalcData(TransInfo *t) { Scene *scene = t->scene; - Base *base; + Base *base = scene->basact; if (t->obedit) { } - else if(G.f & G_PARTICLEEDIT) { + else if(base && base->object->mode & OB_MODE_PARTICLE_EDIT) { flushTransParticles(t); } if (t->spacetype==SPACE_NODE) { @@ -386,7 +385,7 @@ void recalcData(TransInfo *t) /* just tag these animdata-blocks to recalc, assuming that some data there changed */ for (ale= anim_data.first; ale; ale= ale->next) { /* set refresh tags for objects using this animation */ - animedit_refresh_id_tags(ale->id); + animedit_refresh_id_tags(t->scene, ale->id); } /* now free temp channels */ @@ -434,7 +433,7 @@ void recalcData(TransInfo *t) calchandles_fcurve(fcu); /* set refresh tags for objects using this animation */ - animedit_refresh_id_tags(ale->id); + animedit_refresh_id_tags(t->scene, ale->id); } /* do resort and other updates? */ @@ -465,7 +464,7 @@ void recalcData(TransInfo *t) continue; /* set refresh tags for objects using this animation */ - animedit_refresh_id_tags(tdn->id); + animedit_refresh_id_tags(t->scene, tdn->id); /* if cancelling transform, just write the values without validating, then move on */ if (t->state == TRANS_CANCEL) { @@ -768,7 +767,7 @@ void recalcData(TransInfo *t) */ // TODO: autokeyframe calls need some setting to specify to add samples (FPoints) instead of keyframes? if ((t->animtimer) && IS_AUTOKEY_ON(t->scene)) { - short targetless_ik= (t->flag & T_AUTOIK); // XXX this currently doesn't work, since flags aren't set yet! + int targetless_ik= (t->flag & T_AUTOIK); // XXX this currently doesn't work, since flags aren't set yet! animrecord_check_state(t->scene, &ob->id, t->animtimer); autokeyframe_pose_cb_func(t->scene, (View3D *)t->view, ob, t->mode, targetless_ik); diff --git a/source/blender/editors/transform/transform_manipulator.c b/source/blender/editors/transform/transform_manipulator.c index b999053bc1f..e0ab6bcf5f3 100644 --- a/source/blender/editors/transform/transform_manipulator.c +++ b/source/blender/editors/transform/transform_manipulator.c @@ -341,7 +341,7 @@ int calc_manipulator_stats(const bContext *C) Mat4MulVecfl(obedit->obmat, scene->twmax); } } - else if(ob && (ob->flag & OB_POSEMODE)) { + else if(ob && (ob->mode & OB_MODE_POSE)) { bPoseChannel *pchan; int mode = TFM_ROTATION; // mislead counting bones... bah. We don't know the manipulator mode, could be mixed @@ -361,10 +361,10 @@ int calc_manipulator_stats(const bContext *C) Mat4MulVecfl(ob->obmat, scene->twmax); } } - else if(G.f & (G_VERTEXPAINT + G_TEXTUREPAINT + G_WEIGHTPAINT + G_SCULPTMODE)) { + else if(ob && (ob->mode & (OB_MODE_SCULPT|OB_MODE_VERTEX_PAINT|OB_MODE_WEIGHT_PAINT|OB_MODE_TEXTURE_PAINT))) { ; } - else if(G.f & G_PARTICLEEDIT) { + else if(ob && ob->mode & OB_MODE_PARTICLE_EDIT) { ParticleSystem *psys= PE_get_current(scene, ob); ParticleData *pa = psys->particles; ParticleEditKey *ek; @@ -415,7 +415,7 @@ int calc_manipulator_stats(const bContext *C) switch(v3d->twmode) { case V3D_MANIP_NORMAL: - if(obedit || ob->flag & OB_POSEMODE) { + if(obedit || ob->mode & OB_MODE_POSE) { float mat[3][3]; int type; @@ -1418,7 +1418,7 @@ void BIF_draw_manipulator(const bContext *C) rv3d->twmat[3][2]= (scene->twmin[2] + scene->twmax[2])/2.0f; if(v3d->around==V3D_ACTIVE && scene->obedit==NULL) { Object *ob= OBACT; - if(ob && !(ob->flag & OB_POSEMODE)) + if(ob && !(ob->mode & OB_MODE_POSE)) VECCOPY(rv3d->twmat[3], ob->obmat[3]); } break; diff --git a/source/blender/editors/transform/transform_ops.c b/source/blender/editors/transform/transform_ops.c index 89aae3aebfd..9aef9c217ab 100644 --- a/source/blender/editors/transform/transform_ops.c +++ b/source/blender/editors/transform/transform_ops.c @@ -148,6 +148,7 @@ void TFM_OT_select_orientation(struct wmOperatorType *ot) /* identifiers */ ot->name = "Select Orientation"; + ot->description= "Select orientation type."; ot->idname = "TFM_OT_select_orientation"; /* api callbacks */ @@ -308,6 +309,7 @@ void TFM_OT_translate(struct wmOperatorType *ot) { /* identifiers */ ot->name = "Translate"; + ot->description= "Translate selected items."; ot->idname = OP_TRANSLATION; ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO|OPTYPE_BLOCKING; @@ -333,6 +335,7 @@ void TFM_OT_resize(struct wmOperatorType *ot) { /* identifiers */ ot->name = "Resize"; + ot->description= "Resize selected items."; ot->idname = OP_RESIZE; ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO|OPTYPE_BLOCKING; @@ -359,6 +362,7 @@ void TFM_OT_trackball(struct wmOperatorType *ot) { /* identifiers */ ot->name = "Trackball"; + ot->description= "Trackball style rotation of selected items."; ot->idname = OP_TRACKBALL; ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO|OPTYPE_BLOCKING; @@ -380,6 +384,7 @@ void TFM_OT_rotate(struct wmOperatorType *ot) { /* identifiers */ ot->name = "Rotate"; + ot->description= "Rotate selected items."; ot->idname = OP_ROTATION; ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO|OPTYPE_BLOCKING; @@ -405,6 +410,10 @@ void TFM_OT_tilt(struct wmOperatorType *ot) { /* identifiers */ ot->name = "Tilt"; + /*optionals - + "Tilt selected vertices." + "Specify an extra axis rotation for selected vertices of 3d curve." */ + ot->description= "Tilt selected control vertices of 3d curve."; ot->idname = OP_TILT; ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO|OPTYPE_BLOCKING; @@ -428,6 +437,7 @@ void TFM_OT_warp(struct wmOperatorType *ot) { /* identifiers */ ot->name = "Warp"; + ot->description= "Warp selected items around the cursor."; ot->idname = OP_WARP; ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO|OPTYPE_BLOCKING; @@ -452,6 +462,7 @@ void TFM_OT_shear(struct wmOperatorType *ot) { /* identifiers */ ot->name = "Shear"; + ot->description= "Shear selected items along the horizontal screen axis."; ot->idname = OP_SHEAR; ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO|OPTYPE_BLOCKING; @@ -476,6 +487,7 @@ void TFM_OT_shrink_fatten(struct wmOperatorType *ot) { /* identifiers */ ot->name = "Shrink/Fatten"; + ot->description= "Shrink/fatten selected vertices along normals."; ot->idname = OP_SHRINK_FATTEN; ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO|OPTYPE_BLOCKING; @@ -497,6 +509,8 @@ void TFM_OT_tosphere(struct wmOperatorType *ot) { /* identifiers */ ot->name = "To Sphere"; + //added "around mesh center" to differentiate between "MESH_OT_vertices_to_sphere()" + ot->description= "Move selected vertices outward in a spherical shape around mesh center."; ot->idname = OP_TOSPHERE; ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO|OPTYPE_BLOCKING; @@ -548,6 +562,7 @@ void TFM_OT_transform(struct wmOperatorType *ot) /* identifiers */ ot->name = "Transform"; + ot->description= "Transform selected items by mode type."; ot->idname = "TFM_OT_transform"; ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO|OPTYPE_BLOCKING; diff --git a/source/blender/editors/transform/transform_orientations.c b/source/blender/editors/transform/transform_orientations.c index 2caa28600cf..6d5138ff11a 100644 --- a/source/blender/editors/transform/transform_orientations.c +++ b/source/blender/editors/transform/transform_orientations.c @@ -88,7 +88,7 @@ void BIF_manageTransformOrientation(bContext *C, int confirm, int set) { else if (obedit->type == OB_ARMATURE) index = manageBoneSpace(C, confirm, set); } - else if (ob && (ob->flag & OB_POSEMODE)) { + else if (ob && (ob->mode & OB_MODE_POSE)) { index = manageBoneSpace(C, confirm, set); } else { @@ -488,7 +488,7 @@ void initTransformOrientation(bContext *C, TransInfo *t) break; case V3D_MANIP_NORMAL: - if(obedit || ob->flag & OB_POSEMODE) { + if(obedit || ob->mode & OB_MODE_POSE) { float mat[3][3]; int type; @@ -868,7 +868,7 @@ int getTransformOrientation(const bContext *C, float normal[3], float plane[3], Mat3MulVecfl(mat, plane); } } - else if(ob && (ob->flag & OB_POSEMODE)) + else if(ob && (ob->mode & OB_MODE_POSE)) { bArmature *arm= ob->data; bPoseChannel *pchan; @@ -898,10 +898,7 @@ int getTransformOrientation(const bContext *C, float normal[3], float plane[3], result = ORIENTATION_EDGE; } } - else if(G.f & (G_VERTEXPAINT + G_TEXTUREPAINT + G_WEIGHTPAINT + G_SCULPTMODE)) - { - } - else if(G.f & G_PARTICLEEDIT) + else if(ob && (ob->mode & (OB_MODE_SCULPT|OB_MODE_VERTEX_PAINT|OB_MODE_WEIGHT_PAINT|OB_MODE_TEXTURE_PAINT|OB_MODE_PARTICLE_EDIT))) { } else { diff --git a/source/blender/editors/util/undo.c b/source/blender/editors/util/undo.c index 435f2c7ecf4..41159397634 100644 --- a/source/blender/editors/util/undo.c +++ b/source/blender/editors/util/undo.c @@ -75,14 +75,11 @@ /* ***************** generic undo system ********************* */ -/* ********* XXX **************** */ -static void sound_initialize_sounds() {} -/* ********* XXX **************** */ - void ED_undo_push(bContext *C, char *str) { wmWindowManager *wm= CTX_wm_manager(C); Object *obedit= CTX_data_edit_object(C); + Object *obact= CTX_data_active_object(C); if(obedit) { if (U.undosteps == 0) return; @@ -100,7 +97,7 @@ void ED_undo_push(bContext *C, char *str) else if (obedit->type==OB_ARMATURE) undo_push_armature(C, str); } - else if(G.f & G_PARTICLEEDIT) { + else if(obact && obact->mode & OB_MODE_PARTICLE_EDIT) { if (U.undosteps == 0) return; PE_undo_push(CTX_data_scene(C), str); @@ -119,12 +116,13 @@ void ED_undo_push(bContext *C, char *str) static int ed_undo_step(bContext *C, int step, const char *undoname) { Object *obedit= CTX_data_edit_object(C); + Object *obact= CTX_data_active_object(C); ScrArea *sa= CTX_wm_area(C); if(sa && sa->spacetype==SPACE_IMAGE) { SpaceImage *sima= (SpaceImage *)sa->spacedata.first; - if(G.f & G_TEXTUREPAINT || sima->flag & SI_DRAWTOOL) { + if((obact && obact->mode & OB_MODE_TEXTURE_PAINT) || sima->flag & SI_DRAWTOOL) { undo_imagepaint_step(step); WM_event_add_notifier(C, NC_WINDOW, NULL); @@ -146,9 +144,9 @@ static int ed_undo_step(bContext *C, int step, const char *undoname) else { int do_glob_undo= 0; - if(G.f & G_TEXTUREPAINT) + if(obact && obact->mode & OB_MODE_TEXTURE_PAINT) undo_imagepaint_step(step); - else if(G.f & G_PARTICLEEDIT) { + else if(obact && obact->mode & OB_MODE_PARTICLE_EDIT) { if(step==1) PE_undo(CTX_data_scene(C)); else @@ -167,7 +165,6 @@ static int ed_undo_step(bContext *C, int step, const char *undoname) BKE_undo_name(C, undoname); else BKE_undo_step(C, step); - sound_initialize_sounds(); } } @@ -214,13 +211,14 @@ static int ed_redo_exec(bContext *C, wmOperator *op) void ED_undo_menu(bContext *C) { Object *obedit= CTX_data_edit_object(C); + Object *obact= CTX_data_active_object(C); if(obedit) { //if ELEM7(obedit->type, OB_MESH, OB_FONT, OB_CURVE, OB_SURF, OB_MBALL, OB_LATTICE, OB_ARMATURE) // undo_editmode_menu(); } else { - if(G.f & G_PARTICLEEDIT) + if(obact && obact->mode & OB_MODE_PARTICLE_EDIT) PE_undo_menu(CTX_data_scene(C), CTX_data_active_object(C)); else if(U.uiflag & USER_GLOBALUNDO) { char *menu= BKE_undo_menu_string(); @@ -229,7 +227,6 @@ void ED_undo_menu(bContext *C) MEM_freeN(menu); if(event>0) { BKE_undo_number(C, event); - sound_initialize_sounds(); } } } @@ -242,6 +239,7 @@ void ED_OT_undo(wmOperatorType *ot) { /* identifiers */ ot->name= "Undo"; + ot->description= "Undo previous action."; ot->idname= "ED_OT_undo"; /* api callbacks */ @@ -253,6 +251,7 @@ void ED_OT_redo(wmOperatorType *ot) { /* identifiers */ ot->name= "Redo"; + ot->description= "Redo previous action."; ot->idname= "ED_OT_redo"; /* api callbacks */ |