| 4691 | } |
| 4692 | |
| 4693 | void ScriptingApi::Content::ScriptPanel::setMouseCursor(var pathIcon, var colour, var hitPoint) |
| 4694 | { |
| 4695 | getCursorUpdater().enableLockFreeUpdate(getScriptProcessor()->getMainController_()->getGlobalUIUpdater()); |
| 4696 | |
| 4697 | if (auto po = dynamic_cast<ScriptingObjects::PathObject*>(pathIcon.getObject())) |
| 4698 | { |
| 4699 | mouseCursorPath.path = po->getPath(); |
| 4700 | mouseCursorPath.c = ScriptingApi::Content::Helpers::getCleanedObjectColour(colour); |
| 4701 | |
| 4702 | if (auto ar = hitPoint.getArray()) |
| 4703 | { |
| 4704 | if (ar->size() == 2) |
| 4705 | { |
| 4706 | mouseCursorPath.hitPoint = Point<float>((float)((*ar)[0]), (float)((*ar)[1])); |
| 4707 | |
| 4708 | if (!Rectangle<float>(0.0f, 0.0f, 1.0f, 1.0f).contains(mouseCursorPath.hitPoint)) |
| 4709 | reportScriptError("hitPoint must be within [0, 0, 1, 1] area"); |
| 4710 | |
| 4711 | } |
| 4712 | else |
| 4713 | reportScriptError("hitPoint must be a [x, y] array"); |
| 4714 | } |
| 4715 | else |
| 4716 | reportScriptError("hitPoint must be a [x, y] array"); |
| 4717 | } |
| 4718 | else if (pathIcon.isString()) |
| 4719 | { |
| 4720 | auto r = Result::ok(); |
| 4721 | |
| 4722 | auto standardCursor = ApiHelpers::getMouseCursorFromString(pathIcon.toString(), &r); |
| 4723 | mouseCursorPath = MouseCursorInfo(standardCursor); |
| 4724 | |
| 4725 | if(r.failed()) |
| 4726 | reportScriptError(r.getErrorMessage()); |
| 4727 | } |
| 4728 | else |
| 4729 | reportScriptError("pathIcon is not a path"); |
| 4730 | |
| 4731 | getCursorUpdater().sendMessage(sendNotificationAsync, mouseCursorPath); |
| 4732 | } |
| 4733 | |
| 4734 | Rectangle<int> ScriptingApi::Content::ScriptPanel::getBoundsForImage() const |
| 4735 | { |
no test coverage detected