[Bf-blender-cvs] [6ab5bced611] master: Merge branch 'blender-v3.3-release'
Bastien Montagne
noreply at git.blender.org
Wed Aug 17 13:01:12 CEST 2022
Commit: 6ab5bced6114c566313131467f75f97be4428156
Author: Bastien Montagne
Date: Wed Aug 17 13:01:09 2022 +0200
Branches: master
https://developer.blender.org/rB6ab5bced6114c566313131467f75f97be4428156
Merge branch 'blender-v3.3-release'
===================================================================
===================================================================
diff --cc source/blender/editors/interface/interface_ops.cc
index 2533a5454a5,00000000000..27ae7fd9473
mode 100644,000000..100644
--- a/source/blender/editors/interface/interface_ops.cc
+++ b/source/blender/editors/interface/interface_ops.cc
@@@ -1,2273 -1,0 +1,2521 @@@
+/* SPDX-License-Identifier: GPL-2.0-or-later
+ * Copyright 2009 Blender Foundation. All rights reserved. */
+
+/** \file
+ * \ingroup edinterface
+ */
+
+#include <cstring>
+
+#include "MEM_guardedalloc.h"
+
+#include "DNA_armature_types.h"
+#include "DNA_material_types.h"
+#include "DNA_modifier_types.h" /* for handling geometry nodes properties */
+#include "DNA_object_types.h" /* for OB_DATA_SUPPORT_ID */
+#include "DNA_screen_types.h"
+#include "DNA_text_types.h"
+
+#include "BLI_blenlib.h"
+#include "BLI_math_color.h"
+
+#include "BLF_api.h"
+#include "BLT_lang.h"
++#include "BLT_translation.h"
+
+#include "BKE_context.h"
+#include "BKE_global.h"
+#include "BKE_idprop.h"
+#include "BKE_layer.h"
+#include "BKE_lib_id.h"
+#include "BKE_lib_override.h"
++#include "BKE_lib_remap.h"
+#include "BKE_material.h"
+#include "BKE_node.h"
+#include "BKE_report.h"
+#include "BKE_screen.h"
+#include "BKE_text.h"
+
+#include "IMB_colormanagement.h"
+
+#include "DEG_depsgraph.h"
+
+#include "RNA_access.h"
+#include "RNA_define.h"
+#include "RNA_path.h"
+#include "RNA_prototypes.h"
+#include "RNA_types.h"
+
+#include "UI_interface.h"
+
+#include "interface_intern.h"
+
+#include "WM_api.h"
+#include "WM_types.h"
+
+#include "ED_object.h"
+#include "ED_paint.h"
+
+/* for Copy As Driver */
+#include "ED_keyframing.h"
+
+/* only for UI_OT_editsource */
+#include "BKE_main.h"
+#include "BLI_ghash.h"
+#include "ED_screen.h"
+#include "ED_text.h"
+
+/* -------------------------------------------------------------------- */
+/** \name Immediate redraw helper
+ *
+ * Generally handlers shouldn't do any redrawing, that includes the layout/button definitions. That
+ * violates the Model-View-Controller pattern.
+ *
+ * But there are some operators which really need to re-run the layout definitions for various
+ * reasons. For example, "Edit Source" does it to find out which exact Python code added a button.
+ * Other operators may need to access buttons that aren't currently visible. In Blender's UI code
+ * design that typically means just not adding the button in the first place, for a particular
+ * redraw. So the operator needs to change context and re-create the layout, so the button becomes
+ * available to act on.
+ *
+ * \{ */
+
+static void ui_region_redraw_immediately(bContext *C, ARegion *region)
+{
+ ED_region_do_layout(C, region);
+ WM_draw_region_viewport_bind(region);
+ ED_region_do_draw(C, region);
+ WM_draw_region_viewport_unbind(region);
+ region->do_draw = false;
+}
+
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Copy Data Path Operator
+ * \{ */
+
+static bool copy_data_path_button_poll(bContext *C)
+{
+ PointerRNA ptr;
+ PropertyRNA *prop;
+ char *path;
+ int index;
+
+ UI_context_active_but_prop_get(C, &ptr, &prop, &index);
+
+ if (ptr.owner_id && ptr.data && prop) {
+ path = RNA_path_from_ID_to_property(&ptr, prop);
+
+ if (path) {
+ MEM_freeN(path);
+ return true;
+ }
+ }
+
+ return false;
+}
+
+static int copy_data_path_button_exec(bContext *C, wmOperator *op)
+{
+ Main *bmain = CTX_data_main(C);
+ PointerRNA ptr;
+ PropertyRNA *prop;
+ char *path;
+ int index;
+ ID *id;
+
+ const bool full_path = RNA_boolean_get(op->ptr, "full_path");
+
+ /* try to create driver using property retrieved from UI */
+ UI_context_active_but_prop_get(C, &ptr, &prop, &index);
+
+ if (ptr.owner_id != nullptr) {
+ if (full_path) {
+ if (prop) {
+ path = RNA_path_full_property_py_ex(bmain, &ptr, prop, index, true);
+ }
+ else {
+ path = RNA_path_full_struct_py(bmain, &ptr);
+ }
+ }
+ else {
+ path = RNA_path_from_real_ID_to_property_index(bmain, &ptr, prop, 0, -1, &id);
+
+ if (!path) {
+ path = RNA_path_from_ID_to_property(&ptr, prop);
+ }
+ }
+
+ if (path) {
+ WM_clipboard_text_set(path, false);
+ MEM_freeN(path);
+ return OPERATOR_FINISHED;
+ }
+ }
+
+ return OPERATOR_CANCELLED;
+}
+
+static void UI_OT_copy_data_path_button(wmOperatorType *ot)
+{
+ PropertyRNA *prop;
+
+ /* identifiers */
+ ot->name = "Copy Data Path";
+ ot->idname = "UI_OT_copy_data_path_button";
+ ot->description = "Copy the RNA data path for this property to the clipboard";
+
+ /* callbacks */
+ ot->exec = copy_data_path_button_exec;
+ ot->poll = copy_data_path_button_poll;
+
+ /* flags */
+ ot->flag = OPTYPE_REGISTER;
+
+ /* properties */
+ prop = RNA_def_boolean(ot->srna, "full_path", false, "full_path", "Copy full data path");
+ RNA_def_property_flag(prop, PROP_SKIP_SAVE);
+}
+
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Copy As Driver Operator
+ * \{ */
+
+static bool copy_as_driver_button_poll(bContext *C)
+{
+ PointerRNA ptr;
+ PropertyRNA *prop;
+ char *path;
+ int index;
+
+ UI_context_active_but_prop_get(C, &ptr, &prop, &index);
+
+ if (ptr.owner_id && ptr.data && prop &&
+ ELEM(RNA_property_type(prop), PROP_BOOLEAN, PROP_INT, PROP_FLOAT, PROP_ENUM) &&
+ (index >= 0 || !RNA_property_array_check(prop))) {
+ path = RNA_path_from_ID_to_property(&ptr, prop);
+
+ if (path) {
+ MEM_freeN(path);
+ return true;
+ }
+ }
+
+ return false;
+}
+
+static int copy_as_driver_button_exec(bContext *C, wmOperator *op)
+{
+ Main *bmain = CTX_data_main(C);
+ PointerRNA ptr;
+ PropertyRNA *prop;
+ int index;
+
+ /* try to create driver using property retrieved from UI */
+ UI_context_active_but_prop_get(C, &ptr, &prop, &index);
+
+ if (ptr.owner_id && ptr.data && prop) {
+ ID *id;
+ const int dim = RNA_property_array_dimension(&ptr, prop, nullptr);
+ char *path = RNA_path_from_real_ID_to_property_index(bmain, &ptr, prop, dim, index, &id);
+
+ if (path) {
+ ANIM_copy_as_driver(id, path, RNA_property_identifier(prop));
+ MEM_freeN(path);
+ return OPERATOR_FINISHED;
+ }
+
+ BKE_reportf(op->reports, RPT_ERROR, "Could not compute a valid data path");
+ return OPERATOR_CANCELLED;
+ }
+
+ return OPERATOR_CANCELLED;
+}
+
+static void UI_OT_copy_as_driver_button(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name = "Copy as New Driver";
+ ot->idname = "UI_OT_copy_as_driver_button";
+ ot->description =
+ "Create a new driver with this property as input, and copy it to the "
+ "clipboard. Use Paste Driver to add it to the target property, or Paste "
+ "Driver Variables to extend an existing driver";
+
+ /* callbacks */
+ ot->exec = copy_as_driver_button_exec;
+ ot->poll = copy_as_driver_button_poll;
+
+ /* flags */
+ ot->flag = OPTYPE_REGISTER;
+}
+
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Copy Python Command Operator
+ * \{ */
+
+static bool copy_python_command_button_poll(bContext *C)
+{
+ uiBut *but = UI_context_active_but_get(C);
+
+ if (but && (but->optype != nullptr)) {
+ return true;
+ }
+
+ return false;
+}
+
+static int copy_python_command_button_exec(bContext *C, wmOperator *UNUSED(op))
+{
+ uiBut *but = UI_context_active_but_get(C);
+
+ if (but && (but->optype != nullptr)) {
+ PointerRNA *opptr;
+ char *str;
+ opptr = UI_but_operator_ptr_get(but); /* allocated when needed, the button owns it */
+
+ str = WM_operator_pystring_ex(C, nullptr, false, true, but->optype, opptr);
+
+ WM_clipboard_text_set(str, false);
+
+ MEM_freeN(str);
+
+ return OPERATOR_FINISHED;
+ }
+
+ return OPERATOR_CANCELLED;
+}
+
+static void UI_OT_copy_python_command_button(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name = "Copy Python Command";
+ ot->idname = "UI_OT_copy_python_command_button";
+ ot->description = "Copy the Python command matching this button";
+
+ /* callbacks */
+ ot->exec = copy_python_command_button_exec;
+ ot->poll = copy_python_command_button_poll;
+
+ /* flags */
+ ot->flag = OPTYPE_REGISTER;
+}
+
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Reset to Default Values Button Operator
+ * \{ */
+
+static int operator_button_property_finish(bContext *C, PointerRNA *ptr, PropertyRNA *prop)
+{
+ ID *id = ptr->owner_id;
+
+ /* perform updates required for this property */
+ RNA_property_update(C, ptr, prop);
+
+ /* as if we pressed the button */
+ UI_context_active_but_prop_handle(C, false);
+
+ /* Since we don't want to undo _all_ edits to settings, eg window
+ * edits on the screen or on operator settings.
+ * it might be better to move undo's inline - campbell */
+ if (id && ID_CHECK_UNDO(id)) {
+ /* do nothing, go ahead with undo */
+ return OPERATOR_FINISHED;
+ }
+ return OPERATOR_CANCELLED;
+}
+
+static int operator_button_property_finish_with_undo(bContext *C,
+ PointerRNA *ptr,
+ PropertyRNA *prop)
+{
+ /* Perform updates required for this property. */
+ RNA_property_update(C, ptr, prop);
+
+ /* As if we pressed the button. */
+ UI_context_active_but_prop_handle(C, true);
+
+ return OPERATOR_FINISHED;
+}
+
+static bool reset_default_button_poll(bContext *C)
+{
+ PointerRNA ptr;
+ PropertyRNA *prop;
+ int index;
+
+ UI_context_active_but_prop_get(C, &ptr, &prop, &index);
+
+ return (ptr.data && prop && RNA_property_editable(&ptr, prop));
+}
+
+static int reset_default_button_exec(bContext *C, wmOperator *op)
+{
+ PointerRNA ptr;
+ PropertyRNA *prop;
+ int index;
+ const bool all = RNA_boolean_get(op->ptr, "all");
+
+ /* try to reset th
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list