BugFix Allow providing font size as runtime argument

Because with some monitors the resolution is not detected, font appearance can be unsatisfying (#121). User can now set it with --fontsize N argument when launching vimix in command line. Code for managing command line arguments is generaly improved. Man page updated.
This commit is contained in:
Bruno Herbelin
2024-02-05 16:02:38 +01:00
parent 00ff0f532f
commit 47ff1a2dd8
4 changed files with 103 additions and 48 deletions

View File

@@ -17,16 +17,26 @@ performs graphical mixing and blending of several movie clips and computer gener
Its intuitive and hands-on user interface gives direct control on image opacity and shape for producing live graphics during concerts or VJ-ing sessions.
The output image is typically projected full-screen on an external monitor or a projector, but can be streamed live (SRT) or recorded (no audio).
The output image is typically projected full-screen on an external monitor or a projector, but can be streamed live (SRT) or recorded.
.SH OPTIONS
.TP
.BR \-H ", " \-\^\-help
Display usage information for
.B vimix
and exit.
.TP
.BR \-V ", " \-\^\-version
Output the version number of
.B vimix
and exit.
.TP
.BR \-F ", " \-\^\-fontsize N
Set interface font size to specified value N.
.TP
.BR \-C ", " \-\^\-clean
Clean the user stored preferences of
@@ -53,7 +63,7 @@ A user manual and tutorials are available online (https://github.com/brunoherbel
.SH BUGS
.SS "Reporting bugs"
Report bugs and issues on github (https://github.com/brunoherbelin/vimix).
Report bugs and issues on github (https://github.com/brunoherbelin/vimix/issues).
.SH COPYRIGHT
GPL3+ license

View File

@@ -134,7 +134,7 @@ UserInterface::UserInterface()
sessionsavedialog = nullptr;
}
bool UserInterface::Init()
bool UserInterface::Init(int font_size)
{
if (Rendering::manager().mainWindow().window()== nullptr)
return false;
@@ -162,8 +162,11 @@ bool UserInterface::Init()
// Setup Dear ImGui style
ImGuiToolkit::SetAccentColor(static_cast<ImGuiToolkit::accent_color>(Settings::application.accent_color));
// Estalish the base size from the resolution of the monitor
float base_font_size = float(Rendering::manager().mainWindow().pixelsforRealHeight(4.f)) ;
// Read font size from argument
float base_font_size = float(font_size);
// Estalish the base size from the resolution of the monitor for a 4mm height text
if (base_font_size < 1)
base_font_size = float(Rendering::manager().mainWindow().pixelsforRealHeight(4.f));
// at least 8 pixels font size
base_font_size = MAX(base_font_size, 8.f);
// Load Fonts (using resource manager, NB: a temporary copy of the raw data is necessary)

View File

@@ -151,7 +151,7 @@ public:
}
// pre-loop initialization
bool Init();
bool Init(int font_size = 0);
// loop update start new frame
void NewFrame();
// loop update rendering

View File

@@ -62,51 +62,93 @@ int main(int argc, char *argv[])
{
std::string _openfile;
// one extra argument is given
if (argc == 2) {
std::string argument(argv[1]);
if (argument[0] == '-') {
if (argument == "--clean" || argument == "-C") {
// clean start if requested : Save empty settings before loading
Settings::Save();
fprintf(stderr, "%s: clean OK\n", APP_NAME);
return 0;
///
/// Parse arguments
///
int versionRequested = 0;
int testRequested = 0;
int cleanRequested = 0;
int helpRequested = 0;
int fontsizeRequested = 0;
int ret = -1;
for (int i = 1; i < argc; ++i) {
if (strcmp(argv[i], "--version") == 0 || strcmp(argv[i], "-V") == 0) {
versionRequested = 1;
} else if (strcmp(argv[i], "--test") == 0 || strcmp(argv[i], "-T") == 0) {
testRequested = 1;
} else if (strcmp(argv[i], "--clean") == 0 || strcmp(argv[i], "-C") == 0) {
cleanRequested = 1;
} else if (strcmp(argv[i], "--help") == 0 || strcmp(argv[i], "-H") == 0) {
helpRequested = 1;
} else if (strcmp(argv[i], "--fontsize") == 0 || strcmp(argv[i], "-F") == 0) {
// get font size argument
if (i + 1 < argc) {
fontsizeRequested = atoi(argv[i + 1]); // Parse next argument as integer
i++; // Skip the next argument since it's already processed
} else {
fprintf(stderr, "Error: Integer value missing after --fontsize\n");
helpRequested = 1;
}
else if (argument == "--version" || argument == "-V") {
#ifdef VIMIX_GIT
fprintf(stderr, APP_NAME " " VIMIX_GIT " \n");
#else
#ifdef VIMIX_VERSION_MAJOR
fprintf(stderr, "%s: version %d.%d.%d\n", APP_NAME, VIMIX_VERSION_MAJOR, VIMIX_VERSION_MINOR, VIMIX_VERSION_PATCH);
#else
fprintf(stderr, "%s\n", APP_NAME);
#endif
#endif
return 0;
}
else if (argument == "--test" || argument == "-T") {
if ( !Rendering::manager().init() ) {
fprintf(stderr, "%s: test Failed\n", APP_NAME);
return 1;
}
fprintf(stderr, "%s: test OK\n", APP_NAME);
return 0;
}
else {
fprintf(stderr, "%s: unrecognized option '%s'\n"
"Usage: %s [-V, --version][-T, --test][-C, --clean][FILE]\n",
APP_NAME, argument.c_str(), APP_NAME);
return 1;
}
}
else {
// try to open the file
_openfile = argument;
if (!_openfile.empty())
fprintf(stderr, "Loading '%s' ...\n", _openfile.c_str());
} else if ( strchr(argv[i], '-')-argv[i] == 0 ) {
fprintf(stderr, "Error: Invalid argument\n");
helpRequested = 1;
} else {
_openfile = argv[i];
}
}
if (versionRequested) {
#ifdef VIMIX_GIT
printf(APP_NAME " " VIMIX_GIT " \n");
#else
#ifdef VIMIX_VERSION_MAJOR
printf("%s: version %d.%d.%d\n",
APP_NAME,
VIMIX_VERSION_MAJOR,
VIMIX_VERSION_MINOR,
VIMIX_VERSION_PATCH);
#else
printf("%s\n", APP_NAME);
#endif
#endif
ret = 0;
}
if (testRequested) {
if (!Rendering::manager().init()) {
fprintf(stderr, "%s: test Failed\n", argv[0]);
ret = 1;
}
printf("%s: test OK\n", argv[0]);
ret = 0;
}
if (cleanRequested) {
// clean settings : save settings before loading
Settings::Save();
printf("%s: clean OK\n", argv[0]);
ret = 0;
}
if (helpRequested) {
printf("Usage: %s [-H, --help] [-V, --version] [-F N, --fontsize N] [-T, --test] [-C, --clean] [filename]\n",
argv[0]);
printf("Options:\n");
printf(" --help : Display usage information\n");
printf(" --version : Display version information\n");
printf(" --fontsize N : Force rendering font size to specified value N\n");
printf(" --test : Run rendering test\n");
printf(" --clean : Reset user settings\n");
ret = 0;ret = 0;
}
if (ret >= 0)
return ret;
if (!_openfile.empty())
printf("Openning '%s' ...\n", _openfile.c_str());
///
/// Settings
///
@@ -142,7 +184,7 @@ int main(int argc, char *argv[])
///
/// IMGUI INIT
///
if ( !UserInterface::manager().Init() )
if ( !UserInterface::manager().Init( fontsizeRequested ) )
return 1;
///