Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/space_view3d/view3d_ruler.c
| Context not available. | |||||
| #include "DNA_scene_types.h" | #include "DNA_scene_types.h" | ||||
| #include "DNA_object_types.h" | #include "DNA_object_types.h" | ||||
| #include "DNA_gpencil_types.h" | #include "DNA_gpencil_types.h" | ||||
| #include "DNA_brush_types.h" | |||||
| #include "MEM_guardedalloc.h" | #include "MEM_guardedalloc.h" | ||||
| Context not available. | |||||
| #include "BKE_context.h" | #include "BKE_context.h" | ||||
| #include "BKE_unit.h" | #include "BKE_unit.h" | ||||
| #include "BKE_gpencil.h" | #include "BKE_gpencil.h" | ||||
| #include "BKE_paint.h" | |||||
| #include "BIF_gl.h" | #include "BIF_gl.h" | ||||
| Context not available. | |||||
| bGPDlayer *gpl; | bGPDlayer *gpl; | ||||
| bGPDframe *gpf; | bGPDframe *gpf; | ||||
| bGPDstroke *gps; | bGPDstroke *gps; | ||||
| bGPDpalette *palette; | bGPDpaletteref *palslot; | ||||
| bGPDpalettecolor *palcolor; | Palette *palette; | ||||
| PaletteColor *palcolor; | |||||
| RulerItem *ruler_item; | RulerItem *ruler_item; | ||||
| const char *ruler_name = RULER_ID; | const char *ruler_name = RULER_ID; | ||||
| bool changed = false; | bool changed = false; | ||||
| Context not available. | |||||
| } | } | ||||
| /* try to get active palette or create a new one */ | /* try to get active palette or create a new one */ | ||||
| palette = BKE_gpencil_palette_getactive(scene->gpd); | palslot = BKE_gpencil_paletteslot_validate(CTX_data_main(C), scene->gpd); | ||||
| if (palette == NULL) { | palette = palslot->palette; | ||||
| palette = BKE_gpencil_palette_addnew(scene->gpd, DATA_("GP_Palette"), true); | |||||
| } | |||||
| /* try to get color with the ruler name or create a new one */ | /* try to get color with the ruler name or create a new one */ | ||||
| palcolor = BKE_gpencil_palettecolor_getbyname(palette, (char *)ruler_name); | palcolor = BKE_palette_color_getbyname(palette, (char *)ruler_name); | ||||
| if (palcolor == NULL) { | if (palcolor == NULL) { | ||||
| palcolor = BKE_gpencil_palettecolor_addnew(palette, (char *)ruler_name, true); | palcolor = BKE_palette_color_add_name(palette, (char *)ruler_name); | ||||
| } | } | ||||
| gpf = BKE_gpencil_layer_getframe(gpl, CFRA, true); | gpf = BKE_gpencil_layer_getframe(gpl, CFRA, true); | ||||
| Context not available. | |||||
| gps->thickness = 3; | gps->thickness = 3; | ||||
| /* assign color to stroke */ | /* assign color to stroke */ | ||||
| BLI_strncpy(gps->colorname, palcolor->info, sizeof(gps->colorname)); | BLI_strncpy(gps->colorname, palcolor->info, sizeof(gps->colorname)); | ||||
| gps->palette = palette; | |||||
| gps->palcolor = palcolor; | gps->palcolor = palcolor; | ||||
| BLI_addtail(&gpf->strokes, gps); | BLI_addtail(&gpf->strokes, gps); | ||||
| changed = true; | changed = true; | ||||
| Context not available. | |||||