Assets/UI: Improve asset library Preferences UI
* Open File Browser when pressing "Add Asset Library". This just makes sense, since users have to select a directory for the asset library anyway. * Move '+' icon back to the right side of the box. Then it is right under the 'x' icons for each indivdual library, which seems like the more natural place. * Correct tooltip for the "Add Asset Library" operator. * Mark empty asset library name or paths field in red, to make clear that these need to be set.
This commit is contained in:
parent
50e7645211
commit
9ad642c59a
Notes:
blender-bot
2023-02-14 06:21:59 +01:00
Referenced by issue #91863, Correct tooltip for "Add Asset Library"
|
@ -1410,12 +1410,18 @@ class USERPREF_PT_file_paths_asset_libraries(FilePathsPanel, Panel):
|
|||
row.label(text="Path")
|
||||
|
||||
for i, library in enumerate(paths.asset_libraries):
|
||||
name_col.prop(library, "name", text="")
|
||||
row = name_col.row()
|
||||
row.alert = not library.name
|
||||
row.prop(library, "name", text="")
|
||||
|
||||
row = path_col.row()
|
||||
row.prop(library, "path", text="")
|
||||
subrow = row.row()
|
||||
subrow.alert = not library.path
|
||||
subrow.prop(library, "path", text="")
|
||||
row.operator("preferences.asset_library_remove", text="", icon='X', emboss=False).index = i
|
||||
|
||||
row = box.row()
|
||||
row.alignment = 'LEFT'
|
||||
row.alignment = 'RIGHT'
|
||||
row.operator("preferences.asset_library_add", text="", icon='ADD', emboss=False)
|
||||
|
||||
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
#include <string.h>
|
||||
|
||||
#include "DNA_screen_types.h"
|
||||
#include "DNA_space_types.h"
|
||||
|
||||
#include "BLI_listbase.h"
|
||||
#ifdef WIN32
|
||||
|
@ -139,23 +140,51 @@ static void PREFERENCES_OT_autoexec_path_remove(wmOperatorType *ot)
|
|||
/** \name Add Asset Library Operator
|
||||
* \{ */
|
||||
|
||||
static int preferences_asset_library_add_exec(bContext *UNUSED(C), wmOperator *UNUSED(op))
|
||||
static int preferences_asset_library_add_exec(bContext *UNUSED(C), wmOperator *op)
|
||||
{
|
||||
BKE_preferences_asset_library_add(&U, NULL, NULL);
|
||||
char *directory = RNA_string_get_alloc(op->ptr, "directory", NULL, 0, NULL);
|
||||
|
||||
/* NULL is a valid directory path here. A library without path will be created then. */
|
||||
BKE_preferences_asset_library_add(&U, NULL, directory);
|
||||
U.runtime.is_dirty = true;
|
||||
|
||||
/* There's no dedicated notifier for the Preferences. */
|
||||
WM_main_add_notifier(NC_WINDOW, NULL);
|
||||
|
||||
MEM_freeN(directory);
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
||||
static int preferences_asset_library_add_invoke(bContext *C,
|
||||
wmOperator *op,
|
||||
const wmEvent *UNUSED(event))
|
||||
{
|
||||
if (!RNA_struct_property_is_set(op->ptr, "directory")) {
|
||||
WM_event_add_fileselect(C, op);
|
||||
return OPERATOR_RUNNING_MODAL;
|
||||
}
|
||||
|
||||
return preferences_asset_library_add_exec(C, op);
|
||||
}
|
||||
|
||||
static void PREFERENCES_OT_asset_library_add(wmOperatorType *ot)
|
||||
{
|
||||
ot->name = "Add Asset Library";
|
||||
ot->idname = "PREFERENCES_OT_asset_library_add";
|
||||
ot->description =
|
||||
"Add a path to a .blend file to be used by the Asset Browser as source of assets";
|
||||
ot->description = "Add a directory to be used by the Asset Browser as source of assets";
|
||||
|
||||
ot->exec = preferences_asset_library_add_exec;
|
||||
ot->invoke = preferences_asset_library_add_invoke;
|
||||
|
||||
ot->flag = OPTYPE_INTERNAL;
|
||||
|
||||
WM_operator_properties_filesel(ot,
|
||||
FILE_TYPE_FOLDER,
|
||||
FILE_SPECIAL,
|
||||
FILE_OPENFILE,
|
||||
WM_FILESEL_DIRECTORY,
|
||||
FILE_DEFAULTDISPLAY,
|
||||
FILE_SORT_DEFAULT);
|
||||
}
|
||||
|
||||
/** \} */
|
||||
|
|
Loading…
Reference in New Issue