Skip to content

Commit

Permalink
Minor refactor for consistency
Browse files Browse the repository at this point in the history
Signed-off-by: Jonathan Stone <[email protected]>
  • Loading branch information
jstone-lucasfilm authored Jun 28, 2024
1 parent 8c8b522 commit b74a4b4
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions source/MaterialXGraphEditor/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ const std::string options =
" --mesh [FILENAME] Specify the filename of the OBJ or glTF mesh to be displayed in the graph editor\n"
" --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"
" --uiScale [FACTOR] Manually specify a UI scaling factor\n"
" --captureFilename [FILENAME] Specify the filename to which the first rendered frame should be written\n"
" --uiScale [FACTOR] Manually specify a HiDPI scaling factor\n"
" --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 @@ -66,7 +66,7 @@ int main(int argc, char* const argv[])
mx::FilePathVec libraryFolders;
int viewWidth = 256;
int viewHeight = 256;
float uiScaleFactor = 0.0;
float uiScale = 0.0f;
std::string captureFilename;

for (size_t i = 0; i < tokens.size(); i++)
Expand Down Expand Up @@ -98,17 +98,13 @@ int main(int argc, char* const argv[])
{
parseToken(nextToken, "integer", viewHeight);
}
else if (token == "--captureFilename")
else if (token == "--uiScale")
{
parseToken(nextToken, "string", captureFilename);
parseToken(nextToken, "float", uiScale);
}
else if (token == "--uiScale")
else if (token == "--captureFilename")
{
parseToken(nextToken, "float", uiScaleFactor);
if (uiScaleFactor <= 0.0) {
std::cout << "Scale factor must be a positive, non-zero value. Ignoring the supplied value." << std::endl;
uiScaleFactor = 0.0;
}
parseToken(nextToken, "string", captureFilename);
}
else if (token == "--help")
{
Expand Down Expand Up @@ -209,7 +205,10 @@ int main(int argc, char* const argv[])
float xscale = 1.0f, yscale = 1.0f;
glfwGetMonitorContentScale(monitor, &xscale, &yscale);
ImGuiStyle& style = ImGui::GetStyle();
float uiScale = uiScaleFactor == 0.0 ? (xscale > yscale ? xscale : yscale) : uiScaleFactor;
if (uiScale <= 0.0f)
{
uiScale = (xscale > yscale) ? xscale : yscale;
}
style.ScaleAllSizes(uiScale);
graph->setFontScale(uiScale);
}
Expand Down

0 comments on commit b74a4b4

Please sign in to comment.