63 const char *default_tool);
71 const char *idname_pending);
80 if (workspace ==
nullptr) {
104 return tref ? tref->
runtime :
nullptr;
121 return tref ? tref->
runtime :
nullptr;
131 tref = MEM_new<bToolRef>(__func__);
178 if (workspace ==
nullptr) {
198 if (gzgt !=
nullptr) {
220 if (item_idx == -1) {
229 if (active_tool ==
nullptr || active_tool->
runtime ==
nullptr) {
244 const char *brush_type_name)
257 MEM_delete(
paint->tool_brush_bindings.main_brush_asset_reference);
258 paint->tool_brush_bindings.main_brush_asset_reference =
nullptr;
260 if (
paint->brush !=
nullptr) {
261 if (std::optional<AssetWeakReference> brush_asset_reference =
264 paint->tool_brush_bindings.main_brush_asset_reference = MEM_new<AssetWeakReference>(
265 __func__, *brush_asset_reference);
272 const int brush_type)
274 if (
paint->brush ==
nullptr) {
278 if (!brush_type_name || !brush_type_name[0]) {
284 paint, brush_type_name))
286 MEM_delete(existing_brush_ref->brush_asset_reference);
287 existing_brush_ref->brush_asset_reference = MEM_new<AssetWeakReference>(
288 __func__, *
paint->brush_asset_reference);
296 __func__, *
paint->brush_asset_reference);
297 BLI_addhead(&
paint->tool_brush_bindings.active_brush_per_brush_type, new_brush_ref);
331 if (active_tool ==
nullptr || active_tool->
runtime ==
nullptr) {
380 if (brush_type != -1) {
383 paint, brush_type_name);
391 if (
paint->tool_brush_bindings.main_brush_asset_reference) {
392 return *
paint->tool_brush_bindings.main_brush_asset_reference;
417 if (std::optional<AssetWeakReference> brush_asset_reference =
511 if (gzgt !=
nullptr) {
537 if (tref->
runtime ==
nullptr) {
601 *bmain, scene, view_layer, &area, area.
spacetype);
604 if (tref->
tag == 0) {
633 if (tref->
runtime ==
nullptr) {
634 tref->
runtime = MEM_new<bToolRef_Runtime>(__func__);
637 if (tref_rt != tref->
runtime) {
643 bool use_fallback_keymap =
false;
647 use_fallback_keymap =
true;
653 use_fallback_keymap =
true;
658 if (use_fallback_keymap ==
false) {
670 if (win !=
nullptr) {
685 if ((tref_rt ==
nullptr) || (tref_rt->
data_block[0] ==
'\0')) {
753 switch (space_type) {
758 if (obact !=
nullptr) {
791 if (area !=
nullptr) {
813 } context_prev = {
nullptr};
824 int space_type_mask_handled = 0;
827 const int space_type_mask = (1 << area.
spacetype);
829 ((space_type_mask_handled & space_type_mask) == 0))
831 space_type_mask_handled |= space_type_mask;
835 *bmain, scene, view_layer, &area, area.
spacetype);
838 if (context_prev.is_set ==
false) {
842 context_prev.is_set =
true;
855 if (context_prev.is_set) {
888 bmain, scene, view_layer, area, area->
spacetype);
891 if (tref.
mode == mode) {
897 return !(is_tool_set_prev && (tref_prev == area->
runtime.
tool));
913 if (space_type_has_tools[area.
spacetype]) {
947 *bmain, scene, view_layer, &area, area.
spacetype);
948 if (mode == tref->
mode) {
996 return (tref &&
STREQ(tref->
idname, name)) ? tref :
nullptr;
1024 if (ot ==
nullptr) {
1065 const char *idname_pending)
1070 const bool this_match =
STREQ(idname_pending, tref->
idname);
1122 switch (tkey->
mode) {
1136 return "builtin.brush";
1138 return "builtin_brush.Comb";
1140 return "builtin.select_text";
1144 switch (tkey->
mode) {
1146 return "builtin.brush";
1148 return "builtin.sample";
1150 return "builtin.select_box";
1154 return "builtin.select_box";
1157 return "builtin.select_box";
1161 return "builtin.select_box";
1170 const char *default_tool)
1174 if (default_tool ==
nullptr) {
1205 if (!
wm->windows.is_single()) {
1211 if (&win != win_prev) {
1213 if (workspace_iter != workspace) {
1258 wmWindow *win = bmain->
wm.first()->windows.first();
1259 if (win->
next !=
nullptr) {
1265 }
while ((win = win->
next));
1293 if (group ==
nullptr) {
1315 return (prop !=
nullptr);
1333 *dst_ptr = *src_ptr;
1341 if (group !=
nullptr) {
#define SNPRINTF_UTF8(dst, format,...)
#define STRNCPY_UTF8(dst, src)
#define CLOG_WARN(clg_ref,...)
ID and Library types, which are fundamental for SDNA.
Object is a sort of wrapper for general info.
#define OBEDIT_FROM_OBACT(ob)
Read Blender memory allocation and freeing.
#define BLI_assert_unreachable()
std::unique_ptr< IDProperty, IDPropertyDeleter > create_group(StringRef prop_name, eIDPropertyFlag flags={})
Allocate a new IDProperty of type IDP_GROUP.
std::optional< AssetWeakReference > asset_edit_weak_reference_from_id(const ID &id)
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
void WM_toolsystem_refresh_active(bContext *C)
ScrArea * CTX_wm_area(const bContext *C)
Object * BKE_view_layer_active_object_get(const ViewLayer *view_layer)
std::optional< AssetWeakReference > WM_toolsystem_last_brush_asset_from_brush_type(Scene *scene, const int brush_type, const PaintMode paint_mode)
static void toolsystem_brush_activate_from_toolref(Main *bmain, const WorkSpace *workspace, const bToolRef *tref)
bool WM_gizmo_group_type_ensure_ptr(wmGizmoGroupType *gzgt)
const EnumPropertyItem rna_enum_particle_edit_hair_brush_items[]
void WM_toolsystem_refresh_all(const bContext *C, WorkSpace *workspace)
void BLI_addhead(ListBase *listbase, void *vlink) ATTR_NONNULL(1)
WorkSpace * CTX_wm_workspace(const bContext *C)
std::optional< AssetWeakReference > BKE_paint_brush_type_default_reference(bke::paint::AssetCategory asset_category, std::optional< int > brush_type)
void WM_operator_properties_free(PointerRNA *ptr)
int WM_toolsystem_mode_from_spacetype(const Main &bmain, const Scene *scene, ViewLayer *view_layer, ScrArea *area, int space_type)
static void toolsystem_brush_sync_for_texture_paint(Main *bmain, WorkSpace *workspace, bToolRef *tref)
void BKE_paint_previous_asset_reference_clear(Paint *paint)
bToolRef_Runtime * WM_toolsystem_runtime_find(WorkSpace *workspace, const bToolKey *tkey)
static bool toolsystem_key_ensure_check(const bToolKey *tkey)
void RNA_string_set(PointerRNA *ptr, const char *name, const char *value)
IDProperty * IDP_CopyProperty(const IDProperty *prop) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
void CTX_wm_window_set(bContext *C, wmWindow *win)
IDProperty * IDP_GetPropertyFromGroup(const IDProperty *prop, StringRef name) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
static void toolsystem_ref_link(Main *bmain, WorkSpace *workspace, bToolRef *tref)
bool WM_toolsystem_activate_brush_and_tool(bContext *C, Paint *paint, Brush *brush)
static bToolRef * toolsystem_reinit_ensure_toolref(bContext *C, WorkSpace *workspace, const bToolKey *tkey, const char *default_tool)
void WM_toolsystem_refresh(const bContext *C, WorkSpace *workspace, const bToolKey *tkey)
PointerRNA WM_operator_properties_create_ptr(wmOperatorType *ot)
bToolRef * WM_toolsystem_ref_find(WorkSpace *workspace, const bToolKey *tkey)
wmWindow * CTX_wm_window(const bContext *C)
void RNA_enum_set(PointerRNA *ptr, const char *name, int value)
void BKE_workspace_id_tag_all_visible(Main *bmain, int tag) ATTR_NONNULL()
static void toolsystem_main_brush_binding_update_from_active(Paint *paint)
wmGizmoGroupType * WM_gizmogrouptype_find(const StringRef idname, bool quiet)
void WM_tooltip_clear(bContext *C, wmWindow *win)
@ TOOLREF_FLAG_USE_BRUSHES
@ TOOLREF_FLAG_FALLBACK_KEYMAP
ViewLayer * WM_window_get_active_view_layer(const wmWindow *win)
int RNA_enum_from_value(const EnumPropertyItem *item, const int value)
void IDP_MergeGroup(IDProperty *dest, const IDProperty *src, bool do_overwrite) ATTR_NONNULL()
bool WM_toolsystem_key_from_context(const Main &bmain, const Scene *scene, ViewLayer *view_layer, ScrArea *area, bToolKey *tkey)
@ CTX_MODE_VERTEX_GREASE_PENCIL
@ CTX_MODE_VERTEX_GPENCIL_LEGACY
@ CTX_MODE_WEIGHT_GPENCIL_LEGACY
@ CTX_MODE_PAINT_GREASE_PENCIL
@ CTX_MODE_PAINT_GPENCIL_LEGACY
@ CTX_MODE_SCULPT_GREASE_PENCIL
@ CTX_MODE_SCULPT_GPENCIL_LEGACY
@ CTX_MODE_WEIGHT_GREASE_PENCIL
ViewLayer * CTX_data_view_layer(const bContext *C)
void IDP_ReplaceInGroup_ex(IDProperty *group, IDProperty *prop, IDProperty *prop_exist, int flag)
bToolRef_Runtime * WM_toolsystem_runtime_from_context(const bContext *C)
std::optional< int > BKE_paint_get_brush_type_from_paintmode(const Brush *brush, PaintMode mode)
static void toolsystem_ref_set_by_brush_type(bContext *C, const char *brush_type)
int BLI_findindex(const ListBase *listbase, const void *vlink) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
int RNA_enum_from_identifier(const EnumPropertyItem *item, const char *identifier)
void * BLI_findstring_ptr(const ListBase *listbase, const char *id, int offset) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
Scene * WM_window_get_active_scene(const 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_refresh_screen_all(Main *bmain)
IDProperty * WM_toolsystem_ref_properties_get_idprops(bToolRef *tref)
static void toolsystem_reinit_with_toolref(bContext *C, WorkSpace *, bToolRef *tref)
void WM_toolsystem_do_msg_notify_tag_refresh(bContext *C, wmMsgSubscribeKey *, wmMsgSubscribeValue *msg_val)
void WM_toolsystem_ref_properties_ensure_ex(bToolRef *tref, const char *idname, StructRNA *type, PointerRNA *r_ptr)
static void toolsystem_unlink_ref(bContext *C, WorkSpace *, bToolRef *tref)
CLG_LogRef * WM_LOG_TOOL_GIZMO
void WM_gizmoconfig_update_tag_group_type_init(wmGizmoMapType *gzmap_type, wmGizmoGroupType *gzgt)
void WM_toolsystem_init(const bContext *C)
static const char * brush_type_identifier_get(const int brush_type, const PaintMode paint_mode)
static NamedBrushAssetReference * toolsystem_brush_type_binding_lookup(const Paint *paint, const char *brush_type_name)
static void toolsystem_brush_clear_paint_reference(Main *bmain, WorkSpace *workspace, bToolRef *tref)
PaintMode BKE_paintmode_get_from_tool(const bToolRef *tref)
void WM_toolsystem_update_from_context_view3d(bContext *C)
static bool brush_type_matches_active_tool(bContext *C, const int brush_type)
WorkSpace * WM_window_get_active_workspace(const wmWindow *win)
bool BKE_view_layer_synced_ensure(const Main &bmain, const Scene *scene, ViewLayer *view_layer)
PointerRNA RNA_pointer_create_discrete(ID *id, StructRNA *type, void *data)
bool BKE_paint_brush_set(Paint *paint, Brush *brush)
void WM_toolsystem_update_from_context(bContext *C, WorkSpace *workspace, const Scene *scene, ViewLayer *view_layer, ScrArea *area)
bToolRef * WM_toolsystem_ref_set_by_id(bContext *C, const char *name)
wmMsgBus * CTX_wm_message_bus(const bContext *C)
void RNA_boolean_set(PointerRNA *ptr, const char *name, bool value)
static void toolsystem_brush_type_binding_update(Paint *paint, const PaintMode paint_mode, const int brush_type)
@ WM_GIZMOGROUPTYPE_TOOL_FALLBACK_KEYMAP
@ WM_GIZMOGROUPTYPE_TOOL_INIT
void WM_toolsystem_unlink(bContext *C, WorkSpace *workspace, const bToolKey *tkey)
bToolRef * WM_toolsystem_ref_set_by_id_ex(bContext *C, WorkSpace *workspace, const bToolKey *tkey, const char *name, bool cycle)
wmOperatorType * WM_operatortype_find(const char *idname, bool quiet)
void WM_toolsystem_ref_properties_init_for_keymap(bToolRef *tref, PointerRNA *dst_ptr, PointerRNA *src_ptr, wmOperatorType *ot)
const EnumPropertyItem * BKE_paint_get_tool_enum_from_paintmode(PaintMode mode)
static void toolsystem_reinit_ref(bContext *C, WorkSpace *workspace, bToolRef *tref)
bool WM_toolsystem_active_tool_has_custom_cursor(const bContext *C)
bool BKE_paint_can_use_brush(const Paint *paint, const Brush *brush)
static void toolsystem_refresh_screen_from_active_tool(Main *bmain, WorkSpace *workspace, bToolRef *tref)
Main * CTX_data_main(const bContext *C)
char * BLI_strdup(const char *str) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1) ATTR_MALLOC
bToolRef * WM_toolsystem_ref_from_context(const bContext *C)
bool WM_toolsystem_active_tool_is_brush(const bContext *C)
static const bToolRef * toolsystem_active_tool_from_context_or_view3d(const bContext *C)
Paint * BKE_paint_get_active_from_paintmode(Scene *sce, PaintMode mode)
void WM_gizmo_group_remove_by_tool(bContext *C, Main *bmain, const wmGizmoGroupType *gzgt, const bToolRef *tref)
bool WM_toolsystem_refresh_screen_area(const Main &bmain, WorkSpace *workspace, const Scene *scene, ViewLayer *view_layer, ScrArea *area)
static void toolsystem_refresh_ref(const bContext *C, WorkSpace *workspace, bToolRef *tref)
wmOperatorStatus WM_operator_name_call_ptr(bContext *C, wmOperatorType *ot, wm::OpCallContext context, PointerRNA *properties, const wmEvent *event)
void WM_toolsystem_unlink_all(bContext *C, WorkSpace *workspace)
wmGizmoMapType * WM_gizmomaptype_ensure(const wmGizmoMapType_Params *gzmap_params)
static void toolsystem_brush_activate_from_toolref_for_object_particle(const Main *bmain, const WorkSpace *workspace, const bToolRef *tref)
void WM_toolsystem_ref_sync_from_context(Main *bmain, WorkSpace *workspace, bToolRef *tref)
static const char * toolsystem_default_tool(const bToolKey *tkey)
Scene * CTX_data_scene(const bContext *C)
void CTX_wm_region_set(bContext *C, ARegion *region)
static void toolsystem_brush_activate_from_toolref_for_object_paint(Main *bmain, const WorkSpace *workspace, const bToolRef *tref)
bool WM_toolsystem_ref_ensure(WorkSpace *workspace, const bToolKey *tkey, bToolRef **r_tref)
static bToolKey toolsystem_key_from_context_or_view3d(const Main &bmain, const Scene *scene, ViewLayer *view_layer, ScrArea *area)
IDProperty * WM_toolsystem_ref_properties_ensure_idprops(bToolRef *tref)
bool BKE_paint_ensure_from_paintmode(Scene *sce, PaintMode mode)
bScreen * WM_window_get_active_screen(const wmWindow *win)
void WM_toolsystem_reinit_all(bContext *C, wmWindow *win)
static void wm_toolsystem_update_from_context_view3d_impl(bContext *C, WorkSpace *workspace)
void WM_toolsystem_reinit(bContext *C, WorkSpace *workspace, const bToolKey *tkey)
bool WM_toolsystem_ref_properties_get_ex(bToolRef *tref, const char *idname, StructRNA *type, PointerRNA *r_ptr)
ARegion * CTX_wm_region(const bContext *C)
PaintMode BKE_paintmode_get_active_from_context(const bContext *C)
void WM_toolsystem_refresh_screen_window(const Main &bmain, wmWindow *win)
@ AREA_FLAG_ACTIVE_TOOL_UPDATE
static IDProperty * idprops_ensure_named_group(IDProperty *group, const char *idname)
static void toolsystem_ref_set_by_id_pending(Main *bmain, bToolRef *tref, const char *idname_pending)
void CTX_wm_area_set(bContext *C, ScrArea *area)
enum eContextObjectMode CTX_data_mode_enum_ex(const Object *obedit, const Object *ob, eObjectMode object_mode)
ListBaseT< wmWindowManager > wm
ListBaseT< WorkSpace > workspaces
ListBaseT< bScreen > screens
struct AssetWeakReference * brush_asset_reference
struct ToolSettings * toolsettings
ListBaseT< SpaceLink > spacedata
ListBaseT< bToolRef > tools
ListBaseT< struct ScrArea > areabase
wmGizmoMapType_Params gzmap_params
eWM_GizmoFlagGroupTypeFlag flag
#define WM_msg_publish_rna_prop(mbus, id_, data_, type_, prop_)