Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/interface/interface_anim.c
| Show All 12 Lines | |||||
| * along with this program; if not, write to the Free Software Foundation, | * along with this program; if not, write to the Free Software Foundation, | ||||
| * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||||
| */ | */ | ||||
| /** \file | /** \file | ||||
| * \ingroup edinterface | * \ingroup edinterface | ||||
| */ | */ | ||||
| #include <CLG_log.h> | |||||
| #include <stdio.h> | #include <stdio.h> | ||||
| #include <stdlib.h> | #include <stdlib.h> | ||||
| #include <string.h> | #include <string.h> | ||||
| #include "MEM_guardedalloc.h" | #include "MEM_guardedalloc.h" | ||||
| #include "DNA_anim_types.h" | #include "DNA_anim_types.h" | ||||
| #include "DNA_scene_types.h" | #include "DNA_scene_types.h" | ||||
| Show All 21 Lines | |||||
| #include "RNA_access.h" | #include "RNA_access.h" | ||||
| #include "WM_api.h" | #include "WM_api.h" | ||||
| #include "WM_types.h" | #include "WM_types.h" | ||||
| #include "interface_intern.h" | #include "interface_intern.h" | ||||
| static CLG_LogRef LOG = {"interface.anim"}; | |||||
| static FCurve *ui_but_get_fcurve( | static FCurve *ui_but_get_fcurve( | ||||
| uiBut *but, AnimData **adt, bAction **action, bool *r_driven, bool *r_special) | uiBut *but, AnimData **adt, bAction **action, bool *r_driven, bool *r_special) | ||||
| { | { | ||||
| /* for entire array buttons we check the first component, it's not perfect | /* for entire array buttons we check the first component, it's not perfect | ||||
| * but works well enough in typical cases */ | * but works well enough in typical cases */ | ||||
| int rnaindex = (but->rnaindex == -1) ? 0 : but->rnaindex; | int rnaindex = (but->rnaindex == -1) ? 0 : but->rnaindex; | ||||
| return BKE_fcurve_find_by_rna_context_ui( | return BKE_fcurve_find_by_rna_context_ui( | ||||
| ▲ Show 20 Lines • Show All 81 Lines • ▼ Show 20 Lines | if (!decorator_but->rnapoin.data || !decorator_but->rnaprop) { | ||||
| /* Nothing to do. */ | /* Nothing to do. */ | ||||
| return; | return; | ||||
| } | } | ||||
| const uiBut *but_anim = ui_but_anim_decorate_find_attached_button(decorator_but); | const uiBut *but_anim = ui_but_anim_decorate_find_attached_button(decorator_but); | ||||
| uiBut *but = &decorator_but->but; | uiBut *but = &decorator_but->but; | ||||
| if (!but_anim) { | if (!but_anim) { | ||||
| printf("Could not find button with matching property to decorate (%s.%s)\n", | CLOG_ERROR(&LOG, | ||||
| "Could not find button with matching property to decorate (%s.%s)", | |||||
| RNA_struct_identifier(decorator_but->rnapoin.type), | RNA_struct_identifier(decorator_but->rnapoin.type), | ||||
| RNA_property_identifier(decorator_but->rnaprop)); | RNA_property_identifier(decorator_but->rnaprop)); | ||||
| return; | return; | ||||
| } | } | ||||
| int flag = but_anim->flag; | int flag = but_anim->flag; | ||||
| if (flag & UI_BUT_DRIVEN) { | if (flag & UI_BUT_DRIVEN) { | ||||
| but->icon = ICON_DECORATE_DRIVER; | but->icon = ICON_DECORATE_DRIVER; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 81 Lines • ▼ Show 20 Lines | bool ui_but_anim_expression_create(uiBut *but, const char *str) | ||||
| bContext *C = but->block->evil_C; | bContext *C = but->block->evil_C; | ||||
| ID *id; | ID *id; | ||||
| FCurve *fcu; | FCurve *fcu; | ||||
| char *path; | char *path; | ||||
| bool ok = false; | bool ok = false; | ||||
| /* button must have RNA-pointer to a numeric-capable property */ | /* button must have RNA-pointer to a numeric-capable property */ | ||||
| if (ELEM(NULL, but->rnapoin.data, but->rnaprop)) { | if (ELEM(NULL, but->rnapoin.data, but->rnaprop)) { | ||||
| if (G.debug & G_DEBUG) { | CLOG_ERROR(&LOG, "create expression failed - button has no RNA info attached"); | ||||
| printf("ERROR: create expression failed - button has no RNA info attached\n"); | |||||
| } | |||||
| return false; | return false; | ||||
| } | } | ||||
| if (RNA_property_array_check(but->rnaprop) != 0) { | if (RNA_property_array_check(but->rnaprop) != 0) { | ||||
| if (but->rnaindex == -1) { | if (but->rnaindex == -1) { | ||||
| if (G.debug & G_DEBUG) { | CLOG_ERROR(&LOG, "create expression failed - can't create expression for entire array"); | ||||
| printf("ERROR: create expression failed - can't create expression for entire array\n"); | |||||
| } | |||||
| return false; | return false; | ||||
| } | } | ||||
| } | } | ||||
| /* make sure we have animdata for this */ | /* make sure we have animdata for this */ | ||||
| /* FIXME: until materials can be handled by depsgraph, | /* FIXME: until materials can be handled by depsgraph, | ||||
| * don't allow drivers to be created for them */ | * don't allow drivers to be created for them */ | ||||
| id = but->rnapoin.owner_id; | id = but->rnapoin.owner_id; | ||||
| if ((id == NULL) || (GS(id->name) == ID_MA) || (GS(id->name) == ID_TE)) { | if ((id == NULL) || (GS(id->name) == ID_MA) || (GS(id->name) == ID_TE)) { | ||||
| if (G.debug & G_DEBUG) { | CLOG_ERROR(&LOG, "create expression failed - invalid data-block for adding drivers (%p)", id); | ||||
| printf("ERROR: create expression failed - invalid data-block for adding drivers (%p)\n", id); | |||||
| } | |||||
| return false; | return false; | ||||
| } | } | ||||
| /* get path */ | /* get path */ | ||||
| path = RNA_path_from_ID_to_property(&but->rnapoin, but->rnaprop); | path = RNA_path_from_ID_to_property(&but->rnapoin, but->rnaprop); | ||||
| if (path == NULL) { | if (path == NULL) { | ||||
| return false; | return false; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 82 Lines • Show Last 20 Lines | |||||