Commit: efaade3b30f111227dd9ec9623093ce94f3ae529 Author: Joseph Eagar Date: Wed Aug 10 16:22:58 2022 -0700 Branches: temp-sculpt-brush-channel https://developer.blender.org/rBefaade3b30f111227dd9ec9623093ce94f3ae529
temp-sculpt-brush-channel: Add missing RNA callbacks the RNA properties for controlling brush property visibility now properly sets their XXX_USER_SET flags. Also rewrote a few comments. =================================================================== M source/blender/makesdna/DNA_brush_channel_types.h M source/blender/makesrna/intern/rna_brush_channels.c =================================================================== diff --git a/source/blender/makesdna/DNA_brush_channel_types.h b/source/blender/makesdna/DNA_brush_channel_types.h index ea333c519e4..d3aab68ef19 100644 --- a/source/blender/makesdna/DNA_brush_channel_types.h +++ b/source/blender/makesdna/DNA_brush_channel_types.h @@ -81,33 +81,23 @@ typedef struct BrushMapping { typedef struct BrushChannel { struct BrushChannel *next, *prev; - /** Channel id. Avoid calling API methods that take strings directly. - There are API facilities to check channel idnames at compile time: - the BRUSHSET_XXX macros, SCULPT_get_XXX, etc. On the C++ side - BrushChannelSetIF has accessor methods, e.g. BrushChannelSet::radius. - */ - char idname[64]; + char idname[64]; /* The RNA property name */ char uiname[64]; /** user-friendly name */ char *category; /** category; if NULL, def->category will be used */ struct BrushChannelType *def; /* Brush channel definition */ /* - Need to investigate whether we - can use ID properties here. ID properties - don't support CurveMappings and do support - things we don't want, like groups, strings and - ID pointer properties. - - We could implement an ID property CurveMapping - type and prevent the creation of group properties - at the API level though. + Cached channel values. */ float fvalue; /** floating point value */ int ivalue; /** stores integer, boolean, enum and bitmasks */ float vector[4]; /* stores 3 and 4 component vectors */ + + /* For curve channels. */ BrushCurve curve; + /* Input device mappings */ BrushMapping mappings[7]; /* dimension should always be BRUSH_MAPPING_MAX */ short type; /** eBrushChannelType */ @@ -120,7 +110,7 @@ typedef struct BrushChannelSet { ListBase channels; int channels_num, _pad[1]; - void *channelmap; /** quick lookup ghash, maps idnames to brush channels */ + void *channelmap; /** idname -> channel map. */ } BrushChannelSet; #define BRUSH_CHANNEL_MAX_IDNAME sizeof(((BrushChannel){0}).idname) @@ -134,11 +124,9 @@ typedef enum eBrushMappingFlags { /* BrushMapping->inherit_mode */ typedef enum eBrushMappingInheritMode { - /* never inherit */ BRUSH_MAPPING_INHERIT_NEVER, - /* always inherit */ BRUSH_MAPPING_INHERIT_ALWAYS, - /* use channel's inheritance mode */ + /* Use channel's inheritance mode. */ BRUSH_MAPPING_INHERIT_CHANNEL } eBrushMappingInheritMode; @@ -152,7 +140,7 @@ typedef enum eBrushMappingFunc { BRUSH_MAPFUNC_SQUARE, /* square wave */ } eBrushMappingFunc; -// mapping types +/* Input device mapping types. */ typedef enum eBrushMappingType { BRUSH_MAPPING_PRESSURE = 0, BRUSH_MAPPING_XTILT = 1, @@ -168,7 +156,6 @@ BLI_STATIC_ASSERT(offsetof(BrushChannel, type) - offsetof(BrushChannel, mappings sizeof(BrushMapping) * BRUSH_MAPPING_MAX, "BrushChannel.mappings must == BRUSH_MAPPING_MAX"); -// BrushChannel->flag typedef enum eBrushChannelFlag { BRUSH_CHANNEL_INHERIT = 1 << 0, BRUSH_CHANNEL_INHERIT_IF_UNSET = 1 << 1, @@ -187,11 +174,11 @@ typedef enum eBrushChannelFlag { typedef enum eBrushChannelUIFlag { BRUSH_CHANNEL_SHOW_IN_WORKSPACE = 1 << 0, /* Has user overriden this, used for version patching. */ - BRUSH_CHANNEL_SHOW_IN_WORKSPACE_SET = 1 << 1, + BRUSH_CHANNEL_SHOW_IN_WORKSPACE_USER_SET = 1 << 1, BRUSH_CHANNEL_SHOW_IN_HEADER = 1 << 2, - BRUSH_CHANNEL_SHOW_IN_HEADER_SET = 1 << 3, + BRUSH_CHANNEL_SHOW_IN_HEADER_USER_SET = 1 << 3, BRUSH_CHANNEL_SHOW_IN_CONTEXT_MENU = 1 << 4, - BRUSH_CHANNEL_SHOW_IN_CONTEXT_MENU_SET = 1 << 5, + BRUSH_CHANNEL_SHOW_IN_CONTEXT_MENU_USER_SET = 1 << 5, } eBrushChannelUIFlag; // BrushChannelType->type diff --git a/source/blender/makesrna/intern/rna_brush_channels.c b/source/blender/makesrna/intern/rna_brush_channels.c index 89e6cecfee3..2a5d6037c94 100644 --- a/source/blender/makesrna/intern/rna_brush_channels.c +++ b/source/blender/makesrna/intern/rna_brush_channels.c @@ -55,7 +55,7 @@ static EnumPropertyItem null_enum[2] = {{0, "null", ICON_NONE, "null"}, {0, NULL # include "RNA_access.h" -#if 0 +# if 0 static void rna_brushchannel_update(Scene *scene, Brush *brush) { } @@ -83,7 +83,7 @@ void rna_BrushChannel_update(Main *bmain, Scene *scene, PointerRNA *ptr) return; } } -#endif +# endif void rna_BrushChannel_update_tooltip(PointerRNA *ptr, const char *propname) { @@ -432,7 +432,44 @@ void rna_BrushChannel_category_set(PointerRNA *ptr, const char *value) BKE_brush_channel_category_set((BrushChannel *)ptr->data, value); } -#endif +static void channel_uiflag_set(PointerRNA *ptr, bool value, int flag, int user_set_flag) +{ + BrushChannel *ch = (BrushChannel *)ptr->data; + + if (value) { + ch->ui_flag |= flag; + } + else { + ch->ui_flag &= ~flag; + } + + if ((ch->ui_flag & flag) != (ch->def->ui_flag & flag)) { + ch->ui_flag |= user_set_flag; + } + else { + ch->ui_flag &= ~BRUSH_CHANNEL_SHOW_IN_HEADER_USER_SET; + } +} + +void rna_BrushChannel_show_in_header_set(PointerRNA *ptr, bool value) +{ + channel_uiflag_set( + ptr, value, BRUSH_CHANNEL_SHOW_IN_HEADER, BRUSH_CHANNEL_SHOW_IN_HEADER_USER_SET); +} + +void rna_BrushChannel_show_in_workspace_set(PointerRNA *ptr, bool value) +{ + channel_uiflag_set( + ptr, value, BRUSH_CHANNEL_SHOW_IN_WORKSPACE, BRUSH_CHANNEL_SHOW_IN_WORKSPACE_USER_SET); +} + +void rna_BrushChannel_show_in_context_menu_set(PointerRNA *ptr, bool value) +{ + channel_uiflag_set( + ptr, value, BRUSH_CHANNEL_SHOW_IN_CONTEXT_MENU, BRUSH_CHANNEL_SHOW_IN_CONTEXT_MENU_USER_SET); +} + +#else static EnumPropertyItem mapping_type_items[] = { {BRUSH_MAPPING_PRESSURE, "PRESSURE", ICON_NONE, "Pressure"}, @@ -696,16 +733,19 @@ void RNA_def_brush_channel(BlenderRNA *brna) RNA_def_property_ui_text(prop, "In Header", "Show in header"); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY); + RNA_def_property_boolean_funcs(prop, NULL, "rna_BrushChannel_show_in_header_set"); prop = RNA_def_property(srna, "show_in_workspace", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, "BrushChannel", "flag", BRUSH_CHANNEL_SHOW_IN_WORKSPACE); RNA_def_property_ui_text(prop, "In Workspace", "Show in workspace"); RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY); + RNA_def_property_boolean_funcs(prop, NULL, "rna_BrushChannel_show_in_workspace_set"); prop = RNA_def_property(srna, "show_in_context_menu", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, "BrushChannel", "flag", BRUSH_CHANNEL_SHOW_IN_CONTEXT_MENU); RNA_def_property_ui_text(prop, "In Workspace", "Show in workspace"); RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY); + RNA_def_property_boolean_funcs(prop, NULL, "rna_BrushChannel_show_in_context_menu_set"); prop = RNA_def_property(srna, "is_color", PROP_BOOLEAN, PROP_NONE); RNA_def_property_ui_text(prop, "Is Color", "Is this channel a color"); @@ -801,3 +841,4 @@ void RNA_def_brush_channels(BlenderRNA *brna) RNA_def_brush_mapping(brna); RNA_def_brush_channel(brna); } +#endif _______________________________________________ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs