Blender V5.0
ed_util_ops.cc File Reference
#include <cstring>
#include "DNA_space_types.h"
#include "DNA_windowmanager_types.h"
#include "BLI_fileops.h"
#include "BLI_utildefines.h"
#include "BLI_vector.hh"
#include "BKE_context.hh"
#include "BKE_lib_id.hh"
#include "BKE_lib_override.hh"
#include "BKE_library.hh"
#include "BKE_preview_image.hh"
#include "BKE_report.hh"
#include "ED_asset.hh"
#include "ED_render.hh"
#include "ED_undo.hh"
#include "ED_util.hh"
#include "RNA_access.hh"
#include "RNA_prototypes.hh"
#include "UI_interface.hh"
#include "WM_api.hh"
#include "WM_types.hh"

Go to the source code of this file.

Functions

void ED_operatortypes_edutils ()
Context Query Helpers
blender::Vector< PointerRNAED_operator_single_id_from_context_as_vec (const bContext *C)
blender::Vector< PointerRNAED_operator_get_ids_from_context_as_vec (const bContext *C)
ID Previews
static bool lib_id_preview_editing_poll_ex (const ID *id, const char **r_disabled_hint)
static bool lib_id_preview_editing_poll (bContext *C)
static IDlib_id_load_custom_preview_id_get (bContext *C, const wmOperator *op)
static wmOperatorStatus lib_id_load_custom_preview_exec (bContext *C, wmOperator *op)
static wmOperatorStatus lib_id_load_custom_preview_invoke (bContext *C, wmOperator *op, const wmEvent *event)
static void ED_OT_lib_id_load_custom_preview (wmOperatorType *ot)
static void lib_id_batch_edit_previews (bContext *C, blender::FunctionRef< void(ID *)> foreach_id)
static bool lib_id_batch_editing_preview_poll (bContext *C, blender::FunctionRef< bool(const ID *, const char **r_disabled_hint)> additional_condition=nullptr)
static bool lib_id_generate_preview_poll (bContext *C)
static wmOperatorStatus lib_id_generate_preview_exec (bContext *C, wmOperator *)
static void ED_OT_lib_id_generate_preview (wmOperatorType *ot)
static bool lib_id_generate_preview_from_object_poll (bContext *C)
static wmOperatorStatus lib_id_generate_preview_from_object_exec (bContext *C, wmOperator *)
static void ED_OT_lib_id_generate_preview_from_object (wmOperatorType *ot)
static bool lib_id_remove_preview_poll (bContext *C)
static wmOperatorStatus lib_id_remove_preview_exec (bContext *C, wmOperator *)
static void ED_OT_lib_id_remove_preview (wmOperatorType *ot)
Generic ID Operators
static wmOperatorStatus lib_id_fake_user_toggle_exec (bContext *C, wmOperator *op)
static void ED_OT_lib_id_fake_user_toggle (wmOperatorType *ot)
static wmOperatorStatus lib_id_unlink_exec (bContext *C, wmOperator *op)
static void ED_OT_lib_id_unlink (wmOperatorType *ot)
static bool lib_id_override_editable_toggle_poll (bContext *C)
static wmOperatorStatus lib_id_override_editable_toggle_exec (bContext *C, wmOperator *)
static void ED_OT_lib_id_override_editable_toggle (wmOperatorType *ot)
General editor utils.
static wmOperatorStatus ed_flush_edits_exec (bContext *C, wmOperator *)
static void ED_OT_flush_edits (wmOperatorType *ot)

Detailed Description

Utility operators for UI data or for the UI to use.

Definition in file ed_util_ops.cc.

Function Documentation

◆ ed_flush_edits_exec()

wmOperatorStatus ed_flush_edits_exec ( bContext * C,
wmOperator *  )
static

Definition at line 550 of file ed_util_ops.cc.

References C, CTX_data_main(), ED_editors_flush_edits(), and OPERATOR_FINISHED.

Referenced by ED_OT_flush_edits().

◆ ED_operator_get_ids_from_context_as_vec()

blender::Vector< PointerRNA > ED_operator_get_ids_from_context_as_vec ( const bContext * C)

Helper for context sensitive operations: Returns the "selected_ids" context member or, if none, the "id" context member as a PointerRNA vector. Batch operations can use this to get all IDs to act on, including a fallback to the active ID if there's no selection.

Definition at line 54 of file ed_util_ops.cc.

References C, CTX_data_selected_ids(), ED_operator_single_id_from_context_as_vec(), and blender::Vector< T, InlineBufferCapacity, Allocator >::is_empty().

Referenced by blender::ed::asset::ASSET_OT_clear(), blender::ed::asset::ASSET_OT_mark(), lib_id_batch_edit_previews(), and lib_id_batch_editing_preview_poll().

◆ ED_operator_single_id_from_context_as_vec()

blender::Vector< PointerRNA > ED_operator_single_id_from_context_as_vec ( const bContext * C)

Helper for context sensitive operations: Returns the "id" context member wrapped in a PointerRNA vector. Useful when the API uses vectors to also support acting on multiple IDs, e.g. as returned by ED_operator_get_ids_from_context_as_vec().

Definition at line 44 of file ed_util_ops.cc.

References blender::Vector< T, InlineBufferCapacity, Allocator >::append(), C, CTX_data_pointer_get_type(), and PointerRNA::data.

Referenced by blender::ed::asset::ASSET_OT_clear_single(), blender::ed::asset::ASSET_OT_mark_single(), and ED_operator_get_ids_from_context_as_vec().

◆ ED_operatortypes_edutils()

◆ ED_OT_flush_edits()

void ED_OT_flush_edits ( wmOperatorType * ot)
static

Definition at line 557 of file ed_util_ops.cc.

References ed_flush_edits_exec(), OPTYPE_INTERNAL, and ot.

Referenced by ED_operatortypes_edutils().

◆ ED_OT_lib_id_fake_user_toggle()

void ED_OT_lib_id_fake_user_toggle ( wmOperatorType * ot)
static

Definition at line 445 of file ed_util_ops.cc.

References lib_id_fake_user_toggle_exec(), OPTYPE_INTERNAL, OPTYPE_UNDO, and ot.

Referenced by ED_operatortypes_edutils().

◆ ED_OT_lib_id_generate_preview()

void ED_OT_lib_id_generate_preview ( wmOperatorType * ot)
static

◆ ED_OT_lib_id_generate_preview_from_object()

void ED_OT_lib_id_generate_preview_from_object ( wmOperatorType * ot)
static

◆ ED_OT_lib_id_load_custom_preview()

◆ ED_OT_lib_id_override_editable_toggle()

void ED_OT_lib_id_override_editable_toggle ( wmOperatorType * ot)
static

◆ ED_OT_lib_id_remove_preview()

void ED_OT_lib_id_remove_preview ( wmOperatorType * ot)
static

◆ ED_OT_lib_id_unlink()

void ED_OT_lib_id_unlink ( wmOperatorType * ot)
static

Definition at line 483 of file ed_util_ops.cc.

References lib_id_unlink_exec(), OPTYPE_INTERNAL, OPTYPE_UNDO, and ot.

Referenced by ED_operatortypes_edutils().

◆ lib_id_batch_edit_previews()

void lib_id_batch_edit_previews ( bContext * C,
blender::FunctionRef< void(ID *)> foreach_id )
static

Helper for batch editing previews. Gets selected or active IDs from context and calls foreach_id for each ID that supports previews.

Definition at line 193 of file ed_util_ops.cc.

References C, ED_operator_get_ids_from_context_as_vec(), and lib_id_preview_editing_poll_ex().

Referenced by lib_id_generate_preview_exec(), lib_id_generate_preview_from_object_exec(), lib_id_remove_preview_exec(), and lib_id_remove_preview_poll().

◆ lib_id_batch_editing_preview_poll()

bool lib_id_batch_editing_preview_poll ( bContext * C,
blender::FunctionRef< bool(const ID *, const char **r_disabled_hint)> additional_condition = nullptr )
static

Helper for batch editing previews. Check if at least one of the selected or active IDs supports previews, setting a disabled hint if not. Note that only one disabled hint can be set, this simply uses the first one set while polling individual IDs. That's more useful than a generic message still.

Parameters
additional_conditionWhen set, IDs need to additionally pass this check (return true) to be considered as supporting this operation.

Definition at line 214 of file ed_util_ops.cc.

References C, CTX_wm_operator_poll_msg_set(), ED_operator_get_ids_from_context_as_vec(), blender::Vector< T, InlineBufferCapacity, Allocator >::is_empty(), and lib_id_preview_editing_poll_ex().

Referenced by lib_id_generate_preview_from_object_poll(), lib_id_generate_preview_poll(), and lib_id_remove_preview_poll().

◆ lib_id_fake_user_toggle_exec()

◆ lib_id_generate_preview_exec()

◆ lib_id_generate_preview_from_object_exec()

◆ lib_id_generate_preview_from_object_poll()

bool lib_id_generate_preview_from_object_poll ( bContext * C)
static

◆ lib_id_generate_preview_poll()

bool lib_id_generate_preview_poll ( bContext * C)
static

◆ lib_id_load_custom_preview_exec()

◆ lib_id_load_custom_preview_id_get()

ID * lib_id_load_custom_preview_id_get ( bContext * C,
const wmOperator * op )
static

◆ lib_id_load_custom_preview_invoke()

wmOperatorStatus lib_id_load_custom_preview_invoke ( bContext * C,
wmOperator * op,
const wmEvent * event )
static

Obtain the ID from context, and spawn a File Browser to select the preview image. The File Browser may re-use the Asset Browser under the cursor, and clear the file-list on confirmation, leading to failure to obtain the ID at that point. So get it before spawning the File Browser (store it in the operator custom data).

Definition at line 158 of file ed_util_ops.cc.

References C, wmOperator::customdata, lib_id_load_custom_preview_id_get(), and WM_operator_filesel().

Referenced by ED_OT_lib_id_load_custom_preview().

◆ lib_id_override_editable_toggle_exec()

◆ lib_id_override_editable_toggle_poll()

bool lib_id_override_editable_toggle_poll ( bContext * C)
static

◆ lib_id_preview_editing_poll()

◆ lib_id_preview_editing_poll_ex()

bool lib_id_preview_editing_poll_ex ( const ID * id,
const char ** r_disabled_hint )
static

◆ lib_id_remove_preview_exec()

◆ lib_id_remove_preview_poll()

bool lib_id_remove_preview_poll ( bContext * C)
static

◆ lib_id_unlink_exec()