[Bf-blender-cvs] [b7eba20236c] master: UI: Edit Menu Operator Polling

Harley Acheson noreply at git.blender.org
Sun May 19 22:15:44 CEST 2019


Commit: b7eba20236ca6499a62a8ee2b0c852086bc46b8e
Author: Harley Acheson
Date:   Sun May 19 13:12:15 2019 -0700
Branches: master
https://developer.blender.org/rBb7eba20236ca6499a62a8ee2b0c852086bc46b8e

UI: Edit Menu Operator Polling

This patch updates the polling that enable/disables Edit Menu items. Slight Undo History menu changes

Differential Revision: https://developer.blender.org/D4846

Reviewed by Brecht Van Lommel

===================================================================

M	release/scripts/addons
M	source/blender/blenkernel/intern/undo_system.c
M	source/blender/editors/screen/screen_ops.c
M	source/blender/editors/undo/ed_undo.c

===================================================================

diff --git a/release/scripts/addons b/release/scripts/addons
index 2ce7a5d85cf..53e11f6552d 160000
--- a/release/scripts/addons
+++ b/release/scripts/addons
@@ -1 +1 @@
-Subproject commit 2ce7a5d85cfb21b5832a533af551bfb01502b168
+Subproject commit 53e11f6552dfd2defbf2b5c4fd1621d3dfdb6129
diff --git a/source/blender/blenkernel/intern/undo_system.c b/source/blender/blenkernel/intern/undo_system.c
index d3e0ff56977..c24cdf424f9 100644
--- a/source/blender/blenkernel/intern/undo_system.c
+++ b/source/blender/blenkernel/intern/undo_system.c
@@ -337,7 +337,7 @@ static bool undosys_stack_push_main(UndoStack *ustack, const char *name, struct
 void BKE_undosys_stack_init_from_main(UndoStack *ustack, struct Main *bmain)
 {
   UNDO_NESTED_ASSERT(false);
-  undosys_stack_push_main(ustack, "original", bmain);
+  undosys_stack_push_main(ustack, IFACE_("Original"), bmain);
 }
 
 /* called after 'BKE_undosys_stack_init_from_main' */
@@ -345,7 +345,7 @@ void BKE_undosys_stack_init_from_context(UndoStack *ustack, bContext *C)
 {
   const UndoType *ut = BKE_undosys_type_from_context(C);
   if ((ut != NULL) && (ut != BKE_UNDOSYS_TYPE_MEMFILE)) {
-    BKE_undosys_step_push_with_type(ustack, C, "original mode", ut);
+    BKE_undosys_step_push_with_type(ustack, C, IFACE_("Original Mode"), ut);
   }
 }
 
diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c
index af90bbc9975..a94c0e35876 100644
--- a/source/blender/editors/screen/screen_ops.c
+++ b/source/blender/editors/screen/screen_ops.c
@@ -3564,6 +3564,12 @@ static int repeat_last_exec(bContext *C, wmOperator *UNUSED(op))
   return OPERATOR_CANCELLED;
 }
 
+static bool repeat_last_poll(bContext *C)
+{
+  wmWindowManager *wm = CTX_wm_manager(C);
+  return ED_operator_screenactive(C) && !BLI_listbase_is_empty(&wm->operators);
+}
+
 static void SCREEN_OT_repeat_last(wmOperatorType *ot)
 {
   /* identifiers */
@@ -3574,7 +3580,7 @@ static void SCREEN_OT_repeat_last(wmOperatorType *ot)
   /* api callbacks */
   ot->exec = repeat_last_exec;
 
-  ot->poll = ED_operator_screenactive;
+  ot->poll = repeat_last_poll;
 }
 
 /** \} */
@@ -3627,6 +3633,12 @@ static int repeat_history_exec(bContext *C, wmOperator *op)
   return OPERATOR_FINISHED;
 }
 
+static bool repeat_history_poll(bContext *C)
+{
+  wmWindowManager *wm = CTX_wm_manager(C);
+  return ED_operator_screenactive(C) && !BLI_listbase_is_empty(&wm->operators);
+}
+
 static void SCREEN_OT_repeat_history(wmOperatorType *ot)
 {
   /* identifiers */
@@ -3638,7 +3650,7 @@ static void SCREEN_OT_repeat_history(wmOperatorType *ot)
   ot->invoke = repeat_history_invoke;
   ot->exec = repeat_history_exec;
 
-  ot->poll = ED_operator_screenactive;
+  ot->poll = repeat_history_poll;
 
   RNA_def_int(ot->srna, "index", 0, 0, INT_MAX, "Index", "", 0, 1000);
 }
@@ -3660,6 +3672,12 @@ static int redo_last_invoke(bContext *C, wmOperator *UNUSED(op), const wmEvent *
   return OPERATOR_CANCELLED;
 }
 
+static bool redo_last_poll(bContext *C)
+{
+  wmWindowManager *wm = CTX_wm_manager(C);
+  return ED_operator_screenactive(C) && !BLI_listbase_is_empty(&wm->operators);
+}
+
 static void SCREEN_OT_redo_last(wmOperatorType *ot)
 {
   /* identifiers */
@@ -3670,7 +3688,7 @@ static void SCREEN_OT_redo_last(wmOperatorType *ot)
   /* api callbacks */
   ot->invoke = redo_last_invoke;
 
-  ot->poll = ED_operator_screenactive;
+  ot->poll = redo_last_poll;
 }
 
 /** \} */
diff --git a/source/blender/editors/undo/ed_undo.c b/source/blender/editors/undo/ed_undo.c
index 49b5cada04a..99143cd71f9 100644
--- a/source/blender/editors/undo/ed_undo.c
+++ b/source/blender/editors/undo/ed_undo.c
@@ -392,6 +392,15 @@ static bool ed_undo_redo_poll(bContext *C)
           WM_operator_check_ui_enabled(C, last_op->type->name));
 }
 
+static bool ed_undo_poll(bContext *C)
+{
+  if (!ed_undo_is_init_and_screenactive_poll(C)) {
+    return false;
+  }
+  UndoStack *undo_stack = CTX_wm_manager(C)->undo_stack;
+  return (undo_stack->step_active != NULL) && (undo_stack->step_active->prev != NULL);
+}
+
 void ED_OT_undo(wmOperatorType *ot)
 {
   /* identifiers */
@@ -401,7 +410,7 @@ void ED_OT_undo(wmOperatorType *ot)
 
   /* api callbacks */
   ot->exec = ed_undo_exec;
-  ot->poll = ed_undo_is_init_and_screenactive_poll;
+  ot->poll = ed_undo_poll;
 }
 
 void ED_OT_undo_push(wmOperatorType *ot)
@@ -426,6 +435,15 @@ void ED_OT_undo_push(wmOperatorType *ot)
                  "");
 }
 
+static bool ed_redo_poll(bContext *C)
+{
+  if (!ed_undo_is_init_and_screenactive_poll(C)) {
+    return false;
+  }
+  UndoStack *undo_stack = CTX_wm_manager(C)->undo_stack;
+  return (undo_stack->step_active != NULL) && (undo_stack->step_active->next != NULL);
+}
+
 void ED_OT_redo(wmOperatorType *ot)
 {
   /* identifiers */
@@ -435,7 +453,7 @@ void ED_OT_redo(wmOperatorType *ot)
 
   /* api callbacks */
   ot->exec = ed_redo_exec;
-  ot->poll = ed_undo_is_init_and_screenactive_poll;
+  ot->poll = ed_redo_poll;
 }
 
 void ED_OT_undo_redo(wmOperatorType *ot)
@@ -569,7 +587,7 @@ static const EnumPropertyItem *rna_undo_itemf(bContext *C, int *totitem)
       item_tmp.identifier = us->name;
       item_tmp.name = IFACE_(us->name);
       if (us == wm->undo_stack->step_active) {
-        item_tmp.icon = ICON_HIDE_OFF;
+        item_tmp.icon = ICON_LAYER_ACTIVE;
       }
       else {
         item_tmp.icon = ICON_NONE;
@@ -633,6 +651,16 @@ static int undo_history_exec(bContext *C, wmOperator *op)
   return OPERATOR_CANCELLED;
 }
 
+static bool undo_history_poll(bContext *C)
+{
+  if (!ed_undo_is_init_and_screenactive_poll(C)) {
+    return false;
+  }
+  UndoStack *undo_stack = CTX_wm_manager(C)->undo_stack;
+  /* more than just original state entry */
+  return BLI_listbase_count_at_most(&undo_stack->steps, 2) > 1;
+}
+
 void ED_OT_undo_history(wmOperatorType *ot)
 {
   /* identifiers */
@@ -643,7 +671,7 @@ void ED_OT_undo_history(wmOperatorType *ot)
   /* api callbacks */
   ot->invoke = undo_history_invoke;
   ot->exec = undo_history_exec;
-  ot->poll = ed_undo_is_init_and_screenactive_poll;
+  ot->poll = undo_history_poll;
 
   RNA_def_int(ot->srna, "item", 0, 0, INT_MAX, "Item", "", 0, INT_MAX);
 }



More information about the Bf-blender-cvs mailing list