Blender  V3.3
Classes | Macros | Typedefs | Functions | Variables
wm_cursors.c File Reference
#include <stdio.h>
#include <string.h>
#include "GHOST_C-api.h"
#include "BLI_utildefines.h"
#include "BLI_sys_types.h"
#include "DNA_listBase.h"
#include "DNA_userdef_types.h"
#include "DNA_workspace_types.h"
#include "BKE_context.h"
#include "BKE_global.h"
#include "BKE_main.h"
#include "WM_api.h"
#include "WM_types.h"
#include "wm_cursors.h"
#include "wm_window.h"

Go to the source code of this file.

Classes

struct  BCursor
 

Macros

#define BEGIN_CURSOR_BLOCK
 
#define END_CURSOR_BLOCK
 

Typedefs

typedef struct BCursor BCursor
 

Functions

static GHOST_TStandardCursor convert_to_ghost_standard_cursor (WMCursorType curs)
 
static void window_set_custom_cursor (wmWindow *win, const uchar mask[16][2], const uchar bitmap[16][2], int hotx, int hoty)
 
static void window_set_custom_cursor_ex (wmWindow *win, BCursor *cursor)
 
void WM_cursor_set (wmWindow *win, int curs)
 
bool WM_cursor_set_from_tool (struct wmWindow *win, const ScrArea *area, const ARegion *region)
 
void WM_cursor_modal_set (wmWindow *win, int val)
 
void WM_cursor_modal_restore (wmWindow *win)
 
void WM_cursor_wait (bool val)
 
void WM_cursor_grab_enable (wmWindow *win, int wrap, bool hide, int bounds[4])
 
void WM_cursor_grab_disable (wmWindow *win, const int mouse_ungrab_xy[2])
 
static void wm_cursor_warp_relative (wmWindow *win, int x, int y)
 
bool wm_cursor_arrow_move (wmWindow *win, const wmEvent *event)
 
void WM_cursor_time (wmWindow *win, int nr)
 
void wm_init_cursor_data (void)
 

Variables

static BCursorBlenderCursor [WM_CURSOR_NUM] = {0}
 

Detailed Description

Cursor pixmap and cursor utility functions to change the cursor.

Definition in file wm_cursors.c.

Macro Definition Documentation

◆ BEGIN_CURSOR_BLOCK

#define BEGIN_CURSOR_BLOCK
Value:
{ \
((void)0)
SyclQueue void void size_t num_bytes void

Custom Cursor Description

Each bit represents a pixel, so 1 byte = 8 pixels, the bytes go Left to Right. Top to bottom the bits in a byte go right to left (ie; 0x01, 0x80 represents a line of 16 pix with the first and last pix set.)

  • A 0 in the bitmap = white, a 1 black
  • a 0 in the mask = transparent pix.

This type of cursor is 16x16 pixels only.


There is a nice Python GUI utility that can be used for drawing cursors in this format in the Blender source distribution, in ./source/tools/utils/make_cursor_gui.py .

Start it with the command python3 make_cursor_gui.py It will copy its output to the console when you press 'Do it'. Because defining a cursor mixes declarations and executable code each cursor needs its own scoping block or it would be split up over several hundred lines of code. To enforce/document this better I define 2 pretty brain-dead macros so it's obvious what the extra "[]" are for

Definition at line 389 of file wm_cursors.c.

◆ END_CURSOR_BLOCK

#define END_CURSOR_BLOCK
Value:
} \
((void)0)

Definition at line 392 of file wm_cursors.c.

Typedef Documentation

◆ BCursor

typedef struct BCursor BCursor

Function Documentation

◆ convert_to_ghost_standard_cursor()

static GHOST_TStandardCursor convert_to_ghost_standard_cursor ( WMCursorType  curs)
static

◆ window_set_custom_cursor()

static void window_set_custom_cursor ( wmWindow win,
const uchar  mask[16][2],
const uchar  bitmap[16][2],
int  hotx,
int  hoty 
)
static

Definition at line 107 of file wm_cursors.c.

References GHOST_SetCustomCursorShape(), wmWindow::ghostwin, and mask().

Referenced by WM_cursor_time().

◆ window_set_custom_cursor_ex()

static void window_set_custom_cursor_ex ( wmWindow win,
BCursor cursor 
)
static

◆ wm_cursor_arrow_move()

bool wm_cursor_arrow_move ( wmWindow win,
const wmEvent event 
)

◆ WM_cursor_grab_disable()

void WM_cursor_grab_disable ( wmWindow win,
const int  mouse_ungrab_xy[2] 
)

◆ WM_cursor_grab_enable()

void WM_cursor_grab_enable ( struct wmWindow win,
int  wrap,
bool  hide,
int  bounds[4] 
)

◆ WM_cursor_modal_restore()

void WM_cursor_modal_restore ( wmWindow win)

◆ WM_cursor_modal_set()

void WM_cursor_modal_set ( wmWindow win,
int  val 
)

◆ WM_cursor_set()

void WM_cursor_set ( wmWindow win,
int  curs 
)

◆ WM_cursor_set_from_tool()

bool WM_cursor_set_from_tool ( struct wmWindow win,
const ScrArea area,
const ARegion region 
)

◆ WM_cursor_time()

void WM_cursor_time ( struct wmWindow win,
int  nr 
)

After this you can call restore too.

Definition at line 317 of file wm_cursors.c.

References wmWindow::cursor, wmWindow::lastcursor, mask(), window_set_custom_cursor(), x, and y.

Referenced by gpencil_do_frame_fill(), gpencil_fill_modal(), and screen_opengl_render_anim_step().

◆ WM_cursor_wait()

void WM_cursor_wait ( bool  val)

◆ wm_cursor_warp_relative()

static void wm_cursor_warp_relative ( wmWindow win,
int  x,
int  y 
)
static

Definition at line 281 of file wm_cursors.c.

References wm_cursor_position_get(), WM_cursor_warp(), x, and y.

Referenced by wm_cursor_arrow_move().

◆ wm_init_cursor_data()

void wm_init_cursor_data ( void  )

Variable Documentation

◆ BlenderCursor

BCursor* BlenderCursor[WM_CURSOR_NUM] = {0}
static

Definition at line 41 of file wm_cursors.c.

Referenced by WM_cursor_set(), and wm_init_cursor_data().