Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrecht Van Lommel <brechtvanlommel@gmail.com>2018-08-28 16:12:14 +0300
committerBrecht Van Lommel <brechtvanlommel@gmail.com>2018-09-18 20:38:20 +0300
commit84f21c170dda9e503de440c20bc2753002987901 (patch)
treeba079a1930ed2d0d6217679ec0e63ba02ebdfa6f /source/blender/blenlib
parentb08d9f036e05dd3546514239b5e3501b88cbf053 (diff)
Application Templates: make templates more prominent in the UI.
The goal here is to make app templates usable for default templates that we can ship with Blender. These only have a custom startup.blend currently and so are quite limited compared to app templates that fully customize Blender. But still it seems like the same kind of concept where we should be sharing the code and UI. It is useful to be able to save a startup.blend per template, and I can imagine some scripting being useful in the future as well. Changes made: * File > New and Ctrl+N now list the templates, replacing a separate Application Templates menu that was not as easy to discover. * File menu now shows name of active template above Save Startup File and Load Factory Settings to indicate these are saved/loaded per template. * The "Default" template was renamed to "General". * Workspaces can now be added from any of the template startup.blend files when clicking the (+) button in the topbar. * User preferences are now fully shared between app templates, unless the template includes a custom userpref.blend. I think this will be useful in general, not all app templates need their own keymaps for example. * Previously Save User Preferences would save the current app template and then Blender would start using that template by default. I've disabled this, to me it seems it was unintentional, or at least not clear at all that saving user preferences also makes the current Differential Revision: https://developer.blender.org/D3690
Diffstat (limited to 'source/blender/blenlib')
-rw-r--r--source/blender/blenlib/BLI_path_util.h2
-rw-r--r--source/blender/blenlib/intern/path_util.c42
2 files changed, 44 insertions, 0 deletions
diff --git a/source/blender/blenlib/BLI_path_util.h b/source/blender/blenlib/BLI_path_util.h
index e434e83416b..dcfb2c9cbc9 100644
--- a/source/blender/blenlib/BLI_path_util.h
+++ b/source/blender/blenlib/BLI_path_util.h
@@ -108,6 +108,8 @@ void BLI_path_rel(char *file, const char *relfile) ATTR_NONNULL();
bool BLI_path_is_rel(const char *path) ATTR_NONNULL() ATTR_WARN_UNUSED_RESULT;
bool BLI_path_is_unc(const char *path);
+void BLI_path_to_display_name(char *display_name, int maxlen, const char *name) ATTR_NONNULL();
+
#if defined(WIN32)
void BLI_cleanup_unc_16(wchar_t *path_16);
void BLI_cleanup_unc(char *path_16, int maxlen);
diff --git a/source/blender/blenlib/intern/path_util.c b/source/blender/blenlib/intern/path_util.c
index 10ca0fa6cbf..b3ab33312ba 100644
--- a/source/blender/blenlib/intern/path_util.c
+++ b/source/blender/blenlib/intern/path_util.c
@@ -928,6 +928,48 @@ bool BLI_path_frame_check_chars(const char *path)
}
/**
+ * Creates a display string from path to be used menus and the user interface.
+ * Like bpy.path.display_name().
+ */
+void BLI_path_to_display_name(char *display_name, int maxlen, const char *name)
+{
+ /* Strip leading underscores and spaces. */
+ int strip_offset = 0;
+ while (ELEM(name[strip_offset], '_', ' ')) {
+ strip_offset++;
+ }
+
+ BLI_strncpy(display_name, name + strip_offset, maxlen);
+
+ /* Replace underscores with spaces. */
+ BLI_str_replace_char(display_name, '_', ' ');
+
+ /* Strip extension. */
+ BLI_path_extension_replace(display_name, maxlen, "");
+
+ /* Test if string has any upper case characters. */
+ bool all_lower = true;
+ for (int i = 0; display_name[i]; i++) {
+ if (isupper(display_name[i])) {
+ all_lower = false;
+ break;
+ }
+ }
+
+ if (all_lower) {
+ /* For full lowercase string, use title case. */
+ bool prevspace = true;
+ for (int i = 0; display_name[i]; i++) {
+ if (prevspace) {
+ display_name[i] = toupper(display_name[i]);
+ }
+
+ prevspace = isspace(display_name[i]);
+ }
+ }
+}
+
+/**
* If path begins with "//", strips that and replaces it with basepath directory.
*
* \note Also converts drive-letter prefix to something more sensible