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
|
2018-04-02 15:02:08 +02:00
|
|
|
* \ingroup edundo
|
2011-02-27 20:29:51 +00:00
|
|
|
*/
|
|
|
|
|
|
2008-12-30 19:01:12 +00:00
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
|
|
#include "MEM_guardedalloc.h"
|
|
|
|
|
|
2013-06-25 09:27:31 +00:00
|
|
|
#include "DNA_scene_types.h"
|
2008-12-30 19:01:12 +00:00
|
|
|
|
2011-01-07 18:36:47 +00:00
|
|
|
#include "BLI_utildefines.h"
|
2008-12-30 19:01:12 +00:00
|
|
|
|
2015-08-16 17:32:01 +10:00
|
|
|
#include "BLT_translation.h"
|
2012-04-13 19:59:29 +00:00
|
|
|
|
2016-04-24 22:42:41 +10:00
|
|
|
#include "BKE_blender_undo.h"
|
2011-01-07 18:36:47 +00:00
|
|
|
#include "BKE_context.h"
|
|
|
|
|
#include "BKE_global.h"
|
2018-04-03 08:35:42 +02:00
|
|
|
#include "BKE_main.h"
|
2011-01-07 18:36:47 +00:00
|
|
|
#include "BKE_screen.h"
|
2018-03-19 14:17:59 +01:00
|
|
|
#include "BKE_undo_system.h"
|
2008-12-30 19:01:12 +00:00
|
|
|
|
2011-09-06 07:59:18 +00:00
|
|
|
#include "ED_gpencil.h"
|
2013-07-08 22:26:10 +00:00
|
|
|
#include "ED_render.h"
|
2008-12-31 18:52:15 +00:00
|
|
|
#include "ED_screen.h"
|
2018-04-02 15:02:08 +02:00
|
|
|
#include "ED_undo.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"
|
|
|
|
|
|
2018-04-02 15:02:08 +02:00
|
|
|
/* -------------------------------------------------------------------- */
|
|
|
|
|
/** \name Generic Undo System Access
|
|
|
|
|
*
|
|
|
|
|
* Non-operator undo editor functions.
|
|
|
|
|
* \{ */
|
2008-12-30 19:01:12 +00:00
|
|
|
|
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
|
|
|
{
|
2018-03-19 14:17:59 +01:00
|
|
|
if (G.debug & G_DEBUG) {
|
2013-02-25 21:13:40 +00:00
|
|
|
printf("%s: %s\n", __func__, str);
|
2008-12-30 19:01:12 +00:00
|
|
|
}
|
2018-03-19 14:17:59 +01:00
|
|
|
const int steps = U.undosteps;
|
2014-03-13 22:35:26 +02:00
|
|
|
|
2018-03-19 14:17:59 +01:00
|
|
|
if (steps <= 0) {
|
|
|
|
|
return;
|
2008-12-30 19:01:12 +00:00
|
|
|
}
|
2018-03-19 14:17:59 +01:00
|
|
|
|
|
|
|
|
wmWindowManager *wm = CTX_wm_manager(C);
|
|
|
|
|
|
|
|
|
|
/* Only apply limit if this is the last undo step. */
|
|
|
|
|
if (wm->undo_stack->step_active && (wm->undo_stack->step_active->next == NULL)) {
|
|
|
|
|
BKE_undosys_stack_limit_steps_and_memory(wm->undo_stack, steps - 1, 0);
|
2014-05-14 01:09:09 +03:00
|
|
|
}
|
2018-03-19 14:17:59 +01:00
|
|
|
|
|
|
|
|
BKE_undosys_step_push(wm->undo_stack, C, str);
|
|
|
|
|
|
|
|
|
|
if (U.undomemory != 0) {
|
|
|
|
|
const size_t memory_limit = (size_t)U.undomemory * 1024 * 1024;
|
|
|
|
|
BKE_undosys_stack_limit_steps_and_memory(wm->undo_stack, 0, memory_limit);
|
2008-12-30 19:01:12 +00:00
|
|
|
}
|
2014-03-13 22:35:26 +02:00
|
|
|
|
2018-02-19 12:20:18 +11:00
|
|
|
WM_file_tag_modified();
|
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)
|
2014-02-15 13:28:26 +11:00
|
|
|
{
|
|
|
|
|
wmWindowManager *wm = CTX_wm_manager(C);
|
|
|
|
|
wmWindow *win = CTX_wm_window(C);
|
2018-03-19 14:17:59 +01:00
|
|
|
// Main *bmain = CTX_data_main(C);
|
2014-02-15 13:28:26 +11:00
|
|
|
Scene *scene = CTX_data_scene(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,
|
2011-12-11 19:23:02 +00:00
|
|
|
* or they can just lead to freezing job in some other cases */
|
2014-02-15 13:28:26 +11:00
|
|
|
if (WM_jobs_test(wm, scene, WM_JOB_TYPE_ANY)) {
|
2011-11-29 15:26:46 +00:00
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
|
}
|
|
|
|
|
|
2018-03-19 14:17:59 +01:00
|
|
|
/* TODO(campbell): undo_system: use undo system */
|
2011-09-06 07:59:18 +00:00
|
|
|
/* grease pencil can be can be used in plenty of spaces, so check it first */
|
2012-03-24 06:38:07 +00:00
|
|
|
if (ED_gpencil_session_active()) {
|
2011-09-06 07:59:18 +00:00
|
|
|
return ED_undo_gpencil_step(C, step, undoname);
|
|
|
|
|
}
|
|
|
|
|
|
2018-03-19 14:17:59 +01:00
|
|
|
/* Undo System */
|
|
|
|
|
{
|
|
|
|
|
if (undoname) {
|
|
|
|
|
UndoStep *step_data = BKE_undosys_step_find_by_name(wm->undo_stack, undoname);
|
|
|
|
|
BKE_undosys_step_undo_with_data(wm->undo_stack, C, step_data);
|
2009-07-08 15:34:41 +00:00
|
|
|
}
|
2018-03-19 14:17:59 +01:00
|
|
|
else {
|
|
|
|
|
BKE_undosys_step_undo_compat_only(wm->undo_stack, C, step);
|
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
|
|
|
}
|
2014-02-15 13:28:26 +11:00
|
|
|
|
2008-12-31 18:52:15 +00:00
|
|
|
WM_event_add_notifier(C, NC_WINDOW, NULL);
|
2014-09-16 14:28:58 +06:00
|
|
|
WM_event_add_notifier(C, NC_WM | ND_UNDO, NULL);
|
2014-02-15 13:28:26 +11:00
|
|
|
|
|
|
|
|
if (win) {
|
|
|
|
|
win->addmousemove = true;
|
|
|
|
|
}
|
2018-03-19 14:17:59 +01:00
|
|
|
|
2008-12-31 18:52:15 +00:00
|
|
|
return OPERATOR_FINISHED;
|
2008-12-30 19:01:12 +00:00
|
|
|
}
|
|
|
|
|
|
Implement grouped undo option for operators
This option makes an operator to not push a task to the undo stack if the previous stored elemen is the same operator or part of the same undo group.
The main usage is for animation, so you can change frames to inspect the
poses, and revert the previous pose without having to roll back tons of
"change frame" operator, or even see the undo stack full.
This complements rB13ee9b8e
Design with help by Sergey Sharybin.
Reviewers: sergey, mont29
Reviewed By: mont29, sergey
Subscribers: pyc0d3r, hjalti, Severin, lowercase, brecht, monio, aligorith, hadrien, jbakker
Differential Revision: https://developer.blender.org/D2330
2016-11-15 11:50:11 +01:00
|
|
|
void ED_undo_grouped_push(bContext *C, const char *str)
|
|
|
|
|
{
|
|
|
|
|
/* do nothing if previous undo task is the same as this one (or from the same undo group) */
|
2018-03-19 14:17:59 +01:00
|
|
|
{
|
|
|
|
|
wmWindowManager *wm = CTX_wm_manager(C);
|
|
|
|
|
if (wm->undo_stack->steps.last) {
|
|
|
|
|
const UndoStep *us = wm->undo_stack->steps.last;
|
|
|
|
|
if (STREQ(str, us->name)) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
Implement grouped undo option for operators
This option makes an operator to not push a task to the undo stack if the previous stored elemen is the same operator or part of the same undo group.
The main usage is for animation, so you can change frames to inspect the
poses, and revert the previous pose without having to roll back tons of
"change frame" operator, or even see the undo stack full.
This complements rB13ee9b8e
Design with help by Sergey Sharybin.
Reviewers: sergey, mont29
Reviewed By: mont29, sergey
Subscribers: pyc0d3r, hjalti, Severin, lowercase, brecht, monio, aligorith, hadrien, jbakker
Differential Revision: https://developer.blender.org/D2330
2016-11-15 11:50:11 +01:00
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* push as usual */
|
|
|
|
|
ED_undo_push(C, str);
|
|
|
|
|
}
|
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
|
Implement grouped undo option for operators
This option makes an operator to not push a task to the undo stack if the previous stored elemen is the same operator or part of the same undo group.
The main usage is for animation, so you can change frames to inspect the
poses, and revert the previous pose without having to roll back tons of
"change frame" operator, or even see the undo stack full.
This complements rB13ee9b8e
Design with help by Sergey Sharybin.
Reviewers: sergey, mont29
Reviewed By: mont29, sergey
Subscribers: pyc0d3r, hjalti, Severin, lowercase, brecht, monio, aligorith, hadrien, jbakker
Differential Revision: https://developer.blender.org/D2330
2016-11-15 11:50:11 +01:00
|
|
|
void ED_undo_grouped_push_op(bContext *C, wmOperator *op)
|
|
|
|
|
{
|
|
|
|
|
if (op->type->undo_group[0] != '\0') {
|
|
|
|
|
ED_undo_grouped_push(C, op->type->undo_group);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
ED_undo_grouped_push(C, op->type->name);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
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 */
|
2015-04-18 15:41:12 +02:00
|
|
|
bool ED_undo_is_valid(const bContext *C, const char *undoname)
|
2011-01-12 18:00:23 +00:00
|
|
|
{
|
2018-03-19 14:17:59 +01:00
|
|
|
wmWindowManager *wm = CTX_wm_manager(C);
|
|
|
|
|
return BKE_undosys_stack_has_undo(wm->undo_stack, undoname);
|
2011-01-12 18:00:23 +00:00
|
|
|
}
|
|
|
|
|
|
2018-04-03 08:35:42 +02:00
|
|
|
/**
|
|
|
|
|
* Ideally we wont access the stack directly,
|
|
|
|
|
* this is needed for modes which handle undo themselves (bypassing #ED_undo_push).
|
|
|
|
|
*
|
|
|
|
|
* Using global isn't great, this just avoids doing inline,
|
|
|
|
|
* causing 'BKE_global.h' & 'BKE_main.h' includes.
|
|
|
|
|
*/
|
|
|
|
|
UndoStack *ED_undo_stack_get(void)
|
|
|
|
|
{
|
|
|
|
|
wmWindowManager *wm = G.main->wm.first;
|
|
|
|
|
return wm->undo_stack;
|
|
|
|
|
}
|
|
|
|
|
|
2018-04-02 15:02:08 +02:00
|
|
|
/** \} */
|
|
|
|
|
|
|
|
|
|
/* -------------------------------------------------------------------- */
|
|
|
|
|
/** \name Undo, Undo Push & Redo Operators
|
|
|
|
|
* \{ */
|
|
|
|
|
|
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
|
|
|
{
|
2012-06-01 11:46:25 +00:00
|
|
|
/* "last operator" should disappear, later we can tie this 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)
|
|
|
|
|
{
|
2012-09-10 01:55:58 +00:00
|
|
|
char str[BKE_UNDO_STR_MAX];
|
2011-02-22 02:42:19 +00:00
|
|
|
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
|
|
|
}
|
|
|
|
|
|
2016-12-29 12:38:20 +01:00
|
|
|
static int ed_undo_redo_exec(bContext *C, wmOperator *UNUSED(op))
|
|
|
|
|
{
|
|
|
|
|
wmOperator *last_op = WM_operator_last_redo(C);
|
|
|
|
|
const int ret = ED_undo_operator_repeat(C, last_op);
|
|
|
|
|
return ret ? OPERATOR_FINISHED : OPERATOR_CANCELLED;
|
|
|
|
|
}
|
|
|
|
|
|
2017-07-01 10:50:29 +03:00
|
|
|
static int ed_undo_redo_poll(bContext *C)
|
|
|
|
|
{
|
|
|
|
|
wmOperator *last_op = WM_operator_last_redo(C);
|
2018-04-02 15:02:08 +02:00
|
|
|
return last_op && ED_operator_screenactive(C) &&
|
2017-07-01 10:50:29 +03:00
|
|
|
WM_operator_check_ui_enabled(C, last_op->type->name);
|
|
|
|
|
}
|
2008-12-30 19:01:12 +00:00
|
|
|
|
2008-12-31 18:52:15 +00:00
|
|
|
void ED_OT_undo(wmOperatorType *ot)
|
|
|
|
|
{
|
|
|
|
|
/* identifiers */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->name = "Undo";
|
|
|
|
|
ot->description = "Undo previous action";
|
|
|
|
|
ot->idname = "ED_OT_undo";
|
2018-04-02 15:02:08 +02:00
|
|
|
|
2008-12-31 18:52:15 +00:00
|
|
|
/* api callbacks */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->exec = ed_undo_exec;
|
|
|
|
|
ot->poll = ED_operator_screenactive;
|
2008-12-31 18:52:15 +00:00
|
|
|
}
|
|
|
|
|
|
2011-02-22 02:42:19 +00:00
|
|
|
void ED_OT_undo_push(wmOperatorType *ot)
|
|
|
|
|
{
|
|
|
|
|
/* identifiers */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->name = "Undo Push";
|
|
|
|
|
ot->description = "Add an undo state (internal use only)";
|
|
|
|
|
ot->idname = "ED_OT_undo_push";
|
2018-04-02 15:02:08 +02:00
|
|
|
|
2011-02-22 02:42:19 +00:00
|
|
|
/* api callbacks */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->exec = ed_undo_push_exec;
|
2011-02-22 02:42:19 +00:00
|
|
|
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->flag = OPTYPE_INTERNAL;
|
2011-06-06 11:56:54 +00:00
|
|
|
|
2012-09-10 01:55:58 +00:00
|
|
|
RNA_def_string(ot->srna, "message", "Add an undo step *function may be moved*", BKE_UNDO_STR_MAX, "Undo Message", "");
|
2011-02-22 02:42:19 +00:00
|
|
|
}
|
|
|
|
|
|
2008-12-31 18:52:15 +00:00
|
|
|
void ED_OT_redo(wmOperatorType *ot)
|
|
|
|
|
{
|
|
|
|
|
/* identifiers */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->name = "Redo";
|
|
|
|
|
ot->description = "Redo previous action";
|
|
|
|
|
ot->idname = "ED_OT_redo";
|
2018-04-02 15:02:08 +02:00
|
|
|
|
2008-12-31 18:52:15 +00:00
|
|
|
/* api callbacks */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->exec = ed_redo_exec;
|
|
|
|
|
ot->poll = ED_operator_screenactive;
|
2008-12-31 18:52:15 +00:00
|
|
|
}
|
|
|
|
|
|
2016-12-29 12:38:20 +01:00
|
|
|
void ED_OT_undo_redo(wmOperatorType *ot)
|
|
|
|
|
{
|
|
|
|
|
/* identifiers */
|
|
|
|
|
ot->name = "Undo and Redo";
|
|
|
|
|
ot->description = "Undo and redo previous action";
|
|
|
|
|
ot->idname = "ED_OT_undo_redo";
|
2018-04-02 15:02:08 +02:00
|
|
|
|
2016-12-29 12:38:20 +01:00
|
|
|
/* api callbacks */
|
|
|
|
|
ot->exec = ed_undo_redo_exec;
|
2017-07-01 10:50:29 +03:00
|
|
|
ot->poll = ed_undo_redo_poll;
|
2016-12-29 12:38:20 +01:00
|
|
|
}
|
2008-12-31 18:52:15 +00:00
|
|
|
|
2018-04-02 15:02:08 +02:00
|
|
|
/** \} */
|
|
|
|
|
|
|
|
|
|
/* -------------------------------------------------------------------- */
|
|
|
|
|
/** \name Operator Repeat
|
|
|
|
|
* \{ */
|
|
|
|
|
|
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)
|
|
|
|
|
{
|
2012-03-30 10:00:20 +00:00
|
|
|
int ret = 0;
|
2010-12-15 04:06:19 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (op) {
|
2012-03-30 10:00:20 +00:00
|
|
|
wmWindowManager *wm = CTX_wm_manager(C);
|
|
|
|
|
struct Scene *scene = CTX_data_scene(C);
|
2011-12-11 19:23:02 +00:00
|
|
|
|
2013-01-30 11:06:02 +00:00
|
|
|
/* keep in sync with logic in view3d_panel_operator_redo() */
|
2012-03-30 10:00:20 +00:00
|
|
|
ARegion *ar = CTX_wm_region(C);
|
2013-01-30 12:22:02 +00:00
|
|
|
ARegion *ar1 = BKE_area_find_region_active_win(CTX_wm_area(C));
|
2010-12-15 04:06:19 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (ar1)
|
2010-12-15 04:06:19 +00:00
|
|
|
CTX_wm_region_set(C, ar1);
|
|
|
|
|
|
2014-01-12 22:05:24 +11:00
|
|
|
if ((WM_operator_repeat_check(C, op)) &&
|
|
|
|
|
(WM_operator_poll(C, op->type)) &&
|
2011-12-11 19:23:02 +00:00
|
|
|
/* note, undo/redo cant run if there are jobs active,
|
|
|
|
|
* check for screen jobs only so jobs like material/texture/world preview
|
|
|
|
|
* (which copy their data), wont stop redo, see [#29579]],
|
|
|
|
|
*
|
|
|
|
|
* note, - WM_operator_check_ui_enabled() jobs test _must_ stay in sync with this */
|
2014-01-12 22:05:24 +11:00
|
|
|
(WM_jobs_test(wm, scene, WM_JOB_TYPE_ANY) == 0))
|
2011-12-11 19:23:02 +00:00
|
|
|
{
|
2010-12-15 04:06:19 +00:00
|
|
|
int retval;
|
|
|
|
|
|
2014-11-18 15:51:31 +01:00
|
|
|
ED_viewport_render_kill_jobs(wm, CTX_data_main(C), true);
|
2013-07-08 22:26:10 +00:00
|
|
|
|
2012-03-31 00:59:17 +00:00
|
|
|
if (G.debug & G_DEBUG)
|
2010-12-15 04:06:19 +00:00
|
|
|
printf("redo_cb: operator redo %s\n", op->type->name);
|
2017-03-15 05:16:07 +11:00
|
|
|
|
|
|
|
|
WM_operator_free_all_after(wm, op);
|
|
|
|
|
|
2010-12-15 04:06:19 +00:00
|
|
|
ED_undo_pop_op(C, op);
|
2011-03-16 12:21:20 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (op->type->check) {
|
2014-06-15 01:40:15 +10:00
|
|
|
if (op->type->check(C, op)) {
|
|
|
|
|
/* check for popup and re-layout buttons */
|
|
|
|
|
ARegion *ar_menu = CTX_wm_menu(C);
|
|
|
|
|
if (ar_menu) {
|
|
|
|
|
ED_region_tag_refresh_ui(ar_menu);
|
|
|
|
|
}
|
|
|
|
|
}
|
2011-03-16 12:21:20 +00:00
|
|
|
}
|
|
|
|
|
|
2012-03-30 10:00:20 +00:00
|
|
|
retval = WM_operator_repeat(C, op);
|
|
|
|
|
if ((retval & OPERATOR_FINISHED) == 0) {
|
2012-03-31 00:59:17 +00:00
|
|
|
if (G.debug & G_DEBUG)
|
2010-12-15 04:06:19 +00:00
|
|
|
printf("redo_cb: operator redo failed: %s, return %d\n", op->type->name, retval);
|
|
|
|
|
ED_undo_redo(C);
|
|
|
|
|
}
|
|
|
|
|
else {
|
2012-03-30 10:00:20 +00:00
|
|
|
ret = 1;
|
2010-12-15 04:06:19 +00:00
|
|
|
}
|
|
|
|
|
}
|
2011-07-26 13:05:22 +00:00
|
|
|
else {
|
2012-03-31 00:59:17 +00:00
|
|
|
if (G.debug & G_DEBUG) {
|
2011-07-26 13:05:22 +00:00
|
|
|
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 {
|
2012-03-31 00:59:17 +00:00
|
|
|
if (G.debug & 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
|
|
|
|
2018-04-02 15:02:08 +02: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
|
|
|
|
2018-04-02 15:02:08 +02:00
|
|
|
/* -------------------------------------------------------------------- */
|
|
|
|
|
/** \name Undo History Operator
|
|
|
|
|
* \{ */
|
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
|
|
|
|
|
|
|
|
/* create enum based on undo items */
|
2018-03-19 14:17:59 +01:00
|
|
|
static const EnumPropertyItem *rna_undo_itemf(bContext *C, int *totitem)
|
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
|
|
|
{
|
2012-03-30 10:00:20 +00:00
|
|
|
EnumPropertyItem item_tmp = {0}, *item = NULL;
|
2015-04-18 15:41:12 +02:00
|
|
|
int i = 0;
|
2018-03-19 14:17:59 +01:00
|
|
|
|
|
|
|
|
wmWindowManager *wm = CTX_wm_manager(C);
|
|
|
|
|
if (wm->undo_stack == NULL) {
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (UndoStep *us = wm->undo_stack->steps.first; us; us = us->next, i++) {
|
|
|
|
|
if (us->skip == false) {
|
|
|
|
|
item_tmp.identifier = us->name;
|
|
|
|
|
item_tmp.name = IFACE_(us->name);
|
|
|
|
|
if (us == wm->undo_stack->step_active) {
|
2012-03-30 10:00:20 +00:00
|
|
|
item_tmp.icon = ICON_RESTRICT_VIEW_OFF;
|
2018-03-19 14:17:59 +01:00
|
|
|
}
|
|
|
|
|
else {
|
2012-03-30 10:00:20 +00:00
|
|
|
item_tmp.icon = ICON_NONE;
|
2018-03-19 14:17:59 +01:00
|
|
|
}
|
|
|
|
|
item_tmp.value = i;
|
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
|
|
|
RNA_enum_item_add(&item, totitem, &item_tmp);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
RNA_enum_item_end(&item, totitem);
|
2018-03-19 14:17:59 +01: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
|
|
|
return item;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2013-03-13 09:03:46 +00:00
|
|
|
static int undo_history_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
|
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
|
|
|
{
|
2018-03-19 14:17:59 +01:00
|
|
|
int totitem = 0;
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
const EnumPropertyItem *item = rna_undo_itemf(C, &totitem);
|
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (totitem > 0) {
|
2014-11-09 21:20:40 +01:00
|
|
|
uiPopupMenu *pup = UI_popup_menu_begin(C, RNA_struct_ui_name(op->type->srna), ICON_NONE);
|
|
|
|
|
uiLayout *layout = UI_popup_menu_layout(pup);
|
2014-04-01 11:34:00 +11:00
|
|
|
uiLayout *split = uiLayoutSplit(layout, 0.0f, false);
|
2012-06-19 23:08:16 +00:00
|
|
|
uiLayout *column = NULL;
|
2014-04-15 16:49:49 +02:00
|
|
|
const int col_size = 20 + totitem / 12;
|
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;
|
2014-04-15 16:49:49 +02:00
|
|
|
bool add_col = true;
|
2018-04-02 15:02:08 +02:00
|
|
|
|
2014-04-15 16:49:49 +02:00
|
|
|
for (c = 0, i = totitem; i--;) {
|
|
|
|
|
if (add_col && !(c % col_size)) {
|
2014-04-01 11:34:00 +11:00
|
|
|
column = uiLayoutColumn(split, false);
|
2014-04-15 16:49:49 +02:00
|
|
|
add_col = false;
|
|
|
|
|
}
|
|
|
|
|
if (item[i].identifier) {
|
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
|
|
|
uiItemIntO(column, item[i].name, item[i].icon, op->type->idname, "item", item[i].value);
|
2014-04-15 16:49:49 +02:00
|
|
|
++c;
|
|
|
|
|
add_col = true;
|
|
|
|
|
}
|
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
|
|
|
}
|
2018-04-02 15:02:08 +02:00
|
|
|
|
2017-10-18 15:07:26 +11:00
|
|
|
MEM_freeN((void *)item);
|
2018-04-02 15:02:08 +02:00
|
|
|
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_popup_menu_end(C, pup);
|
2012-10-21 05:46:41 +00:00
|
|
|
}
|
2018-04-02 15:02:08 +02: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
|
|
|
}
|
|
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* note: also check ed_undo_step() in top if you change notifiers */
|
|
|
|
|
static int undo_history_exec(bContext *C, wmOperator *op)
|
|
|
|
|
{
|
2018-03-19 14:17:59 +01:00
|
|
|
PropertyRNA *prop = RNA_struct_find_property(op->ptr, "item");
|
|
|
|
|
if (RNA_property_is_set(op->ptr, prop)) {
|
|
|
|
|
int item = RNA_property_int_get(op->ptr, prop);
|
|
|
|
|
wmWindowManager *wm = CTX_wm_manager(C);
|
|
|
|
|
BKE_undosys_step_undo_from_index(wm->undo_stack, C, item);
|
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
|
|
|
WM_event_add_notifier(C, NC_WINDOW, NULL);
|
|
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
|
}
|
|
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ED_OT_undo_history(wmOperatorType *ot)
|
|
|
|
|
{
|
|
|
|
|
/* identifiers */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->name = "Undo History";
|
|
|
|
|
ot->description = "Redo specific action in history";
|
|
|
|
|
ot->idname = "ED_OT_undo_history";
|
2018-04-02 15:02:08 +02: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
|
|
|
/* api callbacks */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->invoke = undo_history_invoke;
|
|
|
|
|
ot->exec = undo_history_exec;
|
|
|
|
|
ot->poll = ED_operator_screenactive;
|
2018-04-02 15:02:08 +02: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
|
|
|
RNA_def_int(ot->srna, "item", 0, 0, INT_MAX, "Item", "", 0, INT_MAX);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2018-04-02 15:02:08 +02:00
|
|
|
/** \} */
|