2.5: gesture code in WM
[blender-staging.git] / source / blender / editors / screen / screen_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  * ***** END GPL LICENSE BLOCK *****
25  */
26
27 #include "MEM_guardedalloc.h"
28
29 #include "BLI_blenlib.h"
30
31 #include "BKE_global.h"
32 #include "BKE_library.h"
33 #include "BKE_main.h"
34 #include "BKE_screen.h"
35 #include "BKE_utildefines.h"
36
37 #include "WM_api.h"
38 #include "WM_types.h"
39
40 #include "ED_area.h"
41 #include "ED_screen.h"
42
43 #include "screen_intern.h"      /* own module include */
44
45 /* ************** Poll tests ********************** */
46
47 int ED_operator_areaactive(bContext *C)
48 {
49         if(C->window==NULL) return 0;
50         if(C->screen==NULL) return 0;
51         if(C->area==NULL) return 0;
52         return 1;
53 }
54
55 int ED_operator_screenactive(bContext *C)
56 {
57         if(C->window==NULL) return 0;
58         if(C->screen==NULL) return 0;
59         return 1;
60 }
61
62 /* when mouse is over area-edge */
63 int ED_operator_screen_mainwinactive(bContext *C)
64 {
65         if(C->window==NULL) return 0;
66         if(C->screen==NULL) return 0;
67         if (C->screen->subwinactive!=C->screen->mainwin) return 0;
68         return 1;
69 }
70
71 /* ******************************* */
72
73 static void ED_SCR_OT_cursor_type(wmOperatorType *ot)
74 {
75     ot->name= "Cursor type";
76     ot->idname= "ED_SCR_OT_cursor_type";
77         
78     ot->invoke= screen_cursor_test;
79     ot->poll= ED_operator_screenactive;
80 }
81
82 /* called in spacetypes.c */
83 void ED_operatortypes_screen(void)
84 {
85         /* generic UI stuff */
86         WM_operatortype_append(ED_SCR_OT_cursor_type);
87         WM_operatortype_append(ED_SCR_OT_actionzone);
88         
89         /* tools */
90         WM_operatortype_append(ED_SCR_OT_move_areas);
91         WM_operatortype_append(ED_SCR_OT_split_area);
92         WM_operatortype_append(ED_SCR_OT_join_areas);
93         WM_operatortype_append(ED_SCR_OT_area_rip);
94         
95         /* for test only */
96         WM_operatortype_append(ED_SCR_OT_border_select);
97 }
98
99 /* called in spacetypes.c */
100 void ED_keymap_screen(wmWindowManager *wm)
101 {
102         WM_keymap_verify_item(&wm->screenkeymap, "ED_SCR_OT_cursor_type", MOUSEMOVE, 0, 0, 0);
103         WM_keymap_verify_item(&wm->screenkeymap, "ED_SCR_OT_actionzone", LEFTMOUSE, KM_PRESS, 0, 0);
104         
105         WM_keymap_verify_item(&wm->screenkeymap, "ED_SCR_OT_move_areas", LEFTMOUSE, KM_PRESS, 0, 0);
106         WM_keymap_verify_item(&wm->screenkeymap, "ED_SCR_OT_split_area", EVT_ACTIONZONE, 0, 0, 0);      /* action tria */
107         WM_keymap_verify_item(&wm->screenkeymap, "ED_SCR_OT_join_areas", EVT_ACTIONZONE, 0, 0, 0);      /* action tria */ 
108         WM_keymap_verify_item(&wm->windowkeymap, "ED_SCR_OT_area_rip", RKEY, KM_PRESS, KM_ALT, 0);
109
110         /* for test only */
111         WM_keymap_verify_item(&wm->windowkeymap, "ED_SCR_OT_border_select", BKEY, KM_PRESS, 0, 0);
112
113 }
114