51 const char *default_tool);
64 if (workspace ==
nullptr) {
78 if (area->runtime.is_tool_set) {
87 return tref ? tref->
runtime :
nullptr;
94 if ((tref->space_type == tkey->
space_type) && (tref->mode == tkey->
mode)) {
104 return tref ? tref->
runtime :
nullptr;
160 if (workspace ==
nullptr) {
179 if (gzgt !=
nullptr) {
201 if (item_idx == -1) {
220 const char *brush_type_name)
236 if (paint->
brush !=
nullptr) {
237 if (std::optional<AssetWeakReference> brush_asset_reference =
241 __func__, *brush_asset_reference);
248 const int brush_type)
250 if (paint->
brush ==
nullptr) {
254 if (!brush_type_name || !brush_type_name[0]) {
260 paint, brush_type_name))
262 MEM_delete(existing_brush_ref->brush_asset_reference);
263 existing_brush_ref->brush_asset_reference = MEM_new<AssetWeakReference>(
367 std::optional<AssetWeakReference> brush_asset_reference =
368 [&]() -> std::optional<AssetWeakReference> {
371 paint, brush_type_name);
381 if (brush_asset_reference) {
392 std::optional<AssetWeakReference> main_brush_asset_reference =
393 [&]() -> std::optional<AssetWeakReference> {
401 if (main_brush_asset_reference) {
437 if (gzgt !=
nullptr) {
459 if (tref->
runtime ==
nullptr) {
493 if (tref->tag == 0) {
524 if (tref->
tag == 0) {
546 if (tref->
runtime ==
nullptr) {
550 if (tref_rt != tref->
runtime) {
556 bool use_fallback_keymap =
false;
560 use_fallback_keymap =
true;
566 use_fallback_keymap =
true;
571 if (use_fallback_keymap ==
false) {
583 if (win !=
nullptr) {
598 if ((tref_rt ==
nullptr) || (tref_rt->
data_block[0] ==
'\0')) {
668 switch (space_type) {
673 if (obact !=
nullptr) {
708 if (area !=
nullptr) {
709 space_type = area->spacetype;
730 } context_prev = {
nullptr};
741 int space_type_mask_handled = 0;
744 const int space_type_mask = (1 << area->spacetype);
746 ((space_type_mask_handled & space_type_mask) == 0))
748 space_type_mask_handled |= space_type_mask;
753 if (tref != area->
runtime.tool) {
754 if (context_prev.is_set ==
false) {
758 context_prev.is_set =
true;
771 if (context_prev.is_set) {
781 workspace->id.tag &= ~ID_TAG_DOIT;
797 const bool is_tool_set_prev = area->runtime.is_tool_set;
800 area->runtime.tool =
nullptr;
801 area->runtime.is_tool_set =
true;
804 if (tref->space_type == area->spacetype) {
805 if (tref->mode == mode) {
806 area->runtime.tool = tref;
811 return !(is_tool_set_prev && (tref_prev == area->
runtime.tool));
819 space_type_has_tools[tref->space_type] =
true;
825 area->runtime.tool =
nullptr;
826 area->runtime.is_tool_set =
true;
827 if (space_type_has_tools[area->spacetype]) {
861 if (mode == tref->
mode) {
862 area->runtime.tool = tref;
863 area->
runtime.is_tool_set =
true;
910 return (tref &&
STREQ(tref->
idname, name)) ? tref :
nullptr;
973 tkey.mode = tref->
mode;
981 switch (tkey->
mode) {
995 return "builtin.brush";
997 return "builtin_brush.Comb";
999 return "builtin.select_text";
1003 switch (tkey->
mode) {
1005 return "builtin.brush";
1009 return "builtin.select_box";
1012 return "builtin.select_box";
1016 return "builtin.select_box";
1025 const char *default_tool)
1029 if (default_tool ==
nullptr) {
1065 if (win != win_prev) {
1067 if (workspace_iter != workspace) {
1112 if (win->
next !=
nullptr) {
1118 }
while ((win = win->
next));
1146 if (group ==
nullptr) {
1168 return (prop !=
nullptr);
1186 *dst_ptr = *src_ptr;
1187 if (dst_ptr->
data) {
1194 if (group !=
nullptr) {
WorkSpace * CTX_wm_workspace(const bContext *C)
@ CTX_MODE_VERTEX_GPENCIL_LEGACY
@ CTX_MODE_WEIGHT_GPENCIL_LEGACY
@ CTX_MODE_SCULPT_GPENCIL_LEGACY
@ CTX_MODE_PAINT_GREASE_PENCIL
@ CTX_MODE_PAINT_GPENCIL_LEGACY
@ CTX_MODE_SCULPT_GREASE_PENCIL
@ CTX_MODE_WEIGHT_GREASE_PENCIL
@ CTX_MODE_VERTEX_GREASE_PENCIL
ScrArea * CTX_wm_area(const bContext *C)
wmWindow * CTX_wm_window(const bContext *C)
Scene * CTX_data_scene(const bContext *C)
enum eContextObjectMode CTX_data_mode_enum_ex(const Object *obedit, const Object *ob, eObjectMode object_mode)
void CTX_wm_window_set(bContext *C, wmWindow *win)
Main * CTX_data_main(const bContext *C)
void CTX_wm_area_set(bContext *C, ScrArea *area)
void CTX_wm_region_set(bContext *C, ARegion *region)
ARegion * CTX_wm_region(const bContext *C)
wmMsgBus * CTX_wm_message_bus(const bContext *C)
ViewLayer * CTX_data_view_layer(const bContext *C)
IDProperty * IDP_GetPropertyFromGroup(const IDProperty *prop, const char *name) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
void IDP_ReplaceInGroup_ex(IDProperty *group, IDProperty *prop, IDProperty *prop_exist)
IDProperty * IDP_CopyProperty(const IDProperty *prop) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
void IDP_MergeGroup(IDProperty *dest, const IDProperty *src, bool do_overwrite) ATTR_NONNULL()
void BKE_view_layer_synced_ensure(const Scene *scene, ViewLayer *view_layer)
Object * BKE_view_layer_active_object_get(const ViewLayer *view_layer)
bool BKE_paint_brush_set(Paint *paint, Brush *brush)
Paint * BKE_paint_get_active_from_paintmode(Scene *sce, PaintMode mode)
const EnumPropertyItem * BKE_paint_get_tool_enum_from_paintmode(PaintMode mode)
std::optional< AssetWeakReference > BKE_paint_brush_type_default_reference(eObjectMode ob_mode, std::optional< int > brush_type)
std::optional< int > BKE_paint_get_brush_type_from_paintmode(const Brush *brush, const PaintMode mode)
PaintMode BKE_paintmode_get_active_from_context(const bContext *C)
bool BKE_paint_brush_poll(const Paint *paint, const Brush *brush)
PaintMode BKE_paintmode_get_from_tool(const bToolRef *tref)
bool BKE_paint_ensure_from_paintmode(Scene *sce, PaintMode mode)
void BKE_workspace_id_tag_all_visible(Main *bmain, int tag) ATTR_NONNULL()
#define BLI_assert_unreachable()
void BLI_addhead(struct ListBase *listbase, void *vlink) ATTR_NONNULL(1)
#define LISTBASE_FOREACH(type, var, list)
void void BLI_INLINE bool BLI_listbase_is_single(const struct ListBase *lb)
int BLI_findindex(const struct ListBase *listbase, const void *vlink) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
void * BLI_findstring_ptr(const struct ListBase *listbase, const char *id, int offset) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
char * BLI_strdup(const char *str) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1) ATTR_MALLOC
#define STRNCPY(dst, src)
#define SNPRINTF(dst, format,...)
#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)
@ TOOLREF_FLAG_FALLBACK_KEYMAP
@ TOOLREF_FLAG_USE_BRUSHES
Read Guarded memory(de)allocation.
@ WM_GIZMOGROUPTYPE_TOOL_INIT
@ WM_GIZMOGROUPTYPE_TOOL_FALLBACK_KEYMAP
CLG_LogRef * WM_LOG_TOOLS
void *(* MEM_callocN)(size_t len, const char *str)
std::unique_ptr< IDProperty, IDPropertyDeleter > create_group(StringRefNull prop_name, eIDPropertyFlag flags={})
Allocate a new IDProperty of type IDP_GROUP.
std::optional< AssetWeakReference > asset_edit_weak_reference_from_id(const ID &id)
void RNA_string_set(PointerRNA *ptr, const char *name, const char *value)
void RNA_boolean_set(PointerRNA *ptr, const char *name, bool value)
int RNA_enum_from_identifier(const EnumPropertyItem *item, const char *identifier)
int RNA_enum_from_value(const EnumPropertyItem *item, const int value)
void RNA_enum_set(PointerRNA *ptr, const char *name, int value)
PointerRNA RNA_pointer_create(ID *id, StructRNA *type, void *data)
const EnumPropertyItem rna_enum_particle_edit_hair_brush_items[]
struct AssetWeakReference * brush_asset_reference
struct Paint_Runtime runtime
struct AssetWeakReference * brush_asset_reference
ToolSystemBrushBindings tool_brush_bindings
wmGizmoMapType_Params gzmap_params
eWM_GizmoFlagGroupTypeFlag flag
int WM_operator_name_call_ptr(bContext *C, wmOperatorType *ot, wmOperatorCallContext context, PointerRNA *properties, const wmEvent *event)
bool WM_gizmo_group_type_ensure_ptr(wmGizmoGroupType *gzgt)
void WM_gizmo_group_remove_by_tool(bContext *C, Main *bmain, const wmGizmoGroupType *gzgt, const bToolRef *tref)
wmGizmoGroupType * WM_gizmogrouptype_find(const char *idname, bool quiet)
void WM_gizmoconfig_update_tag_group_type_init(wmGizmoMapType *gzmap_type, wmGizmoGroupType *gzgt)
wmGizmoMapType * WM_gizmomaptype_ensure(const wmGizmoMapType_Params *gzmap_params)
#define WM_msg_publish_rna_prop(mbus, id_, data_, type_, prop_)
wmOperatorType * WM_operatortype_find(const char *idname, bool quiet)
void WM_operator_properties_create_ptr(PointerRNA *ptr, wmOperatorType *ot)
void WM_operator_properties_free(PointerRNA *ptr)
ViewLayer * WM_window_get_active_view_layer(const wmWindow *win)
Scene * WM_window_get_active_scene(const wmWindow *win)
WorkSpace * WM_window_get_active_workspace(const wmWindow *win)
bScreen * WM_window_get_active_screen(const wmWindow *win)