bd818f6c747c9c9a5167f16fe3109d03d6592156
[blender.git] / source / blender / editors / space_view3d / view3d_ops.c
1 /**
2  * $Id:
3  *
4  * ***** BEGIN GPL LICENSE BLOCK *****
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 2
9  * of the License, or (at your option) any later version. 
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software Foundation,
18  * Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
19  *
20  * The Original Code is Copyright (C) 2008 Blender Foundation.
21  * All rights reserved.
22  *
23  * 
24  * Contributor(s): Blender Foundation
25  *
26  * ***** END GPL LICENSE BLOCK *****
27  */
28
29 #include <stdlib.h>
30 #include <math.h>
31
32 #include "MEM_guardedalloc.h"
33
34 #include "DNA_object_types.h"
35 #include "DNA_scene_types.h"
36 #include "DNA_screen_types.h"
37 #include "DNA_space_types.h"
38 #include "DNA_userdef_types.h"
39 #include "DNA_view3d_types.h"
40 #include "DNA_windowmanager_types.h"
41
42 #include "BLI_arithb.h"
43 #include "BLI_blenlib.h"
44
45 #include "BKE_context.h"
46 #include "BKE_global.h"
47 #include "BKE_utildefines.h"
48
49 #include "RNA_access.h"
50 #include "RNA_define.h"
51
52 #include "WM_api.h"
53 #include "WM_types.h"
54
55 #include "ED_screen.h"
56
57 #include "view3d_intern.h"
58
59
60 /* ************************** registration **********************************/
61
62 void view3d_operatortypes(void)
63 {
64         WM_operatortype_append(ED_VIEW3D_OT_viewrotate);
65         WM_operatortype_append(ED_VIEW3D_OT_viewmove);
66         WM_operatortype_append(ED_VIEW3D_OT_viewzoom);
67         WM_operatortype_append(ED_VIEW3D_OT_viewhome);
68         WM_operatortype_append(ED_VIEW3D_OT_viewcenter);
69         WM_operatortype_append(ED_VIEW3D_OT_select);
70         WM_operatortype_append(ED_VIEW3D_OT_borderselect);
71 }
72
73 void view3d_keymap(wmWindowManager *wm)
74 {
75         ListBase *keymap= WM_keymap_listbase(wm, "View3D", SPACE_VIEW3D, 0);
76         
77         WM_keymap_verify_item(keymap, "ED_VIEW3D_OT_viewrotate", MIDDLEMOUSE, KM_PRESS, 0, 0);
78         WM_keymap_verify_item(keymap, "ED_VIEW3D_OT_viewmove", MIDDLEMOUSE, KM_PRESS, KM_SHIFT, 0);
79         WM_keymap_verify_item(keymap, "ED_VIEW3D_OT_viewzoom", MIDDLEMOUSE, KM_PRESS, KM_CTRL, 0);
80         WM_keymap_verify_item(keymap, "ED_VIEW3D_OT_viewcenter", PADPERIOD, KM_PRESS, 0, 0);
81         
82         RNA_int_set(WM_keymap_add_item(keymap, "ED_VIEW3D_OT_viewzoom", PADPLUSKEY, KM_PRESS, 0, 0)->ptr, "delta", 1);
83         RNA_int_set(WM_keymap_add_item(keymap, "ED_VIEW3D_OT_viewzoom", PADMINUS, KM_PRESS, 0, 0)->ptr, "delta", -1);
84         RNA_int_set(WM_keymap_add_item(keymap, "ED_VIEW3D_OT_viewzoom", WHEELUPMOUSE, KM_ANY, 0, 0)->ptr, "delta", 1);
85         RNA_int_set(WM_keymap_add_item(keymap, "ED_VIEW3D_OT_viewzoom", WHEELDOWNMOUSE, KM_ANY, 0, 0)->ptr, "delta", -1);
86
87         RNA_boolean_set(WM_keymap_add_item(keymap, "ED_VIEW3D_OT_viewhome", HOMEKEY, KM_PRESS, 0, 0)->ptr, "center", 0);
88         RNA_boolean_set(WM_keymap_add_item(keymap, "ED_VIEW3D_OT_viewhome", CKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "center", 1);
89
90         WM_keymap_add_item(keymap, "ED_VIEW3D_OT_select", SELECTMOUSE, KM_PRESS, 0, 0);
91         WM_keymap_add_item(keymap, "ED_VIEW3D_OT_borderselect", BKEY, KM_PRESS, 0, 0);
92
93 }
94