~siretart/ubuntu/utopic/blender/libav10

« back to all changes in this revision

Viewing changes to source/blender/editors/space_graph/graph_buttons.c

  • Committer: Package Import Robot
  • Author(s): Matteo F. Vescovi
  • Date: 2012-07-23 08:54:18 UTC
  • mfrom: (14.2.16 sid)
  • mto: (14.2.19 sid)
  • mto: This revision was merged to the branch mainline in revision 42.
  • Revision ID: package-import@ubuntu.com-20120723085418-9foz30v6afaf5ffs
Tags: 2.63a-2
* debian/: Cycles support added (Closes: #658075)
  For now, this top feature has been enabled only
  on [any-amd64 any-i386] architectures because
  of OpenImageIO failing on all others
* debian/: scripts installation path changed
  from /usr/lib to /usr/share:
  + debian/patches/: patchset re-worked for path changing
  + debian/control: "Breaks" field added on yafaray-exporter

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/**
2
 
 * $Id: graph_buttons.c 28880 2010-05-20 11:49:53Z aligorith $
3
 
 *
 
1
/*
4
2
 * ***** BEGIN GPL LICENSE BLOCK *****
5
3
 *
6
4
 * This program is free software; you can redistribute it and/or
26
24
 * ***** END GPL LICENSE BLOCK *****
27
25
 */
28
26
 
 
27
/** \file blender/editors/space_graph/graph_buttons.c
 
28
 *  \ingroup spgraph
 
29
 */
 
30
 
 
31
 
29
32
#include <string.h>
30
33
#include <stdio.h>
31
34
#include <math.h>
39
42
 
40
43
#include "BLI_math.h"
41
44
#include "BLI_blenlib.h"
42
 
#include "BLI_editVert.h"
43
45
#include "BLI_rand.h"
44
 
 
45
 
#include "BKE_action.h"
46
 
#include "BKE_animsys.h"
 
46
#include "BLI_utildefines.h"
 
47
 
 
48
#include "BLF_translation.h"
 
49
 
47
50
#include "BKE_context.h"
48
 
#include "BKE_curve.h"
49
 
#include "BKE_customdata.h"
50
51
#include "BKE_depsgraph.h"
51
52
#include "BKE_fcurve.h"
52
 
#include "BKE_library.h"
53
53
#include "BKE_main.h"
54
 
#include "BKE_object.h"
55
 
#include "BKE_scene.h"
56
54
#include "BKE_screen.h"
57
 
#include "BKE_utildefines.h"
 
55
#include "BKE_unit.h"
58
56
 
59
 
#include "BIF_gl.h"
60
57
 
61
58
#include "WM_api.h"
62
59
#include "WM_types.h"
80
77
 
81
78
/* ******************* graph editor space & buttons ************** */
82
79
 
83
 
#define B_NOP           1
84
 
#define B_REDR          2
 
80
#define B_REDR 1
85
81
 
86
82
/* -------------- */
87
83
 
88
 
static void do_graph_region_buttons(bContext *C, void *arg, int event)
 
84
static void do_graph_region_buttons(bContext *UNUSED(C), void *UNUSED(arg), int event)
89
85
{
90
86
        //Scene *scene= CTX_data_scene(C);
91
87
        
112
108
        
113
109
        /* try to find 'active' F-Curve */
114
110
        elem= get_active_fcurve_channel(&ac);
115
 
        if(elem == NULL) 
 
111
        if (elem == NULL) 
116
112
                return 0;
117
113
        
118
 
        if(fcu)
 
114
        if (fcu)
119
115
                *fcu= (FCurve*)elem->data;
120
 
        if(ale)
 
116
        if (ale)
121
117
                *ale= elem;
122
118
        else
123
119
                MEM_freeN(elem);
125
121
        return 1;
126
122
}
127
123
 
128
 
static int graph_panel_poll(const bContext *C, PanelType *pt)
 
124
static int graph_panel_poll(const bContext *C, PanelType *UNUSED(pt))
129
125
{
130
126
        return graph_panel_context(C, NULL, NULL);
131
127
}
139
135
        SpaceIpo *sipo= CTX_wm_space_graph(C);
140
136
        Scene *scene= CTX_data_scene(C);
141
137
        PointerRNA spaceptr, sceneptr;
142
 
        uiLayout *col, *subcol, *row;
 
138
        uiLayout *col, *sub, *row;
143
139
        
144
140
        /* get RNA pointers for use when creating the UI elements */
145
141
        RNA_id_pointer_create(&scene->id, &sceneptr);
147
143
 
148
144
        /* 2D-Cursor */
149
145
        col= uiLayoutColumn(pa->layout, 0);
150
 
                uiItemR(col, &spaceptr, "show_cursor", 0, NULL, 0);
151
 
                
152
 
                subcol= uiLayoutColumn(col, 1);
153
 
                uiLayoutSetActive(subcol, RNA_boolean_get(&spaceptr, "show_cursor")); 
154
 
                        uiItemO(subcol, "Cursor from Selection", 0, "GRAPH_OT_frame_jump");
155
 
                
156
 
                subcol= uiLayoutColumn(col, 1);
157
 
                uiLayoutSetActive(subcol, RNA_boolean_get(&spaceptr, "show_cursor")); 
158
 
                        row= uiLayoutSplit(subcol, 0.7, 1);
159
 
                                uiItemR(row, &sceneptr, "frame_current", 0, "Cursor X", 0);
160
 
                                uiItemEnumO(row, "GRAPH_OT_snap", "To Keys", 0, "type", GRAPHKEYS_SNAP_CFRA);
161
 
                        row= uiLayoutSplit(subcol, 0.7, 1);
162
 
                                uiItemR(row, &spaceptr, "cursor_value", 0, "Cursor Y", 0);
163
 
                                uiItemEnumO(row, "GRAPH_OT_snap", "To Keys", 0, "type", GRAPHKEYS_SNAP_VALUE);
 
146
                uiItemR(col, &spaceptr, "show_cursor", 0, NULL, ICON_NONE);
 
147
                
 
148
                sub= uiLayoutColumn(col, 1);
 
149
                uiLayoutSetActive(sub, RNA_boolean_get(&spaceptr, "show_cursor")); 
 
150
                        uiItemO(sub, IFACE_("Cursor from Selection"), ICON_NONE, "GRAPH_OT_frame_jump");
 
151
                
 
152
                sub= uiLayoutColumn(col, 1);
 
153
                uiLayoutSetActive(sub, RNA_boolean_get(&spaceptr, "show_cursor")); 
 
154
                        row= uiLayoutSplit(sub, 0.7, 1);
 
155
                                uiItemR(row, &sceneptr, "frame_current", 0, IFACE_("Cursor X"), ICON_NONE);
 
156
                                uiItemEnumO(row, "GRAPH_OT_snap", IFACE_("To Keys"), 0, "type", GRAPHKEYS_SNAP_CFRA);
 
157
                        row= uiLayoutSplit(sub, 0.7, 1);
 
158
                                uiItemR(row, &spaceptr, "cursor_position_y", 0, IFACE_("Cursor Y"), ICON_NONE);
 
159
                                uiItemEnumO(row, "GRAPH_OT_snap", IFACE_("To Keys"), 0, "type", GRAPHKEYS_SNAP_VALUE);
164
160
}
165
161
 
166
162
/* ******************* active F-Curve ************** */
171
167
        FCurve *fcu;
172
168
        PointerRNA fcu_ptr;
173
169
        uiLayout *layout = pa->layout;
174
 
        uiLayout *col, *row, *subrow;
 
170
        uiLayout *col, *row, *sub;
175
171
        uiBlock *block;
176
172
        char name[256];
177
173
        int icon = 0;
186
182
        RNA_pointer_create(ale->id, &RNA_FCurve, fcu, &fcu_ptr);
187
183
        
188
184
        /* user-friendly 'name' for F-Curve */
189
 
        // TODO: only show the path if this is invalid?
 
185
        /* TODO: only show the path if this is invalid? */
190
186
        col= uiLayoutColumn(layout, 0);
191
187
                icon= getname_anim_fcurve(name, ale->id, fcu);
192
188
                uiItemL(col, name, icon);
193
189
                
194
190
        /* RNA-Path Editing - only really should be enabled when things aren't working */
195
191
        col= uiLayoutColumn(layout, 1);
196
 
                uiLayoutSetEnabled(col, (fcu->flag & FCURVE_DISABLED)); 
 
192
                uiLayoutSetEnabled(col, (fcu->flag & FCURVE_DISABLED)!=0); 
197
193
                uiItemR(col, &fcu_ptr, "data_path", 0, "", ICON_RNA);
198
 
                uiItemR(col, &fcu_ptr, "array_index", 0, NULL, 0);
 
194
                uiItemR(col, &fcu_ptr, "array_index", 0, NULL, ICON_NONE);
199
195
                
200
196
        /* color settings */
201
197
        col= uiLayoutColumn(layout, 1);
202
 
                uiItemL(col, "Display Color:", 0);
 
198
                uiItemL(col, IFACE_("Display Color:"), ICON_NONE);
203
199
                
204
200
                row= uiLayoutRow(col, 1);
205
 
                        uiItemR(row, &fcu_ptr, "color_mode", 0, "", 0);
 
201
                        uiItemR(row, &fcu_ptr, "color_mode", 0, "", ICON_NONE);
206
202
                        
207
 
                        subrow= uiLayoutRow(row, 1);
208
 
                                uiLayoutSetEnabled(subrow, (fcu->color_mode==FCURVE_COLOR_CUSTOM));
209
 
                                uiItemR(subrow, &fcu_ptr, "color", 0, "", 0);
 
203
                        sub= uiLayoutRow(row, 1);
 
204
                                uiLayoutSetEnabled(sub, (fcu->color_mode==FCURVE_COLOR_CUSTOM));
 
205
                                uiItemR(sub, &fcu_ptr, "color", 0, "", ICON_NONE);
210
206
        
211
207
        MEM_freeN(ale);
212
208
}
247
243
        return 0;
248
244
}
249
245
 
 
246
/* update callback for active keyframe properties - base updates stuff */
 
247
static void graphedit_activekey_update_cb(bContext *C, void *fcu_ptr, void *UNUSED(bezt_ptr))
 
248
{
 
249
        SpaceIpo *sipo= CTX_wm_space_graph(C);
 
250
        const short use_handle = !(sipo->flag & SIPO_NOHANDLES);
 
251
        FCurve *fcu = (FCurve *)fcu_ptr;
 
252
        
 
253
        /* make sure F-Curve and its handles are still valid after this editing */
 
254
        sort_time_fcurve(fcu);
 
255
        testhandles_fcurve(fcu, use_handle);
 
256
}
 
257
 
 
258
/* update callback for active keyframe properties - handle-editing wrapper */
 
259
static void graphedit_activekey_handles_cb(bContext *C, void *fcu_ptr, void *bezt_ptr)
 
260
{
 
261
        BezTriple *bezt = (BezTriple *)bezt_ptr;
 
262
        
 
263
        /* since editing the handles, make sure they're set to types which are receptive to editing 
 
264
         * see transform_conversions.c :: createTransGraphEditData(), last step in second loop
 
265
         */
 
266
        if (ELEM(bezt->h1, HD_AUTO, HD_AUTO_ANIM) && ELEM(bezt->h2, HD_AUTO, HD_AUTO_ANIM)) {
 
267
                /* by changing to aligned handles, these can now be moved... */
 
268
                bezt->h1= HD_ALIGN;
 
269
                bezt->h2= HD_ALIGN;
 
270
        }
 
271
        
 
272
        /* now call standard updates */
 
273
        graphedit_activekey_update_cb(C, fcu_ptr, bezt_ptr);
 
274
}
 
275
 
250
276
static void graph_panel_key_properties(const bContext *C, Panel *pa)
251
277
{
252
278
        bAnimListElem *ale;
265
291
        
266
292
        /* only show this info if there are keyframes to edit */
267
293
        if (get_active_fcurve_keyframe_edit(fcu, &bezt, &prevbezt)) {
268
 
                PointerRNA bezt_ptr;
 
294
                PointerRNA bezt_ptr, id_ptr, fcu_prop_ptr;
 
295
                PropertyRNA *fcu_prop = NULL;
 
296
                uiBut *but;
 
297
                int unit = B_UNIT_NONE;
269
298
                
270
299
                /* RNA pointer to keyframe, to allow editing */
271
300
                RNA_pointer_create(ale->id, &RNA_Keyframe, bezt, &bezt_ptr);
272
301
                
 
302
                /* get property that F-Curve affects, for some unit-conversion magic */
 
303
                RNA_id_pointer_create(ale->id, &id_ptr);
 
304
                if (RNA_path_resolve(&id_ptr, fcu->rna_path, &fcu_prop_ptr, &fcu_prop) && fcu_prop) {
 
305
                        /* determine the unit for this property */
 
306
                        unit = RNA_SUBTYPE_UNIT(RNA_property_subtype(fcu_prop));
 
307
                }               
 
308
                
273
309
                /* interpolation */
274
310
                col= uiLayoutColumn(layout, 0);
275
 
                        uiItemR(col, &bezt_ptr, "interpolation", 0, NULL, 0);
 
311
                        uiItemR(col, &bezt_ptr, "interpolation", 0, NULL, ICON_NONE);
276
312
                        
277
 
                /* numerical coordinate editing */
 
313
                /* numerical coordinate editing 
 
314
                 *      - we use the button-versions of the calls so that we can attach special update handlers
 
315
                 *        and unit conversion magic that cannot be achieved using a purely RNA-approach
 
316
                 */
 
317
                // XXX: 
278
318
                col= uiLayoutColumn(layout, 1);
279
319
                        /* keyframe itself */
280
 
                        uiItemR(col, &bezt_ptr, "co", 0, "Key", 0);
 
320
                        {
 
321
                                uiItemL(col, IFACE_("Key:"), ICON_NONE);
 
322
                                
 
323
                                but = uiDefButR(block, NUM, B_REDR, IFACE_("Frame"), 0, 0, UI_UNIT_X, UI_UNIT_Y,
 
324
                                                &bezt_ptr, "co", 0, 0, 0, -1, -1, NULL);
 
325
                                uiButSetFunc(but, graphedit_activekey_update_cb, fcu, bezt);
 
326
                                
 
327
                                but = uiDefButR(block, NUM, B_REDR, IFACE_("Value"), 0, 0, UI_UNIT_X, UI_UNIT_Y,
 
328
                                                &bezt_ptr, "co", 1, 0, 0, -1, -1, NULL);
 
329
                                uiButSetFunc(but, graphedit_activekey_update_cb, fcu, bezt);
 
330
                                uiButSetUnitType(but, unit);
 
331
                        }
281
332
                        
282
333
                        /* previous handle - only if previous was Bezier interpolation */
283
 
                        if ((prevbezt) && (prevbezt->ipo == BEZT_IPO_BEZ))
284
 
                                uiItemR(col, &bezt_ptr, "handle1", 0, NULL, 0);
 
334
                        if ((prevbezt) && (prevbezt->ipo == BEZT_IPO_BEZ)) {
 
335
                                uiItemL(col, IFACE_("Left Handle:"), ICON_NONE);
 
336
                                
 
337
                                but = uiDefButR(block, NUM, B_REDR, "X", 0, 0, UI_UNIT_X, UI_UNIT_Y,
 
338
                                                &bezt_ptr, "handle_left", 0, 0, 0, -1, -1, NULL);
 
339
                                uiButSetFunc(but, graphedit_activekey_handles_cb, fcu, bezt);
 
340
                                
 
341
                                but = uiDefButR(block, NUM, B_REDR, "Y", 0, 0, UI_UNIT_X, UI_UNIT_Y,
 
342
                                                &bezt_ptr, "handle_left", 1, 0, 0, -1, -1, NULL);
 
343
                                uiButSetFunc(but, graphedit_activekey_handles_cb, fcu, bezt);
 
344
                                uiButSetUnitType(but, unit);
 
345
                        }
285
346
                        
286
347
                        /* next handle - only if current is Bezier interpolation */
287
 
                        if (bezt->ipo == BEZT_IPO_BEZ)
288
 
                                uiItemR(col, &bezt_ptr, "handle2", 0, NULL, 0);
289
 
        }
290
 
        else
291
 
                uiItemL(layout, "No active keyframe on F-Curve", 0);
 
348
                        if (bezt->ipo == BEZT_IPO_BEZ) {
 
349
                                uiItemL(col, IFACE_("Right Handle:"), ICON_NONE);
 
350
                                
 
351
                                but = uiDefButR(block, NUM, B_REDR, "X", 0, 0, UI_UNIT_X, UI_UNIT_Y,
 
352
                                                &bezt_ptr, "handle_right", 0, 0, 0, -1, -1, NULL);
 
353
                                uiButSetFunc(but, graphedit_activekey_handles_cb, fcu, bezt);
 
354
                                
 
355
                                but = uiDefButR(block, NUM, B_REDR, "Y", 0, 0, UI_UNIT_X, UI_UNIT_Y,
 
356
                                                &bezt_ptr, "handle_right", 1, 0, 0, -1, -1, NULL);
 
357
                                uiButSetFunc(but, graphedit_activekey_handles_cb, fcu, bezt);
 
358
                                uiButSetUnitType(but, unit);
 
359
                        }
 
360
        }
 
361
        else {
 
362
                if ((fcu->bezt == NULL) && (fcu->modifiers.first)) {
 
363
                        /* modifiers only - so no keyframes to be active */
 
364
                        uiItemL(layout, IFACE_("F-Curve only has F-Modifiers"), ICON_NONE);
 
365
                        uiItemL(layout, IFACE_("See Modifiers panel below"), ICON_INFO);
 
366
                }
 
367
                else if (fcu->fpt) {
 
368
                        /* samples only */
 
369
                        uiItemL(layout, IFACE_("F-Curve doesn't have any keyframes as it only contains sampled points"),
 
370
                                ICON_NONE);
 
371
                }
 
372
                else
 
373
                        uiItemL(layout, IFACE_("No active keyframe on F-Curve"), ICON_NONE);
 
374
        }
292
375
        
293
376
        MEM_freeN(ale);
294
377
}
297
380
 
298
381
#define B_IPO_DEPCHANGE         10
299
382
 
300
 
static void do_graph_region_driver_buttons(bContext *C, void *arg, int event)
 
383
static void do_graph_region_driver_buttons(bContext *C, void *UNUSED(arg), int event)
301
384
{
 
385
        Main *bmain= CTX_data_main(C);
302
386
        Scene *scene= CTX_data_scene(C);
303
387
        
304
388
        switch (event) {
305
389
                case B_IPO_DEPCHANGE:
306
390
                {
307
391
                        /* rebuild depsgraph for the new deps */
308
 
                        DAG_scene_sort(scene);
 
392
                        DAG_scene_sort(bmain, scene);
309
393
                        
310
394
                        /* force an update of depsgraph */
311
 
                        DAG_ids_flush_update(0);
 
395
                        DAG_ids_flush_update(bmain, 0);
312
396
                }
313
397
                        break;
314
398
        }
318
402
}
319
403
 
320
404
/* callback to remove the active driver */
321
 
static void driver_remove_cb (bContext *C, void *ale_v, void *dummy_v)
 
405
static void driver_remove_cb (bContext *C, void *ale_v, void *UNUSED(arg))
322
406
{
323
407
        bAnimListElem *ale= (bAnimListElem *)ale_v;
324
408
        ID *id= ale->id;
325
409
        FCurve *fcu= ale->data;
 
410
        ReportList *reports = CTX_wm_reports(C);
326
411
        
327
412
        /* try to get F-Curve that driver lives on, and ID block which has this AnimData */
328
413
        if (ELEM(NULL, id, fcu))
329
414
                return;
330
415
        
331
416
        /* call API method to remove this driver  */    
332
 
        ANIM_remove_driver(id, fcu->rna_path, fcu->array_index, 0);
 
417
        ANIM_remove_driver(reports, id, fcu->rna_path, fcu->array_index, 0);
333
418
}
334
419
 
335
420
/* callback to add a target variable to the active driver */
336
 
static void driver_add_var_cb (bContext *C, void *driver_v, void *dummy_v)
 
421
static void driver_add_var_cb (bContext *UNUSED(C), void *driver_v, void *UNUSED(arg))
337
422
{
338
423
        ChannelDriver *driver= (ChannelDriver *)driver_v;
339
424
        
342
427
}
343
428
 
344
429
/* callback to remove target variable from active driver */
345
 
static void driver_delete_var_cb (bContext *C, void *driver_v, void *dvar_v)
 
430
static void driver_delete_var_cb (bContext *UNUSED(C), void *driver_v, void *dvar_v)
346
431
{
347
432
        ChannelDriver *driver= (ChannelDriver *)driver_v;
348
433
        DriverVar *dvar= (DriverVar *)dvar_v;
352
437
}
353
438
 
354
439
/* callback to reset the driver's flags */
355
 
static void driver_update_flags_cb (bContext *C, void *fcu_v, void *dummy_v)
 
440
static void driver_update_flags_cb (bContext *UNUSED(C), void *fcu_v, void *UNUSED(arg))
356
441
{
357
442
        FCurve *fcu= (FCurve *)fcu_v;
358
443
        ChannelDriver *driver= fcu->driver;
363
448
}
364
449
 
365
450
/* drivers panel poll */
366
 
static int graph_panel_drivers_poll(const bContext *C, PanelType *pt)
 
451
static int graph_panel_drivers_poll(const bContext *C, PanelType *UNUSED(pt))
367
452
{
368
453
        SpaceIpo *sipo= CTX_wm_space_graph(C);
369
454
 
370
 
        if(sipo->mode != SIPO_MODE_DRIVERS)
 
455
        if (sipo->mode != SIPO_MODE_DRIVERS)
371
456
                return 0;
372
457
 
373
458
        return graph_panel_context(C, NULL, NULL);
374
459
}
375
460
 
376
 
 
377
461
/* settings for 'single property' driver variable type */
378
 
static void graph_panel_driverVar__singleProp(const bContext *C, uiLayout *layout, ID *id, DriverVar *dvar)
 
462
static void graph_panel_driverVar__singleProp(uiLayout *layout, ID *id, DriverVar *dvar)
379
463
{
380
464
        DriverTarget *dtar= &dvar->targets[0];
381
465
        PointerRNA dtar_ptr;
382
466
        uiLayout *row, *col;
383
 
        uiBlock *block;
384
467
        
385
 
        /* initialise RNA pointer to the target */
 
468
        /* initialize RNA pointer to the target */
386
469
        RNA_pointer_create(id, &RNA_DriverTarget, dtar, &dtar_ptr); 
387
470
        
388
471
        /* Target ID */
389
472
        row= uiLayoutRow(layout, 0);
390
 
                uiTemplateAnyID(row, (bContext *)C, &dtar_ptr, "id", "id_type", "Prop:");
 
473
                uiTemplateAnyID(row, &dtar_ptr, "id", "id_type", IFACE_("Prop:"));
391
474
        
392
475
        /* Target Property */
393
476
        // TODO: make this less technical...
398
481
                RNA_id_pointer_create(dtar->id, &root_ptr);
399
482
                
400
483
                col= uiLayoutColumn(layout, 1);
401
 
                block= uiLayoutGetBlock(col);
402
 
                        /* rna path */
403
 
                        uiTemplatePathBuilder(col, (bContext *)C, &dtar_ptr, "data_path", &root_ptr, "Path");
 
484
                /* rna path */
 
485
                uiTemplatePathBuilder(col, &dtar_ptr, "data_path", &root_ptr, IFACE_("Path"));
404
486
        }
405
487
}
406
488
 
407
489
/* settings for 'rotation difference' driver variable type */
408
 
static void graph_panel_driverVar__rotDiff(const bContext *C, uiLayout *layout, ID *id, DriverVar *dvar)
 
490
static void graph_panel_driverVar__rotDiff(uiLayout *layout, ID *id, DriverVar *dvar)
409
491
{
410
492
        DriverTarget *dtar= &dvar->targets[0];
411
493
        DriverTarget *dtar2= &dvar->targets[1];
414
496
        PointerRNA dtar_ptr, dtar2_ptr;
415
497
        uiLayout *col;
416
498
        
417
 
        /* initialise RNA pointer to the target */
 
499
        /* initialize RNA pointer to the target */
418
500
        RNA_pointer_create(id, &RNA_DriverTarget, dtar, &dtar_ptr); 
419
501
        RNA_pointer_create(id, &RNA_DriverTarget, dtar2, &dtar2_ptr); 
420
502
        
421
503
        /* Bone 1 */
422
504
        col= uiLayoutColumn(layout, 1);
423
 
                uiTemplateAnyID(col, (bContext *)C, &dtar_ptr, "id", "id_type", "Bone 1:");
 
505
                uiTemplateAnyID(col, &dtar_ptr, "id", "id_type", IFACE_("Bone 1:"));
424
506
                
425
507
                if (dtar->id && ob1->pose) {
426
508
                        PointerRNA tar_ptr;
430
512
                }
431
513
        
432
514
        col= uiLayoutColumn(layout, 1);
433
 
                uiTemplateAnyID(col, (bContext *)C, &dtar2_ptr, "id", "id_type", "Bone 2:");
 
515
                uiTemplateAnyID(col, &dtar2_ptr, "id", "id_type", IFACE_("Bone 2:"));
434
516
                
435
517
                if (dtar2->id && ob2->pose) {
436
518
                        PointerRNA tar_ptr;
441
523
}
442
524
 
443
525
/* settings for 'location difference' driver variable type */
444
 
static void graph_panel_driverVar__locDiff(const bContext *C, uiLayout *layout, ID *id, DriverVar *dvar)
 
526
static void graph_panel_driverVar__locDiff(uiLayout *layout, ID *id, DriverVar *dvar)
445
527
{
446
528
        DriverTarget *dtar= &dvar->targets[0];
447
529
        DriverTarget *dtar2= &dvar->targets[1];
450
532
        PointerRNA dtar_ptr, dtar2_ptr;
451
533
        uiLayout *col;
452
534
        
453
 
        /* initialise RNA pointer to the target */
 
535
        /* initialize RNA pointer to the target */
454
536
        RNA_pointer_create(id, &RNA_DriverTarget, dtar, &dtar_ptr); 
455
537
        RNA_pointer_create(id, &RNA_DriverTarget, dtar2, &dtar2_ptr); 
456
538
        
457
539
        /* Bone 1 */
458
540
        col= uiLayoutColumn(layout, 1);
459
 
                uiTemplateAnyID(col, (bContext *)C, &dtar_ptr, "id", "id_type", "Ob/Bone 1:");
 
541
                uiTemplateAnyID(col, &dtar_ptr, "id", "id_type", IFACE_("Ob/Bone 1:"));
460
542
                
461
543
                if (dtar->id && ob1->pose) {
462
544
                        PointerRNA tar_ptr;
465
547
                        uiItemPointerR(col, &dtar_ptr, "bone_target", &tar_ptr, "bones", "", ICON_BONE_DATA);
466
548
                }
467
549
                
468
 
                uiItemR(col, &dtar_ptr, "use_local_space_transforms", 0, NULL, 0);
 
550
                uiItemR(col, &dtar_ptr, "transform_space", 0, NULL, ICON_NONE);
469
551
        
470
552
        col= uiLayoutColumn(layout, 1);
471
 
                uiTemplateAnyID(col, (bContext *)C, &dtar2_ptr, "id", "id_type", "Ob/Bone 2:");
 
553
                uiTemplateAnyID(col, &dtar2_ptr, "id", "id_type", IFACE_("Ob/Bone 2:"));
472
554
                
473
555
                if (dtar2->id && ob2->pose) {
474
556
                        PointerRNA tar_ptr;
477
559
                        uiItemPointerR(col, &dtar2_ptr, "bone_target", &tar_ptr, "bones", "", ICON_BONE_DATA);
478
560
                }
479
561
                
480
 
                uiItemR(col, &dtar2_ptr, "use_local_space_transforms", 0, NULL, 0);
 
562
                uiItemR(col, &dtar2_ptr, "transform_space", 0, NULL, ICON_NONE);
481
563
}
482
564
 
483
565
/* settings for 'transform channel' driver variable type */
484
 
static void graph_panel_driverVar__transChan(const bContext *C, uiLayout *layout, ID *id, DriverVar *dvar)
 
566
static void graph_panel_driverVar__transChan(uiLayout *layout, ID *id, DriverVar *dvar)
485
567
{
486
568
        DriverTarget *dtar= &dvar->targets[0];
487
569
        Object *ob = (Object *)dtar->id;
488
570
        PointerRNA dtar_ptr;
489
 
        uiLayout *col, *row;
 
571
        uiLayout *col, *sub;
490
572
        
491
 
        /* initialise RNA pointer to the target */
 
573
        /* initialize RNA pointer to the target */
492
574
        RNA_pointer_create(id, &RNA_DriverTarget, dtar, &dtar_ptr); 
493
575
        
494
576
        /* properties */
495
577
        col= uiLayoutColumn(layout, 1);
496
 
                uiTemplateAnyID(col, (bContext *)C, &dtar_ptr, "id", "id_type", "Ob/Bone:");
 
578
                uiTemplateAnyID(col, &dtar_ptr, "id", "id_type", IFACE_("Ob/Bone:"));
497
579
                
498
580
                if (dtar->id && ob->pose) {
499
581
                        PointerRNA tar_ptr;
502
584
                        uiItemPointerR(col, &dtar_ptr, "bone_target", &tar_ptr, "bones", "", ICON_BONE_DATA);
503
585
                }
504
586
                
505
 
                row= uiLayoutRow(layout, 1);
506
 
                        uiItemR(row, &dtar_ptr, "transform_type", 0, "", 0);
507
 
                        uiItemR(row, &dtar_ptr, "use_local_space_transforms", 0, NULL, 0);
 
587
                sub= uiLayoutColumn(layout, 1);
 
588
                        uiItemR(sub, &dtar_ptr, "transform_type", 0, NULL, ICON_NONE);
 
589
                        uiItemR(sub, &dtar_ptr, "transform_space", 0, IFACE_("Space"), ICON_NONE);
508
590
}
509
591
 
510
592
/* driver settings for active F-Curve (only for 'Drivers' mode) */
532
614
        /* general actions - management */
533
615
        col= uiLayoutColumn(pa->layout, 0);
534
616
        block= uiLayoutGetBlock(col);
535
 
                but= uiDefBut(block, BUT, B_IPO_DEPCHANGE, "Update Dependencies", 0, 0, 10*UI_UNIT_X, 22, NULL, 0.0, 0.0, 0, 0, "Force updates of dependencies");
 
617
                but = uiDefBut(block, BUT, B_IPO_DEPCHANGE, IFACE_("Update Dependencies"), 0, 0, 10*UI_UNIT_X, 22,
 
618
                              NULL, 0.0, 0.0, 0, 0, TIP_("Force updates of dependencies"));
536
619
                uiButSetFunc(but, driver_update_flags_cb, fcu, NULL);
537
620
                
538
 
                but= uiDefBut(block, BUT, B_IPO_DEPCHANGE, "Remove Driver", 0, 0, 10*UI_UNIT_X, 18, NULL, 0.0, 0.0, 0, 0, "Remove this driver");
 
621
                but = uiDefBut(block, BUT, B_IPO_DEPCHANGE, IFACE_("Remove Driver"), 0, 0, 10*UI_UNIT_X, 18,
 
622
                              NULL, 0.0, 0.0, 0, 0, TIP_("Remove this driver"));
539
623
                uiButSetNFunc(but, driver_remove_cb, MEM_dupallocN(ale), NULL);
540
624
                
541
625
        /* driver-level settings - type, expressions, and errors */
543
627
        
544
628
        col= uiLayoutColumn(pa->layout, 1);
545
629
        block= uiLayoutGetBlock(col);
546
 
                uiItemR(col, &driver_ptr, "type", 0, NULL, 0);
 
630
                uiItemR(col, &driver_ptr, "type", 0, NULL, ICON_NONE);
547
631
                
548
632
                /* show expression box if doing scripted drivers, and/or error messages when invalid drivers exist */
549
633
                if (driver->type == DRIVER_TYPE_PYTHON) {
550
634
                        /* expression */
551
 
                        uiItemR(col, &driver_ptr, "expression", 0, "Expr", 0);
 
635
                        uiItemR(col, &driver_ptr, "expression", 0, IFACE_("Expr"), ICON_NONE);
552
636
                        
553
637
                        /* errors? */
554
638
                        if (driver->flag & DRIVER_FLAG_INVALID)
555
 
                                uiItemL(col, "ERROR: invalid Python expression", ICON_ERROR);
 
639
                                uiItemL(col, IFACE_("ERROR: invalid Python expression"), ICON_ERROR);
556
640
                }
557
641
                else {
558
642
                        /* errors? */
559
643
                        if (driver->flag & DRIVER_FLAG_INVALID)
560
 
                                uiItemL(col, "ERROR: invalid target channel(s)", ICON_ERROR);
 
644
                                uiItemL(col, IFACE_("ERROR: invalid target channel(s)"), ICON_ERROR);
561
645
                }
562
646
                
563
647
        col= uiLayoutColumn(pa->layout, 1);
564
648
                /* debug setting */
565
 
                uiItemR(col, &driver_ptr, "show_debug_info", 0, NULL, 0);
 
649
                uiItemR(col, &driver_ptr, "show_debug_info", 0, NULL, ICON_NONE);
566
650
                
567
651
                /* value of driver */
568
652
                if (driver->flag & DRIVER_FLAG_SHOWDEBUG) {
569
653
                        uiLayout *row= uiLayoutRow(col, 1);
570
654
                        char valBuf[32];
571
655
                        
572
 
                        uiItemL(row, "Driver Value:", 0);
 
656
                        uiItemL(row, IFACE_("Driver Value:"), ICON_NONE);
573
657
                        
574
 
                        sprintf(valBuf, "%.3f", driver->curval);
575
 
                        uiItemL(row, valBuf, 0);
 
658
                        BLI_snprintf(valBuf, sizeof(valBuf), "%.3f", driver->curval);
 
659
                        uiItemL(row, valBuf, ICON_NONE);
576
660
                }
577
661
        
578
662
        /* add driver variables */
579
663
        col= uiLayoutColumn(pa->layout, 0);
580
664
        block= uiLayoutGetBlock(col);
581
 
                but= uiDefBut(block, BUT, B_IPO_DEPCHANGE, "Add Variable", 0, 0, 10*UI_UNIT_X, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 0, "Add a new target variable for this Driver");
 
665
                but = uiDefBut(block, BUT, B_IPO_DEPCHANGE, IFACE_("Add Variable"), 0, 0, 10*UI_UNIT_X, UI_UNIT_Y,
 
666
                              NULL, 0.0, 0.0, 0, 0, TIP_("Add a new target variable for this Driver"));
582
667
                uiButSetFunc(but, driver_add_var_cb, driver, NULL);
583
668
        
584
669
        /* loop over targets, drawing them */
597
682
                        row= uiLayoutRow(box, 0);
598
683
                        block= uiLayoutGetBlock(row);
599
684
                                /* variable name */
600
 
                                uiItemR(row, &dvar_ptr, "name", 0, "", 0);
 
685
                                uiItemR(row, &dvar_ptr, "name", 0, "", ICON_NONE);
601
686
                                
602
687
                                /* remove button */
603
688
                                uiBlockSetEmboss(block, UI_EMBOSSN);
604
 
                                        but= uiDefIconBut(block, BUT, B_IPO_DEPCHANGE, ICON_X, 290, 0, UI_UNIT_X, UI_UNIT_Y, NULL, 0.0, 0.0, 0.0, 0.0, "Delete target variable.");
 
689
                                        but = uiDefIconBut(block, BUT, B_IPO_DEPCHANGE, ICON_X, 290, 0, UI_UNIT_X, UI_UNIT_Y,
 
690
                                                          NULL, 0.0, 0.0, 0.0, 0.0, IFACE_("Delete target variable"));
605
691
                                        uiButSetFunc(but, driver_delete_var_cb, driver, dvar);
606
692
                                uiBlockSetEmboss(block, UI_EMBOSS);
607
693
                        
608
694
                        /* variable type */
609
695
                        row= uiLayoutRow(box, 0);
610
 
                                uiItemR(row, &dvar_ptr, "type", 0, "", 0);
 
696
                                uiItemR(row, &dvar_ptr, "type", 0, "", ICON_NONE);
611
697
                                
612
698
                /* variable type settings */
613
699
                box= uiLayoutBox(col);
614
700
                        /* controls to draw depends on the type of variable */
615
701
                        switch (dvar->type) {
616
702
                                case DVAR_TYPE_SINGLE_PROP:     /* single property */
617
 
                                        graph_panel_driverVar__singleProp(C, box, ale->id, dvar);
 
703
                                        graph_panel_driverVar__singleProp(box, ale->id, dvar);
618
704
                                        break;
619
705
                                case DVAR_TYPE_ROT_DIFF: /* rotational difference */
620
 
                                        graph_panel_driverVar__rotDiff(C, box, ale->id, dvar);
 
706
                                        graph_panel_driverVar__rotDiff(box, ale->id, dvar);
621
707
                                        break;
622
708
                                case DVAR_TYPE_LOC_DIFF: /* location difference */
623
 
                                        graph_panel_driverVar__locDiff(C, box, ale->id, dvar);
 
709
                                        graph_panel_driverVar__locDiff(box, ale->id, dvar);
624
710
                                        break;
625
711
                                case DVAR_TYPE_TRANSFORM_CHAN: /* transform channel */
626
 
                                        graph_panel_driverVar__transChan(C, box, ale->id, dvar);
 
712
                                        graph_panel_driverVar__transChan(box, ale->id, dvar);
627
713
                                        break;
628
714
                        }
629
 
                        
630
 
                /* value of variable */
631
 
                if (driver->flag & DRIVER_FLAG_SHOWDEBUG) {
632
 
                        uiLayout *row;
633
 
                        char valBuf[32];
634
 
                        
635
 
                        box= uiLayoutBox(col);
636
 
                        row= uiLayoutRow(box, 1);
637
 
                                uiItemL(row, "Value:", 0);
 
715
 
 
716
                        /* value of variable */
 
717
                        if (driver->flag & DRIVER_FLAG_SHOWDEBUG) {
 
718
                                char valBuf[32];
 
719
 
 
720
                                box= uiLayoutBox(col);
 
721
                                row= uiLayoutRow(box, 1);
 
722
                                uiItemL(row, IFACE_("Value:"), ICON_NONE);
638
723
                                
639
 
                                sprintf(valBuf, "%.3f", dvar->curval);
640
 
                                uiItemL(row, valBuf, 0);
641
 
                }
 
724
                                BLI_snprintf(valBuf, sizeof(valBuf), "%.3f", dvar->curval);
 
725
                                uiItemL(row, valBuf, ICON_NONE);
 
726
                        }
642
727
        }
643
728
        
644
729
        /* cleanup */
650
735
 
651
736
#define B_FMODIFIER_REDRAW              20
652
737
 
653
 
static void do_graph_region_modifier_buttons(bContext *C, void *arg, int event)
 
738
static void do_graph_region_modifier_buttons(bContext *C, void *UNUSED(arg), int event)
654
739
{
655
740
        switch (event) {
656
 
                case B_REDR:
657
741
                case B_FMODIFIER_REDRAW: // XXX this should send depsgraph updates too
658
742
                        WM_event_add_notifier(C, NC_ANIMATION, NULL); // XXX need a notifier specially for F-Modifiers
659
743
                        break;
680
764
                block= uiLayoutGetBlock(row);
681
765
                
682
766
                // XXX for now, this will be a operator button which calls a 'add modifier' operator
683
 
                uiDefButO(block, BUT, "GRAPH_OT_fmodifier_add", WM_OP_INVOKE_REGION_WIN, "Add Modifier", 10, 0, 150, 20, "Adds a new F-Curve Modifier for the active F-Curve");
 
767
                uiDefButO(block, BUT, "GRAPH_OT_fmodifier_add", WM_OP_INVOKE_REGION_WIN, IFACE_("Add Modifier"),
 
768
                          10, 0, 150, 20, TIP_("Adds a new F-Curve Modifier for the active F-Curve"));
684
769
                
685
770
                /* copy/paste (as sub-row)*/
686
771
                row= uiLayoutRow(row, 1);
706
791
 
707
792
        pt= MEM_callocN(sizeof(PanelType), "spacetype graph panel view");
708
793
        strcpy(pt->idname, "GRAPH_PT_view");
709
 
        strcpy(pt->label, "View Properties");
 
794
        strcpy(pt->label, N_("View Properties"));
710
795
        pt->draw= graph_panel_view;
711
796
        pt->flag |= PNL_DEFAULT_CLOSED;
712
797
        BLI_addtail(&art->paneltypes, pt);
713
798
        
714
799
        pt= MEM_callocN(sizeof(PanelType), "spacetype graph panel properties");
715
800
        strcpy(pt->idname, "GRAPH_PT_properties");
716
 
        strcpy(pt->label, "Active F-Curve");
 
801
        strcpy(pt->label, N_("Active F-Curve"));
717
802
        pt->draw= graph_panel_properties;
718
803
        pt->poll= graph_panel_poll;
719
804
        BLI_addtail(&art->paneltypes, pt);
720
805
        
721
806
        pt= MEM_callocN(sizeof(PanelType), "spacetype graph panel properties");
722
807
        strcpy(pt->idname, "GRAPH_PT_key_properties");
723
 
        strcpy(pt->label, "Active Keyframe");
 
808
        strcpy(pt->label, N_("Active Keyframe"));
724
809
        pt->draw= graph_panel_key_properties;
725
810
        pt->poll= graph_panel_poll;
726
811
        BLI_addtail(&art->paneltypes, pt);
728
813
 
729
814
        pt= MEM_callocN(sizeof(PanelType), "spacetype graph panel drivers");
730
815
        strcpy(pt->idname, "GRAPH_PT_drivers");
731
 
        strcpy(pt->label, "Drivers");
 
816
        strcpy(pt->label, N_("Drivers"));
732
817
        pt->draw= graph_panel_drivers;
733
818
        pt->poll= graph_panel_drivers_poll;
734
819
        BLI_addtail(&art->paneltypes, pt);
735
820
 
736
821
        pt= MEM_callocN(sizeof(PanelType), "spacetype graph panel modifiers");
737
822
        strcpy(pt->idname, "GRAPH_PT_modifiers");
738
 
        strcpy(pt->label, "Modifiers");
 
823
        strcpy(pt->label, N_("Modifiers"));
739
824
        pt->draw= graph_panel_modifiers;
740
825
        pt->poll= graph_panel_poll;
741
826
        BLI_addtail(&art->paneltypes, pt);
742
827
}
743
828
 
744
 
static int graph_properties(bContext *C, wmOperator *op)
 
829
static int graph_properties(bContext *C, wmOperator *UNUSED(op))
745
830
{
746
831
        ScrArea *sa= CTX_wm_area(C);
747
832
        ARegion *ar= graph_has_buttons_region(sa);
748
833
        
749
 
        if(ar)
 
834
        if (ar)
750
835
                ED_region_toggle_hidden(C, ar);
751
836
 
752
837
        return OPERATOR_FINISHED;
754
839
 
755
840
void GRAPH_OT_properties(wmOperatorType *ot)
756
841
{
757
 
        ot->name= "Properties";
758
 
        ot->idname= "GRAPH_OT_properties";
 
842
        ot->name = "Properties";
 
843
        ot->idname = "GRAPH_OT_properties";
 
844
        ot->description = "Toggle display properties panel";
759
845
        
760
 
        ot->exec= graph_properties;
761
 
        ot->poll= ED_operator_ipo_active; // xxx
762
 
        
 
846
        ot->exec = graph_properties;
 
847
        ot->poll = ED_operator_graphedit_active;
 
848
 
763
849
        /* flags */
764
 
        ot->flag= 0;
 
850
        ot->flag = 0;
765
851
}