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 Content.getInterfaceSize() #642

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
13 changes: 11 additions & 2 deletions hi_scripting/scripting/api/ScriptingApiContent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6504,6 +6504,7 @@ colour(Colour(0xff777777))
setMethod("setWidth", Wrapper::setWidth);
setMethod("createScreenshot", Wrapper::createScreenshot);
setMethod("addVisualGuide", Wrapper::addVisualGuide);
setMethod("getInterfaceSize", Wrapper::getInterfaceSize);
setMethod("makeFrontInterface", Wrapper::makeFrontInterface);
setMethod("makeFullScreenInterface", Wrapper::makeFullScreenInterface);
setMethod("showModalTextInput", Wrapper::showModalTextInput);
Expand Down Expand Up @@ -6769,7 +6770,6 @@ void ScriptingApi::Content::beginInitialization()
registeredKeyPresses.clear();
}


void ScriptingApi::Content::setHeight(int newHeight) noexcept
{
if(height != newHeight)
Expand All @@ -6792,6 +6792,16 @@ void ScriptingApi::Content::setWidth(int newWidth) noexcept
}
};

var ScriptingApi::Content::getInterfaceSize()
{
Array<var> result;

result.add(width);
result.add(height);

return var(result);
};

void ScriptingApi::Content::makeFrontInterface(int newWidth, int newHeight)
{
width = newWidth;
Expand All @@ -6816,7 +6826,6 @@ void ScriptingApi::Content::setToolbarProperties(const var &/*toolbarProperties*
reportScriptError("2017...");
}


void ScriptingApi::Content::setUseHighResolutionForPanels(bool shouldUseDoubleResolution)
{
useDoubleResolution = shouldUseDoubleResolution;
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 @@ -2664,6 +2664,9 @@ class ScriptingApi::Content : public ScriptingObject,
/** Opens a text input box with the given properties and executes the callback when finished. */
void showModalTextInput(var properties, var callback);

/** Returns an array containing the width and height of the interface. */
var getInterfaceSize();

/** Sets this script as main interface with the given size. */
void makeFrontInterface(int width, int height);

Expand Down
15 changes: 14 additions & 1 deletion hi_scripting/scripting/api/ScriptingApiWrappers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ struct ScriptingApi::Content::Wrapper
static var setWidth(const var::NativeFunctionArgs& args);
static var showModalTextInput(const var::NativeFunctionArgs& args);
static var setName(const var::NativeFunctionArgs& args);
static var getInterfaceSize(const var::NativeFunctionArgs& args);
static var makeFrontInterface(const var::NativeFunctionArgs& args);
static var makeFullScreenInterface(const var::NativeFunctionArgs& args);
static var addItem(const var::NativeFunctionArgs& args);
Expand Down Expand Up @@ -572,11 +573,23 @@ var ScriptingApi::Content::Wrapper::setName (const var::NativeFunctionArgs& args
return var();
};

var ScriptingApi::Content::Wrapper::getInterfaceSize (const var::NativeFunctionArgs& args)
{
if (ScriptingApi::Content* thisObject = GET_OBJECT(Content))
{
CHECK_ARGUMENTS("getInterfaceSize()", 0);

return thisObject->getInterfaceSize();
}

return var();
};

var ScriptingApi::Content::Wrapper::makeFrontInterface (const var::NativeFunctionArgs& args)
{
if (ScriptingApi::Content* thisObject = GET_OBJECT(Content))
{
CHECK_ARGUMENTS("setName()", 2);
CHECK_ARGUMENTS("makeFrontInterface()", 2);

thisObject->makeFrontInterface((int)args.arguments[0], (int)args.arguments[1]);
}
Expand Down