~siretart/ubuntu/utopic/blender/libav10

« back to all changes in this revision

Viewing changes to source/blender/editors/util/editmode_undo.c

  • Committer: Bazaar Package Importer
  • Author(s): Kevin Roy
  • Date: 2011-06-24 11:13:28 UTC
  • mto: (14.1.6 experimental) (1.5.1)
  • mto: This revision was merged to the branch mainline in revision 28.
  • Revision ID: james.westby@ubuntu.com-20110624111328-27ribg6l36edf2ay
Tags: upstream-2.58-svn37702
ImportĀ upstreamĀ versionĀ 2.58-svn37702

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
 
 * $Id: editmode_undo.c 35242 2011-02-27 20:29:51Z jesterking $
 
2
 * $Id: editmode_undo.c 37185 2011-06-04 17:03:46Z ton $
3
3
 *
4
4
 * ***** BEGIN GPL LICENSE BLOCK *****
5
5
 *
296
296
}
297
297
 
298
298
/* based on index nr it does a restore */
299
 
static void undo_number(bContext *C, int nr)
 
299
void undo_editmode_number(bContext *C, int nr)
300
300
{
301
301
        UndoElem *uel;
302
302
        int a=1;
337
337
        return undobase.last != undobase.first;
338
338
}
339
339
 
340
 
/* ************** for interaction with menu/pullown */
341
 
 
342
 
void undo_editmode_menu(bContext *C)
343
 
{
344
 
        UndoElem *uel;
345
 
        DynStr *ds= BLI_dynstr_new();
346
 
        short event= 0;
347
 
        char *menu;
348
 
 
349
 
        undo_clean_stack(C);    // removes other objects from it
350
 
        
351
 
        BLI_dynstr_append(ds, "Editmode Undo History %t");
352
 
        
353
 
        for(uel= undobase.first; uel; uel= uel->next) {
354
 
                BLI_dynstr_append(ds, "|");
355
 
                BLI_dynstr_append(ds, uel->name);
356
 
        }
357
 
        
358
 
        menu= BLI_dynstr_get_cstring(ds);
359
 
        BLI_dynstr_free(ds);
360
 
        
361
 
// XXX  event= pupmenu_col(menu, 20);
362
 
        MEM_freeN(menu);
363
 
        
364
 
        if(event>0) undo_number(C, event);
365
 
}
366
 
 
367
 
static void do_editmode_undohistorymenu(bContext *C, void *UNUSED(arg), int event)
368
 
{
369
 
        Object *obedit= CTX_data_edit_object(C);
370
 
        
371
 
        if(obedit==NULL || event<1) return;
372
 
 
373
 
        undo_number(C, event-1);
374
 
        
375
 
}
376
 
 
377
 
uiBlock *editmode_undohistorymenu(bContext *C, ARegion *ar, void *UNUSED(arg))
378
 
{
379
 
        uiBlock *block;
380
 
        UndoElem *uel;
381
 
        short yco = 20, menuwidth = 120;
382
 
        short item= 1;
383
 
        
384
 
        undo_clean_stack(C);    // removes other objects from it
385
 
 
386
 
        block= uiBeginBlock(C, ar, "view3d_edit_mesh_undohistorymenu", UI_EMBOSSP);
387
 
        uiBlockSetButmFunc(block, do_editmode_undohistorymenu, NULL);
388
 
        
389
 
        for(uel= undobase.first; uel; uel= uel->next, item++) {
390
 
                if (uel==curundo) uiDefBut(block, SEPR, 0, "",          0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
391
 
                uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, uel->name, 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, (float)item, "");
392
 
                if (uel==curundo) uiDefBut(block, SEPR, 0, "",          0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
393
 
        }
394
 
        
395
 
        uiBlockSetDirection(block, UI_RIGHT);
396
 
        uiTextBoundsBlock(block, 60);
397
 
        return block;
398
 
}
 
340
 
 
341
/* get name of undo item, return null if no item with this index */
 
342
/* if active pointer, set it to 1 if true */
 
343
char *undo_editmode_get_name(bContext *C, int nr, int *active)
 
344
{
 
345
        UndoElem *uel;
 
346
        
 
347
        /* prevent wrong numbers to be returned */
 
348
        undo_clean_stack(C);
 
349
        
 
350
        if(active) *active= 0;
 
351
        
 
352
        uel= BLI_findlink(&undobase, nr);
 
353
        if(uel) {
 
354
                if(active && uel==curundo)
 
355
                        *active= 1;
 
356
                return uel->name;
 
357
        }
 
358
        return NULL;
 
359
}
 
360
 
399
361
 
400
362
void *undo_editmode_get_prev(Object *ob)
401
363
{