Blender  V3.3
interface_ops.c File Reference
#include <string.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 "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"
#include "ED_keyframing.h"
#include "BKE_main.h"
#include "BLI_ghash.h"
#include "ED_screen.h"
#include "ED_text.h"

Go to the source code of this file.

Functions

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 *UNUSED(op))
 
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 *UNUSED(op))
 
static void UI_OT_assign_default_button (wmOperatorType *ot)
 
Unset Property Button Operator
static int unset_property_button_exec (bContext *C, wmOperator *UNUSED(op))
 
static void UI_OT_unset_property_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 *UNUSED(op))
 
static void UI_OT_jump_to_target_button (wmOperatorType *ot)
 
Reload Translation Operator
static int reloadtranslation_exec (bContext *UNUSED(C), wmOperator *UNUSED(op))
 
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 *UNUSED(op))
 
static void UI_OT_button_string_clear (wmOperatorType *ot)
 
Drop Color Operator
bool UI_drop_color_poll (struct bContext *C, wmDrag *drag, const wmEvent *UNUSED(event))
 
void UI_drop_color_copy (bContext *UNUSED(C), 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 *UNUSED(event))
 
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 *UNUSED(op), const wmEvent *event)
 
static void UI_OT_list_start_filter (wmOperatorType *ot)
 
UI Tree-View Drop Operator
static bool ui_view_drop_poll (bContext *C)
 
static int ui_view_drop_invoke (bContext *C, wmOperator *UNUSED(op), const wmEvent *event)
 
static void UI_OT_view_drop (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 *UNUSED(op))
 
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)
 
void ED_keymap_ui (wmKeyConfig *keyconf)
 User Interface Keymap. More...
 

Copy To Selected Operator

#define NOT_NULL(assignment)   ((assignment) != NULL)
 
#define NOT_RNA_NULL(assignment)   ((assignment).data != NULL)
 
static void ui_context_selected_bones_via_pose (bContext *C, ListBase *r_lb)
 
bool UI_context_copy_to_selected_list (bContext *C, PointerRNA *ptr, PropertyRNA *prop, ListBase *r_lb, bool *r_use_path_from_id, char **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 *UNUSED(event))
 
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 *UNUSED(op))
 
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 *UNUSED(op))
 
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 *UNUSED(op))
 
static void UI_OT_override_idtemplate_clear (wmOperatorType *ot)
 
static bool override_idtemplate_menu_poll (const bContext *C_const, MenuType *UNUSED(mt))
 
static void override_idtemplate_menu_draw (const bContext *UNUSED(C), Menu *menu)
 
static void override_idtemplate_menu (void)
 

Macro Definition Documentation

◆ NOT_NULL

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

Definition at line 1033 of file interface_ops.c.

◆ NOT_RNA_NULL

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

Definition at line 1034 of file interface_ops.c.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
UIOverride_Type_NOOP 
UIOverride_Type_Replace 
UIOverride_Type_Difference 
UIOverride_Type_Factor 

Definition at line 506 of file interface_ops.c.

Function Documentation

◆ assign_default_button_exec()

static int assign_default_button_exec ( bContext C,
wmOperator UNUSEDop 
)
static

◆ assign_default_button_poll()

static bool assign_default_button_poll ( bContext C)
static

◆ button_string_clear_exec()

static int button_string_clear_exec ( bContext C,
wmOperator UNUSEDop 
)
static

◆ copy_as_driver_button_exec()

static int copy_as_driver_button_exec ( bContext C,
wmOperator op 
)
static

◆ copy_as_driver_button_poll()

static bool copy_as_driver_button_poll ( bContext C)
static

◆ copy_data_path_button_exec()

static int copy_data_path_button_exec ( bContext C,
wmOperator op 
)
static

◆ copy_data_path_button_poll()

static bool copy_data_path_button_poll ( bContext C)
static

◆ copy_python_command_button_exec()

static int copy_python_command_button_exec ( bContext C,
wmOperator UNUSEDop 
)
static

◆ copy_python_command_button_poll()

static bool copy_python_command_button_poll ( bContext C)
static

Definition at line 262 of file interface_ops.c.

References C, NULL, 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 1376 of file interface_ops.c.

References all(), BLI_freelistN(), BLI_listbase_is_empty(), C, CTX_data_main(), PointerRNA::data, LISTBASE_FOREACH, MEM_SAFE_FREE, NULL, 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 1430 of file interface_ops.c.

References C, and copy_to_selected_button().

Referenced by UI_OT_copy_to_selected_button().

◆ drop_color_invoke()

static int drop_color_invoke ( bContext C,
wmOperator op,
const wmEvent event 
)
static

◆ drop_name_invoke()

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

◆ drop_name_poll()

static bool drop_name_poll ( bContext C)
static

◆ ED_keymap_ui()

void ED_keymap_ui ( wmKeyConfig keyconf)

User Interface Keymap.

Definition at line 2546 of file interface_ops.c.

References eyedropper_colorband_modal_keymap(), eyedropper_modal_keymap(), and WM_keymap_ensure().

Referenced by ED_spacetypes_keymap().

◆ ED_operatortypes_ui()

void ED_operatortypes_ui ( void  )

◆ 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 1539 of file interface_ops.c.

References uiButSearch::arg, C, PointerRNA::data, uiButSearch::items_update_fn, jump_to_target_ptr(), MAXBONENAME, MEM_freeN, NULL, 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, type, UI_BTYPE_SEARCH_MENU, UI_context_active_but_get(), 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 UNUSEDop 
)
static

◆ jump_to_target_ptr()

static bool jump_to_target_ptr ( bContext C,
PointerRNA  ptr,
const bool  poll 
)
static

◆ operator_button_property_finish()

static int operator_button_property_finish ( bContext C,
PointerRNA ptr,
PropertyRNA prop 
)
static

◆ 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()

static int override_idtemplate_clear_exec ( bContext C,
wmOperator UNUSEDop 
)
static

◆ override_idtemplate_clear_poll()

static bool override_idtemplate_clear_poll ( bContext C)
static

Definition at line 912 of file interface_ops.c.

References C, and override_idtemplate_poll().

Referenced by UI_OT_override_idtemplate_clear().

◆ override_idtemplate_ids_get()

static void override_idtemplate_ids_get ( bContext C,
ID **  r_owner_id,
ID **  r_id,
PointerRNA r_owner_ptr,
PropertyRNA **  r_prop 
)
static

◆ override_idtemplate_make_exec()

static int override_idtemplate_make_exec ( bContext C,
wmOperator UNUSEDop 
)
static

◆ override_idtemplate_make_poll()

static bool override_idtemplate_make_poll ( bContext C)
static

Definition at line 801 of file interface_ops.c.

References C, and override_idtemplate_poll().

Referenced by UI_OT_override_idtemplate_make().

◆ override_idtemplate_menu()

static void override_idtemplate_menu ( void  )
static

◆ override_idtemplate_menu_draw()

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

Definition at line 1007 of file interface_ops.c.

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 UNUSEDmt 
)
static

◆ override_idtemplate_poll()

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

◆ override_idtemplate_reset_exec()

static int override_idtemplate_reset_exec ( bContext C,
wmOperator UNUSEDop 
)
static

◆ override_idtemplate_reset_poll()

static bool override_idtemplate_reset_poll ( bContext C)
static

Definition at line 864 of file interface_ops.c.

References C, and override_idtemplate_poll().

Referenced by UI_OT_override_idtemplate_reset().

◆ override_remove_button_exec()

static int override_remove_button_exec ( bContext C,
wmOperator op 
)
static

◆ override_remove_button_poll()

static bool override_remove_button_poll ( bContext C)
static

◆ override_type_set_button_exec()

static int override_type_set_button_exec ( bContext C,
wmOperator op 
)
static

◆ override_type_set_button_invoke()

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

◆ override_type_set_button_poll()

static bool override_type_set_button_poll ( bContext C)
static

◆ reloadtranslation_exec()

static int reloadtranslation_exec ( bContext UNUSEDC,
wmOperator UNUSEDop 
)
static

◆ reset_default_button_exec()

static int reset_default_button_exec ( bContext C,
wmOperator op 
)
static

◆ reset_default_button_poll()

static bool reset_default_button_poll ( bContext C)
static

◆ ui_button_press_invoke()

static int ui_button_press_invoke ( bContext C,
wmOperator op,
const wmEvent event 
)
static

◆ UI_context_copy_to_selected_check()

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 
)

◆ UI_context_copy_to_selected_list()

bool UI_context_copy_to_selected_list ( bContext C,
PointerRNA ptr,
PropertyRNA prop,
ListBase r_lb,
bool r_use_path_from_id,
char **  r_path 
)

◆ ui_context_selected_bones_via_pose()

static void ui_context_selected_bones_via_pose ( bContext C,
ListBase r_lb 
)
static

◆ UI_drop_color_copy()

void UI_drop_color_copy ( bContext UNUSEDC,
wmDrag drag,
wmDropBox drop 
)

◆ UI_drop_color_poll()

bool UI_drop_color_poll ( struct bContext C,
wmDrag drag,
const wmEvent UNUSEDevent 
)

◆ ui_drop_material_exec()

static int ui_drop_material_exec ( bContext C,
wmOperator op 
)
static

◆ 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)

Definition at line 1591 of file interface_ops.c.

References C, and jump_to_target_button().

Referenced by UI_OT_jump_to_target_button(), and ui_popup_context_menu_for_button().

◆ ui_list_focused_poll()

static bool ui_list_focused_poll ( bContext C)
static

◆ ui_list_start_filter_invoke()

static int ui_list_start_filter_invoke ( bContext C,
wmOperator UNUSEDop,
const wmEvent event 
)
static

◆ 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 2298 of file interface_ops.c.

References uiList::filter_flag, and UILST_FLT_SHOW.

Referenced by ui_list_start_filter_invoke().

◆ UI_OT_assign_default_button()

static void UI_OT_assign_default_button ( wmOperatorType ot)
static

◆ UI_OT_button_execute()

static void UI_OT_button_execute ( wmOperatorType ot)
static

◆ UI_OT_button_string_clear()

static void UI_OT_button_string_clear ( wmOperatorType ot)
static

◆ UI_OT_copy_as_driver_button()

static void UI_OT_copy_as_driver_button ( wmOperatorType ot)
static

◆ UI_OT_copy_data_path_button()

static void UI_OT_copy_data_path_button ( wmOperatorType ot)
static

◆ UI_OT_copy_python_command_button()

static void UI_OT_copy_python_command_button ( wmOperatorType ot)
static

◆ UI_OT_copy_to_selected_button()

static void UI_OT_copy_to_selected_button ( wmOperatorType ot)
static

◆ UI_OT_drop_color()

static void UI_OT_drop_color ( wmOperatorType ot)
static

◆ UI_OT_drop_material()

static void UI_OT_drop_material ( wmOperatorType ot)
static

◆ UI_OT_drop_name()

static void UI_OT_drop_name ( wmOperatorType ot)
static

◆ UI_OT_jump_to_target_button()

static void UI_OT_jump_to_target_button ( wmOperatorType ot)
static

◆ UI_OT_list_start_filter()

static void UI_OT_list_start_filter ( wmOperatorType ot)
static

◆ UI_OT_override_idtemplate_clear()

static void UI_OT_override_idtemplate_clear ( wmOperatorType ot)
static

◆ UI_OT_override_idtemplate_make()

static void UI_OT_override_idtemplate_make ( wmOperatorType ot)
static

◆ UI_OT_override_idtemplate_reset()

static void UI_OT_override_idtemplate_reset ( wmOperatorType ot)
static

◆ UI_OT_override_remove_button()

static void UI_OT_override_remove_button ( wmOperatorType ot)
static

◆ UI_OT_override_type_set_button()

static void UI_OT_override_type_set_button ( wmOperatorType ot)
static

◆ UI_OT_reloadtranslation()

static void UI_OT_reloadtranslation ( wmOperatorType ot)
static

◆ UI_OT_reset_default_button()

static void UI_OT_reset_default_button ( wmOperatorType ot)
static

◆ UI_OT_unset_property_button()

static void UI_OT_unset_property_button ( wmOperatorType ot)
static

◆ UI_OT_view_drop()

static void UI_OT_view_drop ( wmOperatorType ot)
static

◆ UI_OT_view_item_rename()

static void UI_OT_view_item_rename ( wmOperatorType ot)
static

◆ ui_region_redraw_immediately()

static void ui_region_redraw_immediately ( bContext C,
ARegion region 
)
static

◆ ui_view_drop_invoke()

static int ui_view_drop_invoke ( bContext C,
wmOperator UNUSEDop,
const wmEvent event 
)
static

◆ ui_view_drop_poll()

static bool ui_view_drop_poll ( bContext C)
static

◆ ui_view_item_rename_exec()

static int ui_view_item_rename_exec ( bContext C,
wmOperator UNUSEDop 
)
static

◆ ui_view_item_rename_poll()

static bool ui_view_item_rename_poll ( bContext C)
static

◆ unset_property_button_exec()

static int unset_property_button_exec ( bContext C,
wmOperator UNUSEDop 
)
static

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, NULL, 0, NULL, NULL},
}
@ UIOverride_Type_Replace
@ UIOverride_Type_Difference
@ UIOverride_Type_NOOP
@ UIOverride_Type_Factor

Definition at line 514 of file interface_ops.c.

Referenced by UI_OT_override_type_set_button().