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

Add uiScale option to the Graph Editor #1586

Merged
Changes from 4 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
12 changes: 11 additions & 1 deletion source/MaterialXGraphEditor/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ const std::string options =
" --path [FILEPATH] Specify an additional data search path location (e.g. '/projects/MaterialX'). This absolute path will be queried when locating data libraries, XInclude references, and referenced images.\n"
" --library [FILEPATH] Specify an additional data library folder (e.g. 'vendorlib', 'studiolib'). This relative path will be appended to each location in the data search path when loading data libraries.\n"
" --captureFilename [FILENAME] Specify the filename to which the first rendered frame should be written\n"
" --scaleFactor [FACTOR] Manually specify a HiDPI scaling factor\n"
virokannas marked this conversation as resolved.
Show resolved Hide resolved
" --help Display the complete list of command-line options\n";

template <class T> void parseToken(std::string token, std::string type, T& res)
Expand Down Expand Up @@ -65,6 +66,7 @@ int main(int argc, char* const argv[])
mx::FilePathVec libraryFolders;
int viewWidth = 256;
int viewHeight = 256;
float scaleFactor = 0.0;
std::string captureFilename;

for (size_t i = 0; i < tokens.size(); i++)
Expand Down Expand Up @@ -100,6 +102,14 @@ int main(int argc, char* const argv[])
{
parseToken(nextToken, "string", captureFilename);
}
else if (token == "--scaleFactor")
{
parseToken(nextToken, "float", scaleFactor);
virokannas marked this conversation as resolved.
Show resolved Hide resolved
if (scaleFactor <= 0.0) {
std::cout << "Scale factor must be a positive, non-zero value. Ignoring the supplied value." << std::endl;
scaleFactor = 0.0;
}
}
else if (token == "--help")
{
std::cout << " MaterialXGraphEditor version " << mx::getVersionString() << std::endl;
Expand Down Expand Up @@ -199,7 +209,7 @@ int main(int argc, char* const argv[])
float xscale = 1.0f, yscale = 1.0f;
glfwGetMonitorContentScale(monitor, &xscale, &yscale);
ImGuiStyle& style = ImGui::GetStyle();
float dpiScale = xscale > yscale ? xscale : yscale;
float dpiScale = scaleFactor == 0.0 ? (xscale > yscale ? xscale : yscale) : scaleFactor;
style.ScaleAllSizes(dpiScale);
graph->setFontScale(dpiScale);
}
Expand Down