4 * ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
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. The Blender
10 * Foundation also sells licenses for use in proprietary software under
11 * the Blender License. See http://www.blender.org/BL/ for information
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software Foundation,
21 * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23 * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
24 * All rights reserved.
26 * The Original Code is: all of this file.
28 * Contributor(s): none yet.
30 * ***** END GPL/BL DUAL LICENSE BLOCK *****
40 #include "BLI_winstuff.h"
43 #include "DNA_listBase.h"
44 #include "DNA_userdef_types.h"
46 #include "BIF_cursors.h"
47 #include "BIF_resources.h"
48 #include "BIF_graphics.h"
49 #include "BIF_screen.h"
51 #include "GHOST_C-api.h"
55 /* ******************************************************************
58 Each bit represents a pixel, so 1 byte = 8 pixels,
59 the bytes go Left to Right. Top to bottom
60 the bits in a byte go right to left
61 (ie; 0x01, 0x80 represents a line of 16 pix with the first and last pix set.)
63 A 0 in the bitmap = bg_color, a 1 fg_color
64 a 0 in the mask = transparent pix.
66 Until 32x32 cursors are supported on all platforms, the size of the
67 small cursors MUST be 16x16.
69 Large cursors have a MAXSIZE of 32x32.
71 Other than that, the specified size of the cursors is just a guideline,
72 However, the char array that defines the BM and MASK must be byte aligned.
73 ie a 17x17 cursor needs 3 bytes (cols) * 17 bytes (rows)
74 (3 bytes = 17 bits rounded up to nearest whole byte). Pad extra bits
77 Setting big_bm=NULL disables the large version of the cursor.
79 ******************************************************************* */
81 /* Because defining a cursor mixes declarations and executable code
82 each cursor needs it's own scoping block or it would be split up
83 over several hundred lines of code. To enforce/document this better
84 I define 2 pretty braindead macros so it's obvious what the extra "[]"
87 #define BEGIN_CURSOR_BLOCK {
88 #define END_CURSOR_BLOCK }
91 static BCursor *BlenderCursor[BC_NUMCURSORS]; /*Points to static BCursor Structs */
92 static short CurrentCursor=-1, LastCursor=-1;
94 void SetBlenderCursor(short curs){
97 if ((curs<LASTCURSOR)||(curs>=BC_NUMCURSORS)) return;
99 win=winlay_get_active_window();
101 if (win==NULL) return; /* Can't set custom cursor before Window init */
102 if (win->ghostwin==NULL) return;
104 LastCursor=CurrentCursor;
107 if (curs==LASTCURSOR) curs=LastCursor;
109 if (curs==SYSCURSOR) { /* System default Cursor */
110 set_cursor(CURSOR_STD);
112 else if ( (U.curssize==0) || (BlenderCursor[curs]->big_bm == NULL) ) {
113 printf("setting small cursor\n");
114 GHOST_SetCustomCursorShapeEx(win->ghostwin,
115 BlenderCursor[curs]->small_bm, BlenderCursor[curs]->small_mask,
116 BlenderCursor[curs]->small_sizex,BlenderCursor[curs]->small_sizey,
117 BlenderCursor[curs]->small_hotx,BlenderCursor[curs]->small_hoty,
118 BlenderCursor[curs]->fg_color, BlenderCursor[curs]->bg_color
122 printf("setting big cursor\n");
123 GHOST_SetCustomCursorShapeEx(win->ghostwin,
124 BlenderCursor[curs]->big_bm, BlenderCursor[curs]->big_mask,
125 BlenderCursor[curs]->big_sizex,BlenderCursor[curs]->big_sizey,
126 BlenderCursor[curs]->big_hotx,BlenderCursor[curs]->big_hoty,
127 BlenderCursor[curs]->fg_color, BlenderCursor[curs]->bg_color
134 short GetCurrentCursor(void){
135 return(CurrentCursor);
139 void InitCursorData(void){
141 /********************** NW_ARROW Cursor **************************/
143 static char nw_sbm[]={
144 0x03, 0x00, 0x05, 0x00, 0x09, 0x00, 0x11, 0x00,
145 0x21, 0x00, 0x41, 0x00, 0x81, 0x00, 0x01, 0x01,
146 0x01, 0x02, 0xc1, 0x03, 0x49, 0x00, 0x8d, 0x00,
147 0x8b, 0x00, 0x10, 0x01, 0x90, 0x01, 0x60, 0x00,
150 static char nw_smsk[]={
151 0x03, 0x00, 0x07, 0x00, 0x0f, 0x00, 0x1f, 0x00,
152 0x3f, 0x00, 0x7f, 0x00, 0xff, 0x00, 0xff, 0x01,
153 0xff, 0x03, 0xff, 0x03, 0x7f, 0x00, 0xff, 0x00,
154 0xfb, 0x00, 0xf0, 0x01, 0xf0, 0x01, 0x60, 0x00,
157 static BCursor NWArrowCursor = {
170 BlenderCursor[BC_NW_ARROWCURSOR]=&NWArrowCursor;
173 ///********************** NS_ARROW Cursor *************************/
175 static char ns_sbm[]={
176 0x40, 0x01, 0x20, 0x02, 0x10, 0x04, 0x08, 0x08,
177 0x04, 0x10, 0x3c, 0x1e, 0x20, 0x02, 0x20, 0x02,
178 0x20, 0x02, 0x20, 0x02, 0x3c, 0x1e, 0x04, 0x10,
179 0x08, 0x08, 0x10, 0x04, 0x20, 0x02, 0x40, 0x01
182 static char ns_smsk[]={
183 0xc0, 0x01, 0xe0, 0x03, 0xf0, 0x07, 0xf8, 0x0f,
184 0xfc, 0x1f, 0xfc, 0x1f, 0xe0, 0x03, 0xe0, 0x03,
185 0xe0, 0x03, 0xe0, 0x03, 0xfc, 0x1f, 0xfc, 0x1f,
186 0xf8, 0x0f, 0xf0, 0x07, 0xe0, 0x03, 0xc0, 0x01
189 static BCursor NSArrowCursor = {
202 BlenderCursor[BC_NS_ARROWCURSOR]=&NSArrowCursor;
205 /********************** EW_ARROW Cursor *************************/
207 static char ew_sbm[]={
208 0x00, 0x00, 0x00, 0x00, 0x10, 0x08, 0x38, 0x1c,
209 0x2c, 0x34, 0xe6, 0x67, 0x03, 0xc0, 0x01, 0x80,
210 0x03, 0xc0, 0xe6, 0x67, 0x2c, 0x34, 0x38, 0x1c,
211 0x10, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
214 static char ew_smsk[]={
215 0x00, 0x00, 0x00, 0x00, 0x10, 0x08, 0x38, 0x1c,
216 0x3c, 0x3c, 0xfe, 0x7f, 0xff, 0xff, 0x3f, 0xfc,
217 0xff, 0xff, 0xfe, 0x7f, 0x3c, 0x3c, 0x38, 0x1c,
218 0x10, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
221 static BCursor EWArrowCursor = {
234 BlenderCursor[BC_EW_ARROWCURSOR]=&EWArrowCursor;
237 /********************** Wait Cursor *****************************/
239 static char wait_sbm[]={
240 0xfe, 0x7f, 0x02, 0x40, 0x02, 0x40, 0x84, 0x21,
241 0xc8, 0x13, 0xd0, 0x0b, 0xa0, 0x04, 0x20, 0x05,
242 0xa0, 0x04, 0x10, 0x09, 0x88, 0x11, 0xc4, 0x23,
243 0xe2, 0x47, 0xfa, 0x5f, 0x02, 0x40, 0xfe, 0x7f,
246 static char wait_smsk[]={
247 0xfe, 0x7f, 0xfe, 0x7f, 0x06, 0x60, 0x8c, 0x31,
248 0xd8, 0x1b, 0xf0, 0x0f, 0xe0, 0x06, 0x60, 0x07,
249 0xe0, 0x06, 0x30, 0x0d, 0x98, 0x19, 0xcc, 0x33,
250 0xe6, 0x67, 0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f,
253 static char wait_lbm[]={
254 0xfc, 0xff, 0xff, 0x3f, 0xfc, 0xff, 0xff, 0x3f,
255 0x0c, 0x00, 0x00, 0x30, 0x0c, 0x00, 0x00, 0x30,
256 0x0c, 0x00, 0x00, 0x30, 0x0c, 0x00, 0x00, 0x18,
257 0x18, 0xc0, 0x03, 0x0c, 0x30, 0x20, 0x07, 0x06,
258 0x60, 0xf0, 0x0f, 0x03, 0xc0, 0xd0, 0x8d, 0x01,
259 0x80, 0x79, 0xcf, 0x00, 0x00, 0xf3, 0x67, 0x00,
260 0x00, 0x66, 0x37, 0x00, 0x00, 0x8c, 0x33, 0x00,
261 0x00, 0x0c, 0x32, 0x00, 0x00, 0xcc, 0x33, 0x00,
262 0x00, 0x8c, 0x30, 0x00, 0x00, 0x46, 0x61, 0x00,
263 0x00, 0x03, 0xc3, 0x00, 0x80, 0x01, 0x83, 0x01,
264 0xc0, 0xc0, 0x03, 0x03, 0x60, 0xa0, 0x05, 0x06,
265 0x30, 0xf0, 0x0f, 0x0c, 0x18, 0xf8, 0x1d, 0x18,
266 0x0c, 0x5c, 0x3f, 0x30, 0x0c, 0xff, 0x5f, 0x30,
267 0x0c, 0xf7, 0xfe, 0x31, 0xcc, 0xfb, 0x9f, 0x33,
268 0x0c, 0x00, 0x00, 0x30, 0x0c, 0x00, 0x00, 0x30,
269 0xfc, 0xff, 0xff, 0x3f, 0xfc, 0xff, 0xff, 0x3f,
272 static char wait_lmsk[]={
273 0xfc, 0xff, 0xff, 0x3f, 0xfc, 0xff, 0xff, 0x3f,
274 0xfc, 0xff, 0xff, 0x3f, 0xfc, 0xff, 0xff, 0x3f,
275 0x3c, 0x00, 0x00, 0x3c, 0x3c, 0x00, 0x00, 0x1e,
276 0x78, 0xc0, 0x03, 0x0f, 0xf0, 0xa0, 0x87, 0x07,
277 0xe0, 0xf1, 0xcf, 0x03, 0xc0, 0xf3, 0xef, 0x01,
278 0x80, 0xff, 0xff, 0x00, 0x00, 0xff, 0x7f, 0x00,
279 0x00, 0xfe, 0x3f, 0x00, 0x00, 0xfc, 0x3f, 0x00,
280 0x00, 0x3c, 0x3f, 0x00, 0x00, 0xfc, 0x3f, 0x00,
281 0x00, 0xbc, 0x3c, 0x00, 0x00, 0xde, 0x79, 0x00,
282 0x00, 0x0f, 0xf3, 0x00, 0x80, 0x07, 0xe3, 0x01,
283 0xc0, 0xc3, 0xc3, 0x03, 0xe0, 0xe1, 0x87, 0x07,
284 0xf0, 0xf0, 0x0f, 0x0f, 0x78, 0xf8, 0x1f, 0x1e,
285 0x3c, 0x7c, 0x3f, 0x3c, 0x3c, 0xff, 0x7f, 0x3c,
286 0xbc, 0xff, 0xff, 0x3d, 0xfc, 0xfb, 0xbf, 0x3f,
287 0xfc, 0xff, 0xff, 0x3f, 0xfc, 0xff, 0xff, 0x3f,
288 0xfc, 0xff, 0xff, 0x3f, 0xfc, 0xff, 0xff, 0x3f,
291 static BCursor WaitCursor = {
304 BlenderCursor[BC_WAITCURSOR]=&WaitCursor;
307 /********************** Cross Cursor ***************************/
309 static char cross_sbm[]={
310 0x00, 0x00, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01,
311 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0x7e, 0x7e,
312 0x7e, 0x7e, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01,
313 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0x00, 0x00,
316 static char cross_smsk[]={
317 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01,
318 0x80, 0x01, 0x80, 0x01, 0xc0, 0x03, 0x7f, 0xfe,
319 0x7f, 0xfe, 0xc0, 0x03, 0x80, 0x01, 0x80, 0x01,
320 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01,
322 static char cross_lbm[]={
323 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
324 0x00, 0x80, 0x01, 0x00, 0x00, 0x80, 0x01, 0x00,
325 0x00, 0x80, 0x01, 0x00, 0x00, 0x80, 0x01, 0x00,
326 0x00, 0x80, 0x01, 0x00, 0x00, 0x80, 0x01, 0x00,
327 0x00, 0x80, 0x01, 0x00, 0x00, 0x80, 0x01, 0x00,
328 0x00, 0x80, 0x01, 0x00, 0x00, 0xc0, 0x03, 0x00,
329 0x00, 0xc0, 0x03, 0x00, 0x00, 0x40, 0x02, 0x00,
330 0x00, 0x78, 0x1e, 0x00, 0xfc, 0x1f, 0xf8, 0x3f,
331 0xfc, 0x1f, 0xf8, 0x3f, 0x00, 0x78, 0x1e, 0x00,
332 0x00, 0x40, 0x02, 0x00, 0x00, 0xc0, 0x03, 0x00,
333 0x00, 0xc0, 0x03, 0x00, 0x00, 0x80, 0x01, 0x00,
334 0x00, 0x80, 0x01, 0x00, 0x00, 0x80, 0x01, 0x00,
335 0x00, 0x80, 0x01, 0x00, 0x00, 0x80, 0x01, 0x00,
336 0x00, 0x80, 0x01, 0x00, 0x00, 0x80, 0x01, 0x00,
337 0x00, 0x80, 0x01, 0x00, 0x00, 0x80, 0x01, 0x00,
338 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
341 static char cross_lmsk[]={
342 0x00, 0x80, 0x01, 0x00, 0x00, 0x80, 0x01, 0x00,
343 0x00, 0x80, 0x01, 0x00, 0x00, 0x80, 0x01, 0x00,
344 0x00, 0x80, 0x01, 0x00, 0x00, 0x80, 0x01, 0x00,
345 0x00, 0x80, 0x01, 0x00, 0x00, 0x80, 0x01, 0x00,
346 0x00, 0x80, 0x01, 0x00, 0x00, 0x80, 0x01, 0x00,
347 0x00, 0x80, 0x01, 0x00, 0x00, 0xc0, 0x03, 0x00,
348 0x00, 0xe0, 0x07, 0x00, 0x00, 0x70, 0x0e, 0x00,
349 0x00, 0x78, 0x1e, 0x00, 0xff, 0x1f, 0xf8, 0xff,
350 0xff, 0x1f, 0xf8, 0xff, 0x00, 0x78, 0x1e, 0x00,
351 0x00, 0x70, 0x0e, 0x00, 0x00, 0xe0, 0x07, 0x00,
352 0x00, 0xc0, 0x03, 0x00, 0x00, 0x80, 0x01, 0x00,
353 0x00, 0x80, 0x01, 0x00, 0x00, 0x80, 0x01, 0x00,
354 0x00, 0x80, 0x01, 0x00, 0x00, 0x80, 0x01, 0x00,
355 0x00, 0x80, 0x01, 0x00, 0x00, 0x80, 0x01, 0x00,
356 0x00, 0x80, 0x01, 0x00, 0x00, 0x80, 0x01, 0x00,
357 0x00, 0x80, 0x01, 0x00, 0x00, 0x80, 0x01, 0x00,
360 static BCursor CrossCursor = {
362 cross_sbm, cross_smsk,
366 cross_lbm, cross_lmsk,
373 BlenderCursor[BC_CROSSCURSOR]=&CrossCursor;
376 /********************** EditCross Cursor ***********************/
378 static char editcross_sbm[]={
379 0x0e, 0x00, 0x11, 0x00, 0x1d, 0x00, 0x19, 0x03,
380 0x1d, 0x03, 0x11, 0x03, 0x0e, 0x03, 0x00, 0x03,
381 0xf8, 0x7c, 0xf8, 0x7c, 0x00, 0x03, 0x00, 0x03,
382 0x00, 0x03, 0x00, 0x03, 0x00, 0x03, 0x00, 0x00,
385 static char editcross_smsk[]={
386 0x0e, 0x00, 0x1f, 0x00, 0x1f, 0x03, 0x1f, 0x03,
387 0x1f, 0x03, 0x1f, 0x03, 0x0e, 0x03, 0x80, 0x07,
388 0xfc, 0xfc, 0xfc, 0xfc, 0x80, 0x07, 0x00, 0x03,
389 0x00, 0x03, 0x00, 0x03, 0x00, 0x03, 0x00, 0x03,
392 static BCursor EditCrossCursor = {
394 editcross_sbm, editcross_smsk,
405 BlenderCursor[BC_EDITCROSSCURSOR]=&EditCrossCursor;
408 /********************** Box Select *************************/
410 static char box_sbm[32]={
411 0x7f, 0x00, 0x41, 0x00, 0x41, 0x00, 0x41, 0x06,
412 0x41, 0x06, 0x41, 0x06, 0x7f, 0x06, 0x00, 0x06,
413 0xe0, 0x79, 0xe0, 0x79, 0x00, 0x06, 0x00, 0x06,
414 0x00, 0x06, 0x00, 0x06, 0x00, 0x06, 0x00, 0x00,
417 static char box_smsk[32]={
418 0x7f, 0x00, 0x7f, 0x00, 0x63, 0x06, 0x63, 0x06,
419 0x63, 0x06, 0x7f, 0x06, 0x7f, 0x06, 0x00, 0x0f,
420 0xf0, 0xf9, 0xf0, 0xf9, 0x00, 0x0f, 0x00, 0x06,
421 0x00, 0x06, 0x00, 0x06, 0x00, 0x06, 0x00, 0x06,
425 static BCursor BoxSelCursor = {
438 BlenderCursor[BC_BOXSELCURSOR]=&BoxSelCursor;
441 /********************** Knife Cursor ***********************/
443 static char knife_sbm[]={
444 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x2c,
445 0x00, 0x5a, 0x00, 0x34, 0x00, 0x2a, 0x00, 0x17,
446 0x80, 0x06, 0x40, 0x03, 0xa0, 0x03, 0xd0, 0x01,
447 0x68, 0x00, 0x1c, 0x00, 0x06, 0x00, 0x00, 0x00
450 static char knife_smsk[]={
451 0x00, 0x60, 0x00, 0xf0, 0x00, 0xfc, 0x00, 0xfe,
452 0x00, 0xfe, 0x00, 0x7e, 0x00, 0x7f, 0x80, 0x3f,
453 0xc0, 0x0e, 0x60, 0x07, 0xb0, 0x07, 0xd8, 0x03,
454 0xec, 0x01, 0x7e, 0x00, 0x1f, 0x00, 0x07, 0x00
457 static char knife_lbm[]={
458 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
459 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
460 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x1c,
461 0x00, 0x00, 0x00, 0x3e, 0x00, 0x00, 0x00, 0x7f,
462 0x00, 0x00, 0x80, 0xbf, 0x00, 0x00, 0xc0, 0x5f,
463 0x00, 0x00, 0xc0, 0x6f, 0x00, 0x00, 0xc0, 0x37,
464 0x00, 0x00, 0xa8, 0x1b, 0x00, 0x00, 0x54, 0x0d,
465 0x00, 0x00, 0xa8, 0x00, 0x00, 0x00, 0x54, 0x00,
466 0x00, 0x00, 0xa8, 0x00, 0x00, 0x00, 0x53, 0x00,
467 0x00, 0xc0, 0x07, 0x00, 0x00, 0xe0, 0x0f, 0x00,
468 0x00, 0xd0, 0x0f, 0x00, 0x00, 0xe8, 0x07, 0x00,
469 0x00, 0xf4, 0x07, 0x00, 0x00, 0xfa, 0x00, 0x00,
470 0x00, 0x3d, 0x00, 0x00, 0x80, 0x0e, 0x00, 0x00,
471 0xc0, 0x03, 0x00, 0x00, 0xe0, 0x00, 0x00, 0x00,
472 0x30, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
473 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
477 static char knife_lmsk[]={
478 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
479 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18,
480 0x00, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x00, 0x7e,
481 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x80, 0xff,
482 0x00, 0x00, 0xc0, 0xbf, 0x00, 0x00, 0xe0, 0xdf,
483 0x00, 0x00, 0xe0, 0xef, 0x00, 0x00, 0xf8, 0x77,
484 0x00, 0x00, 0xfc, 0x3b, 0x00, 0x00, 0xfe, 0x1d,
485 0x00, 0x00, 0xfe, 0x0f, 0x00, 0x00, 0xfe, 0x01,
486 0x00, 0x00, 0xff, 0x01, 0x00, 0xc0, 0xff, 0x00,
487 0x00, 0xe0, 0x7f, 0x00, 0x00, 0xf0, 0x1f, 0x00,
488 0x00, 0xd8, 0x1f, 0x00, 0x00, 0xec, 0x0f, 0x00,
489 0x00, 0xf6, 0x0f, 0x00, 0x00, 0xfb, 0x06, 0x00,
490 0x80, 0xbd, 0x01, 0x00, 0xc0, 0x6e, 0x00, 0x00,
491 0xe0, 0x1b, 0x00, 0x00, 0xf0, 0x06, 0x00, 0x00,
492 0xb8, 0x01, 0x00, 0x00, 0x6c, 0x00, 0x00, 0x00,
493 0x1c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
497 static BCursor KnifeCursor = {
499 knife_sbm, knife_smsk,
503 knife_lbm, knife_lmsk,
510 BlenderCursor[BC_KNIFECURSOR]=&KnifeCursor;
513 /********************** Put the cursors in the array ***********************/