Blender V4.3
wm_toolsystem.cc File Reference
#include <cstring>
#include "CLG_log.h"
#include "MEM_guardedalloc.h"
#include "BLI_listbase.h"
#include "BLI_string.h"
#include "BLI_utildefines.h"
#include "DNA_ID.h"
#include "DNA_brush_types.h"
#include "DNA_object_types.h"
#include "DNA_scene_types.h"
#include "DNA_space_types.h"
#include "DNA_windowmanager_types.h"
#include "DNA_workspace_types.h"
#include "BKE_asset_edit.hh"
#include "BKE_brush.hh"
#include "BKE_context.hh"
#include "BKE_idprop.hh"
#include "BKE_layer.hh"
#include "BKE_lib_id.hh"
#include "BKE_main.hh"
#include "BKE_paint.hh"
#include "BKE_workspace.hh"
#include "RNA_access.hh"
#include "RNA_enum_types.hh"
#include "WM_api.hh"
#include "WM_message.hh"
#include "WM_toolsystem.hh"
#include "WM_types.hh"

Go to the source code of this file.

Functions

static void toolsystem_reinit_with_toolref (bContext *C, WorkSpace *, bToolRef *tref)
 
static bToolReftoolsystem_reinit_ensure_toolref (bContext *C, WorkSpace *workspace, const bToolKey *tkey, const char *default_tool)
 
static void toolsystem_refresh_screen_from_active_tool (Main *bmain, WorkSpace *workspace, bToolRef *tref)
 
static void toolsystem_ref_set_by_brush_type (bContext *C, const char *brush_type)
 
static void toolsystem_unlink_ref (bContext *C, WorkSpace *, bToolRef *tref)
 
void WM_toolsystem_unlink (bContext *C, WorkSpace *workspace, const bToolKey *tkey)
 
static void toolsystem_ref_link (const bContext *C, WorkSpace *workspace, bToolRef *tref)
 
static void toolsystem_refresh_ref (const bContext *C, WorkSpace *workspace, bToolRef *tref)
 
void WM_toolsystem_refresh (const bContext *C, WorkSpace *workspace, const bToolKey *tkey)
 
static void toolsystem_reinit_ref (bContext *C, WorkSpace *workspace, bToolRef *tref)
 
void WM_toolsystem_reinit (bContext *C, WorkSpace *workspace, const bToolKey *tkey)
 
void WM_toolsystem_unlink_all (bContext *C, WorkSpace *workspace)
 
void WM_toolsystem_refresh_all (const bContext *C, WorkSpace *workspace)
 
void WM_toolsystem_reinit_all (bContext *C, wmWindow *win)
 
void WM_toolsystem_ref_set_from_runtime (bContext *C, WorkSpace *workspace, bToolRef *tref, const bToolRef_Runtime *tref_rt, const char *idname)
 
void WM_toolsystem_ref_sync_from_context (Main *bmain, WorkSpace *workspace, bToolRef *tref)
 
void WM_toolsystem_init (const bContext *C)
 
static bool toolsystem_key_ensure_check (const bToolKey *tkey)
 
int WM_toolsystem_mode_from_spacetype (const Scene *scene, ViewLayer *view_layer, ScrArea *area, int space_type)
 
bool WM_toolsystem_key_from_context (const Scene *scene, ViewLayer *view_layer, ScrArea *area, bToolKey *tkey)
 
void WM_toolsystem_refresh_active (bContext *C)
 
bool WM_toolsystem_refresh_screen_area (WorkSpace *workspace, const Scene *scene, ViewLayer *view_layer, ScrArea *area)
 
void WM_toolsystem_refresh_screen_window (wmWindow *win)
 
void WM_toolsystem_refresh_screen_all (Main *bmain)
 
bToolRefWM_toolsystem_ref_set_by_id_ex (bContext *C, WorkSpace *workspace, const bToolKey *tkey, const char *name, bool cycle)
 
bToolRefWM_toolsystem_ref_set_by_id (bContext *C, const char *name)
 
static const char * toolsystem_default_tool (const bToolKey *tkey)
 
static void wm_toolsystem_update_from_context_view3d_impl (bContext *C, WorkSpace *workspace)
 
void WM_toolsystem_update_from_context_view3d (bContext *C)
 
void WM_toolsystem_update_from_context (bContext *C, WorkSpace *workspace, const Scene *scene, ViewLayer *view_layer, ScrArea *area)
 
bool WM_toolsystem_active_tool_is_brush (const bContext *C)
 
bool WM_toolsystem_active_tool_has_custom_cursor (const bContext *C)
 
void WM_toolsystem_do_msg_notify_tag_refresh (bContext *C, wmMsgSubscribeKey *, wmMsgSubscribeValue *msg_val)
 
static IDPropertyidprops_ensure_named_group (IDProperty *group, const char *idname)
 
IDPropertyWM_toolsystem_ref_properties_get_idprops (bToolRef *tref)
 
IDPropertyWM_toolsystem_ref_properties_ensure_idprops (bToolRef *tref)
 
bool WM_toolsystem_ref_properties_get_ex (bToolRef *tref, const char *idname, StructRNA *type, PointerRNA *r_ptr)
 
void WM_toolsystem_ref_properties_ensure_ex (bToolRef *tref, const char *idname, StructRNA *type, PointerRNA *r_ptr)
 
void WM_toolsystem_ref_properties_init_for_keymap (bToolRef *tref, PointerRNA *dst_ptr, PointerRNA *src_ptr, wmOperatorType *ot)
 
Tool Reference API
bToolRefWM_toolsystem_ref_from_context (const bContext *C)
 
bToolRef_RuntimeWM_toolsystem_runtime_from_context (const bContext *C)
 
bToolRefWM_toolsystem_ref_find (WorkSpace *workspace, const bToolKey *tkey)
 
bToolRef_RuntimeWM_toolsystem_runtime_find (WorkSpace *workspace, const bToolKey *tkey)
 
bool WM_toolsystem_ref_ensure (WorkSpace *workspace, const bToolKey *tkey, bToolRef **r_tref)
 
static bToolKey toolsystem_key_from_context_or_view3d (const Scene *scene, ViewLayer *view_layer, ScrArea *area)
 
static const bToolReftoolsystem_active_tool_from_context_or_view3d (const bContext *C)
 
Brush Tools
static const char * brush_type_identifier_get (const int brush_type, const PaintMode paint_mode)
 
static bool brush_type_matches_active_tool (bContext *C, const int brush_type)
 
static NamedBrushAssetReferencetoolsystem_brush_type_binding_lookup (const Paint *paint, const char *brush_type_name)
 
static void toolsystem_main_brush_binding_update_from_active (Paint *paint)
 
static void toolsystem_brush_type_binding_update (Paint *paint, const PaintMode paint_mode, const int brush_type)
 
bool WM_toolsystem_activate_brush_and_tool (bContext *C, Paint *paint, Brush *brush)
 
static void toolsystem_brush_activate_from_toolref_for_object_particle (const bContext *C, const WorkSpace *workspace, const bToolRef *tref)
 
static void toolsystem_brush_activate_from_toolref_for_object_paint (const bContext *C, const WorkSpace *workspace, const bToolRef *tref)
 
static void toolsystem_brush_activate_from_toolref (const bContext *C, const WorkSpace *workspace, const bToolRef *tref)
 

Detailed Description

Experimental tool-system>

Definition in file wm_toolsystem.cc.

Function Documentation

◆ brush_type_identifier_get()

static const char * brush_type_identifier_get ( const int brush_type,
const PaintMode paint_mode )
static

◆ brush_type_matches_active_tool()

◆ idprops_ensure_named_group()

◆ toolsystem_active_tool_from_context_or_view3d()

static const bToolRef * toolsystem_active_tool_from_context_or_view3d ( const bContext * C)
static

Get the active tool for the current context (space and mode) if the current space supports tools or, fallback to the active tool of the 3D View in the current mode.

Use this instead of WM_toolsystem_ref_from_context() when usage from properties editors should be possible, which shows tool settings of the 3D View.

Definition at line 150 of file wm_toolsystem.cc.

References CTX_data_scene(), CTX_data_view_layer(), CTX_wm_area(), CTX_wm_workspace(), bToolKey::space_type, SPACE_VIEW3D, WM_toolsystem_mode_from_spacetype(), WM_toolsystem_ref_find(), WM_toolsystem_ref_from_context(), and WM_TOOLSYSTEM_SPACE_MASK.

Referenced by brush_type_matches_active_tool(), and WM_toolsystem_activate_brush_and_tool().

◆ toolsystem_brush_activate_from_toolref()

static void toolsystem_brush_activate_from_toolref ( const bContext * C,
const WorkSpace * workspace,
const bToolRef * tref )
static

◆ toolsystem_brush_activate_from_toolref_for_object_paint()

◆ toolsystem_brush_activate_from_toolref_for_object_particle()

◆ toolsystem_brush_type_binding_lookup()

static NamedBrushAssetReference * toolsystem_brush_type_binding_lookup ( const Paint * paint,
const char * brush_type_name )
static

◆ toolsystem_brush_type_binding_update()

◆ toolsystem_default_tool()

◆ toolsystem_key_ensure_check()

static bool toolsystem_key_ensure_check ( const bToolKey * tkey)
static

◆ toolsystem_key_from_context_or_view3d()

static bToolKey toolsystem_key_from_context_or_view3d ( const Scene * scene,
ViewLayer * view_layer,
ScrArea * area )
static

◆ toolsystem_main_brush_binding_update_from_active()

static void toolsystem_main_brush_binding_update_from_active ( Paint * paint)
static

◆ toolsystem_ref_link()

◆ toolsystem_ref_set_by_brush_type()

◆ toolsystem_refresh_ref()

static void toolsystem_refresh_ref ( const bContext * C,
WorkSpace * workspace,
bToolRef * tref )
static

◆ toolsystem_refresh_screen_from_active_tool()

◆ toolsystem_reinit_ensure_toolref()

static bToolRef * toolsystem_reinit_ensure_toolref ( bContext * C,
WorkSpace * workspace,
const bToolKey * tkey,
const char * default_tool )
static

◆ toolsystem_reinit_ref()

static void toolsystem_reinit_ref ( bContext * C,
WorkSpace * workspace,
bToolRef * tref )
static

Definition at line 473 of file wm_toolsystem.cc.

References toolsystem_reinit_with_toolref().

Referenced by WM_toolsystem_reinit(), and WM_toolsystem_reinit_all().

◆ toolsystem_reinit_with_toolref()

static void toolsystem_reinit_with_toolref ( bContext * C,
WorkSpace * workspace,
bToolRef * tref )
static

◆ toolsystem_unlink_ref()

◆ WM_toolsystem_activate_brush_and_tool()

bool WM_toolsystem_activate_brush_and_tool ( bContext * C,
Paint * paint,
Brush * brush )

Activate the brush through the tool system. This will call BKE_paint_brush_set() with brush, but it will also switch to the tool appropriate for this brush type (if necessary) and update the current tool-brush references to remember the last used brush for that tool.

Returns
True if the brush was successfully activated.

Definition at line 277 of file wm_toolsystem.cc.

References BKE_paint_brush_poll(), BKE_paint_brush_set(), BKE_paint_get_brush_type_from_paintmode(), BKE_paintmode_get_active_from_context(), BLI_assert_unreachable, bToolRef_Runtime::brush_type, brush_type_identifier_get(), brush_type_matches_active_tool(), bToolRef::runtime, toolsystem_active_tool_from_context_or_view3d(), toolsystem_brush_type_binding_update(), toolsystem_main_brush_binding_update_from_active(), toolsystem_ref_set_by_brush_type(), and WM_toolsystem_ref_set_by_id().

Referenced by blender::ed::sculpt_paint::brush_asset_activate_exec(), and blender::ed::sculpt_paint::brush_asset_save_as_exec().

◆ WM_toolsystem_active_tool_has_custom_cursor()

bool WM_toolsystem_active_tool_has_custom_cursor ( const bContext * C)

◆ WM_toolsystem_active_tool_is_brush()

◆ WM_toolsystem_do_msg_notify_tag_refresh()

◆ WM_toolsystem_init()

void WM_toolsystem_init ( const bContext * C)

◆ WM_toolsystem_key_from_context()

bool WM_toolsystem_key_from_context ( const Scene * scene,
ViewLayer * view_layer,
ScrArea * area,
bToolKey * tkey )

◆ WM_toolsystem_mode_from_spacetype()

◆ WM_toolsystem_ref_ensure()

bool WM_toolsystem_ref_ensure ( WorkSpace * workspace,
const bToolKey * tkey,
bToolRef ** r_tref )

◆ WM_toolsystem_ref_find()

◆ WM_toolsystem_ref_from_context()

◆ WM_toolsystem_ref_properties_ensure_ex()

void WM_toolsystem_ref_properties_ensure_ex ( bToolRef * tref,
const char * idname,
StructRNA * type,
PointerRNA * r_ptr )

◆ WM_toolsystem_ref_properties_ensure_idprops()

IDProperty * WM_toolsystem_ref_properties_ensure_idprops ( bToolRef * tref)

◆ WM_toolsystem_ref_properties_get_ex()

bool WM_toolsystem_ref_properties_get_ex ( bToolRef * tref,
const char * idname,
StructRNA * type,
PointerRNA * r_ptr )

◆ WM_toolsystem_ref_properties_get_idprops()

IDProperty * WM_toolsystem_ref_properties_get_idprops ( bToolRef * tref)

◆ WM_toolsystem_ref_properties_init_for_keymap()

◆ WM_toolsystem_ref_set_by_id()

◆ WM_toolsystem_ref_set_by_id_ex()

◆ WM_toolsystem_ref_set_from_runtime()

◆ WM_toolsystem_ref_sync_from_context()

◆ WM_toolsystem_refresh()

void WM_toolsystem_refresh ( const bContext * C,
WorkSpace * workspace,
const bToolKey * tkey )

◆ WM_toolsystem_refresh_active()

void WM_toolsystem_refresh_active ( bContext * C)

◆ WM_toolsystem_refresh_all()

void WM_toolsystem_refresh_all ( const bContext * C,
WorkSpace * workspace )

◆ WM_toolsystem_refresh_screen_all()

void WM_toolsystem_refresh_screen_all ( Main * bmain)

◆ WM_toolsystem_refresh_screen_area()

bool WM_toolsystem_refresh_screen_area ( WorkSpace * workspace,
const Scene * scene,
ViewLayer * view_layer,
ScrArea * area )

◆ WM_toolsystem_refresh_screen_window()

◆ WM_toolsystem_reinit()

void WM_toolsystem_reinit ( bContext * C,
WorkSpace * workspace,
const bToolKey * tkey )

Definition at line 477 of file wm_toolsystem.cc.

References toolsystem_reinit_ref(), and WM_toolsystem_ref_find().

◆ WM_toolsystem_reinit_all()

◆ WM_toolsystem_runtime_find()

bToolRef_Runtime * WM_toolsystem_runtime_find ( WorkSpace * workspace,
const bToolKey * tkey )

Definition at line 101 of file wm_toolsystem.cc.

References bToolRef::runtime, and WM_toolsystem_ref_find().

◆ WM_toolsystem_runtime_from_context()

◆ WM_toolsystem_unlink()

void WM_toolsystem_unlink ( bContext * C,
WorkSpace * workspace,
const bToolKey * tkey )

◆ WM_toolsystem_unlink_all()

void WM_toolsystem_unlink_all ( bContext * C,
WorkSpace * workspace )

Operate on all active tools.

Definition at line 485 of file wm_toolsystem.cc.

References LISTBASE_FOREACH, WorkSpace::tools, and toolsystem_unlink_ref().

◆ WM_toolsystem_update_from_context()

void WM_toolsystem_update_from_context ( bContext * C,
WorkSpace * workspace,
const Scene * scene,
ViewLayer * view_layer,
ScrArea * area )

◆ WM_toolsystem_update_from_context_view3d()

◆ wm_toolsystem_update_from_context_view3d_impl()

static void wm_toolsystem_update_from_context_view3d_impl ( bContext * C,
WorkSpace * workspace )
static