Blender V4.3
wm_operator_utils.cc File Reference
#include <cmath>
#include "BLI_array.hh"
#include "BLI_string.h"
#include "BLI_utildefines.h"
#include "BKE_context.hh"
#include "BKE_global.hh"
#include "BKE_layer.hh"
#include "RNA_access.hh"
#include "RNA_define.hh"
#include "WM_api.hh"
#include "WM_types.hh"
#include "MEM_guardedalloc.h"
#include "ED_object.hh"
#include "ED_screen.hh"

Go to the source code of this file.

Classes

struct  ValueInteraction
 
struct  ObCustomData_ForEditMode
 

Functions

Generic Utilities
int WM_operator_flag_only_pass_through_on_press (int retval, const wmEvent *event)
 
Value Interaction Helper

Possible additions (add as needed).

  • Int support.
  • Configurable motion (x/y).
static void interactive_value_init (bContext *C, ValueInteraction *inter, const wmEvent *event, const float value_final, const float range[2])
 
static void interactive_value_init_from_property (bContext *C, ValueInteraction *inter, const wmEvent *event, PointerRNA *ptr, PropertyRNA *prop)
 
static void interactive_value_exit (ValueInteraction *inter)
 
static bool interactive_value_update (ValueInteraction *inter, const wmEvent *event, float *r_value_final)
 
Object Edit Mode Coords (Modal Callbacks)
Note
We could support object mode coords too, it's just not needed at the moment.
static void op_generic_value_exit (wmOperator *op)
 
static void op_generic_value_restore (wmOperator *op)
 
static void op_generic_value_cancel (bContext *, wmOperator *op)
 
static int op_generic_value_invoke (bContext *C, wmOperator *op, const wmEvent *event)
 
static int op_generic_value_modal (bContext *C, wmOperator *op, const wmEvent *event)
 
void WM_operator_type_modal_from_exec_for_object_edit_coords (wmOperatorType *ot)
 

Detailed Description

Utilities for Implementing Operators

Definition in file wm_operator_utils.cc.

Function Documentation

◆ interactive_value_exit()

static void interactive_value_exit ( ValueInteraction * inter)
static

◆ interactive_value_init()

◆ interactive_value_init_from_property()

static void interactive_value_init_from_property ( bContext * C,
ValueInteraction * inter,
const wmEvent * event,
PointerRNA * ptr,
PropertyRNA * prop )
static

◆ interactive_value_update()

◆ op_generic_value_cancel()

static void op_generic_value_cancel ( bContext * ,
wmOperator * op )
static

◆ op_generic_value_exit()

◆ op_generic_value_invoke()

◆ op_generic_value_modal()

◆ op_generic_value_restore()

◆ WM_operator_flag_only_pass_through_on_press()

int WM_operator_flag_only_pass_through_on_press ( int retval,
const wmEvent * event )

Indented for use in a selection (picking) operators wmOperatorType::invoke callback to implement click-drag, where the initial click selects and the drag action grabs or performs box-select (for example).

  • In this case, returning OPERATOR_FINISHED causes the PRESS event to be handled and prevents further CLICK (on release) or DRAG (on cursor motion) from being generated & handled.
  • Returning OPERATOR_FINISHED | OPERATOR_PASS_THROUGH allows for CLICK/DRAG but only makes sense if the event's value is PRESS. If the operator was already mapped to a CLICK/DRAG event, a single CLICK/DRAG could invoke multiple operators.

This function handles the details of checking the operator return value, clearing OPERATOR_PASS_THROUGH when the wmEvent::val is not KM_PRESS.

Note
Combining selection with other actions should only be used in situations where selecting doesn't change the visibility of other items. Since it means for example click-drag to box select could hide-show elements the user intended to box-select. In this case it's preferred to select on CLICK instead of PRESS (see the Outliner use of click-drag).

Definition at line 39 of file wm_operator_utils.cc.

References BLI_assert, KM_PRESS, OPERATOR_CANCELLED, OPERATOR_FINISHED, OPERATOR_PASS_THROUGH, and wmEvent::val.

Referenced by add_vertex_invoke(), animchannels_mouseclick_invoke(), armature_click_extrude_invoke(), edbm_dupli_extrude_cursor_invoke(), blender::ed::space_node::node_select_invoke(), select_invoke(), sequencer_select_invoke(), uv_select_edge_ring_invoke(), uv_select_invoke(), uv_select_loop_invoke(), and view3d_select_invoke().

◆ WM_operator_type_modal_from_exec_for_object_edit_coords()

void WM_operator_type_modal_from_exec_for_object_edit_coords ( wmOperatorType * ot)

Allow an operator with only and execute function to run modally, re-doing the action, using vertex coordinate store/restore instead of operator undo.

Definition at line 327 of file wm_operator_utils.cc.

References BLI_assert, wmOperatorType::cancel, wmOperatorType::invoke, wmOperatorType::modal, op_generic_value_cancel(), op_generic_value_invoke(), op_generic_value_modal(), ot, wmOperatorType::prop, PROP_HIDDEN, PROP_SKIP_SAVE, RNA_def_boolean(), RNA_def_property_flag(), and wmOperatorType::srna.

Referenced by MESH_OT_vertices_smooth(), and blender::ed::object::TRANSFORM_OT_vertex_random().