Changeset View
Changeset View
Standalone View
Standalone View
source/blender/makesrna/intern/rna_brush.c
| Show First 20 Lines • Show All 73 Lines • ▼ Show 20 Lines | static const EnumPropertyItem sculpt_stroke_method_items[] = { | ||||
| {BRUSH_CURVE, | {BRUSH_CURVE, | ||||
| "CURVE", | "CURVE", | ||||
| 0, | 0, | ||||
| "Curve", | "Curve", | ||||
| "Define the stroke curve with a bezier curve (dabs are separated according to spacing)"}, | "Define the stroke curve with a bezier curve (dabs are separated according to spacing)"}, | ||||
| {0, NULL, 0, NULL, NULL}, | {0, NULL, 0, NULL, NULL}, | ||||
| }; | }; | ||||
| static const EnumPropertyItem rna_brush_texture_slot_map_mode_items[] = { | |||||
jbakker: Should start with `rna_enum_` but the rest of the patch seems fine. | |||||
| {MTEX_MAP_MODE_VIEW, "VIEW_PLANE", 0, "View Plane", ""}, | |||||
| {MTEX_MAP_MODE_AREA, "AREA_PLANE", 0, "Area Plane", ""}, | |||||
| {MTEX_MAP_MODE_TILED, "TILED", 0, "Tiled", ""}, | |||||
| {MTEX_MAP_MODE_3D, "3D", 0, "3D", ""}, | |||||
| {MTEX_MAP_MODE_RANDOM, "RANDOM", 0, "Random", ""}, | |||||
| {MTEX_MAP_MODE_STENCIL, "STENCIL", 0, "Stencil", ""}, | |||||
| {0, NULL, 0, NULL, NULL}, | |||||
| }; | |||||
| /* clang-format off */ | /* clang-format off */ | ||||
| const EnumPropertyItem rna_enum_brush_sculpt_tool_items[] = { | const EnumPropertyItem rna_enum_brush_sculpt_tool_items[] = { | ||||
| {SCULPT_TOOL_DRAW, "DRAW", ICON_BRUSH_SCULPT_DRAW, "Draw", ""}, | {SCULPT_TOOL_DRAW, "DRAW", ICON_BRUSH_SCULPT_DRAW, "Draw", ""}, | ||||
| {SCULPT_TOOL_DRAW_SHARP, "DRAW_SHARP", ICON_BRUSH_SCULPT_DRAW, "Draw Sharp", ""}, | {SCULPT_TOOL_DRAW_SHARP, "DRAW_SHARP", ICON_BRUSH_SCULPT_DRAW, "Draw Sharp", ""}, | ||||
| {SCULPT_TOOL_CLAY, "CLAY", ICON_BRUSH_CLAY, "Clay", ""}, | {SCULPT_TOOL_CLAY, "CLAY", ICON_BRUSH_CLAY, "Clay", ""}, | ||||
| {SCULPT_TOOL_CLAY_STRIPS, "CLAY_STRIPS", ICON_BRUSH_CLAY_STRIPS, "Clay Strips", ""}, | {SCULPT_TOOL_CLAY_STRIPS, "CLAY_STRIPS", ICON_BRUSH_CLAY_STRIPS, "Clay Strips", ""}, | ||||
| {SCULPT_TOOL_CLAY_THUMB, "CLAY_THUMB", ICON_BRUSH_CLAY_STRIPS, "Clay Thumb", ""}, | {SCULPT_TOOL_CLAY_THUMB, "CLAY_THUMB", ICON_BRUSH_CLAY_STRIPS, "Clay Thumb", ""}, | ||||
| {SCULPT_TOOL_LAYER, "LAYER", ICON_BRUSH_LAYER, "Layer", ""}, | {SCULPT_TOOL_LAYER, "LAYER", ICON_BRUSH_LAYER, "Layer", ""}, | ||||
| ▲ Show 20 Lines • Show All 920 Lines • ▼ Show 20 Lines | else { | ||||
| ToolSettings *ts = CTX_data_tool_settings(C); | ToolSettings *ts = CTX_data_tool_settings(C); | ||||
| brush->gpencil_settings->brush_draw_mode = GPENCIL_USE_VERTEX_COLOR(ts) ? | brush->gpencil_settings->brush_draw_mode = GPENCIL_USE_VERTEX_COLOR(ts) ? | ||||
| GP_BRUSH_MODE_VERTEXCOLOR : | GP_BRUSH_MODE_VERTEXCOLOR : | ||||
| GP_BRUSH_MODE_MATERIAL; | GP_BRUSH_MODE_MATERIAL; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| static const EnumPropertyItem *rna_BrushTextureSlot_map_mode_itemf(bContext *C, | |||||
| PointerRNA *UNUSED(ptr), | |||||
| PropertyRNA *UNUSED(prop), | |||||
| bool *r_free) | |||||
| { | |||||
| const bool is_sculpt_mode = (BKE_paintmode_get_active_from_context(C) == PAINT_MODE_SCULPT); | |||||
| int totitem = 0; | |||||
| EnumPropertyItem *result = NULL; | |||||
| for (int i = 0; rna_brush_texture_slot_map_mode_items[i].identifier != NULL; i++) { | |||||
| const EnumPropertyItem *item = &rna_brush_texture_slot_map_mode_items[i]; | |||||
| if (item->value != MTEX_MAP_MODE_AREA || is_sculpt_mode) { | |||||
| RNA_enum_item_add(&result, &totitem, item); | |||||
| } | |||||
| } | |||||
| RNA_enum_item_end(&result, &totitem); | |||||
| *r_free = true; | |||||
| return result; | |||||
| } | |||||
| #else | #else | ||||
| static void rna_def_brush_texture_slot(BlenderRNA *brna) | static void rna_def_brush_texture_slot(BlenderRNA *brna) | ||||
| { | { | ||||
| StructRNA *srna; | StructRNA *srna; | ||||
| PropertyRNA *prop; | PropertyRNA *prop; | ||||
| static const EnumPropertyItem prop_map_mode_items[] = { | |||||
| {MTEX_MAP_MODE_VIEW, "VIEW_PLANE", 0, "View Plane", ""}, | |||||
| {MTEX_MAP_MODE_AREA, "AREA_PLANE", 0, "Area Plane", ""}, | |||||
Done Inline ActionsThis item is only valid for sculpt mode. you could add a itemf function based on the context but that might not be trival to add. Current solution to show it also when texture painting gives a false impression to the user. jbakker: This item is only valid for sculpt mode. you could add a `itemf` function based on the context… | |||||
| {MTEX_MAP_MODE_TILED, "TILED", 0, "Tiled", ""}, | |||||
| {MTEX_MAP_MODE_3D, "3D", 0, "3D", ""}, | |||||
| {MTEX_MAP_MODE_RANDOM, "RANDOM", 0, "Random", ""}, | |||||
| {MTEX_MAP_MODE_STENCIL, "STENCIL", 0, "Stencil", ""}, | |||||
| {0, NULL, 0, NULL, NULL}, | |||||
| }; | |||||
| static const EnumPropertyItem prop_tex_paint_map_mode_items[] = { | |||||
| {MTEX_MAP_MODE_VIEW, "VIEW_PLANE", 0, "View Plane", ""}, | |||||
| {MTEX_MAP_MODE_TILED, "TILED", 0, "Tiled", ""}, | |||||
| {MTEX_MAP_MODE_3D, "3D", 0, "3D", ""}, | |||||
| {MTEX_MAP_MODE_RANDOM, "RANDOM", 0, "Random", ""}, | |||||
| {MTEX_MAP_MODE_STENCIL, "STENCIL", 0, "Stencil", ""}, | |||||
| {0, NULL, 0, NULL, NULL}, | |||||
| }; | |||||
| static const EnumPropertyItem prop_mask_paint_map_mode_items[] = { | static const EnumPropertyItem prop_mask_paint_map_mode_items[] = { | ||||
| {MTEX_MAP_MODE_VIEW, "VIEW_PLANE", 0, "View Plane", ""}, | {MTEX_MAP_MODE_VIEW, "VIEW_PLANE", 0, "View Plane", ""}, | ||||
| {MTEX_MAP_MODE_TILED, "TILED", 0, "Tiled", ""}, | {MTEX_MAP_MODE_TILED, "TILED", 0, "Tiled", ""}, | ||||
| {MTEX_MAP_MODE_RANDOM, "RANDOM", 0, "Random", ""}, | {MTEX_MAP_MODE_RANDOM, "RANDOM", 0, "Random", ""}, | ||||
| {MTEX_MAP_MODE_STENCIL, "STENCIL", 0, "Stencil", ""}, | {MTEX_MAP_MODE_STENCIL, "STENCIL", 0, "Stencil", ""}, | ||||
| {0, NULL, 0, NULL, NULL}, | {0, NULL, 0, NULL, NULL}, | ||||
| }; | }; | ||||
| # define TEXTURE_CAPABILITY(prop_name_, ui_name_) \ | # define TEXTURE_CAPABILITY(prop_name_, ui_name_) \ | ||||
| prop = RNA_def_property(srna, #prop_name_, PROP_BOOLEAN, PROP_NONE); \ | prop = RNA_def_property(srna, #prop_name_, PROP_BOOLEAN, PROP_NONE); \ | ||||
| RNA_def_property_clear_flag(prop, PROP_EDITABLE); \ | RNA_def_property_clear_flag(prop, PROP_EDITABLE); \ | ||||
| RNA_def_property_boolean_funcs(prop, "rna_TextureCapabilities_" #prop_name_ "_get", NULL); \ | RNA_def_property_boolean_funcs(prop, "rna_TextureCapabilities_" #prop_name_ "_get", NULL); \ | ||||
| RNA_def_property_ui_text(prop, ui_name_, NULL) | RNA_def_property_ui_text(prop, ui_name_, NULL) | ||||
| srna = RNA_def_struct(brna, "BrushTextureSlot", "TextureSlot"); | srna = RNA_def_struct(brna, "BrushTextureSlot", "TextureSlot"); | ||||
| RNA_def_struct_sdna(srna, "MTex"); | RNA_def_struct_sdna(srna, "MTex"); | ||||
| RNA_def_struct_ui_text( | RNA_def_struct_ui_text( | ||||
| srna, "Brush Texture Slot", "Texture slot for textures in a Brush data-block"); | srna, "Brush Texture Slot", "Texture slot for textures in a Brush data-block"); | ||||
| prop = RNA_def_property(srna, "angle", PROP_FLOAT, PROP_ANGLE); | prop = RNA_def_property(srna, "angle", PROP_FLOAT, PROP_ANGLE); | ||||
| RNA_def_property_float_sdna(prop, NULL, "rot"); | RNA_def_property_float_sdna(prop, NULL, "rot"); | ||||
| RNA_def_property_range(prop, 0, M_PI * 2); | RNA_def_property_range(prop, 0, M_PI * 2); | ||||
| RNA_def_property_ui_text(prop, "Angle", "Brush texture rotation"); | RNA_def_property_ui_text(prop, "Angle", "Brush texture rotation"); | ||||
| RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); | RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); | ||||
Done Inline ActionsI am not sure about this ivpe: I am not sure about this | |||||
Done Inline ActionsYou're right. Only one needs to be available. You can always check how other itemf functions solve this. Eg render pass in the viewport popover. jbakker: You're right. Only one needs to be available. You can always check how other itemf functions… | |||||
| RNA_def_property_update(prop, 0, "rna_TextureSlot_brush_angle_update"); | RNA_def_property_update(prop, 0, "rna_TextureSlot_brush_angle_update"); | ||||
| prop = RNA_def_property(srna, "map_mode", PROP_ENUM, PROP_NONE); | prop = RNA_def_property(srna, "map_mode", PROP_ENUM, PROP_NONE); | ||||
| RNA_def_property_enum_sdna(prop, NULL, "brush_map_mode"); | RNA_def_property_enum_sdna(prop, NULL, "brush_map_mode"); | ||||
| RNA_def_property_enum_items(prop, prop_map_mode_items); | RNA_def_property_enum_items(prop, rna_brush_texture_slot_map_mode_items); | ||||
| RNA_def_property_ui_text(prop, "Mode", ""); | RNA_def_property_enum_funcs(prop, NULL, NULL, "rna_BrushTextureSlot_map_mode_itemf"); | ||||
| RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); | |||||
| RNA_def_property_update(prop, 0, "rna_TextureSlot_update"); | |||||
| prop = RNA_def_property(srna, "tex_paint_map_mode", PROP_ENUM, PROP_NONE); | |||||
| RNA_def_property_enum_sdna(prop, NULL, "brush_map_mode"); | |||||
| RNA_def_property_enum_items(prop, prop_tex_paint_map_mode_items); | |||||
| RNA_def_property_ui_text(prop, "Mode", ""); | RNA_def_property_ui_text(prop, "Mode", ""); | ||||
| RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); | RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); | ||||
| RNA_def_property_update(prop, 0, "rna_TextureSlot_update"); | RNA_def_property_update(prop, 0, "rna_TextureSlot_update"); | ||||
| prop = RNA_def_property(srna, "mask_map_mode", PROP_ENUM, PROP_NONE); | prop = RNA_def_property(srna, "mask_map_mode", PROP_ENUM, PROP_NONE); | ||||
| RNA_def_property_enum_sdna(prop, NULL, "brush_map_mode"); | RNA_def_property_enum_sdna(prop, NULL, "brush_map_mode"); | ||||
| RNA_def_property_enum_items(prop, prop_mask_paint_map_mode_items); | RNA_def_property_enum_items(prop, prop_mask_paint_map_mode_items); | ||||
| RNA_def_property_ui_text(prop, "Mode", ""); | RNA_def_property_ui_text(prop, "Mode", ""); | ||||
| ▲ Show 20 Lines • Show All 2,402 Lines • Show Last 20 Lines | |||||
Should start with rna_enum_ but the rest of the patch seems fine.