Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/sculpt_paint/paint_ops.c
| Show All 23 Lines | |||||
| #include "MEM_guardedalloc.h" | #include "MEM_guardedalloc.h" | ||||
| #include <stdlib.h> | #include <stdlib.h> | ||||
| #include "BLI_listbase.h" | #include "BLI_listbase.h" | ||||
| #include "BLI_string.h" | #include "BLI_string.h" | ||||
| #include "BLI_utildefines.h" | #include "BLI_utildefines.h" | ||||
| #include "BLI_math_vector.h" | #include "BLI_math_vector.h" | ||||
| #include "BLI_math_color.h" | |||||
| #include "DNA_customdata_types.h" | #include "DNA_customdata_types.h" | ||||
| #include "DNA_object_types.h" | #include "DNA_object_types.h" | ||||
| #include "DNA_scene_types.h" | #include "DNA_scene_types.h" | ||||
| #include "DNA_brush_types.h" | #include "DNA_brush_types.h" | ||||
| #include "DNA_gpencil_types.h" | |||||
| #include "BKE_brush.h" | #include "BKE_brush.h" | ||||
| #include "BKE_context.h" | #include "BKE_context.h" | ||||
| #include "BKE_paint.h" | #include "BKE_paint.h" | ||||
| #include "BKE_gpencil.h" | |||||
| #include "BKE_main.h" | #include "BKE_main.h" | ||||
| #include "BKE_report.h" | |||||
| #include "DEG_depsgraph.h" | |||||
| #include "ED_paint.h" | #include "ED_paint.h" | ||||
| #include "ED_screen.h" | #include "ED_screen.h" | ||||
| #include "ED_image.h" | #include "ED_image.h" | ||||
| #include "ED_gpencil.h" | |||||
| #include "UI_resources.h" | #include "UI_resources.h" | ||||
| #include "WM_api.h" | #include "WM_api.h" | ||||
| #include "WM_types.h" | #include "WM_types.h" | ||||
| #include "WM_toolsystem.h" | #include "WM_toolsystem.h" | ||||
| #include "RNA_access.h" | #include "RNA_access.h" | ||||
| #include "RNA_define.h" | #include "RNA_define.h" | ||||
| Show All 37 Lines | static void BRUSH_OT_add(wmOperatorType *ot) | ||||
| /* api callbacks */ | /* api callbacks */ | ||||
| ot->exec = brush_add_exec; | ot->exec = brush_add_exec; | ||||
| /* flags */ | /* flags */ | ||||
| ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; | ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; | ||||
| } | } | ||||
| static int brush_add_gpencil_exec(bContext *C, wmOperator *UNUSED(op)) | |||||
| { | |||||
| /*int type = RNA_enum_get(op->ptr, "type");*/ | |||||
| ToolSettings *ts = CTX_data_tool_settings(C); | |||||
| Paint *paint = &ts->gp_paint->paint; | |||||
| Brush *br = BKE_paint_brush(paint); | |||||
| Main *bmain = CTX_data_main(C); | |||||
| // ePaintMode mode = ePaintGpencil; | |||||
| if (br) { | |||||
| br = BKE_brush_copy(bmain, br); | |||||
| } | |||||
| else { | |||||
| br = BKE_brush_add(bmain, "Brush", OB_MODE_GPENCIL_PAINT); | |||||
| id_us_min(&br->id); /* fake user only */ | |||||
| } | |||||
| BKE_paint_brush_set(paint, br); | |||||
| /* TODO init grease pencil specific data */ | |||||
| return OPERATOR_FINISHED; | |||||
| } | |||||
| static void BRUSH_OT_add_gpencil(wmOperatorType *ot) | |||||
| { | |||||
| /* identifiers */ | |||||
| ot->name = "Add Drawing Brush"; | |||||
| ot->description = "Add brush for grease pencil"; | |||||
| ot->idname = "BRUSH_OT_add_gpencil"; | |||||
| /* api callbacks */ | |||||
| ot->exec = brush_add_gpencil_exec; | |||||
| /* flags */ | |||||
| ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; | |||||
| } | |||||
| static int brush_scale_size_exec(bContext *C, wmOperator *op) | static int brush_scale_size_exec(bContext *C, wmOperator *op) | ||||
| { | { | ||||
| Scene *scene = CTX_data_scene(C); | Scene *scene = CTX_data_scene(C); | ||||
| Paint *paint = BKE_paint_get_active_from_context(C); | Paint *paint = BKE_paint_get_active_from_context(C); | ||||
| Brush *brush = BKE_paint_brush(paint); | Brush *brush = BKE_paint_brush(paint); | ||||
| // Object *ob = CTX_data_active_object(C); | // Object *ob = CTX_data_active_object(C); | ||||
| float scalar = RNA_float_get(op->ptr, "scalar"); | float scalar = RNA_float_get(op->ptr, "scalar"); | ||||
| ▲ Show 20 Lines • Show All 120 Lines • ▼ Show 20 Lines | static void PALETTE_OT_color_add(wmOperatorType *ot) | ||||
| /* api callbacks */ | /* api callbacks */ | ||||
| ot->exec = palette_color_add_exec; | ot->exec = palette_color_add_exec; | ||||
| ot->poll = palette_poll; | ot->poll = palette_poll; | ||||
| /* flags */ | /* flags */ | ||||
| ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; | ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; | ||||
| } | } | ||||
| static int palette_color_delete_exec(bContext *C, wmOperator *UNUSED(op)) | static int palette_color_delete_exec(bContext *C, wmOperator *UNUSED(op)) | ||||
| { | { | ||||
| Paint *paint = BKE_paint_get_active_from_context(C); | Paint *paint = BKE_paint_get_active_from_context(C); | ||||
| Palette *palette = paint->palette; | Palette *palette = paint->palette; | ||||
| PaletteColor *color = BLI_findlink(&palette->colors, palette->active_color); | PaletteColor *color = BLI_findlink(&palette->colors, palette->active_color); | ||||
| if (color) { | if (color) { | ||||
| BKE_palette_color_remove(palette, color); | BKE_palette_color_remove(palette, color); | ||||
| ▲ Show 20 Lines • Show All 782 Lines • ▼ Show 20 Lines | void ED_operatortypes_paint(void) | ||||
| WM_operatortype_append(PAINTCURVE_OT_delete_point); | WM_operatortype_append(PAINTCURVE_OT_delete_point); | ||||
| WM_operatortype_append(PAINTCURVE_OT_select); | WM_operatortype_append(PAINTCURVE_OT_select); | ||||
| WM_operatortype_append(PAINTCURVE_OT_slide); | WM_operatortype_append(PAINTCURVE_OT_slide); | ||||
| WM_operatortype_append(PAINTCURVE_OT_draw); | WM_operatortype_append(PAINTCURVE_OT_draw); | ||||
| WM_operatortype_append(PAINTCURVE_OT_cursor); | WM_operatortype_append(PAINTCURVE_OT_cursor); | ||||
| /* brush */ | /* brush */ | ||||
| WM_operatortype_append(BRUSH_OT_add); | WM_operatortype_append(BRUSH_OT_add); | ||||
| WM_operatortype_append(BRUSH_OT_add_gpencil); | |||||
| WM_operatortype_append(BRUSH_OT_scale_size); | WM_operatortype_append(BRUSH_OT_scale_size); | ||||
| WM_operatortype_append(BRUSH_OT_curve_preset); | WM_operatortype_append(BRUSH_OT_curve_preset); | ||||
| WM_operatortype_append(BRUSH_OT_reset); | WM_operatortype_append(BRUSH_OT_reset); | ||||
| WM_operatortype_append(BRUSH_OT_stencil_control); | WM_operatortype_append(BRUSH_OT_stencil_control); | ||||
| WM_operatortype_append(BRUSH_OT_stencil_fit_image_aspect); | WM_operatortype_append(BRUSH_OT_stencil_fit_image_aspect); | ||||
| WM_operatortype_append(BRUSH_OT_stencil_reset_transform); | WM_operatortype_append(BRUSH_OT_stencil_reset_transform); | ||||
| /* note, particle uses a different system, can be added with existing operators in wm.py */ | /* note, particle uses a different system, can be added with existing operators in wm.py */ | ||||
| ▲ Show 20 Lines • Show All 431 Lines • Show Last 20 Lines | |||||