Skip to content

Commit

Permalink
Add support for setting the hotspot of the small frame of MouseTypes.
Browse files Browse the repository at this point in the history
  • Loading branch information
CCHyper committed Feb 5, 2024
1 parent 61d584f commit 7cd63f3
Show file tree
Hide file tree
Showing 3 changed files with 209 additions and 104 deletions.
91 changes: 63 additions & 28 deletions src/extensions/mouse/mouseext_hooks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,11 +116,12 @@ bool MouseClassExt::_Override_Mouse_Shape(MouseType mouse, bool wsmall)
Timer = wsmall ? control->SmallFrameRate : control->FrameRate;
Frame = 0;

IsSmall = wsmall;

baseshp = Get_Mouse_Current_Frame(mouse, wsmall);
Point2D hotspot = Get_Mouse_Hotspot(mouse);
WWMouse->Set_Cursor(&hotspot, MouseShapes, baseshp);
CurrentMouseShape = mouse;
IsSmall = wsmall;
return true;
}
return false;
Expand Down Expand Up @@ -189,33 +190,67 @@ Point2D MouseClassExt::_Get_Mouse_Hotspot(MouseType mouse) const
//MouseStruct const * control = &MouseControl[mouse];
MouseTypeClass const * control = MouseTypeClass::As_Pointer(mouse);

int hotspot_x = control->Hotspot.X;
switch (hotspot_x) {
case MOUSE_HOTSPOT_CENTER:
hotspot.X = MouseShapes->Get_Width() / 2;
break;
case MOUSE_HOTSPOT_MAX:
hotspot.X = MouseShapes->Get_Width();
break;
case MOUSE_HOTSPOT_MIN:
default:
hotspot.X = std::clamp(hotspot_x, -MouseShapes->Get_Width(), MouseShapes->Get_Width());
break;
};

int hotspot_y = control->Hotspot.Y;
switch (hotspot_y) {
case MOUSE_HOTSPOT_CENTER:
hotspot.Y = MouseShapes->Get_Height() / 2;
break;
case MOUSE_HOTSPOT_MAX:
hotspot.Y = MouseShapes->Get_Height();
break;
case MOUSE_HOTSPOT_MIN:
default:
hotspot.Y = std::clamp(hotspot_y, -MouseShapes->Get_Height(), MouseShapes->Get_Height());
break;
};
if (IsSmall) {

int hotspot_x = control->Hotspot.X;
switch (hotspot_x) {
case MOUSE_HOTSPOT_CENTER:
hotspot.X = MouseShapes->Get_Width() / 2;
break;
case MOUSE_HOTSPOT_MAX:
hotspot.X = MouseShapes->Get_Width();
break;
case MOUSE_HOTSPOT_MIN:
default:
hotspot.X = std::clamp(hotspot_x, -MouseShapes->Get_Width(), MouseShapes->Get_Width());
break;
};

int hotspot_y = control->Hotspot.Y;
switch (hotspot_y) {
case MOUSE_HOTSPOT_CENTER:
hotspot.Y = MouseShapes->Get_Height() / 2;
break;
case MOUSE_HOTSPOT_MAX:
hotspot.Y = MouseShapes->Get_Height();
break;
case MOUSE_HOTSPOT_MIN:
default:
hotspot.Y = std::clamp(hotspot_y, -MouseShapes->Get_Height(), MouseShapes->Get_Height());
break;
};

} else {

int smallhotspot_x = control->SmallHotspot.X;
switch (smallhotspot_x) {
case MOUSE_HOTSPOT_CENTER:
hotspot.X = MouseShapes->Get_Width() / 2;
break;
case MOUSE_HOTSPOT_MAX:
hotspot.X = MouseShapes->Get_Width();
break;
case MOUSE_HOTSPOT_MIN:
default:
hotspot.X = std::clamp(smallhotspot_x, -(MouseShapes->Get_Width()/2), MouseShapes->Get_Width()/2);
break;
};

int smallhotspot_y = control->SmallHotspot.Y;
switch (smallhotspot_y) {
case MOUSE_HOTSPOT_CENTER:
hotspot.Y = MouseShapes->Get_Height() / 2;
break;
case MOUSE_HOTSPOT_MAX:
hotspot.Y = MouseShapes->Get_Height();
break;
case MOUSE_HOTSPOT_MIN:
default:
hotspot.Y = std::clamp(smallhotspot_y, -(MouseShapes->Get_Height()/2), MouseShapes->Get_Height()/2);
break;
};

}

}

Expand Down
Loading

0 comments on commit 7cd63f3

Please sign in to comment.