2011-02-23 10:52:22 +00:00
|
|
|
/*
|
2008-12-30 19:01:12 +00:00
|
|
|
* ***** BEGIN GPL LICENSE BLOCK *****
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software Foundation,
|
2010-02-12 13:34:04 +00:00
|
|
|
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2008-12-30 19:01:12 +00:00
|
|
|
*
|
|
|
|
* The Original Code is Copyright (C) 2004 Blender Foundation
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* The Original Code is: all of this file.
|
|
|
|
*
|
|
|
|
* Contributor(s): none yet.
|
|
|
|
*
|
|
|
|
* ***** END GPL LICENSE BLOCK *****
|
|
|
|
*/
|
|
|
|
|
2011-02-27 20:29:51 +00:00
|
|
|
/** \file blender/editors/util/undo.c
|
|
|
|
* \ingroup edutil
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2008-12-30 19:01:12 +00:00
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <math.h>
|
|
|
|
|
|
|
|
#include "MEM_guardedalloc.h"
|
|
|
|
|
|
|
|
#include "DNA_object_types.h"
|
|
|
|
|
|
|
|
#include "BLI_blenlib.h"
|
|
|
|
#include "BLI_editVert.h"
|
|
|
|
#include "BLI_dynstr.h"
|
2011-01-07 18:36:47 +00:00
|
|
|
#include "BLI_utildefines.h"
|
2008-12-30 19:01:12 +00:00
|
|
|
|
2011-01-07 18:36:47 +00:00
|
|
|
#include "BKE_blender.h"
|
|
|
|
#include "BKE_context.h"
|
|
|
|
#include "BKE_global.h"
|
|
|
|
#include "BKE_screen.h"
|
2008-12-30 19:01:12 +00:00
|
|
|
|
2009-01-24 13:45:24 +00:00
|
|
|
#include "ED_armature.h"
|
2009-02-20 20:39:27 +00:00
|
|
|
#include "ED_particle.h"
|
2009-01-24 13:45:24 +00:00
|
|
|
#include "ED_curve.h"
|
2011-09-06 07:59:18 +00:00
|
|
|
#include "ED_gpencil.h"
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
#include "ED_mball.h"
|
2008-12-30 19:01:12 +00:00
|
|
|
#include "ED_mesh.h"
|
2009-01-24 13:45:24 +00:00
|
|
|
#include "ED_object.h"
|
2008-12-31 18:52:15 +00:00
|
|
|
#include "ED_screen.h"
|
2009-02-19 23:53:40 +00:00
|
|
|
#include "ED_sculpt.h"
|
2008-12-31 18:52:15 +00:00
|
|
|
#include "ED_util.h"
|
2.5: Text Editor back.
There was very little structure in this code, using many globals
and duplicated code. Now it should be better structured. Most
things should work, the main parts that are not back yet are the
python plugins and markers. Notes:
* Blenfont is used for drawing the text, nicely anti-aliased.
* A monospace truetype font was added, since that is needed for
the text editor. It's Bitstream Vera Sans Mono. This is the
default gnome terminal font, but it doesn't fit entirely well
with the other font I think, can be changed easily of course.
* Clipboard copy/cut/paste now always uses the system clipboard,
the code for the own cut buffer was removed.
* The interface buttons should support copy/cut/paste again now
as well.
* WM_clipboard_text_get/WM_clipboard_text_set were added to the
windowmanager code.
* Find panel is now a kind of second header, instead of a panel.
This needs especially a way to start editing the text field
immediately on open still.
* Operators are independent of the actual space when possible,
was a bit of puzzling but got it solved nice with notifiers,
and some lazy init for syntax highlight in the drawing code.
* RNA was created for the text editor space and used for buttons.
* Operators:
* New, Open, Reload, Save, Save As, Make Internal
* Run Script, Refresh Pyconstraints
* Copy, Cut, Paste
* Convert Whitespace, Uncomment, Comment, Indent, Unindent
* Line Break, Insert
* Next Marker, Previous Marker, Clear All Markers, Mark All
* Select Line, Select All
* Jump, Move, Move Select, Delete, Toggle Overwrite
* Scroll, Scroll Bar, Set Cursor, Line Number
* Find and Replace, Find, Replace, Find Set Selected,
Replace Set Selected
* To 3D Object
* Resolve Conflict
2009-02-28 23:33:35 +00:00
|
|
|
#include "ED_text.h"
|
2008-12-31 18:52:15 +00:00
|
|
|
|
|
|
|
#include "WM_api.h"
|
|
|
|
#include "WM_types.h"
|
2008-12-30 19:01:12 +00:00
|
|
|
|
2011-02-22 02:42:19 +00:00
|
|
|
#include "RNA_access.h"
|
|
|
|
#include "RNA_define.h"
|
2008-12-30 19:01:12 +00:00
|
|
|
|
Code holiday commit:
- fix: user pref, window title was reset to 'Blender' on tab usage
- Undo history menu back:
- name "Undo History"
- hotkey alt+ctrl+z (alt+apple+z for mac)
- works like 2.4x, only for global undo, editmode and particle edit.
- Menu scroll
- for small windows or screens, popup menus now allow to display
all items, using internal scrolling
- works with a timer, scrolling 10 items per second when mouse
is over the top or bottom arrow
- if menu is too big to display, it now draws to top or bottom,
based on largest available space.
- also works for hotkey driven pop up menus.
- User pref "DPI" follows widget/layout size
- widgets & headers now become bigger and smaller, to match
'dpi' font sizes. Works well to match UI to monitor size.
- note that icons can get fuzzy, we need better mipmaps for it
2011-06-04 17:03:46 +00:00
|
|
|
#include "UI_interface.h"
|
|
|
|
#include "UI_resources.h"
|
|
|
|
|
2.5
Operator goodies!
--- Macro operators
Operators now can consist of multiple operators. Such a macro operator
is identical and behaves identical to other opererators. Macros can
also be constructed of macros even! Currently only hardcoded macros are
implemented, this to solve combined operators such as 'add duplicate' or
'extrude' (both want a transform appended).
Usage is simple:
- WM_operatortype_append_macro() : add new operatortype, name, flags
- WM_operatortype_macro_define() : add existing operator to macro
(Note: macro_define will also allow properties to be set, doesnt work
right now)
On converting the macro wmOperatorType to a real operator, it makes a
list of all operators, and the standard macro callbacks (exec, invoke,
modal, poll) just will use all.
Important note; switching to a modal operator only works as last in the
chain now!
Macros implemented for duplicate, extrude and rip. Tool menu works fine
for it, also the redo hotkey F4 works properly.
--- Operator redo fix
The operators use the undo system to switch back, but this could give
errors if other actions added undo pushes (buttons, outliner). Now the
redo for operator searches back for the correct undo level.
This fixes issues with many redos.
Note for brecht: removed the ED_undo_push for buttons... it was called
on *every* button now, which is probably too much? For example, using
the 'toolbar' redo also caused this...
2009-07-29 17:56:38 +00:00
|
|
|
#include "util_intern.h"
|
|
|
|
|
2011-02-22 02:42:19 +00:00
|
|
|
#define MAXUNDONAME 64 /* XXX, make common define */
|
|
|
|
|
2008-12-30 19:01:12 +00:00
|
|
|
/* ***************** generic undo system ********************* */
|
|
|
|
|
2010-11-17 09:45:45 +00:00
|
|
|
void ED_undo_push(bContext *C, const char *str)
|
2008-12-30 19:01:12 +00:00
|
|
|
{
|
2009-02-18 13:29:54 +00:00
|
|
|
wmWindowManager *wm= CTX_wm_manager(C);
|
2009-01-02 19:10:35 +00:00
|
|
|
Object *obedit= CTX_data_edit_object(C);
|
2009-08-16 02:35:44 +00:00
|
|
|
Object *obact= CTX_data_active_object(C);
|
2.5
Operator goodies!
--- Macro operators
Operators now can consist of multiple operators. Such a macro operator
is identical and behaves identical to other opererators. Macros can
also be constructed of macros even! Currently only hardcoded macros are
implemented, this to solve combined operators such as 'add duplicate' or
'extrude' (both want a transform appended).
Usage is simple:
- WM_operatortype_append_macro() : add new operatortype, name, flags
- WM_operatortype_macro_define() : add existing operator to macro
(Note: macro_define will also allow properties to be set, doesnt work
right now)
On converting the macro wmOperatorType to a real operator, it makes a
list of all operators, and the standard macro callbacks (exec, invoke,
modal, poll) just will use all.
Important note; switching to a modal operator only works as last in the
chain now!
Macros implemented for duplicate, extrude and rip. Tool menu works fine
for it, also the redo hotkey F4 works properly.
--- Operator redo fix
The operators use the undo system to switch back, but this could give
errors if other actions added undo pushes (buttons, outliner). Now the
redo for operator searches back for the correct undo level.
This fixes issues with many redos.
Note for brecht: removed the ED_undo_push for buttons... it was called
on *every* button now, which is probably too much? For example, using
the 'toolbar' redo also caused this...
2009-07-29 17:56:38 +00:00
|
|
|
|
2011-03-12 15:09:29 +00:00
|
|
|
if (G.f & G_DEBUG)
|
|
|
|
printf("undo push %s\n", str);
|
|
|
|
|
2009-01-02 19:10:35 +00:00
|
|
|
if(obedit) {
|
2008-12-30 19:01:12 +00:00
|
|
|
if (U.undosteps == 0) return;
|
|
|
|
|
2009-01-02 19:10:35 +00:00
|
|
|
if(obedit->type==OB_MESH)
|
2009-01-01 13:15:35 +00:00
|
|
|
undo_push_mesh(C, str);
|
2009-01-02 19:10:35 +00:00
|
|
|
else if ELEM(obedit->type, OB_CURVE, OB_SURF)
|
2009-01-24 13:45:24 +00:00
|
|
|
undo_push_curve(C, str);
|
2009-01-02 19:10:35 +00:00
|
|
|
else if (obedit->type==OB_FONT)
|
2009-01-24 13:45:24 +00:00
|
|
|
undo_push_font(C, str);
|
2009-01-02 19:10:35 +00:00
|
|
|
else if (obedit->type==OB_MBALL)
|
2009-07-29 12:35:09 +00:00
|
|
|
undo_push_mball(C, str);
|
2009-01-02 19:10:35 +00:00
|
|
|
else if (obedit->type==OB_LATTICE)
|
2009-01-24 13:45:24 +00:00
|
|
|
undo_push_lattice(C, str);
|
2009-01-02 19:10:35 +00:00
|
|
|
else if (obedit->type==OB_ARMATURE)
|
2009-01-24 13:45:24 +00:00
|
|
|
undo_push_armature(C, str);
|
2008-12-30 19:01:12 +00:00
|
|
|
}
|
2009-08-16 02:35:44 +00:00
|
|
|
else if(obact && obact->mode & OB_MODE_PARTICLE_EDIT) {
|
2008-12-30 19:01:12 +00:00
|
|
|
if (U.undosteps == 0) return;
|
|
|
|
|
2009-01-24 13:45:24 +00:00
|
|
|
PE_undo_push(CTX_data_scene(C), str);
|
2008-12-30 19:01:12 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
if(U.uiflag & USER_GLOBALUNDO)
|
|
|
|
BKE_write_undo(C, str);
|
|
|
|
}
|
2009-02-18 13:29:54 +00:00
|
|
|
|
|
|
|
if(wm->file_saved) {
|
|
|
|
wm->file_saved= 0;
|
Code holiday commit:
- fix: user pref, window title was reset to 'Blender' on tab usage
- Undo history menu back:
- name "Undo History"
- hotkey alt+ctrl+z (alt+apple+z for mac)
- works like 2.4x, only for global undo, editmode and particle edit.
- Menu scroll
- for small windows or screens, popup menus now allow to display
all items, using internal scrolling
- works with a timer, scrolling 10 items per second when mouse
is over the top or bottom arrow
- if menu is too big to display, it now draws to top or bottom,
based on largest available space.
- also works for hotkey driven pop up menus.
- User pref "DPI" follows widget/layout size
- widgets & headers now become bigger and smaller, to match
'dpi' font sizes. Works well to match UI to monitor size.
- note that icons can get fuzzy, we need better mipmaps for it
2011-06-04 17:03:46 +00:00
|
|
|
/* notifier that data changed, for save-over warning or header */
|
2009-02-18 13:29:54 +00:00
|
|
|
WM_event_add_notifier(C, NC_WM|ND_DATACHANGED, NULL);
|
|
|
|
}
|
2008-12-30 19:01:12 +00:00
|
|
|
}
|
|
|
|
|
Code holiday commit:
- fix: user pref, window title was reset to 'Blender' on tab usage
- Undo history menu back:
- name "Undo History"
- hotkey alt+ctrl+z (alt+apple+z for mac)
- works like 2.4x, only for global undo, editmode and particle edit.
- Menu scroll
- for small windows or screens, popup menus now allow to display
all items, using internal scrolling
- works with a timer, scrolling 10 items per second when mouse
is over the top or bottom arrow
- if menu is too big to display, it now draws to top or bottom,
based on largest available space.
- also works for hotkey driven pop up menus.
- User pref "DPI" follows widget/layout size
- widgets & headers now become bigger and smaller, to match
'dpi' font sizes. Works well to match UI to monitor size.
- note that icons can get fuzzy, we need better mipmaps for it
2011-06-04 17:03:46 +00:00
|
|
|
/* note: also check undo_history_exec() in bottom if you change notifiers */
|
2.5
Operator goodies!
--- Macro operators
Operators now can consist of multiple operators. Such a macro operator
is identical and behaves identical to other opererators. Macros can
also be constructed of macros even! Currently only hardcoded macros are
implemented, this to solve combined operators such as 'add duplicate' or
'extrude' (both want a transform appended).
Usage is simple:
- WM_operatortype_append_macro() : add new operatortype, name, flags
- WM_operatortype_macro_define() : add existing operator to macro
(Note: macro_define will also allow properties to be set, doesnt work
right now)
On converting the macro wmOperatorType to a real operator, it makes a
list of all operators, and the standard macro callbacks (exec, invoke,
modal, poll) just will use all.
Important note; switching to a modal operator only works as last in the
chain now!
Macros implemented for duplicate, extrude and rip. Tool menu works fine
for it, also the redo hotkey F4 works properly.
--- Operator redo fix
The operators use the undo system to switch back, but this could give
errors if other actions added undo pushes (buttons, outliner). Now the
redo for operator searches back for the correct undo level.
This fixes issues with many redos.
Note for brecht: removed the ED_undo_push for buttons... it was called
on *every* button now, which is probably too much? For example, using
the 'toolbar' redo also caused this...
2009-07-29 17:56:38 +00:00
|
|
|
static int ed_undo_step(bContext *C, int step, const char *undoname)
|
2008-12-30 19:01:12 +00:00
|
|
|
{
|
2009-01-02 19:10:35 +00:00
|
|
|
Object *obedit= CTX_data_edit_object(C);
|
2009-08-16 01:25:53 +00:00
|
|
|
Object *obact= CTX_data_active_object(C);
|
2008-12-30 19:01:12 +00:00
|
|
|
ScrArea *sa= CTX_wm_area(C);
|
2009-07-08 15:34:41 +00:00
|
|
|
|
2011-11-29 15:26:46 +00:00
|
|
|
/* undo during jobs are running can easily lead to freeing data using by jobs,
|
|
|
|
or they can just lead to freezing job in some other cases */
|
|
|
|
if(WM_jobs_has_running(CTX_wm_manager(C))) {
|
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
}
|
|
|
|
|
2011-09-06 07:59:18 +00:00
|
|
|
/* grease pencil can be can be used in plenty of spaces, so check it first */
|
|
|
|
if(ED_gpencil_session_active()) {
|
|
|
|
return ED_undo_gpencil_step(C, step, undoname);
|
|
|
|
}
|
|
|
|
|
2009-07-08 15:34:41 +00:00
|
|
|
if(sa && sa->spacetype==SPACE_IMAGE) {
|
|
|
|
SpaceImage *sima= (SpaceImage *)sa->spacedata.first;
|
|
|
|
|
2009-08-16 01:25:53 +00:00
|
|
|
if((obact && obact->mode & OB_MODE_TEXTURE_PAINT) || sima->flag & SI_DRAWTOOL) {
|
2010-07-23 14:46:31 +00:00
|
|
|
if(!ED_undo_paint_step(C, UNDO_PAINT_IMAGE, step, undoname) && undoname)
|
|
|
|
if(U.uiflag & USER_GLOBALUNDO)
|
|
|
|
BKE_undo_name(C, undoname);
|
2009-07-08 15:34:41 +00:00
|
|
|
|
|
|
|
WM_event_add_notifier(C, NC_WINDOW, NULL);
|
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2.5: Text Editor back.
There was very little structure in this code, using many globals
and duplicated code. Now it should be better structured. Most
things should work, the main parts that are not back yet are the
python plugins and markers. Notes:
* Blenfont is used for drawing the text, nicely anti-aliased.
* A monospace truetype font was added, since that is needed for
the text editor. It's Bitstream Vera Sans Mono. This is the
default gnome terminal font, but it doesn't fit entirely well
with the other font I think, can be changed easily of course.
* Clipboard copy/cut/paste now always uses the system clipboard,
the code for the own cut buffer was removed.
* The interface buttons should support copy/cut/paste again now
as well.
* WM_clipboard_text_get/WM_clipboard_text_set were added to the
windowmanager code.
* Find panel is now a kind of second header, instead of a panel.
This needs especially a way to start editing the text field
immediately on open still.
* Operators are independent of the actual space when possible,
was a bit of puzzling but got it solved nice with notifiers,
and some lazy init for syntax highlight in the drawing code.
* RNA was created for the text editor space and used for buttons.
* Operators:
* New, Open, Reload, Save, Save As, Make Internal
* Run Script, Refresh Pyconstraints
* Copy, Cut, Paste
* Convert Whitespace, Uncomment, Comment, Indent, Unindent
* Line Break, Insert
* Next Marker, Previous Marker, Clear All Markers, Mark All
* Select Line, Select All
* Jump, Move, Move Select, Delete, Toggle Overwrite
* Scroll, Scroll Bar, Set Cursor, Line Number
* Find and Replace, Find, Replace, Find Set Selected,
Replace Set Selected
* To 3D Object
* Resolve Conflict
2009-02-28 23:33:35 +00:00
|
|
|
if(sa && sa->spacetype==SPACE_TEXT) {
|
|
|
|
ED_text_undo_step(C, step);
|
|
|
|
}
|
|
|
|
else if(obedit) {
|
2.5
Operator goodies!
--- Macro operators
Operators now can consist of multiple operators. Such a macro operator
is identical and behaves identical to other opererators. Macros can
also be constructed of macros even! Currently only hardcoded macros are
implemented, this to solve combined operators such as 'add duplicate' or
'extrude' (both want a transform appended).
Usage is simple:
- WM_operatortype_append_macro() : add new operatortype, name, flags
- WM_operatortype_macro_define() : add existing operator to macro
(Note: macro_define will also allow properties to be set, doesnt work
right now)
On converting the macro wmOperatorType to a real operator, it makes a
list of all operators, and the standard macro callbacks (exec, invoke,
modal, poll) just will use all.
Important note; switching to a modal operator only works as last in the
chain now!
Macros implemented for duplicate, extrude and rip. Tool menu works fine
for it, also the redo hotkey F4 works properly.
--- Operator redo fix
The operators use the undo system to switch back, but this could give
errors if other actions added undo pushes (buttons, outliner). Now the
redo for operator searches back for the correct undo level.
This fixes issues with many redos.
Note for brecht: removed the ED_undo_push for buttons... it was called
on *every* button now, which is probably too much? For example, using
the 'toolbar' redo also caused this...
2009-07-29 17:56:38 +00:00
|
|
|
if ELEM7(obedit->type, OB_MESH, OB_FONT, OB_CURVE, OB_SURF, OB_MBALL, OB_LATTICE, OB_ARMATURE) {
|
|
|
|
if(undoname)
|
|
|
|
undo_editmode_name(C, undoname);
|
|
|
|
else
|
|
|
|
undo_editmode_step(C, step);
|
2010-03-12 12:09:06 +00:00
|
|
|
|
|
|
|
WM_event_add_notifier(C, NC_GEOM|ND_DATA, NULL);
|
2.5
Operator goodies!
--- Macro operators
Operators now can consist of multiple operators. Such a macro operator
is identical and behaves identical to other opererators. Macros can
also be constructed of macros even! Currently only hardcoded macros are
implemented, this to solve combined operators such as 'add duplicate' or
'extrude' (both want a transform appended).
Usage is simple:
- WM_operatortype_append_macro() : add new operatortype, name, flags
- WM_operatortype_macro_define() : add existing operator to macro
(Note: macro_define will also allow properties to be set, doesnt work
right now)
On converting the macro wmOperatorType to a real operator, it makes a
list of all operators, and the standard macro callbacks (exec, invoke,
modal, poll) just will use all.
Important note; switching to a modal operator only works as last in the
chain now!
Macros implemented for duplicate, extrude and rip. Tool menu works fine
for it, also the redo hotkey F4 works properly.
--- Operator redo fix
The operators use the undo system to switch back, but this could give
errors if other actions added undo pushes (buttons, outliner). Now the
redo for operator searches back for the correct undo level.
This fixes issues with many redos.
Note for brecht: removed the ED_undo_push for buttons... it was called
on *every* button now, which is probably too much? For example, using
the 'toolbar' redo also caused this...
2009-07-29 17:56:38 +00:00
|
|
|
}
|
2008-12-30 19:01:12 +00:00
|
|
|
}
|
|
|
|
else {
|
2009-01-01 13:15:35 +00:00
|
|
|
int do_glob_undo= 0;
|
|
|
|
|
2010-07-23 14:46:31 +00:00
|
|
|
if(obact && obact->mode & OB_MODE_TEXTURE_PAINT) {
|
2011-06-14 09:55:38 +00:00
|
|
|
if(!ED_undo_paint_step(C, UNDO_PAINT_IMAGE, step, undoname))
|
2010-07-23 14:46:31 +00:00
|
|
|
do_glob_undo= 1;
|
|
|
|
}
|
|
|
|
else if(obact && obact->mode & OB_MODE_SCULPT) {
|
2011-06-14 09:55:38 +00:00
|
|
|
if(!ED_undo_paint_step(C, UNDO_PAINT_MESH, step, undoname))
|
2010-07-23 14:46:31 +00:00
|
|
|
do_glob_undo= 1;
|
|
|
|
}
|
2009-08-16 02:35:44 +00:00
|
|
|
else if(obact && obact->mode & OB_MODE_PARTICLE_EDIT) {
|
2009-01-01 13:15:35 +00:00
|
|
|
if(step==1)
|
2009-01-24 13:45:24 +00:00
|
|
|
PE_undo(CTX_data_scene(C));
|
2008-12-30 19:01:12 +00:00
|
|
|
else
|
2009-01-24 13:45:24 +00:00
|
|
|
PE_redo(CTX_data_scene(C));
|
2008-12-30 19:01:12 +00:00
|
|
|
}
|
|
|
|
else {
|
2009-01-01 13:15:35 +00:00
|
|
|
do_glob_undo= 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(do_glob_undo) {
|
|
|
|
if(U.uiflag & USER_GLOBALUNDO) {
|
2010-11-29 07:56:45 +00:00
|
|
|
// note python defines not valid here anymore.
|
|
|
|
//#ifdef WITH_PYTHON
|
2009-01-01 13:15:35 +00:00
|
|
|
// XXX BPY_scripts_clear_pyobjects();
|
2010-11-29 07:56:45 +00:00
|
|
|
//#endif
|
2.5
Operator goodies!
--- Macro operators
Operators now can consist of multiple operators. Such a macro operator
is identical and behaves identical to other opererators. Macros can
also be constructed of macros even! Currently only hardcoded macros are
implemented, this to solve combined operators such as 'add duplicate' or
'extrude' (both want a transform appended).
Usage is simple:
- WM_operatortype_append_macro() : add new operatortype, name, flags
- WM_operatortype_macro_define() : add existing operator to macro
(Note: macro_define will also allow properties to be set, doesnt work
right now)
On converting the macro wmOperatorType to a real operator, it makes a
list of all operators, and the standard macro callbacks (exec, invoke,
modal, poll) just will use all.
Important note; switching to a modal operator only works as last in the
chain now!
Macros implemented for duplicate, extrude and rip. Tool menu works fine
for it, also the redo hotkey F4 works properly.
--- Operator redo fix
The operators use the undo system to switch back, but this could give
errors if other actions added undo pushes (buttons, outliner). Now the
redo for operator searches back for the correct undo level.
This fixes issues with many redos.
Note for brecht: removed the ED_undo_push for buttons... it was called
on *every* button now, which is probably too much? For example, using
the 'toolbar' redo also caused this...
2009-07-29 17:56:38 +00:00
|
|
|
if(undoname)
|
|
|
|
BKE_undo_name(C, undoname);
|
|
|
|
else
|
|
|
|
BKE_undo_step(C, step);
|
2010-08-28 07:07:02 +00:00
|
|
|
|
|
|
|
WM_event_add_notifier(C, NC_SCENE|ND_LAYER_CONTENT, CTX_data_scene(C));
|
2009-01-01 13:15:35 +00:00
|
|
|
}
|
|
|
|
|
2008-12-30 19:01:12 +00:00
|
|
|
}
|
|
|
|
}
|
2008-12-31 18:52:15 +00:00
|
|
|
|
|
|
|
WM_event_add_notifier(C, NC_WINDOW, NULL);
|
|
|
|
|
|
|
|
return OPERATOR_FINISHED;
|
2008-12-30 19:01:12 +00:00
|
|
|
}
|
|
|
|
|
2009-02-04 11:52:16 +00:00
|
|
|
void ED_undo_pop(bContext *C)
|
|
|
|
{
|
2.5
Operator goodies!
--- Macro operators
Operators now can consist of multiple operators. Such a macro operator
is identical and behaves identical to other opererators. Macros can
also be constructed of macros even! Currently only hardcoded macros are
implemented, this to solve combined operators such as 'add duplicate' or
'extrude' (both want a transform appended).
Usage is simple:
- WM_operatortype_append_macro() : add new operatortype, name, flags
- WM_operatortype_macro_define() : add existing operator to macro
(Note: macro_define will also allow properties to be set, doesnt work
right now)
On converting the macro wmOperatorType to a real operator, it makes a
list of all operators, and the standard macro callbacks (exec, invoke,
modal, poll) just will use all.
Important note; switching to a modal operator only works as last in the
chain now!
Macros implemented for duplicate, extrude and rip. Tool menu works fine
for it, also the redo hotkey F4 works properly.
--- Operator redo fix
The operators use the undo system to switch back, but this could give
errors if other actions added undo pushes (buttons, outliner). Now the
redo for operator searches back for the correct undo level.
This fixes issues with many redos.
Note for brecht: removed the ED_undo_push for buttons... it was called
on *every* button now, which is probably too much? For example, using
the 'toolbar' redo also caused this...
2009-07-29 17:56:38 +00:00
|
|
|
ed_undo_step(C, 1, NULL);
|
2009-02-04 11:52:16 +00:00
|
|
|
}
|
2009-04-15 17:53:12 +00:00
|
|
|
void ED_undo_redo(bContext *C)
|
|
|
|
{
|
2.5
Operator goodies!
--- Macro operators
Operators now can consist of multiple operators. Such a macro operator
is identical and behaves identical to other opererators. Macros can
also be constructed of macros even! Currently only hardcoded macros are
implemented, this to solve combined operators such as 'add duplicate' or
'extrude' (both want a transform appended).
Usage is simple:
- WM_operatortype_append_macro() : add new operatortype, name, flags
- WM_operatortype_macro_define() : add existing operator to macro
(Note: macro_define will also allow properties to be set, doesnt work
right now)
On converting the macro wmOperatorType to a real operator, it makes a
list of all operators, and the standard macro callbacks (exec, invoke,
modal, poll) just will use all.
Important note; switching to a modal operator only works as last in the
chain now!
Macros implemented for duplicate, extrude and rip. Tool menu works fine
for it, also the redo hotkey F4 works properly.
--- Operator redo fix
The operators use the undo system to switch back, but this could give
errors if other actions added undo pushes (buttons, outliner). Now the
redo for operator searches back for the correct undo level.
This fixes issues with many redos.
Note for brecht: removed the ED_undo_push for buttons... it was called
on *every* button now, which is probably too much? For example, using
the 'toolbar' redo also caused this...
2009-07-29 17:56:38 +00:00
|
|
|
ed_undo_step(C, -1, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ED_undo_push_op(bContext *C, wmOperator *op)
|
|
|
|
{
|
|
|
|
/* in future, get undo string info? */
|
|
|
|
ED_undo_push(C, op->type->name);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ED_undo_pop_op(bContext *C, wmOperator *op)
|
|
|
|
{
|
|
|
|
/* search back a couple of undo's, in case something else added pushes */
|
|
|
|
ed_undo_step(C, 0, op->type->name);
|
2009-04-15 17:53:12 +00:00
|
|
|
}
|
2009-02-04 11:52:16 +00:00
|
|
|
|
2011-01-12 18:00:23 +00:00
|
|
|
/* name optionally, function used to check for operator redo panel */
|
|
|
|
int ED_undo_valid(const bContext *C, 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((obact && obact->mode & OB_MODE_TEXTURE_PAINT) || sima->flag & SI_DRAWTOOL) {
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(sa && sa->spacetype==SPACE_TEXT) {
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
else if(obedit) {
|
|
|
|
if ELEM7(obedit->type, OB_MESH, OB_FONT, OB_CURVE, OB_SURF, OB_MBALL, OB_LATTICE, OB_ARMATURE) {
|
|
|
|
return undo_editmode_valid(undoname);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
|
|
|
|
/* if below tests fail, global undo gets executed */
|
|
|
|
|
|
|
|
if(obact && obact->mode & OB_MODE_TEXTURE_PAINT) {
|
|
|
|
if( ED_undo_paint_valid(UNDO_PAINT_IMAGE, undoname) )
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
else if(obact && obact->mode & OB_MODE_SCULPT) {
|
|
|
|
if( ED_undo_paint_valid(UNDO_PAINT_MESH, undoname) )
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
else if(obact && obact->mode & OB_MODE_PARTICLE_EDIT) {
|
|
|
|
return PE_undo_valid(CTX_data_scene(C));
|
|
|
|
}
|
|
|
|
|
|
|
|
if(U.uiflag & USER_GLOBALUNDO) {
|
|
|
|
return BKE_undo_valid(undoname);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2010-10-15 01:36:14 +00:00
|
|
|
static int ed_undo_exec(bContext *C, wmOperator *UNUSED(op))
|
2009-01-01 13:15:35 +00:00
|
|
|
{
|
2009-06-26 15:48:09 +00:00
|
|
|
/* "last operator" should disappear, later we can tie ths with undo stack nicer */
|
2011-05-18 10:56:26 +00:00
|
|
|
WM_operator_stack_clear(CTX_wm_manager(C));
|
2.5
Operator goodies!
--- Macro operators
Operators now can consist of multiple operators. Such a macro operator
is identical and behaves identical to other opererators. Macros can
also be constructed of macros even! Currently only hardcoded macros are
implemented, this to solve combined operators such as 'add duplicate' or
'extrude' (both want a transform appended).
Usage is simple:
- WM_operatortype_append_macro() : add new operatortype, name, flags
- WM_operatortype_macro_define() : add existing operator to macro
(Note: macro_define will also allow properties to be set, doesnt work
right now)
On converting the macro wmOperatorType to a real operator, it makes a
list of all operators, and the standard macro callbacks (exec, invoke,
modal, poll) just will use all.
Important note; switching to a modal operator only works as last in the
chain now!
Macros implemented for duplicate, extrude and rip. Tool menu works fine
for it, also the redo hotkey F4 works properly.
--- Operator redo fix
The operators use the undo system to switch back, but this could give
errors if other actions added undo pushes (buttons, outliner). Now the
redo for operator searches back for the correct undo level.
This fixes issues with many redos.
Note for brecht: removed the ED_undo_push for buttons... it was called
on *every* button now, which is probably too much? For example, using
the 'toolbar' redo also caused this...
2009-07-29 17:56:38 +00:00
|
|
|
return ed_undo_step(C, 1, NULL);
|
2009-01-01 13:15:35 +00:00
|
|
|
}
|
2.5
Operator goodies!
--- Macro operators
Operators now can consist of multiple operators. Such a macro operator
is identical and behaves identical to other opererators. Macros can
also be constructed of macros even! Currently only hardcoded macros are
implemented, this to solve combined operators such as 'add duplicate' or
'extrude' (both want a transform appended).
Usage is simple:
- WM_operatortype_append_macro() : add new operatortype, name, flags
- WM_operatortype_macro_define() : add existing operator to macro
(Note: macro_define will also allow properties to be set, doesnt work
right now)
On converting the macro wmOperatorType to a real operator, it makes a
list of all operators, and the standard macro callbacks (exec, invoke,
modal, poll) just will use all.
Important note; switching to a modal operator only works as last in the
chain now!
Macros implemented for duplicate, extrude and rip. Tool menu works fine
for it, also the redo hotkey F4 works properly.
--- Operator redo fix
The operators use the undo system to switch back, but this could give
errors if other actions added undo pushes (buttons, outliner). Now the
redo for operator searches back for the correct undo level.
This fixes issues with many redos.
Note for brecht: removed the ED_undo_push for buttons... it was called
on *every* button now, which is probably too much? For example, using
the 'toolbar' redo also caused this...
2009-07-29 17:56:38 +00:00
|
|
|
|
2011-02-22 02:42:19 +00:00
|
|
|
static int ed_undo_push_exec(bContext *C, wmOperator *op)
|
|
|
|
{
|
|
|
|
char str[MAXUNDONAME];
|
|
|
|
RNA_string_get(op->ptr, "message", str);
|
|
|
|
ED_undo_push(C, str);
|
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
}
|
|
|
|
|
2010-10-15 01:36:14 +00:00
|
|
|
static int ed_redo_exec(bContext *C, wmOperator *UNUSED(op))
|
2008-12-30 19:01:12 +00:00
|
|
|
{
|
2.5
Operator goodies!
--- Macro operators
Operators now can consist of multiple operators. Such a macro operator
is identical and behaves identical to other opererators. Macros can
also be constructed of macros even! Currently only hardcoded macros are
implemented, this to solve combined operators such as 'add duplicate' or
'extrude' (both want a transform appended).
Usage is simple:
- WM_operatortype_append_macro() : add new operatortype, name, flags
- WM_operatortype_macro_define() : add existing operator to macro
(Note: macro_define will also allow properties to be set, doesnt work
right now)
On converting the macro wmOperatorType to a real operator, it makes a
list of all operators, and the standard macro callbacks (exec, invoke,
modal, poll) just will use all.
Important note; switching to a modal operator only works as last in the
chain now!
Macros implemented for duplicate, extrude and rip. Tool menu works fine
for it, also the redo hotkey F4 works properly.
--- Operator redo fix
The operators use the undo system to switch back, but this could give
errors if other actions added undo pushes (buttons, outliner). Now the
redo for operator searches back for the correct undo level.
This fixes issues with many redos.
Note for brecht: removed the ED_undo_push for buttons... it was called
on *every* button now, which is probably too much? For example, using
the 'toolbar' redo also caused this...
2009-07-29 17:56:38 +00:00
|
|
|
return ed_undo_step(C, -1, NULL);
|
2008-12-30 19:01:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-12-31 18:52:15 +00:00
|
|
|
/* ********************** */
|
|
|
|
|
|
|
|
void ED_OT_undo(wmOperatorType *ot)
|
|
|
|
{
|
|
|
|
/* identifiers */
|
|
|
|
ot->name= "Undo";
|
2010-03-22 09:30:00 +00:00
|
|
|
ot->description= "Undo previous action";
|
2008-12-31 18:52:15 +00:00
|
|
|
ot->idname= "ED_OT_undo";
|
|
|
|
|
|
|
|
/* api callbacks */
|
|
|
|
ot->exec= ed_undo_exec;
|
|
|
|
ot->poll= ED_operator_screenactive;
|
|
|
|
}
|
|
|
|
|
2011-02-22 02:42:19 +00:00
|
|
|
void ED_OT_undo_push(wmOperatorType *ot)
|
|
|
|
{
|
|
|
|
/* identifiers */
|
|
|
|
ot->name= "Undo Push";
|
|
|
|
ot->description= "Add an undo state (internal use only)";
|
|
|
|
ot->idname= "ED_OT_undo_push";
|
|
|
|
|
|
|
|
/* api callbacks */
|
|
|
|
ot->exec= ed_undo_push_exec;
|
|
|
|
|
2011-06-06 11:56:54 +00:00
|
|
|
ot->flag= OPTYPE_INTERNAL;
|
|
|
|
|
2011-02-22 02:42:19 +00:00
|
|
|
RNA_def_string(ot->srna, "message", "Add an undo step *function may be moved*", MAXUNDONAME, "Undo Message", "");
|
|
|
|
}
|
|
|
|
|
2008-12-31 18:52:15 +00:00
|
|
|
void ED_OT_redo(wmOperatorType *ot)
|
|
|
|
{
|
|
|
|
/* identifiers */
|
|
|
|
ot->name= "Redo";
|
2010-03-22 09:30:00 +00:00
|
|
|
ot->description= "Redo previous action";
|
2008-12-31 18:52:15 +00:00
|
|
|
ot->idname= "ED_OT_redo";
|
|
|
|
|
|
|
|
/* api callbacks */
|
|
|
|
ot->exec= ed_redo_exec;
|
|
|
|
ot->poll= ED_operator_screenactive;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-05-28 13:11:24 +00:00
|
|
|
/* ui callbacks should call this rather than calling WM_operator_repeat() themselves */
|
2010-12-15 04:06:19 +00:00
|
|
|
int ED_undo_operator_repeat(bContext *C, struct wmOperator *op)
|
|
|
|
{
|
|
|
|
int ret= 0;
|
|
|
|
|
|
|
|
if(op) {
|
|
|
|
ARegion *ar= CTX_wm_region(C);
|
|
|
|
ARegion *ar1= BKE_area_find_region_type(CTX_wm_area(C), RGN_TYPE_WINDOW);
|
|
|
|
|
|
|
|
if(ar1)
|
|
|
|
CTX_wm_region_set(C, ar1);
|
|
|
|
|
|
|
|
if(WM_operator_repeat_check(C, op) && WM_operator_poll(C, op->type)) {
|
|
|
|
int retval;
|
|
|
|
|
|
|
|
if (G.f & G_DEBUG)
|
|
|
|
printf("redo_cb: operator redo %s\n", op->type->name);
|
|
|
|
ED_undo_pop_op(C, op);
|
2011-03-16 12:21:20 +00:00
|
|
|
|
|
|
|
if(op->type->check) {
|
|
|
|
op->type->check(C, op); /* ignore return value since its running again anyway */
|
|
|
|
}
|
|
|
|
|
2010-12-15 04:06:19 +00:00
|
|
|
retval= WM_operator_repeat(C, op);
|
|
|
|
if((retval & OPERATOR_FINISHED)==0) {
|
|
|
|
if (G.f & G_DEBUG)
|
|
|
|
printf("redo_cb: operator redo failed: %s, return %d\n", op->type->name, retval);
|
|
|
|
ED_undo_redo(C);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
ret= 1;
|
|
|
|
}
|
|
|
|
}
|
2011-07-26 13:05:22 +00:00
|
|
|
else {
|
|
|
|
if (G.f & G_DEBUG) {
|
|
|
|
printf("redo_cb: WM_operator_repeat_check returned false %s\n", op->type->name);
|
|
|
|
}
|
|
|
|
}
|
2010-12-15 04:06:19 +00:00
|
|
|
|
|
|
|
/* set region back */
|
|
|
|
CTX_wm_region_set(C, ar);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
if (G.f & G_DEBUG) {
|
2011-07-26 13:05:22 +00:00
|
|
|
printf("redo_cb: ED_undo_operator_repeat called with NULL 'op'\n");
|
2010-12-15 04:06:19 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2011-07-26 13:05:22 +00:00
|
|
|
|
2010-12-15 04:06:19 +00:00
|
|
|
void ED_undo_operator_repeat_cb(bContext *C, void *arg_op, void *UNUSED(arg_unused))
|
|
|
|
{
|
|
|
|
ED_undo_operator_repeat(C, (wmOperator *)arg_op);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ED_undo_operator_repeat_cb_evt(bContext *C, void *arg_op, int UNUSED(arg_event))
|
|
|
|
{
|
|
|
|
ED_undo_operator_repeat(C, (wmOperator *)arg_op);
|
|
|
|
}
|
Code holiday commit:
- fix: user pref, window title was reset to 'Blender' on tab usage
- Undo history menu back:
- name "Undo History"
- hotkey alt+ctrl+z (alt+apple+z for mac)
- works like 2.4x, only for global undo, editmode and particle edit.
- Menu scroll
- for small windows or screens, popup menus now allow to display
all items, using internal scrolling
- works with a timer, scrolling 10 items per second when mouse
is over the top or bottom arrow
- if menu is too big to display, it now draws to top or bottom,
based on largest available space.
- also works for hotkey driven pop up menus.
- User pref "DPI" follows widget/layout size
- widgets & headers now become bigger and smaller, to match
'dpi' font sizes. Works well to match UI to monitor size.
- note that icons can get fuzzy, we need better mipmaps for it
2011-06-04 17:03:46 +00:00
|
|
|
|
|
|
|
|
|
|
|
/* ************************** */
|
|
|
|
|
|
|
|
#define UNDOSYSTEM_GLOBAL 1
|
|
|
|
#define UNDOSYSTEM_EDITMODE 2
|
|
|
|
#define UNDOSYSTEM_PARTICLE 3
|
|
|
|
|
|
|
|
static int get_undo_system(bContext *C)
|
|
|
|
{
|
|
|
|
Object *obedit= CTX_data_edit_object(C);
|
|
|
|
|
|
|
|
/* find out which undo system */
|
|
|
|
if(obedit) {
|
|
|
|
if (ELEM7(obedit->type, OB_MESH, OB_FONT, OB_CURVE, OB_SURF, OB_MBALL, OB_LATTICE, OB_ARMATURE))
|
|
|
|
return UNDOSYSTEM_EDITMODE;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
Object *obact= CTX_data_active_object(C);
|
|
|
|
|
|
|
|
if(obact && obact->mode & OB_MODE_PARTICLE_EDIT)
|
|
|
|
return UNDOSYSTEM_PARTICLE;
|
|
|
|
else if(U.uiflag & USER_GLOBALUNDO)
|
|
|
|
return UNDOSYSTEM_GLOBAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* create enum based on undo items */
|
|
|
|
static EnumPropertyItem *rna_undo_itemf(bContext *C, int undosys, int *totitem)
|
|
|
|
{
|
|
|
|
EnumPropertyItem item_tmp= {0}, *item= NULL;
|
|
|
|
int active, i= 0;
|
|
|
|
|
|
|
|
while(TRUE) {
|
2011-11-05 11:04:28 +00:00
|
|
|
const char *name= NULL;
|
Code holiday commit:
- fix: user pref, window title was reset to 'Blender' on tab usage
- Undo history menu back:
- name "Undo History"
- hotkey alt+ctrl+z (alt+apple+z for mac)
- works like 2.4x, only for global undo, editmode and particle edit.
- Menu scroll
- for small windows or screens, popup menus now allow to display
all items, using internal scrolling
- works with a timer, scrolling 10 items per second when mouse
is over the top or bottom arrow
- if menu is too big to display, it now draws to top or bottom,
based on largest available space.
- also works for hotkey driven pop up menus.
- User pref "DPI" follows widget/layout size
- widgets & headers now become bigger and smaller, to match
'dpi' font sizes. Works well to match UI to monitor size.
- note that icons can get fuzzy, we need better mipmaps for it
2011-06-04 17:03:46 +00:00
|
|
|
|
|
|
|
if(undosys==UNDOSYSTEM_PARTICLE) {
|
|
|
|
name= PE_undo_get_name(CTX_data_scene(C), i, &active);
|
|
|
|
}
|
|
|
|
else if(undosys==UNDOSYSTEM_EDITMODE) {
|
|
|
|
name= undo_editmode_get_name(C, i, &active);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
name= BKE_undo_get_name(i, &active);
|
|
|
|
}
|
|
|
|
|
|
|
|
if(name) {
|
|
|
|
item_tmp.identifier= item_tmp.name= name;
|
|
|
|
if(active)
|
|
|
|
item_tmp.icon= ICON_RESTRICT_VIEW_OFF;
|
|
|
|
else
|
|
|
|
item_tmp.icon= ICON_NONE;
|
|
|
|
item_tmp.value= i++;
|
|
|
|
RNA_enum_item_add(&item, totitem, &item_tmp);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
RNA_enum_item_end(&item, totitem);
|
|
|
|
|
|
|
|
return item;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int undo_history_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event))
|
|
|
|
{
|
|
|
|
int undosys, totitem= 0;
|
|
|
|
|
|
|
|
undosys= get_undo_system(C);
|
|
|
|
|
|
|
|
if(undosys) {
|
|
|
|
EnumPropertyItem *item= rna_undo_itemf(C, undosys, &totitem);
|
|
|
|
|
|
|
|
if(totitem > 0) {
|
|
|
|
uiPopupMenu *pup= uiPupMenuBegin(C, op->type->name, ICON_NONE);
|
|
|
|
uiLayout *layout= uiPupMenuLayout(pup);
|
2011-09-26 13:24:42 +00:00
|
|
|
uiLayout *split= uiLayoutSplit(layout, 0, 0), *column = NULL;
|
Code holiday commit:
- fix: user pref, window title was reset to 'Blender' on tab usage
- Undo history menu back:
- name "Undo History"
- hotkey alt+ctrl+z (alt+apple+z for mac)
- works like 2.4x, only for global undo, editmode and particle edit.
- Menu scroll
- for small windows or screens, popup menus now allow to display
all items, using internal scrolling
- works with a timer, scrolling 10 items per second when mouse
is over the top or bottom arrow
- if menu is too big to display, it now draws to top or bottom,
based on largest available space.
- also works for hotkey driven pop up menus.
- User pref "DPI" follows widget/layout size
- widgets & headers now become bigger and smaller, to match
'dpi' font sizes. Works well to match UI to monitor size.
- note that icons can get fuzzy, we need better mipmaps for it
2011-06-04 17:03:46 +00:00
|
|
|
int i, c;
|
|
|
|
|
|
|
|
for(c=0, i=totitem-1; i >= 0; i--, c++) {
|
|
|
|
if( (c % 20)==0 )
|
|
|
|
column= uiLayoutColumn(split, 0);
|
|
|
|
if(item[i].identifier)
|
|
|
|
uiItemIntO(column, item[i].name, item[i].icon, op->type->idname, "item", item[i].value);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
MEM_freeN(item);
|
|
|
|
|
|
|
|
uiPupMenuEnd(C, pup);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* note: also check ed_undo_step() in top if you change notifiers */
|
|
|
|
static int undo_history_exec(bContext *C, wmOperator *op)
|
|
|
|
{
|
|
|
|
if(RNA_property_is_set(op->ptr, "item")) {
|
|
|
|
int undosys= get_undo_system(C);
|
|
|
|
int item= RNA_int_get(op->ptr, "item");
|
|
|
|
|
|
|
|
if(undosys==UNDOSYSTEM_PARTICLE) {
|
|
|
|
PE_undo_number(CTX_data_scene(C), item);
|
|
|
|
}
|
|
|
|
else if(undosys==UNDOSYSTEM_EDITMODE) {
|
|
|
|
undo_editmode_number(C, item+1);
|
|
|
|
WM_event_add_notifier(C, NC_GEOM|ND_DATA, NULL);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
BKE_undo_number(C, item);
|
|
|
|
WM_event_add_notifier(C, NC_SCENE|ND_LAYER_CONTENT, CTX_data_scene(C));
|
|
|
|
}
|
|
|
|
WM_event_add_notifier(C, NC_WINDOW, NULL);
|
|
|
|
|
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
}
|
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ED_OT_undo_history(wmOperatorType *ot)
|
|
|
|
{
|
|
|
|
/* identifiers */
|
|
|
|
ot->name= "Undo History";
|
|
|
|
ot->description= "Redo specific action in history";
|
|
|
|
ot->idname= "ED_OT_undo_history";
|
|
|
|
|
|
|
|
/* api callbacks */
|
|
|
|
ot->invoke= undo_history_invoke;
|
|
|
|
ot->exec= undo_history_exec;
|
|
|
|
ot->poll= ED_operator_screenactive;
|
|
|
|
|
|
|
|
RNA_def_int(ot->srna, "item", 0, 0, INT_MAX, "Item", "", 0, INT_MAX);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|