Blender V4.3
interface_ops.cc File Reference
#include <cstring>
#include <fmt/format.h>
#include "MEM_guardedalloc.h"
#include "DNA_armature_types.h"
#include "DNA_material_types.h"
#include "DNA_modifier_types.h"
#include "DNA_object_types.h"
#include "DNA_screen_types.h"
#include "BLI_blenlib.h"
#include "BLI_math_color.h"
#include "BLF_api.hh"
#include "BLT_lang.hh"
#include "BLT_translation.hh"
#include "BKE_anim_data.hh"
#include "BKE_context.hh"
#include "BKE_fcurve.hh"
#include "BKE_idtype.hh"
#include "BKE_layer.hh"
#include "BKE_lib_id.hh"
#include "BKE_lib_override.hh"
#include "BKE_lib_remap.hh"
#include "BKE_material.h"
#include "BKE_node.hh"
#include "BKE_report.hh"
#include "BKE_screen.hh"
#include "IMB_colormanagement.hh"
#include "DEG_depsgraph.hh"
#include "DEG_depsgraph_build.hh"
#include "RNA_access.hh"
#include "RNA_define.hh"
#include "RNA_path.hh"
#include "RNA_prototypes.hh"
#include "UI_abstract_view.hh"
#include "UI_interface.hh"
#include "interface_intern.hh"
#include "WM_api.hh"
#include "WM_types.hh"
#include "ED_object.hh"
#include "ED_paint.hh"
#include "ED_undo.hh"
#include "ED_keyframing.hh"
#include "BLI_ghash.h"
#include "ED_screen.hh"

Go to the source code of this file.

Namespaces

namespace  blender
 
namespace  blender::interface
 
namespace  blender::interface::internal
 

Functions

blender::Vector< FCurve * > blender::interface::internal::get_property_drivers (PointerRNA *ptr, PropertyRNA *prop, bool get_all, int index, bool *r_is_array_prop)
 
int blender::interface::internal::paste_property_drivers (blender::Span< FCurve * > src_drivers, bool is_array_prop, PointerRNA *dst_ptr, PropertyRNA *dst_prop)
 
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)
 
Copy Data Path Operator
static bool copy_data_path_button_poll (bContext *C)
 
static int copy_data_path_button_exec (bContext *C, wmOperator *op)
 
static void UI_OT_copy_data_path_button (wmOperatorType *ot)
 
Copy As Driver Operator
static bool copy_as_driver_button_poll (bContext *C)
 
static int copy_as_driver_button_exec (bContext *C, wmOperator *op)
 
static void UI_OT_copy_as_driver_button (wmOperatorType *ot)
 
Copy Python Command Operator
static bool copy_python_command_button_poll (bContext *C)
 
static int copy_python_command_button_exec (bContext *C, wmOperator *)
 
static void UI_OT_copy_python_command_button (wmOperatorType *ot)
 
Reset to Default Values Button Operator
static int operator_button_property_finish (bContext *C, PointerRNA *ptr, PropertyRNA *prop)
 
static int operator_button_property_finish_with_undo (bContext *C, PointerRNA *ptr, PropertyRNA *prop)
 
static bool reset_default_button_poll (bContext *C)
 
static int reset_default_button_exec (bContext *C, wmOperator *op)
 
static void UI_OT_reset_default_button (wmOperatorType *ot)
 
Assign Value as Default Button Operator
static bool assign_default_button_poll (bContext *C)
 
static int assign_default_button_exec (bContext *C, wmOperator *)
 
static void UI_OT_assign_default_button (wmOperatorType *ot)
 
Unset Property Button Operator
static int unset_property_button_exec (bContext *C, wmOperator *)
 
static void UI_OT_unset_property_button (wmOperatorType *ot)
 
Copy Driver To Selected Operator
static bool copy_driver_to_selected_button (bContext *C, bool copy_entire_array, const bool poll)
 
static bool copy_driver_to_selected_button_poll (bContext *C)
 
static int copy_driver_to_selected_button_exec (bContext *C, wmOperator *op)
 
static void UI_OT_copy_driver_to_selected_button (wmOperatorType *ot)
 
Jump to Target Operator
static bool jump_to_target_ptr (bContext *C, PointerRNA ptr, const bool poll)
 
static bool jump_to_target_button (bContext *C, bool poll)
 
bool ui_jump_to_target_button_poll (bContext *C)
 
static int jump_to_target_button_exec (bContext *C, wmOperator *)
 
static void UI_OT_jump_to_target_button (wmOperatorType *ot)
 
Reload Translation Operator
static int reloadtranslation_exec (bContext *, wmOperator *)
 
static void UI_OT_reloadtranslation (wmOperatorType *ot)
 
Press Button Operator
static int ui_button_press_invoke (bContext *C, wmOperator *op, const wmEvent *event)
 
static void UI_OT_button_execute (wmOperatorType *ot)
 
Text Button Clear Operator
static int button_string_clear_exec (bContext *C, wmOperator *)
 
static void UI_OT_button_string_clear (wmOperatorType *ot)
 
Drop Color Operator
bool UI_drop_color_poll (bContext *C, wmDrag *drag, const wmEvent *)
 
void UI_drop_color_copy (bContext *, wmDrag *drag, wmDropBox *drop)
 
static int drop_color_invoke (bContext *C, wmOperator *op, const wmEvent *event)
 
static void UI_OT_drop_color (wmOperatorType *ot)
 
Drop Name Operator
static bool drop_name_poll (bContext *C)
 
static int drop_name_invoke (bContext *C, wmOperator *op, const wmEvent *)
 
static void UI_OT_drop_name (wmOperatorType *ot)
 
UI List Search Operator
static bool ui_list_focused_poll (bContext *C)
 
static bool ui_list_unhide_filter_options (uiList *list)
 
static int ui_list_start_filter_invoke (bContext *C, wmOperator *, const wmEvent *event)
 
static void UI_OT_list_start_filter (wmOperatorType *ot)
 
UI View Start Filter Operator
static AbstractViewget_view_focused (bContext *C)
 
static bool ui_view_focused_poll (bContext *C)
 
static int ui_view_start_filter_invoke (bContext *C, wmOperator *, const wmEvent *event)
 
static void UI_OT_view_start_filter (wmOperatorType *ot)
 
UI View Drop Operator
static bool ui_view_drop_poll (bContext *C)
 
static int ui_view_drop_invoke (bContext *C, wmOperator *, const wmEvent *event)
 
static void UI_OT_view_drop (wmOperatorType *ot)
 
static bool ui_view_scroll_poll (bContext *C)
 
static int ui_view_scroll_invoke (bContext *C, wmOperator *, const wmEvent *event)
 
static void UI_OT_view_scroll (wmOperatorType *ot)
 
UI View Item Rename Operator

General purpose renaming operator for views. Thanks to this, to add a rename button to context menus for example, view API users don't have to implement their own renaming operators with the same logic as they already have for their #ui::AbstractViewItem::rename() override.

static bool ui_view_item_rename_poll (bContext *C)
 
static int ui_view_item_rename_exec (bContext *C, wmOperator *)
 
static void UI_OT_view_item_rename (wmOperatorType *ot)
 
Material Drag/Drop Operator
static bool ui_drop_material_poll (bContext *C)
 
static int ui_drop_material_exec (bContext *C, wmOperator *op)
 
static void UI_OT_drop_material (wmOperatorType *ot)
 
Operator & Keymap Registration
void ED_operatortypes_ui ()
 
void ED_keymap_ui (wmKeyConfig *keyconf)
 User Interface Keymap.
 

Copy To Selected Operator

#define NOT_NULL(assignment)   ((assignment) != nullptr)
 
#define NOT_RNA_NULL(assignment)   ((assignment).data != nullptr)
 
static void ui_context_selected_bones_via_pose (bContext *C, blender::Vector< PointerRNA > *r_lb)
 
static void ui_context_fcurve_modifiers_via_fcurve (bContext *C, blender::Vector< PointerRNA > *r_lb, FModifier *source)
 
bool UI_context_copy_to_selected_list (bContext *C, PointerRNA *ptr, PropertyRNA *prop, blender::Vector< PointerRNA > *r_lb, bool *r_use_path_from_id, std::optional< std::string > *r_path)
 
bool UI_context_copy_to_selected_check (PointerRNA *ptr, PointerRNA *ptr_link, PropertyRNA *prop, const char *path, bool use_path_from_id, PointerRNA *r_ptr, PropertyRNA **r_prop)
 
static bool copy_to_selected_button (bContext *C, bool all, bool poll)
 
static bool copy_to_selected_button_poll (bContext *C)
 
static int copy_to_selected_button_exec (bContext *C, wmOperator *op)
 
static void UI_OT_copy_to_selected_button (wmOperatorType *ot)
 

Define Override Type Operator

enum  { UIOverride_Type_NOOP = 0 , UIOverride_Type_Replace = 1 , UIOverride_Type_Difference = 2 , UIOverride_Type_Factor = 3 }
 
static EnumPropertyItem override_type_items []
 
static bool override_type_set_button_poll (bContext *C)
 
static int override_type_set_button_exec (bContext *C, wmOperator *op)
 
static int override_type_set_button_invoke (bContext *C, wmOperator *op, const wmEvent *)
 
static void UI_OT_override_type_set_button (wmOperatorType *ot)
 
static bool override_remove_button_poll (bContext *C)
 
static int override_remove_button_exec (bContext *C, wmOperator *op)
 
static void UI_OT_override_remove_button (wmOperatorType *ot)
 
static void override_idtemplate_ids_get (bContext *C, ID **r_owner_id, ID **r_id, PointerRNA *r_owner_ptr, PropertyRNA **r_prop)
 
static bool override_idtemplate_poll (bContext *C, const bool is_create_op)
 
static bool override_idtemplate_make_poll (bContext *C)
 
static int override_idtemplate_make_exec (bContext *C, wmOperator *)
 
static void UI_OT_override_idtemplate_make (wmOperatorType *ot)
 
static bool override_idtemplate_reset_poll (bContext *C)
 
static int override_idtemplate_reset_exec (bContext *C, wmOperator *)
 
static void UI_OT_override_idtemplate_reset (wmOperatorType *ot)
 
static bool override_idtemplate_clear_poll (bContext *C)
 
static int override_idtemplate_clear_exec (bContext *C, wmOperator *)
 
static void UI_OT_override_idtemplate_clear (wmOperatorType *ot)
 
static bool override_idtemplate_menu_poll (const bContext *C_const, MenuType *)
 
static void override_idtemplate_menu_draw (const bContext *, Menu *menu)
 
static void override_idtemplate_menu ()
 

Macro Definition Documentation

◆ NOT_NULL

#define NOT_NULL ( assignment)    ((assignment) != nullptr)

Definition at line 1020 of file interface_ops.cc.

◆ NOT_RNA_NULL

#define NOT_RNA_NULL ( assignment)    ((assignment).data != nullptr)

Definition at line 1021 of file interface_ops.cc.

Referenced by UI_context_copy_to_selected_list().

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
UIOverride_Type_NOOP 
UIOverride_Type_Replace 
UIOverride_Type_Difference 
UIOverride_Type_Factor 

Definition at line 503 of file interface_ops.cc.

Function Documentation

◆ assign_default_button_exec()

◆ assign_default_button_poll()

◆ button_string_clear_exec()

static int button_string_clear_exec ( bContext * C,
wmOperator *  )
static

◆ copy_as_driver_button_exec()

◆ copy_as_driver_button_poll()

◆ copy_data_path_button_exec()

◆ copy_data_path_button_poll()

static bool copy_data_path_button_poll ( bContext * C)
static

◆ copy_driver_to_selected_button()

static bool copy_driver_to_selected_button ( bContext * C,
bool copy_entire_array,
const bool poll )
static

Called from both exec & poll.

Note
We use this function for both poll and exec because the logic for whether there is a valid selection to copy to is baked into UI_context_copy_to_selected_list(), and the setup required to call that would either be duplicated or need to be split out into its own awkward difficult-to-name function with a large number of parameters. So instead we follow the same pattern as copy_to_selected_button() further above, with a bool to switch between exec and poll behavior. This isn't great, but seems like the lesser evil under the circumstances.
Parameters
copy_entire_arrayIf true, copies drivers of all elements of an array property. Otherwise only copies one specific element.
pollIf true, only checks if the driver(s) could be copied rather than actually performing the copy.
Returns
true in exec mode if any copies were successfully made, and false otherwise. Returns true in poll mode if a copy could be successfully made, and false otherwise.

Definition at line 1723 of file interface_ops.cc.

References blender::Vector< T, InlineBufferCapacity, Allocator >::as_span(), PointerRNA::data, blender::Vector< T, InlineBufferCapacity, Allocator >::is_empty(), PointerRNA::owner_id, ptr, RNA_property_driver_editable(), RNA_property_update(), UI_context_active_but_prop_get(), UI_context_copy_to_selected_check(), and UI_context_copy_to_selected_list().

Referenced by copy_driver_to_selected_button_exec(), and copy_driver_to_selected_button_poll().

◆ copy_driver_to_selected_button_exec()

◆ copy_driver_to_selected_button_poll()

static bool copy_driver_to_selected_button_poll ( bContext * C)
static

Definition at line 1801 of file interface_ops.cc.

References copy_driver_to_selected_button().

Referenced by UI_OT_copy_driver_to_selected_button().

◆ copy_python_command_button_exec()

◆ copy_python_command_button_poll()

static bool copy_python_command_button_poll ( bContext * C)
static

Definition at line 260 of file interface_ops.cc.

References uiBut::optype, and UI_context_active_but_get().

Referenced by UI_OT_copy_python_command_button().

◆ copy_to_selected_button()

static bool copy_to_selected_button ( bContext * C,
bool all,
bool poll )
static

Called from both exec & poll.

Note
Normally we wouldn't call a loop from within a poll function, however this is a special case, and for regular poll calls, getting the context from the button will fail early.

Definition at line 1481 of file interface_ops.cc.

References CTX_data_main(), PointerRNA::data, ptr, RNA_property_copy(), RNA_property_update(), UI_context_active_but_prop_get(), UI_context_copy_to_selected_check(), and UI_context_copy_to_selected_list().

Referenced by copy_to_selected_button_exec(), and copy_to_selected_button_poll().

◆ copy_to_selected_button_exec()

static int copy_to_selected_button_exec ( bContext * C,
wmOperator * op )
static

◆ copy_to_selected_button_poll()

static bool copy_to_selected_button_poll ( bContext * C)
static

Definition at line 1532 of file interface_ops.cc.

References copy_to_selected_button().

Referenced by UI_OT_copy_to_selected_button().

◆ drop_color_invoke()

◆ drop_name_invoke()

static int drop_name_invoke ( bContext * C,
wmOperator * op,
const wmEvent *  )
static

◆ drop_name_poll()

static bool drop_name_poll ( bContext * C)
static

◆ ED_keymap_ui()

void ED_keymap_ui ( wmKeyConfig * keyconf)

◆ ED_operatortypes_ui()

◆ get_view_focused()

◆ jump_to_target_button()

static bool jump_to_target_button ( bContext * C,
bool poll )
static

Jump to the object or bone referred to by the current UI field value.

Note
quite heavy for a poll callback, but the operator is only used as a right click menu item for certain UI field types, and this will fail quickly if the context is completely unsuitable.

Definition at line 1915 of file interface_ops.cc.

References uiButSearch::arg, PointerRNA::data, uiButSearch::items_update_fn, jump_to_target_ptr(), MAXBONENAME, MEM_freeN(), PROP_POINTER, PROP_STRING, ptr, RNA_property_collection_lookup_string(), RNA_property_pointer_get(), RNA_property_string_get_alloc(), RNA_property_type(), uiRNACollectionSearch::search_prop, uiRNACollectionSearch::search_ptr, uiBut::type, UI_BTYPE_SEARCH_MENU, UI_context_active_but_prop_get(), and ui_rna_collection_search_update_fn().

Referenced by jump_to_target_button_exec(), and ui_jump_to_target_button_poll().

◆ jump_to_target_button_exec()

static int jump_to_target_button_exec ( bContext * C,
wmOperator *  )
static

◆ jump_to_target_ptr()

◆ operator_button_property_finish()

◆ operator_button_property_finish_with_undo()

static int operator_button_property_finish_with_undo ( bContext * C,
PointerRNA * ptr,
PropertyRNA * prop )
static

◆ override_idtemplate_clear_exec()

◆ override_idtemplate_clear_poll()

static bool override_idtemplate_clear_poll ( bContext * C)
static

Definition at line 898 of file interface_ops.cc.

References override_idtemplate_poll().

Referenced by UI_OT_override_idtemplate_clear().

◆ override_idtemplate_ids_get()

◆ override_idtemplate_make_exec()

◆ override_idtemplate_make_poll()

static bool override_idtemplate_make_poll ( bContext * C)
static

Definition at line 789 of file interface_ops.cc.

References override_idtemplate_poll().

Referenced by UI_OT_override_idtemplate_make().

◆ override_idtemplate_menu()

static void override_idtemplate_menu ( )
static

◆ override_idtemplate_menu_draw()

static void override_idtemplate_menu_draw ( const bContext * ,
Menu * menu )
static

Definition at line 994 of file interface_ops.cc.

References IFACE_, Menu::layout, and uiItemO().

Referenced by override_idtemplate_menu().

◆ override_idtemplate_menu_poll()

static bool override_idtemplate_menu_poll ( const bContext * C_const,
MenuType *  )
static

◆ override_idtemplate_poll()

static bool override_idtemplate_poll ( bContext * C,
const bool is_create_op )
static

◆ override_idtemplate_reset_exec()

◆ override_idtemplate_reset_poll()

static bool override_idtemplate_reset_poll ( bContext * C)
static

Definition at line 851 of file interface_ops.cc.

References override_idtemplate_poll().

Referenced by UI_OT_override_idtemplate_reset().

◆ override_remove_button_exec()

◆ override_remove_button_poll()

◆ override_type_set_button_exec()

◆ override_type_set_button_invoke()

static int override_type_set_button_invoke ( bContext * C,
wmOperator * op,
const wmEvent *  )
static

◆ override_type_set_button_poll()

static bool override_type_set_button_poll ( bContext * C)
static

◆ reloadtranslation_exec()

static int reloadtranslation_exec ( bContext * ,
wmOperator *  )
static

◆ reset_default_button_exec()

◆ reset_default_button_poll()

static bool reset_default_button_poll ( bContext * C)
static

◆ ui_button_press_invoke()

◆ UI_context_copy_to_selected_check()

◆ UI_context_copy_to_selected_list()

bool UI_context_copy_to_selected_list ( bContext * C,
PointerRNA * ptr,
PropertyRNA * prop,
blender::Vector< PointerRNA > * r_lb,
bool * r_use_path_from_id,
std::optional< std::string > * r_path )

◆ ui_context_fcurve_modifiers_via_fcurve()

◆ ui_context_selected_bones_via_pose()

◆ UI_drop_color_copy()

void UI_drop_color_copy ( bContext * C,
wmDrag * drag,
wmDropBox * drop )

◆ UI_drop_color_poll()

bool UI_drop_color_poll ( bContext * C,
wmDrag * drag,
const wmEvent * event )

◆ ui_drop_material_exec()

◆ ui_drop_material_poll()

static bool ui_drop_material_poll ( bContext * C)
static

◆ ui_jump_to_target_button_poll()

bool ui_jump_to_target_button_poll ( bContext * C)

◆ ui_list_focused_poll()

static bool ui_list_focused_poll ( bContext * C)
static

◆ ui_list_start_filter_invoke()

◆ ui_list_unhide_filter_options()

static bool ui_list_unhide_filter_options ( uiList * list)
static

Ensure the filter options are set to be visible in the UI list.

Returns
if the visibility changed, requiring a redraw.

Definition at line 2479 of file interface_ops.cc.

References UILST_FLT_SHOW.

Referenced by ui_list_start_filter_invoke().

◆ UI_OT_assign_default_button()

◆ UI_OT_button_execute()

◆ UI_OT_button_string_clear()

◆ UI_OT_copy_as_driver_button()

◆ UI_OT_copy_data_path_button()

◆ UI_OT_copy_driver_to_selected_button()

◆ UI_OT_copy_python_command_button()

◆ UI_OT_copy_to_selected_button()

◆ UI_OT_drop_color()

◆ UI_OT_drop_material()

◆ UI_OT_drop_name()

◆ UI_OT_jump_to_target_button()

◆ UI_OT_list_start_filter()

◆ UI_OT_override_idtemplate_clear()

◆ UI_OT_override_idtemplate_make()

◆ UI_OT_override_idtemplate_reset()

◆ UI_OT_override_remove_button()

◆ UI_OT_override_type_set_button()

◆ UI_OT_reloadtranslation()

static void UI_OT_reloadtranslation ( wmOperatorType * ot)
static

◆ UI_OT_reset_default_button()

◆ UI_OT_unset_property_button()

◆ UI_OT_view_drop()

◆ UI_OT_view_item_rename()

◆ UI_OT_view_scroll()

◆ UI_OT_view_start_filter()

◆ ui_region_redraw_immediately()

static void ui_region_redraw_immediately ( bContext * C,
ARegion * region )
static

◆ ui_view_drop_invoke()

◆ ui_view_drop_poll()

static bool ui_view_drop_poll ( bContext * C)
static

◆ ui_view_focused_poll()

static bool ui_view_focused_poll ( bContext * C)
static

Definition at line 2538 of file interface_ops.cc.

References get_view_focused().

Referenced by UI_OT_view_start_filter().

◆ ui_view_item_rename_exec()

static int ui_view_item_rename_exec ( bContext * C,
wmOperator *  )
static

◆ ui_view_item_rename_poll()

static bool ui_view_item_rename_poll ( bContext * C)
static

◆ ui_view_scroll_invoke()

◆ ui_view_scroll_poll()

static bool ui_view_scroll_poll ( bContext * C)
static

Definition at line 2625 of file interface_ops.cc.

References get_view_focused().

Referenced by UI_OT_view_scroll().

◆ ui_view_start_filter_invoke()

static int ui_view_start_filter_invoke ( bContext * C,
wmOperator * ,
const wmEvent * event )
static

◆ unset_property_button_exec()

Variable Documentation

◆ override_type_items

EnumPropertyItem override_type_items[]
static
Initial value:
= {
"NOOP",
0,
"NoOp",
"'No-Operation', place holder preventing automatic override to ever affect the property"},
"REPLACE",
0,
"Replace",
"Completely replace value from linked data by local one"},
"DIFFERENCE",
0,
"Difference",
"Store difference to linked data value"},
"FACTOR",
0,
"Factor",
"Store factor to linked data value (useful e.g. for scale)"},
{0, nullptr, 0, nullptr, nullptr},
}
@ UIOverride_Type_Replace
@ UIOverride_Type_Difference
@ UIOverride_Type_NOOP
@ UIOverride_Type_Factor

Definition at line 511 of file interface_ops.cc.

Referenced by UI_OT_override_type_set_button().