UI: Window Title With Version #111998
|
@ -42,6 +42,9 @@ extern "C" {
|
|||
/** User readable version string. */
|
||||
const char *BKE_blender_version_string(void);
|
||||
|
||||
/** As above but does not show patch version. */
|
||||
const char *BKE_blender_version_string_compact(void);
|
||||
|
||||
/** Returns true when version cycle is alpha, otherwise (beta, rc) returns false. */
|
||||
bool BKE_blender_version_is_alpha(void);
|
||||
|
||||
|
|
|
@ -93,6 +93,9 @@ void BKE_blender_free()
|
|||
|
||||
static char blender_version_string[48] = "";
|
||||
|
||||
/* Only includes patch if non-zero. */
|
||||
static char blender_version_string_compact[48] = "";
|
||||
|
||||
static void blender_version_init()
|
||||
{
|
||||
const char *version_cycle = "";
|
||||
|
@ -118,6 +121,12 @@ static void blender_version_init()
|
|||
BLENDER_VERSION % 100,
|
||||
BLENDER_VERSION_PATCH,
|
||||
version_cycle);
|
||||
|
||||
SNPRINTF(blender_version_string_compact,
|
||||
"%d.%01d%s",
|
||||
BLENDER_VERSION / 100,
|
||||
BLENDER_VERSION % 100,
|
||||
version_cycle);
|
||||
Harley marked this conversation as resolved
|
||||
}
|
||||
|
||||
const char *BKE_blender_version_string()
|
||||
|
@ -125,6 +134,11 @@ const char *BKE_blender_version_string()
|
|||
return blender_version_string;
|
||||
}
|
||||
|
||||
const char *BKE_blender_version_string_compact()
|
||||
{
|
||||
return blender_version_string_compact;
|
||||
}
|
||||
|
||||
void BKE_blender_version_blendfile_string_from_values(char *str_buff,
|
||||
const size_t str_buff_maxncpy,
|
||||
const short file_version,
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
|
||||
#include "BLT_translation.h"
|
||||
|
||||
#include "BKE_blender_version.h"
|
||||
#include "BKE_context.h"
|
||||
#include "BKE_global.h"
|
||||
#include "BKE_icons.h"
|
||||
|
@ -481,20 +482,23 @@ void wm_window_title(wmWindowManager *wm, wmWindow *win)
|
|||
* because #WM_window_open always sets window title. */
|
||||
}
|
||||
else if (win->ghostwin) {
|
||||
/* this is set to 1 if you don't have startup.blend open */
|
||||
const char *blendfile_path = BKE_main_blendfile_path_from_global();
|
||||
if (blendfile_path[0] != '\0') {
|
||||
char str[sizeof(Main::filepath) + 24];
|
||||
SNPRINTF(str,
|
||||
"Blender%s [%s%s]",
|
||||
wm->file_saved ? "" : "*",
|
||||
blendfile_path,
|
||||
G_MAIN->recovered ? " (Recovered)" : "");
|
||||
GHOST_SetTitle(static_cast<GHOST_WindowHandle>(win->ghostwin), str);
|
||||
}
|
||||
else {
|
||||
GHOST_SetTitle(static_cast<GHOST_WindowHandle>(win->ghostwin), "Blender");
|
||||
char str[sizeof(Main::filepath) + 24];
|
||||
const char *filepath = BKE_main_blendfile_path_from_global();
|
||||
Harley marked this conversation as resolved
Outdated
Campbell Barton
commented
Use Use `filepath` for full path names.
Campbell Barton
commented
Calling twice (while not a problem) is a bit odd, would just do:
Calling twice (while not a problem) is a bit odd, would just do:
`const char *filepath = BKE_main_blendfile_path_from_global();` then have the ternary operator within the SNPRINTF statement.
|
||||
char basepath[FILE_MAXDIR] = {0};
|
||||
char filename[FILE_MAXFILE] = {0};
|
||||
std::string location;
|
||||
if (filepath[0]) {
|
||||
Harley marked this conversation as resolved
Outdated
Campbell Barton
commented
`SNPRINTF` should still be used here.
|
||||
BLI_path_split_dir_file(filepath, basepath, sizeof(basepath), filename, sizeof(filename));
|
||||
location = " [" + std::string(basepath) + "]";
|
||||
}
|
||||
SNPRINTF(str,
|
||||
"%s %s%s%s - Blender %s",
|
||||
wm->file_saved ? "" : "*",
|
||||
filename[0] ? filename : IFACE_("(Unsaved)"),
|
||||
G_MAIN->recovered ? " (Recovered)" : "",
|
||||
basepath[0] ? location.c_str() : "",
|
||||
BKE_blender_version_string_compact());
|
||||
GHOST_SetTitle(static_cast<GHOST_WindowHandle>(win->ghostwin), str);
|
||||
|
||||
/* Informs GHOST of unsaved changes, to set window modified visual indicator (macOS)
|
||||
* and to give hint of unsaved changes for a user warning mechanism in case of OS application
|
||||
Harley marked this conversation as resolved
Outdated
Brecht Van Lommel
commented
Deduplicate this code with Deduplicate this code with `blender_version_init` in `blender.cc`. If the formatting needs to be different you can construct a second string in that function.
|
||||
|
|
Loading…
Reference in New Issue
I think the patch version should left out entirely from the title.
It's not important to distinguish Blender windows based on that. And showing it only when it is non-zero seems strange to me.