Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added panel.getImageSize() #403

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions hi_scripting/scripting/api/ScriptingApiContent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3363,6 +3363,7 @@ struct ScriptingApi::Content::ScriptPanel::Wrapper
API_VOID_METHOD_WRAPPER_2(ScriptPanel, loadImage);
API_VOID_METHOD_WRAPPER_0(ScriptPanel, unloadAllImages);
API_METHOD_WRAPPER_1(ScriptPanel, isImageLoaded);
API_METHOD_WRAPPER_1(ScriptPanel, getImageSize);
API_VOID_METHOD_WRAPPER_1(ScriptPanel, setDraggingBounds);
API_VOID_METHOD_WRAPPER_2(ScriptPanel, setPopupData);
API_VOID_METHOD_WRAPPER_3(ScriptPanel, setValueWithUndo);
Expand Down Expand Up @@ -3473,6 +3474,7 @@ void ScriptingApi::Content::ScriptPanel::init()
ADD_API_METHOD_2(loadImage);
ADD_API_METHOD_0(unloadAllImages);
ADD_API_METHOD_1(isImageLoaded);
ADD_API_METHOD_1(getImageSize);
ADD_API_METHOD_1(setDraggingBounds);
ADD_API_METHOD_2(setPopupData);
ADD_API_METHOD_3(setValueWithUndo);
Expand Down Expand Up @@ -3773,6 +3775,13 @@ bool ScriptingApi::Content::ScriptPanel::isImageLoaded(String prettyName)
return false;
}

var ScriptingApi::Content::ScriptPanel::getImageSize(String imageName)
{
Image img = getLoadedImage(imageName);

return Array<var> (img.getWidth(), img.getHeight());
}

StringArray ScriptingApi::Content::ScriptPanel::getItemList() const
{
String items = getScriptObjectProperty(PopupMenuItems).toString();
Expand Down
3 changes: 3 additions & 0 deletions hi_scripting/scripting/api/ScriptingApiContent.h
Original file line number Diff line number Diff line change
Expand Up @@ -1926,6 +1926,9 @@ class ScriptingApi::Content : public ScriptingObject,
/** Checks if the image has been loaded into the panel */
bool isImageLoaded(String prettyName);

/** Returns the width and height of the image */
var getImageSize(String imageName);

/** If `allowedDragging` is enabled, it will define the boundaries where the panel can be dragged. */
void setDraggingBounds(var area);

Expand Down