Cleanup: rename misleading/inconsistent GHOST types

Remove mask suffix from:
- GHOST_TButtonMask
- GHOST_TModifierKeyMask
.. neither are used as bit-masks.

Remove 'Grab' from:
- GHOST_kGrabAxisNone
- GHOST_kGrabAxisY
.. matching the existing GHOST_TAxisFlag & GHOST_kAxisX.
This commit is contained in:
Campbell Barton 2022-06-27 20:31:28 +10:00
parent 3cf6516e7b
commit a617929683
24 changed files with 51 additions and 52 deletions

View File

@ -439,7 +439,7 @@ extern GHOST_TSuccess GHOST_SetCursorGrab(GHOST_WindowHandle windowhandle,
* \return Indication of success.
*/
extern GHOST_TSuccess GHOST_GetModifierKeyState(GHOST_SystemHandle systemhandle,
GHOST_TModifierKeyMask mask,
GHOST_TModifierKey mask,
bool *r_is_down);
/**
@ -450,7 +450,7 @@ extern GHOST_TSuccess GHOST_GetModifierKeyState(GHOST_SystemHandle systemhandle,
* \return Indication of success.
*/
extern GHOST_TSuccess GHOST_GetButtonState(GHOST_SystemHandle systemhandle,
GHOST_TButtonMask mask,
GHOST_TButton mask,
bool *r_is_down);
#ifdef WITH_INPUT_NDOF

View File

@ -391,7 +391,7 @@ class GHOST_ISystem {
* \param isDown: The state of a modifier key (true == pressed).
* \return Indication of success.
*/
virtual GHOST_TSuccess getModifierKeyState(GHOST_TModifierKeyMask mask, bool &isDown) const = 0;
virtual GHOST_TSuccess getModifierKeyState(GHOST_TModifierKey mask, bool &isDown) const = 0;
/**
* Returns the state of a mouse button (outside the message queue).
@ -399,7 +399,7 @@ class GHOST_ISystem {
* \param isDown: Button state.
* \return Indication of success.
*/
virtual GHOST_TSuccess getButtonState(GHOST_TButtonMask mask, bool &isDown) const = 0;
virtual GHOST_TSuccess getButtonState(GHOST_TButton mask, bool &isDown) const = 0;
/**
* Set which tablet API to use. Only affects Windows, other platforms have a single API.

View File

@ -244,7 +244,7 @@ inline void GHOST_Rect::wrapPoint(int32_t &x, int32_t &y, int32_t ofs, GHOST_TAx
x -= w - (ofs * 2);
}
}
if (axis & GHOST_kGrabAxisY) {
if (axis & GHOST_kAxisY) {
while (y - ofs < m_t) {
y += h - (ofs * 2);
}

View File

@ -123,8 +123,8 @@ typedef enum {
GHOST_kModifierKeyLeftControl,
GHOST_kModifierKeyRightControl,
GHOST_kModifierKeyOS,
GHOST_kModifierKeyNumMasks
} GHOST_TModifierKeyMask;
GHOST_kModifierKeyNum
} GHOST_TModifierKey;
typedef enum {
GHOST_kWindowStateNormal = 0,
@ -163,8 +163,8 @@ typedef enum {
/* Trackballs and programmable buttons. */
GHOST_kButtonMaskButton6,
GHOST_kButtonMaskButton7,
GHOST_kButtonNumMasks
} GHOST_TButtonMask;
GHOST_kButtonNum
} GHOST_TButton;
typedef enum {
GHOST_kEventUnknown = 0,
@ -419,9 +419,9 @@ typedef enum {
typedef enum {
/** Axis that cursor grab will wrap. */
GHOST_kGrabAxisNone = 0,
GHOST_kAxisNone = 0,
GHOST_kAxisX = (1 << 0),
GHOST_kGrabAxisY = (1 << 1),
GHOST_kAxisY = (1 << 1),
} GHOST_TAxisFlag;
typedef void *GHOST_TEventDataPtr;
@ -437,7 +437,7 @@ typedef struct {
typedef struct {
/** The mask of the mouse button. */
GHOST_TButtonMask button;
GHOST_TButton button;
/** Associated tablet data. */
GHOST_TabletData tablet;
} GHOST_TEventButtonData;

View File

@ -12,7 +12,7 @@ GHOST_Buttons::GHOST_Buttons()
clear();
}
bool GHOST_Buttons::get(GHOST_TButtonMask mask) const
bool GHOST_Buttons::get(GHOST_TButton mask) const
{
switch (mask) {
case GHOST_kButtonMaskLeft:
@ -34,7 +34,7 @@ bool GHOST_Buttons::get(GHOST_TButtonMask mask) const
}
}
void GHOST_Buttons::set(GHOST_TButtonMask mask, bool down)
void GHOST_Buttons::set(GHOST_TButton mask, bool down)
{
switch (mask) {
case GHOST_kButtonMaskLeft:

View File

@ -27,14 +27,14 @@ struct GHOST_Buttons {
* \param mask: Key button to return.
* \return The state of the button (pressed == true).
*/
bool get(GHOST_TButtonMask mask) const;
bool get(GHOST_TButton mask) const;
/**
* Updates the state of a single button.
* \param mask: Button state to update.
* \param down: The new state of the button.
*/
void set(GHOST_TButtonMask mask, bool down);
void set(GHOST_TButton mask, bool down);
/**
* Sets the state of all buttons to up.

View File

@ -402,7 +402,7 @@ void GHOST_GetCursorGrabState(GHOST_WindowHandle windowhandle,
}
GHOST_TSuccess GHOST_GetModifierKeyState(GHOST_SystemHandle systemhandle,
GHOST_TModifierKeyMask mask,
GHOST_TModifierKey mask,
bool *r_is_down)
{
GHOST_ISystem *system = (GHOST_ISystem *)systemhandle;
@ -416,7 +416,7 @@ GHOST_TSuccess GHOST_GetModifierKeyState(GHOST_SystemHandle systemhandle,
}
GHOST_TSuccess GHOST_GetButtonState(GHOST_SystemHandle systemhandle,
GHOST_TButtonMask mask,
GHOST_TButton mask,
bool *r_is_down)
{
GHOST_ISystem *system = (GHOST_ISystem *)systemhandle;

View File

@ -27,7 +27,7 @@ class GHOST_EventButton : public GHOST_Event {
GHOST_EventButton(uint64_t time,
GHOST_TEventType type,
GHOST_IWindow *window,
GHOST_TButtonMask button,
GHOST_TButton button,
const GHOST_TabletData &tablet)
: GHOST_Event(time, type, window), m_buttonEventData({button, tablet})
{

View File

@ -20,7 +20,7 @@ GHOST_ModifierKeys::~GHOST_ModifierKeys()
{
}
GHOST_TKey GHOST_ModifierKeys::getModifierKeyCode(GHOST_TModifierKeyMask mask)
GHOST_TKey GHOST_ModifierKeys::getModifierKeyCode(GHOST_TModifierKey mask)
{
GHOST_TKey key;
switch (mask) {
@ -53,7 +53,7 @@ GHOST_TKey GHOST_ModifierKeys::getModifierKeyCode(GHOST_TModifierKeyMask mask)
return key;
}
bool GHOST_ModifierKeys::get(GHOST_TModifierKeyMask mask) const
bool GHOST_ModifierKeys::get(GHOST_TModifierKey mask) const
{
switch (mask) {
case GHOST_kModifierKeyLeftShift:
@ -75,7 +75,7 @@ bool GHOST_ModifierKeys::get(GHOST_TModifierKeyMask mask) const
}
}
void GHOST_ModifierKeys::set(GHOST_TModifierKeyMask mask, bool down)
void GHOST_ModifierKeys::set(GHOST_TModifierKey mask, bool down)
{
switch (mask) {
case GHOST_kModifierKeyLeftShift:

View File

@ -27,21 +27,21 @@ struct GHOST_ModifierKeys {
* \param mask: The mask of the modifier key.
* \return The modifier key's key code.
*/
static GHOST_TKey getModifierKeyCode(GHOST_TModifierKeyMask mask);
static GHOST_TKey getModifierKeyCode(GHOST_TModifierKey mask);
/**
* Returns the state of a single modifier key.
* \param mask: Key state to return.
* \return The state of the key (pressed == true).
*/
bool get(GHOST_TModifierKeyMask mask) const;
bool get(GHOST_TModifierKey mask) const;
/**
* Updates the state of a single modifier key.
* \param mask: Key state to update.
* \param down: The new state of the key.
*/
void set(GHOST_TModifierKeyMask mask, bool down);
void set(GHOST_TModifierKey mask, bool down);
/**
* Sets the state of all modifier keys to up.

View File

@ -260,7 +260,7 @@ GHOST_TSuccess GHOST_System::pushEvent(GHOST_IEvent *event)
return success;
}
GHOST_TSuccess GHOST_System::getModifierKeyState(GHOST_TModifierKeyMask mask, bool &isDown) const
GHOST_TSuccess GHOST_System::getModifierKeyState(GHOST_TModifierKey mask, bool &isDown) const
{
GHOST_ModifierKeys keys;
/* Get the state of all modifier keys. */
@ -272,7 +272,7 @@ GHOST_TSuccess GHOST_System::getModifierKeyState(GHOST_TModifierKeyMask mask, bo
return success;
}
GHOST_TSuccess GHOST_System::getButtonState(GHOST_TButtonMask mask, bool &isDown) const
GHOST_TSuccess GHOST_System::getButtonState(GHOST_TButton mask, bool &isDown) const
{
GHOST_Buttons buttons;
/* Get the state of all mouse buttons. */

View File

@ -221,7 +221,7 @@ class GHOST_System : public GHOST_ISystem {
* \param isDown: The state of a modifier key (true == pressed).
* \return Indication of success.
*/
GHOST_TSuccess getModifierKeyState(GHOST_TModifierKeyMask mask, bool &isDown) const;
GHOST_TSuccess getModifierKeyState(GHOST_TModifierKey mask, bool &isDown) const;
/**
* Returns the state of a mouse button (outside the message queue).
@ -229,7 +229,7 @@ class GHOST_System : public GHOST_ISystem {
* \param isDown: Button state.
* \return Indication of success.
*/
GHOST_TSuccess getButtonState(GHOST_TButtonMask mask, bool &isDown) const;
GHOST_TSuccess getButtonState(GHOST_TButton mask, bool &isDown) const;
/**
* Set which tablet API to use. Only affects Windows, other platforms have a single API.

View File

@ -410,7 +410,7 @@ void GHOST_SystemSDL::processEvent(SDL_Event *sdl_event)
case SDL_MOUSEBUTTONUP:
case SDL_MOUSEBUTTONDOWN: {
SDL_MouseButtonEvent &sdl_sub_evt = sdl_event->button;
GHOST_TButtonMask gbmask = GHOST_kButtonMaskLeft;
GHOST_TButton gbmask = GHOST_kButtonMaskLeft;
GHOST_TEventType type = (sdl_sub_evt.state == SDL_PRESSED) ? GHOST_kEventButtonDown :
GHOST_kEventButtonUp;

View File

@ -1312,7 +1312,7 @@ static void pointer_handle_button(void *data,
break;
}
GHOST_TButtonMask ebutton = GHOST_kButtonMaskLeft;
GHOST_TButton ebutton = GHOST_kButtonMaskLeft;
switch (button) {
case BTN_LEFT:
ebutton = GHOST_kButtonMaskLeft;
@ -1480,7 +1480,7 @@ static void tablet_tool_handle_down(void *data,
{
tablet_tool_input_t *tool_input = static_cast<tablet_tool_input_t *>(data);
input_t *input = tool_input->input;
const GHOST_TButtonMask ebutton = GHOST_kButtonMaskLeft;
const GHOST_TButton ebutton = GHOST_kButtonMaskLeft;
const GHOST_TEventType etype = GHOST_kEventButtonDown;
input->data_source_serial = serial;
@ -1498,7 +1498,7 @@ static void tablet_tool_handle_up(void *data, struct zwp_tablet_tool_v2 * /*zwp_
{
tablet_tool_input_t *tool_input = static_cast<tablet_tool_input_t *>(data);
input_t *input = tool_input->input;
const GHOST_TButtonMask ebutton = GHOST_kButtonMaskLeft;
const GHOST_TButton ebutton = GHOST_kButtonMaskLeft;
const GHOST_TEventType etype = GHOST_kEventButtonUp;
input->tablet.buttons.set(ebutton, false);
@ -1614,7 +1614,7 @@ static void tablet_tool_handle_button(void *data,
break;
}
GHOST_TButtonMask ebutton = GHOST_kButtonMaskLeft;
GHOST_TButton ebutton = GHOST_kButtonMaskLeft;
switch (button) {
case BTN_STYLUS:
ebutton = GHOST_kButtonMaskRight;
@ -2507,7 +2507,7 @@ GHOST_TSuccess GHOST_SystemWayland::getModifierKeys(GHOST_ModifierKeys &keys) co
keys.set(GHOST_kModifierKeyOS, val);
val = xkb_state_mod_name_is_active(d->inputs[0]->xkb_state, XKB_MOD_NAME_NUM, mods_all) == 1;
keys.set(GHOST_kModifierKeyNumMasks, val);
keys.set(GHOST_kModifierKeyNum, val);
return GHOST_kSuccess;
}

View File

@ -580,7 +580,7 @@ GHOST_TKey GHOST_SystemWin32::hardKey(RAWINPUT const &raw,
// extra handling of modifier keys: don't send repeats out from GHOST
if (key >= GHOST_kKeyLeftShift && key <= GHOST_kKeyRightAlt) {
bool changed = false;
GHOST_TModifierKeyMask modifier;
GHOST_TModifierKey modifier;
switch (key) {
case GHOST_kKeyLeftShift: {
changed = (modifiers.get(GHOST_kModifierKeyLeftShift) != *r_keyDown);
@ -864,7 +864,7 @@ GHOST_TKey GHOST_SystemWin32::convertKey(short vKey, short scanCode, short exten
GHOST_EventButton *GHOST_SystemWin32::processButtonEvent(GHOST_TEventType type,
GHOST_WindowWin32 *window,
GHOST_TButtonMask mask)
GHOST_TButton mask)
{
GHOST_SystemWin32 *system = (GHOST_SystemWin32 *)getSystem();

View File

@ -310,7 +310,7 @@ class GHOST_SystemWin32 : public GHOST_System {
*/
static GHOST_EventButton *processButtonEvent(GHOST_TEventType type,
GHOST_WindowWin32 *window,
GHOST_TButtonMask mask);
GHOST_TButton mask);
/**
* Creates tablet events from Wintab events.

View File

@ -1231,7 +1231,7 @@ void GHOST_SystemX11::processEvent(XEvent *xe)
case ButtonPress:
case ButtonRelease: {
XButtonEvent &xbe = xe->xbutton;
GHOST_TButtonMask gbmask = GHOST_kButtonMaskLeft;
GHOST_TButton gbmask = GHOST_kButtonMaskLeft;
GHOST_TEventType type = (xbe.type == ButtonPress) ? GHOST_kEventButtonDown :
GHOST_kEventButtonUp;

View File

@ -177,7 +177,7 @@ void GHOST_Window::getCursorGrabState(GHOST_TGrabCursorMode &mode,
bounds.m_r = -1;
bounds.m_t = -1;
bounds.m_b = -1;
wrap_axis = GHOST_kGrabAxisNone;
wrap_axis = GHOST_kAxisNone;
}
use_software_cursor = (m_cursorGrab != GHOST_kGrabDisable) ? getCursorGrabUseSoftwareDisplay() :
false;

View File

@ -34,7 +34,7 @@ typedef BOOL(API *GHOST_WIN32_AdjustWindowRectExForDpi)(
struct GHOST_PointerInfoWin32 {
int32_t pointerId;
int32_t isPrimary;
GHOST_TButtonMask buttonMask;
GHOST_TButton buttonMask;
POINT pixelLocation;
uint64_t time;
GHOST_TabletData tabletData;

View File

@ -373,7 +373,7 @@ void GHOST_Wintab::getInput(std::vector<GHOST_WintabInfoWin32> &outWintabInfo)
/* Iterate over button flag indices until all flags are clear. */
for (WORD buttonIndex = 0; buttonsChanged; buttonIndex++, buttonsChanged >>= 1) {
if (buttonsChanged & 1) {
GHOST_TButtonMask button = mapWintabToGhostButton(pkt.pkCursor, buttonIndex);
GHOST_TButton button = mapWintabToGhostButton(pkt.pkCursor, buttonIndex);
if (button != GHOST_kButtonMaskNone) {
/* If this is not the first button found, push info for the prior Wintab button. */
@ -397,7 +397,7 @@ void GHOST_Wintab::getInput(std::vector<GHOST_WintabInfoWin32> &outWintabInfo)
}
}
GHOST_TButtonMask GHOST_Wintab::mapWintabToGhostButton(UINT cursor, WORD physicalButton)
GHOST_TButton GHOST_Wintab::mapWintabToGhostButton(UINT cursor, WORD physicalButton)
{
const WORD numButtons = 32;
BYTE logicalButtons[numButtons] = {0};

View File

@ -54,7 +54,7 @@ struct GHOST_WintabInfoWin32 {
int32_t x = 0;
int32_t y = 0;
GHOST_TEventType type = GHOST_kEventCursorMove;
GHOST_TButtonMask button = GHOST_kButtonMaskNone;
GHOST_TButton button = GHOST_kButtonMaskNone;
uint64_t time = 0;
GHOST_TabletData tabletData = GHOST_TABLET_DATA_NONE;
};
@ -243,7 +243,7 @@ class GHOST_Wintab {
* \param physicalButton: The physical button ID to inspect.
* \return The system mapped button.
*/
GHOST_TButtonMask mapWintabToGhostButton(UINT cursor, WORD physicalButton);
GHOST_TButton mapWintabToGhostButton(UINT cursor, WORD physicalButton);
/**
* Applies common modifications to Wintab context.

View File

@ -228,7 +228,7 @@ void WM_cursor_grab_enable(wmWindow *win, int wrap, bool hide, int bounds[4])
/* Only grab cursor when not running debug.
* It helps not to get a stuck WM when hitting a break-point. */
GHOST_TGrabCursorMode mode = GHOST_kGrabNormal;
GHOST_TAxisFlag mode_axis = GHOST_kAxisX | GHOST_kGrabAxisY;
GHOST_TAxisFlag mode_axis = GHOST_kAxisX | GHOST_kAxisY;
if (bounds) {
wm_cursor_position_to_ghost(win, &bounds[0], &bounds[1]);
@ -245,7 +245,7 @@ void WM_cursor_grab_enable(wmWindow *win, int wrap, bool hide, int bounds[4])
mode_axis = GHOST_kAxisX;
}
else if (wrap == WM_CURSOR_WRAP_Y) {
mode_axis = GHOST_kGrabAxisY;
mode_axis = GHOST_kAxisY;
}
}
@ -267,11 +267,10 @@ void WM_cursor_grab_disable(wmWindow *win, const int mouse_ungrab_xy[2])
if (mouse_ungrab_xy) {
int mouse_xy[2] = {mouse_ungrab_xy[0], mouse_ungrab_xy[1]};
wm_cursor_position_to_ghost(win, &mouse_xy[0], &mouse_xy[1]);
GHOST_SetCursorGrab(
win->ghostwin, GHOST_kGrabDisable, GHOST_kGrabAxisNone, NULL, mouse_xy);
GHOST_SetCursorGrab(win->ghostwin, GHOST_kGrabDisable, GHOST_kAxisNone, NULL, mouse_xy);
}
else {
GHOST_SetCursorGrab(win->ghostwin, GHOST_kGrabDisable, GHOST_kGrabAxisNone, NULL, NULL);
GHOST_SetCursorGrab(win->ghostwin, GHOST_kGrabDisable, GHOST_kAxisNone, NULL, NULL);
}
win->grabcursor = GHOST_kGrabDisable;

View File

@ -309,7 +309,7 @@ static void wm_software_cursor_draw(wmWindow *win, const struct GrabState *grab_
event_xy[0] = mod_i(event_xy[0] - min, max - min) + min;
}
}
if (grab_state->wrap_axis & GHOST_kGrabAxisY) {
if (grab_state->wrap_axis & GHOST_kAxisY) {
const int height = WM_window_pixels_y(win);
const int min = height - grab_state->bounds[1];
const int max = height - grab_state->bounds[3];

View File

@ -963,7 +963,7 @@ typedef enum {
/* check if specified modifier key type is pressed */
static int query_qual(modifierKeyType qual)
{
GHOST_TModifierKeyMask left, right;
GHOST_TModifierKey left, right;
switch (qual) {
case SHIFT:
left = GHOST_kModifierKeyLeftShift;