Fix #35640, part 2. Check id.lib in poll functions for operators which do critical...
[blender.git] / source / blender / editors / gpencil / gpencil_ops.c
1 /*
2  * ***** BEGIN GPL LICENSE BLOCK *****
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License
6  * as published by the Free Software Foundation; either version 2
7  * of the License, or (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software Foundation,
16  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17  *
18  * The Original Code is Copyright (C) 2009, Blender Foundation, Joshua Leung
19  * This is a new part of Blender
20  *
21  * Contributor(s): Joshua Leung
22  *
23  * ***** END GPL LICENSE BLOCK *****
24  */
25
26 /** \file blender/editors/gpencil/gpencil_ops.c
27  *  \ingroup edgpencil
28  */
29
30
31 #include <stdlib.h>
32 #include <stddef.h>
33 #include <stdio.h>
34
35 #include "BLI_sys_types.h"
36
37 #include "BLI_blenlib.h"
38
39 #include "WM_api.h"
40 #include "WM_types.h"
41
42 #include "RNA_access.h"
43
44 #include "ED_gpencil.h"
45
46 #include "gpencil_intern.h"
47
48 /* ****************************************** */
49 /* Generic Editing Keymap */
50
51 void ED_keymap_gpencil(wmKeyConfig *keyconf)
52 {
53         wmKeyMap *keymap = WM_keymap_find(keyconf, "Grease Pencil", 0, 0);
54         wmKeyMapItem *kmi;
55         
56         /* Draw */
57
58         /* draw */
59         kmi = WM_keymap_add_item(keymap, "GPENCIL_OT_draw", LEFTMOUSE, KM_PRESS, 0, DKEY);
60         RNA_enum_set(kmi->ptr, "mode", GP_PAINTMODE_DRAW);
61
62         /* draw - straight lines */
63         kmi = WM_keymap_add_item(keymap, "GPENCIL_OT_draw", LEFTMOUSE, KM_PRESS, KM_CTRL, DKEY);
64         RNA_enum_set(kmi->ptr, "mode", GP_PAINTMODE_DRAW_STRAIGHT);
65
66         /* draw - poly lines */
67         kmi = WM_keymap_add_item(keymap, "GPENCIL_OT_draw", RIGHTMOUSE, KM_PRESS, KM_CTRL, DKEY);
68         RNA_enum_set(kmi->ptr, "mode", GP_PAINTMODE_DRAW_POLY);
69
70         /* erase */
71         kmi = WM_keymap_add_item(keymap, "GPENCIL_OT_draw", RIGHTMOUSE, KM_PRESS, 0, DKEY);
72         RNA_enum_set(kmi->ptr, "mode", GP_PAINTMODE_ERASER);
73 }
74
75 /* ****************************************** */
76
77 void ED_operatortypes_gpencil(void)
78 {
79         /* Drawing ----------------------- */
80         
81         WM_operatortype_append(GPENCIL_OT_draw);
82         
83         /* Editing (Buttons) ------------ */
84         
85         WM_operatortype_append(GPENCIL_OT_data_add);
86         WM_operatortype_append(GPENCIL_OT_data_unlink);
87         
88         WM_operatortype_append(GPENCIL_OT_layer_add);
89         
90         WM_operatortype_append(GPENCIL_OT_active_frame_delete);
91         
92         WM_operatortype_append(GPENCIL_OT_convert);
93         
94         /* Editing (Time) --------------- */
95 }
96
97 /* ****************************************** */