Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/intern
diff options
context:
space:
mode:
authorRobert Wenzlaff <rwenzlaff@soylent-green.com>2003-12-26 23:12:42 +0300
committerRobert Wenzlaff <rwenzlaff@soylent-green.com>2003-12-26 23:12:42 +0300
commit85ae21d5dda29fcd6b0f7a145804323b084a5801 (patch)
tree237969cf87f5bae721d2f46c95fbb14f2b6bb4f5 /intern
parentda0e131b1665b283fc53606dff43c21d7b7a2902 (diff)
Commit of cursor framework. Cursors now defined in source/blender/src/cursors.c and
source/blender/include/BIF_cursors.h. Allows large cursors on Win32 and X11. See cursors.c for documentatioin on how to use.
Diffstat (limited to 'intern')
-rw-r--r--intern/ghost/GHOST_C-api.h17
-rw-r--r--intern/ghost/GHOST_IWindow.h6
-rw-r--r--intern/ghost/intern/GHOST_C-api.cpp18
-rw-r--r--intern/ghost/intern/GHOST_Window.cpp13
-rw-r--r--intern/ghost/intern/GHOST_Window.h13
-rw-r--r--intern/ghost/intern/GHOST_WindowCarbon.cpp22
-rw-r--r--intern/ghost/intern/GHOST_WindowCarbon.h3
-rw-r--r--intern/ghost/intern/GHOST_WindowWin32.cpp41
-rw-r--r--intern/ghost/intern/GHOST_WindowWin32.h11
-rwxr-xr-xintern/ghost/intern/GHOST_WindowX11.cpp22
-rwxr-xr-xintern/ghost/intern/GHOST_WindowX11.h16
11 files changed, 166 insertions, 16 deletions
diff --git a/intern/ghost/GHOST_C-api.h b/intern/ghost/GHOST_C-api.h
index 35191c4e45d..ba22074a620 100644
--- a/intern/ghost/GHOST_C-api.h
+++ b/intern/ghost/GHOST_C-api.h
@@ -300,6 +300,23 @@ extern GHOST_TSuccess GHOST_SetCustomCursorShape(GHOST_WindowHandle windowhandle
GHOST_TUns8 mask[16][2],
int hotX,
int hotY);
+/**
+ * Set the shape of the cursor to a custom cursor of specified size.
+ * @param windowhandle The handle to the window
+ * @param bitmap The bitmap data for the cursor.
+ * @param mask The mask data for the cursor.
+ * @parm sizex, sizey The size of the cursor
+ * @param hotX The X coordinate of the cursor hotspot.
+ * @param hotY The Y coordinate of the cursor hotspot.
+ * @param fg_color, bg_color Colors of the cursor
+ * @return Indication of success.
+ */
+extern GHOST_TSuccess GHOST_SetCustomCursorShapeEx(GHOST_WindowHandle windowhandle,
+ GHOST_TUns8 *bitmap,
+ GHOST_TUns8 *mask,
+ int sizex, int sizey,
+ int hotX, int hotY,
+ int fg_color, int bg_color );
/**
* Returns the visibility state of the cursor.
diff --git a/intern/ghost/GHOST_IWindow.h b/intern/ghost/GHOST_IWindow.h
index a9331fadf59..bd15df3dba8 100644
--- a/intern/ghost/GHOST_IWindow.h
+++ b/intern/ghost/GHOST_IWindow.h
@@ -230,6 +230,12 @@ public:
GHOST_TUns8 mask[16][2],
int hotX,
int hotY) = 0;
+
+ virtual GHOST_TSuccess setCustomCursorShape(GHOST_TUns8 *bitmap,
+ GHOST_TUns8 *mask,
+ int sizex, int sizey,
+ int hotX, int hotY,
+ int fg_color, int bg_color) = 0;
/**
* Returns the visibility state of the cursor.
diff --git a/intern/ghost/intern/GHOST_C-api.cpp b/intern/ghost/intern/GHOST_C-api.cpp
index 5f7866b3c85..6f8ddd858ef 100644
--- a/intern/ghost/intern/GHOST_C-api.cpp
+++ b/intern/ghost/intern/GHOST_C-api.cpp
@@ -289,6 +289,24 @@ GHOST_TSuccess GHOST_SetCustomCursorShape(GHOST_WindowHandle windowhandle,
return window->setCustomCursorShape(bitmap, mask, hotX, hotY);
}
+GHOST_TSuccess GHOST_SetCustomCursorShapeEx(GHOST_WindowHandle windowhandle,
+ GHOST_TUns8 *bitmap,
+ GHOST_TUns8 *mask,
+ int sizex,
+ int sizey,
+ int hotX,
+ int hotY,
+ int fg_color,
+ int bg_color)
+{
+ GHOST_IWindow* window = (GHOST_IWindow*) windowhandle;
+
+ return window->setCustomCursorShape(bitmap, mask, sizex, sizey,
+ hotX, hotY, fg_color, bg_color);
+}
+
+
+
int GHOST_GetCursorVisibility(GHOST_WindowHandle windowhandle)
{
GHOST_IWindow* window = (GHOST_IWindow*) windowhandle;
diff --git a/intern/ghost/intern/GHOST_Window.cpp b/intern/ghost/intern/GHOST_Window.cpp
index a21233d4475..f4f7c581814 100644
--- a/intern/ghost/intern/GHOST_Window.cpp
+++ b/intern/ghost/intern/GHOST_Window.cpp
@@ -107,9 +107,18 @@ GHOST_TSuccess GHOST_Window::setCursorShape(GHOST_TStandardCursor cursorShape)
}
}
-GHOST_TSuccess GHOST_Window::setCustomCursorShape(GHOST_TUns8 bitmap[16][2], GHOST_TUns8 mask[16][2], int hotX, int hotY)
+GHOST_TSuccess GHOST_Window::setCustomCursorShape(GHOST_TUns8 bitmap[16][2], GHOST_TUns8 mask[16][2],
+ int hotX, int hotY)
{
- if (setWindowCustomCursorShape(bitmap, mask, hotX, hotY)) {
+ return setCustomCursorShape( (GHOST_TUns8 *)bitmap, (GHOST_TUns8 *)mask,
+ 16, 16, hotX, hotY, 0, 1 );
+}
+
+GHOST_TSuccess GHOST_Window::setCustomCursorShape(GHOST_TUns8 *bitmap, GHOST_TUns8 *mask,
+ int sizex, int sizey, int hotX, int hotY,
+ int fg_color, int bg_color )
+{
+ if (setWindowCustomCursorShape(bitmap, mask, sizex, sizey,hotX, hotY, fg_color, bg_color)) {
m_cursorShape = GHOST_kStandardCursorCustom;
return GHOST_kSuccess;
}
diff --git a/intern/ghost/intern/GHOST_Window.h b/intern/ghost/intern/GHOST_Window.h
index be4dc808981..acf28177b37 100644
--- a/intern/ghost/intern/GHOST_Window.h
+++ b/intern/ghost/intern/GHOST_Window.h
@@ -149,6 +149,12 @@ public:
GHOST_TUns8 mask[16][2],
int hotX,
int hotY);
+
+ virtual GHOST_TSuccess setCustomCursorShape(GHOST_TUns8 *bitmap,
+ GHOST_TUns8 *mask,
+ int sizex, int sizey,
+ int hotX, int hotY,
+ int fg_color, int bg_color);
/**
* Returns the visibility state of the cursor.
@@ -226,8 +232,11 @@ protected:
* Sets the cursor shape on the window using
* native window system calls.
*/
- virtual GHOST_TSuccess setWindowCustomCursorShape(GHOST_TUns8 bitmap[16][2], GHOST_TUns8 mask[16][2], int hotX, int hotY) = 0;
-
+ virtual GHOST_TSuccess setWindowCustomCursorShape(GHOST_TUns8 bitmap[16][2], GHOST_TUns8 mask[16][2],
+ int hotX, int hotY) = 0;
+
+ virtual GHOST_TSuccess setWindowCustomCursorShape(GHOST_TUns8 *bitmap, GHOST_TUns8 *mask,
+ int szx, int szy, int hotX, int hotY, int fg, int bg) = 0;
/** The the of drawing context installed in this window. */
GHOST_TDrawingContextType m_drawingContextType;
diff --git a/intern/ghost/intern/GHOST_WindowCarbon.cpp b/intern/ghost/intern/GHOST_WindowCarbon.cpp
index 29fab93b314..516a753f4b2 100644
--- a/intern/ghost/intern/GHOST_WindowCarbon.cpp
+++ b/intern/ghost/intern/GHOST_WindowCarbon.cpp
@@ -602,6 +602,15 @@ GHOST_TSuccess GHOST_WindowCarbon::setWindowCursorShape(GHOST_TStandardCursor sh
return GHOST_kSuccess;
}
+/** Reverse the bits in a GHOST_TUns8 */
+static GHOST_TUns8 uns8ReverseBits(GHOST_TUns8 ch)
+{
+ ch= ((ch>>1)&0x55) | ((ch<<1)&0xAA);
+ ch= ((ch>>2)&0x33) | ((ch<<2)&0xCC);
+ ch= ((ch>>4)&0x0F) | ((ch<<4)&0xF0);
+ return ch;
+}
+
/** Reverse the bits in a GHOST_TUns16 */
static GHOST_TUns16 uns16ReverseBits(GHOST_TUns16 shrt)
{
@@ -612,7 +621,8 @@ static GHOST_TUns16 uns16ReverseBits(GHOST_TUns16 shrt)
return shrt;
}
-GHOST_TSuccess GHOST_WindowCarbon::setWindowCustomCursorShape(GHOST_TUns8 bitmap[16][2], GHOST_TUns8 mask[16][2], int hotX, int hotY)
+GHOST_TSuccess GHOST_WindowCarbon::setWindowCustomCursorShape(GHOST_TUns8 *bitmap, GHOST_TUns8 *mask,
+ int sizex, int sizey, int hotX, int hotY, int fg_color, int bg_color)
{
int y;
@@ -625,8 +635,8 @@ GHOST_TSuccess GHOST_WindowCarbon::setWindowCustomCursorShape(GHOST_TUns8 bitmap
if (!m_customCursor) return GHOST_kFailure;
for (y=0; y<16; y++) {
- m_customCursor->data[y] = uns16ReverseBits((bitmap[y][0]<<0) | (bitmap[y][1]<<8));
- m_customCursor->mask[y] = uns16ReverseBits((mask[y][0]<<0) | (mask[y][1]<<8));
+ m_customCursor->data[y] = uns16ReverseBits((bitmap[2*y]<<0) | (bitmap[2*y+1]<<8));
+ m_customCursor->mask[y] = uns16ReverseBits((mask[2*y]<<0) | (mask[2*y+1]<<8));
}
m_customCursor->hotSpot.h = hotX;
@@ -638,3 +648,9 @@ GHOST_TSuccess GHOST_WindowCarbon::setWindowCustomCursorShape(GHOST_TUns8 bitmap
return GHOST_kSuccess;
}
+
+GHOST_TSuccess GHOST_WindowCarbon::setWindowCustomCursorShape(GHOST_TUns8 bitmap[16][2],
+ GHOST_TUns8 mask[16][2], int hotX, int hotY)
+{
+ setWindowCustomCursorShape((GHOST_TUns8*)bitmap, (GHOST_TUns8*) mask, 16, 16, hotX, hotY, 0, 1);
+}
diff --git a/intern/ghost/intern/GHOST_WindowCarbon.h b/intern/ghost/intern/GHOST_WindowCarbon.h
index 15757556780..289ad44dc6b 100644
--- a/intern/ghost/intern/GHOST_WindowCarbon.h
+++ b/intern/ghost/intern/GHOST_WindowCarbon.h
@@ -243,6 +243,9 @@ protected:
* Sets the cursor shape on the window using
* native window system calls.
*/
+ virtual GHOST_TSuccess setWindowCustomCursorShape(GHOST_TUns8 *bitmap, GHOST_TUns8 *mask,
+ int sizex, int sizey, int hotX, int hotY, int fg_color, int bg_color);
+
virtual GHOST_TSuccess setWindowCustomCursorShape(GHOST_TUns8 bitmap[16][2], GHOST_TUns8 mask[16][2], int hotX, int hotY);
/**
diff --git a/intern/ghost/intern/GHOST_WindowWin32.cpp b/intern/ghost/intern/GHOST_WindowWin32.cpp
index 1a5060df184..236f0502b67 100644
--- a/intern/ghost/intern/GHOST_WindowWin32.cpp
+++ b/intern/ghost/intern/GHOST_WindowWin32.cpp
@@ -560,6 +560,15 @@ GHOST_TSuccess GHOST_WindowWin32::setWindowCursorShape(GHOST_TStandardCursor cur
return GHOST_kSuccess;
}
+/** Reverse the bits in a GHOST_TUns8 */
+static GHOST_TUns8 uns8ReverseBits(GHOST_TUns8 ch)
+{
+ ch= ((ch>>1)&0x55) | ((ch<<1)&0xAA);
+ ch= ((ch>>2)&0x33) | ((ch<<2)&0xCC);
+ ch= ((ch>>4)&0x0F) | ((ch<<4)&0xF0);
+ return ch;
+}
+
/** Reverse the bits in a GHOST_TUns16 */
static GHOST_TUns16 uns16ReverseBits(GHOST_TUns16 shrt)
{
@@ -569,13 +578,26 @@ static GHOST_TUns16 uns16ReverseBits(GHOST_TUns16 shrt)
shrt= ((shrt>>8)&0x00FF) | ((shrt<<8)&0xFF00);
return shrt;
}
+GHOST_TSuccess GHOST_WindowWin32::setWindowCustomCursorShape(GHOST_TUns8 bitmap[16][2],
+ GHOST_TUns8 mask[16][2], int hotX, int hotY)
+{
+ setWindowCustomCursorShape((GHOST_TUns8*)bitmap, (GHOST_TUns8*)mask,
+ 16, 16, hotX, hotY, 0, 1);
-GHOST_TSuccess GHOST_WindowWin32::setWindowCustomCursorShape(GHOST_TUns8 bitmap[16][2], GHOST_TUns8 mask[16][2], int hotX, int hotY)
+}
+
+GHOST_TSuccess GHOST_WindowWin32::setWindowCustomCursorShape(GHOST_TUns8 *bitmap,
+ GHOST_TUns8 *mask, int sixeX, int sizeY, int hotX, int hotY,
+ int fg_color, int bg_color)
{
GHOST_TUns32 andData[32];
GHOST_TUns32 xorData[32];
- int y;
-
+ GHOST_TUns32 fullBitRow, fullMaskRow;
+ int x, y, cols;
+
+ cols=sizeX/8; /* Num of whole bytes per row (width of bm/mask) */
+ if (sizeX%8) cols++;
+
if (m_customCursor) {
DestroyCursor(m_customCursor);
m_customCursor = NULL;
@@ -584,10 +606,15 @@ GHOST_TSuccess GHOST_WindowWin32::setWindowCustomCursorShape(GHOST_TUns8 bitmap[
memset(&andData, 0xFF, sizeof(andData));
memset(&xorData, 0, sizeof(xorData));
- for (y=0; y<16; y++) {
- GHOST_TUns32 fullBitRow = uns16ReverseBits((bitmap[y][0]<<8) | (bitmap[y][1]<<0));
- GHOST_TUns32 fullMaskRow = uns16ReverseBits((mask[y][0]<<8) | (mask[y][1]<<0));
-
+ for (y=0; y<sizeY; y++) {
+ fullBitRow=0;
+ fullMaskRow=0;
+ for (x=cols-1; x>=0; x--){
+ fullBitRow<<=8;
+ fullMaskRow<<=8;
+ fullBitRow |= uns8ReverseBits(bitmap[cols*y + x]);
+ fullMaskRow |= uns8ReverseBits( mask[cols*y + x]);
+ }
xorData[y]= fullBitRow & fullMaskRow;
andData[y]= ~fullMaskRow;
}
diff --git a/intern/ghost/intern/GHOST_WindowWin32.h b/intern/ghost/intern/GHOST_WindowWin32.h
index 3d45d2afa5d..2ecd02b22da 100644
--- a/intern/ghost/intern/GHOST_WindowWin32.h
+++ b/intern/ghost/intern/GHOST_WindowWin32.h
@@ -249,6 +249,17 @@ protected:
*/
virtual GHOST_TSuccess setWindowCustomCursorShape(GHOST_TUns8 bitmap[16][2], GHOST_TUns8 mask[16][2], int hotX, int hotY);
+ virtual setWindowCustomCursorShape(
+ GHOST_TUns8 *bitmap,
+ GHOST_TUns8 *mask,
+ int sizex,
+ int sizey,
+ int hotX,
+ int hotY,
+ int fg_color,
+ int bg_color
+ );
+
/** Window handle. */
HWND m_hWnd;
/** Device context handle. */
diff --git a/intern/ghost/intern/GHOST_WindowX11.cpp b/intern/ghost/intern/GHOST_WindowX11.cpp
index 7b6fa2aa42a..e4122992378 100755
--- a/intern/ghost/intern/GHOST_WindowX11.cpp
+++ b/intern/ghost/intern/GHOST_WindowX11.cpp
@@ -684,6 +684,24 @@ setWindowCustomCursorShape(
int hotX,
int hotY
){
+
+setWindowCustomCursorShape((GHOST_TUns8*)bitmap, (GHOST_TUns8*)mask,
+ 16, 16, hotX, hotY, 0, 1);
+
+}
+
+ GHOST_TSuccess
+GHOST_WindowX11::
+setWindowCustomCursorShape(
+ GHOST_TUns8 *bitmap,
+ GHOST_TUns8 *mask,
+ int sizex,
+ int sizey,
+ int hotX,
+ int hotY,
+ int fg_color,
+ int bg_color
+){
Pixmap bitmap_pix, mask_pix;
XColor fg, bg;
@@ -696,8 +714,8 @@ setWindowCustomCursorShape(
XFreeCursor(m_display, m_custom_cursor);
}
- bitmap_pix = XCreateBitmapFromData(m_display, m_window, (char*) bitmap, 16, 16);
- mask_pix = XCreateBitmapFromData(m_display, m_window, (char*) mask, 16, 16);
+ bitmap_pix = XCreateBitmapFromData(m_display, m_window, (char*) bitmap, sizex, sizey);
+ mask_pix = XCreateBitmapFromData(m_display, m_window, (char*) mask, sizex, sizey);
m_custom_cursor = XCreatePixmapCursor(m_display, bitmap_pix, mask_pix, &fg, &bg, hotX, hotY);
XDefineCursor(m_display, m_window, m_custom_cursor);
diff --git a/intern/ghost/intern/GHOST_WindowX11.h b/intern/ghost/intern/GHOST_WindowX11.h
index 0b0b8d596d5..d8b5f61697e 100755
--- a/intern/ghost/intern/GHOST_WindowX11.h
+++ b/intern/ghost/intern/GHOST_WindowX11.h
@@ -236,6 +236,22 @@ protected:
int hotX,
int hotY
);
+
+ /**
+ * Sets the cursor shape on the window using
+ * native window system calls (Arbitrary size/color).
+ */
+ GHOST_TSuccess
+ setWindowCustomCursorShape(
+ GHOST_TUns8 *bitmap,
+ GHOST_TUns8 *mask,
+ int sizex,
+ int sizey,
+ int hotX,
+ int hotY,
+ int fg_color,
+ int bg_color
+ );
private :