Blender V4.3
wm_cursors.cc File Reference
#include <cstdio>
#include <cstring>
#include "GHOST_C-api.h"
#include "BLI_utildefines.h"
#include "DNA_listBase.h"
#include "DNA_userdef_types.h"
#include "DNA_workspace_types.h"
#include "BKE_global.hh"
#include "BKE_main.hh"
#include "WM_api.hh"
#include "WM_types.hh"
#include "wm_cursors.hh"
#include "wm_window.hh"

Go to the source code of this file.

Classes

struct  BCursor
 

Macros

#define BEGIN_CURSOR_BLOCK
 
#define END_CURSOR_BLOCK
 

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 (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, const eWM_CursorWrapAxis wrap, const rcti *wrap_region, const bool hide)
 
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 ()
 

Variables

static BCursorBlenderCursor [WM_CURSOR_NUM] = {nullptr}
 

Detailed Description

Cursor pixmap and cursor utility functions to change the cursor.

Definition in file wm_cursors.cc.

Macro Definition Documentation

◆ BEGIN_CURSOR_BLOCK

#define BEGIN_CURSOR_BLOCK
Value:
{ \
((void)0)

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 ./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 431 of file wm_cursors.cc.

Referenced by wm_init_cursor_data().

◆ END_CURSOR_BLOCK

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

Definition at line 434 of file wm_cursors.cc.

Referenced by wm_init_cursor_data().

Function Documentation

◆ convert_to_ghost_standard_cursor()

static GHOST_TStandardCursor convert_to_ghost_standard_cursor ( WMCursorType curs)
static

Definition at line 42 of file wm_cursors.cc.

References GHOST_kStandardCursorBothHandles, GHOST_kStandardCursorCopy, GHOST_kStandardCursorCrosshair, GHOST_kStandardCursorCrosshairA, GHOST_kStandardCursorCrosshairB, GHOST_kStandardCursorCrosshairC, GHOST_kStandardCursorCustom, GHOST_kStandardCursorDefault, GHOST_kStandardCursorDownArrow, GHOST_kStandardCursorEraser, GHOST_kStandardCursorEWScroll, GHOST_kStandardCursorEyedropper, GHOST_kStandardCursorHandClosed, GHOST_kStandardCursorHandOpen, GHOST_kStandardCursorHandPoint, GHOST_kStandardCursorHorizontalSplit, GHOST_kStandardCursorKnife, GHOST_kStandardCursorLeftArrow, GHOST_kStandardCursorLeftHandle, GHOST_kStandardCursorLeftRight, GHOST_kStandardCursorMove, GHOST_kStandardCursorNSEWScroll, GHOST_kStandardCursorNSScroll, GHOST_kStandardCursorPencil, GHOST_kStandardCursorRightArrow, GHOST_kStandardCursorRightHandle, GHOST_kStandardCursorStop, GHOST_kStandardCursorText, GHOST_kStandardCursorUpArrow, GHOST_kStandardCursorUpDown, GHOST_kStandardCursorVerticalSplit, GHOST_kStandardCursorWait, GHOST_kStandardCursorZoomIn, GHOST_kStandardCursorZoomOut, WM_CURSOR_BOTH_HANDLES, WM_CURSOR_COPY, WM_CURSOR_CROSS, WM_CURSOR_CROSSC, WM_CURSOR_DEFAULT, WM_CURSOR_DOT, WM_CURSOR_E_ARROW, WM_CURSOR_EDIT, WM_CURSOR_ERASER, WM_CURSOR_EW_SCROLL, WM_CURSOR_EYEDROPPER, WM_CURSOR_H_SPLIT, WM_CURSOR_HAND, WM_CURSOR_HAND_CLOSED, WM_CURSOR_HAND_POINT, WM_CURSOR_KNIFE, WM_CURSOR_LEFT_HANDLE, WM_CURSOR_MOVE, WM_CURSOR_N_ARROW, WM_CURSOR_NS_SCROLL, WM_CURSOR_NSEW_SCROLL, WM_CURSOR_PAINT, WM_CURSOR_PAINT_BRUSH, WM_CURSOR_RIGHT_HANDLE, WM_CURSOR_S_ARROW, WM_CURSOR_STOP, WM_CURSOR_TEXT_EDIT, WM_CURSOR_V_SPLIT, WM_CURSOR_W_ARROW, WM_CURSOR_WAIT, WM_CURSOR_X_MOVE, WM_CURSOR_Y_MOVE, WM_CURSOR_ZOOM_IN, and WM_CURSOR_ZOOM_OUT.

Referenced by WM_cursor_set().

◆ 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 117 of file wm_cursors.cc.

References GHOST_SetCustomCursorShape(), and wmWindow::ghostwin.

Referenced by WM_cursor_time().

◆ window_set_custom_cursor_ex()

static void window_set_custom_cursor_ex ( wmWindow * win,
BCursor * cursor )
static

Definition at line 130 of file wm_cursors.cc.

References GHOST_SetCustomCursorShape(), and wmWindow::ghostwin.

Referenced by WM_cursor_set().

◆ wm_cursor_arrow_move()

◆ WM_cursor_grab_disable()

◆ WM_cursor_grab_enable()

void WM_cursor_grab_enable ( wmWindow * win,
eWM_CursorWrapAxis wrap,
const rcti * wrap_region,
bool hide )

Enable cursor grabbing, optionally hiding the cursor and wrapping cursor-motion within a sub-region of the window.

Parameters
wrapan enum (WM_CURSOR_WRAP_NONE, WM_CURSOR_WRAP_XY... etc).
wrap_regionWindow-relative region for cursor wrapping (when wrap is WM_CURSOR_WRAP_XY). When NULL, the window bounds are used for wrapping.
Note
The current grab state can be accessed by #wmWindowManager.grabcursor although.

Definition at line 244 of file wm_cursors.cc.

References wmWindow::eventstate, G, G_DEBUG, GHOST_kAxisX, GHOST_kAxisY, GHOST_kGrabHide, GHOST_kGrabNormal, GHOST_kGrabWrap, GHOST_SetCursorGrab(), wmWindow::ghostwin, wmWindow::grabcursor, wmTabletData::is_motion_absolute, wmEvent::tablet, wm_cursor_position_to_ghost_screen_coords(), WM_CURSOR_WRAP_NONE, WM_CURSOR_WRAP_X, WM_CURSOR_WRAP_Y, wrap(), rcti::xmax, rcti::xmin, rcti::ymax, and rcti::ymin.

Referenced by button_activate_state(), initWalkInfo(), wm_gizmomap_modal_set(), wm_macro_modal(), and wm_operator_invoke().

◆ WM_cursor_modal_restore()

◆ WM_cursor_modal_set()

void WM_cursor_modal_set ( wmWindow * win,
int val )

◆ WM_cursor_set()

◆ WM_cursor_set_from_tool()

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

◆ WM_cursor_time()

void WM_cursor_time ( wmWindow * win,
int nr )

After this you can call restore too.

Definition at line 359 of file wm_cursors.cc.

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

Referenced by screen_opengl_render_anim_step().

◆ WM_cursor_wait()

◆ wm_cursor_warp_relative()

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

Definition at line 322 of file wm_cursors.cc.

References wm_cursor_position_get(), and WM_cursor_warp().

Referenced by wm_cursor_arrow_move().

◆ wm_init_cursor_data()

Variable Documentation

◆ BlenderCursor

BCursor* BlenderCursor[WM_CURSOR_NUM] = {nullptr}
static

Definition at line 39 of file wm_cursors.cc.

Referenced by WM_cursor_set(), and wm_init_cursor_data().